Signed-off-by: Nikolay Sivov nsivov@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.@] *
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.spec | 4 + dlls/combase/usrmarshal.c | 203 +++++++++++++++++++++++++++++++++++++- dlls/ole32/ole32.spec | 8 +- dlls/ole32/usrmarshal.c | 198 ------------------------------------- 4 files changed, 206 insertions(+), 207 deletions(-)
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 359f1774336..10a794f82f8 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 HMETAFILE_UserFree(ptr ptr) +@ stdcall HMETAFILE_UserMarshal(ptr ptr ptr) +@ stdcall HMETAFILE_UserSize(ptr long ptr) +@ stdcall HMETAFILE_UserUnmarshal(ptr ptr ptr) @ stdcall HMETAFILEPICT_UserFree(ptr ptr) @ stdcall HMETAFILEPICT_UserMarshal(ptr ptr ptr) @ stdcall HMETAFILEPICT_UserSize(ptr long ptr) diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index 725b29aa28d..08dccb0507d 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -29,11 +29,6 @@
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) @@ -650,6 +645,204 @@ void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal) FIXME(":stub\n"); }
+/****************************************************************************** + * HMETAFILE_UserSize (combase.@) + * + * Calculates the buffer size required to marshal a metafile. + * + * 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. + * phmf [I] Metafile to size. + * + * RETURNS + * The buffer size required to marshal a metafile 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 HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf) +{ + ULONG size = StartingSize; + + TRACE("%s, %u, &%p.\n", debugstr_user_flags(pFlags), StartingSize, *phmf); + + ALIGN_LENGTH(size, 3); + + size += sizeof(ULONG); + if (LOWORD(*pFlags) == MSHCTX_INPROC) + size += sizeof(ULONG_PTR); + else + { + size += sizeof(ULONG); + + if (*phmf) + { + UINT mfsize; + + size += 2 * sizeof(ULONG); + mfsize = GetMetaFileBitsEx(*phmf, 0, NULL); + size += mfsize; + } + } + + return size; +} + +/****************************************************************************** + * HMETAFILE_UserMarshal (combase.@) + * + * Marshals a metafile into a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format into. + * phEmf [I] Metafile 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 HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf) +{ + TRACE("%s, %p, &%p.\n", debugstr_user_flags(pFlags), pBuffer, *phmf); + + ALIGN_POINTER(pBuffer, 3); + + if (LOWORD(*pFlags) == MSHCTX_INPROC) + { + if (sizeof(*phmf) == 8) + *(ULONG *)pBuffer = WDT_INPROC64_CALL; + else + *(ULONG *)pBuffer = WDT_INPROC_CALL; + pBuffer += sizeof(ULONG); + *(HMETAFILE *)pBuffer = *phmf; + pBuffer += sizeof(HMETAFILE); + } + else + { + *(ULONG *)pBuffer = WDT_REMOTE_CALL; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf; + pBuffer += sizeof(ULONG); + + if (*phmf) + { + UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL); + + *(ULONG *)pBuffer = mfsize; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = mfsize; + pBuffer += sizeof(ULONG); + GetMetaFileBitsEx(*phmf, mfsize, pBuffer); + pBuffer += mfsize; + } + } + + return pBuffer; +} + +/****************************************************************************** + * HMETAFILE_UserUnmarshal (combase.@) + * + * Unmarshals a metafile from a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format from. + * phmf [O] Address that receive the unmarshaled metafile. + * + * 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 HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf) +{ + ULONG fContext; + + TRACE("%s, %p, %p.\n", debugstr_user_flags(pFlags), pBuffer, phmf); + + ALIGN_POINTER(pBuffer, 3); + + fContext = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) || + ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8))) + { + *phmf = *(HMETAFILE *)pBuffer; + pBuffer += sizeof(*phmf); + } + else if (fContext == WDT_REMOTE_CALL) + { + ULONG handle; + + handle = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (handle) + { + ULONG size; + size = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + if (size != *(ULONG *)pBuffer) + { + RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); + return pBuffer; + } + pBuffer += sizeof(ULONG); + *phmf = SetMetaFileBitsEx(size, pBuffer); + pBuffer += size; + } + else + *phmf = NULL; + } + else + RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); + + return pBuffer; +} + +/****************************************************************************** + * HMETAFILE_UserFree (combase.@) + * + * Frees an unmarshaled metafile. + * + * PARAMS + * pFlags [I] Flags. See notes. + * phmf [I] Metafile 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 HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf) +{ + TRACE("%s, &%p.\n", debugstr_user_flags(pFlags), *phmf); + + if (LOWORD(*pFlags) != MSHCTX_INPROC) + DeleteMetaFile(*phmf); +} + /****************************************************************************** * HMETAFILEPICT_UserSize (combase.@) * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index cabbb480b43..3a37fb277a2 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -159,10 +159,10 @@ @ 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) -@ stdcall HMETAFILE_UserUnmarshal(ptr ptr ptr) +@ stdcall HMETAFILE_UserFree(ptr ptr) combase.HMETAFILE_UserFree +@ stdcall HMETAFILE_UserMarshal(ptr ptr ptr) combase.HMETAFILE_UserMarshal +@ stdcall HMETAFILE_UserSize(ptr long ptr) combase.HMETAFILE_UserSize +@ stdcall HMETAFILE_UserUnmarshal(ptr ptr ptr) combase.HMETAFILE_UserUnmarshal @ stdcall HPALETTE_UserFree(ptr ptr) combase.HPALETTE_UserFree @ stdcall HPALETTE_UserMarshal(ptr ptr ptr) combase.HPALETTE_UserMarshal @ stdcall HPALETTE_UserSize(ptr long ptr) combase.HPALETTE_UserSize diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index 7319badc97a..4cde079ae8c 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -379,204 +379,6 @@ void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal) GlobalFree(*phGlobal); }
-/****************************************************************************** - * HMETAFILE_UserSize [OLE32.@] - * - * Calculates the buffer size required to marshal a metafile. - * - * 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. - * phmf [I] Metafile to size. - * - * RETURNS - * The buffer size required to marshal a metafile 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 HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf) -{ - ULONG size = StartingSize; - - TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf); - - ALIGN_LENGTH(size, 3); - - size += sizeof(ULONG); - if (LOWORD(*pFlags) == MSHCTX_INPROC) - size += sizeof(ULONG_PTR); - else - { - size += sizeof(ULONG); - - if (*phmf) - { - UINT mfsize; - - size += 2 * sizeof(ULONG); - mfsize = GetMetaFileBitsEx(*phmf, 0, NULL); - size += mfsize; - } - } - - return size; -} - -/****************************************************************************** - * HMETAFILE_UserMarshal [OLE32.@] - * - * Marshals a metafile into a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format into. - * phEmf [I] Metafile 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 HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf) -{ - TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf); - - ALIGN_POINTER(pBuffer, 3); - - if (LOWORD(*pFlags) == MSHCTX_INPROC) - { - if (sizeof(*phmf) == 8) - *(ULONG *)pBuffer = WDT_INPROC64_CALL; - else - *(ULONG *)pBuffer = WDT_INPROC_CALL; - pBuffer += sizeof(ULONG); - *(HMETAFILE *)pBuffer = *phmf; - pBuffer += sizeof(HMETAFILE); - } - else - { - *(ULONG *)pBuffer = WDT_REMOTE_CALL; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf; - pBuffer += sizeof(ULONG); - - if (*phmf) - { - UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL); - - *(ULONG *)pBuffer = mfsize; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = mfsize; - pBuffer += sizeof(ULONG); - GetMetaFileBitsEx(*phmf, mfsize, pBuffer); - pBuffer += mfsize; - } - } - - return pBuffer; -} - -/****************************************************************************** - * HMETAFILE_UserUnmarshal [OLE32.@] - * - * Unmarshals a metafile from a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format from. - * phmf [O] Address that receive the unmarshaled metafile. - * - * 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 HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf) -{ - ULONG fContext; - - TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf); - - ALIGN_POINTER(pBuffer, 3); - - fContext = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) || - ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8))) - { - *phmf = *(HMETAFILE *)pBuffer; - pBuffer += sizeof(*phmf); - } - else if (fContext == WDT_REMOTE_CALL) - { - ULONG handle; - - handle = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (handle) - { - ULONG size; - size = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - if (size != *(ULONG *)pBuffer) - { - RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - return pBuffer; - } - pBuffer += sizeof(ULONG); - *phmf = SetMetaFileBitsEx(size, pBuffer); - pBuffer += size; - } - else - *phmf = NULL; - } - else - RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); - - return pBuffer; -} - -/****************************************************************************** - * HMETAFILE_UserFree [OLE32.@] - * - * Frees an unmarshaled metafile. - * - * PARAMS - * pFlags [I] Flags. See notes. - * phmf [I] Metafile 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 HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf) -{ - TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf); - - if (LOWORD(*pFlags) != MSHCTX_INPROC) - DeleteMetaFile(*phmf); -} - /****************************************************************************** * HENHMETAFILE_UserSize [OLE32.@] *
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76459
Your paranoid android.
=== debiant (64 bit WoW report) ===
ole32: clipboard.c:1159: Test failed: got 800401d0 clipboard.c:1175: Test failed: got 800401d0 clipboard.c:1182: Test failed: data objects match clipboard.c:1185: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1190: Test failed: data objects match clipboard.c:1191: Test failed: data objects match clipboard.c:1201: Test failed: got 800401d0 clipboard.c:1213: Test failed: got 800401d0 clipboard.c:1214: Test failed: GetData not called clipboard.c:1217: Test failed: 1 1 clipboard.c:1223: Test failed: got 800401d0 clipboard.c:1224: Test failed: GetData not called clipboard.c:1228: Test failed: 1 clipboard.c:1239: Test failed: got 800401d0 clipboard.c:1250: Test failed: got 800401d0 clipboard.c:1256: Test failed: got 800401d0 clipboard.c:1257: Test failed: GetData not called clipboard.c:1263: Test failed: 1 1 clipboard.c:1266: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1269: Test failed: 1 clipboard.c:1281: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1283: Test failed: 1 1 clipboard.c:1287: Test failed: 1
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.spec | 4 + dlls/combase/usrmarshal.c | 220 ++++++++++++++++++++++++++++++++++++++ dlls/ole32/ole32.spec | 8 +- dlls/ole32/usrmarshal.c | 219 ------------------------------------- 4 files changed, 228 insertions(+), 223 deletions(-)
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 10a794f82f8..614b33148f8 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -197,6 +197,10 @@ @ stdcall HDC_UserMarshal(ptr ptr ptr) @ stdcall HDC_UserSize(ptr long ptr) @ stdcall HDC_UserUnmarshal(ptr ptr ptr) +@ stdcall HGLOBAL_UserFree(ptr ptr) +@ stdcall HGLOBAL_UserMarshal(ptr ptr ptr) +@ stdcall HGLOBAL_UserSize(ptr long ptr) +@ stdcall HGLOBAL_UserUnmarshal(ptr ptr ptr) @ stdcall HICON_UserFree(ptr ptr) @ stdcall HICON_UserMarshal(ptr ptr ptr) @ stdcall HICON_UserSize(ptr long ptr) diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index 08dccb0507d..54fecf8a235 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -1063,6 +1063,226 @@ void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp) GlobalFree(*phMfp); } } + +/****************************************************************************** + * HGLOBAL_UserSize (combase.@) + * + * Calculates the buffer size required to marshal an HGLOBAL. + * + * 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. + * phGlobal [I] HGLOBAL to size. + * + * RETURNS + * The buffer size required to marshal an HGLOBAL 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 HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal) +{ + ULONG size = StartingSize; + + TRACE("%s, %u, %p.\n", debugstr_user_flags(pFlags), StartingSize, phGlobal); + + ALIGN_LENGTH(size, 3); + + size += sizeof(ULONG); + + if (LOWORD(*pFlags) == MSHCTX_INPROC) + size += sizeof(HGLOBAL); + else + { + size += sizeof(ULONG); + if (*phGlobal) + { + SIZE_T ret; + size += 3 * sizeof(ULONG); + ret = GlobalSize(*phGlobal); + size += (ULONG)ret; + } + } + + return size; +} + +/****************************************************************************** + * HGLOBAL_UserMarshal (combase.@) + * + * Marshals an HGLOBAL into a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format into. + * phGlobal [I] HGLOBAL 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 HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal) +{ + TRACE("%s, %p, &%p.\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal); + + ALIGN_POINTER(pBuffer, 3); + + if (LOWORD(*pFlags) == MSHCTX_INPROC) + { + if (sizeof(*phGlobal) == 8) + *(ULONG *)pBuffer = WDT_INPROC64_CALL; + else + *(ULONG *)pBuffer = WDT_INPROC_CALL; + pBuffer += sizeof(ULONG); + *(HGLOBAL *)pBuffer = *phGlobal; + pBuffer += sizeof(HGLOBAL); + } + else + { + *(ULONG *)pBuffer = WDT_REMOTE_CALL; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = HandleToULong(*phGlobal); + pBuffer += sizeof(ULONG); + if (*phGlobal) + { + const unsigned char *memory; + SIZE_T size = GlobalSize(*phGlobal); + *(ULONG *)pBuffer = (ULONG)size; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = HandleToULong(*phGlobal); + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = (ULONG)size; + pBuffer += sizeof(ULONG); + + memory = GlobalLock(*phGlobal); + memcpy(pBuffer, memory, size); + pBuffer += size; + GlobalUnlock(*phGlobal); + } + } + + return pBuffer; +} + +/****************************************************************************** + * HGLOBAL_UserUnmarshal (combase.@) + * + * Unmarshals an HGLOBAL from a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format from. + * phGlobal [O] Address that receive the unmarshaled HGLOBAL. + * + * 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 HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal) +{ + ULONG fContext; + + TRACE("%s, %p, &%p.\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal); + + ALIGN_POINTER(pBuffer, 3); + + fContext = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) || + ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8))) + { + *phGlobal = *(HGLOBAL *)pBuffer; + pBuffer += sizeof(*phGlobal); + } + else if (fContext == WDT_REMOTE_CALL) + { + ULONG handle; + + handle = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (handle) + { + ULONG size; + void *memory; + + size = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + /* redundancy is bad - it means you have to check consistency like + * this: */ + if (*(ULONG *)pBuffer != handle) + { + RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); + return pBuffer; + } + pBuffer += sizeof(ULONG); + /* redundancy is bad - it means you have to check consistency like + * this: */ + if (*(ULONG *)pBuffer != size) + { + RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); + return pBuffer; + } + pBuffer += sizeof(ULONG); + + /* FIXME: check size is not too big */ + + *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size); + memory = GlobalLock(*phGlobal); + memcpy(memory, pBuffer, size); + pBuffer += size; + GlobalUnlock(*phGlobal); + } + else + *phGlobal = NULL; + } + else + RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); + + return pBuffer; +} + +/****************************************************************************** + * HGLOBAL_UserFree (combase.@) + * + * Frees an unmarshaled HGLOBAL. + * + * PARAMS + * pFlags [I] Flags. See notes. + * phGlobal [I] HGLOBAL 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 HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal) +{ + TRACE("%s, &%p.\n", debugstr_user_flags(pFlags), *phGlobal); + + if (LOWORD(*pFlags) != MSHCTX_INPROC && *phGlobal) + GlobalFree(*phGlobal); +} + /****************************************************************************** * WdtpInterfacePointer_UserSize (combase.@) * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 3a37fb277a2..cbb90660199 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -143,10 +143,10 @@ @ stdcall HENHMETAFILE_UserMarshal(ptr ptr ptr) @ stdcall HENHMETAFILE_UserSize(ptr long ptr) @ stdcall HENHMETAFILE_UserUnmarshal(ptr ptr ptr) -@ stdcall HGLOBAL_UserFree(ptr ptr) -@ stdcall HGLOBAL_UserMarshal(ptr ptr ptr) -@ stdcall HGLOBAL_UserSize(ptr long ptr) -@ stdcall HGLOBAL_UserUnmarshal(ptr ptr ptr) +@ stdcall HGLOBAL_UserFree(ptr ptr) combase.HGLOBAL_UserFree +@ stdcall HGLOBAL_UserMarshal(ptr ptr ptr) combase.HGLOBAL_UserMarshal +@ stdcall HGLOBAL_UserSize(ptr long ptr) combase.HGLOBAL_UserSize +@ stdcall HGLOBAL_UserUnmarshal(ptr ptr ptr) combase.HGLOBAL_UserUnmarshal @ stdcall HICON_UserFree(ptr ptr) combase.HICON_UserFree @ stdcall HICON_UserMarshal(ptr ptr ptr) combase.HICON_UserMarshal @ stdcall HICON_UserSize(ptr long ptr) combase.HICON_UserSize diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index 4cde079ae8c..80cfde15949 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -160,225 +160,6 @@ static void handle_UserFree(ULONG *pFlags, HANDLE *handle)
IMPL_WIREM_HANDLE(HACCEL)
-/****************************************************************************** - * HGLOBAL_UserSize [OLE32.@] - * - * Calculates the buffer size required to marshal an HGLOBAL. - * - * 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. - * phGlobal [I] HGLOBAL to size. - * - * RETURNS - * The buffer size required to marshal an HGLOBAL 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 HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal) -{ - ULONG size = StartingSize; - - TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal); - - ALIGN_LENGTH(size, 3); - - size += sizeof(ULONG); - - if (LOWORD(*pFlags) == MSHCTX_INPROC) - size += sizeof(HGLOBAL); - else - { - size += sizeof(ULONG); - if (*phGlobal) - { - SIZE_T ret; - size += 3 * sizeof(ULONG); - ret = GlobalSize(*phGlobal); - size += (ULONG)ret; - } - } - - return size; -} - -/****************************************************************************** - * HGLOBAL_UserMarshal [OLE32.@] - * - * Marshals an HGLOBAL into a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format into. - * phGlobal [I] HGLOBAL 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 HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal) -{ - TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal); - - ALIGN_POINTER(pBuffer, 3); - - if (LOWORD(*pFlags) == MSHCTX_INPROC) - { - if (sizeof(*phGlobal) == 8) - *(ULONG *)pBuffer = WDT_INPROC64_CALL; - else - *(ULONG *)pBuffer = WDT_INPROC_CALL; - pBuffer += sizeof(ULONG); - *(HGLOBAL *)pBuffer = *phGlobal; - pBuffer += sizeof(HGLOBAL); - } - else - { - *(ULONG *)pBuffer = WDT_REMOTE_CALL; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = HandleToULong(*phGlobal); - pBuffer += sizeof(ULONG); - if (*phGlobal) - { - const unsigned char *memory; - SIZE_T size = GlobalSize(*phGlobal); - *(ULONG *)pBuffer = (ULONG)size; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = HandleToULong(*phGlobal); - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = (ULONG)size; - pBuffer += sizeof(ULONG); - - memory = GlobalLock(*phGlobal); - memcpy(pBuffer, memory, size); - pBuffer += size; - GlobalUnlock(*phGlobal); - } - } - - return pBuffer; -} - -/****************************************************************************** - * HGLOBAL_UserUnmarshal [OLE32.@] - * - * Unmarshals an HGLOBAL from a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format from. - * phGlobal [O] Address that receive the unmarshaled HGLOBAL. - * - * 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 HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal) -{ - ULONG fContext; - - TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal); - - ALIGN_POINTER(pBuffer, 3); - - fContext = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) || - ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8))) - { - *phGlobal = *(HGLOBAL *)pBuffer; - pBuffer += sizeof(*phGlobal); - } - else if (fContext == WDT_REMOTE_CALL) - { - ULONG handle; - - handle = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (handle) - { - ULONG size; - void *memory; - - size = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - /* redundancy is bad - it means you have to check consistency like - * this: */ - if (*(ULONG *)pBuffer != handle) - { - RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - return pBuffer; - } - pBuffer += sizeof(ULONG); - /* redundancy is bad - it means you have to check consistency like - * this: */ - if (*(ULONG *)pBuffer != size) - { - RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - return pBuffer; - } - pBuffer += sizeof(ULONG); - - /* FIXME: check size is not too big */ - - *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size); - memory = GlobalLock(*phGlobal); - memcpy(memory, pBuffer, size); - pBuffer += size; - GlobalUnlock(*phGlobal); - } - else - *phGlobal = NULL; - } - else - RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); - - return pBuffer; -} - -/****************************************************************************** - * HGLOBAL_UserFree [OLE32.@] - * - * Frees an unmarshaled HGLOBAL. - * - * PARAMS - * pFlags [I] Flags. See notes. - * phGlobal [I] HGLOBAL 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 HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal) -{ - TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal); - - if (LOWORD(*pFlags) != MSHCTX_INPROC && *phGlobal) - GlobalFree(*phGlobal); -} - /****************************************************************************** * HENHMETAFILE_UserSize [OLE32.@] *
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76460
Your paranoid android.
=== debiant (64 bit WoW report) ===
ole32: clipboard.c:1159: Test failed: got 800401d0 clipboard.c:1175: Test failed: got 800401d0 clipboard.c:1182: Test failed: data objects match clipboard.c:1185: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1190: Test failed: data objects match clipboard.c:1191: Test failed: data objects match clipboard.c:1201: Test failed: got 800401d0 clipboard.c:1213: Test failed: got 800401d0 clipboard.c:1214: Test failed: GetData not called clipboard.c:1217: Test failed: 1 1 clipboard.c:1223: Test failed: got 800401d0 clipboard.c:1224: Test failed: GetData not called clipboard.c:1228: Test failed: 1 clipboard.c:1239: Test failed: got 800401d0
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.spec | 4 +++ dlls/combase/usrmarshal.c | 1 + dlls/ole32/ole32.spec | 8 ++--- dlls/ole32/usrmarshal.c | 74 --------------------------------------- 4 files changed, 9 insertions(+), 78 deletions(-)
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 614b33148f8..0cd1bf29ae7 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -185,6 +185,10 @@ @ stdcall GetHGlobalFromStream(ptr ptr) ole32.GetHGlobalFromStream @ stub GetHookInterface @ stdcall GetRestrictedErrorInfo(ptr) +@ stdcall HACCEL_UserFree(ptr ptr) +@ stdcall HACCEL_UserMarshal(ptr ptr ptr) +@ stdcall HACCEL_UserSize(ptr long ptr) +@ stdcall HACCEL_UserUnmarshal(ptr ptr ptr) @ stdcall HBITMAP_UserFree(ptr ptr) @ stdcall HBITMAP_UserMarshal(ptr ptr ptr) @ stdcall HBITMAP_UserSize(ptr long ptr) diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index 54fecf8a235..d4629a6bd76 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -139,6 +139,7 @@ static void handle_UserFree(ULONG *pFlags, HANDLE *handle) handle_UserFree(pFlags, (HANDLE *)handle); \ }
+IMPL_WIREM_HANDLE(HACCEL) IMPL_WIREM_HANDLE(HBRUSH) IMPL_WIREM_HANDLE(HDC) IMPL_WIREM_HANDLE(HICON) diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index cbb90660199..dbc31cb9604 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -123,10 +123,10 @@ @ stdcall GetHGlobalFromStream(ptr ptr) @ stub GetHookInterface @ stdcall GetRunningObjectTable(long ptr) -@ stdcall HACCEL_UserFree(ptr ptr) -@ stdcall HACCEL_UserMarshal(ptr ptr ptr) -@ stdcall HACCEL_UserSize(ptr long ptr) -@ stdcall HACCEL_UserUnmarshal(ptr ptr ptr) +@ stdcall HACCEL_UserFree(ptr ptr) combase.HACCEL_UserFree +@ stdcall HACCEL_UserMarshal(ptr ptr ptr) combase.HACCEL_UserMarshal +@ stdcall HACCEL_UserSize(ptr long ptr) combase.HACCEL_UserSize +@ stdcall HACCEL_UserUnmarshal(ptr ptr ptr) combase.HACCEL_UserUnmarshal @ stdcall HBITMAP_UserFree(ptr ptr) combase.HBITMAP_UserFree @ stdcall HBITMAP_UserMarshal(ptr ptr ptr) combase.HBITMAP_UserMarshal @ stdcall HBITMAP_UserSize(ptr long ptr) combase.HBITMAP_UserSize diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index 80cfde15949..a2aee9d6942 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -86,80 +86,6 @@ static const char* debugstr_user_flags(ULONG *pFlags) return wine_dbg_sprintf("MAKELONG(%s, 0x%04x)", loword, HIWORD(*pFlags)); }
-static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle) -{ - if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE) - { - ERR("can't remote a local handle\n"); - RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); - return StartingSize; - } - - ALIGN_LENGTH(StartingSize, 3); - return StartingSize + sizeof(RemotableHandle); -} - -static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) -{ - RemotableHandle *remhandle; - if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE) - { - ERR("can't remote a local handle\n"); - RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); - return pBuffer; - } - - ALIGN_POINTER(pBuffer, 3); - remhandle = (RemotableHandle *)pBuffer; - remhandle->fContext = WDT_INPROC_CALL; - remhandle->u.hInproc = (LONG_PTR)*handle; - return pBuffer + sizeof(RemotableHandle); -} - -static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle) -{ - RemotableHandle *remhandle; - - ALIGN_POINTER(pBuffer, 3); - remhandle = (RemotableHandle *)pBuffer; - if (remhandle->fContext != WDT_INPROC_CALL) - RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - *handle = (HANDLE)(LONG_PTR)remhandle->u.hInproc; - return pBuffer + sizeof(RemotableHandle); -} - -static void handle_UserFree(ULONG *pFlags, HANDLE *handle) -{ - /* nothing to do */ -} - -#define IMPL_WIREM_HANDLE(type) \ - ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \ - { \ - TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \ - return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \ - } \ - \ - unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \ - { \ - TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \ - return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \ - } \ - \ - unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \ - { \ - TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \ - return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \ - } \ - \ - void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \ - { \ - TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \ - handle_UserFree(pFlags, (HANDLE *)handle); \ - } - -IMPL_WIREM_HANDLE(HACCEL) - /****************************************************************************** * HENHMETAFILE_UserSize [OLE32.@] *
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/combase.spec | 4 + dlls/combase/usrmarshal.c | 196 +++++++++++++++++++++++++++++++++++++ dlls/ole32/ole32.spec | 8 +- dlls/ole32/usrmarshal.c | 200 +------------------------------------- 4 files changed, 208 insertions(+), 200 deletions(-)
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 0cd1bf29ae7..43ea5e1ea2b 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -201,6 +201,10 @@ @ stdcall HDC_UserMarshal(ptr ptr ptr) @ stdcall HDC_UserSize(ptr long ptr) @ stdcall HDC_UserUnmarshal(ptr ptr ptr) +@ stdcall HENHMETAFILE_UserFree(ptr ptr) +@ stdcall HENHMETAFILE_UserMarshal(ptr ptr ptr) +@ stdcall HENHMETAFILE_UserSize(ptr long ptr) +@ stdcall HENHMETAFILE_UserUnmarshal(ptr ptr ptr) @ stdcall HGLOBAL_UserFree(ptr ptr) @ stdcall HGLOBAL_UserMarshal(ptr ptr ptr) @ stdcall HGLOBAL_UserSize(ptr long ptr) diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c index d4629a6bd76..ef68cdf8d0f 100644 --- a/dlls/combase/usrmarshal.c +++ b/dlls/combase/usrmarshal.c @@ -1065,6 +1065,202 @@ void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp) } }
+/****************************************************************************** +* HENHMETAFILE_UserSize (combase.@) +* +* Calculates the buffer size required to marshal an enhanced metafile. +* +* 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. +* phEmf [I] Enhanced metafile to size. +* +* RETURNS +* The buffer size required to marshal an enhanced metafile 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 HENHMETAFILE_UserSize(ULONG *pFlags, ULONG size, HENHMETAFILE *phEmf) +{ + TRACE("%s, %u, %p.\n", debugstr_user_flags(pFlags), size, *phEmf); + + ALIGN_LENGTH(size, 3); + + size += sizeof(ULONG); + if (LOWORD(*pFlags) == MSHCTX_INPROC) + size += sizeof(ULONG_PTR); + else + { + size += sizeof(ULONG); + + if (*phEmf) + { + UINT emfsize; + + size += 2 * sizeof(ULONG); + emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL); + size += emfsize; + } + } + + return size; +} + +/****************************************************************************** + * HENHMETAFILE_UserMarshal (combase.@) + * + * Marshals an enhance metafile into a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format into. + * phEmf [I] Enhanced metafile 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 HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf) +{ + TRACE("%s, %p, &%p.\n", debugstr_user_flags(pFlags), pBuffer, *phEmf); + + ALIGN_POINTER(pBuffer, 3); + + if (LOWORD(*pFlags) == MSHCTX_INPROC) + { + if (sizeof(*phEmf) == 8) + *(ULONG *)pBuffer = WDT_INPROC64_CALL; + else + *(ULONG *)pBuffer = WDT_INPROC_CALL; + pBuffer += sizeof(ULONG); + *(HENHMETAFILE *)pBuffer = *phEmf; + pBuffer += sizeof(HENHMETAFILE); + } + else + { + *(ULONG *)pBuffer = WDT_REMOTE_CALL; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf; + pBuffer += sizeof(ULONG); + + if (*phEmf) + { + UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL); + + *(ULONG *)pBuffer = emfsize; + pBuffer += sizeof(ULONG); + *(ULONG *)pBuffer = emfsize; + pBuffer += sizeof(ULONG); + GetEnhMetaFileBits(*phEmf, emfsize, pBuffer); + pBuffer += emfsize; + } + } + + return pBuffer; +} + +/****************************************************************************** + * HENHMETAFILE_UserUnmarshal (combase.@) + * + * Unmarshals an enhanced metafile from a buffer. + * + * PARAMS + * pFlags [I] Flags. See notes. + * pBuffer [I] Buffer to marshal the clip format from. + * phEmf [O] Address that receive the unmarshaled enhanced metafile. + * + * 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 HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf) +{ + ULONG fContext; + + TRACE("%s, %p, %p.\n", debugstr_user_flags(pFlags), pBuffer, phEmf); + + ALIGN_POINTER(pBuffer, 3); + + fContext = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) || + ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8))) + { + *phEmf = *(HENHMETAFILE *)pBuffer; + pBuffer += sizeof(*phEmf); + } + else if (fContext == WDT_REMOTE_CALL) + { + ULONG handle; + + handle = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + + if (handle) + { + ULONG size; + size = *(ULONG *)pBuffer; + pBuffer += sizeof(ULONG); + if (size != *(ULONG *)pBuffer) + { + RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); + return pBuffer; + } + pBuffer += sizeof(ULONG); + *phEmf = SetEnhMetaFileBits(size, pBuffer); + pBuffer += size; + } + else + *phEmf = NULL; + } + else + RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); + + return pBuffer; +} + +/****************************************************************************** + * HENHMETAFILE_UserFree (combase.@) + * + * Frees an unmarshaled enhanced metafile. + * + * PARAMS + * pFlags [I] Flags. See notes. + * phEmf [I] Enhanced metafile 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 HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf) +{ + TRACE("%s, &%p.\n", debugstr_user_flags(pFlags), *phEmf); + + if (LOWORD(*pFlags) != MSHCTX_INPROC) + DeleteEnhMetaFile(*phEmf); +} + /****************************************************************************** * HGLOBAL_UserSize (combase.@) * diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index dbc31cb9604..0efdcb56301 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -139,10 +139,10 @@ @ stdcall HDC_UserMarshal(ptr ptr ptr) combase.HDC_UserMarshal @ stdcall HDC_UserSize(ptr long ptr) combase.HDC_UserSize @ stdcall HDC_UserUnmarshal(ptr ptr ptr) combase.HDC_UserUnmarshal -@ stdcall HENHMETAFILE_UserFree(ptr ptr) -@ stdcall HENHMETAFILE_UserMarshal(ptr ptr ptr) -@ stdcall HENHMETAFILE_UserSize(ptr long ptr) -@ stdcall HENHMETAFILE_UserUnmarshal(ptr ptr ptr) +@ stdcall HENHMETAFILE_UserFree(ptr ptr) combase.HENHMETAFILE_UserFree +@ stdcall HENHMETAFILE_UserMarshal(ptr ptr ptr) combase.HENHMETAFILE_UserMarshal +@ stdcall HENHMETAFILE_UserSize(ptr long ptr) combase.HENHMETAFILE_UserSize +@ stdcall HENHMETAFILE_UserUnmarshal(ptr ptr ptr) combase.HENHMETAFILE_UserUnmarshal @ stdcall HGLOBAL_UserFree(ptr ptr) combase.HGLOBAL_UserFree @ stdcall HGLOBAL_UserMarshal(ptr ptr ptr) combase.HGLOBAL_UserMarshal @ stdcall HGLOBAL_UserSize(ptr long ptr) combase.HGLOBAL_UserSize diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c index a2aee9d6942..43f94f0f652 100644 --- a/dlls/ole32/usrmarshal.c +++ b/dlls/ole32/usrmarshal.c @@ -56,6 +56,10 @@ ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG size, HMETAFILEPICT 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); +ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG size, HENHMETAFILE *phEmf); +unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf); +unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf); +void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf);
static const char* debugstr_user_flags(ULONG *pFlags) { @@ -86,202 +90,6 @@ static const char* debugstr_user_flags(ULONG *pFlags) return wine_dbg_sprintf("MAKELONG(%s, 0x%04x)", loword, HIWORD(*pFlags)); }
-/****************************************************************************** -* HENHMETAFILE_UserSize [OLE32.@] -* -* Calculates the buffer size required to marshal an enhanced metafile. -* -* 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. -* phEmf [I] Enhanced metafile to size. -* -* RETURNS -* The buffer size required to marshal an enhanced metafile 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 HENHMETAFILE_UserSize(ULONG *pFlags, ULONG size, HENHMETAFILE *phEmf) -{ - TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), size, *phEmf); - - ALIGN_LENGTH(size, 3); - - size += sizeof(ULONG); - if (LOWORD(*pFlags) == MSHCTX_INPROC) - size += sizeof(ULONG_PTR); - else - { - size += sizeof(ULONG); - - if (*phEmf) - { - UINT emfsize; - - size += 2 * sizeof(ULONG); - emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL); - size += emfsize; - } - } - - return size; -} - -/****************************************************************************** - * HENHMETAFILE_UserMarshal [OLE32.@] - * - * Marshals an enhance metafile into a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format into. - * phEmf [I] Enhanced metafile 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 HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf) -{ - TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf); - - ALIGN_POINTER(pBuffer, 3); - - if (LOWORD(*pFlags) == MSHCTX_INPROC) - { - if (sizeof(*phEmf) == 8) - *(ULONG *)pBuffer = WDT_INPROC64_CALL; - else - *(ULONG *)pBuffer = WDT_INPROC_CALL; - pBuffer += sizeof(ULONG); - *(HENHMETAFILE *)pBuffer = *phEmf; - pBuffer += sizeof(HENHMETAFILE); - } - else - { - *(ULONG *)pBuffer = WDT_REMOTE_CALL; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf; - pBuffer += sizeof(ULONG); - - if (*phEmf) - { - UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL); - - *(ULONG *)pBuffer = emfsize; - pBuffer += sizeof(ULONG); - *(ULONG *)pBuffer = emfsize; - pBuffer += sizeof(ULONG); - GetEnhMetaFileBits(*phEmf, emfsize, pBuffer); - pBuffer += emfsize; - } - } - - return pBuffer; -} - -/****************************************************************************** - * HENHMETAFILE_UserUnmarshal [OLE32.@] - * - * Unmarshals an enhanced metafile from a buffer. - * - * PARAMS - * pFlags [I] Flags. See notes. - * pBuffer [I] Buffer to marshal the clip format from. - * phEmf [O] Address that receive the unmarshaled enhanced metafile. - * - * 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 HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf) -{ - ULONG fContext; - - TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf); - - ALIGN_POINTER(pBuffer, 3); - - fContext = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) || - ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8))) - { - *phEmf = *(HENHMETAFILE *)pBuffer; - pBuffer += sizeof(*phEmf); - } - else if (fContext == WDT_REMOTE_CALL) - { - ULONG handle; - - handle = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - - if (handle) - { - ULONG size; - size = *(ULONG *)pBuffer; - pBuffer += sizeof(ULONG); - if (size != *(ULONG *)pBuffer) - { - RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL); - return pBuffer; - } - pBuffer += sizeof(ULONG); - *phEmf = SetEnhMetaFileBits(size, pBuffer); - pBuffer += size; - } - else - *phEmf = NULL; - } - else - RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL); - - return pBuffer; -} - -/****************************************************************************** - * HENHMETAFILE_UserFree [OLE32.@] - * - * Frees an unmarshaled enhanced metafile. - * - * PARAMS - * pFlags [I] Flags. See notes. - * phEmf [I] Enhanced metafile 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 HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf) -{ - TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf); - - if (LOWORD(*pFlags) != MSHCTX_INPROC) - DeleteEnhMetaFile(*phEmf); -} - /****************************************************************************** * STGMEDIUM_UserSize [OLE32.@] *
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=76458
Your paranoid android.
=== debiant (32 bit Chinese:China report) ===
ole32: clipboard.c:1256: Test failed: got 800401d0 clipboard.c:1257: Test failed: GetData not called clipboard.c:1263: Test failed: 5 5 clipboard.c:1266: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1269: Test failed: 5 clipboard.c:1281: Test failed: Failed to clear clipboard, hr 0x800401d0. clipboard.c:1283: Test failed: 1 1 clipboard.c:1287: Test failed: 1
Please ignore this set. Metafile functions are not supposed to move.