* - Checks for integer addition overflow in user marshall functions
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-
-#define NONAMELESSUNION
-#include "windef.h"
-#include "winbase.h"
-#include "winerror.h"
-
-#include "ndr_misc.h"
-#include "rpcndr.h"
-#include "ndrtypes.h"
-
-#include "wine/unicode.h"
-#include "wine/rpcfc.h"
-
-#include "wine/debug.h"
+#include "precomp.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
LITTLE_ENDIAN_UINT32_READ(pchar)
#endif
-/* _Align must be the desired alignment,
- * e.g. ALIGN_LENGTH(len, 4) to align on a dword boundary. */
-#define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align)-1)&~((_Align)-1))
-#define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
-#define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
-#define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
-#define ALIGN_POINTER_CLEAR(_Ptr, _Align) \
- do { \
- memset((_Ptr), 0, ((_Align) - (ULONG_PTR)(_Ptr)) & ((_Align) - 1)); \
- ALIGN_POINTER(_Ptr, _Align); \
- } while(0)
+static inline void align_length( ULONG *len, unsigned int align )
+{
+ *len = (*len + align - 1) & ~(align - 1);
+}
+
+static inline void align_pointer( unsigned char **ptr, unsigned int align )
+{
+ ULONG_PTR mask = align - 1;
+ *ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
+}
+
+static inline void align_pointer_clear( unsigned char **ptr, unsigned int align )
+{
+ ULONG_PTR mask = align - 1;
+ memset( *ptr, 0, (align - (ULONG_PTR)*ptr) & mask );
+ *ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
+}
#define STD_OVERFLOW_CHECK(_Msg) do { \
TRACE("buffer=%d/%d\n", (ULONG)(_Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer), _Msg->BufferLength); \
static ULONG WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING);
+static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
+ unsigned char *pMemory,
+ PFORMAT_STRING pFormat,
+ PFORMAT_STRING pPointer);
+static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
+ unsigned char *pMemory,
+ PFORMAT_STRING pFormat,
+ PFORMAT_STRING pPointer);
+static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
+ unsigned char *pMemory,
+ PFORMAT_STRING pFormat,
+ PFORMAT_STRING pPointer,
+ unsigned char fMustAlloc);
+static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
+ PFORMAT_STRING pFormat,
+ PFORMAT_STRING pPointer);
+static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
+ unsigned char *pMemory,
+ PFORMAT_STRING pFormat,
+ PFORMAT_STRING pPointer);
+
const NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE] = {
0,
NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
void *p;
NDR_MEMORY_LIST *mem_list;
- aligned_len = ALIGNED_LENGTH(len, 8);
+ aligned_len = (len + 7) & ~7;
adjusted_len = aligned_len + sizeof(NDR_MEMORY_LIST);
/* check for overflow */
if (adjusted_len < len)
static PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
{
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + 4 > pStubMsg->BufferEnd)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
goto done;
}
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + 8 > pStubMsg->BufferEnd)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
/* writes the conformance value to the buffer */
static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
{
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->MaxCount);
/* writes the variance values to the buffer */
static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
{
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + 8 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->Offset);
/* requests buffer space for the conformance value */
static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
{
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
if (pStubMsg->BufferLength + 4 < pStubMsg->BufferLength)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
pStubMsg->BufferLength += 4;
/* requests buffer space for the variance values */
static inline void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
{
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
if (pStubMsg->BufferLength + 8 < pStubMsg->BufferLength)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
pStubMsg->BufferLength += 8;
BYTE dtype = pFormat[0] & 0xf;
short ofs = *(const short *)&pFormat[2];
LPVOID ptr = NULL;
- DWORD data = 0;
+ ULONG_PTR data = 0;
if (!IsConformanceOrVariancePresent(pFormat)) {
/* null descriptor */
break;
case RPC_FC_CONSTANT_CONFORMANCE:
data = ofs | ((DWORD)pFormat[1] << 16);
- TRACE("constant conformance, val=%d\n", data);
+ TRACE("constant conformance, val=%ld\n", data);
*pCount = data;
goto finish_conf;
case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE:
case RPC_FC_CALLBACK:
{
unsigned char *old_stack_top = pStubMsg->StackTop;
+ ULONG_PTR max_count, old_max_count = pStubMsg->MaxCount;
+
pStubMsg->StackTop = ptr;
/* ofs is index into StubDesc->apfnExprEval */
pStubMsg->StackTop = old_stack_top;
/* the callback function always stores the computed value in MaxCount */
- *pCount = pStubMsg->MaxCount;
+ max_count = pStubMsg->MaxCount;
+ pStubMsg->MaxCount = old_max_count;
+ *pCount = max_count;
goto finish_conf;
}
default:
case RPC_FC_USMALL:
data = *(UCHAR*)ptr;
break;
+ case RPC_FC_HYPER:
+ data = *(ULONGLONG *)ptr;
+ break;
default:
FIXME("unknown conformance data type %x\n", dtype);
goto done_conf_grab;
}
- TRACE("dereferenced data type %x at %p, got %d\n", dtype, ptr, data);
+ TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
done_conf_grab:
switch (pFormat[1]) {
static inline PFORMAT_STRING SkipConformance(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
- if (IsConformanceOrVariancePresent(pFormat))
- {
if (pStubMsg->fHasNewCorrDesc)
pFormat += 6;
else
pFormat += 4;
- }
- return pFormat;
+ return pFormat;
+}
+
+static inline PFORMAT_STRING SkipVariance(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
+{
+ return SkipConformance( pStubMsg, pFormat );
}
/* multiply two numbers together, raising an RPC_S_INVALID_BOUND exception if
PFORMAT_STRING desc;
NDR_MARSHALL m;
ULONG pointer_id;
- int pointer_needs_marshaling;
+ BOOL pointer_needs_marshaling;
TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
ERR("NULL ref pointer is not allowed\n");
RpcRaiseException(RPC_X_NULL_REF_POINTER);
}
- pointer_needs_marshaling = 1;
+ pointer_needs_marshaling = TRUE;
break;
case RPC_FC_UP: /* unique pointer */
case RPC_FC_OP: /* object pointer - same as unique here */
if (Pointer)
- pointer_needs_marshaling = 1;
+ pointer_needs_marshaling = TRUE;
else
- pointer_needs_marshaling = 0;
+ pointer_needs_marshaling = FALSE;
pointer_id = Pointer ? NDR_POINTER_ID(pStubMsg) : 0;
TRACE("writing 0x%08x to buffer\n", pointer_id);
NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
PFORMAT_STRING desc;
NDR_UNMARSHALL m;
DWORD pointer_id = 0;
- int pointer_needs_unmarshaling;
+ BOOL pointer_needs_unmarshaling;
TRACE("(%p,%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pSrcPointer, pFormat, fMustAlloc);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
switch (type) {
case RPC_FC_RP: /* ref pointer (always non-null) */
- pointer_needs_unmarshaling = 1;
+ pointer_needs_unmarshaling = TRUE;
break;
case RPC_FC_UP: /* unique pointer */
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
TRACE("pointer_id is 0x%08x\n", pointer_id);
if (pointer_id)
- pointer_needs_unmarshaling = 1;
+ pointer_needs_unmarshaling = TRUE;
else {
*pPointer = NULL;
- pointer_needs_unmarshaling = 0;
+ pointer_needs_unmarshaling = FALSE;
}
break;
case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
fMustAlloc = TRUE;
}
if (pointer_id)
- pointer_needs_unmarshaling = 1;
+ pointer_needs_unmarshaling = TRUE;
else
{
*pPointer = NULL;
- pointer_needs_unmarshaling = 0;
+ pointer_needs_unmarshaling = FALSE;
}
break;
case RPC_FC_FP:
}
if (pointer_needs_unmarshaling) {
- unsigned char *base_ptr_val = *pPointer;
unsigned char **current_ptr = pPointer;
if (pStubMsg->IsClient) {
TRACE("client\n");
if (!fMustAlloc) {
if (pSrcPointer) {
TRACE("setting *pPointer to %p\n", pSrcPointer);
- *pPointer = base_ptr_val = pSrcPointer;
+ *pPointer = pSrcPointer;
} else
fMustAlloc = TRUE;
}
if (attr & RPC_FC_P_DEREF) {
fMustAlloc = TRUE;
} else {
- base_ptr_val = NULL;
*current_ptr = NULL;
}
}
if (attr & RPC_FC_P_DEREF) {
if (fMustAlloc) {
- base_ptr_val = NdrAllocate(pStubMsg, sizeof(void *));
+ unsigned char *base_ptr_val = NdrAllocate(pStubMsg, sizeof(void *));
*pPointer = base_ptr_val;
current_ptr = (unsigned char **)base_ptr_val;
} else
unsigned type = pFormat[0], attr = pFormat[1];
PFORMAT_STRING desc;
NDR_BUFFERSIZE m;
- int pointer_needs_sizing;
+ BOOL pointer_needs_sizing;
ULONG pointer_id;
TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
PFORMAT_STRING desc;
NDR_MEMORYSIZE m;
DWORD pointer_id = 0;
- int pointer_needs_sizing;
+ BOOL pointer_needs_sizing;
TRACE("(%p,%p,%p)\n", pStubMsg, Buffer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
switch (type) {
case RPC_FC_RP: /* ref pointer (always non-null) */
- pointer_needs_sizing = 1;
+ pointer_needs_sizing = TRUE;
break;
case RPC_FC_UP: /* unique pointer */
case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
TRACE("pointer_id is 0x%08x\n", pointer_id);
if (pointer_id)
- pointer_needs_sizing = 1;
+ pointer_needs_sizing = TRUE;
else
- pointer_needs_sizing = 0;
+ pointer_needs_sizing = FALSE;
break;
case RPC_FC_FP:
{
}
if (attr & RPC_FC_P_DEREF) {
- ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void*));
+ align_length(&pStubMsg->MemorySize, sizeof(void*));
pStubMsg->MemorySize += sizeof(void*);
TRACE("deref\n");
}
while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) {
default:
- FIXME("unknown repeat type %d\n", pFormat[0]);
+ FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
+ /* fallthrough */
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
switch (pFormat[0]) {
default:
- FIXME("unknown repeat type %d\n", pFormat[0]);
+ FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
+ /* fallthrough */
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) {
default:
- FIXME("unknown repeat type %d\n", pFormat[0]);
+ FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
+ /* fallthrough */
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) {
default:
- FIXME("unknown repeat type %d\n", pFormat[0]);
+ FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
+ /* fallthrough */
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
while (pFormat[0] != RPC_FC_END) {
switch (pFormat[0]) {
default:
- FIXME("unknown repeat type %d\n", pFormat[0]);
+ FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
+ /* fallthrough */
case RPC_FC_NO_REPEAT:
rep = 1;
stride = 0;
* the buffer, and shouldn't write any additional pointer data to the wire */
if (*pFormat != RPC_FC_RP)
{
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
Buffer = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, 4);
}
* 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);
+ align_pointer(&pStubMsg->Buffer, 4);
Buffer = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, 4);
}
* length, and shouldn't write anything more to the wire */
if (*pFormat != RPC_FC_RP)
{
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4);
}
unsigned char *Buffer = pStubMsg->Buffer;
if (*pFormat != RPC_FC_RP)
{
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
safe_buffer_increment(pStubMsg, 4);
}
- ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *));
+ align_length(&pStubMsg->MemorySize, sizeof(void *));
return PointerMemorySize(pStubMsg, Buffer, pFormat);
}
unsigned char FormatChar )
{
#define BASE_TYPE_UNMARSHALL(type) \
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(type)); \
+ align_pointer(&pStubMsg->Buffer, sizeof(type)); \
TRACE("pMemory: %p\n", pMemory); \
*(type *)pMemory = *(type *)pStubMsg->Buffer; \
pStubMsg->Buffer += sizeof(type);
TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG *)pMemory));
break;
case RPC_FC_ENUM16:
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
+ align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
TRACE("pMemory: %p\n", pMemory);
/* 16-bits on the wire, but int in memory */
*(UINT *)pMemory = *(USHORT *)pStubMsg->Buffer;
pStubMsg->Buffer += sizeof(USHORT);
TRACE("value: 0x%08x\n", *(UINT *)pMemory);
break;
+ case RPC_FC_INT3264:
+ align_pointer(&pStubMsg->Buffer, sizeof(INT));
+ /* 32-bits on the wire, but int_ptr in memory */
+ *(INT_PTR *)pMemory = *(INT *)pStubMsg->Buffer;
+ pStubMsg->Buffer += sizeof(INT);
+ TRACE("value: 0x%08lx\n", *(INT_PTR *)pMemory);
+ break;
+ case RPC_FC_UINT3264:
+ align_pointer(&pStubMsg->Buffer, sizeof(UINT));
+ /* 32-bits on the wire, but int_ptr in memory */
+ *(UINT_PTR *)pMemory = *(UINT *)pStubMsg->Buffer;
+ pStubMsg->Buffer += sizeof(UINT);
+ TRACE("value: 0x%08lx\n", *(UINT_PTR *)pMemory);
+ break;
case RPC_FC_IGNORE:
break;
default:
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
pStubMsg->BufferMark = pStubMsg->Buffer;
safe_copy_to_buffer(pStubMsg, pMemory, size);
unsigned char *saved_buffer;
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
if (fMustAlloc)
*ppMemory = NdrAllocate(pStubMsg, size);
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
+ align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
safe_buffer_length_increment(pStubMsg, size);
if (pFormat[0] != RPC_FC_STRUCT)
TRACE("(%p,%p)\n", pStubMsg, pFormat);
- ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
pStubMsg->MemorySize += size;
safe_buffer_increment(pStubMsg, size);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
+ DWORD count;
+
switch (fc)
{
case RPC_FC_CARRAY:
SizeConformance(pStubMsg);
break;
+ case RPC_FC_BOGUS_ARRAY:
+ count = *(const WORD *)(pFormat + 2);
+ pFormat += 4;
+ if (IsConformanceOrVariancePresent(pFormat)) SizeConformance(pStubMsg);
+ pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, count);
+ pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat, unsigned char fHasPointers)
{
- DWORD size;
+ DWORD i, size;
DWORD esize;
unsigned char alignment;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
- ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
+ align_length(&pStubMsg->BufferLength, alignment);
size = safe_multiply(esize, pStubMsg->MaxCount);
/* conformance value plus array */
alignment = pFormat[1] + 1;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
- pFormat = SkipConformance(pStubMsg, pFormat);
+ pFormat = SkipVariance(pStubMsg, pFormat);
SizeVariance(pStubMsg);
- ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
+ align_length(&pStubMsg->BufferLength, alignment);
size = safe_multiply(esize, pStubMsg->ActualCount);
safe_buffer_length_increment(pStubMsg, size);
size = safe_multiply(esize, pStubMsg->ActualCount);
safe_buffer_length_increment(pStubMsg, size);
break;
+ case RPC_FC_BOGUS_ARRAY:
+ alignment = pFormat[1] + 1;
+ pFormat = SkipConformance(pStubMsg, pFormat + 4);
+ if (IsConformanceOrVariancePresent(pFormat)) SizeVariance(pStubMsg);
+ pFormat = SkipVariance(pStubMsg, pFormat);
+
+ align_length(&pStubMsg->BufferLength, alignment);
+
+ size = pStubMsg->ActualCount;
+ for (i = 0; i < size; i++)
+ pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
+ ULONG def;
+ BOOL conformance_present;
+
switch (fc)
{
case RPC_FC_CARRAY:
pStubMsg->Offset = 0;
WriteConformance(pStubMsg);
break;
+ case RPC_FC_BOGUS_ARRAY:
+ def = *(const WORD *)(pFormat + 2);
+ pFormat += 4;
+ conformance_present = IsConformanceOrVariancePresent(pFormat);
+ pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
+ pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
+ if (conformance_present) WriteConformance(pStubMsg);
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
PFORMAT_STRING pFormat, unsigned char fHasPointers)
{
- DWORD size;
+ DWORD i, size;
DWORD esize;
unsigned char alignment;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, alignment);
+ align_pointer_clear(&pStubMsg->Buffer, alignment);
size = safe_multiply(esize, pStubMsg->MaxCount);
if (fHasPointers)
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
- /* conformance */
pFormat = SkipConformance(pStubMsg, pFormat + 4);
- /* variance */
- pFormat = SkipConformance(pStubMsg, pFormat);
+ pFormat = SkipVariance(pStubMsg, pFormat);
WriteVariance(pStubMsg);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, alignment);
+ align_pointer_clear(&pStubMsg->Buffer, alignment);
size = safe_multiply(esize, pStubMsg->ActualCount);
size = safe_multiply(esize, pStubMsg->ActualCount);
safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
break;
+ case RPC_FC_BOGUS_ARRAY:
+ alignment = pFormat[1] + 1;
+ pFormat = SkipConformance(pStubMsg, pFormat + 4);
+ if (IsConformanceOrVariancePresent(pFormat)) WriteVariance(pStubMsg);
+ pFormat = SkipVariance(pStubMsg, pFormat);
+
+ align_pointer_clear(&pStubMsg->Buffer, alignment);
+
+ size = pStubMsg->ActualCount;
+ for (i = 0; i < size; i++)
+ pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
static inline ULONG array_read_conformance(
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
{
- DWORD esize;
+ DWORD def, esize;
switch (fc)
{
else
ReadConformance(pStubMsg, NULL);
return safe_multiply(esize, pStubMsg->MaxCount);
+ case RPC_FC_BOGUS_ARRAY:
+ def = *(const WORD *)(pFormat + 2);
+ pFormat += 4;
+ if (IsConformanceOrVariancePresent(pFormat)) pFormat = ReadConformance(pStubMsg, pFormat);
+ else
+ {
+ pStubMsg->MaxCount = def;
+ pFormat = SkipConformance( pStubMsg, pFormat );
+ }
+ pFormat = SkipVariance( pStubMsg, pFormat );
+
+ esize = ComplexStructSize(pStubMsg, pFormat);
+ return safe_multiply(pStubMsg->MaxCount, esize);
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
ULONG bufsize, memsize;
WORD esize;
unsigned char alignment;
- unsigned char *saved_buffer;
- ULONG offset;
+ unsigned char *saved_buffer, *pMemory;
+ ULONG i, offset, count;
switch (fc)
{
pFormat = SkipConformance(pStubMsg, pFormat + 4);
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
if (fUnmarshall)
{
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
memsize = safe_multiply(esize, pStubMsg->MaxCount);
TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
}
return bufsize;
+
+ case RPC_FC_BOGUS_ARRAY:
+ alignment = pFormat[1] + 1;
+ pFormat = SkipConformance(pStubMsg, pFormat + 4);
+ pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
+
+ esize = ComplexStructSize(pStubMsg, pFormat);
+ memsize = safe_multiply(esize, pStubMsg->MaxCount);
+
+ assert( fUnmarshall );
+
+ if (!fMustAlloc && !*ppMemory)
+ fMustAlloc = TRUE;
+ if (fMustAlloc)
+ *ppMemory = NdrAllocate(pStubMsg, memsize);
+
+ align_pointer(&pStubMsg->Buffer, alignment);
+ saved_buffer = pStubMsg->Buffer;
+
+ pMemory = *ppMemory;
+ count = pStubMsg->ActualCount;
+ for (i = 0; i < count; i++)
+ pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
+ return pStubMsg->Buffer - saved_buffer;
+
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
unsigned char fHasPointers)
{
+ ULONG i, count, SavedMemorySize;
ULONG bufsize, memsize;
DWORD esize;
unsigned char alignment;
bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
pStubMsg->MemorySize += memsize;
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
if (fHasPointers)
pStubMsg->BufferMark = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, bufsize);
memsize = safe_multiply(esize, pStubMsg->MaxCount);
pStubMsg->MemorySize += memsize;
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
if (fHasPointers)
pStubMsg->BufferMark = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, bufsize);
safe_buffer_increment(pStubMsg, bufsize);
pStubMsg->MemorySize += memsize;
break;
+ case RPC_FC_BOGUS_ARRAY:
+ alignment = pFormat[1] + 1;
+ pFormat = SkipConformance(pStubMsg, pFormat + 4);
+ pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
+
+ align_pointer(&pStubMsg->Buffer, alignment);
+
+ SavedMemorySize = pStubMsg->MemorySize;
+
+ esize = ComplexStructSize(pStubMsg, pFormat);
+ memsize = safe_multiply(pStubMsg->MaxCount, esize);
+
+ count = pStubMsg->ActualCount;
+ for (i = 0; i < count; i++)
+ ComplexStructMemorySize(pStubMsg, pFormat, NULL);
+
+ pStubMsg->MemorySize = SavedMemorySize + memsize;
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
{
+ DWORD i, count;
+
switch (fc)
{
case RPC_FC_CARRAY:
case RPC_FC_C_WSTRING:
/* No embedded pointers so nothing to do */
break;
+ case RPC_FC_BOGUS_ARRAY:
+ count = *(const WORD *)(pFormat + 2);
+ pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, count);
+ pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
+
+ count = pStubMsg->ActualCount;
+ for (i = 0; i < count; i++)
+ pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
+ break;
default:
ERR("unknown array format 0x%x\n", fc);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
- maxsize = *(USHORT *)&pFormat[2];
+ maxsize = *(const USHORT *)&pFormat[2];
if (*pFormat == RPC_FC_CSTRING)
{
- ULONG i;
+ ULONG i = 0;
const char *str = (const char *)pMemory;
- for (i = 0; i < maxsize && *str; i++, str++)
- ;
+ while (i < maxsize && str[i]) i++;
TRACE("string=%s\n", debugstr_an(str, i));
pStubMsg->ActualCount = i + 1;
esize = 1;
}
else if (*pFormat == RPC_FC_WSTRING)
{
- ULONG i;
+ ULONG i = 0;
const WCHAR *str = (const WCHAR *)pMemory;
- for (i = 0; i < maxsize && *str; i++, str++)
- ;
+ while (i < maxsize && str[i]) i++;
TRACE("string=%s\n", debugstr_wn(str, i));
pStubMsg->ActualCount = i + 1;
esize = 2;
TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
pStubMsg, *ppMemory, pFormat, fMustAlloc);
- maxsize = *(USHORT *)&pFormat[2];
+ maxsize = *(const USHORT *)&pFormat[2];
ReadVariance(pStubMsg, NULL, maxsize);
if (pStubMsg->Offset)
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
- maxsize = *(USHORT *)&pFormat[2];
+ maxsize = *(const USHORT *)&pFormat[2];
SizeVariance(pStubMsg);
if (*pFormat == RPC_FC_CSTRING)
{
- ULONG i;
+ ULONG i = 0;
const char *str = (const char *)pMemory;
- for (i = 0; i < maxsize && *str; i++, str++)
- ;
+ while (i < maxsize && str[i]) i++;
TRACE("string=%s\n", debugstr_an(str, i));
pStubMsg->ActualCount = i + 1;
esize = 1;
}
else if (*pFormat == RPC_FC_WSTRING)
{
- ULONG i;
+ ULONG i = 0;
const WCHAR *str = (const WCHAR *)pMemory;
- for (i = 0; i < maxsize && *str; i++, str++)
- ;
+ while (i < maxsize && str[i]) i++;
TRACE("string=%s\n", debugstr_wn(str, i));
pStubMsg->ActualCount = i + 1;
esize = 2;
TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
- maxsize = *(USHORT *)&pFormat[2];
+ maxsize = *(const USHORT *)&pFormat[2];
ReadVariance(pStubMsg, NULL, maxsize);
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
return sizeof(ULONG);
case RPC_FC_FLOAT:
return sizeof(float);
pMemory += 2;
break;
case RPC_FC_ENUM16:
+ {
+ USHORT val = *(DWORD *)pMemory;
TRACE("enum16=%d <= %p\n", *(DWORD*)pMemory, pMemory);
if (32767 < *(DWORD*)pMemory)
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
- safe_copy_to_buffer(pStubMsg, pMemory, 2);
+ safe_copy_to_buffer(pStubMsg, &val, 2);
pMemory += 4;
break;
+ }
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
safe_copy_to_buffer(pStubMsg, pMemory, 4);
pMemory += 4;
break;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ {
+ UINT val = *(UINT_PTR *)pMemory;
+ TRACE("int3264=%ld <= %p\n", *(UINT_PTR *)pMemory, pMemory);
+ safe_copy_to_buffer(pStubMsg, &val, sizeof(UINT));
+ pMemory += sizeof(UINT_PTR);
+ break;
+ }
case RPC_FC_FLOAT:
TRACE("float=%f <= %p\n", *(float*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
case RPC_FC_POINTER:
{
unsigned char *saved_buffer;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer);
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP)
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
{
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
else if (*pPointer != RPC_FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
break;
}
case RPC_FC_ALIGNM2:
- ALIGN_POINTER(pMemory, 2);
+ align_pointer(&pMemory, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_POINTER(pMemory, 4);
+ align_pointer(&pMemory, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_POINTER(pMemory, 8);
+ align_pointer(&pMemory, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
pMemory += 2;
break;
case RPC_FC_ENUM16:
- safe_copy_from_buffer(pStubMsg, pMemory, 2);
- *(DWORD*)pMemory &= 0xffff;
+ {
+ WORD val;
+ safe_copy_from_buffer(pStubMsg, &val, 2);
+ *(DWORD*)pMemory = val;
TRACE("enum16=%d => %p\n", *(DWORD*)pMemory, pMemory);
if (32767 < *(DWORD*)pMemory)
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
pMemory += 4;
break;
+ }
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory);
pMemory += 4;
break;
+ case RPC_FC_INT3264:
+ {
+ INT val;
+ safe_copy_from_buffer(pStubMsg, &val, 4);
+ *(INT_PTR *)pMemory = val;
+ TRACE("int3264=%ld => %p\n", *(INT_PTR*)pMemory, pMemory);
+ pMemory += sizeof(INT_PTR);
+ break;
+ }
+ case RPC_FC_UINT3264:
+ {
+ UINT val;
+ safe_copy_from_buffer(pStubMsg, &val, 4);
+ *(UINT_PTR *)pMemory = val;
+ TRACE("uint3264=%ld => %p\n", *(UINT_PTR*)pMemory, pMemory);
+ pMemory += sizeof(UINT_PTR);
+ break;
+ }
case RPC_FC_FLOAT:
safe_copy_from_buffer(pStubMsg, pMemory, sizeof(float));
TRACE("float=%f => %p\n", *(float*)pMemory, pMemory);
case RPC_FC_POINTER:
{
unsigned char *saved_buffer;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
TRACE("pointer => %p\n", pMemory);
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP)
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
{
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
else if (*pPointer != RPC_FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
break;
}
case RPC_FC_ALIGNM2:
- ALIGN_POINTER_CLEAR(pMemory, 2);
+ align_pointer_clear(&pMemory, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_POINTER_CLEAR(pMemory, 4);
+ align_pointer_clear(&pMemory, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_POINTER_CLEAR(pMemory, 8);
+ align_pointer_clear(&pMemory, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
safe_buffer_length_increment(pStubMsg, 4);
pMemory += 4;
break;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ safe_buffer_length_increment(pStubMsg, 4);
+ pMemory += sizeof(INT_PTR);
+ break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
safe_buffer_length_increment(pStubMsg, 8);
}
if (*pPointer != RPC_FC_RP)
{
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4);
}
if (*pFormat == RPC_FC_POINTER)
pMemory += sizeof(void*);
break;
case RPC_FC_ALIGNM2:
- ALIGN_POINTER(pMemory, 2);
+ align_pointer(&pMemory, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_POINTER(pMemory, 4);
+ align_pointer(&pMemory, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_POINTER(pMemory, 8);
+ align_pointer(&pMemory, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
case RPC_FC_FLOAT:
pMemory += 4;
break;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ pMemory += sizeof(INT_PTR);
+ break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
pMemory += 8;
pMemory += sizeof(void *);
break;
case RPC_FC_ALIGNM2:
- ALIGN_POINTER(pMemory, 2);
+ align_pointer(&pMemory, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_POINTER(pMemory, 4);
+ align_pointer(&pMemory, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_POINTER(pMemory, 8);
+ align_pointer(&pMemory, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
size += 4;
safe_buffer_increment(pStubMsg, 4);
break;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ size += sizeof(INT_PTR);
+ safe_buffer_increment(pStubMsg, 4);
+ break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
size += 8;
case RPC_FC_POINTER:
{
unsigned char *saved_buffer;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
if (*pFormat != RPC_FC_POINTER)
pPointer = pFormat;
if (*pPointer != RPC_FC_RP)
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
{
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
else if (*pPointer != RPC_FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
break;
}
case RPC_FC_ALIGNM2:
- ALIGN_LENGTH(size, 2);
+ align_length(&size, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_LENGTH(size, 4);
+ align_length(&size, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_LENGTH(size, 8);
+ align_length(&size, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
case RPC_FC_FLOAT:
size += 4;
break;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ size += sizeof(INT_PTR);
+ break;
case RPC_FC_HYPER:
case RPC_FC_DOUBLE:
size += 8;
pFormat += 4;
break;
case RPC_FC_ALIGNM2:
- ALIGN_LENGTH(size, 2);
+ align_length(&size, 2);
break;
case RPC_FC_ALIGNM4:
- ALIGN_LENGTH(size, 4);
+ align_length(&size, 4);
break;
case RPC_FC_ALIGNM8:
- ALIGN_LENGTH(size, 8);
+ align_length(&size, 8);
break;
case RPC_FC_STRUCTPAD1:
case RPC_FC_STRUCTPAD2:
PFORMAT_STRING conf_array = NULL;
PFORMAT_STRING pointer_desc = NULL;
unsigned char *OldMemory = pStubMsg->Memory;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
ULONG count = 0;
ULONG max_count = 0;
ULONG offset = 0;
/* save it for use by embedded pointer code later */
pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - pStubMsg->Buffer));
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
/* restore the original buffer length */
pStubMsg->BufferLength = saved_buffer_length;
}
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
pFormat += 4;
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
PFORMAT_STRING conf_array = NULL;
PFORMAT_STRING pointer_desc = NULL;
unsigned char *pMemory;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
ULONG count = 0;
ULONG max_count = 0;
ULONG offset = 0;
/* save it for use by embedded pointer code later */
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->PointerBufferMark - saved_buffer));
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
/* restore the original buffer */
pStubMsg->Buffer = saved_buffer;
}
- ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
pFormat += 4;
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
+ align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
if(!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
{
TRACE("(%p,%p)\n", pStubMsg, pFormat);
- ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+ align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
pFormat += 4;
if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
- ULONG i, count, def;
- BOOL variance_present;
- unsigned char alignment;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
return NULL;
}
- alignment = pFormat[1] + 1;
-
if (!pStubMsg->PointerBufferMark)
{
/* save buffer fields that may be changed by buffer sizer functions
/* save it for use by embedded pointer code later */
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;
+ pointer_buffer_mark_set = TRUE;
/* restore fields */
pStubMsg->ActualCount = saved_actual_count;
pStubMsg->BufferLength = saved_buffer_length;
}
- def = *(const WORD*)&pFormat[2];
- pFormat += 4;
-
- pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
- TRACE("conformance = %ld\n", pStubMsg->MaxCount);
-
- variance_present = IsConformanceOrVariancePresent(pFormat);
- pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
- TRACE("variance = %d\n", pStubMsg->ActualCount);
-
- WriteConformance(pStubMsg);
- if (variance_present)
- WriteVariance(pStubMsg);
-
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, alignment);
-
- count = pStubMsg->ActualCount;
- for (i = 0; i < count; i++)
- pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
+ array_compute_and_write_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
+ array_write_variance_and_marshall(RPC_FC_BOGUS_ARRAY, pStubMsg,
+ pMemory, pFormat, TRUE /* fHasPointers */);
STD_OVERFLOW_CHECK(pStubMsg);
PFORMAT_STRING pFormat,
unsigned char fMustAlloc)
{
- ULONG i, count, size;
- unsigned char alignment;
- unsigned char *pMemory;
unsigned char *saved_buffer;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
int saved_ignore_embedded;
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
return NULL;
}
- alignment = pFormat[1] + 1;
-
saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
/* save buffer pointer */
saved_buffer = pStubMsg->Buffer;
pStubMsg->IgnoreEmbeddedPointers = 1;
pStubMsg->MemorySize = 0;
NdrComplexArrayMemorySize(pStubMsg, pFormat);
- size = pStubMsg->MemorySize;
pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
TRACE("difference = 0x%x\n", (ULONG)(pStubMsg->Buffer - saved_buffer));
{
/* save it for use by embedded pointer code later */
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
/* restore the original buffer */
pStubMsg->Buffer = saved_buffer;
- pFormat += 4;
-
- pFormat = ReadConformance(pStubMsg, pFormat);
- pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
-
- if (!fMustAlloc && !*ppMemory)
- fMustAlloc = TRUE;
- if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, size);
-
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
-
- pMemory = *ppMemory;
- count = pStubMsg->ActualCount;
- for (i = 0; i < count; i++)
- pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
+ array_read_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(RPC_FC_BOGUS_ARRAY, pStubMsg, ppMemory, pFormat, fMustAlloc,
+ TRUE /* fUseBufferMemoryServer */, TRUE /* fUnmarshall */);
if (pointer_buffer_mark_set)
{
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
- ULONG i, count, def;
- unsigned char alignment;
- BOOL variance_present;
int pointer_length_set = 0;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
return;
}
- alignment = pFormat[1] + 1;
-
if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
{
/* save buffer fields that may be changed by buffer sizer functions
pStubMsg->MaxCount = saved_max_count;
pStubMsg->BufferLength = saved_buffer_length;
}
- def = *(const WORD*)&pFormat[2];
- pFormat += 4;
-
- pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
- TRACE("conformance = %ld\n", pStubMsg->MaxCount);
- SizeConformance(pStubMsg);
-
- variance_present = IsConformanceOrVariancePresent(pFormat);
- pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
- TRACE("variance = %d\n", pStubMsg->ActualCount);
-
- if (variance_present)
- SizeVariance(pStubMsg);
- ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
-
- count = pStubMsg->ActualCount;
- for (i = 0; i < count; i++)
- pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
+ array_compute_and_size_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
+ array_buffer_size(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
if(pointer_length_set)
{
ULONG WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
- ULONG i, count, esize, SavedMemorySize, MemorySize;
- unsigned char alignment;
-
TRACE("(%p,%p)\n", pStubMsg, pFormat);
if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
return 0;
}
- alignment = pFormat[1] + 1;
-
- pFormat += 4;
-
- pFormat = ReadConformance(pStubMsg, pFormat);
- pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
-
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
-
- SavedMemorySize = pStubMsg->MemorySize;
-
- esize = ComplexStructSize(pStubMsg, pFormat);
-
- MemorySize = safe_multiply(pStubMsg->MaxCount, esize);
-
- count = pStubMsg->ActualCount;
- for (i = 0; i < count; i++)
- ComplexStructMemorySize(pStubMsg, pFormat, NULL);
-
- pStubMsg->MemorySize = SavedMemorySize;
-
- pStubMsg->MemorySize += MemorySize;
- return MemorySize;
+ array_read_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat);
+ array_memory_size(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
+ return pStubMsg->MemorySize;
}
/***********************************************************************
if (flags & USER_MARSHAL_POINTER)
{
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, USER_MARSHAL_PTR_PREFIX);
pStubMsg->Buffer += 4;
if (pStubMsg->PointerBufferMark)
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
}
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 8);
+ align_pointer_clear(&pStubMsg->Buffer, 8);
}
else
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, (flags & 0xf) + 1);
+ align_pointer_clear(&pStubMsg->Buffer, (flags & 0xf) + 1);
pStubMsg->Buffer =
pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
if (flags & USER_MARSHAL_POINTER)
{
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
/* skip pointer prefix */
pStubMsg->Buffer += 4;
if (pStubMsg->PointerBufferMark)
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
}
- ALIGN_POINTER(pStubMsg->Buffer, 8);
+ align_pointer(&pStubMsg->Buffer, 8);
}
else
- ALIGN_POINTER(pStubMsg->Buffer, (flags & 0xf) + 1);
+ align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (flags & USER_MARSHAL_POINTER)
{
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
/* skip pointer prefix */
safe_buffer_length_increment(pStubMsg, 4);
if (pStubMsg->IgnoreEmbeddedPointers)
pStubMsg->BufferLength = pStubMsg->PointerLength;
pStubMsg->PointerLength = 0;
}
- ALIGN_LENGTH(pStubMsg->BufferLength, 8);
+ align_length(&pStubMsg->BufferLength, 8);
}
else
- ALIGN_LENGTH(pStubMsg->BufferLength, (flags & 0xf) + 1);
+ align_length(&pStubMsg->BufferLength, (flags & 0xf) + 1);
if (bufsize) {
TRACE("size=%d\n", bufsize);
if (flags & USER_MARSHAL_POINTER)
{
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
/* skip pointer prefix */
pStubMsg->Buffer += 4;
if (pStubMsg->IgnoreEmbeddedPointers)
return pStubMsg->MemorySize;
- ALIGN_POINTER(pStubMsg->Buffer, 8);
+ align_pointer(&pStubMsg->Buffer, 8);
}
else
- ALIGN_POINTER(pStubMsg->Buffer, (flags & 0xf) + 1);
+ align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
if (!bufsize)
FIXME("not implemented for varying buffer size\n");
WriteConformance(pStubMsg);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, pCStructFormat->alignment + 1);
+ align_pointer_clear(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
pCArrayFormat = ReadConformance(pStubMsg, pCArrayFormat + 4);
- ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
+ align_pointer(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
pCArrayFormat = ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size, pCArrayFormat+4, 0);
SizeConformance(pStubMsg);
- ALIGN_LENGTH(pStubMsg->BufferLength, pCStructFormat->alignment + 1);
+ align_length(&pStubMsg->BufferLength, pCStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
pMemory + pCVStructFormat->memory_size,
pCVArrayFormat);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, pCVStructFormat->alignment + 1);
+ align_pointer_clear(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
memsize = array_read_conformance(*pCVArrayFormat, pStubMsg,
pCVArrayFormat);
- ALIGN_POINTER(pStubMsg->Buffer, pCVStructFormat->alignment + 1);
+ align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
pMemory + pCVStructFormat->memory_size,
pCVArrayFormat);
- ALIGN_LENGTH(pStubMsg->BufferLength, pCVStructFormat->alignment + 1);
+ align_length(&pStubMsg->BufferLength, pCVStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
pCVStructFormat->offset_to_array_description;
array_read_conformance(*pCVArrayFormat, pStubMsg, pCVArrayFormat);
- ALIGN_POINTER(pStubMsg->Buffer, pCVStructFormat->alignment + 1);
+ align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
return NULL;
}
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
+ align_pointer_clear(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
{
return NULL;
}
- ALIGN_POINTER(pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
+ align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
{
return;
}
- ALIGN_LENGTH(pStubMsg->BufferLength, pSmFArrayFormat->alignment + 1);
+ align_length(&pStubMsg->BufferLength, pSmFArrayFormat->alignment + 1);
if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
{
return 0;
}
- ALIGN_POINTER(pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
+ align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
{
WriteVariance(pStubMsg);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, alignment);
+ align_pointer_clear(&pStubMsg->Buffer, alignment);
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
pStubMsg->BufferMark = pStubMsg->Buffer;
pFormat = ReadVariance(pStubMsg, pFormat, elements);
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
bufsize = safe_multiply(esize, pStubMsg->ActualCount);
offset = pStubMsg->Offset;
SizeVariance(pStubMsg);
- ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
+ align_length(&pStubMsg->BufferLength, alignment);
safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
pFormat = ReadVariance(pStubMsg, pFormat, elements);
- ALIGN_POINTER(pStubMsg->Buffer, alignment);
+ align_pointer(&pStubMsg->Buffer, alignment);
safe_buffer_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
pStubMsg->MemorySize += size;
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
return *(const ULONG *)pMemory;
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ return *(const ULONG_PTR *)pMemory;
default:
FIXME("Unhandled base type: 0x%02x\n", fc);
return 0;
if (m)
{
unsigned char *saved_buffer = NULL;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
switch(*desc)
{
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
{
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
else
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
if (m)
{
unsigned char *saved_buffer = NULL;
- int pointer_buffer_mark_set = 0;
+ BOOL pointer_buffer_mark_set = FALSE;
switch(*desc)
{
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
{
pStubMsg->Buffer = pStubMsg->PointerBufferMark;
pStubMsg->PointerBufferMark = NULL;
- pointer_buffer_mark_set = 1;
+ pointer_buffer_mark_set = TRUE;
}
else
pStubMsg->Buffer += 4; /* for pointer ID */
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4); /* for pointer ID */
if (!pStubMsg->IgnoreEmbeddedPointers)
{
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, 4);
- ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *));
+ align_length(&pStubMsg->MemorySize, sizeof(void *));
pStubMsg->MemorySize += sizeof(void *);
if (!pStubMsg->IgnoreEmbeddedPointers)
PointerMemorySize(pStubMsg, saved_buffer, pFormat);
increment = (*pFormat & 0xf0) >> 4;
pFormat++;
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, increment);
+ align_pointer_clear(&pStubMsg->Buffer, increment);
switch_value = get_discriminant(switch_type, pMemory);
TRACE("got switch value 0x%x\n", switch_value);
increment = (*pFormat & 0xf0) >> 4;
pFormat++;
- ALIGN_POINTER(pStubMsg->Buffer, increment);
+ align_pointer(&pStubMsg->Buffer, increment);
switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
TRACE("got switch value 0x%x\n", switch_value);
increment = (*pFormat & 0xf0) >> 4;
pFormat++;
- ALIGN_LENGTH(pStubMsg->BufferLength, increment);
+ align_length(&pStubMsg->BufferLength, increment);
switch_value = get_discriminant(switch_type, pMemory);
TRACE("got switch value 0x%x\n", switch_value);
increment = (*pFormat & 0xf0) >> 4;
pFormat++;
- ALIGN_POINTER(pStubMsg->Buffer, increment);
+ align_pointer(&pStubMsg->Buffer, increment);
switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
TRACE("got switch value 0x%x\n", switch_value);
case RPC_FC_ENUM16:
{
USHORT d;
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
+ align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
discriminant = d;
break;
case RPC_FC_ULONG:
{
ULONG d;
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG));
+ align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
discriminant = d;
break;
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
- NDR_RANGE *pRange = (NDR_RANGE *)pFormat;
+ const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
unsigned char base_type;
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
PFORMAT_STRING pFormat,
unsigned char fMustAlloc)
{
- NDR_RANGE *pRange = (NDR_RANGE *)pFormat;
+ const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
unsigned char base_type;
TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec) \
do \
{ \
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(wire_type)); \
+ align_pointer(&pStubMsg->Buffer, sizeof(wire_type)); \
if (!fMustAlloc && !*ppMemory) \
fMustAlloc = TRUE; \
if (fMustAlloc) \
unsigned char *pMemory,
PFORMAT_STRING pFormat)
{
- NDR_RANGE *pRange = (NDR_RANGE *)pFormat;
+ const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
unsigned char base_type;
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
PMIDL_STUB_MESSAGE pStubMsg,
PFORMAT_STRING pFormat)
{
- NDR_RANGE *pRange = (NDR_RANGE *)pFormat;
+ const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
unsigned char base_type;
if (pRange->type != RPC_FC_RANGE)
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
case RPC_FC_USHORT:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(USHORT));
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(USHORT));
TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
break;
case RPC_FC_ULONG:
case RPC_FC_ERROR_STATUS_T:
case RPC_FC_ENUM32:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(ULONG));
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONG));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG));
TRACE("value: 0x%08x\n", *(ULONG *)pMemory);
break;
case RPC_FC_FLOAT:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(float));
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(float));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
break;
case RPC_FC_DOUBLE:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(double));
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(double));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
break;
case RPC_FC_HYPER:
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(ULONGLONG));
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONGLONG));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONGLONG));
TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory));
break;
case RPC_FC_ENUM16:
+ {
+ USHORT val = *(UINT *)pMemory;
/* only 16-bits on the wire, so do a sanity check */
if (*(UINT *)pMemory > SHRT_MAX)
RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, sizeof(USHORT));
- if (pStubMsg->Buffer + sizeof(USHORT) > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
- RpcRaiseException(RPC_X_BAD_STUB_DATA);
- *(USHORT *)pStubMsg->Buffer = *(UINT *)pMemory;
- pStubMsg->Buffer += sizeof(USHORT);
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
+ safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
TRACE("value: 0x%04x\n", *(UINT *)pMemory);
break;
+ }
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ {
+ UINT val = *(UINT_PTR *)pMemory;
+ align_pointer_clear(&pStubMsg->Buffer, sizeof(UINT));
+ safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
+ break;
+ }
case RPC_FC_IGNORE:
break;
default:
{
TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
-#define BASE_TYPE_UNMARSHALL(type) \
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(type)); \
+#define BASE_TYPE_UNMARSHALL(type) do { \
+ align_pointer(&pStubMsg->Buffer, sizeof(type)); \
if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \
{ \
*ppMemory = pStubMsg->Buffer; \
*ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \
TRACE("*ppMemory: %p\n", *ppMemory); \
safe_copy_from_buffer(pStubMsg, *ppMemory, sizeof(type)); \
- }
+ } \
+ } while (0)
switch(*pFormat)
{
TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
break;
case RPC_FC_ENUM16:
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
+ {
+ USHORT val;
+ align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (fMustAlloc)
*ppMemory = NdrAllocate(pStubMsg, sizeof(UINT));
- if (pStubMsg->Buffer + sizeof(USHORT) > pStubMsg->BufferEnd)
- RpcRaiseException(RPC_X_BAD_STUB_DATA);
- TRACE("*ppMemory: %p\n", *ppMemory);
+ safe_copy_from_buffer(pStubMsg, &val, sizeof(USHORT));
/* 16-bits on the wire, but int in memory */
- **(UINT **)ppMemory = *(USHORT *)pStubMsg->Buffer;
- pStubMsg->Buffer += sizeof(USHORT);
+ **(UINT **)ppMemory = val;
TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
break;
+ }
+ case RPC_FC_INT3264:
+ if (sizeof(INT_PTR) == sizeof(INT)) BASE_TYPE_UNMARSHALL(INT);
+ else
+ {
+ INT val;
+ align_pointer(&pStubMsg->Buffer, sizeof(INT));
+ if (!fMustAlloc && !*ppMemory)
+ fMustAlloc = TRUE;
+ if (fMustAlloc)
+ *ppMemory = NdrAllocate(pStubMsg, sizeof(INT_PTR));
+ safe_copy_from_buffer(pStubMsg, &val, sizeof(INT));
+ **(INT_PTR **)ppMemory = val;
+ TRACE("value: 0x%08lx\n", **(INT_PTR **)ppMemory);
+ }
+ break;
+ case RPC_FC_UINT3264:
+ if (sizeof(UINT_PTR) == sizeof(UINT)) BASE_TYPE_UNMARSHALL(UINT);
+ else
+ {
+ UINT val;
+ align_pointer(&pStubMsg->Buffer, sizeof(UINT));
+ if (!fMustAlloc && !*ppMemory)
+ fMustAlloc = TRUE;
+ if (fMustAlloc)
+ *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT_PTR));
+ safe_copy_from_buffer(pStubMsg, &val, sizeof(UINT));
+ **(UINT_PTR **)ppMemory = val;
+ TRACE("value: 0x%08lx\n", **(UINT_PTR **)ppMemory);
+ }
+ break;
case RPC_FC_IGNORE:
break;
default:
case RPC_FC_SHORT:
case RPC_FC_USHORT:
case RPC_FC_ENUM16:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(USHORT));
+ align_length(&pStubMsg->BufferLength, sizeof(USHORT));
safe_buffer_length_increment(pStubMsg, sizeof(USHORT));
break;
case RPC_FC_LONG:
case RPC_FC_ULONG:
case RPC_FC_ENUM32:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONG));
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ align_length(&pStubMsg->BufferLength, sizeof(ULONG));
safe_buffer_length_increment(pStubMsg, sizeof(ULONG));
break;
case RPC_FC_FLOAT:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(float));
+ align_length(&pStubMsg->BufferLength, sizeof(float));
safe_buffer_length_increment(pStubMsg, sizeof(float));
break;
case RPC_FC_DOUBLE:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(double));
+ align_length(&pStubMsg->BufferLength, sizeof(double));
safe_buffer_length_increment(pStubMsg, sizeof(double));
break;
case RPC_FC_HYPER:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONGLONG));
+ align_length(&pStubMsg->BufferLength, sizeof(ULONGLONG));
safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG));
break;
case RPC_FC_ERROR_STATUS_T:
- ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(error_status_t));
+ align_length(&pStubMsg->BufferLength, sizeof(error_status_t));
safe_buffer_length_increment(pStubMsg, sizeof(error_status_t));
break;
case RPC_FC_IGNORE:
case RPC_FC_WCHAR:
case RPC_FC_SHORT:
case RPC_FC_USHORT:
- ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
+ align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
safe_buffer_increment(pStubMsg, sizeof(USHORT));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
safe_buffer_increment(pStubMsg, sizeof(ULONG));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(float));
safe_buffer_increment(pStubMsg, sizeof(float));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(double));
safe_buffer_increment(pStubMsg, sizeof(double));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(ULONGLONG));
safe_buffer_increment(pStubMsg, sizeof(ULONGLONG));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(error_status_t));
safe_buffer_increment(pStubMsg, sizeof(error_status_t));
- ALIGN_LENGTH(pStubMsg->MemorySize, 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));
+ align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
safe_buffer_increment(pStubMsg, sizeof(USHORT));
- ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(UINT));
+ align_length(&pStubMsg->MemorySize, sizeof(UINT));
pStubMsg->MemorySize += sizeof(UINT);
return sizeof(UINT);
+ case RPC_FC_INT3264:
+ case RPC_FC_UINT3264:
+ align_pointer(&pStubMsg->Buffer, sizeof(UINT));
+ safe_buffer_increment(pStubMsg, sizeof(UINT));
+ align_length(&pStubMsg->MemorySize, sizeof(UINT_PTR));
+ pStubMsg->MemorySize += sizeof(UINT_PTR);
+ return sizeof(UINT_PTR);
case RPC_FC_IGNORE:
- ALIGN_LENGTH(pStubMsg->MemorySize, sizeof(void *));
+ align_length(&pStubMsg->MemorySize, sizeof(void *));
pStubMsg->MemorySize += sizeof(void *);
return sizeof(void *);
default:
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
- ALIGN_LENGTH(pStubMsg->BufferLength, 4);
+ align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, cbNDRContext);
}
{
TRACE("(%p, %p, %d)\n", pStubMsg, ContextHandle, fCheck);
- ALIGN_POINTER_CLEAR(pStubMsg->Buffer, 4);
+ align_pointer_clear(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
{
{
TRACE("(%p, %p, %p)\n", pStubMsg, pContextHandle, BindHandle);
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > pStubMsg->BufferEnd)
RpcRaiseException(RPC_X_BAD_STUB_DATA);
{
TRACE("(%p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine);
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
{
TRACE("(%p)\n", pStubMsg);
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
{
TRACE("(%p, %p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
{
TRACE("(%p, %p)\n", pStubMsg, pFormat);
- ALIGN_POINTER(pStubMsg->Buffer, 4);
+ align_pointer(&pStubMsg->Buffer, 4);
if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
{