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.@] *