Commit 088c0857 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Add support for marshalling/unmarshalling complex arrays of pointers.

parent eb4100e9
...@@ -2711,12 +2711,18 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2711,12 +2711,18 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double)); safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
pMemory += sizeof(double); pMemory += sizeof(double);
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
{ {
unsigned char *saved_buffer; unsigned char *saved_buffer;
int pointer_buffer_mark_set = 0; int pointer_buffer_mark_set = 0;
TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory); TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer); TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer);
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP) if (*pPointer != RPC_FC_RP)
ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4); ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer; saved_buffer = pStubMsg->Buffer;
...@@ -2738,7 +2744,10 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2738,7 +2744,10 @@ static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
} }
TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer); TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer);
pPointer += 4; if (*pFormat == RPC_FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *); pMemory += sizeof(void *);
break; break;
} }
...@@ -2850,11 +2859,17 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2850,11 +2859,17 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
TRACE("double=%f => %p\n", *(double*)pMemory, pMemory); TRACE("double=%f => %p\n", *(double*)pMemory, pMemory);
pMemory += sizeof(double); pMemory += sizeof(double);
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
{ {
unsigned char *saved_buffer; unsigned char *saved_buffer;
int pointer_buffer_mark_set = 0; int pointer_buffer_mark_set = 0;
TRACE("pointer => %p\n", pMemory); TRACE("pointer => %p\n", pMemory);
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP) if (*pPointer != RPC_FC_RP)
ALIGN_POINTER(pStubMsg->Buffer, 4); ALIGN_POINTER(pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer; saved_buffer = pStubMsg->Buffer;
...@@ -2876,7 +2891,10 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2876,7 +2891,10 @@ static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
if (*pPointer != RPC_FC_RP) if (*pPointer != RPC_FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
} }
pPointer += 4; if (*pFormat == RPC_FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *); pMemory += sizeof(void *);
break; break;
} }
...@@ -2979,7 +2997,13 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2979,7 +2997,13 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
safe_buffer_length_increment(pStubMsg, 8); safe_buffer_length_increment(pStubMsg, 8);
pMemory += 8; pMemory += 8;
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (!pStubMsg->IgnoreEmbeddedPointers) if (!pStubMsg->IgnoreEmbeddedPointers)
{ {
int saved_buffer_length = pStubMsg->BufferLength; int saved_buffer_length = pStubMsg->BufferLength;
...@@ -2996,7 +3020,10 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -2996,7 +3020,10 @@ static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
ALIGN_LENGTH(pStubMsg->BufferLength, 4); ALIGN_LENGTH(pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4); safe_buffer_length_increment(pStubMsg, 4);
} }
pPointer += 4; if (*pFormat == RPC_FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void*); pMemory += sizeof(void*);
break; break;
case RPC_FC_ALIGNM2: case RPC_FC_ALIGNM2:
...@@ -3082,9 +3109,18 @@ static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -3082,9 +3109,18 @@ static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
case RPC_FC_DOUBLE: case RPC_FC_DOUBLE:
pMemory += 8; pMemory += 8;
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer); NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
pPointer += 4; if (*pFormat == RPC_FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *); pMemory += sizeof(void *);
break; break;
case RPC_FC_ALIGNM2: case RPC_FC_ALIGNM2:
...@@ -3174,10 +3210,16 @@ static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -3174,10 +3210,16 @@ static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
size += 8; size += 8;
safe_buffer_increment(pStubMsg, 8); safe_buffer_increment(pStubMsg, 8);
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
{ {
unsigned char *saved_buffer; unsigned char *saved_buffer;
int pointer_buffer_mark_set = 0; int pointer_buffer_mark_set = 0;
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP) if (*pPointer != RPC_FC_RP)
ALIGN_POINTER(pStubMsg->Buffer, 4); ALIGN_POINTER(pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer; saved_buffer = pStubMsg->Buffer;
...@@ -3200,7 +3242,10 @@ static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -3200,7 +3242,10 @@ static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
if (*pPointer != RPC_FC_RP) if (*pPointer != RPC_FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
} }
pPointer += 4; if (*pFormat == RPC_FC_POINTER)
pPointer += 4;
else
pFormat += 4;
size += sizeof(void *); size += sizeof(void *);
break; break;
} }
...@@ -3269,8 +3314,14 @@ ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) ...@@ -3269,8 +3314,14 @@ ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
case RPC_FC_DOUBLE: case RPC_FC_DOUBLE:
size += 8; size += 8;
break; break;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_POINTER: case RPC_FC_POINTER:
size += sizeof(void *); size += sizeof(void *);
if (*pFormat != RPC_FC_POINTER)
pFormat += 4;
break; break;
case RPC_FC_ALIGNM2: case RPC_FC_ALIGNM2:
ALIGN_LENGTH(size, 2); ALIGN_LENGTH(size, 2);
......
...@@ -1997,7 +1997,6 @@ static void test_conf_complex_array(void) ...@@ -1997,7 +1997,6 @@ static void test_conf_complex_array(void)
win_skip("Tests crash on Win9x, WinMe and NT4\n"); win_skip("Tests crash on Win9x, WinMe and NT4\n");
goto cleanup; goto cleanup;
} }
todo_wine
ok(StubMsg.BufferLength >= expected_length, "length %d\n", StubMsg.BufferLength); ok(StubMsg.BufferLength >= expected_length, "length %d\n", StubMsg.BufferLength);
/*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/ /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
...@@ -2013,13 +2012,8 @@ todo_wine ...@@ -2013,13 +2012,8 @@ todo_wine
#endif #endif
ok(ptr == NULL, "ret %p\n", ptr); ok(ptr == NULL, "ret %p\n", ptr);
todo_wine
ok((char*)StubMsg.Buffer == (char*)StubMsg.BufferStart + expected_length, "not at expected length\n"); ok((char*)StubMsg.Buffer == (char*)StubMsg.BufferStart + expected_length, "not at expected length\n");
/* Skip tests on Wine until the todo_wine is removed */
if((char*)StubMsg.Buffer == (char*)StubMsg.BufferStart + expected_length)
{
buf = (DWORD *)StubMsg.BufferStart; buf = (DWORD *)StubMsg.BufferStart;
ok(*buf == memsrc.dim1, "dim1 should have been %d instead of %08x\n", memsrc.dim1, *buf); ok(*buf == memsrc.dim1, "dim1 should have been %d instead of %08x\n", memsrc.dim1, *buf);
...@@ -2069,7 +2063,6 @@ todo_wine ...@@ -2069,7 +2063,6 @@ todo_wine
#else #else
NdrSimpleStructFree( &StubMsg, (unsigned char*)mem, &fmtstr_complex_array[32]); NdrSimpleStructFree( &StubMsg, (unsigned char*)mem, &fmtstr_complex_array[32]);
#endif #endif
}
HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer); HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
......
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