[PATCH 1/5] combase: Move HMETAFILEPICT marshalling functions.
Nikolay Sivov
nsivov at codeweavers.com
Tue Aug 4 01:38:15 CDT 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/combase/Makefile.in | 2 +-
dlls/combase/combase.spec | 4 +
dlls/combase/usrmarshal.c | 230 ++++++++++++++++++++++++++++++++++++++
dlls/ole32/ole32.spec | 8 +-
dlls/ole32/usrmarshal.c | 225 +------------------------------------
5 files changed, 243 insertions(+), 226 deletions(-)
diff --git a/dlls/combase/Makefile.in b/dlls/combase/Makefile.in
index 954dc629973..24793205d5d 100644
--- a/dlls/combase/Makefile.in
+++ b/dlls/combase/Makefile.in
@@ -1,6 +1,6 @@
MODULE = combase.dll
IMPORTLIB = combase
-IMPORTS = advapi32 ole32 user32 gdi32 uuid
+IMPORTS = advapi32 ole32 user32 gdi32 uuid rpcrt4
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index 9d0bad29f0d..359f1774336 100644
--- a/dlls/combase/combase.spec
+++ b/dlls/combase/combase.spec
@@ -205,6 +205,10 @@
@ stdcall HMENU_UserMarshal(ptr ptr ptr)
@ stdcall HMENU_UserSize(ptr long ptr)
@ stdcall HMENU_UserUnmarshal(ptr ptr ptr)
+@ stdcall HMETAFILEPICT_UserFree(ptr ptr)
+@ stdcall HMETAFILEPICT_UserMarshal(ptr ptr ptr)
+@ stdcall HMETAFILEPICT_UserSize(ptr long ptr)
+@ stdcall HMETAFILEPICT_UserUnmarshal(ptr ptr ptr)
@ stdcall HPALETTE_UserFree(ptr ptr)
@ stdcall HPALETTE_UserMarshal(ptr ptr ptr)
@ stdcall HPALETTE_UserSize(ptr long ptr)
diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c
index c88e8c57cd0..725b29aa28d 100644
--- a/dlls/combase/usrmarshal.c
+++ b/dlls/combase/usrmarshal.c
@@ -23,16 +23,26 @@
#define NONAMELESSUNION
#include "ole2.h"
+#include "rpc.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
+ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf);
+unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf);
+unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf);
+void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf);
+
#define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
#define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
#define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
#define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
+#define USER_MARSHAL_PTR_PREFIX \
+ ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
+ ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
+
static const char* debugstr_user_flags(ULONG *pFlags)
{
char buf[12];
@@ -640,6 +650,226 @@ void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
FIXME(":stub\n");
}
+/******************************************************************************
+ * HMETAFILEPICT_UserSize (combase.@)
+ *
+ * Calculates the buffer size required to marshal an metafile pict.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * StartingSize [I] Starting size of the buffer. This value is added on to
+ * the buffer size required for the clip format.
+ * phMfp [I] Metafile pict to size.
+ *
+ * RETURNS
+ * The buffer size required to marshal a metafile pict 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.
+ * This function is only intended to be called by the RPC runtime.
+ */
+ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG size, HMETAFILEPICT *phMfp)
+{
+ TRACE("%s, %u, &%p.\n", debugstr_user_flags(pFlags), size, *phMfp);
+
+ ALIGN_LENGTH(size, 3);
+
+ size += sizeof(ULONG);
+
+ if(LOWORD(*pFlags) == MSHCTX_INPROC)
+ size += sizeof(HMETAFILEPICT);
+ else
+ {
+ size += sizeof(ULONG);
+
+ if (*phMfp)
+ {
+ METAFILEPICT *mfpict = GlobalLock(*phMfp);
+
+ /* FIXME: raise an exception if mfpict is NULL? */
+ size += 3 * sizeof(ULONG);
+ size += sizeof(ULONG);
+
+ size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
+
+ GlobalUnlock(*phMfp);
+ }
+ }
+
+ return size;
+}
+
+/******************************************************************************
+ * HMETAFILEPICT_UserMarshal (combase.@)
+ *
+ * Marshals a metafile pict into a buffer.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * pBuffer [I] Buffer to marshal the clip format into.
+ * phMfp [I] Metafile pict 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.
+ * This function is only intended to be called by the RPC runtime.
+ */
+unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
+{
+ TRACE("%s, %p, &%p.\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
+
+ ALIGN_POINTER(pBuffer, 3);
+
+ if (LOWORD(*pFlags) == MSHCTX_INPROC)
+ {
+ if (sizeof(HMETAFILEPICT) == 8)
+ *(ULONG *)pBuffer = WDT_INPROC64_CALL;
+ else
+ *(ULONG *)pBuffer = WDT_INPROC_CALL;
+ pBuffer += sizeof(ULONG);
+ *(HMETAFILEPICT *)pBuffer = *phMfp;
+ pBuffer += sizeof(HMETAFILEPICT);
+ }
+ else
+ {
+ *(ULONG *)pBuffer = WDT_REMOTE_CALL;
+ pBuffer += sizeof(ULONG);
+ *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
+ pBuffer += sizeof(ULONG);
+
+ if (*phMfp)
+ {
+ METAFILEPICT *mfpict = GlobalLock(*phMfp);
+ remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
+
+ /* FIXME: raise an exception if mfpict is NULL? */
+ remmfpict->mm = mfpict->mm;
+ remmfpict->xExt = mfpict->xExt;
+ remmfpict->yExt = mfpict->yExt;
+ pBuffer += 3 * sizeof(ULONG);
+ *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
+ pBuffer += sizeof(ULONG);
+
+ pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
+
+ GlobalUnlock(*phMfp);
+ }
+ }
+ return pBuffer;
+}
+
+/******************************************************************************
+ * HMETAFILEPICT_UserUnmarshal (combase.@)
+ *
+ * Unmarshals an metafile pict from a buffer.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * pBuffer [I] Buffer to marshal the clip format from.
+ * phMfp [O] Address that receive the unmarshaled metafile pict.
+ *
+ * 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.
+ * This function is only intended to be called by the RPC runtime.
+ */
+unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
+{
+ ULONG fContext;
+
+ TRACE("%s, %p, %p.\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
+
+ ALIGN_POINTER(pBuffer, 3);
+
+ fContext = *(ULONG *)pBuffer;
+ pBuffer += sizeof(ULONG);
+
+ if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
+ {
+ *phMfp = *(HMETAFILEPICT *)pBuffer;
+ pBuffer += sizeof(HMETAFILEPICT);
+ }
+ else
+ {
+ ULONG handle = *(ULONG *)pBuffer;
+ pBuffer += sizeof(ULONG);
+ *phMfp = NULL;
+
+ if(handle)
+ {
+ METAFILEPICT *mfpict;
+ const remoteMETAFILEPICT *remmfpict;
+ ULONG user_marshal_prefix;
+
+ remmfpict = (const remoteMETAFILEPICT *)pBuffer;
+
+ *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
+ if (!*phMfp)
+ RpcRaiseException(E_OUTOFMEMORY);
+
+ mfpict = GlobalLock(*phMfp);
+ mfpict->mm = remmfpict->mm;
+ mfpict->xExt = remmfpict->xExt;
+ mfpict->yExt = remmfpict->yExt;
+ pBuffer += 3 * sizeof(ULONG);
+ user_marshal_prefix = *(ULONG *)pBuffer;
+ pBuffer += sizeof(ULONG);
+
+ if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
+ RpcRaiseException(RPC_X_INVALID_TAG);
+
+ pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
+
+ GlobalUnlock(*phMfp);
+ }
+ }
+ return pBuffer;
+}
+
+/******************************************************************************
+ * HMETAFILEPICT_UserFree (combase.@)
+ *
+ * Frees an unmarshaled metafile pict.
+ *
+ * PARAMS
+ * pFlags [I] Flags. See notes.
+ * phMfp [I] Metafile pict to free.
+ *
+ * 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.
+ * This function is only intended to be called by the RPC runtime.
+ */
+void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
+{
+ TRACE("%s, &%p.\n", debugstr_user_flags(pFlags), *phMfp);
+
+ if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
+ {
+ METAFILEPICT *mfpict;
+
+ mfpict = GlobalLock(*phMfp);
+ /* FIXME: raise an exception if mfpict is NULL? */
+ HMETAFILE_UserFree(pFlags, &mfpict->hMF);
+ GlobalUnlock(*phMfp);
+
+ GlobalFree(*phMfp);
+ }
+}
/******************************************************************************
* WdtpInterfacePointer_UserSize (combase.@)
*
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index 97618e08935..cabbb480b43 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -155,10 +155,10 @@
@ stdcall HMENU_UserMarshal(ptr ptr ptr) combase.HMENU_UserMarshal
@ stdcall HMENU_UserSize(ptr long ptr) combase.HMENU_UserSize
@ stdcall HMENU_UserUnmarshal(ptr ptr ptr) combase.HMENU_UserUnmarshal
-@ stdcall HMETAFILEPICT_UserFree(ptr ptr)
-@ stdcall HMETAFILEPICT_UserMarshal(ptr ptr ptr)
-@ stdcall HMETAFILEPICT_UserSize(ptr long ptr)
-@ stdcall HMETAFILEPICT_UserUnmarshal(ptr ptr ptr)
+@ stdcall HMETAFILEPICT_UserFree(ptr ptr) combase.HMETAFILEPICT_UserFree
+@ stdcall HMETAFILEPICT_UserMarshal(ptr ptr ptr) combase.HMETAFILEPICT_UserMarshal
+@ stdcall HMETAFILEPICT_UserSize(ptr long ptr) combase.HMETAFILEPICT_UserSize
+@ stdcall HMETAFILEPICT_UserUnmarshal(ptr ptr ptr) combase.HMETAFILEPICT_UserUnmarshal
@ stdcall HMETAFILE_UserFree(ptr ptr)
@ stdcall HMETAFILE_UserMarshal(ptr ptr ptr)
@ stdcall HMETAFILE_UserSize(ptr long ptr)
diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c
index 694ef60764f..7319badc97a 100644
--- a/dlls/ole32/usrmarshal.c
+++ b/dlls/ole32/usrmarshal.c
@@ -52,6 +52,10 @@ ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, U
unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer,
IUnknown *punk, REFIID riid);
unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid);
+ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG size, HMETAFILEPICT *phMfp);
+unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp);
+unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp);
+void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp);
static const char* debugstr_user_flags(ULONG *pFlags)
{
@@ -769,227 +773,6 @@ void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
DeleteEnhMetaFile(*phEmf);
}
-/******************************************************************************
- * HMETAFILEPICT_UserSize [OLE32.@]
- *
- * Calculates the buffer size required to marshal an metafile pict.
- *
- * PARAMS
- * pFlags [I] Flags. See notes.
- * StartingSize [I] Starting size of the buffer. This value is added on to
- * the buffer size required for the clip format.
- * phMfp [I] Metafile pict to size.
- *
- * RETURNS
- * The buffer size required to marshal a metafile pict 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.
- * This function is only intended to be called by the RPC runtime.
- */
-ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG size, HMETAFILEPICT *phMfp)
-{
- TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), size, *phMfp);
-
- ALIGN_LENGTH(size, 3);
-
- size += sizeof(ULONG);
-
- if(LOWORD(*pFlags) == MSHCTX_INPROC)
- size += sizeof(HMETAFILEPICT);
- else
- {
- size += sizeof(ULONG);
-
- if (*phMfp)
- {
- METAFILEPICT *mfpict = GlobalLock(*phMfp);
-
- /* FIXME: raise an exception if mfpict is NULL? */
- size += 3 * sizeof(ULONG);
- size += sizeof(ULONG);
-
- size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
-
- GlobalUnlock(*phMfp);
- }
- }
-
- return size;
-}
-
-/******************************************************************************
- * HMETAFILEPICT_UserMarshal [OLE32.@]
- *
- * Marshals a metafile pict into a buffer.
- *
- * PARAMS
- * pFlags [I] Flags. See notes.
- * pBuffer [I] Buffer to marshal the clip format into.
- * phMfp [I] Metafile pict 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.
- * This function is only intended to be called by the RPC runtime.
- */
-unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
-{
- TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
-
- ALIGN_POINTER(pBuffer, 3);
-
- if (LOWORD(*pFlags) == MSHCTX_INPROC)
- {
- if (sizeof(HMETAFILEPICT) == 8)
- *(ULONG *)pBuffer = WDT_INPROC64_CALL;
- else
- *(ULONG *)pBuffer = WDT_INPROC_CALL;
- pBuffer += sizeof(ULONG);
- *(HMETAFILEPICT *)pBuffer = *phMfp;
- pBuffer += sizeof(HMETAFILEPICT);
- }
- else
- {
- *(ULONG *)pBuffer = WDT_REMOTE_CALL;
- pBuffer += sizeof(ULONG);
- *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
- pBuffer += sizeof(ULONG);
-
- if (*phMfp)
- {
- METAFILEPICT *mfpict = GlobalLock(*phMfp);
- remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
-
- /* FIXME: raise an exception if mfpict is NULL? */
- remmfpict->mm = mfpict->mm;
- remmfpict->xExt = mfpict->xExt;
- remmfpict->yExt = mfpict->yExt;
- pBuffer += 3 * sizeof(ULONG);
- *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
- pBuffer += sizeof(ULONG);
-
- pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
-
- GlobalUnlock(*phMfp);
- }
- }
- return pBuffer;
-}
-
-/******************************************************************************
- * HMETAFILEPICT_UserUnmarshal [OLE32.@]
- *
- * Unmarshals an metafile pict from a buffer.
- *
- * PARAMS
- * pFlags [I] Flags. See notes.
- * pBuffer [I] Buffer to marshal the clip format from.
- * phMfp [O] Address that receive the unmarshaled metafile pict.
- *
- * 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.
- * This function is only intended to be called by the RPC runtime.
- */
-unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
-{
- ULONG fContext;
-
- TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
-
- ALIGN_POINTER(pBuffer, 3);
-
- fContext = *(ULONG *)pBuffer;
- pBuffer += sizeof(ULONG);
-
- if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
- {
- *phMfp = *(HMETAFILEPICT *)pBuffer;
- pBuffer += sizeof(HMETAFILEPICT);
- }
- else
- {
- ULONG handle = *(ULONG *)pBuffer;
- pBuffer += sizeof(ULONG);
- *phMfp = NULL;
-
- if(handle)
- {
- METAFILEPICT *mfpict;
- const remoteMETAFILEPICT *remmfpict;
- ULONG user_marshal_prefix;
-
- remmfpict = (const remoteMETAFILEPICT *)pBuffer;
-
- *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
- if (!*phMfp)
- RpcRaiseException(E_OUTOFMEMORY);
-
- mfpict = GlobalLock(*phMfp);
- mfpict->mm = remmfpict->mm;
- mfpict->xExt = remmfpict->xExt;
- mfpict->yExt = remmfpict->yExt;
- pBuffer += 3 * sizeof(ULONG);
- user_marshal_prefix = *(ULONG *)pBuffer;
- pBuffer += sizeof(ULONG);
-
- if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
- RpcRaiseException(RPC_X_INVALID_TAG);
-
- pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
-
- GlobalUnlock(*phMfp);
- }
- }
- return pBuffer;
-}
-
-/******************************************************************************
- * HMETAFILEPICT_UserFree [OLE32.@]
- *
- * Frees an unmarshaled metafile pict.
- *
- * PARAMS
- * pFlags [I] Flags. See notes.
- * phMfp [I] Metafile pict to free.
- *
- * 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.
- * This function is only intended to be called by the RPC runtime.
- */
-void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
-{
- TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
-
- if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
- {
- METAFILEPICT *mfpict;
-
- mfpict = GlobalLock(*phMfp);
- /* FIXME: raise an exception if mfpict is NULL? */
- HMETAFILE_UserFree(pFlags, &mfpict->hMF);
- GlobalUnlock(*phMfp);
-
- GlobalFree(*phMfp);
- }
-}
-
/******************************************************************************
* STGMEDIUM_UserSize [OLE32.@]
*
--
2.27.0
More information about the wine-devel
mailing list