4 * Copyright 2002 Greg Turner
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * - figure out whether we *really* got this right
22 * - check for errors and throw exceptions
39 #include "wine/unicode.h"
40 #include "wine/rpcfc.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(ole);
46 #define BUFFER_PARANOIA 20
49 # define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
50 (*((UINT32 *)(pchar)) = (uint32))
52 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
53 (*((UINT32 *)(pchar)))
55 /* these would work for i386 too, but less efficient */
56 # define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
57 (*(pchar) = LOBYTE(LOWORD(uint32)), \
58 *((pchar)+1) = HIBYTE(LOWORD(uint32)), \
59 *((pchar)+2) = LOBYTE(HIWORD(uint32)), \
60 *((pchar)+3) = HIBYTE(HIWORD(uint32)), \
61 (uint32)) /* allow as r-value */
63 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
65 MAKEWORD(*(pchar), *((pchar)+1)), \
66 MAKEWORD(*((pchar)+2), *((pchar)+3))))
69 #define BIG_ENDIAN_UINT32_WRITE(pchar, uint32) \
70 (*((pchar)+3) = LOBYTE(LOWORD(uint32)), \
71 *((pchar)+2) = HIBYTE(LOWORD(uint32)), \
72 *((pchar)+1) = LOBYTE(HIWORD(uint32)), \
73 *(pchar) = HIBYTE(HIWORD(uint32)), \
74 (uint32)) /* allow as r-value */
76 #define BIG_ENDIAN_UINT32_READ(pchar) \
78 MAKEWORD(*((pchar)+3), *((pchar)+2)), \
79 MAKEWORD(*((pchar)+1), *(pchar))))
81 #ifdef NDR_LOCAL_IS_BIG_ENDIAN
82 # define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
83 BIG_ENDIAN_UINT32_WRITE(pchar, uint32)
84 # define NDR_LOCAL_UINT32_READ(pchar) \
85 BIG_ENDIAN_UINT32_READ(pchar)
87 # define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
88 LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
89 # define NDR_LOCAL_UINT32_READ(pchar) \
90 LITTLE_ENDIAN_UINT32_READ(pchar)
93 /* _Align must be the desired alignment,
94 * e.g. ALIGN_LENGTH(len, 4) to align on a dword boundary. */
95 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align)-1)&~((_Align)-1))
96 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
97 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
98 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
100 #define STD_OVERFLOW_CHECK(_Msg) do { \
101 TRACE("buffer=%d/%ld\n", _Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer, _Msg->BufferLength); \
102 if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \
103 ERR("buffer overflow %d bytes\n", _Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength)); \
106 #define NDR_TABLE_SIZE 128
107 #define NDR_TABLE_MASK 127
109 static unsigned char *WINAPI NdrBaseTypeMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
110 static unsigned char *WINAPI NdrBaseTypeUnmarshall(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char);
111 static void WINAPI NdrBaseTypeBufferSize(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
112 static void WINAPI NdrBaseTypeFree(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
113 static unsigned long WINAPI NdrBaseTypeMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING);
115 const NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE] = {
117 NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
118 NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
119 NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
120 NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall, NdrBaseTypeMarshall,
124 NdrPointerMarshall, NdrPointerMarshall,
125 NdrPointerMarshall, NdrPointerMarshall,
127 NdrSimpleStructMarshall, NdrSimpleStructMarshall,
128 NdrConformantStructMarshall, NdrConformantStructMarshall,
129 NdrConformantVaryingStructMarshall,
130 NdrComplexStructMarshall,
132 NdrConformantArrayMarshall,
133 NdrConformantVaryingArrayMarshall,
134 NdrFixedArrayMarshall, NdrFixedArrayMarshall,
135 NdrVaryingArrayMarshall, NdrVaryingArrayMarshall,
136 NdrComplexArrayMarshall,
138 NdrConformantStringMarshall, 0, 0,
139 NdrConformantStringMarshall,
140 NdrNonConformantStringMarshall, 0, 0, 0,
142 NdrEncapsulatedUnionMarshall,
143 NdrNonEncapsulatedUnionMarshall,
145 NdrXmitOrRepAsMarshall, NdrXmitOrRepAsMarshall,
147 NdrInterfacePointerMarshall,
150 NdrUserMarshalMarshall
152 const NDR_UNMARSHALL NdrUnmarshaller[NDR_TABLE_SIZE] = {
154 NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
155 NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
156 NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
157 NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall, NdrBaseTypeUnmarshall,
159 NdrBaseTypeUnmarshall,
161 NdrPointerUnmarshall, NdrPointerUnmarshall,
162 NdrPointerUnmarshall, NdrPointerUnmarshall,
164 NdrSimpleStructUnmarshall, NdrSimpleStructUnmarshall,
165 NdrConformantStructUnmarshall, NdrConformantStructUnmarshall,
166 NdrConformantVaryingStructUnmarshall,
167 NdrComplexStructUnmarshall,
169 NdrConformantArrayUnmarshall,
170 NdrConformantVaryingArrayUnmarshall,
171 NdrFixedArrayUnmarshall, NdrFixedArrayUnmarshall,
172 NdrVaryingArrayUnmarshall, NdrVaryingArrayUnmarshall,
173 NdrComplexArrayUnmarshall,
175 NdrConformantStringUnmarshall, 0, 0,
176 NdrConformantStringUnmarshall,
177 NdrNonConformantStringUnmarshall, 0, 0, 0,
179 NdrEncapsulatedUnionUnmarshall,
180 NdrNonEncapsulatedUnionUnmarshall,
182 NdrXmitOrRepAsUnmarshall, NdrXmitOrRepAsUnmarshall,
184 NdrInterfacePointerUnmarshall,
187 NdrUserMarshalUnmarshall
189 const NDR_BUFFERSIZE NdrBufferSizer[NDR_TABLE_SIZE] = {
191 NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
192 NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
193 NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
194 NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize, NdrBaseTypeBufferSize,
196 NdrBaseTypeBufferSize,
198 NdrPointerBufferSize, NdrPointerBufferSize,
199 NdrPointerBufferSize, NdrPointerBufferSize,
201 NdrSimpleStructBufferSize, NdrSimpleStructBufferSize,
202 NdrConformantStructBufferSize, NdrConformantStructBufferSize,
203 NdrConformantVaryingStructBufferSize,
204 NdrComplexStructBufferSize,
206 NdrConformantArrayBufferSize,
207 NdrConformantVaryingArrayBufferSize,
208 NdrFixedArrayBufferSize, NdrFixedArrayBufferSize,
209 NdrVaryingArrayBufferSize, NdrVaryingArrayBufferSize,
210 NdrComplexArrayBufferSize,
212 NdrConformantStringBufferSize, 0, 0,
213 NdrConformantStringBufferSize,
214 NdrNonConformantStringBufferSize, 0, 0, 0,
216 NdrEncapsulatedUnionBufferSize,
217 NdrNonEncapsulatedUnionBufferSize,
219 NdrXmitOrRepAsBufferSize, NdrXmitOrRepAsBufferSize,
221 NdrInterfacePointerBufferSize,
224 NdrUserMarshalBufferSize
226 const NDR_MEMORYSIZE NdrMemorySizer[NDR_TABLE_SIZE] = {
228 NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
229 NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
230 NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
231 NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize, NdrBaseTypeMemorySize,
233 NdrBaseTypeMemorySize,
235 NdrPointerMemorySize, NdrPointerMemorySize,
236 NdrPointerMemorySize, NdrPointerMemorySize,
238 NdrSimpleStructMemorySize, NdrSimpleStructMemorySize,
240 NdrComplexStructMemorySize,
242 NdrConformantArrayMemorySize, 0, 0, 0, 0, 0,
243 NdrComplexArrayMemorySize,
245 NdrConformantStringMemorySize, 0, 0,
246 NdrConformantStringMemorySize,
247 NdrNonConformantStringMemorySize, 0, 0, 0,
251 NdrInterfacePointerMemorySize,
254 NdrUserMarshalMemorySize
256 const NDR_FREE NdrFreer[NDR_TABLE_SIZE] = {
258 NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
259 NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
260 NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
261 NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree, NdrBaseTypeFree,
265 NdrPointerFree, NdrPointerFree,
266 NdrPointerFree, NdrPointerFree,
268 NdrSimpleStructFree, NdrSimpleStructFree,
269 NdrConformantStructFree, NdrConformantStructFree,
270 NdrConformantVaryingStructFree,
271 NdrComplexStructFree,
273 NdrConformantArrayFree,
274 NdrConformantVaryingArrayFree,
275 NdrFixedArrayFree, NdrFixedArrayFree,
276 NdrVaryingArrayFree, NdrVaryingArrayFree,
282 NdrEncapsulatedUnionFree,
283 NdrNonEncapsulatedUnionFree,
285 NdrXmitOrRepAsFree, NdrXmitOrRepAsFree,
287 NdrInterfacePointerFree,
293 void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, size_t len)
295 /* hmm, this is probably supposed to do more? */
296 return pStubMsg->pfnAllocate(len);
299 static void WINAPI NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
301 pStubMsg->pfnFree(Pointer);
304 static inline BOOL IsConformanceOrVariancePresent(PFORMAT_STRING pFormat)
306 return (*(const ULONG *)pFormat != -1);
309 PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
311 pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
312 pStubMsg->Buffer += 4;
313 TRACE("unmarshalled conformance is %ld\n", pStubMsg->MaxCount);
314 if (pStubMsg->fHasNewCorrDesc)
320 static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
322 if (!IsConformanceOrVariancePresent(pFormat))
324 pStubMsg->Offset = 0;
325 pStubMsg->ActualCount = pStubMsg->MaxCount;
329 pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
330 pStubMsg->Buffer += 4;
331 TRACE("offset is %ld\n", pStubMsg->Offset);
332 pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
333 pStubMsg->Buffer += 4;
334 TRACE("variance is %ld\n", pStubMsg->ActualCount);
337 if (pStubMsg->fHasNewCorrDesc)
343 /* writes the conformance value to the buffer */
344 static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
346 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->MaxCount);
347 pStubMsg->Buffer += 4;
350 /* writes the variance values to the buffer */
351 static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
353 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->Offset);
354 pStubMsg->Buffer += 4;
355 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->ActualCount);
356 pStubMsg->Buffer += 4;
359 /* requests buffer space for the conformance value */
360 static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
362 pStubMsg->BufferLength += 4;
365 /* requests buffer space for the variance values */
366 static inline void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
368 pStubMsg->BufferLength += 8;
371 PFORMAT_STRING ComputeConformanceOrVariance(
372 MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
373 PFORMAT_STRING pFormat, ULONG_PTR def, ULONG *pCount)
375 BYTE dtype = pFormat[0] & 0xf;
376 short ofs = *(short *)&pFormat[2];
380 if (!IsConformanceOrVariancePresent(pFormat)) {
381 /* null descriptor */
386 switch (pFormat[0] & 0xf0) {
387 case RPC_FC_NORMAL_CONFORMANCE:
388 TRACE("normal conformance, ofs=%d\n", ofs);
391 case RPC_FC_POINTER_CONFORMANCE:
392 TRACE("pointer conformance, ofs=%d\n", ofs);
393 ptr = pStubMsg->Memory;
395 case RPC_FC_TOP_LEVEL_CONFORMANCE:
396 TRACE("toplevel conformance, ofs=%d\n", ofs);
397 if (pStubMsg->StackTop) {
398 ptr = pStubMsg->StackTop;
401 /* -Os mode, *pCount is already set */
405 case RPC_FC_CONSTANT_CONFORMANCE:
406 data = ofs | ((DWORD)pFormat[1] << 16);
407 TRACE("constant conformance, val=%ld\n", data);
410 case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE:
411 FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
412 if (pStubMsg->StackTop) {
413 ptr = pStubMsg->StackTop;
421 FIXME("unknown conformance type %x\n", pFormat[0] & 0xf0);
424 switch (pFormat[1]) {
425 case RPC_FC_DEREFERENCE:
426 ptr = *(LPVOID*)((char *)ptr + ofs);
428 case RPC_FC_CALLBACK:
430 unsigned char *old_stack_top = pStubMsg->StackTop;
431 pStubMsg->StackTop = ptr;
433 /* ofs is index into StubDesc->apfnExprEval */
434 TRACE("callback conformance into apfnExprEval[%d]\n", ofs);
435 pStubMsg->StubDesc->apfnExprEval[ofs](pStubMsg);
437 pStubMsg->StackTop = old_stack_top;
441 ptr = (char *)ptr + ofs;
454 data = *(USHORT*)ptr;
463 FIXME("unknown conformance data type %x\n", dtype);
466 TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
469 switch (pFormat[1]) {
473 case RPC_FC_DEREFERENCE:
474 /* already handled */
477 FIXME("unknown conformance op %d\n", pFormat[1]);
482 TRACE("resulting conformance is %ld\n", *pCount);
483 if (pStubMsg->fHasNewCorrDesc)
491 * NdrConformantString:
493 * What MS calls a ConformantString is, in DCE terminology,
494 * a Varying-Conformant String.
496 * maxlen: DWORD (max # of CHARTYPE characters, inclusive of '\0')
497 * offset: DWORD (actual string data begins at (offset) CHARTYPE's
498 * into unmarshalled string)
499 * length: DWORD (# of CHARTYPE characters, inclusive of '\0')
501 * data: CHARTYPE[maxlen]
503 * ], where CHARTYPE is the appropriate character type (specified externally)
507 /***********************************************************************
508 * NdrConformantStringMarshall [RPCRT4.@]
510 unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg,
511 unsigned char *pszMessage, PFORMAT_STRING pFormat)
513 unsigned long len, esize;
515 TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
518 if (*pFormat == RPC_FC_C_CSTRING) {
519 TRACE("string=%s\n", debugstr_a((char*)pszMessage));
520 len = strlen((char*)pszMessage)+1;
523 else if (*pFormat == RPC_FC_C_WSTRING) {
524 TRACE("string=%s\n", debugstr_w((LPWSTR)pszMessage));
525 len = strlenW((LPWSTR)pszMessage)+1;
529 ERR("Unhandled string type: %#x\n", *pFormat);
530 /* FIXME: raise an exception. */
534 if (pFormat[1] != RPC_FC_PAD) {
535 FIXME("sized string format=%d\n", pFormat[1]);
538 assert( (pStubMsg->BufferLength >= (len*esize + 13)) && (pStubMsg->Buffer != NULL) );
540 pStubMsg->MaxCount = pStubMsg->ActualCount = len;
541 pStubMsg->Offset = 0;
542 WriteConformance(pStubMsg);
543 WriteVariance(pStubMsg);
545 memcpy(pStubMsg->Buffer, pszMessage, len*esize); /* the string itself */
546 pStubMsg->Buffer += len*esize;
548 STD_OVERFLOW_CHECK(pStubMsg);
551 return NULL; /* is this always right? */
554 /***********************************************************************
555 * NdrConformantStringBufferSize [RPCRT4.@]
557 void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
558 unsigned char* pMemory, PFORMAT_STRING pFormat)
560 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
562 SizeConformance(pStubMsg);
563 SizeVariance(pStubMsg);
566 if (*pFormat == RPC_FC_C_CSTRING) {
567 /* we need + 1 octet for '\0' */
568 TRACE("string=%s\n", debugstr_a((char*)pMemory));
569 pStubMsg->BufferLength += strlen((char*)pMemory) + 1 + BUFFER_PARANOIA;
571 else if (*pFormat == RPC_FC_C_WSTRING) {
572 /* we need + 2 octets for L'\0' */
573 TRACE("string=%s\n", debugstr_w((LPWSTR)pMemory));
574 pStubMsg->BufferLength += strlenW((LPWSTR)pMemory)*2 + 2 + BUFFER_PARANOIA;
577 ERR("Unhandled string type: %#x\n", *pFormat);
578 /* FIXME: raise an exception */
581 if (pFormat[1] != RPC_FC_PAD) {
582 FIXME("sized string format=%d\n", pFormat[1]);
586 /************************************************************************
587 * NdrConformantStringMemorySize [RPCRT4.@]
589 unsigned long WINAPI NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
590 PFORMAT_STRING pFormat )
592 unsigned long rslt = 0;
594 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
596 assert(pStubMsg && pFormat);
598 if (*pFormat == RPC_FC_C_CSTRING) {
599 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); /* maxlen */
601 else if (*pFormat == RPC_FC_C_WSTRING) {
602 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer)*2; /* maxlen */
605 ERR("Unhandled string type: %#x\n", *pFormat);
606 /* FIXME: raise an exception */
609 if (pFormat[1] != RPC_FC_PAD) {
610 FIXME("sized string format=%d\n", pFormat[1]);
613 TRACE(" --> %lu\n", rslt);
617 /************************************************************************
618 * NdrConformantStringUnmarshall [RPCRT4.@]
620 unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
621 unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc )
623 unsigned long len, esize, ofs;
625 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
626 pStubMsg, *ppMemory, pFormat, fMustAlloc);
628 assert(pFormat && ppMemory && pStubMsg);
630 pStubMsg->Buffer += 4;
631 ofs = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
632 pStubMsg->Buffer += 4;
633 len = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
634 pStubMsg->Buffer += 4;
636 if (*pFormat == RPC_FC_C_CSTRING) esize = 1;
637 else if (*pFormat == RPC_FC_C_WSTRING) esize = 2;
639 ERR("Unhandled string type: %#x\n", *pFormat);
640 /* FIXME: raise an exception */
644 if (pFormat[1] != RPC_FC_PAD) {
645 FIXME("sized string format=%d\n", pFormat[1]);
648 if (fMustAlloc || !*ppMemory)
649 *ppMemory = NdrAllocate(pStubMsg, len*esize + BUFFER_PARANOIA);
651 memcpy(*ppMemory, pStubMsg->Buffer, len*esize);
653 pStubMsg->Buffer += len*esize;
655 if (*pFormat == RPC_FC_C_CSTRING) {
656 TRACE("string=%s\n", debugstr_a((char*)*ppMemory));
658 else if (*pFormat == RPC_FC_C_WSTRING) {
659 TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
662 return NULL; /* FIXME: is this always right? */
665 /***********************************************************************
666 * NdrNonConformantStringMarshall [RPCRT4.@]
668 unsigned char * WINAPI NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE pStubMsg,
669 unsigned char *pMemory,
670 PFORMAT_STRING pFormat)
676 /***********************************************************************
677 * NdrNonConformantStringUnmarshall [RPCRT4.@]
679 unsigned char * WINAPI NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
680 unsigned char **ppMemory,
681 PFORMAT_STRING pFormat,
682 unsigned char fMustAlloc)
688 /***********************************************************************
689 * NdrNonConformantStringBufferSize [RPCRT4.@]
691 void WINAPI NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
692 unsigned char *pMemory,
693 PFORMAT_STRING pFormat)
698 /***********************************************************************
699 * NdrNonConformantStringMemorySize [RPCRT4.@]
701 unsigned long WINAPI NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
702 PFORMAT_STRING pFormat)
708 static inline void dump_pointer_attr(unsigned char attr)
710 if (attr & RPC_FC_P_ALLOCALLNODES)
711 TRACE(" RPC_FC_P_ALLOCALLNODES");
712 if (attr & RPC_FC_P_DONTFREE)
713 TRACE(" RPC_FC_P_DONTFREE");
714 if (attr & RPC_FC_P_ONSTACK)
715 TRACE(" RPC_FC_P_ONSTACK");
716 if (attr & RPC_FC_P_SIMPLEPOINTER)
717 TRACE(" RPC_FC_P_SIMPLEPOINTER");
718 if (attr & RPC_FC_P_DEREF)
719 TRACE(" RPC_FC_P_DEREF");
723 /***********************************************************************
726 void WINAPI PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
727 unsigned char *Buffer,
728 unsigned char *Pointer,
729 PFORMAT_STRING pFormat)
731 unsigned type = pFormat[0], attr = pFormat[1];
735 TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
736 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
738 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
739 else desc = pFormat + *(const SHORT*)pFormat;
742 case RPC_FC_RP: /* ref pointer (always non-null) */
743 #if 0 /* this causes problems for InstallShield so is disabled - we need more tests */
745 RpcRaiseException(RPC_X_NULL_REF_POINTER);
748 case RPC_FC_UP: /* unique pointer */
749 case RPC_FC_OP: /* object pointer - same as unique here */
750 TRACE("writing %p to buffer\n", Pointer);
751 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, (unsigned long)Pointer);
752 pStubMsg->Buffer += 4;
756 FIXME("unhandled ptr type=%02x\n", type);
757 RpcRaiseException(RPC_X_BAD_STUB_DATA);
760 TRACE("calling marshaller for type 0x%x\n", (int)*desc);
763 if (attr & RPC_FC_P_DEREF) {
764 Pointer = *(unsigned char**)Pointer;
765 TRACE("deref => %p\n", Pointer);
767 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
768 if (m) m(pStubMsg, Pointer, desc);
769 else FIXME("no marshaller for data type=%02x\n", *desc);
772 STD_OVERFLOW_CHECK(pStubMsg);
775 /***********************************************************************
778 void WINAPI PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
779 unsigned char *Buffer,
780 unsigned char **pPointer,
781 PFORMAT_STRING pFormat,
782 unsigned char fMustAlloc)
784 unsigned type = pFormat[0], attr = pFormat[1];
787 DWORD pointer_id = 0;
789 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pFormat, fMustAlloc);
790 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
792 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
793 else desc = pFormat + *(const SHORT*)pFormat;
796 case RPC_FC_RP: /* ref pointer (always non-null) */
799 case RPC_FC_UP: /* unique pointer */
800 pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
801 pStubMsg->Buffer += 4;
803 case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
804 pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
805 pStubMsg->Buffer += 4;
807 FIXME("free object pointer %p\n", *pPointer);
811 FIXME("unhandled ptr type=%02x\n", type);
812 RpcRaiseException(RPC_X_BAD_STUB_DATA);
816 if (attr & RPC_FC_P_DEREF) {
817 if (!*pPointer || fMustAlloc)
818 *pPointer = NdrAllocate(pStubMsg, sizeof(void *));
819 pPointer = *(unsigned char***)pPointer;
820 TRACE("deref => %p\n", pPointer);
822 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
823 if (m) m(pStubMsg, pPointer, desc, fMustAlloc);
824 else FIXME("no unmarshaller for data type=%02x\n", *desc);
827 TRACE("pointer=%p\n", *pPointer);
830 /***********************************************************************
833 void WINAPI PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
834 unsigned char *Pointer,
835 PFORMAT_STRING pFormat)
837 unsigned type = pFormat[0], attr = pFormat[1];
841 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
842 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
844 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
845 else desc = pFormat + *(const SHORT*)pFormat;
848 case RPC_FC_RP: /* ref pointer (always non-null) */
852 pStubMsg->BufferLength += 4;
853 /* NULL pointer has no further representation */
859 FIXME("unhandled ptr type=%02x\n", type);
860 RpcRaiseException(RPC_X_BAD_STUB_DATA);
863 if (attr & RPC_FC_P_DEREF) {
864 Pointer = *(unsigned char**)Pointer;
865 TRACE("deref => %p\n", Pointer);
868 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
869 if (m) m(pStubMsg, Pointer, desc);
870 else FIXME("no buffersizer for data type=%02x\n", *desc);
873 /***********************************************************************
874 * PointerMemorySize [RPCRT4.@]
876 unsigned long WINAPI PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
877 unsigned char *Buffer,
878 PFORMAT_STRING pFormat)
880 unsigned type = pFormat[0], attr = pFormat[1];
884 FIXME("(%p,%p,%p): stub\n", pStubMsg, Buffer, pFormat);
885 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
887 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
888 else desc = pFormat + *(const SHORT*)pFormat;
891 case RPC_FC_RP: /* ref pointer (always non-null) */
894 FIXME("unhandled ptr type=%02x\n", type);
895 RpcRaiseException(RPC_X_BAD_STUB_DATA);
898 if (attr & RPC_FC_P_DEREF) {
902 m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
903 if (m) m(pStubMsg, desc);
904 else FIXME("no memorysizer for data type=%02x\n", *desc);
909 /***********************************************************************
910 * PointerFree [RPCRT4.@]
912 void WINAPI PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
913 unsigned char *Pointer,
914 PFORMAT_STRING pFormat)
916 unsigned type = pFormat[0], attr = pFormat[1];
920 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
921 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
922 if (attr & RPC_FC_P_DONTFREE) return;
924 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
925 else desc = pFormat + *(const SHORT*)pFormat;
927 if (!Pointer) return;
929 if (attr & RPC_FC_P_DEREF) {
930 Pointer = *(unsigned char**)Pointer;
931 TRACE("deref => %p\n", Pointer);
934 m = NdrFreer[*desc & NDR_TABLE_MASK];
935 if (m) m(pStubMsg, Pointer, desc);
937 /* hmm... is this sensible?
938 * perhaps we should check if the memory comes from NdrAllocate,
939 * and deallocate only if so - checking if the pointer is between
940 * BufferStart and BufferEnd is probably no good since the buffer
941 * may be reallocated when the server wants to marshal the reply */
943 case RPC_FC_BOGUS_STRUCT:
944 case RPC_FC_BOGUS_ARRAY:
945 case RPC_FC_USER_MARSHAL:
950 FIXME("unhandled data type=%02x\n", *desc);
952 case RPC_FC_C_CSTRING:
953 case RPC_FC_C_WSTRING:
954 if (pStubMsg->ReuseBuffer) goto notfree;
960 if (attr & RPC_FC_P_ONSTACK) {
961 TRACE("not freeing stack ptr %p\n", Pointer);
964 TRACE("freeing %p\n", Pointer);
965 NdrFree(pStubMsg, Pointer);
968 TRACE("not freeing %p\n", Pointer);
971 /***********************************************************************
972 * EmbeddedPointerMarshall
974 unsigned char * WINAPI EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
975 unsigned char *pMemory,
976 PFORMAT_STRING pFormat)
978 unsigned char *Mark = pStubMsg->BufferMark;
979 unsigned long Offset = pStubMsg->Offset;
980 unsigned ofs, rep, count, stride, xofs;
982 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
984 if (*pFormat != RPC_FC_PP) return NULL;
987 while (pFormat[0] != RPC_FC_END) {
988 switch (pFormat[0]) {
990 FIXME("unknown repeat type %d\n", pFormat[0]);
991 case RPC_FC_NO_REPEAT:
999 case RPC_FC_FIXED_REPEAT:
1000 rep = *(const WORD*)&pFormat[2];
1001 stride = *(const WORD*)&pFormat[4];
1002 ofs = *(const WORD*)&pFormat[6];
1003 count = *(const WORD*)&pFormat[8];
1007 case RPC_FC_VARIABLE_REPEAT:
1008 rep = pStubMsg->MaxCount;
1009 stride = *(const WORD*)&pFormat[2];
1010 ofs = *(const WORD*)&pFormat[4];
1011 count = *(const WORD*)&pFormat[6];
1012 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1016 /* ofs doesn't seem to matter in this context */
1018 PFORMAT_STRING info = pFormat;
1019 unsigned char *membase = pMemory + xofs;
1021 for (u=0; u<count; u++,info+=8) {
1022 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1023 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1024 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
1028 pFormat += 8 * count;
1031 STD_OVERFLOW_CHECK(pStubMsg);
1036 /***********************************************************************
1037 * EmbeddedPointerUnmarshall
1039 unsigned char * WINAPI EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1040 unsigned char **ppMemory,
1041 PFORMAT_STRING pFormat,
1042 unsigned char fMustAlloc)
1044 unsigned char *Mark = pStubMsg->BufferMark;
1045 unsigned long Offset = pStubMsg->Offset;
1046 unsigned ofs, rep, count, stride, xofs;
1048 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1050 if (*pFormat != RPC_FC_PP) return NULL;
1053 while (pFormat[0] != RPC_FC_END) {
1054 switch (pFormat[0]) {
1056 FIXME("unknown repeat type %d\n", pFormat[0]);
1057 case RPC_FC_NO_REPEAT:
1065 case RPC_FC_FIXED_REPEAT:
1066 rep = *(const WORD*)&pFormat[2];
1067 stride = *(const WORD*)&pFormat[4];
1068 ofs = *(const WORD*)&pFormat[6];
1069 count = *(const WORD*)&pFormat[8];
1073 case RPC_FC_VARIABLE_REPEAT:
1074 rep = pStubMsg->MaxCount;
1075 stride = *(const WORD*)&pFormat[2];
1076 ofs = *(const WORD*)&pFormat[4];
1077 count = *(const WORD*)&pFormat[6];
1078 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1082 /* ofs doesn't seem to matter in this context */
1084 PFORMAT_STRING info = pFormat;
1085 unsigned char *membase = *ppMemory + xofs;
1087 for (u=0; u<count; u++,info+=8) {
1088 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1089 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1090 PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
1094 pFormat += 8 * count;
1100 /***********************************************************************
1101 * EmbeddedPointerBufferSize
1103 void WINAPI EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1104 unsigned char *pMemory,
1105 PFORMAT_STRING pFormat)
1107 unsigned long Offset = pStubMsg->Offset;
1108 unsigned ofs, rep, count, stride, xofs;
1110 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1111 if (*pFormat != RPC_FC_PP) return;
1114 while (pFormat[0] != RPC_FC_END) {
1115 switch (pFormat[0]) {
1117 FIXME("unknown repeat type %d\n", pFormat[0]);
1118 case RPC_FC_NO_REPEAT:
1126 case RPC_FC_FIXED_REPEAT:
1127 rep = *(const WORD*)&pFormat[2];
1128 stride = *(const WORD*)&pFormat[4];
1129 ofs = *(const WORD*)&pFormat[6];
1130 count = *(const WORD*)&pFormat[8];
1134 case RPC_FC_VARIABLE_REPEAT:
1135 rep = pStubMsg->MaxCount;
1136 stride = *(const WORD*)&pFormat[2];
1137 ofs = *(const WORD*)&pFormat[4];
1138 count = *(const WORD*)&pFormat[6];
1139 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1143 /* ofs doesn't seem to matter in this context */
1145 PFORMAT_STRING info = pFormat;
1146 unsigned char *membase = pMemory + xofs;
1148 for (u=0; u<count; u++,info+=8) {
1149 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1150 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1154 pFormat += 8 * count;
1158 /***********************************************************************
1159 * EmbeddedPointerMemorySize
1161 unsigned long WINAPI EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1162 PFORMAT_STRING pFormat)
1164 unsigned long Offset = pStubMsg->Offset;
1165 unsigned char *Mark = pStubMsg->BufferMark;
1166 unsigned ofs, rep, count, stride, xofs;
1168 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1169 if (*pFormat != RPC_FC_PP) return 0;
1172 while (pFormat[0] != RPC_FC_END) {
1173 switch (pFormat[0]) {
1175 FIXME("unknown repeat type %d\n", pFormat[0]);
1176 case RPC_FC_NO_REPEAT:
1184 case RPC_FC_FIXED_REPEAT:
1185 rep = *(const WORD*)&pFormat[2];
1186 stride = *(const WORD*)&pFormat[4];
1187 ofs = *(const WORD*)&pFormat[6];
1188 count = *(const WORD*)&pFormat[8];
1192 case RPC_FC_VARIABLE_REPEAT:
1193 rep = pStubMsg->MaxCount;
1194 stride = *(const WORD*)&pFormat[2];
1195 ofs = *(const WORD*)&pFormat[4];
1196 count = *(const WORD*)&pFormat[6];
1197 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1201 /* ofs doesn't seem to matter in this context */
1203 PFORMAT_STRING info = pFormat;
1205 for (u=0; u<count; u++,info+=8) {
1206 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1207 PointerMemorySize(pStubMsg, bufptr, info+4);
1211 pFormat += 8 * count;
1217 /***********************************************************************
1218 * EmbeddedPointerFree
1220 void WINAPI EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1221 unsigned char *pMemory,
1222 PFORMAT_STRING pFormat)
1224 unsigned long Offset = pStubMsg->Offset;
1225 unsigned ofs, rep, count, stride, xofs;
1227 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1228 if (*pFormat != RPC_FC_PP) return;
1231 while (pFormat[0] != RPC_FC_END) {
1232 switch (pFormat[0]) {
1234 FIXME("unknown repeat type %d\n", pFormat[0]);
1235 case RPC_FC_NO_REPEAT:
1243 case RPC_FC_FIXED_REPEAT:
1244 rep = *(const WORD*)&pFormat[2];
1245 stride = *(const WORD*)&pFormat[4];
1246 ofs = *(const WORD*)&pFormat[6];
1247 count = *(const WORD*)&pFormat[8];
1251 case RPC_FC_VARIABLE_REPEAT:
1252 rep = pStubMsg->MaxCount;
1253 stride = *(const WORD*)&pFormat[2];
1254 ofs = *(const WORD*)&pFormat[4];
1255 count = *(const WORD*)&pFormat[6];
1256 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1260 /* ofs doesn't seem to matter in this context */
1262 PFORMAT_STRING info = pFormat;
1263 unsigned char *membase = pMemory + xofs;
1265 for (u=0; u<count; u++,info+=8) {
1266 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1267 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1271 pFormat += 8 * count;
1275 /***********************************************************************
1276 * NdrPointerMarshall [RPCRT4.@]
1278 unsigned char * WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1279 unsigned char *pMemory,
1280 PFORMAT_STRING pFormat)
1282 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1284 pStubMsg->BufferMark = pStubMsg->Buffer;
1285 PointerMarshall(pStubMsg, pStubMsg->Buffer, pMemory, pFormat);
1287 STD_OVERFLOW_CHECK(pStubMsg);
1292 /***********************************************************************
1293 * NdrPointerUnmarshall [RPCRT4.@]
1295 unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1296 unsigned char **ppMemory,
1297 PFORMAT_STRING pFormat,
1298 unsigned char fMustAlloc)
1300 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1302 pStubMsg->BufferMark = pStubMsg->Buffer;
1303 PointerUnmarshall(pStubMsg, pStubMsg->Buffer, ppMemory, pFormat, fMustAlloc);
1308 /***********************************************************************
1309 * NdrPointerBufferSize [RPCRT4.@]
1311 void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1312 unsigned char *pMemory,
1313 PFORMAT_STRING pFormat)
1315 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1316 PointerBufferSize(pStubMsg, pMemory, pFormat);
1319 /***********************************************************************
1320 * NdrPointerMemorySize [RPCRT4.@]
1322 unsigned long WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1323 PFORMAT_STRING pFormat)
1325 /* unsigned size = *(LPWORD)(pFormat+2); */
1326 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1327 PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat);
1331 /***********************************************************************
1332 * NdrPointerFree [RPCRT4.@]
1334 void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1335 unsigned char *pMemory,
1336 PFORMAT_STRING pFormat)
1338 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1339 PointerFree(pStubMsg, pMemory, pFormat);
1342 /***********************************************************************
1343 * NdrSimpleStructMarshall [RPCRT4.@]
1345 unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1346 unsigned char *pMemory,
1347 PFORMAT_STRING pFormat)
1349 unsigned size = *(const WORD*)(pFormat+2);
1350 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1352 ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
1354 memcpy(pStubMsg->Buffer, pMemory, size);
1355 pStubMsg->BufferMark = pStubMsg->Buffer;
1356 pStubMsg->Buffer += size;
1358 if (pFormat[0] != RPC_FC_STRUCT)
1359 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
1361 STD_OVERFLOW_CHECK(pStubMsg);
1366 /***********************************************************************
1367 * NdrSimpleStructUnmarshall [RPCRT4.@]
1369 unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1370 unsigned char **ppMemory,
1371 PFORMAT_STRING pFormat,
1372 unsigned char fMustAlloc)
1374 unsigned size = *(const WORD*)(pFormat+2);
1375 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1377 ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
1380 *ppMemory = NdrAllocate(pStubMsg, size);
1381 memcpy(*ppMemory, pStubMsg->Buffer, size);
1383 if (pStubMsg->ReuseBuffer && !*ppMemory)
1384 /* for servers, we may just point straight into the RPC buffer, I think
1385 * (I guess that's what MS does since MIDL code doesn't try to free) */
1386 *ppMemory = pStubMsg->Buffer;
1388 /* for clients, memory should be provided by caller */
1389 memcpy(*ppMemory, pStubMsg->Buffer, size);
1392 pStubMsg->BufferMark = pStubMsg->Buffer;
1393 pStubMsg->Buffer += size;
1395 if (pFormat[0] != RPC_FC_STRUCT)
1396 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat+4, fMustAlloc);
1402 /***********************************************************************
1403 * NdrSimpleStructUnmarshall [RPCRT4.@]
1405 void WINAPI NdrSimpleTypeMarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
1406 unsigned char FormatChar )
1412 /***********************************************************************
1413 * NdrSimpleStructUnmarshall [RPCRT4.@]
1415 void WINAPI NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
1416 unsigned char FormatChar )
1422 /***********************************************************************
1423 * NdrSimpleStructBufferSize [RPCRT4.@]
1425 void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1426 unsigned char *pMemory,
1427 PFORMAT_STRING pFormat)
1429 unsigned size = *(const WORD*)(pFormat+2);
1430 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1432 ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
1434 pStubMsg->BufferLength += size;
1435 if (pFormat[0] != RPC_FC_STRUCT)
1436 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
1439 /***********************************************************************
1440 * NdrSimpleStructMemorySize [RPCRT4.@]
1442 unsigned long WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1443 PFORMAT_STRING pFormat)
1445 /* unsigned size = *(LPWORD)(pFormat+2); */
1446 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1447 if (pFormat[0] != RPC_FC_STRUCT)
1448 EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
1452 /***********************************************************************
1453 * NdrSimpleStructFree [RPCRT4.@]
1455 void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1456 unsigned char *pMemory,
1457 PFORMAT_STRING pFormat)
1459 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1460 if (pFormat[0] != RPC_FC_STRUCT)
1461 EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
1465 unsigned long WINAPI EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg,
1466 PFORMAT_STRING pFormat)
1470 case RPC_FC_PSTRUCT:
1471 case RPC_FC_CSTRUCT:
1472 case RPC_FC_BOGUS_STRUCT:
1473 return *(const WORD*)&pFormat[2];
1474 case RPC_FC_USER_MARSHAL:
1475 return *(const WORD*)&pFormat[4];
1476 case RPC_FC_NON_ENCAPSULATED_UNION:
1477 return NdrNonEncapsulatedUnionMemorySize(pStubMsg, pFormat);
1479 FIXME("unhandled embedded type %02x\n", *pFormat);
1485 unsigned char * WINAPI ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1486 unsigned char *pMemory,
1487 PFORMAT_STRING pFormat,
1488 PFORMAT_STRING pPointer)
1490 PFORMAT_STRING desc;
1494 while (*pFormat != RPC_FC_END) {
1498 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
1499 memcpy(pStubMsg->Buffer, pMemory, 2);
1500 pStubMsg->Buffer += 2;
1506 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
1507 memcpy(pStubMsg->Buffer, pMemory, 4);
1508 pStubMsg->Buffer += 4;
1511 case RPC_FC_POINTER:
1512 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
1513 NdrPointerMarshall(pStubMsg, *(unsigned char**)pMemory, pPointer);
1517 case RPC_FC_ALIGNM4:
1518 ALIGN_POINTER(pMemory, 4);
1520 case RPC_FC_ALIGNM8:
1521 ALIGN_POINTER(pMemory, 8);
1523 case RPC_FC_STRUCTPAD2:
1526 case RPC_FC_EMBEDDED_COMPLEX:
1527 pMemory += pFormat[1];
1529 desc = pFormat + *(const SHORT*)pFormat;
1530 size = EmbeddedComplexSize(pStubMsg, desc);
1531 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
1532 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
1533 if (m) m(pStubMsg, pMemory, desc);
1534 else FIXME("no marshaller for embedded type %02x\n", *desc);
1541 FIXME("unhandled format %02x\n", *pFormat);
1549 unsigned char * WINAPI ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1550 unsigned char *pMemory,
1551 PFORMAT_STRING pFormat,
1552 PFORMAT_STRING pPointer,
1553 unsigned char fMustAlloc)
1555 PFORMAT_STRING desc;
1559 while (*pFormat != RPC_FC_END) {
1563 memcpy(pMemory, pStubMsg->Buffer, 2);
1564 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
1565 pStubMsg->Buffer += 2;
1571 memcpy(pMemory, pStubMsg->Buffer, 4);
1572 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
1573 pStubMsg->Buffer += 4;
1576 case RPC_FC_POINTER:
1577 *(unsigned char**)pMemory = NULL;
1578 TRACE("pointer => %p\n", pMemory);
1579 NdrPointerUnmarshall(pStubMsg, (unsigned char**)pMemory, pPointer, fMustAlloc);
1583 case RPC_FC_ALIGNM4:
1584 ALIGN_POINTER(pMemory, 4);
1586 case RPC_FC_ALIGNM8:
1587 ALIGN_POINTER(pMemory, 8);
1589 case RPC_FC_STRUCTPAD2:
1592 case RPC_FC_EMBEDDED_COMPLEX:
1593 pMemory += pFormat[1];
1595 desc = pFormat + *(const SHORT*)pFormat;
1596 size = EmbeddedComplexSize(pStubMsg, desc);
1597 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
1598 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
1599 memset(pMemory, 0, size); /* just in case */
1600 if (m) m(pStubMsg, &pMemory, desc, fMustAlloc);
1601 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
1608 FIXME("unhandled format %d\n", *pFormat);
1616 unsigned char * WINAPI ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1617 unsigned char *pMemory,
1618 PFORMAT_STRING pFormat,
1619 PFORMAT_STRING pPointer)
1621 PFORMAT_STRING desc;
1625 while (*pFormat != RPC_FC_END) {
1629 pStubMsg->BufferLength += 2;
1635 pStubMsg->BufferLength += 4;
1638 case RPC_FC_POINTER:
1639 NdrPointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
1643 case RPC_FC_ALIGNM4:
1644 ALIGN_POINTER(pMemory, 4);
1646 case RPC_FC_ALIGNM8:
1647 ALIGN_POINTER(pMemory, 8);
1649 case RPC_FC_STRUCTPAD2:
1652 case RPC_FC_EMBEDDED_COMPLEX:
1653 pMemory += pFormat[1];
1655 desc = pFormat + *(const SHORT*)pFormat;
1656 size = EmbeddedComplexSize(pStubMsg, desc);
1657 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
1658 if (m) m(pStubMsg, pMemory, desc);
1659 else FIXME("no buffersizer for embedded type %02x\n", *desc);
1666 FIXME("unhandled format %d\n", *pFormat);
1674 unsigned char * WINAPI ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
1675 unsigned char *pMemory,
1676 PFORMAT_STRING pFormat,
1677 PFORMAT_STRING pPointer)
1679 PFORMAT_STRING desc;
1683 while (*pFormat != RPC_FC_END) {
1694 case RPC_FC_POINTER:
1695 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
1699 case RPC_FC_ALIGNM4:
1700 ALIGN_POINTER(pMemory, 4);
1702 case RPC_FC_ALIGNM8:
1703 ALIGN_POINTER(pMemory, 8);
1705 case RPC_FC_STRUCTPAD2:
1708 case RPC_FC_EMBEDDED_COMPLEX:
1709 pMemory += pFormat[1];
1711 desc = pFormat + *(const SHORT*)pFormat;
1712 size = EmbeddedComplexSize(pStubMsg, desc);
1713 m = NdrFreer[*desc & NDR_TABLE_MASK];
1714 if (m) m(pStubMsg, pMemory, desc);
1715 else FIXME("no freer for embedded type %02x\n", *desc);
1722 FIXME("unhandled format %d\n", *pFormat);
1730 unsigned long WINAPI ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg,
1731 PFORMAT_STRING pFormat)
1733 PFORMAT_STRING desc;
1734 unsigned long size = 0;
1736 while (*pFormat != RPC_FC_END) {
1746 case RPC_FC_POINTER:
1749 case RPC_FC_ALIGNM4:
1750 ALIGN_LENGTH(size, 4);
1752 case RPC_FC_ALIGNM8:
1753 ALIGN_LENGTH(size, 8);
1755 case RPC_FC_STRUCTPAD2:
1758 case RPC_FC_EMBEDDED_COMPLEX:
1761 desc = pFormat + *(const SHORT*)pFormat;
1762 size += EmbeddedComplexSize(pStubMsg, desc);
1768 FIXME("unhandled format %d\n", *pFormat);
1776 /***********************************************************************
1777 * NdrComplexStructMarshall [RPCRT4.@]
1779 unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1780 unsigned char *pMemory,
1781 PFORMAT_STRING pFormat)
1783 PFORMAT_STRING conf_array = NULL;
1784 PFORMAT_STRING pointer_desc = NULL;
1785 unsigned char *OldMemory = pStubMsg->Memory;
1787 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1789 ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
1792 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1794 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1797 pStubMsg->Memory = pMemory;
1799 ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
1802 NdrConformantArrayMarshall(pStubMsg, pMemory, conf_array);
1804 pStubMsg->Memory = OldMemory;
1806 STD_OVERFLOW_CHECK(pStubMsg);
1811 /***********************************************************************
1812 * NdrComplexStructUnmarshall [RPCRT4.@]
1814 unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1815 unsigned char **ppMemory,
1816 PFORMAT_STRING pFormat,
1817 unsigned char fMustAlloc)
1819 unsigned size = *(const WORD*)(pFormat+2);
1820 PFORMAT_STRING conf_array = NULL;
1821 PFORMAT_STRING pointer_desc = NULL;
1822 unsigned char *pMemory;
1824 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1826 ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
1828 if (fMustAlloc || !*ppMemory)
1830 *ppMemory = NdrAllocate(pStubMsg, size);
1831 memset(*ppMemory, 0, size);
1835 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1837 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1840 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
1843 NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
1848 /***********************************************************************
1849 * NdrComplexStructBufferSize [RPCRT4.@]
1851 void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1852 unsigned char *pMemory,
1853 PFORMAT_STRING pFormat)
1855 PFORMAT_STRING conf_array = NULL;
1856 PFORMAT_STRING pointer_desc = NULL;
1857 unsigned char *OldMemory = pStubMsg->Memory;
1859 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1861 ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
1864 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1866 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1869 pStubMsg->Memory = pMemory;
1871 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
1874 NdrConformantArrayBufferSize(pStubMsg, pMemory, conf_array);
1876 pStubMsg->Memory = OldMemory;
1879 /***********************************************************************
1880 * NdrComplexStructMemorySize [RPCRT4.@]
1882 unsigned long WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1883 PFORMAT_STRING pFormat)
1885 /* unsigned size = *(LPWORD)(pFormat+2); */
1886 PFORMAT_STRING conf_array = NULL;
1887 PFORMAT_STRING pointer_desc = NULL;
1889 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1892 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1894 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1900 /***********************************************************************
1901 * NdrComplexStructFree [RPCRT4.@]
1903 void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1904 unsigned char *pMemory,
1905 PFORMAT_STRING pFormat)
1907 PFORMAT_STRING conf_array = NULL;
1908 PFORMAT_STRING pointer_desc = NULL;
1909 unsigned char *OldMemory = pStubMsg->Memory;
1911 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1914 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1916 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1919 pStubMsg->Memory = pMemory;
1921 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
1924 NdrConformantArrayFree(pStubMsg, pMemory, conf_array);
1926 pStubMsg->Memory = OldMemory;
1929 /***********************************************************************
1930 * NdrConformantArrayMarshall [RPCRT4.@]
1932 unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1933 unsigned char *pMemory,
1934 PFORMAT_STRING pFormat)
1936 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1937 unsigned char alignment = pFormat[1] + 1;
1939 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1940 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1942 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1943 size = pStubMsg->MaxCount;
1945 WriteConformance(pStubMsg);
1947 ALIGN_POINTER(pStubMsg->Buffer, alignment);
1949 memcpy(pStubMsg->Buffer, pMemory, size*esize);
1950 pStubMsg->BufferMark = pStubMsg->Buffer;
1951 pStubMsg->Buffer += size*esize;
1953 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
1955 STD_OVERFLOW_CHECK(pStubMsg);
1960 /***********************************************************************
1961 * NdrConformantArrayUnmarshall [RPCRT4.@]
1963 unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1964 unsigned char **ppMemory,
1965 PFORMAT_STRING pFormat,
1966 unsigned char fMustAlloc)
1968 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1969 unsigned char alignment = pFormat[1] + 1;
1971 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1972 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1974 pFormat = ReadConformance(pStubMsg, pFormat+4);
1975 size = pStubMsg->MaxCount;
1977 if (fMustAlloc || !*ppMemory)
1978 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1980 ALIGN_POINTER(pStubMsg->Buffer, alignment);
1982 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1984 pStubMsg->BufferMark = pStubMsg->Buffer;
1985 pStubMsg->Buffer += size*esize;
1987 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
1992 /***********************************************************************
1993 * NdrConformantArrayBufferSize [RPCRT4.@]
1995 void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1996 unsigned char *pMemory,
1997 PFORMAT_STRING pFormat)
1999 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
2000 unsigned char alignment = pFormat[1] + 1;
2002 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2003 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
2005 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2006 size = pStubMsg->MaxCount;
2008 SizeVariance(pStubMsg);
2010 ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
2012 /* conformance value plus array */
2013 pStubMsg->BufferLength += size*esize;
2015 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
2018 /***********************************************************************
2019 * NdrConformantArrayMemorySize [RPCRT4.@]
2021 unsigned long WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2022 PFORMAT_STRING pFormat)
2024 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
2025 unsigned char *buffer;
2027 TRACE("(%p,%p)\n", pStubMsg, pFormat);
2028 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
2030 buffer = pStubMsg->Buffer;
2031 pFormat = ReadConformance(pStubMsg, pFormat+4);
2032 pStubMsg->Buffer = buffer;
2033 size = pStubMsg->MaxCount;
2038 /***********************************************************************
2039 * NdrConformantArrayFree [RPCRT4.@]
2041 void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2042 unsigned char *pMemory,
2043 PFORMAT_STRING pFormat)
2045 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2046 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
2048 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2052 /***********************************************************************
2053 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
2055 unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
2056 unsigned char* pMemory,
2057 PFORMAT_STRING pFormat )
2059 unsigned char alignment = pFormat[1] + 1;
2060 DWORD esize = *(const WORD*)(pFormat+2);
2062 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
2064 if (pFormat[0] != RPC_FC_CVARRAY)
2066 ERR("invalid format type %x\n", pFormat[0]);
2067 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2071 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2072 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
2074 WriteConformance(pStubMsg);
2075 WriteVariance(pStubMsg);
2077 ALIGN_POINTER(pStubMsg->Buffer, alignment);
2079 memcpy(pStubMsg->Buffer, pMemory + pStubMsg->Offset, pStubMsg->ActualCount*esize);
2080 pStubMsg->BufferMark = pStubMsg->Buffer;
2081 pStubMsg->Buffer += pStubMsg->ActualCount*esize;
2083 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2085 STD_OVERFLOW_CHECK(pStubMsg);
2091 /***********************************************************************
2092 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
2094 unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
2095 unsigned char** ppMemory,
2096 PFORMAT_STRING pFormat,
2097 unsigned char fMustAlloc )
2099 unsigned char alignment = pFormat[1] + 1;
2100 DWORD esize = *(const WORD*)(pFormat+2);
2102 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2104 if (pFormat[0] != RPC_FC_CVARRAY)
2106 ERR("invalid format type %x\n", pFormat[0]);
2107 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2111 pFormat = ReadConformance(pStubMsg, pFormat);
2112 pFormat = ReadVariance(pStubMsg, pFormat);
2114 ALIGN_POINTER(pStubMsg->Buffer, alignment);
2116 if (!*ppMemory || fMustAlloc)
2117 *ppMemory = NdrAllocate(pStubMsg, pStubMsg->MaxCount * esize);
2118 memcpy(*ppMemory + pStubMsg->Offset, pStubMsg->Buffer, pStubMsg->ActualCount * esize);
2119 pStubMsg->Buffer += pStubMsg->ActualCount * esize;
2121 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
2127 /***********************************************************************
2128 * NdrConformantVaryingArrayFree [RPCRT4.@]
2130 void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
2131 unsigned char* pMemory,
2132 PFORMAT_STRING pFormat )
2134 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2136 if (pFormat[0] != RPC_FC_CVARRAY)
2138 ERR("invalid format type %x\n", pFormat[0]);
2139 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2143 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2144 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
2146 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2150 /***********************************************************************
2151 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
2153 void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
2154 unsigned char* pMemory, PFORMAT_STRING pFormat )
2156 unsigned char alignment = pFormat[1] + 1;
2157 DWORD esize = *(const WORD*)(pFormat+2);
2159 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
2161 if (pFormat[0] != RPC_FC_CVARRAY)
2163 ERR("invalid format type %x\n", pFormat[0]);
2164 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2169 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2170 /* compute length */
2171 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
2173 SizeConformance(pStubMsg);
2174 SizeVariance(pStubMsg);
2176 ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
2178 pStubMsg->BufferLength += pStubMsg->ActualCount*esize;
2180 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
2184 /***********************************************************************
2185 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
2187 unsigned long WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
2188 PFORMAT_STRING pFormat )
2195 /***********************************************************************
2196 * NdrComplexArrayMarshall [RPCRT4.@]
2198 unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2199 unsigned char *pMemory,
2200 PFORMAT_STRING pFormat)
2203 BOOL variance_present;
2204 unsigned char alignment;
2206 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2208 if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
2210 ERR("invalid format type %x\n", pFormat[0]);
2211 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2215 alignment = pFormat[1] + 1;
2217 def = *(const WORD*)&pFormat[2];
2220 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2221 TRACE("conformance = %ld\n", pStubMsg->MaxCount);
2223 variance_present = IsConformanceOrVariancePresent(pFormat);
2224 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2225 TRACE("variance = %ld\n", pStubMsg->ActualCount);
2227 WriteConformance(pStubMsg);
2228 if (variance_present)
2229 WriteVariance(pStubMsg);
2231 ALIGN_POINTER(pStubMsg->Buffer, alignment);
2233 for (count = 0; count < pStubMsg->ActualCount; count++)
2234 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2236 STD_OVERFLOW_CHECK(pStubMsg);
2241 /***********************************************************************
2242 * NdrComplexArrayUnmarshall [RPCRT4.@]
2244 unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2245 unsigned char **ppMemory,
2246 PFORMAT_STRING pFormat,
2247 unsigned char fMustAlloc)
2250 unsigned char alignment;
2251 unsigned char *pMemory;
2253 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2255 if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
2257 ERR("invalid format type %x\n", pFormat[0]);
2258 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2262 alignment = pFormat[1] + 1;
2266 pFormat = ReadConformance(pStubMsg, pFormat);
2267 pFormat = ReadVariance(pStubMsg, pFormat);
2269 esize = ComplexStructSize(pStubMsg, pFormat);
2271 if (fMustAlloc || !*ppMemory)
2273 *ppMemory = NdrAllocate(pStubMsg, pStubMsg->MaxCount * esize);
2274 memset(*ppMemory, 0, pStubMsg->MaxCount * esize);
2277 ALIGN_POINTER(pStubMsg->Buffer, alignment);
2279 pMemory = *ppMemory;
2280 for (count = 0; count < pStubMsg->ActualCount; count++)
2281 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2286 /***********************************************************************
2287 * NdrComplexArrayBufferSize [RPCRT4.@]
2289 void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2290 unsigned char *pMemory,
2291 PFORMAT_STRING pFormat)
2294 unsigned char alignment;
2295 BOOL variance_present;
2297 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2299 if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
2301 ERR("invalid format type %x\n", pFormat[0]);
2302 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2306 alignment = pFormat[1] + 1;
2308 def = *(const WORD*)&pFormat[2];
2311 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2312 TRACE("conformance = %ld\n", pStubMsg->MaxCount);
2313 SizeConformance(pStubMsg);
2315 variance_present = IsConformanceOrVariancePresent(pFormat);
2316 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2317 TRACE("variance = %ld\n", pStubMsg->ActualCount);
2319 if (variance_present)
2320 SizeVariance(pStubMsg);
2322 ALIGN_LENGTH(pStubMsg->BufferLength, alignment);
2324 for (count=0; count < pStubMsg->ActualCount; count++)
2325 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
2328 /***********************************************************************
2329 * NdrComplexArrayMemorySize [RPCRT4.@]
2331 unsigned long WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2332 PFORMAT_STRING pFormat)
2335 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2337 if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
2339 ERR("invalid format type %x\n", pFormat[0]);
2340 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2346 pFormat = ReadConformance(pStubMsg, pFormat);
2347 size = pStubMsg->MaxCount;
2348 TRACE("conformance=%ld\n", size);
2355 /***********************************************************************
2356 * NdrComplexArrayFree [RPCRT4.@]
2358 void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2359 unsigned char *pMemory,
2360 PFORMAT_STRING pFormat)
2364 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2366 if (pFormat[0] != RPC_FC_BOGUS_ARRAY)
2368 ERR("invalid format type %x\n", pFormat[0]);
2369 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2373 def = *(const WORD*)&pFormat[2];
2376 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2377 TRACE("conformance = %ld\n", pStubMsg->MaxCount);
2379 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2380 TRACE("variance = %ld\n", pStubMsg->ActualCount);
2382 for (count=0; count < pStubMsg->ActualCount; count++)
2383 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2386 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg)
2388 return MAKELONG(pStubMsg->dwDestContext,
2389 pStubMsg->RpcMsg->DataRepresentation);
2392 /***********************************************************************
2393 * NdrUserMarshalMarshall [RPCRT4.@]
2395 unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2396 unsigned char *pMemory,
2397 PFORMAT_STRING pFormat)
2399 /* unsigned flags = pFormat[1]; */
2400 unsigned index = *(const WORD*)&pFormat[2];
2401 unsigned long uflag = UserMarshalFlags(pStubMsg);
2402 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2403 TRACE("index=%d\n", index);
2406 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
2407 &uflag, pStubMsg->Buffer, pMemory);
2409 STD_OVERFLOW_CHECK(pStubMsg);
2414 /***********************************************************************
2415 * NdrUserMarshalUnmarshall [RPCRT4.@]
2417 unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2418 unsigned char **ppMemory,
2419 PFORMAT_STRING pFormat,
2420 unsigned char fMustAlloc)
2422 /* unsigned flags = pFormat[1];*/
2423 unsigned index = *(const WORD*)&pFormat[2];
2424 DWORD memsize = *(const WORD*)&pFormat[4];
2425 unsigned long uflag = UserMarshalFlags(pStubMsg);
2426 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2427 TRACE("index=%d\n", index);
2429 if (fMustAlloc || !*ppMemory)
2430 *ppMemory = NdrAllocate(pStubMsg, memsize);
2433 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
2434 &uflag, pStubMsg->Buffer, *ppMemory);
2439 /***********************************************************************
2440 * NdrUserMarshalBufferSize [RPCRT4.@]
2442 void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2443 unsigned char *pMemory,
2444 PFORMAT_STRING pFormat)
2446 /* unsigned flags = pFormat[1];*/
2447 unsigned index = *(const WORD*)&pFormat[2];
2448 DWORD bufsize = *(const WORD*)&pFormat[6];
2449 unsigned long uflag = UserMarshalFlags(pStubMsg);
2450 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2451 TRACE("index=%d\n", index);
2454 TRACE("size=%ld\n", bufsize);
2455 pStubMsg->BufferLength += bufsize;
2459 pStubMsg->BufferLength =
2460 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
2461 &uflag, pStubMsg->BufferLength, pMemory);
2464 /***********************************************************************
2465 * NdrUserMarshalMemorySize [RPCRT4.@]
2467 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2468 PFORMAT_STRING pFormat)
2470 unsigned index = *(const WORD*)&pFormat[2];
2471 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2472 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2473 TRACE("index=%d\n", index);
2478 /***********************************************************************
2479 * NdrUserMarshalFree [RPCRT4.@]
2481 void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
2482 unsigned char *pMemory,
2483 PFORMAT_STRING pFormat)
2485 /* unsigned flags = pFormat[1]; */
2486 unsigned index = *(const WORD*)&pFormat[2];
2487 unsigned long uflag = UserMarshalFlags(pStubMsg);
2488 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2489 TRACE("index=%d\n", index);
2491 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
2495 /***********************************************************************
2496 * NdrClearOutParameters [RPCRT4.@]
2498 void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
2499 PFORMAT_STRING pFormat,
2502 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
2505 /***********************************************************************
2506 * NdrConvert [RPCRT4.@]
2508 void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
2510 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
2511 /* FIXME: since this stub doesn't do any converting, the proper behavior
2512 is to raise an exception */
2515 /***********************************************************************
2516 * NdrConvert2 [RPCRT4.@]
2518 void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams )
2520 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2521 pStubMsg, pFormat, NumberParams);
2522 /* FIXME: since this stub doesn't do any converting, the proper behavior
2523 is to raise an exception */
2526 typedef struct _NDR_CSTRUCT_FORMAT
2529 unsigned char alignment;
2530 unsigned short memory_size;
2531 short offset_to_array_description;
2532 } NDR_CSTRUCT_FORMAT;
2534 /***********************************************************************
2535 * NdrConformantStructMarshall [RPCRT4.@]
2537 unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2538 unsigned char *pMemory,
2539 PFORMAT_STRING pFormat)
2541 const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat;
2542 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
2544 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
2546 if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
2548 ERR("invalid format type %x\n", pCStructFormat->type);
2549 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2553 ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
2555 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
2557 /* copy constant sized part of struct */
2558 memcpy(pStubMsg->Buffer, pMemory, pCStructFormat->memory_size);
2559 pStubMsg->Buffer += pCStructFormat->memory_size;
2561 if (pCStructFormat->offset_to_array_description)
2563 PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description +
2564 pCStructFormat->offset_to_array_description;
2565 NdrConformantArrayMarshall(pStubMsg, pMemory + pCStructFormat->memory_size, pArrayFormat);
2567 if (pCStructFormat->type == RPC_FC_CPSTRUCT)
2568 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2572 /***********************************************************************
2573 * NdrConformantStructUnmarshall [RPCRT4.@]
2575 unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2576 unsigned char **ppMemory,
2577 PFORMAT_STRING pFormat,
2578 unsigned char fMustAlloc)
2580 const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat;
2581 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
2583 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2585 if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
2587 ERR("invalid format type %x\n", pCStructFormat->type);
2588 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2592 ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
2594 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
2596 /* work out how much memory to allocate if we need to do so */
2597 if (!*ppMemory || fMustAlloc)
2599 SIZE_T size = pCStructFormat->memory_size;
2601 if (pCStructFormat->offset_to_array_description)
2603 unsigned char *buffer;
2604 PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description +
2605 pCStructFormat->offset_to_array_description;
2606 buffer = pStubMsg->Buffer;
2607 pStubMsg->Buffer += pCStructFormat->memory_size;
2608 size += NdrConformantArrayMemorySize(pStubMsg, pArrayFormat);
2609 pStubMsg->Buffer = buffer;
2611 *ppMemory = NdrAllocate(pStubMsg, size);
2614 /* now copy the data */
2615 memcpy(*ppMemory, pStubMsg->Buffer, pCStructFormat->memory_size);
2616 pStubMsg->Buffer += pCStructFormat->memory_size;
2617 if (pCStructFormat->offset_to_array_description)
2619 PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description +
2620 pCStructFormat->offset_to_array_description;
2621 unsigned char *pMemoryArray = *ppMemory + pCStructFormat->memory_size;
2622 /* note that we pass fMustAlloc as 0 as we have already allocated the
2624 NdrConformantArrayUnmarshall(pStubMsg, &pMemoryArray, pArrayFormat, 0);
2626 if (pCStructFormat->type == RPC_FC_CPSTRUCT)
2627 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
2631 /***********************************************************************
2632 * NdrConformantStructBufferSize [RPCRT4.@]
2634 void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2635 unsigned char *pMemory,
2636 PFORMAT_STRING pFormat)
2638 const NDR_CSTRUCT_FORMAT * pCStructFormat = (NDR_CSTRUCT_FORMAT*)pFormat;
2639 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
2640 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
2642 if ((pCStructFormat->type != RPC_FC_CPSTRUCT) && (pCStructFormat->type != RPC_FC_CSTRUCT))
2644 ERR("invalid format type %x\n", pCStructFormat->type);
2645 RpcRaiseException(RPC_S_INTERNAL_ERROR);
2649 ALIGN_LENGTH(pStubMsg->BufferLength, pCStructFormat->alignment + 1);
2651 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
2653 /* add constant sized part of struct to buffer size */
2654 pStubMsg->BufferLength += pCStructFormat->memory_size;
2656 if (pCStructFormat->offset_to_array_description)
2658 PFORMAT_STRING pArrayFormat = (unsigned char*)&pCStructFormat->offset_to_array_description +
2659 pCStructFormat->offset_to_array_description;
2660 NdrConformantArrayBufferSize(pStubMsg, pMemory + pCStructFormat->memory_size, pArrayFormat);
2662 if (pCStructFormat->type == RPC_FC_CPSTRUCT)
2663 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
2666 /***********************************************************************
2667 * NdrConformantStructMemorySize [RPCRT4.@]
2669 unsigned long WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2670 PFORMAT_STRING pFormat)
2676 /***********************************************************************
2677 * NdrConformantStructFree [RPCRT4.@]
2679 void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2680 unsigned char *pMemory,
2681 PFORMAT_STRING pFormat)
2686 /***********************************************************************
2687 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2689 unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2690 unsigned char *pMemory,
2691 PFORMAT_STRING pFormat)
2697 /***********************************************************************
2698 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2700 unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2701 unsigned char **ppMemory,
2702 PFORMAT_STRING pFormat,
2703 unsigned char fMustAlloc)
2709 /***********************************************************************
2710 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2712 void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2713 unsigned char *pMemory,
2714 PFORMAT_STRING pFormat)
2719 /***********************************************************************
2720 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2722 unsigned long WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2723 PFORMAT_STRING pFormat)
2729 /***********************************************************************
2730 * NdrConformantVaryingStructFree [RPCRT4.@]
2732 void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2733 unsigned char *pMemory,
2734 PFORMAT_STRING pFormat)
2739 /***********************************************************************
2740 * NdrFixedArrayMarshall [RPCRT4.@]
2742 unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2743 unsigned char *pMemory,
2744 PFORMAT_STRING pFormat)
2750 /***********************************************************************
2751 * NdrFixedArrayUnmarshall [RPCRT4.@]
2753 unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2754 unsigned char **ppMemory,
2755 PFORMAT_STRING pFormat,
2756 unsigned char fMustAlloc)
2762 /***********************************************************************
2763 * NdrFixedArrayBufferSize [RPCRT4.@]
2765 void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2766 unsigned char *pMemory,
2767 PFORMAT_STRING pFormat)
2772 /***********************************************************************
2773 * NdrFixedArrayMemorySize [RPCRT4.@]
2775 unsigned long WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2776 PFORMAT_STRING pFormat)
2782 /***********************************************************************
2783 * NdrFixedArrayFree [RPCRT4.@]
2785 void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2786 unsigned char *pMemory,
2787 PFORMAT_STRING pFormat)
2792 /***********************************************************************
2793 * NdrVaryingArrayMarshall [RPCRT4.@]
2795 unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2796 unsigned char *pMemory,
2797 PFORMAT_STRING pFormat)
2803 /***********************************************************************
2804 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2806 unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2807 unsigned char **ppMemory,
2808 PFORMAT_STRING pFormat,
2809 unsigned char fMustAlloc)
2815 /***********************************************************************
2816 * NdrVaryingArrayBufferSize [RPCRT4.@]
2818 void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2819 unsigned char *pMemory,
2820 PFORMAT_STRING pFormat)
2825 /***********************************************************************
2826 * NdrVaryingArrayMemorySize [RPCRT4.@]
2828 unsigned long WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2829 PFORMAT_STRING pFormat)
2835 /***********************************************************************
2836 * NdrVaryingArrayFree [RPCRT4.@]
2838 void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2839 unsigned char *pMemory,
2840 PFORMAT_STRING pFormat)
2845 /***********************************************************************
2846 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2848 unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2849 unsigned char *pMemory,
2850 PFORMAT_STRING pFormat)
2856 /***********************************************************************
2857 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2859 unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2860 unsigned char **ppMemory,
2861 PFORMAT_STRING pFormat,
2862 unsigned char fMustAlloc)
2868 /***********************************************************************
2869 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2871 void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2872 unsigned char *pMemory,
2873 PFORMAT_STRING pFormat)
2878 /***********************************************************************
2879 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2881 unsigned long WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2882 PFORMAT_STRING pFormat)
2888 /***********************************************************************
2889 * NdrEncapsulatedUnionFree [RPCRT4.@]
2891 void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2892 unsigned char *pMemory,
2893 PFORMAT_STRING pFormat)
2898 static PFORMAT_STRING get_arm_offset_from_union_arm_selector(PMIDL_STUB_MESSAGE pStubMsg,
2899 unsigned long discriminant,
2900 PFORMAT_STRING pFormat)
2902 unsigned short num_arms, arm, type;
2904 num_arms = *(const SHORT*)pFormat & 0x0fff;
2906 for(arm = 0; arm < num_arms; arm++)
2908 if(discriminant == *(const ULONG*)pFormat)
2916 type = *(const unsigned short*)pFormat;
2917 TRACE("type %04x\n", type);
2918 if(arm == num_arms) /* default arm extras */
2922 FIXME("should raise an exception here\n");
2927 /* Don't marshall any type. FIXME is this correct? */
2934 static PFORMAT_STRING get_non_encapsulated_union_arm(PMIDL_STUB_MESSAGE pStubMsg,
2935 unsigned char *pMemory,
2936 PFORMAT_STRING pFormat)
2940 pFormat = ComputeConformanceOrVariance(pStubMsg, pMemory, pFormat,
2942 TRACE("got switch value %lx\n", value);
2943 pFormat += *(const SHORT*)pFormat;
2946 return get_arm_offset_from_union_arm_selector(pStubMsg, value, pFormat);
2949 static unsigned char *get_conformance_address(PMIDL_STUB_MESSAGE pStubMsg,
2950 unsigned char *pMemory,
2951 PFORMAT_STRING pFormat)
2953 short ofs = *(short *)&pFormat[2];
2956 switch (pFormat[0] & 0xf0)
2958 case RPC_FC_NORMAL_CONFORMANCE:
2962 FIXME("Conformance type %x\n", pFormat[0]);
2968 FIXME("Conformance op %x\n", pFormat[1]);
2972 return (unsigned char *)ptr + ofs;
2975 /***********************************************************************
2976 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2978 unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2979 unsigned char *pMemory,
2980 PFORMAT_STRING pFormat)
2982 unsigned char *discriminant;
2983 unsigned short type;
2985 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
2988 /* Marshall discriminant */
2989 discriminant = get_conformance_address(pStubMsg, pMemory, pFormat + 1);
2990 NdrBaseTypeMarshall(pStubMsg, discriminant, pFormat);
2993 pFormat = get_non_encapsulated_union_arm(pStubMsg, pMemory, pFormat);
2997 type = *(const unsigned short*)pFormat;
3001 return NdrBaseTypeMarshall(pStubMsg, pMemory, pFormat);
3005 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
3006 NDR_MARSHALL m = NdrMarshaller[*desc & NDR_TABLE_MASK];
3015 pMemory = *(void**)pMemory;
3018 m(pStubMsg, pMemory, desc);
3020 else FIXME("no marshaller for embedded type %02x\n", *desc);
3025 static long unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg,
3026 PFORMAT_STRING *ppFormat)
3028 long discriminant = 0;
3036 discriminant = *(UCHAR *)pStubMsg->Buffer;
3037 pStubMsg->Buffer += sizeof(UCHAR);
3042 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
3043 discriminant = *(USHORT *)pStubMsg->Buffer;
3044 pStubMsg->Buffer += sizeof(USHORT);
3048 ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG));
3049 discriminant = *(ULONG *)pStubMsg->Buffer;
3050 pStubMsg->Buffer += sizeof(ULONG);
3053 FIXME("Unhandled base type: 0x%02x\n", **ppFormat);
3057 if (pStubMsg->fHasNewCorrDesc)
3061 return discriminant;
3064 /**********************************************************************
3065 * NdrNonEncapsulatedUnionUnmarshall[RPCRT4.@]
3067 unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3068 unsigned char **ppMemory,
3069 PFORMAT_STRING pFormat,
3070 unsigned char fMustAlloc)
3073 unsigned short type, size;
3075 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
3078 /* Unmarshall discriminant */
3079 discriminant = unmarshall_discriminant(pStubMsg, &pFormat);
3080 TRACE("unmarshalled discriminant %lx\n", discriminant);
3082 pFormat += *(const SHORT*)pFormat;
3084 size = *(const unsigned short*)pFormat;
3087 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
3091 if(!*ppMemory || fMustAlloc)
3092 *ppMemory = NdrAllocate(pStubMsg, size);
3094 type = *(const unsigned short*)pFormat;
3098 return NdrBaseTypeUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
3102 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
3103 NDR_UNMARSHALL m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
3112 **(void***)ppMemory = NULL;
3115 return m(pStubMsg, (unsigned char **)*ppMemory, desc, fMustAlloc);
3117 else FIXME("no marshaller for embedded type %02x\n", *desc);
3122 /***********************************************************************
3123 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
3125 void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
3126 unsigned char *pMemory,
3127 PFORMAT_STRING pFormat)
3129 unsigned short type;
3130 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
3133 /* Add discriminant size */
3134 NdrBaseTypeBufferSize(pStubMsg, pMemory, pFormat);
3137 pFormat = get_non_encapsulated_union_arm(pStubMsg, pMemory, pFormat);
3141 type = *(const unsigned short*)pFormat;
3145 NdrBaseTypeBufferSize(pStubMsg, pMemory, pFormat);
3149 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
3150 NDR_BUFFERSIZE m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
3159 pMemory = *(void**)pMemory;
3162 m(pStubMsg, pMemory, desc);
3164 else FIXME("no buffersizer for embedded type %02x\n", *desc);
3169 /***********************************************************************
3170 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
3172 unsigned long WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
3173 PFORMAT_STRING pFormat)
3176 if (pStubMsg->fHasNewCorrDesc)
3181 pFormat += *(const SHORT*)pFormat;
3182 TRACE("size %d\n", *(const SHORT*)pFormat);
3183 return *(const SHORT*)pFormat;
3186 /***********************************************************************
3187 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
3189 void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
3190 unsigned char *pMemory,
3191 PFORMAT_STRING pFormat)
3196 /***********************************************************************
3197 * NdrByteCountPointerMarshall [RPCRT4.@]
3199 unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
3200 unsigned char *pMemory,
3201 PFORMAT_STRING pFormat)
3207 /***********************************************************************
3208 * NdrByteCountPointerUnmarshall [RPCRT4.@]
3210 unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3211 unsigned char **ppMemory,
3212 PFORMAT_STRING pFormat,
3213 unsigned char fMustAlloc)
3219 /***********************************************************************
3220 * NdrByteCountPointerBufferSize [RPCRT4.@]
3222 void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
3223 unsigned char *pMemory,
3224 PFORMAT_STRING pFormat)
3229 /***********************************************************************
3230 * NdrByteCountPointerMemorySize [RPCRT4.@]
3232 unsigned long WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
3233 PFORMAT_STRING pFormat)
3239 /***********************************************************************
3240 * NdrByteCountPointerFree [RPCRT4.@]
3242 void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
3243 unsigned char *pMemory,
3244 PFORMAT_STRING pFormat)
3249 /***********************************************************************
3250 * NdrXmitOrRepAsMarshall [RPCRT4.@]
3252 unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
3253 unsigned char *pMemory,
3254 PFORMAT_STRING pFormat)
3260 /***********************************************************************
3261 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
3263 unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3264 unsigned char **ppMemory,
3265 PFORMAT_STRING pFormat,
3266 unsigned char fMustAlloc)
3272 /***********************************************************************
3273 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
3275 void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
3276 unsigned char *pMemory,
3277 PFORMAT_STRING pFormat)
3282 /***********************************************************************
3283 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
3285 unsigned long WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
3286 PFORMAT_STRING pFormat)
3292 /***********************************************************************
3293 * NdrXmitOrRepAsFree [RPCRT4.@]
3295 void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
3296 unsigned char *pMemory,
3297 PFORMAT_STRING pFormat)
3302 /***********************************************************************
3303 * NdrBaseTypeMarshall [internal]
3305 static unsigned char *WINAPI NdrBaseTypeMarshall(
3306 PMIDL_STUB_MESSAGE pStubMsg,
3307 unsigned char *pMemory,
3308 PFORMAT_STRING pFormat)
3310 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
3318 *(UCHAR *)pStubMsg->Buffer = *(UCHAR *)pMemory;
3319 pStubMsg->Buffer += sizeof(UCHAR);
3320 TRACE("value: 0x%02x\n", *(UCHAR *)pMemory);
3325 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
3326 *(USHORT *)pStubMsg->Buffer = *(USHORT *)pMemory;
3327 pStubMsg->Buffer += sizeof(USHORT);
3328 TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
3332 case RPC_FC_ERROR_STATUS_T:
3334 ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG));
3335 *(ULONG *)pStubMsg->Buffer = *(ULONG *)pMemory;
3336 pStubMsg->Buffer += sizeof(ULONG);
3337 TRACE("value: 0x%08lx\n", *(ULONG *)pMemory);
3340 ALIGN_POINTER(pStubMsg->Buffer, sizeof(float));
3341 *(float *)pStubMsg->Buffer = *(float *)pMemory;
3342 pStubMsg->Buffer += sizeof(float);
3345 ALIGN_POINTER(pStubMsg->Buffer, sizeof(double));
3346 *(double *)pStubMsg->Buffer = *(double *)pMemory;
3347 pStubMsg->Buffer += sizeof(double);
3350 ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONGLONG));
3351 *(ULONGLONG *)pStubMsg->Buffer = *(ULONGLONG *)pMemory;
3352 pStubMsg->Buffer += sizeof(ULONGLONG);
3353 TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory));
3356 /* only 16-bits on the wire, so do a sanity check */
3357 if (*(UINT *)pMemory > USHRT_MAX)
3358 RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE);
3359 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
3360 *(USHORT *)pStubMsg->Buffer = *(UINT *)pMemory;
3361 pStubMsg->Buffer += sizeof(USHORT);
3362 TRACE("value: 0x%04x\n", *(UINT *)pMemory);
3365 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
3368 STD_OVERFLOW_CHECK(pStubMsg);
3370 /* FIXME: what is the correct return value? */
3374 /***********************************************************************
3375 * NdrBaseTypeUnmarshall [internal]
3377 static unsigned char *WINAPI NdrBaseTypeUnmarshall(
3378 PMIDL_STUB_MESSAGE pStubMsg,
3379 unsigned char **ppMemory,
3380 PFORMAT_STRING pFormat,
3381 unsigned char fMustAlloc)
3383 TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
3385 if (fMustAlloc || !*ppMemory)
3386 *ppMemory = NdrAllocate(pStubMsg, NdrBaseTypeMemorySize(pStubMsg, pFormat));
3388 TRACE("*ppMemory: %p\n", *ppMemory);
3396 **(UCHAR **)ppMemory = *(UCHAR *)pStubMsg->Buffer;
3397 pStubMsg->Buffer += sizeof(UCHAR);
3398 TRACE("value: 0x%02x\n", **(UCHAR **)ppMemory);
3403 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
3404 **(USHORT **)ppMemory = *(USHORT *)pStubMsg->Buffer;
3405 pStubMsg->Buffer += sizeof(USHORT);
3406 TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
3410 case RPC_FC_ERROR_STATUS_T:
3412 ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONG));
3413 **(ULONG **)ppMemory = *(ULONG *)pStubMsg->Buffer;
3414 pStubMsg->Buffer += sizeof(ULONG);
3415 TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory);
3418 ALIGN_POINTER(pStubMsg->Buffer, sizeof(float));
3419 **(float **)ppMemory = *(float *)pStubMsg->Buffer;
3420 pStubMsg->Buffer += sizeof(float);
3421 TRACE("value: %f\n", **(float **)ppMemory);
3424 ALIGN_POINTER(pStubMsg->Buffer, sizeof(double));
3425 **(double **)ppMemory = *(double*)pStubMsg->Buffer;
3426 pStubMsg->Buffer += sizeof(double);
3427 TRACE("value: %f\n", **(double **)ppMemory);
3430 ALIGN_POINTER(pStubMsg->Buffer, sizeof(ULONGLONG));
3431 **(ULONGLONG **)ppMemory = *(ULONGLONG *)pStubMsg->Buffer;
3432 pStubMsg->Buffer += sizeof(ULONGLONG);
3433 TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
3436 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
3437 /* 16-bits on the wire, but int in memory */
3438 **(UINT **)ppMemory = *(USHORT *)pStubMsg->Buffer;
3439 pStubMsg->Buffer += sizeof(USHORT);
3440 TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
3443 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
3446 /* FIXME: what is the correct return value? */
3451 /***********************************************************************
3452 * NdrBaseTypeBufferSize [internal]
3454 static void WINAPI NdrBaseTypeBufferSize(
3455 PMIDL_STUB_MESSAGE pStubMsg,
3456 unsigned char *pMemory,
3457 PFORMAT_STRING pFormat)
3459 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
3467 pStubMsg->BufferLength += sizeof(UCHAR);
3473 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(USHORT));
3474 pStubMsg->BufferLength += sizeof(USHORT);
3479 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONG));
3480 pStubMsg->BufferLength += sizeof(ULONG);
3483 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(float));
3484 pStubMsg->BufferLength += sizeof(float);
3487 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(double));
3488 pStubMsg->BufferLength += sizeof(double);
3491 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(ULONGLONG));
3492 pStubMsg->BufferLength += sizeof(ULONGLONG);
3494 case RPC_FC_ERROR_STATUS_T:
3495 ALIGN_LENGTH(pStubMsg->BufferLength, sizeof(error_status_t));
3496 pStubMsg->BufferLength += sizeof(error_status_t);
3499 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
3503 /***********************************************************************
3504 * NdrBaseTypeMemorySize [internal]
3506 static unsigned long WINAPI NdrBaseTypeMemorySize(
3507 PMIDL_STUB_MESSAGE pStubMsg,
3508 PFORMAT_STRING pFormat)
3516 return sizeof(UCHAR);
3520 return sizeof(USHORT);
3523 return sizeof(ULONG);
3525 return sizeof(float);
3527 return sizeof(double);
3529 return sizeof(ULONGLONG);
3530 case RPC_FC_ERROR_STATUS_T:
3531 return sizeof(error_status_t);
3536 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
3541 /***********************************************************************
3542 * NdrBaseTypeFree [internal]
3544 static void WINAPI NdrBaseTypeFree(PMIDL_STUB_MESSAGE pStubMsg,
3545 unsigned char *pMemory,
3546 PFORMAT_STRING pFormat)
3548 TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
3553 /***********************************************************************
3554 * NdrClientContextMarshall
3556 void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
3557 NDR_CCONTEXT ContextHandle,
3560 FIXME("(%p, %p, %d): stub\n", pStubMsg, ContextHandle, fCheck);
3563 /***********************************************************************
3564 * NdrClientContextUnmarshall
3566 void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3567 NDR_CCONTEXT * pContextHandle,
3568 RPC_BINDING_HANDLE BindHandle)
3570 FIXME("(%p, %p, %p): stub\n", pStubMsg, pContextHandle, BindHandle);
3573 void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
3574 NDR_SCONTEXT ContextHandle,
3575 NDR_RUNDOWN RundownRoutine )
3577 FIXME("(%p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine);
3580 NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
3582 FIXME("(%p): stub\n", pStubMsg);
3586 void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
3587 unsigned char* pMemory,
3588 PFORMAT_STRING pFormat)
3590 FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
3593 NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
3594 PFORMAT_STRING pFormat)
3596 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
3600 void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
3601 NDR_SCONTEXT ContextHandle,
3602 NDR_RUNDOWN RundownRoutine,
3603 PFORMAT_STRING pFormat)
3605 FIXME("(%p, %p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
3608 NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3609 PFORMAT_STRING pFormat)
3611 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
3615 RPC_BINDING_HANDLE WINAPI NDRCContextBinding(NDR_CCONTEXT CContext)
3617 FIXME("(%p): stub\n", CContext);