Commit 718fb9de authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: Properly align HMETAFILEPICT marshal data.

parent 7c166d67
...@@ -502,12 +502,12 @@ static void test_marshal_HMETAFILEPICT(void) ...@@ -502,12 +502,12 @@ static void test_marshal_HMETAFILEPICT(void)
GlobalUnlock(hmfp); GlobalUnlock(hmfp);
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 = HMETAFILEPICT_UserSize(&umcb.Flags, 0, &hmfp); size = HMETAFILEPICT_UserSize(&umcb.Flags, 1, &hmfp);
ok(size > 20, "size should be at least 20 bytes, not %d\n", size); ok(size > 24, "size should be at least 24 bytes, not %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);
buffer_end = HMETAFILEPICT_UserMarshal(&umcb.Flags, buffer, &hmfp); buffer_end = HMETAFILEPICT_UserMarshal(&umcb.Flags, buffer + 1, &hmfp);
wirehmfp = buffer; wirehmfp = buffer + 4;
ok(*(DWORD *)wirehmfp == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmfp);
wirehmfp += sizeof(DWORD); wirehmfp += sizeof(DWORD);
ok(*(DWORD *)wirehmfp == (DWORD)(DWORD_PTR)hmfp, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == (DWORD)(DWORD_PTR)hmfp, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD *)wirehmfp);
...@@ -528,16 +528,16 @@ static void test_marshal_HMETAFILEPICT(void) ...@@ -528,16 +528,16 @@ static void test_marshal_HMETAFILEPICT(void)
wirehmfp += sizeof(DWORD); wirehmfp += sizeof(DWORD);
/* Note use (buffer_end - buffer) instead of size here, because size is an /* Note use (buffer_end - buffer) instead of size here, because size is an
* overestimate with native */ * overestimate with native */
ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x28), "wirestgm + 0x20 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x2c), "wirestgm + 0x20 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
wirehmfp += sizeof(DWORD); wirehmfp += sizeof(DWORD);
ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x28), "wirestgm + 0x24 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x2c), "wirestgm + 0x24 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
wirehmfp += sizeof(DWORD); wirehmfp += sizeof(DWORD);
ok(*(WORD *)wirehmfp == 1, "wirehmfp + 0x28 should be 1 instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(WORD *)wirehmfp == 1, "wirehmfp + 0x28 should be 1 instead of 0x%08x\n", *(DWORD *)wirehmfp);
/* ... rest of data not tested - refer to tests for GetMetaFileBits /* ... rest of data not tested - refer to tests for GetMetaFileBits
* at this point */ * at this point */
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);
HMETAFILEPICT_UserUnmarshal(&umcb.Flags, buffer, &hmfp2); HMETAFILEPICT_UserUnmarshal(&umcb.Flags, buffer + 1, &hmfp2);
ok(hmfp2 != NULL, "HMETAFILEPICT didn't unmarshal\n"); ok(hmfp2 != NULL, "HMETAFILEPICT didn't unmarshal\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);
...@@ -551,12 +551,13 @@ static void test_marshal_HMETAFILEPICT(void) ...@@ -551,12 +551,13 @@ static void test_marshal_HMETAFILEPICT(void)
hmfp = NULL; hmfp = NULL;
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 = HMETAFILEPICT_UserSize(&umcb.Flags, 0, &hmfp); size = HMETAFILEPICT_UserSize(&umcb.Flags, 1, &hmfp);
ok(size == 8, "size should be 8 bytes, not %d\n", size); ok(size == 12, "size should be 12 bytes, not %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);
HMETAFILEPICT_UserMarshal(&umcb.Flags, buffer, &hmfp); buffer_end = HMETAFILEPICT_UserMarshal(&umcb.Flags, buffer + 1, &hmfp);
wirehmfp = buffer; ok(buffer_end == buffer + size, "got %p buffer %p\n", buffer_end, buffer);
wirehmfp = buffer + 4;
ok(*(DWORD *)wirehmfp == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmfp);
wirehmfp += sizeof(DWORD); wirehmfp += sizeof(DWORD);
ok(*(DWORD *)wirehmfp == (DWORD)(DWORD_PTR)hmfp, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD *)wirehmfp); ok(*(DWORD *)wirehmfp == (DWORD)(DWORD_PTR)hmfp, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD *)wirehmfp);
...@@ -564,7 +565,8 @@ static void test_marshal_HMETAFILEPICT(void) ...@@ -564,7 +565,8 @@ static void test_marshal_HMETAFILEPICT(void)
hmfp2 = NULL; hmfp2 = NULL;
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);
HMETAFILEPICT_UserUnmarshal(&umcb.Flags, buffer, &hmfp2); buffer_end = HMETAFILEPICT_UserUnmarshal(&umcb.Flags, buffer + 1, &hmfp2);
ok(buffer_end == buffer + size, "got %p buffer %p\n", buffer_end, buffer);
ok(hmfp2 == NULL, "NULL HMETAFILE didn't unmarshal\n"); ok(hmfp2 == NULL, "NULL HMETAFILE didn't unmarshal\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);
......
...@@ -1291,11 +1291,11 @@ void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf) ...@@ -1291,11 +1291,11 @@ void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
* the first parameter is a ULONG. * the first parameter is a ULONG.
* This function is only intended to be called by the RPC runtime. * This function is only intended to be called by the RPC runtime.
*/ */
ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp) ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG size, HMETAFILEPICT *phMfp)
{ {
ULONG size = StartingSize; TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), size, *phMfp);
TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp); ALIGN_LENGTH(size, 3);
size += sizeof(ULONG); size += sizeof(ULONG);
...@@ -1345,6 +1345,8 @@ unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned cha ...@@ -1345,6 +1345,8 @@ unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned cha
{ {
TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp); TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
ALIGN_POINTER(pBuffer, 3);
if (LOWORD(*pFlags) == MSHCTX_INPROC) if (LOWORD(*pFlags) == MSHCTX_INPROC)
{ {
if (sizeof(HMETAFILEPICT) == 8) if (sizeof(HMETAFILEPICT) == 8)
...@@ -1408,6 +1410,8 @@ unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned c ...@@ -1408,6 +1410,8 @@ unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned c
TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp); TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
ALIGN_POINTER(pBuffer, 3);
fContext = *(ULONG *)pBuffer; fContext = *(ULONG *)pBuffer;
pBuffer += sizeof(ULONG); pBuffer += sizeof(ULONG);
......
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