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