Module: wine Branch: master Commit: 61368e76e4b7a31940310a87b47816acb1eea48f URL: http://source.winehq.org/git/wine.git/?a=commit;h=61368e76e4b7a31940310a87b4...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Jun 16 08:57:30 2015 +0300
ole32: Marshal HBRUSH as remotable handle.
---
dlls/ole32/ole32.spec | 8 ++++---- dlls/ole32/tests/usrmarshal.c | 45 +++++++++++++++++++++++++++++++++++++++++++ dlls/ole32/usrmarshal.c | 1 + 3 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 7019450..b36e683 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -124,10 +124,10 @@ @ stdcall HBITMAP_UserMarshal(ptr ptr ptr) @ stdcall HBITMAP_UserSize(ptr long ptr) @ stdcall HBITMAP_UserUnmarshal(ptr ptr ptr) -@ stub HBRUSH_UserFree -@ stub HBRUSH_UserMarshal -@ stub HBRUSH_UserSize -@ stub HBRUSH_UserUnmarshal +@ stdcall HBRUSH_UserFree(ptr ptr) +@ stdcall HBRUSH_UserMarshal(ptr ptr ptr) +@ stdcall HBRUSH_UserSize(ptr long ptr) +@ stdcall HBRUSH_UserUnmarshal(ptr ptr ptr) @ stdcall HDC_UserFree(ptr ptr) @ stdcall HDC_UserMarshal(ptr ptr ptr) @ stdcall HDC_UserSize(ptr long ptr) diff --git a/dlls/ole32/tests/usrmarshal.c b/dlls/ole32/tests/usrmarshal.c index 6f90c53..b1803df 100644 --- a/dlls/ole32/tests/usrmarshal.c +++ b/dlls/ole32/tests/usrmarshal.c @@ -44,6 +44,11 @@ unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal (ULONG *, unsigned char *, unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *, unsigned char *, HMETAFILEPICT *); void __RPC_USER HMETAFILEPICT_UserFree(ULONG *, HMETAFILEPICT *);
+ULONG __RPC_USER HBRUSH_UserSize(ULONG *, ULONG, HBRUSH *); +unsigned char * __RPC_USER HBRUSH_UserMarshal(ULONG *, unsigned char *, HBRUSH *); +unsigned char * __RPC_USER HBRUSH_UserUnmarshal(ULONG *, unsigned char *, HBRUSH *); +void __RPC_USER HBRUSH_UserFree(ULONG *, HBRUSH *); + static BOOL g_expect_user_alloc; static void * WINAPI user_allocate(SIZE_T size) { @@ -932,6 +937,45 @@ static void test_marshal_HICON(void) DestroyIcon(hIcon); }
+static void test_marshal_HBRUSH(void) +{ + MIDL_STUB_MESSAGE stub_msg; + HBRUSH hBrush, hBrush2; + USER_MARSHAL_CB umcb; + RPC_MESSAGE rpc_msg; + unsigned char *buffer; + LOGBRUSH logbrush; + wireHBRUSH wirehbrush; + ULONG size; + + logbrush.lbStyle = BS_SOLID; + logbrush.lbColor = RGB(0, 0, 0); + logbrush.lbHatch = 0; + + hBrush = CreateBrushIndirect(&logbrush); + ok(hBrush != 0, "CreateBrushIndirect failed\n"); + + init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL); + size = HBRUSH_UserSize(&umcb.Flags, 0, &hBrush); + ok(size == sizeof(*wirehbrush), "Wrong size %d\n", size); + + buffer = HeapAlloc(GetProcessHeap(), 0, size); + init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); + HBRUSH_UserMarshal(&umcb.Flags, buffer, &hBrush); + wirehbrush = (wireHBRUSH)buffer; + ok(wirehbrush->fContext == WDT_INPROC_CALL, "Context should be WDT_INPROC_CALL instead of 0x%08x\n", wirehbrush->fContext); + ok(wirehbrush->u.hInproc == (LONG_PTR)hBrush, "Marshaled value should be %p instead of %x\n", hBrush, wirehbrush->u.hRemote); + + init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); + HBRUSH_UserUnmarshal(&umcb.Flags, buffer, &hBrush2); + ok(hBrush == hBrush2, "Didn't unmarshal properly\n"); + HeapFree(GetProcessHeap(), 0, buffer); + + init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL); + HBRUSH_UserFree(&umcb.Flags, &hBrush2); + DeleteObject(hBrush); +} + START_TEST(usrmarshal) { CoInitialize(NULL); @@ -947,6 +991,7 @@ START_TEST(usrmarshal) test_marshal_SNB(); test_marshal_HDC(); test_marshal_HICON(); + test_marshal_HBRUSH();
CoUninitialize(); } diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index 89f4f4a..957338a 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -343,6 +343,7 @@ IMPL_WIREM_HANDLE(HMENU) IMPL_WIREM_HANDLE(HWND) IMPL_WIREM_HANDLE(HDC) IMPL_WIREM_HANDLE(HICON) +IMPL_WIREM_HANDLE(HBRUSH)
/****************************************************************************** * HGLOBAL_UserSize [OLE32.@]