#include "ndrtypes.h"
#include "wine/unicode.h"
-#include "wine/rpcfc.h"
-
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
*ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
}
+static inline void align_pointer_offset( unsigned char **ptr, unsigned char *base, unsigned int align )
+{
+ ULONG_PTR mask = align - 1;
+ *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
+}
+
+static inline void align_pointer_offset_clear( unsigned char **ptr, unsigned char *base, unsigned int align )
+{
+ ULONG_PTR mask = align - 1;
+ memset( *ptr, 0, (align - (ULONG_PTR)(*ptr - base)) & mask );
+ *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
+}
+
#define STD_OVERFLOW_CHECK(_Msg) do { \
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) \
return p;
}
+static void *NdrAllocateZero(MIDL_STUB_MESSAGE *stubmsg, SIZE_T len)
+{
+ void *mem = NdrAllocate(stubmsg, len);
+ memset(mem, 0, len);
+ return mem;
+}
+
static void NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
{
TRACE("(%p, %p)\n", pStubMsg, Pointer);
}
switch (pFormat[0] & 0xf0) {
- case RPC_FC_NORMAL_CONFORMANCE:
+ case FC_NORMAL_CONFORMANCE:
TRACE("normal conformance, ofs=%d\n", ofs);
ptr = pMemory;
break;
- case RPC_FC_POINTER_CONFORMANCE:
+ case FC_POINTER_CONFORMANCE:
TRACE("pointer conformance, ofs=%d\n", ofs);
ptr = pStubMsg->Memory;
break;
- case RPC_FC_TOP_LEVEL_CONFORMANCE:
+ case FC_TOP_LEVEL_CONFORMANCE:
TRACE("toplevel conformance, ofs=%d\n", ofs);
if (pStubMsg->StackTop) {
ptr = pStubMsg->StackTop;
goto finish_conf;
}
break;
- case RPC_FC_CONSTANT_CONFORMANCE:
+ case FC_CONSTANT_CONFORMANCE:
data = ofs | ((DWORD)pFormat[1] << 16);
TRACE("constant conformance, val=%ld\n", data);
*pCount = data;
goto finish_conf;
- case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE:
+ case FC_TOP_LEVEL_MULTID_CONFORMANCE:
FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
if (pStubMsg->StackTop) {
ptr = pStubMsg->StackTop;
}
switch (pFormat[1]) {
- case RPC_FC_DEREFERENCE:
+ case FC_DEREFERENCE:
ptr = *(LPVOID*)((char *)ptr + ofs);
break;
- case RPC_FC_CALLBACK:
+ case FC_CALLBACK:
{
unsigned char *old_stack_top = pStubMsg->StackTop;
ULONG_PTR max_count, old_max_count = pStubMsg->MaxCount;
}
switch (dtype) {
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
+ case FC_LONG:
+ case FC_ULONG:
data = *(DWORD*)ptr;
break;
- case RPC_FC_SHORT:
+ case FC_SHORT:
data = *(SHORT*)ptr;
break;
- case RPC_FC_USHORT:
+ case FC_USHORT:
data = *(USHORT*)ptr;
break;
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
+ case FC_CHAR:
+ case FC_SMALL:
data = *(CHAR*)ptr;
break;
- case RPC_FC_BYTE:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_USMALL:
data = *(UCHAR*)ptr;
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
data = *(ULONGLONG *)ptr;
break;
default:
done_conf_grab:
switch (pFormat[1]) {
- case RPC_FC_DEREFERENCE: /* already handled */
+ case FC_DEREFERENCE: /* already handled */
case 0: /* no op */
*pCount = data;
break;
- case RPC_FC_ADD_1:
+ case FC_ADD_1:
*pCount = data + 1;
break;
- case RPC_FC_SUB_1:
+ case FC_SUB_1:
*pCount = data - 1;
break;
- case RPC_FC_MULT_2:
+ case FC_MULT_2:
*pCount = data * 2;
break;
- case RPC_FC_DIV_2:
+ case FC_DIV_2:
*pCount = data / 2;
break;
default:
static inline void dump_pointer_attr(unsigned char attr)
{
- if (attr & RPC_FC_P_ALLOCALLNODES)
- TRACE(" RPC_FC_P_ALLOCALLNODES");
- if (attr & RPC_FC_P_DONTFREE)
- TRACE(" RPC_FC_P_DONTFREE");
- if (attr & RPC_FC_P_ONSTACK)
- TRACE(" RPC_FC_P_ONSTACK");
- if (attr & RPC_FC_P_SIMPLEPOINTER)
- TRACE(" RPC_FC_P_SIMPLEPOINTER");
- if (attr & RPC_FC_P_DEREF)
- TRACE(" RPC_FC_P_DEREF");
+ if (attr & FC_ALLOCATE_ALL_NODES)
+ TRACE(" FC_ALLOCATE_ALL_NODES");
+ if (attr & FC_DONT_FREE)
+ TRACE(" FC_DONT_FREE");
+ if (attr & FC_ALLOCED_ON_STACK)
+ TRACE(" FC_ALLOCED_ON_STACK");
+ if (attr & FC_SIMPLE_POINTER)
+ TRACE(" FC_SIMPLE_POINTER");
+ if (attr & FC_POINTER_DEREF)
+ TRACE(" FC_POINTER_DEREF");
TRACE("\n");
}
TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
pFormat += 2;
- if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
+ if (attr & FC_SIMPLE_POINTER) desc = pFormat;
else desc = pFormat + *(const SHORT*)pFormat;
switch (type) {
- case RPC_FC_RP: /* ref pointer (always non-null) */
+ case FC_RP: /* ref pointer (always non-null) */
if (!Pointer)
{
ERR("NULL ref pointer is not allowed\n");
}
pointer_needs_marshaling = TRUE;
break;
- case RPC_FC_UP: /* unique pointer */
- case RPC_FC_OP: /* object pointer - same as unique here */
+ case FC_UP: /* unique pointer */
+ case FC_OP: /* object pointer - same as unique here */
if (Pointer)
pointer_needs_marshaling = TRUE;
else
TRACE("writing 0x%08x to buffer\n", pointer_id);
NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
break;
- case RPC_FC_FP:
+ case FC_FP:
pointer_needs_marshaling = !NdrFullPointerQueryPointer(
pStubMsg->FullPtrXlatTables, Pointer, 1, &pointer_id);
TRACE("writing 0x%08x to buffer\n", pointer_id);
TRACE("calling marshaller for type 0x%x\n", (int)*desc);
if (pointer_needs_marshaling) {
- if (attr & RPC_FC_P_DEREF) {
+ if (attr & FC_POINTER_DEREF) {
Pointer = *(unsigned char**)Pointer;
TRACE("deref => %p\n", Pointer);
}
STD_OVERFLOW_CHECK(pStubMsg);
}
-/***********************************************************************
- * PointerUnmarshall [internal]
- */
+/* pPointer is the pointer that we will unmarshal into; pSrcPointer is the
+ * pointer to memory which we may attempt to reuse if non-NULL. Usually these
+ * are the same; for the case when they aren't, see EmbeddedPointerUnmarshall().
+ *
+ * fMustAlloc seems to determine whether we can allocate from the buffer (if we
+ * are on the server side). It's ignored here, since we can't allocate a pointer
+ * from the buffer. */
static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *Buffer,
unsigned char **pPointer,
PFORMAT_STRING desc;
NDR_UNMARSHALL m;
DWORD pointer_id = 0;
- BOOL pointer_needs_unmarshaling;
+ BOOL pointer_needs_unmarshaling, need_alloc = FALSE, inner_must_alloc = FALSE;
TRACE("(%p,%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pSrcPointer, pFormat, fMustAlloc);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
pFormat += 2;
- if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
+ if (attr & FC_SIMPLE_POINTER) desc = pFormat;
else desc = pFormat + *(const SHORT*)pFormat;
switch (type) {
- case RPC_FC_RP: /* ref pointer (always non-null) */
+ case FC_RP: /* ref pointer (always non-null) */
pointer_needs_unmarshaling = TRUE;
break;
- case RPC_FC_UP: /* unique pointer */
+ case 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 = FALSE;
}
break;
- case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
+ case 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 (!fMustAlloc && pSrcPointer)
- {
+
+ /* An object pointer always allocates new memory (it cannot point to the
+ * buffer). */
+ inner_must_alloc = TRUE;
+
+ if (pSrcPointer)
FIXME("free object pointer %p\n", pSrcPointer);
- fMustAlloc = TRUE;
- }
if (pointer_id)
pointer_needs_unmarshaling = TRUE;
else
pointer_needs_unmarshaling = FALSE;
}
break;
- case RPC_FC_FP:
+ case FC_FP:
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
TRACE("pointer_id is 0x%08x\n", pointer_id);
pointer_needs_unmarshaling = !NdrFullPointerQueryRefId(
unsigned char **current_ptr = pPointer;
if (pStubMsg->IsClient) {
TRACE("client\n");
- /* if we aren't forcing allocation of memory then try to use the existing
- * (source) pointer to unmarshall the data into so that [in,out]
- * parameters behave correctly. it doesn't matter if the parameter is
- * [out] only since in that case the pointer will be NULL. we force
- * allocation when the source pointer is NULL here instead of in the type
- * unmarshalling routine for the benefit of the deref code below */
- if (!fMustAlloc) {
- if (pSrcPointer) {
- TRACE("setting *pPointer to %p\n", pSrcPointer);
- *pPointer = pSrcPointer;
- } else
- fMustAlloc = TRUE;
+ /* Try to use the existing (source) pointer to unmarshall the data into
+ * so that [in, out] or [out, ref] parameters behave correctly. If the
+ * source pointer is NULL and we are not dereferencing, we must force the
+ * inner marshalling routine to allocate, since otherwise it will crash. */
+ if (pSrcPointer)
+ {
+ TRACE("setting *pPointer to %p\n", pSrcPointer);
+ *pPointer = pSrcPointer;
}
+ else
+ need_alloc = inner_must_alloc = TRUE;
} else {
TRACE("server\n");
- /* the memory in a stub is never initialised, so we have to work out here
- * whether we have to initialise it so we can use the optimisation of
- * setting the pointer to the buffer, if possible, or set fMustAlloc to
- * TRUE. */
- if (attr & RPC_FC_P_DEREF) {
- fMustAlloc = TRUE;
- } else {
- *current_ptr = NULL;
+ /* We can use an existing source pointer here only if it is on-stack,
+ * probably since otherwise NdrPointerFree() might later try to free a
+ * pointer we don't know the provenance of. Otherwise we must always
+ * allocate if we are dereferencing. We never need to force the inner
+ * routine to allocate here, since it will either write into an existing
+ * pointer, or use a pointer to the buffer. */
+ if (attr & FC_POINTER_DEREF)
+ {
+ if (pSrcPointer && (attr & FC_ALLOCED_ON_STACK))
+ *pPointer = pSrcPointer;
+ else
+ need_alloc = TRUE;
}
+ else
+ *pPointer = NULL;
}
- if (attr & RPC_FC_P_ALLOCALLNODES)
- FIXME("RPC_FC_P_ALLOCALLNODES not implemented\n");
+ if (attr & FC_ALLOCATE_ALL_NODES)
+ FIXME("FC_ALLOCATE_ALL_NODES not implemented\n");
+
+ if (attr & FC_POINTER_DEREF) {
+ if (need_alloc)
+ *pPointer = NdrAllocateZero(pStubMsg, sizeof(void *));
- if (attr & RPC_FC_P_DEREF) {
- if (fMustAlloc) {
- unsigned char *base_ptr_val = NdrAllocate(pStubMsg, sizeof(void *));
- *pPointer = base_ptr_val;
- current_ptr = (unsigned char **)base_ptr_val;
- } else
- current_ptr = *(unsigned char***)current_ptr;
+ current_ptr = *(unsigned char***)current_ptr;
TRACE("deref => %p\n", current_ptr);
- if (!fMustAlloc && !*current_ptr) fMustAlloc = TRUE;
}
m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
- if (m) m(pStubMsg, current_ptr, desc, fMustAlloc);
+ if (m) m(pStubMsg, current_ptr, desc, inner_must_alloc);
else FIXME("no unmarshaller for data type=%02x\n", *desc);
- if (type == RPC_FC_FP)
+ if (type == FC_FP)
NdrFullPointerInsertRefId(pStubMsg->FullPtrXlatTables, pointer_id,
*pPointer);
}
TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
pFormat += 2;
- if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
+ if (attr & FC_SIMPLE_POINTER) desc = pFormat;
else desc = pFormat + *(const SHORT*)pFormat;
switch (type) {
- case RPC_FC_RP: /* ref pointer (always non-null) */
+ case FC_RP: /* ref pointer (always non-null) */
if (!Pointer)
{
ERR("NULL ref pointer is not allowed\n");
RpcRaiseException(RPC_X_NULL_REF_POINTER);
}
break;
- case RPC_FC_OP:
- case RPC_FC_UP:
+ case FC_OP:
+ case FC_UP:
/* NULL pointer has no further representation */
if (!Pointer)
return;
break;
- case RPC_FC_FP:
+ case FC_FP:
pointer_needs_sizing = !NdrFullPointerQueryPointer(
pStubMsg->FullPtrXlatTables, Pointer, 0, &pointer_id);
if (!pointer_needs_sizing)
return;
}
- if (attr & RPC_FC_P_DEREF) {
+ if (attr & FC_POINTER_DEREF) {
Pointer = *(unsigned char**)Pointer;
TRACE("deref => %p\n", Pointer);
}
TRACE("(%p,%p,%p)\n", pStubMsg, Buffer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
pFormat += 2;
- if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
+ if (attr & FC_SIMPLE_POINTER) desc = pFormat;
else desc = pFormat + *(const SHORT*)pFormat;
switch (type) {
- case RPC_FC_RP: /* ref pointer (always non-null) */
+ case FC_RP: /* ref pointer (always non-null) */
pointer_needs_sizing = TRUE;
break;
- case RPC_FC_UP: /* unique pointer */
- case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
+ case FC_UP: /* unique pointer */
+ case 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)
else
pointer_needs_sizing = FALSE;
break;
- case RPC_FC_FP:
+ case FC_FP:
{
void *pointer;
pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
return 0;
}
- if (attr & RPC_FC_P_DEREF) {
+ if (attr & FC_POINTER_DEREF) {
align_length(&pStubMsg->MemorySize, sizeof(void*));
pStubMsg->MemorySize += sizeof(void*);
TRACE("deref\n");
TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
- if (attr & RPC_FC_P_DONTFREE) return;
+ if (attr & FC_DONT_FREE) return;
pFormat += 2;
- if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
+ if (attr & FC_SIMPLE_POINTER) desc = pFormat;
else desc = pFormat + *(const SHORT*)pFormat;
if (!Pointer) return;
- if (type == RPC_FC_FP) {
+ if (type == FC_FP) {
int pointer_needs_freeing = NdrFullPointerFree(
pStubMsg->FullPtrXlatTables, Pointer);
if (!pointer_needs_freeing)
return;
}
- if (attr & RPC_FC_P_DEREF) {
+ if (attr & FC_POINTER_DEREF) {
current_pointer = *(unsigned char**)Pointer;
TRACE("deref => %p\n", current_pointer);
}
if (Pointer >= pStubMsg->BufferStart && Pointer <= pStubMsg->BufferEnd)
goto notfree;
- if (attr & RPC_FC_P_ONSTACK) {
+ if (attr & FC_ALLOCED_ON_STACK) {
TRACE("not freeing stack ptr %p\n", Pointer);
return;
}
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (*pFormat != RPC_FC_PP) return NULL;
+ if (*pFormat != FC_PP) return NULL;
pFormat += 2;
if (pStubMsg->PointerBufferMark)
pStubMsg->PointerBufferMark = NULL;
}
- while (pFormat[0] != RPC_FC_END) {
+ while (pFormat[0] != FC_END) {
switch (pFormat[0]) {
default:
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
- case RPC_FC_NO_REPEAT:
+ case FC_NO_REPEAT:
rep = 1;
stride = 0;
count = 1;
pFormat += 2;
break;
- case RPC_FC_FIXED_REPEAT:
+ case FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[8];
pFormat += 10;
break;
- case RPC_FC_VARIABLE_REPEAT:
- rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
+ case FC_VARIABLE_REPEAT:
+ rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
count = *(const WORD*)&pFormat[6];
pFormat += 8;
return NULL;
}
-/***********************************************************************
- * EmbeddedPointerUnmarshall
- */
+/* rpcrt4 does something bizarre with embedded pointers: instead of copying the
+ * struct/array/union from the buffer to memory and then unmarshalling pointers
+ * into it, it unmarshals pointers into the buffer itself and then copies it to
+ * memory. However, it will still attempt to use a user-supplied pointer where
+ * appropriate (i.e. one on stack). Therefore we need to pass both pointers to
+ * this function and to PointerUnmarshall: the pointer (to the buffer) that we
+ * will actually unmarshal into (pDstBuffer), and the pointer (to memory) that
+ * we will attempt to use for storage if possible (pSrcMemoryPtrs). */
static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
unsigned char *pDstBuffer,
unsigned char *pSrcMemoryPtrs,
TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, pDstBuffer, pSrcMemoryPtrs, pFormat, fMustAlloc);
- if (*pFormat != RPC_FC_PP) return NULL;
+ if (*pFormat != FC_PP) return NULL;
pFormat += 2;
if (pStubMsg->PointerBufferMark)
pStubMsg->PointerBufferMark = NULL;
}
- while (pFormat[0] != RPC_FC_END) {
+ while (pFormat[0] != FC_END) {
TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
switch (pFormat[0]) {
default:
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
- case RPC_FC_NO_REPEAT:
+ case FC_NO_REPEAT:
rep = 1;
stride = 0;
count = 1;
pFormat += 2;
break;
- case RPC_FC_FIXED_REPEAT:
+ case FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[8];
pFormat += 10;
break;
- case RPC_FC_VARIABLE_REPEAT:
- rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
+ case FC_VARIABLE_REPEAT:
+ rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
count = *(const WORD*)&pFormat[6];
pFormat += 8;
if (pStubMsg->IgnoreEmbeddedPointers) return;
- if (*pFormat != RPC_FC_PP) return;
+ if (*pFormat != FC_PP) return;
pFormat += 2;
if (pStubMsg->PointerLength)
pStubMsg->PointerLength = 0;
}
- while (pFormat[0] != RPC_FC_END) {
+ while (pFormat[0] != FC_END) {
switch (pFormat[0]) {
default:
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
- case RPC_FC_NO_REPEAT:
+ case FC_NO_REPEAT:
rep = 1;
stride = 0;
count = 1;
pFormat += 2;
break;
- case RPC_FC_FIXED_REPEAT:
+ case FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[8];
pFormat += 10;
break;
- case RPC_FC_VARIABLE_REPEAT:
- rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
+ case FC_VARIABLE_REPEAT:
+ rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
count = *(const WORD*)&pFormat[6];
pFormat += 8;
pStubMsg->PointerBufferMark = NULL;
}
- if (*pFormat != RPC_FC_PP) return 0;
+ if (*pFormat != FC_PP) return 0;
pFormat += 2;
- while (pFormat[0] != RPC_FC_END) {
+ while (pFormat[0] != FC_END) {
switch (pFormat[0]) {
default:
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
- case RPC_FC_NO_REPEAT:
+ case FC_NO_REPEAT:
rep = 1;
stride = 0;
count = 1;
pFormat += 2;
break;
- case RPC_FC_FIXED_REPEAT:
+ case FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[8];
pFormat += 10;
break;
- case RPC_FC_VARIABLE_REPEAT:
- rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
+ case FC_VARIABLE_REPEAT:
+ rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
count = *(const WORD*)&pFormat[6];
pFormat += 8;
unsigned i;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (*pFormat != RPC_FC_PP) return;
+ if (*pFormat != FC_PP) return;
pFormat += 2;
- while (pFormat[0] != RPC_FC_END) {
+ while (pFormat[0] != FC_END) {
switch (pFormat[0]) {
default:
FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
/* fallthrough */
- case RPC_FC_NO_REPEAT:
+ case FC_NO_REPEAT:
rep = 1;
stride = 0;
count = 1;
pFormat += 2;
break;
- case RPC_FC_FIXED_REPEAT:
+ case FC_FIXED_REPEAT:
rep = *(const WORD*)&pFormat[2];
stride = *(const WORD*)&pFormat[4];
count = *(const WORD*)&pFormat[8];
pFormat += 10;
break;
- case RPC_FC_VARIABLE_REPEAT:
- rep = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
+ case FC_VARIABLE_REPEAT:
+ rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
stride = *(const WORD*)&pFormat[2];
count = *(const WORD*)&pFormat[6];
pFormat += 8;
/* Increment the buffer here instead of in PointerMarshall,
* as that is used by embedded pointers which already handle the incrementing
* the buffer, and shouldn't write any additional pointer data to the wire */
- if (*pFormat != RPC_FC_RP)
+ if (*pFormat != FC_RP)
{
align_pointer_clear(&pStubMsg->Buffer, 4);
Buffer = pStubMsg->Buffer;
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if (*pFormat == RPC_FC_RP)
+ if (*pFormat == FC_RP)
{
Buffer = pStubMsg->Buffer;
/* Do the NULL ref pointer check here because embedded pointers can be
/* Increment the buffer length here instead of in PointerBufferSize,
* as that is used by embedded pointers which already handle the buffer
* length, and shouldn't write anything more to the wire */
- if (*pFormat != RPC_FC_RP)
+ if (*pFormat != FC_RP)
{
align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4);
PFORMAT_STRING pFormat)
{
unsigned char *Buffer = pStubMsg->Buffer;
- if (*pFormat != RPC_FC_RP)
+ if (*pFormat != FC_RP)
{
align_pointer(&pStubMsg->Buffer, 4);
safe_buffer_increment(pStubMsg, 4);
switch(FormatChar)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
BASE_TYPE_UNMARSHALL(UCHAR);
TRACE("value: 0x%02x\n", *pMemory);
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
BASE_TYPE_UNMARSHALL(USHORT);
TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ERROR_STATUS_T:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ERROR_STATUS_T:
+ case FC_ENUM32:
BASE_TYPE_UNMARSHALL(ULONG);
TRACE("value: 0x%08x\n", *(ULONG *)pMemory);
break;
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
BASE_TYPE_UNMARSHALL(float);
TRACE("value: %f\n", *(float *)pMemory);
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
BASE_TYPE_UNMARSHALL(double);
TRACE("value: %f\n", *(double *)pMemory);
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
BASE_TYPE_UNMARSHALL(ULONGLONG);
TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG *)pMemory));
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
TRACE("pMemory: %p\n", pMemory);
/* 16-bits on the wire, but int in memory */
pStubMsg->Buffer += sizeof(USHORT);
TRACE("value: 0x%08x\n", *(UINT *)pMemory);
break;
- case RPC_FC_INT3264:
+ case 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:
+ case 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:
+ case FC_IGNORE:
break;
default:
FIXME("Unhandled base type: 0x%02x\n", FormatChar);
pStubMsg->BufferMark = pStubMsg->Buffer;
safe_copy_to_buffer(pStubMsg, pMemory, size);
- if (pFormat[0] != RPC_FC_STRUCT)
+ if (pFormat[0] != FC_STRUCT)
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
return NULL;
align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, size);
+ *ppMemory = NdrAllocateZero(pStubMsg, size);
else
{
if (!pStubMsg->IsClient && !*ppMemory)
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, size);
- if (pFormat[0] == RPC_FC_PSTRUCT)
+ if (pFormat[0] == FC_PSTRUCT)
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat+4, fMustAlloc);
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
safe_buffer_length_increment(pStubMsg, size);
- if (pFormat[0] != RPC_FC_STRUCT)
+ if (pFormat[0] != FC_STRUCT)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
}
pStubMsg->MemorySize += size;
safe_buffer_increment(pStubMsg, size);
- if (pFormat[0] != RPC_FC_STRUCT)
+ if (pFormat[0] != FC_STRUCT)
EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
return pStubMsg->MemorySize;
}
PFORMAT_STRING pFormat)
{
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_STRUCT)
+ if (pFormat[0] != FC_STRUCT)
EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
}
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
SizeConformance(pStubMsg);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
SizeConformance(pStubMsg);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
{
TRACE("string=%s\n", debugstr_a((const char *)pMemory));
pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
pStubMsg->ActualCount = strlenW((LPCWSTR)pMemory)+1;
}
- if (pFormat[1] == RPC_FC_STRING_SIZED)
+ if (pFormat[1] == FC_STRING_SIZED)
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
else
pStubMsg->MaxCount = pStubMsg->ActualCount;
SizeConformance(pStubMsg);
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
count = *(const WORD *)(pFormat + 2);
pFormat += 4;
if (IsConformanceOrVariancePresent(pFormat)) SizeConformance(pStubMsg);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
esize = 1;
else
esize = 2;
size = safe_multiply(esize, pStubMsg->ActualCount);
safe_buffer_length_increment(pStubMsg, size);
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
alignment = pFormat[1] + 1;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
if (IsConformanceOrVariancePresent(pFormat)) SizeVariance(pStubMsg);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
WriteConformance(pStubMsg);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
WriteConformance(pStubMsg);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
{
TRACE("string=%s\n", debugstr_a((const char *)pMemory));
pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
pStubMsg->ActualCount = strlenW((LPCWSTR)pMemory)+1;
}
- if (pFormat[1] == RPC_FC_STRING_SIZED)
+ if (pFormat[1] == FC_STRING_SIZED)
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
else
pStubMsg->MaxCount = pStubMsg->ActualCount;
pStubMsg->Offset = 0;
WriteConformance(pStubMsg);
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
def = *(const WORD *)(pFormat + 2);
pFormat += 4;
conformance_present = IsConformanceOrVariancePresent(pFormat);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
esize = 1;
else
esize = 2;
size = safe_multiply(esize, pStubMsg->ActualCount);
safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
alignment = pFormat[1] + 1;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
if (IsConformanceOrVariancePresent(pFormat)) WriteVariance(pStubMsg);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
esize = *(const WORD*)(pFormat+2);
pFormat = ReadConformance(pStubMsg, pFormat+4);
return safe_multiply(esize, pStubMsg->MaxCount);
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
esize = *(const WORD*)(pFormat+2);
pFormat = ReadConformance(pStubMsg, pFormat+4);
return safe_multiply(esize, pStubMsg->MaxCount);
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
esize = 1;
else
esize = 2;
- if (pFormat[1] == RPC_FC_STRING_SIZED)
+ if (pFormat[1] == FC_STRING_SIZED)
ReadConformance(pStubMsg, pFormat + 2);
else
ReadConformance(pStubMsg, NULL);
return safe_multiply(esize, pStubMsg->MaxCount);
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
def = *(const WORD *)(pFormat + 2);
pFormat += 4;
if (IsConformanceOrVariancePresent(pFormat)) pFormat = ReadConformance(pStubMsg, pFormat);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fUnmarshall)
{
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, memsize);
+ *ppMemory = NdrAllocateZero(pStubMsg, memsize);
else
{
if (fUseBufferMemoryServer && !pStubMsg->IsClient && !*ppMemory)
memcpy(*ppMemory, saved_buffer, bufsize);
}
return bufsize;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, memsize);
+ *ppMemory = NdrAllocateZero(pStubMsg, memsize);
saved_buffer = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, bufsize);
memcpy(*ppMemory + offset, saved_buffer, bufsize);
}
return bufsize;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
esize = 1;
else
esize = 2;
ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
- if (pFormat[1] != RPC_FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
+ if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
{
ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
pStubMsg->ActualCount, pStubMsg->MaxCount);
else
safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
- if (*pFormat == RPC_FC_C_CSTRING)
+ if (*pFormat == FC_C_CSTRING)
TRACE("string=%s\n", debugstr_a((char*)*ppMemory));
else
TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
}
return bufsize;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
alignment = pFormat[1] + 1;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, memsize);
+ *ppMemory = NdrAllocateZero(pStubMsg, memsize);
align_pointer(&pStubMsg->Buffer, alignment);
saved_buffer = pStubMsg->Buffer;
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerMemorySize(pStubMsg, pFormat);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
esize = *(const WORD*)(pFormat+2);
alignment = pFormat[1] + 1;
if (fHasPointers)
EmbeddedPointerMemorySize(pStubMsg, pFormat);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
- if (fc == RPC_FC_C_CSTRING)
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
+ if (fc == FC_C_CSTRING)
esize = 1;
else
esize = 2;
ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
- if (pFormat[1] != RPC_FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
+ if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
{
ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
pStubMsg->ActualCount, pStubMsg->MaxCount);
safe_buffer_increment(pStubMsg, bufsize);
pStubMsg->MemorySize += memsize;
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
alignment = pFormat[1] + 1;
pFormat = SkipConformance(pStubMsg, pFormat + 4);
pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
switch (fc)
{
- case RPC_FC_CARRAY:
+ case FC_CARRAY:
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
if (fHasPointers)
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_CVARRAY:
+ case FC_CVARRAY:
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
if (fHasPointers)
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
break;
- case RPC_FC_C_CSTRING:
- case RPC_FC_C_WSTRING:
+ case FC_C_CSTRING:
+ case FC_C_WSTRING:
/* No embedded pointers so nothing to do */
break;
- case RPC_FC_BOGUS_ARRAY:
+ case FC_BOGUS_ARRAY:
count = *(const WORD *)(pFormat + 2);
pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, count);
pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
{
TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
- if (pFormat[0] != RPC_FC_C_CSTRING && pFormat[0] != RPC_FC_C_WSTRING) {
+ if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
ERR("Unhandled string type: %#x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* allow compiler to optimise inline function by passing constant into
* these functions */
- if (pFormat[0] == RPC_FC_C_CSTRING) {
- array_compute_and_write_conformance(RPC_FC_C_CSTRING, pStubMsg, pszMessage,
+ if (pFormat[0] == FC_C_CSTRING) {
+ array_compute_and_write_conformance(FC_C_CSTRING, pStubMsg, pszMessage,
pFormat);
- array_write_variance_and_marshall(RPC_FC_C_CSTRING, pStubMsg, pszMessage,
+ array_write_variance_and_marshall(FC_C_CSTRING, pStubMsg, pszMessage,
pFormat, TRUE /* fHasPointers */);
} else {
- array_compute_and_write_conformance(RPC_FC_C_WSTRING, pStubMsg, pszMessage,
+ array_compute_and_write_conformance(FC_C_WSTRING, pStubMsg, pszMessage,
pFormat);
- array_write_variance_and_marshall(RPC_FC_C_WSTRING, pStubMsg, pszMessage,
+ array_write_variance_and_marshall(FC_C_WSTRING, pStubMsg, pszMessage,
pFormat, TRUE /* fHasPointers */);
}
{
TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_C_CSTRING && pFormat[0] != RPC_FC_C_WSTRING) {
+ if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
ERR("Unhandled string type: %#x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* allow compiler to optimise inline function by passing constant into
* these functions */
- if (pFormat[0] == RPC_FC_C_CSTRING) {
- array_compute_and_size_conformance(RPC_FC_C_CSTRING, pStubMsg, pMemory,
+ if (pFormat[0] == FC_C_CSTRING) {
+ array_compute_and_size_conformance(FC_C_CSTRING, pStubMsg, pMemory,
pFormat);
- array_buffer_size(RPC_FC_C_CSTRING, pStubMsg, pMemory, pFormat,
+ array_buffer_size(FC_C_CSTRING, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
} else {
- array_compute_and_size_conformance(RPC_FC_C_WSTRING, pStubMsg, pMemory,
+ array_compute_and_size_conformance(FC_C_WSTRING, pStubMsg, pMemory,
pFormat);
- array_buffer_size(RPC_FC_C_WSTRING, pStubMsg, pMemory, pFormat,
+ array_buffer_size(FC_C_WSTRING, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
}
}
{
TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
- if (pFormat[0] != RPC_FC_C_CSTRING && pFormat[0] != RPC_FC_C_WSTRING) {
+ if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
ERR("Unhandled string type: %#x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* allow compiler to optimise inline function by passing constant into
* these functions */
- if (pFormat[0] == RPC_FC_C_CSTRING) {
- array_read_conformance(RPC_FC_C_CSTRING, pStubMsg, pFormat);
- array_memory_size(RPC_FC_C_CSTRING, pStubMsg, pFormat,
+ if (pFormat[0] == FC_C_CSTRING) {
+ array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
+ array_memory_size(FC_C_CSTRING, pStubMsg, pFormat,
TRUE /* fHasPointers */);
} else {
- array_read_conformance(RPC_FC_C_WSTRING, pStubMsg, pFormat);
- array_memory_size(RPC_FC_C_WSTRING, pStubMsg, pFormat,
+ array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
+ array_memory_size(FC_C_WSTRING, pStubMsg, pFormat,
TRUE /* fHasPointers */);
}
TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
pStubMsg, *ppMemory, pFormat, fMustAlloc);
- if (pFormat[0] != RPC_FC_C_CSTRING && pFormat[0] != RPC_FC_C_WSTRING) {
+ if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
ERR("Unhandled string type: %#x\n", *pFormat);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
/* allow compiler to optimise inline function by passing constant into
* these functions */
- if (pFormat[0] == RPC_FC_C_CSTRING) {
- array_read_conformance(RPC_FC_C_CSTRING, pStubMsg, pFormat);
- array_read_variance_and_unmarshall(RPC_FC_C_CSTRING, pStubMsg, ppMemory,
+ if (pFormat[0] == FC_C_CSTRING) {
+ array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(FC_C_CSTRING, pStubMsg, ppMemory,
pFormat, fMustAlloc,
TRUE /* fUseBufferMemoryServer */,
TRUE /* fUnmarshall */);
} else {
- array_read_conformance(RPC_FC_C_WSTRING, pStubMsg, pFormat);
- array_read_variance_and_unmarshall(RPC_FC_C_WSTRING, pStubMsg, ppMemory,
+ array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(FC_C_WSTRING, pStubMsg, ppMemory,
pFormat, fMustAlloc,
TRUE /* fUseBufferMemoryServer */,
TRUE /* fUnmarshall */);
maxsize = *(const USHORT *)&pFormat[2];
- if (*pFormat == RPC_FC_CSTRING)
+ if (*pFormat == FC_CSTRING)
{
ULONG i = 0;
const char *str = (const char *)pMemory;
pStubMsg->ActualCount = i + 1;
esize = 1;
}
- else if (*pFormat == RPC_FC_WSTRING)
+ else if (*pFormat == FC_WSTRING)
{
ULONG i = 0;
const WCHAR *str = (const WCHAR *)pMemory;
RpcRaiseException(RPC_S_INVALID_BOUND);
}
- if (*pFormat == RPC_FC_CSTRING) esize = 1;
- else if (*pFormat == RPC_FC_WSTRING) esize = 2;
+ if (*pFormat == FC_CSTRING) esize = 1;
+ else if (*pFormat == FC_WSTRING) esize = 2;
else
{
ERR("Unhandled string type: %#x\n", *pFormat);
safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
- if (*pFormat == RPC_FC_CSTRING) {
+ if (*pFormat == FC_CSTRING) {
TRACE("string=%s\n", debugstr_an((char*)*ppMemory, pStubMsg->ActualCount));
}
- else if (*pFormat == RPC_FC_WSTRING) {
+ else if (*pFormat == FC_WSTRING) {
TRACE("string=%s\n", debugstr_wn((LPWSTR)*ppMemory, pStubMsg->ActualCount));
}
SizeVariance(pStubMsg);
- if (*pFormat == RPC_FC_CSTRING)
+ if (*pFormat == FC_CSTRING)
{
ULONG i = 0;
const char *str = (const char *)pMemory;
pStubMsg->ActualCount = i + 1;
esize = 1;
}
- else if (*pFormat == RPC_FC_WSTRING)
+ else if (*pFormat == FC_WSTRING)
{
ULONG i = 0;
const WCHAR *str = (const WCHAR *)pMemory;
RpcRaiseException(RPC_S_INVALID_BOUND);
}
- if (*pFormat == RPC_FC_CSTRING) esize = 1;
- else if (*pFormat == RPC_FC_WSTRING) esize = 2;
+ if (*pFormat == FC_CSTRING) esize = 1;
+ else if (*pFormat == FC_WSTRING) esize = 2;
else
{
ERR("Unhandled string type: %#x\n", *pFormat);
PFORMAT_STRING pFormat)
{
switch (*pFormat) {
- case RPC_FC_STRUCT:
- case RPC_FC_PSTRUCT:
- case RPC_FC_CSTRUCT:
- case RPC_FC_BOGUS_STRUCT:
- case RPC_FC_SMFARRAY:
- case RPC_FC_SMVARRAY:
- case RPC_FC_CSTRING:
+ case FC_STRUCT:
+ case FC_PSTRUCT:
+ case FC_CSTRUCT:
+ case FC_BOGUS_STRUCT:
+ case FC_SMFARRAY:
+ case FC_SMVARRAY:
+ case FC_CSTRING:
return *(const WORD*)&pFormat[2];
- case RPC_FC_USER_MARSHAL:
+ case FC_LGFARRAY:
+ case FC_LGVARRAY:
+ return *(const ULONG*)&pFormat[2];
+ case FC_USER_MARSHAL:
return *(const WORD*)&pFormat[4];
- case RPC_FC_RANGE: {
+ case FC_RANGE: {
switch (((const NDR_RANGE *)pFormat)->flags_type & 0xf) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
return sizeof(UCHAR);
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
return sizeof(USHORT);
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
return sizeof(ULONG);
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
return sizeof(float);
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
return sizeof(double);
- case RPC_FC_HYPER:
+ case FC_HYPER:
return sizeof(ULONGLONG);
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
return sizeof(UINT);
default:
ERR("unknown type 0x%x\n", ((const NDR_RANGE *)pFormat)->flags_type & 0xf);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
- case RPC_FC_NON_ENCAPSULATED_UNION:
+ case FC_NON_ENCAPSULATED_UNION:
pFormat += 2;
pFormat = SkipConformance(pStubMsg, pFormat);
pFormat += *(const SHORT*)pFormat;
return *(const SHORT*)pFormat;
- case RPC_FC_IP:
+ case FC_IP:
return sizeof(void *);
- case RPC_FC_WSTRING:
+ case FC_WSTRING:
return *(const WORD*)&pFormat[2] * 2;
default:
FIXME("unhandled embedded type %02x\n", *pFormat);
PFORMAT_STRING pFormat,
PFORMAT_STRING pPointer)
{
+ unsigned char *mem_base = pMemory;
PFORMAT_STRING desc;
NDR_MARSHALL m;
ULONG size;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
TRACE("byte=%d <= %p\n", *(WORD*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, 1);
pMemory += 1;
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, 2);
pMemory += 2;
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
{
USHORT val = *(DWORD *)pMemory;
TRACE("enum16=%d <= %p\n", *(DWORD*)pMemory, pMemory);
pMemory += 4;
break;
}
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
TRACE("long=%d <= %p\n", *(DWORD*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, 4);
pMemory += 4;
break;
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case FC_UINT3264:
{
UINT val = *(UINT_PTR *)pMemory;
TRACE("int3264=%ld <= %p\n", *(UINT_PTR *)pMemory, pMemory);
pMemory += sizeof(UINT_PTR);
break;
}
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
TRACE("float=%f <= %p\n", *(float*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
pMemory += sizeof(float);
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
TRACE("longlong=%s <= %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, 8);
pMemory += 8;
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
TRACE("double=%f <= %p\n", *(double*)pMemory, pMemory);
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
pMemory += sizeof(double);
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
{
unsigned char *saved_buffer;
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)
+ if (*pFormat != FC_POINTER)
pPointer = pFormat;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
align_pointer_clear(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
pStubMsg->PointerBufferMark = NULL;
pointer_buffer_mark_set = TRUE;
}
- else if (*pPointer != RPC_FC_RP)
+ else if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
PointerMarshall(pStubMsg, saved_buffer, *(unsigned char**)pMemory, pPointer);
if (pointer_buffer_mark_set)
STD_OVERFLOW_CHECK(pStubMsg);
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
pStubMsg->Buffer = saved_buffer;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
}
TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer);
- if (*pFormat == RPC_FC_POINTER)
+ if (*pFormat == FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *);
break;
}
- case RPC_FC_ALIGNM2:
- align_pointer(&pMemory, 2);
+ case FC_ALIGNM2:
+ align_pointer_offset(&pMemory, mem_base, 2);
break;
- case RPC_FC_ALIGNM4:
- align_pointer(&pMemory, 4);
+ case FC_ALIGNM4:
+ align_pointer_offset(&pMemory, mem_base, 4);
break;
- case RPC_FC_ALIGNM8:
- align_pointer(&pMemory, 8);
+ case FC_ALIGNM8:
+ align_pointer_offset(&pMemory, mem_base, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- pMemory += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ pMemory += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
pMemory += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
if (m)
{
/* for some reason interface pointers aren't generated as
- * RPC_FC_POINTER, but instead as RPC_FC_EMBEDDED_COMPLEX, yet
+ * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
* they still need the dereferencing treatment that pointers are
* given */
- if (*desc == RPC_FC_IP)
+ if (*desc == FC_IP)
m(pStubMsg, *(unsigned char **)pMemory, desc);
else
m(pStubMsg, pMemory, desc);
pMemory += size;
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format 0x%02x\n", *pFormat);
PFORMAT_STRING pPointer,
unsigned char fMustAlloc)
{
+ unsigned char *mem_base = pMemory;
PFORMAT_STRING desc;
NDR_UNMARSHALL m;
ULONG size;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
safe_copy_from_buffer(pStubMsg, pMemory, 1);
TRACE("byte=%d => %p\n", *(WORD*)pMemory, pMemory);
pMemory += 1;
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
safe_copy_from_buffer(pStubMsg, pMemory, 2);
TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
pMemory += 2;
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
{
WORD val;
safe_copy_from_buffer(pStubMsg, &val, 2);
pMemory += 4;
break;
}
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
safe_copy_from_buffer(pStubMsg, pMemory, 4);
TRACE("long=%d => %p\n", *(DWORD*)pMemory, pMemory);
pMemory += 4;
break;
- case RPC_FC_INT3264:
+ case FC_INT3264:
{
INT val;
safe_copy_from_buffer(pStubMsg, &val, 4);
pMemory += sizeof(INT_PTR);
break;
}
- case RPC_FC_UINT3264:
+ case FC_UINT3264:
{
UINT val;
safe_copy_from_buffer(pStubMsg, &val, 4);
pMemory += sizeof(UINT_PTR);
break;
}
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
safe_copy_from_buffer(pStubMsg, pMemory, sizeof(float));
TRACE("float=%f => %p\n", *(float*)pMemory, pMemory);
pMemory += sizeof(float);
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
safe_copy_from_buffer(pStubMsg, pMemory, 8);
TRACE("longlong=%s => %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
pMemory += 8;
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
safe_copy_from_buffer(pStubMsg, pMemory, sizeof(double));
TRACE("double=%f => %p\n", *(double*)pMemory, pMemory);
pMemory += sizeof(double);
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
{
unsigned char *saved_buffer;
BOOL pointer_buffer_mark_set = FALSE;
TRACE("pointer => %p\n", pMemory);
- if (*pFormat != RPC_FC_POINTER)
+ if (*pFormat != FC_POINTER)
pPointer = pFormat;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
pStubMsg->PointerBufferMark = NULL;
pointer_buffer_mark_set = TRUE;
}
- else if (*pPointer != RPC_FC_RP)
+ else if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, fMustAlloc);
STD_OVERFLOW_CHECK(pStubMsg);
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
pStubMsg->Buffer = saved_buffer;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
}
- if (*pFormat == RPC_FC_POINTER)
+ if (*pFormat == FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *);
break;
}
- case RPC_FC_ALIGNM2:
- align_pointer_clear(&pMemory, 2);
+ case FC_ALIGNM2:
+ align_pointer_offset_clear(&pMemory, mem_base, 2);
break;
- case RPC_FC_ALIGNM4:
- align_pointer_clear(&pMemory, 4);
+ case FC_ALIGNM4:
+ align_pointer_offset_clear(&pMemory, mem_base, 4);
break;
- case RPC_FC_ALIGNM8:
- align_pointer_clear(&pMemory, 8);
+ case FC_ALIGNM8:
+ align_pointer_offset_clear(&pMemory, mem_base, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- memset(pMemory, 0, *pFormat - RPC_FC_STRUCTPAD1 + 1);
- pMemory += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ memset(pMemory, 0, *pFormat - FC_STRUCTPAD1 + 1);
+ pMemory += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
pMemory += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
if (m)
{
/* for some reason interface pointers aren't generated as
- * RPC_FC_POINTER, but instead as RPC_FC_EMBEDDED_COMPLEX, yet
+ * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
* they still need the dereferencing treatment that pointers are
* given */
- if (*desc == RPC_FC_IP)
+ if (*desc == FC_IP)
m(pStubMsg, (unsigned char **)pMemory, desc, FALSE);
else
m(pStubMsg, &pMemory, desc, FALSE);
pMemory += size;
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format %d\n", *pFormat);
PFORMAT_STRING pFormat,
PFORMAT_STRING pPointer)
{
+ unsigned char *mem_base = pMemory;
PFORMAT_STRING desc;
NDR_BUFFERSIZE m;
ULONG size;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
safe_buffer_length_increment(pStubMsg, 1);
pMemory += 1;
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
safe_buffer_length_increment(pStubMsg, 2);
pMemory += 2;
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
safe_buffer_length_increment(pStubMsg, 2);
pMemory += 4;
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
- case RPC_FC_FLOAT:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
+ case FC_FLOAT:
safe_buffer_length_increment(pStubMsg, 4);
pMemory += 4;
break;
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case FC_UINT3264:
safe_buffer_length_increment(pStubMsg, 4);
pMemory += sizeof(INT_PTR);
break;
- case RPC_FC_HYPER:
- case RPC_FC_DOUBLE:
+ case FC_HYPER:
+ case FC_DOUBLE:
safe_buffer_length_increment(pStubMsg, 8);
pMemory += 8;
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
- if (*pFormat != RPC_FC_POINTER)
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
+ if (*pFormat != FC_POINTER)
pPointer = pFormat;
if (!pStubMsg->IgnoreEmbeddedPointers)
{
pStubMsg->PointerLength = pStubMsg->BufferLength;
pStubMsg->BufferLength = saved_buffer_length;
}
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
{
align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4);
}
- if (*pFormat == RPC_FC_POINTER)
+ if (*pFormat == FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void*);
break;
- case RPC_FC_ALIGNM2:
- align_pointer(&pMemory, 2);
+ case FC_ALIGNM2:
+ align_pointer_offset(&pMemory, mem_base, 2);
break;
- case RPC_FC_ALIGNM4:
- align_pointer(&pMemory, 4);
+ case FC_ALIGNM4:
+ align_pointer_offset(&pMemory, mem_base, 4);
break;
- case RPC_FC_ALIGNM8:
- align_pointer(&pMemory, 8);
+ case FC_ALIGNM8:
+ align_pointer_offset(&pMemory, mem_base, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- pMemory += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ pMemory += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
pMemory += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
if (m)
{
/* for some reason interface pointers aren't generated as
- * RPC_FC_POINTER, but instead as RPC_FC_EMBEDDED_COMPLEX, yet
+ * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
* they still need the dereferencing treatment that pointers are
* given */
- if (*desc == RPC_FC_IP)
+ if (*desc == FC_IP)
m(pStubMsg, *(unsigned char **)pMemory, desc);
else
m(pStubMsg, pMemory, desc);
pMemory += size;
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format 0x%02x\n", *pFormat);
PFORMAT_STRING pFormat,
PFORMAT_STRING pPointer)
{
+ unsigned char *mem_base = pMemory;
PFORMAT_STRING desc;
NDR_FREE m;
ULONG size;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
pMemory += 1;
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
pMemory += 2;
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM16:
- case RPC_FC_ENUM32:
- case RPC_FC_FLOAT:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM16:
+ case FC_ENUM32:
+ case FC_FLOAT:
pMemory += 4;
break;
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case FC_UINT3264:
pMemory += sizeof(INT_PTR);
break;
- case RPC_FC_HYPER:
- case RPC_FC_DOUBLE:
+ case FC_HYPER:
+ case FC_DOUBLE:
pMemory += 8;
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
- if (*pFormat != RPC_FC_POINTER)
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
+ if (*pFormat != FC_POINTER)
pPointer = pFormat;
NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
- if (*pFormat == RPC_FC_POINTER)
+ if (*pFormat == FC_POINTER)
pPointer += 4;
else
pFormat += 4;
pMemory += sizeof(void *);
break;
- case RPC_FC_ALIGNM2:
- align_pointer(&pMemory, 2);
+ case FC_ALIGNM2:
+ align_pointer_offset(&pMemory, mem_base, 2);
break;
- case RPC_FC_ALIGNM4:
- align_pointer(&pMemory, 4);
+ case FC_ALIGNM4:
+ align_pointer_offset(&pMemory, mem_base, 4);
break;
- case RPC_FC_ALIGNM8:
- align_pointer(&pMemory, 8);
+ case FC_ALIGNM8:
+ align_pointer_offset(&pMemory, mem_base, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- pMemory += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ pMemory += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
pMemory += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
if (m)
{
/* for some reason interface pointers aren't generated as
- * RPC_FC_POINTER, but instead as RPC_FC_EMBEDDED_COMPLEX, yet
+ * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
* they still need the dereferencing treatment that pointers are
* given */
- if (*desc == RPC_FC_IP)
+ if (*desc == FC_IP)
m(pStubMsg, *(unsigned char **)pMemory, desc);
else
m(pStubMsg, pMemory, desc);
pMemory += size;
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format 0x%02x\n", *pFormat);
PFORMAT_STRING desc;
ULONG size = 0;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
size += 1;
safe_buffer_increment(pStubMsg, 1);
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
size += 2;
safe_buffer_increment(pStubMsg, 2);
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
size += 4;
safe_buffer_increment(pStubMsg, 2);
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
- case RPC_FC_FLOAT:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
+ case FC_FLOAT:
size += 4;
safe_buffer_increment(pStubMsg, 4);
break;
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case FC_UINT3264:
size += sizeof(INT_PTR);
safe_buffer_increment(pStubMsg, 4);
break;
- case RPC_FC_HYPER:
- case RPC_FC_DOUBLE:
+ case FC_HYPER:
+ case FC_DOUBLE:
size += 8;
safe_buffer_increment(pStubMsg, 8);
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
{
unsigned char *saved_buffer;
BOOL pointer_buffer_mark_set = FALSE;
- if (*pFormat != RPC_FC_POINTER)
+ if (*pFormat != FC_POINTER)
pPointer = pFormat;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
pStubMsg->PointerBufferMark = NULL;
pointer_buffer_mark_set = TRUE;
}
- else if (*pPointer != RPC_FC_RP)
+ else if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
if (!pStubMsg->IgnoreEmbeddedPointers)
STD_OVERFLOW_CHECK(pStubMsg);
pStubMsg->PointerBufferMark = pStubMsg->Buffer;
pStubMsg->Buffer = saved_buffer;
- if (*pPointer != RPC_FC_RP)
+ if (*pPointer != FC_RP)
safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
}
- if (*pFormat == RPC_FC_POINTER)
+ if (*pFormat == FC_POINTER)
pPointer += 4;
else
pFormat += 4;
size += sizeof(void *);
break;
}
- case RPC_FC_ALIGNM2:
+ case FC_ALIGNM2:
align_length(&size, 2);
break;
- case RPC_FC_ALIGNM4:
+ case FC_ALIGNM4:
align_length(&size, 4);
break;
- case RPC_FC_ALIGNM8:
+ case FC_ALIGNM8:
align_length(&size, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- size += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ size += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
size += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
size += EmbeddedComplexMemorySize(pStubMsg, desc);
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format 0x%02x\n", *pFormat);
PFORMAT_STRING desc;
ULONG size = 0;
- while (*pFormat != RPC_FC_END) {
+ while (*pFormat != FC_END) {
switch (*pFormat) {
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
size += 1;
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
size += 2;
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM16:
- case RPC_FC_ENUM32:
- case RPC_FC_FLOAT:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM16:
+ case FC_ENUM32:
+ case FC_FLOAT:
size += 4;
break;
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case FC_UINT3264:
size += sizeof(INT_PTR);
break;
- case RPC_FC_HYPER:
- case RPC_FC_DOUBLE:
+ case FC_HYPER:
+ case FC_DOUBLE:
size += 8;
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
- case RPC_FC_POINTER:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
+ case FC_POINTER:
size += sizeof(void *);
- if (*pFormat != RPC_FC_POINTER)
+ if (*pFormat != FC_POINTER)
pFormat += 4;
break;
- case RPC_FC_ALIGNM2:
+ case FC_ALIGNM2:
align_length(&size, 2);
break;
- case RPC_FC_ALIGNM4:
+ case FC_ALIGNM4:
align_length(&size, 4);
break;
- case RPC_FC_ALIGNM8:
+ case FC_ALIGNM8:
align_length(&size, 8);
break;
- case RPC_FC_STRUCTPAD1:
- case RPC_FC_STRUCTPAD2:
- case RPC_FC_STRUCTPAD3:
- case RPC_FC_STRUCTPAD4:
- case RPC_FC_STRUCTPAD5:
- case RPC_FC_STRUCTPAD6:
- case RPC_FC_STRUCTPAD7:
- size += *pFormat - RPC_FC_STRUCTPAD1 + 1;
+ case FC_STRUCTPAD1:
+ case FC_STRUCTPAD2:
+ case FC_STRUCTPAD3:
+ case FC_STRUCTPAD4:
+ case FC_STRUCTPAD5:
+ case FC_STRUCTPAD6:
+ case FC_STRUCTPAD7:
+ size += *pFormat - FC_STRUCTPAD1 + 1;
break;
- case RPC_FC_EMBEDDED_COMPLEX:
+ case FC_EMBEDDED_COMPLEX:
size += pFormat[1];
pFormat += 2;
desc = pFormat + *(const SHORT*)pFormat;
size += EmbeddedComplexSize(pStubMsg, desc);
pFormat += 2;
continue;
- case RPC_FC_PAD:
+ case FC_PAD:
break;
default:
FIXME("unhandled format 0x%02x\n", *pFormat);
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, size);
+ *ppMemory = NdrAllocateZero(pStubMsg, size);
pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
PFORMAT_STRING pFormat)
{
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CARRAY)
+ if (pFormat[0] != FC_CARRAY)
{
ERR("invalid format = 0x%x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
- array_compute_and_write_conformance(RPC_FC_CARRAY, pStubMsg, pMemory,
+ array_compute_and_write_conformance(FC_CARRAY, pStubMsg, pMemory,
pFormat);
- array_write_variance_and_marshall(RPC_FC_CARRAY, pStubMsg, pMemory, pFormat,
+ array_write_variance_and_marshall(FC_CARRAY, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
return NULL;
unsigned char fMustAlloc)
{
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if (pFormat[0] != RPC_FC_CARRAY)
+ if (pFormat[0] != FC_CARRAY)
{
ERR("invalid format = 0x%x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
- array_read_conformance(RPC_FC_CARRAY, pStubMsg, pFormat);
- array_read_variance_and_unmarshall(RPC_FC_CARRAY, pStubMsg, ppMemory, pFormat,
+ array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(FC_CARRAY, pStubMsg, ppMemory, pFormat,
fMustAlloc,
TRUE /* fUseBufferMemoryServer */,
TRUE /* fUnmarshall */);
PFORMAT_STRING pFormat)
{
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CARRAY)
+ if (pFormat[0] != FC_CARRAY)
{
ERR("invalid format = 0x%x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
- array_compute_and_size_conformance(RPC_FC_CARRAY, pStubMsg, pMemory, pFormat);
- array_buffer_size(RPC_FC_CARRAY, pStubMsg, pMemory, pFormat,
+ array_compute_and_size_conformance(FC_CARRAY, pStubMsg, pMemory, pFormat);
+ array_buffer_size(FC_CARRAY, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
}
PFORMAT_STRING pFormat)
{
TRACE("(%p,%p)\n", pStubMsg, pFormat);
- if (pFormat[0] != RPC_FC_CARRAY)
+ if (pFormat[0] != FC_CARRAY)
{
ERR("invalid format = 0x%x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
- array_read_conformance(RPC_FC_CARRAY, pStubMsg, pFormat);
- array_memory_size(RPC_FC_CARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
+ array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
+ array_memory_size(FC_CARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
return pStubMsg->MemorySize;
}
PFORMAT_STRING pFormat)
{
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CARRAY)
+ if (pFormat[0] != FC_CARRAY)
{
ERR("invalid format = 0x%x\n", pFormat[0]);
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
- array_free(RPC_FC_CARRAY, pStubMsg, pMemory, pFormat,
+ array_free(FC_CARRAY, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
}
{
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CVARRAY)
+ if (pFormat[0] != FC_CVARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return NULL;
}
- array_compute_and_write_conformance(RPC_FC_CVARRAY, pStubMsg, pMemory,
+ array_compute_and_write_conformance(FC_CVARRAY, pStubMsg, pMemory,
pFormat);
- array_write_variance_and_marshall(RPC_FC_CVARRAY, pStubMsg, pMemory,
+ array_write_variance_and_marshall(FC_CVARRAY, pStubMsg, pMemory,
pFormat, TRUE /* fHasPointers */);
return NULL;
{
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if (pFormat[0] != RPC_FC_CVARRAY)
+ if (pFormat[0] != FC_CVARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return NULL;
}
- array_read_conformance(RPC_FC_CVARRAY, pStubMsg, pFormat);
- array_read_variance_and_unmarshall(RPC_FC_CVARRAY, pStubMsg, ppMemory,
+ array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(FC_CVARRAY, pStubMsg, ppMemory,
pFormat, fMustAlloc,
TRUE /* fUseBufferMemoryServer */,
TRUE /* fUnmarshall */);
{
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CVARRAY)
+ if (pFormat[0] != FC_CVARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return;
}
- array_free(RPC_FC_CVARRAY, pStubMsg, pMemory, pFormat,
+ array_free(FC_CVARRAY, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
}
{
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_CVARRAY)
+ if (pFormat[0] != FC_CVARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return;
}
- array_compute_and_size_conformance(RPC_FC_CVARRAY, pStubMsg, pMemory,
+ array_compute_and_size_conformance(FC_CVARRAY, pStubMsg, pMemory,
pFormat);
- array_buffer_size(RPC_FC_CVARRAY, pStubMsg, pMemory, pFormat,
+ array_buffer_size(FC_CVARRAY, pStubMsg, pMemory, pFormat,
TRUE /* fHasPointers */);
}
{
TRACE("(%p, %p)\n", pStubMsg, pFormat);
- if (pFormat[0] != RPC_FC_CVARRAY)
+ if (pFormat[0] != FC_CVARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return pStubMsg->MemorySize;
}
- array_read_conformance(RPC_FC_CVARRAY, pStubMsg, pFormat);
- array_memory_size(RPC_FC_CVARRAY, pStubMsg, pFormat,
+ array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
+ array_memory_size(FC_CVARRAY, pStubMsg, pFormat,
TRUE /* fHasPointers */);
return pStubMsg->MemorySize;
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
+ if (pFormat[0] != FC_BOGUS_ARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
pStubMsg->BufferLength = saved_buffer_length;
}
- array_compute_and_write_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
- array_write_variance_and_marshall(RPC_FC_BOGUS_ARRAY, pStubMsg,
+ array_compute_and_write_conformance(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
+ array_write_variance_and_marshall(FC_BOGUS_ARRAY, pStubMsg,
pMemory, pFormat, TRUE /* fHasPointers */);
STD_OVERFLOW_CHECK(pStubMsg);
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
+ if (pFormat[0] != FC_BOGUS_ARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
/* restore the original buffer */
pStubMsg->Buffer = saved_buffer;
- array_read_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat);
- array_read_variance_and_unmarshall(RPC_FC_BOGUS_ARRAY, pStubMsg, ppMemory, pFormat, fMustAlloc,
+ array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
+ array_read_variance_and_unmarshall(FC_BOGUS_ARRAY, pStubMsg, ppMemory, pFormat, fMustAlloc,
TRUE /* fUseBufferMemoryServer */, TRUE /* fUnmarshall */);
if (pointer_buffer_mark_set)
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
+ if (pFormat[0] != FC_BOGUS_ARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
pStubMsg->BufferLength = saved_buffer_length;
}
- array_compute_and_size_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
- array_buffer_size(RPC_FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
+ array_compute_and_size_conformance(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat);
+ array_buffer_size(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
if(pointer_length_set)
{
{
TRACE("(%p,%p)\n", pStubMsg, pFormat);
- if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
+ if (pFormat[0] != FC_BOGUS_ARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return 0;
}
- array_read_conformance(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat);
- array_memory_size(RPC_FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
+ array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
+ array_memory_size(FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
return pStubMsg->MemorySize;
}
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
- if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
+ if (pFormat[0] != FC_BOGUS_ARRAY)
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
- if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
+ if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
{
ERR("invalid format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
pCStructFormat->offset_to_array_description;
- if (*pCArrayFormat != RPC_FC_CARRAY)
+ if (*pCArrayFormat != FC_CARRAY)
{
ERR("invalid array format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
pStubMsg->BufferMark = pStubMsg->Buffer;
safe_copy_to_buffer(pStubMsg, pMemory, pCStructFormat->memory_size + bufsize);
- if (pCStructFormat->type == RPC_FC_CPSTRUCT)
+ if (pCStructFormat->type == FC_CPSTRUCT)
EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
return NULL;
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
- if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
+ if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
{
ERR("invalid format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
pCStructFormat->offset_to_array_description;
- if (*pCArrayFormat != RPC_FC_CARRAY)
+ if (*pCArrayFormat != FC_CARRAY)
{
ERR("invalid array format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
if (fMustAlloc)
{
SIZE_T size = pCStructFormat->memory_size + bufsize;
- *ppMemory = NdrAllocate(pStubMsg, size);
+ *ppMemory = NdrAllocateZero(pStubMsg, size);
}
else
{
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, pCStructFormat->memory_size + bufsize);
- if (pCStructFormat->type == RPC_FC_CPSTRUCT)
+ if (pCStructFormat->type == FC_CPSTRUCT)
EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
- if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
+ if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
{
ERR("invalid format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
}
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
pCStructFormat->offset_to_array_description;
- if (*pCArrayFormat != RPC_FC_CARRAY)
+ if (*pCArrayFormat != FC_CARRAY)
{
ERR("invalid array format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
safe_buffer_length_increment(pStubMsg, pCStructFormat->memory_size);
safe_buffer_length_increment(pStubMsg, safe_multiply(pStubMsg->MaxCount, esize));
- if (pCStructFormat->type == RPC_FC_CPSTRUCT)
+ if (pCStructFormat->type == FC_CPSTRUCT)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
}
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CSTRUCT_FORMAT);
- if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
+ if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
{
ERR("invalid format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
pCStructFormat->offset_to_array_description;
- if (*pCArrayFormat != RPC_FC_CARRAY)
+ if (*pCArrayFormat != FC_CARRAY)
{
ERR("invalid array format type %x\n", pCStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
/* copy constant sized part of struct */
pStubMsg->BufferMark = pStubMsg->Buffer;
- if (pCStructFormat->type == RPC_FC_CPSTRUCT)
+ if (pCStructFormat->type == FC_CPSTRUCT)
EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
}
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
- if (pCVStructFormat->type != RPC_FC_CVSTRUCT)
+ if (pCVStructFormat->type != FC_CVSTRUCT)
{
ERR("invalid format type %x\n", pCVStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
- if (pCVStructFormat->type != RPC_FC_CVSTRUCT)
+ if (pCVStructFormat->type != FC_CVSTRUCT)
{
ERR("invalid format type %x\n", pCVStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
if (fMustAlloc)
{
SIZE_T size = pCVStructFormat->memory_size + memsize;
- *ppMemory = NdrAllocate(pStubMsg, size);
+ *ppMemory = NdrAllocateZero(pStubMsg, size);
}
/* mark the start of the constant data */
memcpy(*ppMemory + pCVStructFormat->memory_size + offset,
saved_array_buffer, bufsize);
- if (*pCVArrayFormat == RPC_FC_C_CSTRING)
+ if (*pCVArrayFormat == FC_C_CSTRING)
TRACE("string=%s\n", debugstr_a((char *)(*ppMemory + pCVStructFormat->memory_size)));
- else if (*pCVArrayFormat == RPC_FC_C_WSTRING)
+ else if (*pCVArrayFormat == FC_C_WSTRING)
TRACE("string=%s\n", debugstr_w((WCHAR *)(*ppMemory + pCVStructFormat->memory_size)));
return NULL;
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
- if (pCVStructFormat->type != RPC_FC_CVSTRUCT)
+ if (pCVStructFormat->type != FC_CVSTRUCT)
{
ERR("invalid format type %x\n", pCVStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("(%p, %p)\n", pStubMsg, pFormat);
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
- if (pCVStructFormat->type != RPC_FC_CVSTRUCT)
+ if (pCVStructFormat->type != FC_CVSTRUCT)
{
ERR("invalid format type %x\n", pCVStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
- if (pCVStructFormat->type != RPC_FC_CVSTRUCT)
+ if (pCVStructFormat->type != FC_CVSTRUCT)
{
ERR("invalid format type %x\n", pCVStructFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pSmFArrayFormat->type != RPC_FC_SMFARRAY) &&
- (pSmFArrayFormat->type != RPC_FC_LGFARRAY))
+ if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
+ (pSmFArrayFormat->type != FC_LGFARRAY))
{
ERR("invalid format type %x\n", pSmFArrayFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
align_pointer_clear(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
- if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
+ if (pSmFArrayFormat->type == FC_SMFARRAY)
{
total_size = pSmFArrayFormat->total_size;
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if ((pSmFArrayFormat->type != RPC_FC_SMFARRAY) &&
- (pSmFArrayFormat->type != RPC_FC_LGFARRAY))
+ if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
+ (pSmFArrayFormat->type != FC_LGFARRAY))
{
ERR("invalid format type %x\n", pSmFArrayFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
- if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
+ if (pSmFArrayFormat->type == FC_SMFARRAY)
{
total_size = pSmFArrayFormat->total_size;
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
}
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, total_size);
+ *ppMemory = NdrAllocateZero(pStubMsg, total_size);
else
{
if (!pStubMsg->IsClient && !*ppMemory)
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pSmFArrayFormat->type != RPC_FC_SMFARRAY) &&
- (pSmFArrayFormat->type != RPC_FC_LGFARRAY))
+ if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
+ (pSmFArrayFormat->type != FC_LGFARRAY))
{
ERR("invalid format type %x\n", pSmFArrayFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
align_length(&pStubMsg->BufferLength, pSmFArrayFormat->alignment + 1);
- if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
+ if (pSmFArrayFormat->type == FC_SMFARRAY)
{
total_size = pSmFArrayFormat->total_size;
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
TRACE("(%p, %p)\n", pStubMsg, pFormat);
- if ((pSmFArrayFormat->type != RPC_FC_SMFARRAY) &&
- (pSmFArrayFormat->type != RPC_FC_LGFARRAY))
+ if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
+ (pSmFArrayFormat->type != FC_LGFARRAY))
{
ERR("invalid format type %x\n", pSmFArrayFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
- if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
+ if (pSmFArrayFormat->type == FC_SMFARRAY)
{
total_size = pSmFArrayFormat->total_size;
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pSmFArrayFormat->type != RPC_FC_SMFARRAY) &&
- (pSmFArrayFormat->type != RPC_FC_LGFARRAY))
+ if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
+ (pSmFArrayFormat->type != FC_LGFARRAY))
{
ERR("invalid format type %x\n", pSmFArrayFormat->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return;
}
- if (pSmFArrayFormat->type == RPC_FC_SMFARRAY)
+ if (pSmFArrayFormat->type == FC_SMFARRAY)
pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
else
{
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pFormat[0] != RPC_FC_SMVARRAY) &&
- (pFormat[0] != RPC_FC_LGVARRAY))
+ if ((pFormat[0] != FC_SMVARRAY) &&
+ (pFormat[0] != FC_LGVARRAY))
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
alignment = pFormat[1] + 1;
- if (pFormat[0] == RPC_FC_SMVARRAY)
+ if (pFormat[0] == FC_SMVARRAY)
{
pFormat += 2;
pFormat += sizeof(WORD);
TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
- if ((pFormat[0] != RPC_FC_SMVARRAY) &&
- (pFormat[0] != RPC_FC_LGVARRAY))
+ if ((pFormat[0] != FC_SMVARRAY) &&
+ (pFormat[0] != FC_LGVARRAY))
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
alignment = pFormat[1] + 1;
- if (pFormat[0] == RPC_FC_SMVARRAY)
+ if (pFormat[0] == FC_SMVARRAY)
{
pFormat += 2;
size = *(const WORD*)pFormat;
if (!fMustAlloc && !*ppMemory)
fMustAlloc = TRUE;
if (fMustAlloc)
- *ppMemory = NdrAllocate(pStubMsg, size);
+ *ppMemory = NdrAllocateZero(pStubMsg, size);
saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, bufsize);
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pFormat[0] != RPC_FC_SMVARRAY) &&
- (pFormat[0] != RPC_FC_LGVARRAY))
+ if ((pFormat[0] != FC_SMVARRAY) &&
+ (pFormat[0] != FC_LGVARRAY))
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
alignment = pFormat[1] + 1;
- if (pFormat[0] == RPC_FC_SMVARRAY)
+ if (pFormat[0] == FC_SMVARRAY)
{
pFormat += 2;
pFormat += sizeof(WORD);
TRACE("(%p, %p)\n", pStubMsg, pFormat);
- if ((pFormat[0] != RPC_FC_SMVARRAY) &&
- (pFormat[0] != RPC_FC_LGVARRAY))
+ if ((pFormat[0] != FC_SMVARRAY) &&
+ (pFormat[0] != FC_LGVARRAY))
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
alignment = pFormat[1] + 1;
- if (pFormat[0] == RPC_FC_SMVARRAY)
+ if (pFormat[0] == FC_SMVARRAY)
{
pFormat += 2;
size = *(const WORD*)pFormat;
TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
- if ((pFormat[0] != RPC_FC_SMVARRAY) &&
- (pFormat[0] != RPC_FC_LGVARRAY))
+ if ((pFormat[0] != FC_SMVARRAY) &&
+ (pFormat[0] != FC_LGVARRAY))
{
ERR("invalid format type %x\n", pFormat[0]);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
return;
}
- if (pFormat[0] == RPC_FC_SMVARRAY)
+ if (pFormat[0] == FC_SMVARRAY)
{
pFormat += 2;
pFormat += sizeof(WORD);
{
switch (fc)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
return *pMemory;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
- case RPC_FC_ENUM16:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
+ case FC_ENUM16:
return *(const USHORT *)pMemory;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case 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;
BOOL pointer_buffer_mark_set = FALSE;
switch(*desc)
{
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
align_pointer_clear(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
pStubMsg->Buffer = saved_buffer + 4;
}
break;
- case RPC_FC_IP:
+ case FC_IP:
/* must be dereferenced first */
m(pStubMsg, *(unsigned char **)pMemory, desc);
break;
BOOL pointer_buffer_mark_set = FALSE;
switch(*desc)
{
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
if (pStubMsg->PointerBufferMark)
pStubMsg->Buffer = saved_buffer + 4;
}
break;
- case RPC_FC_IP:
+ case FC_IP:
/* must be dereferenced first */
m(pStubMsg, *(unsigned char ***)ppMemory, desc, fMustAlloc);
break;
{
switch(*desc)
{
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
align_length(&pStubMsg->BufferLength, 4);
safe_buffer_length_increment(pStubMsg, 4); /* for pointer ID */
if (!pStubMsg->IgnoreEmbeddedPointers)
pStubMsg->BufferLength = saved_buffer_length;
}
break;
- case RPC_FC_IP:
+ case FC_IP:
/* must be dereferenced first */
m(pStubMsg, *(unsigned char **)pMemory, desc);
break;
{
switch(*desc)
{
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
align_pointer(&pStubMsg->Buffer, 4);
saved_buffer = pStubMsg->Buffer;
safe_buffer_increment(pStubMsg, 4);
{
switch(*desc)
{
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_OP:
- case RPC_FC_FP:
+ case FC_RP:
+ case FC_UP:
+ case FC_OP:
+ case FC_FP:
PointerFree(pStubMsg, *(unsigned char **)pMemory, desc);
break;
- case RPC_FC_IP:
+ case FC_IP:
/* must be dereferenced first */
m(pStubMsg, *(unsigned char **)pMemory, desc);
break;
switch(**ppFormat)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
{
UCHAR d;
safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
discriminant = d;
break;
}
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
- case RPC_FC_ENUM16:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
+ case FC_ENUM16:
{
USHORT d;
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
discriminant = d;
break;
}
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
+ case FC_LONG:
+ case FC_ULONG:
{
ULONG d;
align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
- if (pRange->type != RPC_FC_RANGE)
+ if (pRange->type != FC_RANGE)
{
ERR("invalid format type %x\n", pRange->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
- if (pRange->type != RPC_FC_RANGE)
+ if (pRange->type != FC_RANGE)
{
ERR("invalid format type %x\n", pRange->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
switch(base_type)
{
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
+ case FC_CHAR:
+ case FC_SMALL:
RANGE_UNMARSHALL(UCHAR, UCHAR, "%d");
TRACE("value: 0x%02x\n", **ppMemory);
break;
- case RPC_FC_BYTE:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_USMALL:
RANGE_UNMARSHALL(CHAR, CHAR, "%u");
TRACE("value: 0x%02x\n", **ppMemory);
break;
- case RPC_FC_WCHAR: /* FIXME: valid? */
- case RPC_FC_USHORT:
+ case FC_WCHAR: /* FIXME: valid? */
+ case FC_USHORT:
RANGE_UNMARSHALL(USHORT, USHORT, "%u");
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
break;
- case RPC_FC_SHORT:
+ case FC_SHORT:
RANGE_UNMARSHALL(SHORT, SHORT, "%d");
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
break;
- case RPC_FC_LONG:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ENUM32:
RANGE_UNMARSHALL(LONG, LONG, "%d");
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
break;
- case RPC_FC_ULONG:
+ case FC_ULONG:
RANGE_UNMARSHALL(ULONG, ULONG, "%u");
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
RANGE_UNMARSHALL(UINT, USHORT, "%u");
TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
break;
- case RPC_FC_FLOAT:
- case RPC_FC_DOUBLE:
- case RPC_FC_HYPER:
+ case FC_FLOAT:
+ case FC_DOUBLE:
+ case FC_HYPER:
default:
ERR("invalid range base type: 0x%02x\n", base_type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
- if (pRange->type != RPC_FC_RANGE)
+ if (pRange->type != FC_RANGE)
{
ERR("invalid format type %x\n", pRange->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
unsigned char base_type;
- if (pRange->type != RPC_FC_RANGE)
+ if (pRange->type != FC_RANGE)
{
ERR("invalid format type %x\n", pRange->type);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
switch(*pFormat)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR));
TRACE("value: 0x%02x\n", *pMemory);
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_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_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ERROR_STATUS_T:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ERROR_STATUS_T:
+ case FC_ENUM32:
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:
+ case FC_FLOAT:
align_pointer_clear(&pStubMsg->Buffer, sizeof(float));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
align_pointer_clear(&pStubMsg->Buffer, sizeof(double));
safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
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:
+ case FC_ENUM16:
{
USHORT val = *(UINT *)pMemory;
/* only 16-bits on the wire, so do a sanity check */
TRACE("value: 0x%04x\n", *(UINT *)pMemory);
break;
}
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case 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:
+ case FC_IGNORE:
break;
default:
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
switch(*pFormat)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
BASE_TYPE_UNMARSHALL(UCHAR);
TRACE("value: 0x%02x\n", **ppMemory);
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
BASE_TYPE_UNMARSHALL(USHORT);
TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
break;
- case RPC_FC_LONG:
- case RPC_FC_ULONG:
- case RPC_FC_ERROR_STATUS_T:
- case RPC_FC_ENUM32:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ERROR_STATUS_T:
+ case FC_ENUM32:
BASE_TYPE_UNMARSHALL(ULONG);
TRACE("value: 0x%08x\n", **(ULONG **)ppMemory);
break;
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
BASE_TYPE_UNMARSHALL(float);
TRACE("value: %f\n", **(float **)ppMemory);
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
BASE_TYPE_UNMARSHALL(double);
TRACE("value: %f\n", **(double **)ppMemory);
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
BASE_TYPE_UNMARSHALL(ULONGLONG);
TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
break;
- case RPC_FC_ENUM16:
+ case FC_ENUM16:
{
USHORT val;
align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
break;
}
- case RPC_FC_INT3264:
+ case FC_INT3264:
if (sizeof(INT_PTR) == sizeof(INT)) BASE_TYPE_UNMARSHALL(INT);
else
{
TRACE("value: 0x%08lx\n", **(INT_PTR **)ppMemory);
}
break;
- case RPC_FC_UINT3264:
+ case FC_UINT3264:
if (sizeof(UINT_PTR) == sizeof(UINT)) BASE_TYPE_UNMARSHALL(UINT);
else
{
TRACE("value: 0x%08lx\n", **(UINT_PTR **)ppMemory);
}
break;
- case RPC_FC_IGNORE:
+ case FC_IGNORE:
break;
default:
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
switch(*pFormat)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
safe_buffer_length_increment(pStubMsg, sizeof(UCHAR));
break;
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
- case RPC_FC_ENUM16:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case FC_USHORT:
+ case FC_ENUM16:
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:
- case RPC_FC_INT3264:
- case RPC_FC_UINT3264:
+ case FC_LONG:
+ case FC_ULONG:
+ case FC_ENUM32:
+ case FC_INT3264:
+ case FC_UINT3264:
align_length(&pStubMsg->BufferLength, sizeof(ULONG));
safe_buffer_length_increment(pStubMsg, sizeof(ULONG));
break;
- case RPC_FC_FLOAT:
+ case FC_FLOAT:
align_length(&pStubMsg->BufferLength, sizeof(float));
safe_buffer_length_increment(pStubMsg, sizeof(float));
break;
- case RPC_FC_DOUBLE:
+ case FC_DOUBLE:
align_length(&pStubMsg->BufferLength, sizeof(double));
safe_buffer_length_increment(pStubMsg, sizeof(double));
break;
- case RPC_FC_HYPER:
+ case FC_HYPER:
align_length(&pStubMsg->BufferLength, sizeof(ULONGLONG));
safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG));
break;
- case RPC_FC_ERROR_STATUS_T:
+ case FC_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 FC_IGNORE:
break;
default:
FIXME("Unhandled base type: 0x%02x\n", *pFormat);
switch(*pFormat)
{
- case RPC_FC_BYTE:
- case RPC_FC_CHAR:
- case RPC_FC_SMALL:
- case RPC_FC_USMALL:
+ case FC_BYTE:
+ case FC_CHAR:
+ case FC_SMALL:
+ case FC_USMALL:
safe_buffer_increment(pStubMsg, sizeof(UCHAR));
pStubMsg->MemorySize += sizeof(UCHAR);
return sizeof(UCHAR);
- case RPC_FC_WCHAR:
- case RPC_FC_SHORT:
- case RPC_FC_USHORT:
+ case FC_WCHAR:
+ case FC_SHORT:
+ case 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:
+ case FC_LONG:
+ case FC_ULONG:
+ case 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:
+ case 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:
+ case 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:
+ case 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:
+ case 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:
+ case 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_INT3264:
- case RPC_FC_UINT3264:
+ case FC_INT3264:
+ case 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:
+ case FC_IGNORE:
align_length(&pStubMsg->MemorySize, sizeof(void *));
pStubMsg->MemorySize += sizeof(void *);
return sizeof(void *);
{
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
- if (*pFormat != RPC_FC_BIND_CONTEXT)
+ if (*pFormat != FC_BIND_CONTEXT)
{
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
{
TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
- if (*pFormat != RPC_FC_BIND_CONTEXT)
+ if (*pFormat != FC_BIND_CONTEXT)
{
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
TRACE("pStubMsg %p, ppMemory %p, pFormat %p, fMustAlloc %s\n", pStubMsg,
ppMemory, pFormat, fMustAlloc ? "TRUE": "FALSE");
- if (*pFormat != RPC_FC_BIND_CONTEXT)
+ if (*pFormat != FC_BIND_CONTEXT)
{
ERR("invalid format type %x\n", *pFormat);
RpcRaiseException(RPC_S_INTERNAL_ERROR);
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
- if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
+ if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
- if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
+ if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
flags |= RPC_CONTEXT_HANDLE_SERIALIZE;
- if (pFormat[1] & NDR_CONTEXT_HANDLE_NO_SERIALIZE)
+ if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
flags |= RPC_CONTEXT_HANDLE_DONT_SERIALIZE;
if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
{
--- /dev/null
+/*
+ * Type library proxy/stub implementation
+ *
+ * Copyright 2018 Zebediah Figura
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <assert.h>
+
+#define COBJMACROS
+#ifdef __REACTOS__
+#include "objbase.h"
+#endif
+#include "oaidl.h"
+#define USE_STUBLESS_PROXY
+#include "rpcproxy.h"
+#include "ndrtypes.h"
+#include "wine/debug.h"
+#include "wine/heap.h"
+
+#include "cpsf.h"
+#include "initguid.h"
+#include "ndr_types.h"
+#include "ndr_stubless.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(ole);
+
+static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str,
+ size_t *len, TYPEDESC *desc, BOOL toplevel, BOOL onstack);
+
+#define WRITE_CHAR(str, len, val) \
+ do { if ((str)) (str)[(len)] = (val); (len)++; } while (0)
+#define WRITE_SHORT(str, len, val) \
+ do { if ((str)) *((short *)((str) + (len))) = (val); (len) += 2; } while (0)
+#define WRITE_INT(str, len, val) \
+ do { if ((str)) *((int *)((str) + (len))) = (val); (len) += 4; } while (0)
+
+extern const ExtendedProxyFileInfo ndr_types_ProxyFileInfo;
+
+static const MIDL_STUBLESS_PROXY_INFO *get_ndr_types_proxy_info(void)
+{
+ return ndr_types_ProxyFileInfo.pProxyVtblList[0]->header.pStublessProxyInfo;
+}
+
+static const NDR_PARAM_OIF *get_ndr_types_params( unsigned int *nb_params )
+{
+ const MIDL_STUBLESS_PROXY_INFO *proxy = get_ndr_types_proxy_info();
+ const unsigned char *format = proxy->ProcFormatString + proxy->FormatStringOffset[3];
+ const NDR_PROC_HEADER *proc = (const NDR_PROC_HEADER *)format;
+ const NDR_PROC_PARTIAL_OIF_HEADER *header;
+
+ if (proc->Oi_flags & Oi_HAS_RPCFLAGS)
+ format += sizeof(NDR_PROC_HEADER_RPC);
+ else
+ format += sizeof(NDR_PROC_HEADER);
+
+ header = (const NDR_PROC_PARTIAL_OIF_HEADER *)format;
+ format += sizeof(*header);
+ if (header->Oi2Flags.HasExtensions)
+ {
+ const NDR_PROC_HEADER_EXTS *ext = (const NDR_PROC_HEADER_EXTS *)format;
+ format += ext->Size;
+ }
+ *nb_params = header->number_of_params;
+ return (const NDR_PARAM_OIF *)format;
+}
+
+static unsigned short get_tfs_offset( int param )
+{
+ unsigned int nb_params;
+ const NDR_PARAM_OIF *params = get_ndr_types_params( &nb_params );
+
+ assert( param < nb_params );
+ return params[param].u.type_offset;
+}
+
+static const unsigned char *get_type_format_string( size_t *size )
+{
+ unsigned int nb_params;
+ const NDR_PARAM_OIF *params = get_ndr_types_params( &nb_params );
+
+ *size = params[nb_params - 1].u.type_offset;
+ return get_ndr_types_proxy_info()->pStubDesc->pFormatTypes;
+}
+
+static unsigned short write_oleaut_tfs(VARTYPE vt)
+{
+ switch (vt)
+ {
+ case VT_BSTR: return get_tfs_offset( 0 );
+ case VT_UNKNOWN: return get_tfs_offset( 1 );
+ case VT_DISPATCH: return get_tfs_offset( 2 );
+ case VT_VARIANT: return get_tfs_offset( 3 );
+ case VT_SAFEARRAY: return get_tfs_offset( 4 );
+ }
+ return 0;
+}
+
+static unsigned char get_base_type(VARTYPE vt)
+{
+ switch (vt)
+ {
+ case VT_I1: return FC_SMALL;
+ case VT_BOOL:
+ case VT_I2: return FC_SHORT;
+ case VT_INT:
+ case VT_ERROR:
+ case VT_HRESULT:
+ case VT_I4: return FC_LONG;
+ case VT_I8:
+ case VT_UI8: return FC_HYPER;
+ case VT_UI1: return FC_USMALL;
+ case VT_UI2: return FC_USHORT;
+ case VT_UINT:
+ case VT_UI4: return FC_ULONG;
+ case VT_R4: return FC_FLOAT;
+ case VT_DATE:
+ case VT_R8: return FC_DOUBLE;
+ default: return 0;
+ }
+}
+
+static unsigned int type_memsize(ITypeInfo *typeinfo, TYPEDESC *desc)
+{
+ switch (desc->vt)
+ {
+ case VT_I1:
+ case VT_UI1:
+ return 1;
+ case VT_I2:
+ case VT_UI2:
+ case VT_BOOL:
+ return 2;
+ case VT_I4:
+ case VT_UI4:
+ case VT_R4:
+ case VT_INT:
+ case VT_UINT:
+ case VT_ERROR:
+ case VT_HRESULT:
+ return 4;
+ case VT_I8:
+ case VT_UI8:
+ case VT_R8:
+ case VT_DATE:
+ return 8;
+ case VT_BSTR:
+ case VT_SAFEARRAY:
+ case VT_PTR:
+ case VT_UNKNOWN:
+ case VT_DISPATCH:
+ return sizeof(void *);
+ case VT_VARIANT:
+ return sizeof(VARIANT);
+ case VT_CARRAY:
+ {
+ unsigned int size = type_memsize(typeinfo, &desc->lpadesc->tdescElem);
+ unsigned int i;
+ for (i = 0; i < desc->lpadesc->cDims; i++)
+ size *= desc->lpadesc->rgbounds[i].cElements;
+ return size;
+ }
+ case VT_USERDEFINED:
+ {
+ unsigned int size = 0;
+ ITypeInfo *refinfo;
+ TYPEATTR *attr;
+
+ ITypeInfo_GetRefTypeInfo(typeinfo, desc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+ size = attr->cbSizeInstance;
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ return size;
+ }
+ default:
+ FIXME("unhandled type %u\n", desc->vt);
+ return 0;
+ }
+}
+
+static unsigned char get_array_fc(ITypeInfo *typeinfo, TYPEDESC *desc);
+
+static unsigned char get_struct_fc(ITypeInfo *typeinfo, TYPEATTR *attr)
+{
+ unsigned char fc = FC_STRUCT;
+ VARDESC *desc;
+ VARTYPE vt;
+ WORD i;
+
+ for (i = 0; i < attr->cVars; i++)
+ {
+ ITypeInfo_GetVarDesc(typeinfo, i, &desc);
+ vt = desc->elemdescVar.tdesc.vt;
+
+ switch (vt)
+ {
+ case VT_CARRAY:
+ if (get_array_fc(typeinfo, &desc->elemdescVar.tdesc.lpadesc->tdescElem) == FC_BOGUS_ARRAY)
+ fc = FC_BOGUS_STRUCT;
+ break;
+ default:
+ if (!get_base_type(vt))
+ {
+ FIXME("unhandled type %u\n", vt);
+ fc = FC_BOGUS_STRUCT;
+ }
+ break;
+ }
+
+ ITypeInfo_ReleaseVarDesc(typeinfo, desc);
+ }
+
+ return fc;
+}
+
+static unsigned char get_array_fc(ITypeInfo *typeinfo, TYPEDESC *desc)
+{
+ if (get_base_type(desc->vt))
+ return FC_LGFARRAY;
+ else if (desc->vt == VT_USERDEFINED)
+ {
+ ITypeInfo *refinfo;
+ TYPEATTR *attr;
+ unsigned char fc;
+
+ ITypeInfo_GetRefTypeInfo(typeinfo, desc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ if (attr->typekind == TKIND_ENUM)
+ fc = FC_LGFARRAY;
+ else if (attr->typekind == TKIND_RECORD && get_struct_fc(refinfo, attr) == FC_STRUCT)
+ fc = FC_LGFARRAY;
+ else
+ fc = FC_BOGUS_ARRAY;
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+
+ return fc;
+ }
+ else
+ return FC_BOGUS_ARRAY;
+}
+
+static size_t write_struct_tfs(ITypeInfo *typeinfo, unsigned char *str,
+ size_t *len, TYPEATTR *attr)
+{
+ unsigned char fc = get_struct_fc(typeinfo, attr);
+ size_t off = *len;
+
+ if (fc != FC_STRUCT)
+ FIXME("fc %02x not implemented\n", fc);
+
+ WRITE_CHAR (str, *len, FC_STRUCT);
+ WRITE_CHAR (str, *len, attr->cbAlignment - 1);
+ WRITE_SHORT(str, *len, attr->cbSizeInstance);
+ WRITE_CHAR (str, *len, FC_PAD);
+ WRITE_CHAR (str, *len, FC_END);
+
+ return off;
+}
+
+static size_t write_array_tfs(ITypeInfo *typeinfo, unsigned char *str,
+ size_t *len, ARRAYDESC *desc)
+{
+ unsigned char fc = get_array_fc(typeinfo, &desc->tdescElem);
+ ULONG size = type_memsize(typeinfo, &desc->tdescElem);
+ unsigned char basetype;
+ size_t ref = 0, off;
+ USHORT i;
+
+ if (fc != FC_LGFARRAY)
+ FIXME("complex arrays not implemented\n");
+
+ if (!(basetype = get_base_type(desc->tdescElem.vt)))
+ ref = write_type_tfs(typeinfo, str, len, &desc->tdescElem, FALSE, FALSE);
+
+ /* In theory arrays should be nested, but there's no reason not to marshal
+ * [x][y] as [x*y]. */
+ for (i = 0; i < desc->cDims; i++) size *= desc->rgbounds[i].cElements;
+
+ off = *len;
+
+ WRITE_CHAR(str, *len, FC_LGFARRAY);
+ WRITE_CHAR(str, *len, 0);
+ WRITE_INT (str, *len, size);
+ if (basetype)
+ WRITE_CHAR(str, *len, basetype);
+ else
+ {
+ WRITE_CHAR (str, *len, FC_EMBEDDED_COMPLEX);
+ WRITE_CHAR (str, *len, 0);
+ WRITE_SHORT(str, *len, ref - *len);
+ WRITE_CHAR (str, *len, FC_PAD);
+ }
+ WRITE_CHAR(str, *len, FC_END);
+
+ return off;
+}
+
+static size_t write_ip_tfs(unsigned char *str, size_t *len, const GUID *iid)
+{
+ size_t off = *len;
+
+ if (str)
+ {
+ str[*len] = FC_IP;
+ str[*len+1] = FC_CONSTANT_IID;
+ memcpy(str + *len + 2, iid, sizeof(*iid));
+ }
+ *len += 2 + sizeof(*iid);
+
+ return off;
+}
+
+static void get_default_iface(ITypeInfo *typeinfo, WORD count, GUID *iid)
+{
+ ITypeInfo *refinfo;
+ HREFTYPE reftype;
+ TYPEATTR *attr;
+ int flags, i;
+
+ for (i = 0; i < count; ++i)
+ {
+ ITypeInfo_GetImplTypeFlags(typeinfo, i, &flags);
+ if (flags & IMPLTYPEFLAG_FDEFAULT)
+ break;
+ }
+
+ /* If no interface was explicitly marked default, choose the first one. */
+ if (i == count)
+ i = 0;
+
+ ITypeInfo_GetRefTypeOfImplType(typeinfo, i, &reftype);
+ ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+ *iid = attr->guid;
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+}
+
+static size_t write_pointer_tfs(ITypeInfo *typeinfo, unsigned char *str,
+ size_t *len, TYPEDESC *desc, BOOL toplevel, BOOL onstack)
+{
+ unsigned char basetype, flags = 0;
+ size_t ref, off = *len;
+ ITypeInfo *refinfo;
+ TYPEATTR *attr;
+ GUID guid;
+
+ if (desc->vt == VT_USERDEFINED)
+ {
+ ITypeInfo_GetRefTypeInfo(typeinfo, desc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ switch (attr->typekind)
+ {
+ case TKIND_ENUM:
+ assert(!toplevel); /* toplevel base-type pointers should use IsSimpleRef */
+ WRITE_CHAR(str, *len, FC_UP);
+ WRITE_CHAR(str, *len, FC_SIMPLE_POINTER);
+ WRITE_CHAR(str, *len, FC_ENUM32);
+ WRITE_CHAR(str, *len, FC_PAD);
+ break;
+ case TKIND_RECORD:
+ assert(!toplevel); /* toplevel struct pointers should use IsSimpleRef */
+ ref = write_struct_tfs(refinfo, str, len, attr);
+ off = *len;
+ WRITE_CHAR (str, *len, FC_UP);
+ WRITE_CHAR (str, *len, 0);
+ WRITE_SHORT(str, *len, ref - *len);
+ break;
+ case TKIND_INTERFACE:
+ case TKIND_DISPATCH:
+ write_ip_tfs(str, len, &attr->guid);
+ break;
+ case TKIND_COCLASS:
+ get_default_iface(refinfo, attr->cImplTypes, &guid);
+ write_ip_tfs(str, len, &guid);
+ break;
+ case TKIND_ALIAS:
+ off = write_pointer_tfs(refinfo, str, len, &attr->tdescAlias, toplevel, onstack);
+ break;
+ default:
+ FIXME("unhandled kind %#x\n", attr->typekind);
+ WRITE_SHORT(str, *len, 0);
+ break;
+ }
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ }
+ else if ((basetype = get_base_type(desc->vt)))
+ {
+ assert(!toplevel); /* toplevel base-type pointers should use IsSimpleRef */
+ WRITE_CHAR(str, *len, FC_UP);
+ WRITE_CHAR(str, *len, FC_SIMPLE_POINTER);
+ WRITE_CHAR(str, *len, basetype);
+ WRITE_CHAR(str, *len, FC_PAD);
+ }
+ else
+ {
+ ref = write_type_tfs(typeinfo, str, len, desc, FALSE, FALSE);
+
+ if (onstack) flags |= FC_ALLOCED_ON_STACK;
+ if (desc->vt == VT_PTR || desc->vt == VT_UNKNOWN || desc->vt == VT_DISPATCH)
+ flags |= FC_POINTER_DEREF;
+
+ off = *len;
+
+ WRITE_CHAR (str, *len, toplevel ? FC_RP : FC_UP);
+ WRITE_CHAR (str, *len, flags);
+ WRITE_SHORT(str, *len, ref - *len);
+ }
+
+ return off;
+}
+
+static size_t write_type_tfs(ITypeInfo *typeinfo, unsigned char *str,
+ size_t *len, TYPEDESC *desc, BOOL toplevel, BOOL onstack)
+{
+ ITypeInfo *refinfo;
+ TYPEATTR *attr;
+ size_t off;
+
+ TRACE("vt %d%s\n", desc->vt, toplevel ? " (toplevel)" : "");
+
+ if ((off = write_oleaut_tfs(desc->vt)))
+ return off;
+
+ switch (desc->vt)
+ {
+ case VT_PTR:
+ return write_pointer_tfs(typeinfo, str, len, desc->lptdesc, toplevel, onstack);
+ case VT_CARRAY:
+ return write_array_tfs(typeinfo, str, len, desc->lpadesc);
+ case VT_USERDEFINED:
+ ITypeInfo_GetRefTypeInfo(typeinfo, desc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ switch (attr->typekind)
+ {
+ case TKIND_RECORD:
+ off = write_struct_tfs(refinfo, str, len, attr);
+ break;
+ default:
+ FIXME("unhandled kind %u\n", attr->typekind);
+ off = *len;
+ WRITE_SHORT(str, *len, 0);
+ break;
+ }
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ break;
+ default:
+ /* base types are always embedded directly */
+ assert(!get_base_type(desc->vt));
+ FIXME("unhandled type %u\n", desc->vt);
+ off = *len;
+ WRITE_SHORT(str, *len, 0);
+ break;
+ }
+
+ return off;
+}
+
+static unsigned short get_stack_size(ITypeInfo *typeinfo, TYPEDESC *desc)
+{
+#if defined(__i386__) || defined(__arm__)
+ if (desc->vt == VT_CARRAY)
+ return sizeof(void *);
+ return (type_memsize(typeinfo, desc) + 3) & ~3;
+#else
+ return sizeof(void *);
+#endif
+}
+
+static const unsigned short MustSize = 0x0001;
+static const unsigned short MustFree = 0x0002;
+static const unsigned short IsIn = 0x0008;
+static const unsigned short IsOut = 0x0010;
+static const unsigned short IsReturn = 0x0020;
+static const unsigned short IsBasetype = 0x0040;
+static const unsigned short IsByValue = 0x0080;
+static const unsigned short IsSimpleRef = 0x0100;
+
+static HRESULT get_param_pointer_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int is_in,
+ int is_out, unsigned short *server_size, unsigned short *flags,
+ unsigned char *basetype, TYPEDESC **tfs_tdesc)
+{
+ ITypeInfo *refinfo;
+ HRESULT hr = S_OK;
+ TYPEATTR *attr;
+
+ switch (tdesc->vt)
+ {
+ case VT_UNKNOWN:
+ case VT_DISPATCH:
+ *flags |= MustFree;
+ if (is_in && is_out)
+ *server_size = sizeof(void *);
+ break;
+ case VT_PTR:
+ *flags |= MustFree;
+
+ if (tdesc->lptdesc->vt == VT_USERDEFINED)
+ {
+ ITypeInfo_GetRefTypeInfo(typeinfo, tdesc->lptdesc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ switch (attr->typekind)
+ {
+ case TKIND_INTERFACE:
+ case TKIND_DISPATCH:
+ case TKIND_COCLASS:
+ if (is_in && is_out)
+ *server_size = sizeof(void *);
+ break;
+ default:
+ *server_size = sizeof(void *);
+ }
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ }
+ else
+ *server_size = sizeof(void *);
+ break;
+ case VT_CARRAY:
+ *flags |= IsSimpleRef | MustFree;
+ *server_size = type_memsize(typeinfo, tdesc);
+ *tfs_tdesc = tdesc;
+ break;
+ case VT_USERDEFINED:
+ ITypeInfo_GetRefTypeInfo(typeinfo, tdesc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ switch (attr->typekind)
+ {
+ case TKIND_ENUM:
+ *flags |= IsSimpleRef | IsBasetype;
+ if (!is_in && is_out)
+ *server_size = sizeof(void *);
+ *basetype = FC_ENUM32;
+ break;
+ case TKIND_RECORD:
+ *flags |= IsSimpleRef | MustFree;
+ if (!is_in && is_out)
+ *server_size = attr->cbSizeInstance;
+ *tfs_tdesc = tdesc;
+ break;
+ case TKIND_INTERFACE:
+ case TKIND_DISPATCH:
+ case TKIND_COCLASS:
+ *flags |= MustFree;
+ break;
+ case TKIND_ALIAS:
+ hr = get_param_pointer_info(refinfo, &attr->tdescAlias, is_in,
+ is_out, server_size, flags, basetype, tfs_tdesc);
+ break;
+ default:
+ FIXME("unhandled kind %#x\n", attr->typekind);
+ hr = E_NOTIMPL;
+ break;
+ }
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ break;
+ default:
+ *flags |= IsSimpleRef;
+ *tfs_tdesc = tdesc;
+ if (!is_in && is_out)
+ *server_size = type_memsize(typeinfo, tdesc);
+ if ((*basetype = get_base_type(tdesc->vt)))
+ *flags |= IsBasetype;
+ break;
+ }
+
+ return hr;
+}
+
+static HRESULT get_param_info(ITypeInfo *typeinfo, TYPEDESC *tdesc, int is_in,
+ int is_out, unsigned short *server_size, unsigned short *flags,
+ unsigned char *basetype, TYPEDESC **tfs_tdesc)
+{
+ ITypeInfo *refinfo;
+ HRESULT hr = S_OK;
+ TYPEATTR *attr;
+
+ *server_size = 0;
+ *flags = MustSize;
+ *basetype = 0;
+ *tfs_tdesc = tdesc;
+
+ TRACE("vt %u\n", tdesc->vt);
+
+ switch (tdesc->vt)
+ {
+ case VT_VARIANT:
+#if !defined(__i386__) && !defined(__arm__)
+ *flags |= IsSimpleRef | MustFree;
+ break;
+#endif
+ /* otherwise fall through */
+ case VT_BSTR:
+ case VT_SAFEARRAY:
+ case VT_CY:
+ *flags |= IsByValue | MustFree;
+ break;
+ case VT_UNKNOWN:
+ case VT_DISPATCH:
+ case VT_CARRAY:
+ *flags |= MustFree;
+ break;
+ case VT_PTR:
+ return get_param_pointer_info(typeinfo, tdesc->lptdesc, is_in, is_out,
+ server_size, flags, basetype, tfs_tdesc);
+ case VT_USERDEFINED:
+ ITypeInfo_GetRefTypeInfo(typeinfo, tdesc->hreftype, &refinfo);
+ ITypeInfo_GetTypeAttr(refinfo, &attr);
+
+ switch (attr->typekind)
+ {
+ case TKIND_ENUM:
+ *flags |= IsBasetype;
+ *basetype = FC_ENUM32;
+ break;
+ case TKIND_RECORD:
+#if defined(__i386__) || defined(__arm__)
+ *flags |= IsByValue | MustFree;
+#else
+ if (attr->cbSizeInstance <= 8)
+ *flags |= IsByValue | MustFree;
+ else
+ *flags |= IsSimpleRef | MustFree;
+#endif
+ break;
+ case TKIND_ALIAS:
+ hr = get_param_info(refinfo, &attr->tdescAlias, is_in, is_out,
+ server_size, flags, basetype, tfs_tdesc);
+ break;
+ default:
+ FIXME("unhandled kind %#x\n", attr->typekind);
+ hr = E_NOTIMPL;
+ break;
+ }
+
+ ITypeInfo_ReleaseTypeAttr(refinfo, attr);
+ ITypeInfo_Release(refinfo);
+ break;
+ default:
+ if ((*basetype = get_base_type(tdesc->vt)))
+ *flags |= IsBasetype;
+ else
+ {
+ FIXME("unhandled type %u\n", tdesc->vt);
+ return E_NOTIMPL;
+ }
+ break;
+ }
+
+ return hr;
+}
+
+static HRESULT write_param_fs(ITypeInfo *typeinfo, unsigned char *type,
+ size_t *typelen, unsigned char *proc, size_t *proclen, ELEMDESC *desc,
+ BOOL is_return, unsigned short *stack_offset)
+{
+ USHORT param_flags = desc->paramdesc.wParamFlags;
+ int is_in = param_flags & PARAMFLAG_FIN;
+ int is_out = param_flags & PARAMFLAG_FOUT;
+ TYPEDESC *tdesc = &desc->tdesc, *tfs_tdesc;
+ unsigned short server_size;
+ unsigned short stack_size = get_stack_size(typeinfo, tdesc);
+ unsigned char basetype;
+ unsigned short flags;
+ size_t off = 0;
+ HRESULT hr;
+
+ hr = get_param_info(typeinfo, tdesc, is_in, is_out, &server_size, &flags,
+ &basetype, &tfs_tdesc);
+
+ if (is_in) flags |= IsIn;
+ if (is_out) flags |= IsOut;
+ if (is_return) flags |= IsOut | IsReturn;
+
+ server_size = (server_size + 7) / 8;
+ if (server_size >= 8) server_size = 0;
+ flags |= server_size << 13;
+
+ if (!basetype)
+ off = write_type_tfs(typeinfo, type, typelen, tfs_tdesc, TRUE, server_size != 0);
+
+ if (SUCCEEDED(hr))
+ {
+ WRITE_SHORT(proc, *proclen, flags);
+ WRITE_SHORT(proc, *proclen, *stack_offset);
+ WRITE_SHORT(proc, *proclen, basetype ? basetype : off);
+
+ *stack_offset += stack_size;
+ }
+
+ return hr;
+}
+
+static void write_proc_func_header(ITypeInfo *typeinfo, FUNCDESC *desc,
+ WORD proc_idx, unsigned char *proc, size_t *proclen)
+{
+ unsigned short stack_size = 2 * sizeof(void *); /* This + return */
+#ifdef __x86_64__
+ unsigned short float_mask = 0;
+ unsigned char basetype;
+#endif
+ WORD param_idx;
+
+ WRITE_CHAR (proc, *proclen, FC_AUTO_HANDLE);
+ WRITE_CHAR (proc, *proclen, Oi_OBJECT_PROC | Oi_OBJ_USE_V2_INTERPRETER);
+ WRITE_SHORT(proc, *proclen, proc_idx);
+ for (param_idx = 0; param_idx < desc->cParams; param_idx++)
+ stack_size += get_stack_size(typeinfo, &desc->lprgelemdescParam[param_idx].tdesc);
+ WRITE_SHORT(proc, *proclen, stack_size);
+
+ WRITE_SHORT(proc, *proclen, 0); /* constant_client_buffer_size */
+ WRITE_SHORT(proc, *proclen, 0); /* constant_server_buffer_size */
+#ifdef __x86_64__
+ WRITE_CHAR (proc, *proclen, 0x47); /* HasExtensions | HasReturn | ClientMustSize | ServerMustSize */
+#else
+ WRITE_CHAR (proc, *proclen, 0x07); /* HasReturn | ClientMustSize | ServerMustSize */
+#endif
+ WRITE_CHAR (proc, *proclen, desc->cParams + 1); /* incl. return value */
+#ifdef __x86_64__
+ WRITE_CHAR (proc, *proclen, 10); /* extension size */
+ WRITE_CHAR (proc, *proclen, 0); /* INTERPRETER_OPT_FLAGS2 */
+ WRITE_SHORT(proc, *proclen, 0); /* ClientCorrHint */
+ WRITE_SHORT(proc, *proclen, 0); /* ServerCorrHint */
+ WRITE_SHORT(proc, *proclen, 0); /* NotifyIndex */
+ for (param_idx = 0; param_idx < desc->cParams && param_idx < 3; param_idx++)
+ {
+ basetype = get_base_type(desc->lprgelemdescParam[param_idx].tdesc.vt);
+ if (basetype == FC_FLOAT)
+ float_mask |= (1 << ((param_idx + 1) * 2));
+ else if (basetype == FC_DOUBLE)
+ float_mask |= (2 << ((param_idx + 1) * 2));
+ }
+ WRITE_SHORT(proc, *proclen, float_mask);
+#endif
+}
+
+static HRESULT write_iface_fs(ITypeInfo *typeinfo, WORD funcs, WORD parentfuncs,
+ unsigned char *type, size_t *typelen, unsigned char *proc,
+ size_t *proclen, unsigned short *offset)
+{
+ unsigned short stack_offset;
+ WORD proc_idx, param_idx;
+ FUNCDESC *desc;
+ HRESULT hr;
+
+ for (proc_idx = 3; proc_idx < parentfuncs; proc_idx++)
+ {
+ if (offset)
+ offset[proc_idx - 3] = -1;
+ }
+
+ for (proc_idx = 0; proc_idx < funcs; proc_idx++)
+ {
+ TRACE("Writing procedure %d.\n", proc_idx);
+
+ hr = ITypeInfo_GetFuncDesc(typeinfo, proc_idx, &desc);
+ if (FAILED(hr)) return hr;
+
+ if (offset)
+ offset[proc_idx + parentfuncs - 3] = *proclen;
+
+ write_proc_func_header(typeinfo, desc, proc_idx + parentfuncs, proc, proclen);
+
+ stack_offset = sizeof(void *); /* This */
+ for (param_idx = 0; param_idx < desc->cParams; param_idx++)
+ {
+ TRACE("Writing parameter %d.\n", param_idx);
+ hr = write_param_fs(typeinfo, type, typelen, proc, proclen,
+ &desc->lprgelemdescParam[param_idx], FALSE, &stack_offset);
+ if (FAILED(hr))
+ {
+ ITypeInfo_ReleaseFuncDesc(typeinfo, desc);
+ return hr;
+ }
+ }
+
+ hr = write_param_fs(typeinfo, type, typelen, proc, proclen,
+ &desc->elemdescFunc, TRUE, &stack_offset);
+ ITypeInfo_ReleaseFuncDesc(typeinfo, desc);
+ if (FAILED(hr)) return hr;
+ }
+
+ return S_OK;
+}
+
+static HRESULT build_format_strings(ITypeInfo *typeinfo, WORD funcs,
+ WORD parentfuncs, const unsigned char **type_ret,
+ const unsigned char **proc_ret, unsigned short **offset_ret)
+{
+ size_t tfs_size;
+ const unsigned char *tfs = get_type_format_string( &tfs_size );
+ size_t typelen = tfs_size, proclen = 0;
+ unsigned char *type, *proc;
+ unsigned short *offset;
+ HRESULT hr;
+
+ hr = write_iface_fs(typeinfo, funcs, parentfuncs, NULL, &typelen, NULL, &proclen, NULL);
+ if (FAILED(hr)) return hr;
+
+ type = heap_alloc(typelen);
+ proc = heap_alloc(proclen);
+ offset = heap_alloc((parentfuncs + funcs - 3) * sizeof(*offset));
+ if (!type || !proc || !offset)
+ {
+ ERR("Failed to allocate format strings.\n");
+ hr = E_OUTOFMEMORY;
+ goto err;
+ }
+
+ memcpy(type, tfs, tfs_size);
+ typelen = tfs_size;
+ proclen = 0;
+
+ hr = write_iface_fs(typeinfo, funcs, parentfuncs, type, &typelen, proc, &proclen, offset);
+ if (SUCCEEDED(hr))
+ {
+ *type_ret = type;
+ *proc_ret = proc;
+ *offset_ret = offset;
+ return S_OK;
+ }
+
+err:
+ heap_free(type);
+ heap_free(proc);
+ heap_free(offset);
+ return hr;
+}
+
+/* Common helper for Create{Proxy,Stub}FromTypeInfo(). */
+static HRESULT get_iface_info(ITypeInfo **typeinfo, WORD *funcs, WORD *parentfuncs,
+ GUID *parentiid)
+{
+ ITypeInfo *real_typeinfo, *parentinfo;
+ TYPEATTR *typeattr;
+ ITypeLib *typelib;
+ TLIBATTR *libattr;
+ TYPEKIND typekind;
+ HREFTYPE reftype;
+ SYSKIND syskind;
+ HRESULT hr;
+
+ /* Dual interfaces report their size to be sizeof(IDispatchVtbl) and their
+ * implemented type to be IDispatch. We need to retrieve the underlying
+ * interface to get that information. */
+ hr = ITypeInfo_GetTypeAttr(*typeinfo, &typeattr);
+ if (FAILED(hr))
+ return hr;
+ typekind = typeattr->typekind;
+ ITypeInfo_ReleaseTypeAttr(*typeinfo, typeattr);
+ if (typekind == TKIND_DISPATCH)
+ {
+ hr = ITypeInfo_GetRefTypeOfImplType(*typeinfo, -1, &reftype);
+ if (FAILED(hr))
+ return hr;
+
+ hr = ITypeInfo_GetRefTypeInfo(*typeinfo, reftype, &real_typeinfo);
+ if (FAILED(hr))
+ return hr;
+
+ ITypeInfo_Release(*typeinfo);
+ *typeinfo = real_typeinfo;
+ }
+
+ hr = ITypeInfo_GetContainingTypeLib(*typeinfo, &typelib, NULL);
+ if (FAILED(hr))
+ return hr;
+
+ hr = ITypeLib_GetLibAttr(typelib, &libattr);
+ if (FAILED(hr))
+ {
+ ITypeLib_Release(typelib);
+ return hr;
+ }
+ syskind = libattr->syskind;
+ ITypeLib_ReleaseTLibAttr(typelib, libattr);
+ ITypeLib_Release(typelib);
+
+ hr = ITypeInfo_GetTypeAttr(*typeinfo, &typeattr);
+ if (FAILED(hr))
+ return hr;
+ *funcs = typeattr->cFuncs;
+ *parentfuncs = typeattr->cbSizeVft / (syskind == SYS_WIN64 ? 8 : 4) - *funcs;
+ ITypeInfo_ReleaseTypeAttr(*typeinfo, typeattr);
+
+ hr = ITypeInfo_GetRefTypeOfImplType(*typeinfo, 0, &reftype);
+ if (FAILED(hr))
+ return hr;
+ hr = ITypeInfo_GetRefTypeInfo(*typeinfo, reftype, &parentinfo);
+ if (FAILED(hr))
+ return hr;
+ hr = ITypeInfo_GetTypeAttr(parentinfo, &typeattr);
+ if (FAILED(hr))
+ return hr;
+ *parentiid = typeattr->guid;
+ ITypeInfo_ReleaseTypeAttr(parentinfo, typeattr);
+ ITypeInfo_Release(parentinfo);
+
+ return hr;
+}
+
+static void init_stub_desc(MIDL_STUB_DESC *desc)
+{
+ desc->pfnAllocate = NdrOleAllocate;
+ desc->pfnFree = NdrOleFree;
+ desc->Version = 0x50002;
+ desc->aUserMarshalQuadruple = get_ndr_types_proxy_info()->pStubDesc->aUserMarshalQuadruple;
+ /* type format string is initialized with proc format string and offset table */
+}
+
+struct typelib_proxy
+{
+ StdProxyImpl proxy;
+ IID iid;
+ MIDL_STUB_DESC stub_desc;
+ MIDL_STUBLESS_PROXY_INFO proxy_info;
+ CInterfaceProxyVtbl *proxy_vtbl;
+ unsigned short *offset_table;
+};
+
+static ULONG WINAPI typelib_proxy_Release(IRpcProxyBuffer *iface)
+{
+ struct typelib_proxy *proxy = CONTAINING_RECORD(iface, struct typelib_proxy, proxy.IRpcProxyBuffer_iface);
+ ULONG refcount = InterlockedDecrement(&proxy->proxy.RefCount);
+
+ TRACE("(%p) decreasing refs to %d\n", proxy, refcount);
+
+ if (!refcount)
+ {
+ if (proxy->proxy.pChannel)
+ IRpcProxyBuffer_Disconnect(&proxy->proxy.IRpcProxyBuffer_iface);
+ if (proxy->proxy.base_object)
+ IUnknown_Release(proxy->proxy.base_object);
+ if (proxy->proxy.base_proxy)
+ IRpcProxyBuffer_Release(proxy->proxy.base_proxy);
+ heap_free((void *)proxy->stub_desc.pFormatTypes);
+ heap_free((void *)proxy->proxy_info.ProcFormatString);
+ heap_free(proxy->offset_table);
+ heap_free(proxy->proxy_vtbl);
+ heap_free(proxy);
+ }
+ return refcount;
+}
+
+static const IRpcProxyBufferVtbl typelib_proxy_vtbl =
+{
+ StdProxy_QueryInterface,
+ StdProxy_AddRef,
+ typelib_proxy_Release,
+ StdProxy_Connect,
+ StdProxy_Disconnect,
+};
+
+static HRESULT typelib_proxy_init(struct typelib_proxy *proxy, IUnknown *outer,
+ ULONG count, const GUID *parentiid, IRpcProxyBuffer **proxy_buffer, void **out)
+{
+ if (!fill_stubless_table((IUnknownVtbl *)proxy->proxy_vtbl->Vtbl, count))
+ return E_OUTOFMEMORY;
+
+ if (!outer) outer = (IUnknown *)&proxy->proxy;
+
+ proxy->proxy.IRpcProxyBuffer_iface.lpVtbl = &typelib_proxy_vtbl;
+ proxy->proxy.PVtbl = proxy->proxy_vtbl->Vtbl;
+ proxy->proxy.RefCount = 1;
+ proxy->proxy.piid = proxy->proxy_vtbl->header.piid;
+ proxy->proxy.pUnkOuter = outer;
+
+ if (!IsEqualGUID(parentiid, &IID_IUnknown))
+ {
+ HRESULT hr = create_proxy(parentiid, NULL, &proxy->proxy.base_proxy,
+ (void **)&proxy->proxy.base_object);
+ if (FAILED(hr)) return hr;
+ }
+
+ *proxy_buffer = &proxy->proxy.IRpcProxyBuffer_iface;
+ *out = &proxy->proxy.PVtbl;
+ IUnknown_AddRef((IUnknown *)*out);
+
+ return S_OK;
+}
+
+HRESULT WINAPI CreateProxyFromTypeInfo(ITypeInfo *typeinfo, IUnknown *outer,
+ REFIID iid, IRpcProxyBuffer **proxy_buffer, void **out)
+{
+ struct typelib_proxy *proxy;
+ WORD funcs, parentfuncs, i;
+ GUID parentiid;
+ HRESULT hr;
+
+ TRACE("typeinfo %p, outer %p, iid %s, proxy_buffer %p, out %p.\n",
+ typeinfo, outer, debugstr_guid(iid), proxy_buffer, out);
+
+ hr = get_iface_info(&typeinfo, &funcs, &parentfuncs, &parentiid);
+ if (FAILED(hr))
+ return hr;
+
+ if (!(proxy = heap_alloc_zero(sizeof(*proxy))))
+ {
+ ERR("Failed to allocate proxy object.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ init_stub_desc(&proxy->stub_desc);
+ proxy->proxy_info.pStubDesc = &proxy->stub_desc;
+
+ proxy->proxy_vtbl = heap_alloc_zero(sizeof(proxy->proxy_vtbl->header) + (funcs + parentfuncs) * sizeof(void *));
+ if (!proxy->proxy_vtbl)
+ {
+ ERR("Failed to allocate proxy vtbl.\n");
+ heap_free(proxy);
+ return E_OUTOFMEMORY;
+ }
+ proxy->proxy_vtbl->header.pStublessProxyInfo = &proxy->proxy_info;
+ proxy->iid = *iid;
+ proxy->proxy_vtbl->header.piid = &proxy->iid;
+ fill_delegated_proxy_table((IUnknownVtbl *)proxy->proxy_vtbl->Vtbl, parentfuncs);
+ for (i = 0; i < funcs; i++)
+ proxy->proxy_vtbl->Vtbl[parentfuncs + i] = (void *)-1;
+
+ hr = build_format_strings(typeinfo, funcs, parentfuncs, &proxy->stub_desc.pFormatTypes,
+ &proxy->proxy_info.ProcFormatString, &proxy->offset_table);
+ if (FAILED(hr))
+ {
+ heap_free(proxy->proxy_vtbl);
+ heap_free(proxy);
+ return hr;
+ }
+ proxy->proxy_info.FormatStringOffset = &proxy->offset_table[-3];
+
+ hr = typelib_proxy_init(proxy, outer, funcs + parentfuncs, &parentiid, proxy_buffer, out);
+ if (FAILED(hr))
+ {
+ heap_free((void *)proxy->stub_desc.pFormatTypes);
+ heap_free((void *)proxy->proxy_info.ProcFormatString);
+ heap_free((void *)proxy->offset_table);
+ heap_free(proxy->proxy_vtbl);
+ heap_free(proxy);
+ }
+
+ return hr;
+}
+
+struct typelib_stub
+{
+ cstdstubbuffer_delegating_t stub;
+ IID iid;
+ MIDL_STUB_DESC stub_desc;
+ MIDL_SERVER_INFO server_info;
+ CInterfaceStubVtbl stub_vtbl;
+ unsigned short *offset_table;
+ PRPC_STUB_FUNCTION *dispatch_table;
+};
+
+static ULONG WINAPI typelib_stub_Release(IRpcStubBuffer *iface)
+{
+ struct typelib_stub *stub = CONTAINING_RECORD(iface, struct typelib_stub, stub.stub_buffer);
+ ULONG refcount = InterlockedDecrement(&stub->stub.stub_buffer.RefCount);
+
+ TRACE("(%p) decreasing refs to %d\n", stub, refcount);
+
+ if (!refcount)
+ {
+ /* test_Release shows that native doesn't call Disconnect here.
+ We'll leave it in for the time being. */
+ IRpcStubBuffer_Disconnect(iface);
+
+ if (stub->stub.base_stub)
+ {
+ IRpcStubBuffer_Release(stub->stub.base_stub);
+ release_delegating_vtbl(stub->stub.base_obj);
+ heap_free(stub->dispatch_table);
+ }
+
+ heap_free((void *)stub->stub_desc.pFormatTypes);
+ heap_free((void *)stub->server_info.ProcString);
+ heap_free(stub->offset_table);
+ heap_free(stub);
+ }
+
+ return refcount;
+}
+
+static HRESULT typelib_stub_init(struct typelib_stub *stub, IUnknown *server,
+ const GUID *parentiid, IRpcStubBuffer **stub_buffer)
+{
+ HRESULT hr;
+
+ hr = IUnknown_QueryInterface(server, stub->stub_vtbl.header.piid,
+ (void **)&stub->stub.stub_buffer.pvServerObject);
+ if (FAILED(hr))
+ {
+ WARN("Failed to get interface %s, hr %#x.\n",
+ debugstr_guid(stub->stub_vtbl.header.piid), hr);
+ stub->stub.stub_buffer.pvServerObject = server;
+ IUnknown_AddRef(server);
+ }
+
+ if (!IsEqualGUID(parentiid, &IID_IUnknown))
+ {
+ stub->stub.base_obj = get_delegating_vtbl(stub->stub_vtbl.header.DispatchTableCount);
+ hr = create_stub(parentiid, (IUnknown *)&stub->stub.base_obj, &stub->stub.base_stub);
+ if (FAILED(hr))
+ {
+ release_delegating_vtbl(stub->stub.base_obj);
+ IUnknown_Release(stub->stub.stub_buffer.pvServerObject);
+ return hr;
+ }
+ }
+
+ stub->stub.stub_buffer.lpVtbl = &stub->stub_vtbl.Vtbl;
+ stub->stub.stub_buffer.RefCount = 1;
+
+ *stub_buffer = (IRpcStubBuffer *)&stub->stub.stub_buffer;
+ return S_OK;
+}
+
+HRESULT WINAPI CreateStubFromTypeInfo(ITypeInfo *typeinfo, REFIID iid,
+ IUnknown *server, IRpcStubBuffer **stub_buffer)
+{
+ WORD funcs, parentfuncs, i;
+ struct typelib_stub *stub;
+ GUID parentiid;
+ HRESULT hr;
+
+ TRACE("typeinfo %p, iid %s, server %p, stub_buffer %p.\n",
+ typeinfo, debugstr_guid(iid), server, stub_buffer);
+
+ hr = get_iface_info(&typeinfo, &funcs, &parentfuncs, &parentiid);
+ if (FAILED(hr))
+ return hr;
+
+ if (!(stub = heap_alloc_zero(sizeof(*stub))))
+ {
+ ERR("Failed to allocate stub object.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ init_stub_desc(&stub->stub_desc);
+ stub->server_info.pStubDesc = &stub->stub_desc;
+
+ hr = build_format_strings(typeinfo, funcs, parentfuncs, &stub->stub_desc.pFormatTypes,
+ &stub->server_info.ProcString, &stub->offset_table);
+ if (FAILED(hr))
+ {
+ heap_free(stub);
+ return hr;
+ }
+ stub->server_info.FmtStringOffset = &stub->offset_table[-3];
+
+ stub->iid = *iid;
+ stub->stub_vtbl.header.piid = &stub->iid;
+ stub->stub_vtbl.header.pServerInfo = &stub->server_info;
+ stub->stub_vtbl.header.DispatchTableCount = funcs + parentfuncs;
+
+ if (!IsEqualGUID(&parentiid, &IID_IUnknown))
+ {
+ stub->dispatch_table = heap_alloc((funcs + parentfuncs) * sizeof(void *));
+ for (i = 3; i < parentfuncs; i++)
+ stub->dispatch_table[i - 3] = NdrStubForwardingFunction;
+ for (; i < funcs + parentfuncs; i++)
+ stub->dispatch_table[i - 3] = (PRPC_STUB_FUNCTION)NdrStubCall2;
+ stub->stub_vtbl.header.pDispatchTable = &stub->dispatch_table[-3];
+ stub->stub_vtbl.Vtbl = CStdStubBuffer_Delegating_Vtbl;
+ }
+ else
+ stub->stub_vtbl.Vtbl = CStdStubBuffer_Vtbl;
+ stub->stub_vtbl.Vtbl.Release = typelib_stub_Release;
+
+ hr = typelib_stub_init(stub, server, &parentiid, stub_buffer);
+ if (FAILED(hr))
+ {
+ heap_free((void *)stub->stub_desc.pFormatTypes);
+ heap_free((void *)stub->server_info.ProcString);
+ heap_free(stub->offset_table);
+ heap_free(stub);
+ }
+
+ return hr;
+}