Author: cwittich Date: Sun Aug 9 16:28:07 2009 New Revision: 42564
URL: http://svn.reactos.org/svn/reactos?rev=42564&view=rev Log: partial rpcrt4 sync to wine 1.1.27 (fixes ~180 rpcrt4 winetests)
Modified: trunk/reactos/dll/win32/rpcrt4/ndr_es.c trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c
Modified: trunk/reactos/dll/win32/rpcrt4/ndr_es.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rpcrt4/ndr_es.c?r... ============================================================================== --- trunk/reactos/dll/win32/rpcrt4/ndr_es.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rpcrt4/ndr_es.c [iso-8859-1] Sun Aug 9 16:28:07 2009 @@ -105,7 +105,7 @@ handle_t Handle, void *UserState, MIDL_ES_ALLOC AllocFn, MIDL_ES_WRITE WriteFn, MIDL_ES_READ ReadFn, MIDL_ES_CODE Operation) { - MIDL_ES_MESSAGE *pEsMsg = (MIDL_ES_MESSAGE *)Handle; + MIDL_ES_MESSAGE *pEsMsg = Handle;
TRACE("(%p, %p, %p, %p, %p, %d)\n", Handle, UserState, AllocFn, WriteFn, ReadFn, Operation); @@ -324,7 +324,7 @@ { /* pointer to start of stack where arguments start */ RPC_MESSAGE rpcMsg; - MIDL_ES_MESSAGE *pEsMsg = (MIDL_ES_MESSAGE *)Handle; + MIDL_ES_MESSAGE *pEsMsg = Handle; /* size of stack */ unsigned short stack_size; /* header for procedure string */
Modified: trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/rpcrt4/ndr_marsha... ============================================================================== --- trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/rpcrt4/ndr_marshall.c [iso-8859-1] Sun Aug 9 16:28:07 2009 @@ -102,9 +102,9 @@ } while(0)
#define STD_OVERFLOW_CHECK(_Msg) do { \ - TRACE("buffer=%d/%d\n", _Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer, _Msg->BufferLength); \ + TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \ if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \ - ERR("buffer overflow %d bytes\n", _Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength)); \ + ERR("buffer overflow %d bytes\n", (ULONG)(_Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength))); \ } while (0)
#define NDR_POINTER_ID_BASE 0x20000 @@ -998,9 +998,8 @@ /*********************************************************************** * PointerMemorySize [internal] */ -static unsigned long PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, - unsigned char *Buffer, - PFORMAT_STRING pFormat) +static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, + unsigned char *Buffer, PFORMAT_STRING pFormat) { unsigned type = pFormat[0], attr = pFormat[1]; PFORMAT_STRING desc; @@ -1043,6 +1042,8 @@ }
if (attr & RPC_FC_P_DEREF) { + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void*)); + pStubMsg->MemorySize += sizeof(void*); TRACE("deref\n"); }
@@ -1339,8 +1340,8 @@ /*********************************************************************** * EmbeddedPointerMemorySize [internal] */ -static unsigned long EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, - PFORMAT_STRING pFormat) +static ULONG EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, + PFORMAT_STRING pFormat) { unsigned char *Mark = pStubMsg->BufferMark; unsigned rep, count, stride; @@ -1500,18 +1501,28 @@
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- /* Increment the buffer here instead of in PointerUnmarshall, - * as that is used by embedded pointers which already handle the incrementing - * the buffer, and shouldn't read any additional pointer data from the - * buffer */ - if (*pFormat != RPC_FC_RP) - { + if (*pFormat == RPC_FC_RP) + { + Buffer = pStubMsg->Buffer; + /* Do the NULL ref pointer check here because embedded pointers can be + * NULL if the type the pointer is embedded in was allocated rather than + * being passed in by the client */ + if (pStubMsg->IsClient && !*ppMemory) + { + ERR("NULL ref pointer is not allowed\n"); + RpcRaiseException(RPC_X_NULL_REF_POINTER); + } + } + else + { + /* Increment the buffer here instead of in PointerUnmarshall, + * as that is used by embedded pointers which already handle the incrementing + * the buffer, and shouldn't read any additional pointer data from the + * buffer */ ALIGN_POINTER(pStubMsg->Buffer, 4); Buffer = pStubMsg->Buffer; safe_buffer_increment(pStubMsg, 4); } - else - Buffer = pStubMsg->Buffer;
PointerUnmarshall(pStubMsg, Buffer, ppMemory, *ppMemory, pFormat, fMustAlloc);
@@ -1545,10 +1556,14 @@ ULONG WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) { - /* unsigned size = *(LPWORD)(pFormat+2); */ - FIXME("(%p,%p): stub\n", pStubMsg, pFormat); - PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat); - return 0; + unsigned char *Buffer = pStubMsg->Buffer; + if (*pFormat != RPC_FC_RP) + { + ALIGN_POINTER(pStubMsg->Buffer, 4); + safe_buffer_increment(pStubMsg, 4); + } + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *)); + return PointerMemorySize(pStubMsg, Buffer, pFormat); }
/*********************************************************************** @@ -2559,8 +2574,8 @@ } NDR_RANGE; #include "poppack.h"
-static unsigned long EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, - PFORMAT_STRING pFormat) +static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, + PFORMAT_STRING pFormat) { switch (*pFormat) { case RPC_FC_STRUCT: @@ -2621,8 +2636,8 @@ }
-static unsigned long EmbeddedComplexMemorySize(PMIDL_STUB_MESSAGE pStubMsg, - PFORMAT_STRING pFormat) +static ULONG EmbeddedComplexMemorySize(PMIDL_STUB_MESSAGE pStubMsg, + PFORMAT_STRING pFormat) { NDR_MEMORYSIZE m = NdrMemorySizer[*pFormat & NDR_TABLE_MASK];
@@ -2643,7 +2658,7 @@ { PFORMAT_STRING desc; NDR_MARSHALL m; - unsigned long size; + ULONG size;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -2709,7 +2724,7 @@ } TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer); pPointer += 4; - pMemory += 4; + pMemory += sizeof(void *); break; } case RPC_FC_ALIGNM4: @@ -2732,7 +2747,7 @@ pFormat += 2; desc = pFormat + *(const SHORT*)pFormat; size = EmbeddedComplexSize(pStubMsg, desc); - TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory); + TRACE("embedded complex (size=%d) <= %p\n", size, pMemory); m = NdrMarshaller[*desc & NDR_TABLE_MASK]; if (m) { @@ -2768,7 +2783,7 @@ { PFORMAT_STRING desc; NDR_UNMARSHALL m; - unsigned long size; + ULONG size;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -2834,7 +2849,7 @@ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ } pPointer += 4; - pMemory += 4; + pMemory += sizeof(void *); break; } case RPC_FC_ALIGNM4: @@ -2858,7 +2873,7 @@ pFormat += 2; desc = pFormat + *(const SHORT*)pFormat; size = EmbeddedComplexSize(pStubMsg, desc); - TRACE("embedded complex (size=%ld) => %p\n", size, pMemory); + TRACE("embedded complex (size=%d) => %p\n", size, pMemory); if (fMustAlloc) /* we can't pass fMustAlloc=TRUE into the marshaller for this type * since the type is part of the memory block that is encompassed by @@ -2900,7 +2915,7 @@ { PFORMAT_STRING desc; NDR_BUFFERSIZE m; - unsigned long size; + ULONG size;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -2949,7 +2964,7 @@ safe_buffer_length_increment(pStubMsg, 4); } pPointer += 4; - pMemory += 4; + pMemory += sizeof(void*); break; case RPC_FC_ALIGNM4: ALIGN_POINTER(pMemory, 4); @@ -3005,7 +3020,7 @@ { PFORMAT_STRING desc; NDR_FREE m; - unsigned long size; + ULONG size;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -3032,7 +3047,7 @@ case RPC_FC_POINTER: NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer); pPointer += 4; - pMemory += 4; + pMemory += sizeof(void *); break; case RPC_FC_ALIGNM4: ALIGN_POINTER(pMemory, 4); @@ -3080,12 +3095,12 @@ return pMemory; }
-static unsigned long ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, - PFORMAT_STRING pFormat, - PFORMAT_STRING pPointer) +static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, + PFORMAT_STRING pFormat, + PFORMAT_STRING pPointer) { PFORMAT_STRING desc; - unsigned long size = 0; + ULONG size = 0;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -3143,7 +3158,7 @@ safe_buffer_increment(pStubMsg, 4); /* for pointer ID */ } pPointer += 4; - size += 4; + size += sizeof(void *); break; } case RPC_FC_ALIGNM4: @@ -3179,11 +3194,10 @@ return size; }
-unsigned long ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, - PFORMAT_STRING pFormat) +ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) { PFORMAT_STRING desc; - unsigned long size = 0; + ULONG size = 0;
while (*pFormat != RPC_FC_END) { switch (*pFormat) { @@ -3264,18 +3278,18 @@ { int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers; /* save buffer length */ - unsigned long saved_buffer_length = pStubMsg->BufferLength; + ULONG saved_buffer_length = pStubMsg->BufferLength;
/* get the buffer pointer after complex array data, but before * pointer data */ - pStubMsg->BufferLength = pStubMsg->Buffer - pStubMsg->BufferStart; + pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer; pStubMsg->IgnoreEmbeddedPointers = 1; NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat); pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
/* save it for use by embedded pointer code later */ - pStubMsg->PointerBufferMark = pStubMsg->BufferStart + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", pStubMsg->PointerBufferMark - pStubMsg->Buffer); + pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - pStubMsg->Buffer)); pointer_buffer_mark_set = 1;
/* restore the original buffer length */ @@ -3294,7 +3308,7 @@
if (conf_array) { - unsigned long struct_size = ComplexStructSize(pStubMsg, pFormat); + ULONG struct_size = ComplexStructSize(pStubMsg, pFormat); array_compute_and_write_conformance(conf_array[0], pStubMsg, pMemory + struct_size, conf_array); /* these could be changed in ComplexMarshall so save them for later */ @@ -3361,7 +3375,7 @@
/* save it for use by embedded pointer code later */ pStubMsg->PointerBufferMark = pStubMsg->Buffer; - TRACE("difference = 0x%lx\n", (unsigned long)(pStubMsg->PointerBufferMark - saved_buffer)); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - saved_buffer)); pointer_buffer_mark_set = 1;
/* restore the original buffer */ @@ -3438,7 +3452,7 @@ if(!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength) { int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers; - unsigned long saved_buffer_length = pStubMsg->BufferLength; + ULONG saved_buffer_length = pStubMsg->BufferLength;
/* get the buffer length after complex struct data, but before * pointer data */ @@ -3449,7 +3463,7 @@ /* save it for use by embedded pointer code later */ pStubMsg->PointerLength = pStubMsg->BufferLength; pointer_length_set = 1; - TRACE("difference = 0x%lx\n", pStubMsg->PointerLength - saved_buffer_length); + TRACE("difference = 0x%x\n", pStubMsg->PointerLength - saved_buffer_length);
/* restore the original buffer length */ pStubMsg->BufferLength = saved_buffer_length; @@ -3465,7 +3479,7 @@
if (conf_array) { - unsigned long struct_size = ComplexStructSize(pStubMsg, pFormat); + ULONG struct_size = ComplexStructSize(pStubMsg, pFormat); array_compute_and_size_conformance(conf_array[0], pStubMsg, pMemory + struct_size, conf_array);
@@ -3823,21 +3837,21 @@ /* save buffer fields that may be changed by buffer sizer functions * and that may be needed later on */ int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers; - unsigned long saved_buffer_length = pStubMsg->BufferLength; - unsigned long saved_max_count = pStubMsg->MaxCount; - unsigned long saved_offset = pStubMsg->Offset; - unsigned long saved_actual_count = pStubMsg->ActualCount; + ULONG saved_buffer_length = pStubMsg->BufferLength; + ULONG_PTR saved_max_count = pStubMsg->MaxCount; + ULONG saved_offset = pStubMsg->Offset; + ULONG saved_actual_count = pStubMsg->ActualCount;
/* get the buffer pointer after complex array data, but before * pointer data */ - pStubMsg->BufferLength = pStubMsg->Buffer - pStubMsg->BufferStart; + pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer; pStubMsg->IgnoreEmbeddedPointers = 1; NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat); pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
/* save it for use by embedded pointer code later */ - pStubMsg->PointerBufferMark = pStubMsg->BufferStart + pStubMsg->BufferLength; - TRACE("difference = 0x%x\n", pStubMsg->Buffer - pStubMsg->BufferStart); + pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength; + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer)); pointer_buffer_mark_set = 1;
/* restore fields */ @@ -3915,7 +3929,7 @@ size = pStubMsg->MemorySize; pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
- TRACE("difference = 0x%lx\n", (unsigned long)(pStubMsg->Buffer - saved_buffer)); + TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - saved_buffer)); if (!pStubMsg->PointerBufferMark) { /* save it for use by embedded pointer code later */ @@ -3979,10 +3993,10 @@ /* save buffer fields that may be changed by buffer sizer functions * and that may be needed later on */ int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers; - unsigned long saved_buffer_length = pStubMsg->BufferLength; - unsigned long saved_max_count = pStubMsg->MaxCount; - unsigned long saved_offset = pStubMsg->Offset; - unsigned long saved_actual_count = pStubMsg->ActualCount; + ULONG saved_buffer_length = pStubMsg->BufferLength; + ULONG_PTR saved_max_count = pStubMsg->MaxCount; + ULONG saved_offset = pStubMsg->Offset; + ULONG saved_actual_count = pStubMsg->ActualCount;
/* get the buffer pointer after complex array data, but before * pointer data */ @@ -4237,7 +4251,7 @@ unsigned index = *(const WORD*)&pFormat[2]; DWORD bufsize = *(const WORD*)&pFormat[6]; USER_MARSHAL_CB umcb; - unsigned long saved_buffer_length = 0; + ULONG saved_buffer_length = 0;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat); TRACE("index=%d\n", index); @@ -4891,7 +4905,7 @@ { unsigned char type; unsigned char alignment; - unsigned long total_size; + ULONG total_size; } NDR_LGFARRAY_FORMAT; #include "poppack.h"
@@ -4903,7 +4917,7 @@ PFORMAT_STRING pFormat) { const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat; - unsigned long total_size; + ULONG total_size;
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
@@ -4946,7 +4960,7 @@ unsigned char fMustAlloc) { const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat; - unsigned long total_size; + ULONG total_size; unsigned char *saved_buffer;
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); @@ -5001,7 +5015,7 @@ PFORMAT_STRING pFormat) { const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat; - unsigned long total_size; + ULONG total_size;
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
@@ -5413,7 +5427,7 @@ }
static PFORMAT_STRING get_arm_offset_from_union_arm_selector(PMIDL_STUB_MESSAGE pStubMsg, - unsigned long discriminant, + ULONG discriminant, PFORMAT_STRING pFormat) { unsigned short num_arms, arm, type; @@ -5436,13 +5450,13 @@ { if(type == 0xffff) { - ERR("no arm for 0x%lx and no default case\n", discriminant); + ERR("no arm for 0x%x and no default case\n", discriminant); RpcRaiseException(RPC_S_INVALID_TAG); return NULL; } if(type == 0) { - TRACE("falling back to empty default case for 0x%lx\n", discriminant); + TRACE("falling back to empty default case for 0x%x\n", discriminant); return NULL; } } @@ -5547,7 +5561,6 @@ case RPC_FC_UP: case RPC_FC_OP: case RPC_FC_FP: - **(void***)ppMemory = NULL; ALIGN_POINTER(pStubMsg->Buffer, 4); saved_buffer = pStubMsg->Buffer; if (pStubMsg->PointerBufferMark) @@ -5671,8 +5684,8 @@ ALIGN_POINTER(pStubMsg->Buffer, 4); saved_buffer = pStubMsg->Buffer; safe_buffer_increment(pStubMsg, 4); - ALIGN_LENGTH(pStubMsg->MemorySize, 4); - pStubMsg->MemorySize += 4; + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *)); + pStubMsg->MemorySize += sizeof(void *); if (!pStubMsg->IgnoreEmbeddedPointers) PointerMemorySize(pStubMsg, saved_buffer, pFormat); break; @@ -5782,10 +5795,18 @@ if (fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, size);
+ /* we can't pass fMustAlloc=TRUE into the marshaller for the arm + * since the arm is part of the memory block that is encompassed by + * the whole union. Memory is forced to allocate when pointers + * are set to NULL, so we emulate that part of fMustAlloc=TRUE by + * clearing the memory we pass in to the unmarshaller */ + if (fMustAlloc) + memset(*ppMemory, 0, size); + NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &switch_type, FALSE); pMemoryArm = *ppMemory + increment;
- return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, fMustAlloc); + return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, FALSE); }
/*********************************************************************** @@ -5889,10 +5910,10 @@ return union_arm_marshall(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat); }
-static long unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, +static LONG unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING *ppFormat) { - long discriminant = 0; + LONG discriminant = 0;
switch(**ppFormat) { @@ -5945,7 +5966,7 @@ PFORMAT_STRING pFormat, unsigned char fMustAlloc) { - long discriminant; + LONG discriminant; unsigned short size;
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc); @@ -5953,7 +5974,7 @@
/* Unmarshall discriminant */ discriminant = unmarshall_discriminant(pStubMsg, &pFormat); - TRACE("unmarshalled discriminant %lx\n", discriminant); + TRACE("unmarshalled discriminant %x\n", discriminant);
pFormat += *(const SHORT*)pFormat;
@@ -5964,7 +5985,15 @@ if (fMustAlloc) *ppMemory = NdrAllocate(pStubMsg, size);
- return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, fMustAlloc); + /* we can't pass fMustAlloc=TRUE into the marshaller for the arm + * since the arm is part of the memory block that is encompassed by + * the whole union. Memory is forced to allocate when pointers + * are set to NULL, so we emulate that part of fMustAlloc=TRUE by + * clearing the memory we pass in to the unmarshaller */ + if (fMustAlloc) + memset(*ppMemory, 0, size); + + return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, FALSE); }
/*********************************************************************** @@ -6179,68 +6208,68 @@ TRACE("base_type = 0x%02x, low_value = %d, high_value = %d\n", base_type, pRange->low_value, pRange->high_value);
-#define RANGE_UNMARSHALL(type, format_spec) \ +#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec) \ do \ { \ - ALIGN_POINTER(pStubMsg->Buffer, sizeof(type)); \ + ALIGN_POINTER(pStubMsg->Buffer, sizeof(wire_type)); \ if (!fMustAlloc && !*ppMemory) \ fMustAlloc = TRUE; \ if (fMustAlloc) \ - *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \ - if (pStubMsg->Buffer + sizeof(type) > pStubMsg->BufferEnd) \ + *ppMemory = NdrAllocate(pStubMsg, sizeof(mem_type)); \ + if (pStubMsg->Buffer + sizeof(wire_type) > pStubMsg->BufferEnd) \ { \ ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", \ pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); \ RpcRaiseException(RPC_X_BAD_STUB_DATA); \ } \ - if ((*(type *)pStubMsg->Buffer < (type)pRange->low_value) || \ - (*(type *)pStubMsg->Buffer > (type)pRange->high_value)) \ + if ((*(wire_type *)pStubMsg->Buffer < (mem_type)pRange->low_value) || \ + (*(wire_type *)pStubMsg->Buffer > (mem_type)pRange->high_value)) \ { \ ERR("value exceeded bounds: " format_spec ", low: " format_spec ", high: " format_spec "\n", \ - *(type *)pStubMsg->Buffer, (type)pRange->low_value, \ - (type)pRange->high_value); \ + *(wire_type *)pStubMsg->Buffer, (mem_type)pRange->low_value, \ + (mem_type)pRange->high_value); \ RpcRaiseException(RPC_S_INVALID_BOUND); \ return NULL; \ } \ TRACE("*ppMemory: %p\n", *ppMemory); \ - **(type **)ppMemory = *(type *)pStubMsg->Buffer; \ - pStubMsg->Buffer += sizeof(type); \ + **(mem_type **)ppMemory = *(wire_type *)pStubMsg->Buffer; \ + pStubMsg->Buffer += sizeof(wire_type); \ } while (0)
switch(base_type) { case RPC_FC_CHAR: case RPC_FC_SMALL: - RANGE_UNMARSHALL(UCHAR, "%d"); + RANGE_UNMARSHALL(UCHAR, UCHAR, "%d"); TRACE("value: 0x%02x\n", **ppMemory); break; case RPC_FC_BYTE: case RPC_FC_USMALL: - RANGE_UNMARSHALL(CHAR, "%u"); + RANGE_UNMARSHALL(CHAR, CHAR, "%u"); TRACE("value: 0x%02x\n", **ppMemory); break; case RPC_FC_WCHAR: /* FIXME: valid? */ case RPC_FC_USHORT: - RANGE_UNMARSHALL(USHORT, "%u"); + RANGE_UNMARSHALL(USHORT, USHORT, "%u"); TRACE("value: 0x%04x\n", **(USHORT **)ppMemory); break; case RPC_FC_SHORT: - RANGE_UNMARSHALL(SHORT, "%d"); + RANGE_UNMARSHALL(SHORT, SHORT, "%d"); TRACE("value: 0x%04x\n", **(USHORT **)ppMemory); break; case RPC_FC_LONG: - RANGE_UNMARSHALL(LONG, "%d"); + case RPC_FC_ENUM32: + RANGE_UNMARSHALL(LONG, LONG, "%d"); TRACE("value: 0x%08x\n", **(ULONG **)ppMemory); break; case RPC_FC_ULONG: - RANGE_UNMARSHALL(ULONG, "%u"); + RANGE_UNMARSHALL(ULONG, ULONG, "%u"); TRACE("value: 0x%08x\n", **(ULONG **)ppMemory); break; case RPC_FC_ENUM16: - case RPC_FC_ENUM32: - FIXME("Unhandled enum type\n"); + RANGE_UNMARSHALL(UINT, USHORT, "%u"); + TRACE("value: 0x%08x\n", **(UINT **)ppMemory); break; - case RPC_FC_ERROR_STATUS_T: /* FIXME: valid? */ case RPC_FC_FLOAT: case RPC_FC_DOUBLE: case RPC_FC_HYPER: @@ -6538,36 +6567,51 @@ case RPC_FC_WCHAR: case RPC_FC_SHORT: case RPC_FC_USHORT: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); safe_buffer_increment(pStubMsg, sizeof(USHORT)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(USHORT)); pStubMsg->MemorySize += sizeof(USHORT); return sizeof(USHORT); case RPC_FC_LONG: case RPC_FC_ULONG: case RPC_FC_ENUM32: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG)); safe_buffer_increment(pStubMsg, sizeof(ULONG)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(ULONG)); pStubMsg->MemorySize += sizeof(ULONG); return sizeof(ULONG); case RPC_FC_FLOAT: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(float)); safe_buffer_increment(pStubMsg, sizeof(float)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(float)); pStubMsg->MemorySize += sizeof(float); return sizeof(float); case RPC_FC_DOUBLE: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(double)); safe_buffer_increment(pStubMsg, sizeof(double)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(double)); pStubMsg->MemorySize += sizeof(double); return sizeof(double); case RPC_FC_HYPER: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONGLONG)); safe_buffer_increment(pStubMsg, sizeof(ULONGLONG)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(ULONGLONG)); pStubMsg->MemorySize += sizeof(ULONGLONG); return sizeof(ULONGLONG); case RPC_FC_ERROR_STATUS_T: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(error_status_t)); safe_buffer_increment(pStubMsg, sizeof(error_status_t)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(error_status_t)); pStubMsg->MemorySize += sizeof(error_status_t); return sizeof(error_status_t); case RPC_FC_ENUM16: + ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); safe_buffer_increment(pStubMsg, sizeof(USHORT)); + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(UINT)); pStubMsg->MemorySize += sizeof(UINT); return sizeof(UINT); case RPC_FC_IGNORE: + ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *)); pStubMsg->MemorySize += sizeof(void *); return sizeof(void *); default: @@ -6627,7 +6671,7 @@ if (pFormat[1] & 0x80) NdrClientContextMarshall(pStubMsg, *(NDR_CCONTEXT **)pMemory, FALSE); else - NdrClientContextMarshall(pStubMsg, (NDR_CCONTEXT *)pMemory, FALSE); + NdrClientContextMarshall(pStubMsg, pMemory, FALSE);
return NULL; }