ole32: Add in-process user marshalling for bitmaps.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2017-12-07 11:20:10 -06:00 committed by Alexandre Julliard
parent a3c162da5b
commit 2812086ebf
2 changed files with 76 additions and 9 deletions

View File

@ -1190,6 +1190,39 @@ static void test_marshal_HBRUSH(void)
DeleteObject(hBrush);
}
static void test_marshal_HBITMAP(void)
{
static BYTE bmp_bits[1024];
MIDL_STUB_MESSAGE stub_msg;
HBITMAP hBitmap, hBitmap2;
USER_MARSHAL_CB umcb;
RPC_MESSAGE rpc_msg;
unsigned char *buffer, *buffer_end;
ULONG size;
hBitmap = CreateBitmap(16, 16, 1, 1, bmp_bits);
ok(hBitmap != 0, "CreateBitmap failed\n");
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_INPROC);
size = HBITMAP_UserSize(&umcb.Flags, 1, &hBitmap);
ok(size == 0xc, "Wrong size %d\n", size);
buffer = HeapAlloc(GetProcessHeap(), 0, size + 4);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC);
buffer_end = HBITMAP_UserMarshal(&umcb.Flags, buffer + 1, &hBitmap);
ok(buffer_end == buffer + 0xc, "HBITMAP_UserMarshal() returned wrong size %d\n", (LONG)(buffer_end - buffer));
ok(*(ULONG *)(buffer + 0x4) == WDT_INPROC_CALL, "Context should be WDT_INPROC_CALL instead of 0x%08x\n", *(ULONG *)(buffer + 0x4));
ok(*(ULONG *)(buffer + 0x8) == (ULONG)(ULONG_PTR)hBitmap, "wirestgm + 0x4 should be bitmap handle instead of 0x%08x\n", *(ULONG *)(buffer + 0x8));
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC);
HBITMAP_UserUnmarshal(&umcb.Flags, buffer + 1, &hBitmap2);
ok(hBitmap2 != NULL, "Didn't unmarshal properly\n");
HeapFree(GetProcessHeap(), 0, buffer);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_INPROC);
HBITMAP_UserFree(&umcb.Flags, &hBitmap2);
DeleteObject(hBitmap);
}
struct obj
{
IDataObject IDataObject_iface;
@ -1353,6 +1386,7 @@ START_TEST(usrmarshal)
test_marshal_HDC();
test_marshal_HICON();
test_marshal_HBRUSH();
test_marshal_HBITMAP();
test_GetDataHere_Proxy();

View File

@ -584,10 +584,17 @@ void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
* the first parameter is a ULONG.
* This function is only intended to be called by the RPC runtime.
*/
ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
ULONG __RPC_USER HBITMAP_UserSize(ULONG *flags, ULONG size, HBITMAP *bmp)
{
FIXME(":stub\n");
return StartingSize;
TRACE("(%s, %d, %p)\n", debugstr_user_flags(flags), size, *bmp);
ALIGN_LENGTH(size, 3);
size += sizeof(ULONG);
if (LOWORD(*flags) == MSHCTX_INPROC)
size += sizeof(ULONG);
return size;
}
/******************************************************************************
@ -609,10 +616,20 @@ ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *ph
* the first parameter is a ULONG.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
{
FIXME(":stub\n");
return pBuffer;
TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, *bmp);
ALIGN_POINTER(buffer, 3);
if (LOWORD(*flags) == MSHCTX_INPROC)
{
*(ULONG *)buffer = WDT_INPROC_CALL;
buffer += sizeof(ULONG);
*(ULONG *)buffer = (ULONG)(ULONG_PTR)*bmp;
buffer += sizeof(ULONG);
}
return buffer;
}
/******************************************************************************
@ -634,10 +651,26 @@ unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBu
* the first parameter is an ULONG.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
{
FIXME(":stub\n");
return pBuffer;
ULONG context;
TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, bmp);
ALIGN_POINTER(buffer, 3);
context = *(ULONG *)buffer;
buffer += sizeof(ULONG);
if (context == WDT_INPROC_CALL)
{
*bmp = *(HBITMAP *)buffer;
buffer += sizeof(*bmp);
}
else
RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
return buffer;
}
/******************************************************************************