Rob Shearman : ole32: Add tests for WdtpInterfacePointer_* functions.
Alexandre Julliard
julliard at winehq.org
Tue Nov 27 09:54:28 CST 2007
Module: wine
Branch: master
Commit: c111c2d6859a18331b361aedd6cd5460ed54ef58
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c111c2d6859a18331b361aedd6cd5460ed54ef58
Author: Rob Shearman <rob at codeweavers.com>
Date: Mon Nov 26 22:52:07 2007 +0000
ole32: Add tests for WdtpInterfacePointer_* functions.
Add stubs for these so that the tests link.
---
dlls/ole32/ole32.spec | 8 ++--
dlls/ole32/tests/usrmarshal.c | 113 +++++++++++++++++++++++++++++++++++++++++
dlls/ole32/usrmarshal.c | 94 ++++++++++++++++++++++++++++++++++
3 files changed, 211 insertions(+), 4 deletions(-)
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index 1643484..25a1955 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -267,10 +267,10 @@
@ stub UtConvertDvtd32toDvtd16
@ stub UtGetDvtd16Info
@ stub UtGetDvtd32Info
-@ stub WdtpInterfacePointer_UserFree
-@ stub WdtpInterfacePointer_UserMarshal
-@ stub WdtpInterfacePointer_UserSize
-@ stub WdtpInterfacePointer_UserUnmarshal
+@ stdcall WdtpInterfacePointer_UserFree(ptr)
+@ stdcall WdtpInterfacePointer_UserMarshal(ptr long ptr ptr ptr)
+@ stdcall WdtpInterfacePointer_UserSize(ptr long ptr long ptr)
+@ stdcall WdtpInterfacePointer_UserUnmarshal(ptr ptr ptr ptr)
@ stdcall WriteClassStg(ptr ptr)
@ stdcall WriteClassStm(ptr ptr)
@ stdcall WriteFmtUserTypeStg(ptr long ptr)
diff --git a/dlls/ole32/tests/usrmarshal.c b/dlls/ole32/tests/usrmarshal.c
index 28c6687..281f9a0 100644
--- a/dlls/ole32/tests/usrmarshal.c
+++ b/dlls/ole32/tests/usrmarshal.c
@@ -366,6 +366,118 @@ static void test_marshal_HMETAFILEPICT(void)
HMETAFILEPICT_UserFree(&flags, &hmfp2);
}
+static HRESULT WINAPI Test_IUnknown_QueryInterface(
+ LPUNKNOWN iface,
+ REFIID riid,
+ LPVOID *ppvObj)
+{
+ if (ppvObj == NULL) return E_POINTER;
+
+ if (IsEqualGUID(riid, &IID_IUnknown))
+ {
+ *ppvObj = (LPVOID)iface;
+ IUnknown_AddRef(iface);
+ return S_OK;
+ }
+
+ *ppvObj = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI Test_IUnknown_AddRef(LPUNKNOWN iface)
+{
+ return 2; /* non-heap-based object */
+}
+
+static ULONG WINAPI Test_IUnknown_Release(LPUNKNOWN iface)
+{
+ return 1; /* non-heap-based object */
+}
+
+static const IUnknownVtbl TestUnknown_Vtbl =
+{
+ Test_IUnknown_QueryInterface,
+ Test_IUnknown_AddRef,
+ Test_IUnknown_Release,
+};
+
+static IUnknown Test_Unknown = { &TestUnknown_Vtbl };
+
+ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *, ULONG, ULONG, IUnknown *, REFIID);
+unsigned char * __RPC_USER WdtpInterfacePointer_UserMarshal(ULONG *, ULONG, unsigned char *, IUnknown *, REFIID);
+unsigned char * __RPC_USER WdtpInterfacePointer_UserUnmarshal(ULONG *, unsigned char *, IUnknown **, REFIID);
+void __RPC_USER WdtpInterfacePointer_UserFree(IUnknown *);
+
+static void test_marshal_WdtpInterfacePointer(void)
+{
+ unsigned char *buffer, *buffer_end;
+ ULONG size;
+ MIDL_STUB_MESSAGE stubmsg;
+ USER_MARSHAL_CB umcb;
+ IUnknown *unk;
+ IUnknown *unk2;
+ unsigned char *wireip;
+ const IID *iid;
+
+ memset(&stubmsg, 0xcc, sizeof(stubmsg));
+ stubmsg.dwDestContext = MSHCTX_INPROC;
+ stubmsg.pvDestContext = NULL;
+
+ memset(&umcb, 0xcc, sizeof(umcb));
+ umcb.Flags = MAKELONG(MSHCTX_INPROC, NDR_LOCAL_DATA_REPRESENTATION);
+ umcb.pStubMsg = &stubmsg;
+
+ /* shows that the WdtpInterfacePointer functions don't marshal anything for
+ * NULL pointers, so code using these functions must handle that case
+ * itself */
+ unk = NULL;
+ size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown);
+ ok(size == 0, "size should be 0 bytes, not %d\n", size);
+ buffer = HeapAlloc(GetProcessHeap(), 0, size);
+ buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown);
+ wireip = buffer;
+ HeapFree(GetProcessHeap(), 0, buffer);
+
+ unk = &Test_Unknown;
+ size = WdtpInterfacePointer_UserSize(&umcb.Flags, umcb.Flags, 0, unk, &IID_IUnknown);
+ todo_wine
+ ok(size == 108, "size should be 108 bytes, not %d\n", size);
+ buffer = HeapAlloc(GetProcessHeap(), 0, size);
+ buffer_end = WdtpInterfacePointer_UserMarshal(&umcb.Flags, umcb.Flags, buffer, unk, &IID_IUnknown);
+ wireip = buffer;
+ if (size >= 28)
+ {
+ ok(*(DWORD *)wireip == 0x44, "wireip + 0x0 should be 0x4c instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ ok(*(DWORD *)wireip == 0x44, "wireip + 0x8 should be 0x4c instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ ok(*(DWORD *)wireip == 0x574f454d /* 'MEOW' */, "wireip + 0xc should be 0x574f454d instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ ok(*(DWORD *)wireip == 0x1, "wireip + 0x10 should be 0x1 instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ iid = (const IID *)buffer;
+ ok(!IsEqualIID(iid, &IID_IUnknown),
+ "wireip + 0x14 should be IID_IUnknown instead of {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
+ iid->Data1, iid->Data2, iid->Data3,
+ iid->Data4[0], iid->Data4[1], iid->Data4[2], iid->Data4[3],
+ iid->Data4[4], iid->Data4[5], iid->Data4[6], iid->Data4[7]);
+ ok(*(DWORD *)wireip == 0, "wireip + 0x14 should be 0 instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(IID);
+ ok(*(DWORD *)wireip == 0, "wireip + 0x20 should be 0 instead of 0x%08x\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ ok(*(DWORD *)wireip == 5, "wireip + 0x24 should be 5 instead of %d\n", *(DWORD *)wireip);
+ wireip += sizeof(DWORD);
+ /* the rest is dynamic so can't really be tested */
+ }
+
+ unk2 = NULL;
+ WdtpInterfacePointer_UserUnmarshal(&umcb.Flags, buffer, &unk2, &IID_IUnknown);
+ todo_wine
+ ok(unk2 != NULL, "IUnknown object didn't unmarshal properly\n");
+ HeapFree(GetProcessHeap(), 0, buffer);
+ WdtpInterfacePointer_UserFree(unk2);
+}
+
START_TEST(usrmarshal)
{
CoInitialize(NULL);
@@ -376,6 +488,7 @@ START_TEST(usrmarshal)
test_marshal_HENHMETAFILE();
test_marshal_HMETAFILE();
test_marshal_HMETAFILEPICT();
+ test_marshal_WdtpInterfacePointer();
CoUninitialize();
}
diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c
index a1e1d89..c25b86a 100644
--- a/dlls/ole32/usrmarshal.c
+++ b/dlls/ole32/usrmarshal.c
@@ -1434,6 +1434,100 @@ void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
}
/******************************************************************************
+ * WdtpInterfacePointer_UserSize [OLE32.@]
+ *
+ * Calculates the buffer size required to marshal an interface pointer.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * RealFlags [I] The MSHCTX to use when marshaling the interface.
+ * punk [I] Interface pointer to size.
+ * StartingSize [I] Starting size of the buffer. This value is added on to
+ * the buffer size required for the clip format.
+ * riid [I] ID of interface to size.
+ *
+ * RETURNS
+ * The buffer size required to marshal an interface pointer plus the starting size.
+ *
+ * NOTES
+ * Even though the function is documented to take a pointer to a ULONG in
+ * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
+ * the first parameter is a ULONG.
+ */
+ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, IUnknown *punk, ULONG StartingSize, REFIID riid)
+{
+ FIXME("(%s, 0%x, %p, %d, %s): stub\n", debugstr_user_flags(pFlags), RealFlags, punk, StartingSize, debugstr_guid(riid));
+ return 0;
+}
+
+/******************************************************************************
+ * WdtpInterfacePointer_UserMarshal [OLE32.@]
+ *
+ * Marshals an interface pointer into a buffer.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * RealFlags [I] The MSHCTX to use when marshaling the interface.
+ * pBuffer [I] Buffer to marshal the clip format into.
+ * punk [I] Interface pointer to marshal.
+ * riid [I] ID of interface to marshal.
+ *
+ * RETURNS
+ * The end of the marshaled data in the buffer.
+ *
+ * NOTES
+ * Even though the function is documented to take a pointer to a ULONG in
+ * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
+ * the first parameter is a ULONG.
+ */
+unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
+{
+ FIXME("(%s, 0x%x, %p, &%p, %s): stub\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
+ return NULL;
+}
+
+/******************************************************************************
+ * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
+ *
+ * Unmarshals an interface pointer from a buffer.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * pBuffer [I] Buffer to marshal the clip format from.
+ * ppunk [I/O] Address that receives the unmarshaled interface pointer.
+ * riid [I] ID of interface to unmarshal.
+ *
+ * RETURNS
+ * The end of the marshaled data in the buffer.
+ *
+ * NOTES
+ * Even though the function is documented to take a pointer to an ULONG in
+ * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
+ * the first parameter is an ULONG.
+ */
+unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
+{
+ FIXME("(%s, %p, %p, %s): stub\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
+ return NULL;
+}
+
+/******************************************************************************
+ * WdtpInterfacePointer_UserFree [OLE32.@]
+ *
+ * Frees an unmarshaled interface pointer.
+ *
+ * PARAMS
+ * punk [I] Interface pointer to free.
+ *
+ * RETURNS
+ * Nothing.
+ */
+void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
+{
+ FIXME("(%p): stub\n", punk);
+}
+
+/******************************************************************************
* STGMEDIUM_UserSize [OLE32.@]
*
* Calculates the buffer size required to marshal an STGMEDIUM.
More information about the wine-cvs
mailing list