Commit affe9a1e authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32/tests: Show that it's the loword of the separate flag parameter that…

ole32/tests: Show that it's the loword of the separate flag parameter that determines the marshalling context.
parent fcf86b61
...@@ -502,7 +502,7 @@ unsigned char * __RPC_USER WdtpInterfacePointer_UserMarshal(ULONG *, ULONG, unsi ...@@ -502,7 +502,7 @@ unsigned char * __RPC_USER WdtpInterfacePointer_UserMarshal(ULONG *, ULONG, unsi
unsigned char * __RPC_USER WdtpInterfacePointer_UserUnmarshal(ULONG *, unsigned char *, IUnknown **, REFIID); unsigned char * __RPC_USER WdtpInterfacePointer_UserUnmarshal(ULONG *, unsigned char *, IUnknown **, REFIID);
void __RPC_USER WdtpInterfacePointer_UserFree(IUnknown *); void __RPC_USER WdtpInterfacePointer_UserFree(IUnknown *);
static void test_marshal_WdtpInterfacePointer(void) static void marshal_WdtpInterfacePointer(DWORD umcb_ctx, DWORD ctx)
{ {
USER_MARSHAL_CB umcb; USER_MARSHAL_CB umcb;
MIDL_STUB_MESSAGE stub_msg; MIDL_STUB_MESSAGE stub_msg;
...@@ -512,52 +512,60 @@ static void test_marshal_WdtpInterfacePointer(void) ...@@ -512,52 +512,60 @@ static void test_marshal_WdtpInterfacePointer(void)
IUnknown *unk; IUnknown *unk;
IUnknown *unk2; IUnknown *unk2;
unsigned char *wireip; unsigned char *wireip;
DWORD expected_size;
/* The marshalled data depends on the LOWORD of the ctx */
expected_size = (LOWORD(ctx) == MSHCTX_INPROC) ? 0x4c : 0xb4;
/* shows that the WdtpInterfacePointer functions don't marshal anything for /* shows that the WdtpInterfacePointer functions don't marshal anything for
* NULL pointers, so code using these functions must handle that case * NULL pointers, so code using these functions must handle that case
* itself */ * itself */
unk = NULL; unk = NULL;
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_INPROC); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, umcb_ctx);
size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown); size = WdtpInterfacePointer_UserSize(&umcb.Flags, ctx, 0, unk, &IID_IUnknown);
ok(size == 0, "size should be 0 bytes, not %d\n", size); ok(size == 0, "size should be 0 bytes, not %d\n", size);
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = HeapAlloc(GetProcessHeap(), 0, size);
buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown); buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, ctx, buffer, unk, &IID_IUnknown);
wireip = buffer; wireip = buffer;
HeapFree(GetProcessHeap(), 0, buffer); HeapFree(GetProcessHeap(), 0, buffer);
unk = &Test_Unknown; unk = &Test_Unknown;
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_INPROC); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, umcb_ctx);
size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown); size = WdtpInterfacePointer_UserSize(&umcb.Flags, ctx, 0, unk, &IID_IUnknown);
todo_wine todo_wine
ok(size >= 0x4c, "size should be >= 0x4c bytes, not %d\n", size); ok(size >= expected_size, "size should be >= %x bytes, not %x\n", expected_size, size);
trace("WdtpInterfacePointer_UserSize returned %d\n", size); trace("WdtpInterfacePointer_UserSize returned %d\n", size);
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = HeapAlloc(GetProcessHeap(), 0, size);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, umcb_ctx);
buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown); buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, ctx, buffer, unk, &IID_IUnknown);
wireip = buffer; wireip = buffer;
if (size >= 0x4c) if(size)
{ {
HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0); HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
IStream *stm; IStream *stm;
void *ptr; void *ptr;
LARGE_INTEGER pos; LARGE_INTEGER pos;
DWORD h_size; DWORD h_size, marshal_size;
ok(buffer_end == buffer + 0x4c, "buffer_end %p buffer %p\n", buffer_end, buffer); ok(buffer_end == buffer + expected_size, "buffer_end %p buffer %p (diff %x)\n", buffer_end, buffer, buffer_end - buffer);
ok(*(DWORD *)wireip == 0x44, "wireip + 0x0 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip);
marshal_size = buffer_end - buffer - 2 * sizeof(DWORD);
ok(*(DWORD *)wireip == marshal_size, "wireip + 0x0 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip);
wireip += sizeof(DWORD); wireip += sizeof(DWORD);
ok(*(DWORD *)wireip == 0x44, "wireip + 0x4 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip); ok(*(DWORD *)wireip == marshal_size, "wireip + 0x4 should be 0x44 instead of 0x%08x\n", *(DWORD *)wireip);
wireip += sizeof(DWORD); wireip += sizeof(DWORD);
/* The remaining 0x44 bytes are the result of CoMarshalInterface */ /* The remaining 0x44/0xac bytes are the result of CoMarshalInterface */
CreateStreamOnHGlobal(h, TRUE, &stm); CreateStreamOnHGlobal(h, TRUE, &stm);
CoMarshalInterface(stm, &IID_IUnknown, unk, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL); CoMarshalInterface(stm, &IID_IUnknown, unk, LOWORD(ctx), NULL, MSHLFLAGS_NORMAL);
h_size = GlobalSize(h); h_size = GlobalSize(h);
ok(h_size == 0x44, "size %x\n", h_size); ok(h_size == marshal_size, "size %x\n", h_size);
ptr = GlobalLock(h); ptr = GlobalLock(h);
ok(!memcmp(ptr, wireip, 0x44), "buffer mismatch\n"); ok(!memcmp(ptr, wireip, h_size), "buffer mismatch\n");
GlobalUnlock(h); GlobalUnlock(h);
pos.QuadPart = 0; pos.QuadPart = 0;
IStream_Seek(stm, pos, STREAM_SEEK_SET, NULL); IStream_Seek(stm, pos, STREAM_SEEK_SET, NULL);
...@@ -566,7 +574,7 @@ static void test_marshal_WdtpInterfacePointer(void) ...@@ -566,7 +574,7 @@ static void test_marshal_WdtpInterfacePointer(void)
} }
unk2 = NULL; unk2 = NULL;
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_INPROC); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, umcb_ctx);
WdtpInterfacePointer_UserUnmarshal(&umcb.Flags, buffer, &unk2, &IID_IUnknown); WdtpInterfacePointer_UserUnmarshal(&umcb.Flags, buffer, &unk2, &IID_IUnknown);
todo_wine todo_wine
ok(unk2 != NULL, "IUnknown object didn't unmarshal properly\n"); ok(unk2 != NULL, "IUnknown object didn't unmarshal properly\n");
...@@ -575,6 +583,25 @@ static void test_marshal_WdtpInterfacePointer(void) ...@@ -575,6 +583,25 @@ static void test_marshal_WdtpInterfacePointer(void)
WdtpInterfacePointer_UserFree(unk2); WdtpInterfacePointer_UserFree(unk2);
} }
static void test_marshal_WdtpInterfacePointer(void)
{
/*
* There are two places where we can pass the marshalling ctx: as
* part of the umcb and as a separate flag. The loword of that
* separate flag field is what matters.
*/
/* All three are marshalled as inproc */
marshal_WdtpInterfacePointer(MSHCTX_INPROC, MSHCTX_INPROC);
marshal_WdtpInterfacePointer(MSHCTX_DIFFERENTMACHINE, MSHCTX_INPROC);
marshal_WdtpInterfacePointer(MSHCTX_INPROC, MAKELONG(MSHCTX_INPROC, 0xffff));
/* All three are marshalled as remote */
marshal_WdtpInterfacePointer(MSHCTX_INPROC, MSHCTX_DIFFERENTMACHINE);
marshal_WdtpInterfacePointer(MSHCTX_DIFFERENTMACHINE, MSHCTX_DIFFERENTMACHINE);
marshal_WdtpInterfacePointer(MSHCTX_INPROC, MAKELONG(MSHCTX_DIFFERENTMACHINE, 0xffff));
}
START_TEST(usrmarshal) START_TEST(usrmarshal)
{ {
CoInitialize(NULL); CoInitialize(NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment