Commit f155a53b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

combase: Move CLIPFORMAT marshalling functions.

parent 0c7ecc89
MODULE = combase.dll
IMPORTLIB = combase
IMPORTS = advapi32 ole32 uuid
IMPORTS = advapi32 ole32 user32 uuid
EXTRADLLFLAGS = -mno-cygwin
......
......@@ -62,6 +62,10 @@
@ stub RoFailFastWithErrorContextInternal2
@ stub RoFailFastWithErrorContextInternal
@ stub UpdateProcessTracing
@ stdcall CLIPFORMAT_UserFree(ptr ptr)
@ stdcall CLIPFORMAT_UserMarshal(ptr ptr ptr)
@ stdcall CLIPFORMAT_UserSize(ptr long ptr)
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr)
@ stub CLSIDFromOle1Class
@ stdcall CLSIDFromProgID(wstr ptr) ole32.CLSIDFromProgID
@ stdcall CLSIDFromString(wstr ptr) ole32.CLSIDFromString
......
......@@ -141,6 +141,206 @@ IMPL_WIREM_HANDLE(HMENU)
IMPL_WIREM_HANDLE(HWND)
/******************************************************************************
* CLIPFORMAT_UserSize (combase.@)
*
* Calculates the buffer size required to marshal a clip format.
*
* 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.
* pCF [I] Clip format to size.
*
* RETURNS
* The buffer size required to marshal a clip format plus the starting size.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG size, CLIPFORMAT *pCF)
{
TRACE("%s, %u, %p.n", debugstr_user_flags(pFlags), size, pCF);
ALIGN_LENGTH(size, 3);
size += 8;
/* only need to marshal the name if it is not a pre-defined type and
* we are going remote */
if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
{
WCHAR format[255];
INT ret;
size += 3 * sizeof(UINT);
/* urg! this function is badly designed because it won't tell us how
* much space is needed without doing a dummy run of storing the
* name into a buffer */
ret = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!ret)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
size += (ret + 1) * sizeof(WCHAR);
}
return size;
}
/******************************************************************************
* CLIPFORMAT_UserMarshal (combase.@)
*
* Marshals a clip format into a buffer.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pBuffer [I] Buffer to marshal the clip format into.
* pCF [I] Clip format to marshal.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{
TRACE("%s, %p, &0x%04x.\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
ALIGN_POINTER(pBuffer, 3);
/* only need to marshal the name if it is not a pre-defined type and
* we are going remote */
if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
{
WCHAR format[255];
UINT len;
*(DWORD *)pBuffer = WDT_REMOTE_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
len = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!len)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
len += 1;
*(UINT *)pBuffer = len;
pBuffer += sizeof(UINT);
*(UINT *)pBuffer = 0;
pBuffer += sizeof(UINT);
*(UINT *)pBuffer = len;
pBuffer += sizeof(UINT);
TRACE("marshaling format name %s\n", debugstr_w(format));
memcpy(pBuffer, format, len * sizeof(WCHAR));
pBuffer += len * sizeof(WCHAR);
}
else
{
*(DWORD *)pBuffer = WDT_INPROC_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
}
return pBuffer;
}
/******************************************************************************
* CLIPFORMAT_UserUnmarshal (combase.@)
*
* Unmarshals a clip format from a buffer.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pBuffer [I] Buffer to marshal the clip format from.
* pCF [O] Address that receive the unmarshaled clip format.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{
LONG fContext;
TRACE("%s, %p, %p.\n", debugstr_user_flags(pFlags), pBuffer, pCF);
ALIGN_POINTER(pBuffer, 3);
fContext = *(DWORD *)pBuffer;
pBuffer += 4;
if (fContext == WDT_INPROC_CALL)
{
*pCF = *(CLIPFORMAT *)pBuffer;
pBuffer += 4;
}
else if (fContext == WDT_REMOTE_CALL)
{
CLIPFORMAT cf;
UINT len;
/* pointer ID for registered clip format string */
if (*(DWORD *)pBuffer == 0)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += 4;
len = *(UINT *)pBuffer;
pBuffer += sizeof(UINT);
if (*(UINT *)pBuffer != 0)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(UINT);
if (*(UINT *)pBuffer != len)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(UINT);
if (((WCHAR *)pBuffer)[len - 1] != '\0')
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
pBuffer += len * sizeof(WCHAR);
if (!cf)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
*pCF = cf;
}
else
/* code not really appropriate, but nearest I can find */
RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
return pBuffer;
}
/******************************************************************************
* CLIPFORMAT_UserFree (combase.@)
*
* Frees an unmarshaled clip format.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pCF [I] Clip format to free.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
* structure, of which the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
{
/* there is no inverse of the RegisterClipboardFormat function,
* so nothing to do */
}
/******************************************************************************
* WdtpInterfacePointer_UserSize (combase.@)
*
* Calculates the buffer size required to marshal an interface pointer.
......
@ stdcall BindMoniker(ptr long ptr ptr)
@ stdcall CLIPFORMAT_UserFree(ptr ptr)
@ stdcall CLIPFORMAT_UserMarshal(ptr ptr ptr)
@ stdcall CLIPFORMAT_UserSize(ptr long ptr)
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr)
@ stdcall CLIPFORMAT_UserFree(ptr ptr) combase.CLIPFORMAT_UserFree
@ stdcall CLIPFORMAT_UserMarshal(ptr ptr ptr) combase.CLIPFORMAT_UserMarshal
@ stdcall CLIPFORMAT_UserSize(ptr long ptr) combase.CLIPFORMAT_UserSize
@ stdcall CLIPFORMAT_UserUnmarshal(ptr ptr ptr) combase.CLIPFORMAT_UserUnmarshal
@ stdcall CLSIDFromProgID(wstr ptr)
@ stdcall CLSIDFromProgIDEx(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr)
......
......@@ -82,206 +82,6 @@ static const char* debugstr_user_flags(ULONG *pFlags)
return wine_dbg_sprintf("MAKELONG(%s, 0x%04x)", loword, HIWORD(*pFlags));
}
/******************************************************************************
* CLIPFORMAT_UserSize [OLE32.@]
*
* Calculates the buffer size required to marshal a clip format.
*
* 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.
* pCF [I] Clip format to size.
*
* RETURNS
* The buffer size required to marshal a clip format plus the starting size.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG size, CLIPFORMAT *pCF)
{
TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), size, pCF);
ALIGN_LENGTH(size, 3);
size += 8;
/* only need to marshal the name if it is not a pre-defined type and
* we are going remote */
if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
{
WCHAR format[255];
INT ret;
size += 3 * sizeof(UINT);
/* urg! this function is badly designed because it won't tell us how
* much space is needed without doing a dummy run of storing the
* name into a buffer */
ret = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!ret)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
size += (ret + 1) * sizeof(WCHAR);
}
return size;
}
/******************************************************************************
* CLIPFORMAT_UserMarshal [OLE32.@]
*
* Marshals a clip format into a buffer.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pBuffer [I] Buffer to marshal the clip format into.
* pCF [I] Clip format to marshal.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{
TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
ALIGN_POINTER(pBuffer, 3);
/* only need to marshal the name if it is not a pre-defined type and
* we are going remote */
if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
{
WCHAR format[255];
UINT len;
*(DWORD *)pBuffer = WDT_REMOTE_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
len = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!len)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
len += 1;
*(UINT *)pBuffer = len;
pBuffer += sizeof(UINT);
*(UINT *)pBuffer = 0;
pBuffer += sizeof(UINT);
*(UINT *)pBuffer = len;
pBuffer += sizeof(UINT);
TRACE("marshaling format name %s\n", debugstr_w(format));
memcpy(pBuffer, format, len * sizeof(WCHAR));
pBuffer += len * sizeof(WCHAR);
}
else
{
*(DWORD *)pBuffer = WDT_INPROC_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
}
return pBuffer;
}
/******************************************************************************
* CLIPFORMAT_UserUnmarshal [OLE32.@]
*
* Unmarshals a clip format from a buffer.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pBuffer [I] Buffer to marshal the clip format from.
* pCF [O] Address that receive the unmarshaled clip format.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
* the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{
LONG fContext;
TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
ALIGN_POINTER(pBuffer, 3);
fContext = *(DWORD *)pBuffer;
pBuffer += 4;
if (fContext == WDT_INPROC_CALL)
{
*pCF = *(CLIPFORMAT *)pBuffer;
pBuffer += 4;
}
else if (fContext == WDT_REMOTE_CALL)
{
CLIPFORMAT cf;
UINT len;
/* pointer ID for registered clip format string */
if (*(DWORD *)pBuffer == 0)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += 4;
len = *(UINT *)pBuffer;
pBuffer += sizeof(UINT);
if (*(UINT *)pBuffer != 0)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(UINT);
if (*(UINT *)pBuffer != len)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(UINT);
if (((WCHAR *)pBuffer)[len - 1] != '\0')
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
pBuffer += len * sizeof(WCHAR);
if (!cf)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
*pCF = cf;
}
else
/* code not really appropriate, but nearest I can find */
RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
return pBuffer;
}
/******************************************************************************
* CLIPFORMAT_UserFree [OLE32.@]
*
* Frees an unmarshaled clip format.
*
* PARAMS
* pFlags [I] Flags. See notes.
* pCF [I] Clip format to free.
*
* RETURNS
* The end of the marshaled data in the buffer.
*
* NOTES
* Even though the function is documented to take a pointer to an unsigned
* long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
* structure, of which the first parameter is an unsigned long.
* This function is only intended to be called by the RPC runtime.
*/
void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
{
/* there is no inverse of the RegisterClipboardFormat function,
* so nothing to do */
}
static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
{
if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment