[PATCH 4/5] combase: Move HBITMAP marshalling functions.

Nikolay Sivov nsivov at codeweavers.com
Mon Aug 3 04:08:38 CDT 2020


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/combase/Makefile.in  |   2 +-
 dlls/combase/combase.spec |   4 +
 dlls/combase/usrmarshal.c | 201 ++++++++++++++++++++++++++++++++++++++
 dlls/ole32/ole32.spec     |   8 +-
 dlls/ole32/usrmarshal.c   | 201 --------------------------------------
 5 files changed, 210 insertions(+), 206 deletions(-)

diff --git a/dlls/combase/Makefile.in b/dlls/combase/Makefile.in
index f91f6bffc36..954dc629973 100644
--- a/dlls/combase/Makefile.in
+++ b/dlls/combase/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = combase.dll
 IMPORTLIB = combase
-IMPORTS   = advapi32 ole32 user32 uuid
+IMPORTS   = advapi32 ole32 user32 gdi32 uuid
 
 EXTRADLLFLAGS = -mno-cygwin
 
diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec
index 10356b414d8..a612d250d18 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 HBITMAP_UserFree(ptr ptr)
+@ stdcall HBITMAP_UserMarshal(ptr ptr ptr)
+@ stdcall HBITMAP_UserSize(ptr long ptr)
+@ stdcall HBITMAP_UserUnmarshal(ptr ptr ptr)
 @ stdcall HBRUSH_UserFree(ptr ptr)
 @ stdcall HBRUSH_UserMarshal(ptr ptr ptr)
 @ stdcall HBRUSH_UserSize(ptr long ptr)
diff --git a/dlls/combase/usrmarshal.c b/dlls/combase/usrmarshal.c
index 59198ccf3f3..5b3062f0c2c 100644
--- a/dlls/combase/usrmarshal.c
+++ b/dlls/combase/usrmarshal.c
@@ -340,6 +340,207 @@ void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
      * so nothing to do */
 }
 
+/******************************************************************************
+ *           HBITMAP_UserSize (combase.@)
+ *
+ * Calculates the buffer size required to marshal a bitmap.
+ *
+ * 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.
+ *  phBmp        [I] Bitmap to size.
+ *
+ * RETURNS
+ *  The buffer size required to marshal an bitmap 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 HBITMAP_UserSize(ULONG *flags, ULONG size, HBITMAP *bmp)
+{
+    TRACE("(%s, %d, %p)\n", debugstr_user_flags(flags), size, *bmp);
+
+    ALIGN_LENGTH(size, 3);
+
+    size += sizeof(ULONG);
+    if (LOWORD(*flags) == MSHCTX_INPROC)
+        size += sizeof(ULONG);
+    else
+    {
+        size += sizeof(ULONG);
+
+        if (*bmp)
+        {
+            size += sizeof(ULONG);
+            size += FIELD_OFFSET(userBITMAP, cbSize);
+            size += GetBitmapBits(*bmp, 0, NULL);
+        }
+    }
+
+    return size;
+}
+
+/******************************************************************************
+*           HBITMAP_UserMarshal (combase.@)
+*
+* Marshals a bitmap into a buffer.
+*
+* PARAMS
+*  pFlags  [I] Flags. See notes.
+*  pBuffer [I] Buffer to marshal the clip format into.
+*  phBmp   [I] Bitmap 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 HBITMAP_UserMarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
+{
+    TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, *bmp);
+
+    ALIGN_POINTER(buffer, 3);
+
+    if (LOWORD(*flags) == MSHCTX_INPROC)
+    {
+        *(ULONG *)buffer = WDT_INPROC_CALL;
+        buffer += sizeof(ULONG);
+        *(ULONG *)buffer = (ULONG)(ULONG_PTR)*bmp;
+        buffer += sizeof(ULONG);
+    }
+    else
+    {
+        *(ULONG *)buffer = WDT_REMOTE_CALL;
+        buffer += sizeof(ULONG);
+        *(ULONG *)buffer = (ULONG)(ULONG_PTR)*bmp;
+        buffer += sizeof(ULONG);
+
+        if (*bmp)
+        {
+            static const ULONG header_size = FIELD_OFFSET(userBITMAP, cbSize);
+            BITMAP bitmap;
+            ULONG bitmap_size;
+
+            bitmap_size = GetBitmapBits(*bmp, 0, NULL);
+            *(ULONG *)buffer = bitmap_size;
+            buffer += sizeof(ULONG);
+
+            GetObjectW(*bmp, sizeof(BITMAP), &bitmap);
+            memcpy(buffer, &bitmap, header_size);
+            buffer += header_size;
+
+            GetBitmapBits(*bmp, bitmap_size, buffer);
+            buffer += bitmap_size;
+        }
+    }
+    return buffer;
+}
+
+/******************************************************************************
+ *           HBITMAP_UserUnmarshal (combase.@)
+ *
+ * Unmarshals a bitmap from a buffer.
+ *
+ * PARAMS
+ *  pFlags   [I] Flags. See notes.
+ *  pBuffer  [I] Buffer to marshal the clip format from.
+ *  phBmp    [O] Address that receive the unmarshaled bitmap.
+ *
+ * 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 HBITMAP_UserUnmarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
+{
+    ULONG context;
+
+    TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, bmp);
+
+    ALIGN_POINTER(buffer, 3);
+
+    context = *(ULONG *)buffer;
+    buffer += sizeof(ULONG);
+
+    if (context == WDT_INPROC_CALL)
+    {
+        *bmp = *(HBITMAP *)buffer;
+        buffer += sizeof(*bmp);
+    }
+    else if (context == WDT_REMOTE_CALL)
+    {
+        ULONG handle = *(ULONG *)buffer;
+        buffer += sizeof(ULONG);
+
+        if (handle)
+        {
+            static const ULONG header_size = FIELD_OFFSET(userBITMAP, cbSize);
+            BITMAP bitmap;
+            ULONG bitmap_size;
+            unsigned char *bits;
+
+            bitmap_size = *(ULONG *)buffer;
+            buffer += sizeof(ULONG);
+            bits = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
+
+            memcpy(&bitmap, buffer, header_size);
+            buffer += header_size;
+
+            memcpy(bits, buffer, bitmap_size);
+            buffer += bitmap_size;
+
+            bitmap.bmBits = bits;
+            *bmp = CreateBitmapIndirect(&bitmap);
+
+            HeapFree(GetProcessHeap(), 0, bits);
+        }
+        else
+            *bmp = NULL;
+    }
+    else
+        RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
+
+    return buffer;
+}
+
+/******************************************************************************
+ *           HBITMAP_UserFree (combase.@)
+ *
+ * Frees an unmarshaled bitmap.
+ *
+ * PARAMS
+ *  pFlags   [I] Flags. See notes.
+ *  phBmp    [I] Bitmap 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 HBITMAP_UserFree(ULONG *flags, HBITMAP *bmp)
+{
+    TRACE("(%s, %p)\n", debugstr_user_flags(flags), *bmp);
+
+    if (LOWORD(*flags) != MSHCTX_INPROC)
+        DeleteObject(*bmp);
+}
+
 /******************************************************************************
  *           WdtpInterfacePointer_UserSize (combase.@)
  *
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec
index c58a406d278..9f13f123272 100644
--- a/dlls/ole32/ole32.spec
+++ b/dlls/ole32/ole32.spec
@@ -127,10 +127,10 @@
 @ 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)
-@ stdcall HBITMAP_UserUnmarshal(ptr ptr ptr)
+@ 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
+@ stdcall HBITMAP_UserUnmarshal(ptr ptr ptr) combase.HBITMAP_UserUnmarshal
 @ stdcall HBRUSH_UserFree(ptr ptr) combase.HBRUSH_UserFree
 @ stdcall HBRUSH_UserMarshal(ptr ptr ptr) combase.HBRUSH_UserMarshal
 @ stdcall HBRUSH_UserSize(ptr long ptr) combase.HBRUSH_UserSize
diff --git a/dlls/ole32/usrmarshal.c b/dlls/ole32/usrmarshal.c
index b7cacf7f620..d12f81f504f 100644
--- a/dlls/ole32/usrmarshal.c
+++ b/dlls/ole32/usrmarshal.c
@@ -375,207 +375,6 @@ void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
         GlobalFree(*phGlobal);
 }
 
-/******************************************************************************
- *           HBITMAP_UserSize [OLE32.@]
- *
- * Calculates the buffer size required to marshal a bitmap.
- *
- * 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.
- *  phBmp        [I] Bitmap to size.
- *
- * RETURNS
- *  The buffer size required to marshal an bitmap 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 HBITMAP_UserSize(ULONG *flags, ULONG size, HBITMAP *bmp)
-{
-    TRACE("(%s, %d, %p)\n", debugstr_user_flags(flags), size, *bmp);
-
-    ALIGN_LENGTH(size, 3);
-
-    size += sizeof(ULONG);
-    if (LOWORD(*flags) == MSHCTX_INPROC)
-        size += sizeof(ULONG);
-    else
-    {
-        size += sizeof(ULONG);
-
-        if (*bmp)
-        {
-            size += sizeof(ULONG);
-            size += FIELD_OFFSET(userBITMAP, cbSize);
-            size += GetBitmapBits(*bmp, 0, NULL);
-        }
-    }
-
-    return size;
-}
-
-/******************************************************************************
-*           HBITMAP_UserMarshal [OLE32.@]
-*
-* Marshals a bitmap into a buffer.
-*
-* PARAMS
-*  pFlags  [I] Flags. See notes.
-*  pBuffer [I] Buffer to marshal the clip format into.
-*  phBmp   [I] Bitmap 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 HBITMAP_UserMarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
-{
-    TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, *bmp);
-
-    ALIGN_POINTER(buffer, 3);
-
-    if (LOWORD(*flags) == MSHCTX_INPROC)
-    {
-        *(ULONG *)buffer = WDT_INPROC_CALL;
-        buffer += sizeof(ULONG);
-        *(ULONG *)buffer = (ULONG)(ULONG_PTR)*bmp;
-        buffer += sizeof(ULONG);
-    }
-    else
-    {
-        *(ULONG *)buffer = WDT_REMOTE_CALL;
-        buffer += sizeof(ULONG);
-        *(ULONG *)buffer = (ULONG)(ULONG_PTR)*bmp;
-        buffer += sizeof(ULONG);
-
-        if (*bmp)
-        {
-            static const ULONG header_size = FIELD_OFFSET(userBITMAP, cbSize);
-            BITMAP bitmap;
-            ULONG bitmap_size;
-
-            bitmap_size = GetBitmapBits(*bmp, 0, NULL);
-            *(ULONG *)buffer = bitmap_size;
-            buffer += sizeof(ULONG);
-
-            GetObjectW(*bmp, sizeof(BITMAP), &bitmap);
-            memcpy(buffer, &bitmap, header_size);
-            buffer += header_size;
-
-            GetBitmapBits(*bmp, bitmap_size, buffer);
-            buffer += bitmap_size;
-        }
-    }
-    return buffer;
-}
-
-/******************************************************************************
- *           HBITMAP_UserUnmarshal [OLE32.@]
- *
- * Unmarshals a bitmap from a buffer.
- *
- * PARAMS
- *  pFlags   [I] Flags. See notes.
- *  pBuffer  [I] Buffer to marshal the clip format from.
- *  phBmp    [O] Address that receive the unmarshaled bitmap.
- *
- * 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 HBITMAP_UserUnmarshal(ULONG *flags, unsigned char *buffer, HBITMAP *bmp)
-{
-    ULONG context;
-
-    TRACE("(%s, %p, %p)\n", debugstr_user_flags(flags), buffer, bmp);
-
-    ALIGN_POINTER(buffer, 3);
-
-    context = *(ULONG *)buffer;
-    buffer += sizeof(ULONG);
-
-    if (context == WDT_INPROC_CALL)
-    {
-        *bmp = *(HBITMAP *)buffer;
-        buffer += sizeof(*bmp);
-    }
-    else if (context == WDT_REMOTE_CALL)
-    {
-        ULONG handle = *(ULONG *)buffer;
-        buffer += sizeof(ULONG);
-
-        if (handle)
-        {
-            static const ULONG header_size = FIELD_OFFSET(userBITMAP, cbSize);
-            BITMAP bitmap;
-            ULONG bitmap_size;
-            unsigned char *bits;
-
-            bitmap_size = *(ULONG *)buffer;
-            buffer += sizeof(ULONG);
-            bits = HeapAlloc(GetProcessHeap(), 0, bitmap_size);
-
-            memcpy(&bitmap, buffer, header_size);
-            buffer += header_size;
-
-            memcpy(bits, buffer, bitmap_size);
-            buffer += bitmap_size;
-
-            bitmap.bmBits = bits;
-            *bmp = CreateBitmapIndirect(&bitmap);
-
-            HeapFree(GetProcessHeap(), 0, bits);
-        }
-        else
-            *bmp = NULL;
-    }
-    else
-        RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
-
-    return buffer;
-}
-
-/******************************************************************************
- *           HBITMAP_UserFree [OLE32.@]
- *
- * Frees an unmarshaled bitmap.
- *
- * PARAMS
- *  pFlags   [I] Flags. See notes.
- *  phBmp    [I] Bitmap 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 HBITMAP_UserFree(ULONG *flags, HBITMAP *bmp)
-{
-    TRACE("(%s, %p)\n", debugstr_user_flags(flags), *bmp);
-
-    if (LOWORD(*flags) != MSHCTX_INPROC)
-        DeleteObject(*bmp);
-}
-
 /******************************************************************************
  *           HPALETTE_UserSize [OLE32.@]
  *
-- 
2.27.0




More information about the wine-devel mailing list