combase: Move HBITMAP marshalling functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f155a53b54
commit
6cd7f96f28
|
@ -1,6 +1,6 @@
|
|||
MODULE = combase.dll
|
||||
IMPORTLIB = combase
|
||||
IMPORTS = advapi32 ole32 user32 uuid
|
||||
IMPORTS = advapi32 ole32 user32 gdi32 uuid
|
||||
|
||||
EXTRADLLFLAGS = -mno-cygwin
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.@)
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.@]
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue