Commit 2eca96af authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Fix CLIPFORMAT marshalling on 64-bit platforms by not using the wireCLIPFORMAT type.

The wireCLIPFORMAT represents the memory equivalent format of the wire format and not the wire format itself. Also update the tests to do the same.
parent c80fdb88
...@@ -95,25 +95,23 @@ static void test_marshal_CLIPFORMAT(void) ...@@ -95,25 +95,23 @@ static void test_marshal_CLIPFORMAT(void)
RPC_MESSAGE rpc_msg; RPC_MESSAGE rpc_msg;
unsigned char *buffer; unsigned char *buffer;
ULONG size; ULONG size;
wireCLIPFORMAT wirecf;
CLIPFORMAT cf = RegisterClipboardFormatA("MyFormat"); CLIPFORMAT cf = RegisterClipboardFormatA("MyFormat");
CLIPFORMAT cf2; CLIPFORMAT cf2;
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
size = CLIPFORMAT_UserSize(&umcb.Flags, 0, &cf); size = CLIPFORMAT_UserSize(&umcb.Flags, 0, &cf);
ok(size == sizeof(*wirecf) + sizeof(cf_marshaled), "Wrong size %d\n", size); ok(size == 8 + sizeof(cf_marshaled), "CLIPFORMAT: Wrong size %d\n", size);
buffer = HeapAlloc(GetProcessHeap(), 0, size); buffer = HeapAlloc(GetProcessHeap(), 0, size);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
CLIPFORMAT_UserMarshal(&umcb.Flags, buffer, &cf); CLIPFORMAT_UserMarshal(&umcb.Flags, buffer, &cf);
wirecf = (wireCLIPFORMAT)buffer; ok(*(LONG *)(buffer + 0) == WDT_REMOTE_CALL, "CLIPFORMAT: Context should be WDT_REMOTE_CALL instead of 0x%08x\n", *(LONG *)(buffer + 0));
ok(wirecf->fContext == WDT_REMOTE_CALL, "Context should be WDT_REMOTE_CALL instead of 0x%08lx\n", wirecf->fContext); ok(*(DWORD *)(buffer + 4) == cf, "CLIPFORMAT: Marshaled value should be 0x%04x instead of 0x%04x\n", cf, *(DWORD *)(buffer + 4));
ok(wirecf->u.dwValue == cf, "Marshaled value should be 0x%04x instead of 0x%04x\n", cf, wirecf->u.dwValue); ok(!memcmp(buffer + 8, cf_marshaled, sizeof(cf_marshaled)), "Marshaled data differs\n");
ok(!memcmp(wirecf+1, cf_marshaled, sizeof(cf_marshaled)), "Marshaled data differs\n");
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_DIFFERENTMACHINE);
CLIPFORMAT_UserUnmarshal(&umcb.Flags, buffer, &cf2); CLIPFORMAT_UserUnmarshal(&umcb.Flags, buffer, &cf2);
ok(cf == cf2, "Didn't unmarshal properly\n"); ok(cf == cf2, "CLIPFORMAT: Didn't unmarshal properly\n");
HeapFree(GetProcessHeap(), 0, buffer); HeapFree(GetProcessHeap(), 0, buffer);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_DIFFERENTMACHINE);
......
...@@ -105,7 +105,7 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM ...@@ -105,7 +105,7 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM
TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF); TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF);
size += sizeof(userCLIPFORMAT); size += 8;
/* only need to marshal the name if it is not a pre-defined type and /* only need to marshal the name if it is not a pre-defined type and
* we are going remote */ * we are going remote */
...@@ -113,7 +113,7 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM ...@@ -113,7 +113,7 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM
{ {
WCHAR format[255]; WCHAR format[255];
INT ret; INT ret;
size += 3 * sizeof(INT); size += 3 * sizeof(UINT);
/* urg! this function is badly designed because it won't tell us how /* 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 * much space is needed without doing a dummy run of storing the
* name into a buffer */ * name into a buffer */
...@@ -146,30 +146,30 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM ...@@ -146,30 +146,30 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORM
*/ */
unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF) unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{ {
wireCLIPFORMAT wirecf = (wireCLIPFORMAT)pBuffer;
TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF); TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
wirecf->u.dwValue = *pCF;
pBuffer += sizeof(*wirecf);
/* only need to marshal the name if it is not a pre-defined type and /* only need to marshal the name if it is not a pre-defined type and
* we are going remote */ * we are going remote */
if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)) if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
{ {
WCHAR format[255]; WCHAR format[255];
INT len; UINT len;
wirecf->fContext = WDT_REMOTE_CALL;
*(DWORD *)pBuffer = WDT_REMOTE_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1); len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
if (!len) if (!len)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL); RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
len += 1; len += 1;
*(INT *)pBuffer = len; *(UINT *)pBuffer = len;
pBuffer += sizeof(INT); pBuffer += sizeof(UINT);
*(INT *)pBuffer = 0; *(UINT *)pBuffer = 0;
pBuffer += sizeof(INT); pBuffer += sizeof(UINT);
*(INT *)pBuffer = len; *(UINT *)pBuffer = len;
pBuffer += sizeof(INT); pBuffer += sizeof(UINT);
TRACE("marshaling format name %s\n", debugstr_wn(format, len-1)); TRACE("marshaling format name %s\n", debugstr_wn(format, len-1));
lstrcpynW((LPWSTR)pBuffer, format, len); lstrcpynW((LPWSTR)pBuffer, format, len);
pBuffer += len * sizeof(WCHAR); pBuffer += len * sizeof(WCHAR);
...@@ -177,7 +177,12 @@ unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char * ...@@ -177,7 +177,12 @@ unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *
pBuffer += sizeof(WCHAR); pBuffer += sizeof(WCHAR);
} }
else else
wirecf->fContext = WDT_INPROC_CALL; {
*(DWORD *)pBuffer = WDT_INPROC_CALL;
pBuffer += 4;
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
}
return pBuffer; return pBuffer;
} }
...@@ -203,24 +208,36 @@ unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char * ...@@ -203,24 +208,36 @@ unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *
*/ */
unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF) unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
{ {
wireCLIPFORMAT wirecf = (wireCLIPFORMAT)pBuffer; LONG fContext;
TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF); TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
pBuffer += sizeof(*wirecf); fContext = *(DWORD *)pBuffer;
if (wirecf->fContext == WDT_INPROC_CALL) pBuffer += 4;
*pCF = (CLIPFORMAT)wirecf->u.dwValue;
else if (wirecf->fContext == WDT_REMOTE_CALL) if (fContext == WDT_INPROC_CALL)
{
*pCF = *(CLIPFORMAT *)pBuffer;
pBuffer += 4;
}
else if (fContext == WDT_REMOTE_CALL)
{ {
CLIPFORMAT cf; CLIPFORMAT cf;
INT len = *(INT *)pBuffer; UINT len;
pBuffer += sizeof(INT);
if (*(INT *)pBuffer != 0) /* 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); RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(INT); pBuffer += sizeof(UINT);
if (*(INT *)pBuffer != len) if (*(UINT *)pBuffer != len)
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL); RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
pBuffer += sizeof(INT); pBuffer += sizeof(UINT);
if (((WCHAR *)pBuffer)[len] != '\0') if (((WCHAR *)pBuffer)[len] != '\0')
RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL); RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer)); TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
......
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