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
38 #include "wine/unicode.h"
39 #include "wine/rpcfc.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(ole);
45 #define BUFFER_PARANOIA 20
48 # define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
49 (*((UINT32 *)(pchar)) = (uint32))
51 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
52 (*((UINT32 *)(pchar)))
54 /* these would work for i386 too, but less efficient */
55 # define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
56 (*(pchar) = LOBYTE(LOWORD(uint32)), \
57 *((pchar)+1) = HIBYTE(LOWORD(uint32)), \
58 *((pchar)+2) = LOBYTE(HIWORD(uint32)), \
59 *((pchar)+3) = HIBYTE(HIWORD(uint32)), \
60 (uint32)) /* allow as r-value */
62 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
64 MAKEWORD(*(pchar), *((pchar)+1)), \
65 MAKEWORD(*((pchar)+2), *((pchar)+3))))
68 #define BIG_ENDIAN_UINT32_WRITE(pchar, uint32) \
69 (*((pchar)+3) = LOBYTE(LOWORD(uint32)), \
70 *((pchar)+2) = HIBYTE(LOWORD(uint32)), \
71 *((pchar)+1) = LOBYTE(HIWORD(uint32)), \
72 *(pchar) = HIBYTE(HIWORD(uint32)), \
73 (uint32)) /* allow as r-value */
75 #define BIG_ENDIAN_UINT32_READ(pchar) \
77 MAKEWORD(*((pchar)+3), *((pchar)+2)), \
78 MAKEWORD(*((pchar)+1), *(pchar))))
80 #ifdef NDR_LOCAL_IS_BIG_ENDIAN
81 # define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
82 BIG_ENDIAN_UINT32_WRITE(pchar, uint32)
83 # define NDR_LOCAL_UINT32_READ(pchar) \
84 BIG_ENDIAN_UINT32_READ(pchar)
86 # define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
87 LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
88 # define NDR_LOCAL_UINT32_READ(pchar) \
89 LITTLE_ENDIAN_UINT32_READ(pchar)
92 /* _Align must be the desired alignment minus 1,
93 * e.g. ALIGN_LENGTH(len, 3) to align on a dword boundary. */
94 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
95 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
96 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
97 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
99 #define STD_OVERFLOW_CHECK(_Msg) do { \
100 TRACE("buffer=%d/%ld\n", _Msg->Buffer - _Msg->BufferStart, _Msg->BufferLength); \
101 if (_Msg->Buffer > _Msg->BufferEnd) ERR("buffer overflow %d bytes\n", _Msg->Buffer - _Msg->BufferEnd); \
104 #define NDR_TABLE_SIZE 128
105 #define NDR_TABLE_MASK 127
107 NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE] = {
108 0, 0, 0, 0, 0, 0, 0, 0,
109 0, 0, 0, 0, 0, 0, 0, 0,
113 NdrPointerMarshall, NdrPointerMarshall,
114 NdrPointerMarshall, NdrPointerMarshall,
116 NdrSimpleStructMarshall, NdrSimpleStructMarshall,
117 NdrConformantStructMarshall, NdrConformantStructMarshall,
118 NdrConformantVaryingStructMarshall,
119 NdrComplexStructMarshall,
121 NdrConformantArrayMarshall,
122 NdrConformantVaryingArrayMarshall,
123 NdrFixedArrayMarshall, NdrFixedArrayMarshall,
124 NdrVaryingArrayMarshall, NdrVaryingArrayMarshall,
125 NdrComplexArrayMarshall,
127 NdrConformantStringMarshall, 0, 0,
128 NdrConformantStringMarshall, 0, 0, 0, 0,
130 NdrEncapsulatedUnionMarshall,
131 NdrNonEncapsulatedUnionMarshall,
133 NdrXmitOrRepAsMarshall, NdrXmitOrRepAsMarshall,
135 NdrInterfacePointerMarshall,
138 NdrUserMarshalMarshall
140 NDR_UNMARSHALL NdrUnmarshaller[NDR_TABLE_SIZE] = {
141 0, 0, 0, 0, 0, 0, 0, 0,
142 0, 0, 0, 0, 0, 0, 0, 0,
146 NdrPointerUnmarshall, NdrPointerUnmarshall,
147 NdrPointerUnmarshall, NdrPointerUnmarshall,
149 NdrSimpleStructUnmarshall, NdrSimpleStructUnmarshall,
150 NdrConformantStructUnmarshall, NdrConformantStructUnmarshall,
151 NdrConformantVaryingStructUnmarshall,
152 NdrComplexStructUnmarshall,
154 NdrConformantArrayUnmarshall,
155 NdrConformantVaryingArrayUnmarshall,
156 NdrFixedArrayUnmarshall, NdrFixedArrayUnmarshall,
157 NdrVaryingArrayUnmarshall, NdrVaryingArrayUnmarshall,
158 NdrComplexArrayUnmarshall,
160 NdrConformantStringUnmarshall, 0, 0,
161 NdrConformantStringUnmarshall, 0, 0, 0, 0,
163 NdrEncapsulatedUnionUnmarshall,
164 NdrNonEncapsulatedUnionUnmarshall,
166 NdrXmitOrRepAsUnmarshall, NdrXmitOrRepAsUnmarshall,
168 NdrInterfacePointerUnmarshall,
171 NdrUserMarshalUnmarshall
173 NDR_BUFFERSIZE NdrBufferSizer[NDR_TABLE_SIZE] = {
174 0, 0, 0, 0, 0, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0,
179 NdrPointerBufferSize, NdrPointerBufferSize,
180 NdrPointerBufferSize, NdrPointerBufferSize,
182 NdrSimpleStructBufferSize, NdrSimpleStructBufferSize,
183 NdrConformantStructBufferSize, NdrConformantStructBufferSize,
184 NdrConformantVaryingStructBufferSize,
185 NdrComplexStructBufferSize,
187 NdrConformantArrayBufferSize,
188 NdrConformantVaryingArrayBufferSize,
189 NdrFixedArrayBufferSize, NdrFixedArrayBufferSize,
190 NdrVaryingArrayBufferSize, NdrVaryingArrayBufferSize,
191 NdrComplexArrayBufferSize,
193 NdrConformantStringBufferSize, 0, 0,
194 NdrConformantStringBufferSize, 0, 0, 0, 0,
196 NdrEncapsulatedUnionBufferSize,
197 NdrNonEncapsulatedUnionBufferSize,
199 NdrXmitOrRepAsBufferSize, NdrXmitOrRepAsBufferSize,
201 NdrInterfacePointerBufferSize,
204 NdrUserMarshalBufferSize
206 NDR_MEMORYSIZE NdrMemorySizer[NDR_TABLE_SIZE] = {
207 0, 0, 0, 0, 0, 0, 0, 0,
208 0, 0, 0, 0, 0, 0, 0, 0,
212 NdrPointerMemorySize, NdrPointerMemorySize,
213 NdrPointerMemorySize, NdrPointerMemorySize,
215 NdrSimpleStructMemorySize, NdrSimpleStructMemorySize,
217 NdrComplexStructMemorySize,
219 NdrConformantArrayMemorySize, 0, 0, 0, 0, 0,
220 NdrComplexArrayMemorySize,
222 NdrConformantStringMemorySize, 0, 0,
223 NdrConformantStringMemorySize, 0, 0, 0, 0,
227 NdrInterfacePointerMemorySize,
230 NdrUserMarshalMemorySize
232 NDR_FREE NdrFreer[NDR_TABLE_SIZE] = {
233 0, 0, 0, 0, 0, 0, 0, 0,
234 0, 0, 0, 0, 0, 0, 0, 0,
238 NdrPointerFree, NdrPointerFree,
239 NdrPointerFree, NdrPointerFree,
241 NdrSimpleStructFree, NdrSimpleStructFree,
242 NdrConformantStructFree, NdrConformantStructFree,
243 NdrConformantVaryingStructFree,
244 NdrComplexStructFree,
246 NdrConformantArrayFree,
247 NdrConformantVaryingArrayFree,
248 NdrFixedArrayFree, NdrFixedArrayFree,
249 NdrVaryingArrayFree, NdrVaryingArrayFree,
255 NdrEncapsulatedUnionFree,
256 NdrNonEncapsulatedUnionFree,
258 NdrXmitOrRepAsFree, NdrXmitOrRepAsFree,
260 NdrInterfacePointerFree,
266 void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, size_t len)
268 /* hmm, this is probably supposed to do more? */
269 return pStubMsg->pfnAllocate(len);
272 static void WINAPI NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
274 pStubMsg->pfnFree(Pointer);
277 PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
279 pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
280 pStubMsg->Buffer += 4;
281 TRACE("unmarshalled conformance is %ld\n", pStubMsg->MaxCount);
285 PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
286 PFORMAT_STRING pFormat, ULONG_PTR def)
288 BYTE dtype = pFormat[0] & 0xf;
289 DWORD ofs = (DWORD)pFormat[2] | ((DWORD)pFormat[3] << 8);
293 if (pFormat[0] == 0xff) {
294 /* null descriptor */
295 pStubMsg->MaxCount = def;
299 switch (pFormat[0] & 0xf0) {
300 case RPC_FC_NORMAL_CONFORMANCE:
301 TRACE("normal conformance, ofs=%ld\n", ofs);
304 case RPC_FC_POINTER_CONFORMANCE:
305 TRACE("pointer conformance, ofs=%ld\n", ofs);
306 ptr = pStubMsg->Memory + ofs;
308 case RPC_FC_TOP_LEVEL_CONFORMANCE:
309 TRACE("toplevel conformance, ofs=%ld\n", ofs);
310 if (pStubMsg->StackTop) {
311 ptr = pStubMsg->StackTop + ofs;
314 /* -Os mode, MaxCount is already set */
318 case RPC_FC_CONSTANT_CONFORMANCE:
319 data = ofs | ((DWORD)pFormat[1] << 16);
320 TRACE("constant conformance, val=%ld\n", data);
321 pStubMsg->MaxCount = data;
323 case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE:
324 FIXME("toplevel multidimensional conformance, ofs=%ld\n", ofs);
325 if (pStubMsg->StackTop) {
326 ptr = pStubMsg->StackTop + ofs;
334 FIXME("unknown conformance type %x\n", pFormat[0] & 0xf0);
337 switch (pFormat[1]) {
338 case RPC_FC_DEREFERENCE:
341 case RPC_FC_CALLBACK:
342 /* ofs is index into StubDesc->apfnExprEval */
343 FIXME("handle callback\n");
358 data = *(USHORT*)ptr;
367 FIXME("unknown conformance data type %x\n", dtype);
370 TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
373 switch (pFormat[1]) {
375 pStubMsg->MaxCount = data;
377 case RPC_FC_DEREFERENCE:
378 /* already handled */
381 FIXME("unknown conformance op %d\n", pFormat[1]);
386 TRACE("resulting conformance is %ld\n", pStubMsg->MaxCount);
392 * NdrConformantString:
394 * What MS calls a ConformantString is, in DCE terminology,
395 * a Varying-Conformant String.
397 * maxlen: DWORD (max # of CHARTYPE characters, inclusive of '\0')
398 * offset: DWORD (actual string data begins at (offset) CHARTYPE's
399 * into unmarshalled string)
400 * length: DWORD (# of CHARTYPE characters, inclusive of '\0')
402 * data: CHARTYPE[maxlen]
404 * ], where CHARTYPE is the appropriate character type (specified externally)
408 /***********************************************************************
409 * NdrConformantStringMarshall [RPCRT4.@]
411 unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg,
412 unsigned char *pszMessage, PFORMAT_STRING pFormat)
414 unsigned long len, esize;
417 TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
420 if (*pFormat == RPC_FC_C_CSTRING) {
421 TRACE("string=%s\n", debugstr_a(pszMessage));
422 len = strlen(pszMessage)+1;
425 else if (*pFormat == RPC_FC_C_WSTRING) {
426 TRACE("string=%s\n", debugstr_w((LPWSTR)pszMessage));
427 len = strlenW((LPWSTR)pszMessage)+1;
431 ERR("Unhandled string type: %#x\n", *pFormat);
432 /* FIXME: raise an exception. */
436 if (pFormat[1] != RPC_FC_PAD) {
437 FIXME("sized string format=%d\n", pFormat[1]);
440 assert( (pStubMsg->BufferLength >= (len*esize + 13)) && (pStubMsg->Buffer != NULL) );
442 c = pStubMsg->Buffer;
444 NDR_LOCAL_UINT32_WRITE(c, len); /* max length: strlen + 1 (for '\0') */
445 c += 8; /* offset: 0 */
446 NDR_LOCAL_UINT32_WRITE(c, len); /* actual length: (same) */
448 memcpy(c, pszMessage, len*esize); /* the string itself */
450 pStubMsg->Buffer = c;
452 STD_OVERFLOW_CHECK(pStubMsg);
455 return NULL; /* is this always right? */
458 /***********************************************************************
459 * NdrConformantStringBufferSize [RPCRT4.@]
461 void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
462 unsigned char* pMemory, PFORMAT_STRING pFormat)
464 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
467 if (*pFormat == RPC_FC_C_CSTRING) {
468 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */
469 TRACE("string=%s\n", debugstr_a(pMemory));
470 pStubMsg->BufferLength += strlen(pMemory) + 13 + BUFFER_PARANOIA;
472 else if (*pFormat == RPC_FC_C_WSTRING) {
473 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 2 octets for L'\0' */
474 TRACE("string=%s\n", debugstr_w((LPWSTR)pMemory));
475 pStubMsg->BufferLength += strlenW((LPWSTR)pMemory)*2 + 14 + BUFFER_PARANOIA;
478 ERR("Unhandled string type: %#x\n", *pFormat);
479 /* FIXME: raise an exception */
482 if (pFormat[1] != RPC_FC_PAD) {
483 FIXME("sized string format=%d\n", pFormat[1]);
487 /************************************************************************
488 * NdrConformantStringMemorySize [RPCRT4.@]
490 unsigned long WINAPI NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
491 PFORMAT_STRING pFormat )
493 unsigned long rslt = 0;
495 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
497 assert(pStubMsg && pFormat);
499 if (*pFormat == RPC_FC_C_CSTRING) {
500 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); /* maxlen */
502 else if (*pFormat == RPC_FC_C_WSTRING) {
503 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer)*2; /* maxlen */
506 ERR("Unhandled string type: %#x\n", *pFormat);
507 /* FIXME: raise an exception */
510 if (pFormat[1] != RPC_FC_PAD) {
511 FIXME("sized string format=%d\n", pFormat[1]);
514 TRACE(" --> %lu\n", rslt);
518 /************************************************************************
519 * NdrConformantStringUnmarshall [RPCRT4.@]
521 unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
522 unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc )
524 unsigned long len, esize, ofs;
527 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
528 pStubMsg, *ppMemory, pFormat, fMustAlloc);
530 assert(pFormat && ppMemory && pStubMsg);
532 pStubMsg->Buffer += 4;
533 ofs = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
534 pStubMsg->Buffer += 4;
535 len = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
536 pStubMsg->Buffer += 4;
538 if (*pFormat == RPC_FC_C_CSTRING) esize = 1;
539 else if (*pFormat == RPC_FC_C_WSTRING) esize = 2;
541 ERR("Unhandled string type: %#x\n", *pFormat);
542 /* FIXME: raise an exception */
546 if (pFormat[1] != RPC_FC_PAD) {
547 FIXME("sized string format=%d\n", pFormat[1]);
551 *ppMemory = NdrAllocate(pStubMsg, len*esize + BUFFER_PARANOIA);
553 if (pStubMsg->ReuseBuffer && !*ppMemory)
554 /* for servers, we may just point straight into the RPC buffer, I think
555 * (I guess that's what MS does since MIDL code doesn't try to free) */
556 *ppMemory = pStubMsg->Buffer - ofs*esize;
557 /* for clients, memory should be provided by caller */
560 pMem = *ppMemory + ofs*esize;
562 if (pMem != pStubMsg->Buffer)
563 memcpy(pMem, pStubMsg->Buffer, len*esize);
565 pStubMsg->Buffer += len*esize;
567 if (*pFormat == RPC_FC_C_CSTRING) {
568 TRACE("string=%s\n", debugstr_a(pMem));
570 else if (*pFormat == RPC_FC_C_WSTRING) {
571 TRACE("string=%s\n", debugstr_w((LPWSTR)pMem));
574 return NULL; /* FIXME: is this always right? */
577 static inline void dump_pointer_attr(unsigned char attr)
579 if (attr & RPC_FC_P_ALLOCALLNODES)
580 TRACE(" RPC_FC_P_ALLOCALLNODES");
581 if (attr & RPC_FC_P_DONTFREE)
582 TRACE(" RPC_FC_P_DONTFREE");
583 if (attr & RPC_FC_P_ONSTACK)
584 TRACE(" RPC_FC_P_ONSTACK");
585 if (attr & RPC_FC_P_SIMPLEPOINTER)
586 TRACE(" RPC_FC_P_SIMPLEPOINTER");
587 if (attr & RPC_FC_P_DEREF)
588 TRACE(" RPC_FC_P_DEREF");
592 /***********************************************************************
595 void WINAPI PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
596 unsigned char *Buffer,
597 unsigned char *Pointer,
598 PFORMAT_STRING pFormat)
600 unsigned type = pFormat[0], attr = pFormat[1];
604 TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
605 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
607 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
608 else desc = pFormat + *(const SHORT*)pFormat;
609 if (attr & RPC_FC_P_DEREF) {
610 Pointer = *(unsigned char**)Pointer;
611 TRACE("deref => %p\n", Pointer);
615 case RPC_FC_RP: /* ref pointer (always non-null) */
616 #if 0 /* this causes problems for InstallShield so is disabled - we need more tests */
618 RpcRaiseException(RPC_X_NULL_REF_POINTER);
621 case RPC_FC_UP: /* unique pointer */
622 case RPC_FC_OP: /* object pointer - same as unique here */
623 TRACE("writing %p to buffer\n", Pointer);
624 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, (unsigned long)Pointer);
625 pStubMsg->Buffer += 4;
629 FIXME("unhandled ptr type=%02x\n", type);
630 RpcRaiseException(RPC_X_BAD_STUB_DATA);
633 TRACE("calling marshaller for type 0x%x\n", (int)*desc);
636 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
637 if (m) m(pStubMsg, Pointer, desc);
638 else FIXME("no marshaller for data type=%02x\n", *desc);
641 STD_OVERFLOW_CHECK(pStubMsg);
644 /***********************************************************************
647 void WINAPI PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
648 unsigned char *Buffer,
649 unsigned char **pPointer,
650 PFORMAT_STRING pFormat,
651 unsigned char fMustAlloc)
653 unsigned type = pFormat[0], attr = pFormat[1];
656 DWORD pointer_id = 0;
658 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pFormat, fMustAlloc);
659 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
661 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
662 else desc = pFormat + *(const SHORT*)pFormat;
663 if (attr & RPC_FC_P_DEREF) {
664 pPointer = *(unsigned char***)pPointer;
665 TRACE("deref => %p\n", pPointer);
669 case RPC_FC_RP: /* ref pointer (always non-null) */
672 case RPC_FC_UP: /* unique pointer */
673 pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
674 pStubMsg->Buffer += 4;
676 case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
679 FIXME("unhandled ptr type=%02x\n", type);
680 RpcRaiseException(RPC_X_BAD_STUB_DATA);
686 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
687 if (m) m(pStubMsg, pPointer, desc, fMustAlloc);
688 else FIXME("no unmarshaller for data type=%02x\n", *desc);
691 TRACE("pointer=%p\n", *pPointer);
694 /***********************************************************************
697 void WINAPI PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
698 unsigned char *Pointer,
699 PFORMAT_STRING pFormat)
701 unsigned type = pFormat[0], attr = pFormat[1];
705 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
706 TRACE("type=%d, attr=%d\n", type, attr);
708 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
709 else desc = pFormat + *(const SHORT*)pFormat;
710 if (attr & RPC_FC_P_DEREF) {
711 Pointer = *(unsigned char**)Pointer;
712 TRACE("deref => %p\n", Pointer);
716 case RPC_FC_RP: /* ref pointer (always non-null) */
720 pStubMsg->BufferLength += 4;
721 /* NULL pointer has no further representation */
727 FIXME("unhandled ptr type=%02x\n", type);
728 RpcRaiseException(RPC_X_BAD_STUB_DATA);
731 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
732 if (m) m(pStubMsg, Pointer, desc);
733 else FIXME("no buffersizer for data type=%02x\n", *desc);
736 /***********************************************************************
737 * PointerMemorySize [RPCRT4.@]
739 unsigned long WINAPI PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
740 unsigned char *Buffer,
741 PFORMAT_STRING pFormat)
743 unsigned type = pFormat[0], attr = pFormat[1];
747 FIXME("(%p,%p,%p): stub\n", pStubMsg, Buffer, pFormat);
748 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
750 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
751 else desc = pFormat + *(const SHORT*)pFormat;
752 if (attr & RPC_FC_P_DEREF) {
757 case RPC_FC_RP: /* ref pointer (always non-null) */
760 FIXME("unhandled ptr type=%02x\n", type);
761 RpcRaiseException(RPC_X_BAD_STUB_DATA);
764 m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
765 if (m) m(pStubMsg, desc);
766 else FIXME("no memorysizer for data type=%02x\n", *desc);
771 /***********************************************************************
772 * PointerFree [RPCRT4.@]
774 void WINAPI PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
775 unsigned char *Pointer,
776 PFORMAT_STRING pFormat)
778 unsigned type = pFormat[0], attr = pFormat[1];
782 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
783 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
784 if (attr & RPC_FC_P_DONTFREE) return;
786 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
787 else desc = pFormat + *(const SHORT*)pFormat;
788 if (attr & RPC_FC_P_DEREF) {
789 Pointer = *(unsigned char**)Pointer;
790 TRACE("deref => %p\n", Pointer);
793 if (!Pointer) return;
795 m = NdrFreer[*desc & NDR_TABLE_MASK];
796 if (m) m(pStubMsg, Pointer, desc);
798 /* hmm... is this sensible?
799 * perhaps we should check if the memory comes from NdrAllocate,
800 * and deallocate only if so - checking if the pointer is between
801 * BufferStart and BufferEnd is probably no good since the buffer
802 * may be reallocated when the server wants to marshal the reply */
804 case RPC_FC_BOGUS_STRUCT:
805 case RPC_FC_BOGUS_ARRAY:
806 case RPC_FC_USER_MARSHAL:
809 FIXME("unhandled data type=%02x\n", *desc);
811 case RPC_FC_C_CSTRING:
812 case RPC_FC_C_WSTRING:
813 if (pStubMsg->ReuseBuffer) goto notfree;
819 if (attr & RPC_FC_P_ONSTACK) {
820 TRACE("not freeing stack ptr %p\n", Pointer);
823 TRACE("freeing %p\n", Pointer);
824 NdrFree(pStubMsg, Pointer);
827 TRACE("not freeing %p\n", Pointer);
830 /***********************************************************************
831 * EmbeddedPointerMarshall
833 unsigned char * WINAPI EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
834 unsigned char *pMemory,
835 PFORMAT_STRING pFormat)
837 unsigned char *Mark = pStubMsg->BufferMark;
838 unsigned long Offset = pStubMsg->Offset;
839 unsigned ofs, rep, count, stride, xofs;
841 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
843 if (*pFormat != RPC_FC_PP) return NULL;
846 while (pFormat[0] != RPC_FC_END) {
847 switch (pFormat[0]) {
849 FIXME("unknown repeat type %d\n", pFormat[0]);
850 case RPC_FC_NO_REPEAT:
858 case RPC_FC_FIXED_REPEAT:
859 rep = *(const WORD*)&pFormat[2];
860 stride = *(const WORD*)&pFormat[4];
861 ofs = *(const WORD*)&pFormat[6];
862 count = *(const WORD*)&pFormat[8];
866 case RPC_FC_VARIABLE_REPEAT:
867 rep = pStubMsg->MaxCount;
868 stride = *(const WORD*)&pFormat[2];
869 ofs = *(const WORD*)&pFormat[4];
870 count = *(const WORD*)&pFormat[6];
871 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
875 /* ofs doesn't seem to matter in this context */
877 PFORMAT_STRING info = pFormat;
878 unsigned char *membase = pMemory + xofs;
880 for (u=0; u<count; u++,info+=8) {
881 unsigned char *memptr = membase + *(const SHORT*)&info[0];
882 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
883 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
887 pFormat += 8 * count;
890 STD_OVERFLOW_CHECK(pStubMsg);
895 /***********************************************************************
896 * EmbeddedPointerUnmarshall
898 unsigned char * WINAPI EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
899 unsigned char **ppMemory,
900 PFORMAT_STRING pFormat,
901 unsigned char fMustAlloc)
903 unsigned char *Mark = pStubMsg->BufferMark;
904 unsigned long Offset = pStubMsg->Offset;
905 unsigned ofs, rep, count, stride, xofs;
907 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
909 if (*pFormat != RPC_FC_PP) return NULL;
912 while (pFormat[0] != RPC_FC_END) {
913 switch (pFormat[0]) {
915 FIXME("unknown repeat type %d\n", pFormat[0]);
916 case RPC_FC_NO_REPEAT:
924 case RPC_FC_FIXED_REPEAT:
925 rep = *(const WORD*)&pFormat[2];
926 stride = *(const WORD*)&pFormat[4];
927 ofs = *(const WORD*)&pFormat[6];
928 count = *(const WORD*)&pFormat[8];
932 case RPC_FC_VARIABLE_REPEAT:
933 rep = pStubMsg->MaxCount;
934 stride = *(const WORD*)&pFormat[2];
935 ofs = *(const WORD*)&pFormat[4];
936 count = *(const WORD*)&pFormat[6];
937 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
941 /* ofs doesn't seem to matter in this context */
943 PFORMAT_STRING info = pFormat;
944 unsigned char *membase = *ppMemory + xofs;
946 for (u=0; u<count; u++,info+=8) {
947 unsigned char *memptr = membase + *(const SHORT*)&info[0];
948 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
949 PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
953 pFormat += 8 * count;
959 /***********************************************************************
960 * EmbeddedPointerBufferSize
962 void WINAPI EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
963 unsigned char *pMemory,
964 PFORMAT_STRING pFormat)
966 unsigned long Offset = pStubMsg->Offset;
967 unsigned ofs, rep, count, stride, xofs;
969 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
970 if (*pFormat != RPC_FC_PP) return;
973 while (pFormat[0] != RPC_FC_END) {
974 switch (pFormat[0]) {
976 FIXME("unknown repeat type %d\n", pFormat[0]);
977 case RPC_FC_NO_REPEAT:
985 case RPC_FC_FIXED_REPEAT:
986 rep = *(const WORD*)&pFormat[2];
987 stride = *(const WORD*)&pFormat[4];
988 ofs = *(const WORD*)&pFormat[6];
989 count = *(const WORD*)&pFormat[8];
993 case RPC_FC_VARIABLE_REPEAT:
994 rep = pStubMsg->MaxCount;
995 stride = *(const WORD*)&pFormat[2];
996 ofs = *(const WORD*)&pFormat[4];
997 count = *(const WORD*)&pFormat[6];
998 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1002 /* ofs doesn't seem to matter in this context */
1004 PFORMAT_STRING info = pFormat;
1005 unsigned char *membase = pMemory + xofs;
1007 for (u=0; u<count; u++,info+=8) {
1008 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1009 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1013 pFormat += 8 * count;
1017 /***********************************************************************
1018 * EmbeddedPointerMemorySize
1020 unsigned long WINAPI EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1021 PFORMAT_STRING pFormat)
1023 unsigned long Offset = pStubMsg->Offset;
1024 unsigned char *Mark = pStubMsg->BufferMark;
1025 unsigned ofs, rep, count, stride, xofs;
1027 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1028 if (*pFormat != RPC_FC_PP) return 0;
1031 while (pFormat[0] != RPC_FC_END) {
1032 switch (pFormat[0]) {
1034 FIXME("unknown repeat type %d\n", pFormat[0]);
1035 case RPC_FC_NO_REPEAT:
1043 case RPC_FC_FIXED_REPEAT:
1044 rep = *(const WORD*)&pFormat[2];
1045 stride = *(const WORD*)&pFormat[4];
1046 ofs = *(const WORD*)&pFormat[6];
1047 count = *(const WORD*)&pFormat[8];
1051 case RPC_FC_VARIABLE_REPEAT:
1052 rep = pStubMsg->MaxCount;
1053 stride = *(const WORD*)&pFormat[2];
1054 ofs = *(const WORD*)&pFormat[4];
1055 count = *(const WORD*)&pFormat[6];
1056 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1060 /* ofs doesn't seem to matter in this context */
1062 PFORMAT_STRING info = pFormat;
1064 for (u=0; u<count; u++,info+=8) {
1065 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1066 PointerMemorySize(pStubMsg, bufptr, info+4);
1070 pFormat += 8 * count;
1076 /***********************************************************************
1077 * EmbeddedPointerFree
1079 void WINAPI EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1080 unsigned char *pMemory,
1081 PFORMAT_STRING pFormat)
1083 unsigned long Offset = pStubMsg->Offset;
1084 unsigned ofs, rep, count, stride, xofs;
1086 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1087 if (*pFormat != RPC_FC_PP) return;
1090 while (pFormat[0] != RPC_FC_END) {
1091 switch (pFormat[0]) {
1093 FIXME("unknown repeat type %d\n", pFormat[0]);
1094 case RPC_FC_NO_REPEAT:
1102 case RPC_FC_FIXED_REPEAT:
1103 rep = *(const WORD*)&pFormat[2];
1104 stride = *(const WORD*)&pFormat[4];
1105 ofs = *(const WORD*)&pFormat[6];
1106 count = *(const WORD*)&pFormat[8];
1110 case RPC_FC_VARIABLE_REPEAT:
1111 rep = pStubMsg->MaxCount;
1112 stride = *(const WORD*)&pFormat[2];
1113 ofs = *(const WORD*)&pFormat[4];
1114 count = *(const WORD*)&pFormat[6];
1115 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1119 /* ofs doesn't seem to matter in this context */
1121 PFORMAT_STRING info = pFormat;
1122 unsigned char *membase = pMemory + xofs;
1124 for (u=0; u<count; u++,info+=8) {
1125 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1126 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1130 pFormat += 8 * count;
1134 /***********************************************************************
1135 * NdrPointerMarshall [RPCRT4.@]
1137 unsigned char * WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1138 unsigned char *pMemory,
1139 PFORMAT_STRING pFormat)
1141 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1143 pStubMsg->BufferMark = pStubMsg->Buffer;
1144 PointerMarshall(pStubMsg, pStubMsg->Buffer, pMemory, pFormat);
1146 STD_OVERFLOW_CHECK(pStubMsg);
1151 /***********************************************************************
1152 * NdrPointerUnmarshall [RPCRT4.@]
1154 unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1155 unsigned char **ppMemory,
1156 PFORMAT_STRING pFormat,
1157 unsigned char fMustAlloc)
1159 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1161 pStubMsg->BufferMark = pStubMsg->Buffer;
1162 PointerUnmarshall(pStubMsg, pStubMsg->Buffer, ppMemory, pFormat, fMustAlloc);
1167 /***********************************************************************
1168 * NdrPointerBufferSize [RPCRT4.@]
1170 void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1171 unsigned char *pMemory,
1172 PFORMAT_STRING pFormat)
1174 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1175 PointerBufferSize(pStubMsg, pMemory, pFormat);
1178 /***********************************************************************
1179 * NdrPointerMemorySize [RPCRT4.@]
1181 unsigned long WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1182 PFORMAT_STRING pFormat)
1184 /* unsigned size = *(LPWORD)(pFormat+2); */
1185 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1186 PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat);
1190 /***********************************************************************
1191 * NdrPointerFree [RPCRT4.@]
1193 void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1194 unsigned char *pMemory,
1195 PFORMAT_STRING pFormat)
1197 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1198 PointerFree(pStubMsg, pMemory, pFormat);
1201 /***********************************************************************
1202 * NdrSimpleStructMarshall [RPCRT4.@]
1204 unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1205 unsigned char *pMemory,
1206 PFORMAT_STRING pFormat)
1208 unsigned size = *(const WORD*)(pFormat+2);
1209 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1211 memcpy(pStubMsg->Buffer, pMemory, size);
1212 pStubMsg->BufferMark = pStubMsg->Buffer;
1213 pStubMsg->Buffer += size;
1215 if (pFormat[0] != RPC_FC_STRUCT)
1216 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
1218 STD_OVERFLOW_CHECK(pStubMsg);
1223 /***********************************************************************
1224 * NdrSimpleStructUnmarshall [RPCRT4.@]
1226 unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1227 unsigned char **ppMemory,
1228 PFORMAT_STRING pFormat,
1229 unsigned char fMustAlloc)
1231 unsigned size = *(const WORD*)(pFormat+2);
1232 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1235 *ppMemory = NdrAllocate(pStubMsg, size);
1236 memcpy(*ppMemory, pStubMsg->Buffer, size);
1238 if (pStubMsg->ReuseBuffer && !*ppMemory)
1239 /* for servers, we may just point straight into the RPC buffer, I think
1240 * (I guess that's what MS does since MIDL code doesn't try to free) */
1241 *ppMemory = pStubMsg->Buffer;
1243 /* for clients, memory should be provided by caller */
1244 memcpy(*ppMemory, pStubMsg->Buffer, size);
1247 pStubMsg->BufferMark = pStubMsg->Buffer;
1248 pStubMsg->Buffer += size;
1250 if (pFormat[0] != RPC_FC_STRUCT)
1251 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat+4, fMustAlloc);
1257 /***********************************************************************
1258 * NdrSimpleStructUnmarshall [RPCRT4.@]
1260 void WINAPI NdrSimpleTypeMarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
1261 unsigned char FormatChar )
1267 /***********************************************************************
1268 * NdrSimpleStructUnmarshall [RPCRT4.@]
1270 void WINAPI NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory,
1271 unsigned char FormatChar )
1277 /***********************************************************************
1278 * NdrSimpleStructBufferSize [RPCRT4.@]
1280 void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1281 unsigned char *pMemory,
1282 PFORMAT_STRING pFormat)
1284 unsigned size = *(const WORD*)(pFormat+2);
1285 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1286 pStubMsg->BufferLength += size;
1287 if (pFormat[0] != RPC_FC_STRUCT)
1288 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
1291 /***********************************************************************
1292 * NdrSimpleStructMemorySize [RPCRT4.@]
1294 unsigned long WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1295 PFORMAT_STRING pFormat)
1297 /* unsigned size = *(LPWORD)(pFormat+2); */
1298 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1299 if (pFormat[0] != RPC_FC_STRUCT)
1300 EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
1304 /***********************************************************************
1305 * NdrSimpleStructFree [RPCRT4.@]
1307 void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1308 unsigned char *pMemory,
1309 PFORMAT_STRING pFormat)
1311 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1312 if (pFormat[0] != RPC_FC_STRUCT)
1313 EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
1317 unsigned long WINAPI EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg,
1318 PFORMAT_STRING pFormat)
1322 case RPC_FC_PSTRUCT:
1323 case RPC_FC_CSTRUCT:
1324 case RPC_FC_BOGUS_STRUCT:
1325 return *(const WORD*)&pFormat[2];
1326 case RPC_FC_USER_MARSHAL:
1327 return *(const WORD*)&pFormat[4];
1329 FIXME("unhandled embedded type %02x\n", *pFormat);
1335 unsigned char * WINAPI ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1336 unsigned char *pMemory,
1337 PFORMAT_STRING pFormat,
1338 PFORMAT_STRING pPointer)
1340 PFORMAT_STRING desc;
1344 while (*pFormat != RPC_FC_END) {
1348 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
1349 memcpy(pStubMsg->Buffer, pMemory, 2);
1350 pStubMsg->Buffer += 2;
1355 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
1356 memcpy(pStubMsg->Buffer, pMemory, 4);
1357 pStubMsg->Buffer += 4;
1360 case RPC_FC_POINTER:
1361 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
1362 NdrPointerMarshall(pStubMsg, *(unsigned char**)pMemory, pPointer);
1366 case RPC_FC_ALIGNM4:
1367 ALIGN_POINTER(pMemory, 3);
1369 case RPC_FC_ALIGNM8:
1370 ALIGN_POINTER(pMemory, 7);
1372 case RPC_FC_EMBEDDED_COMPLEX:
1373 pMemory += pFormat[1];
1375 desc = pFormat + *(const SHORT*)pFormat;
1376 size = EmbeddedComplexSize(pStubMsg, desc);
1377 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
1378 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
1379 if (m) m(pStubMsg, pMemory, desc);
1380 else FIXME("no marshaller for embedded type %02x\n", *desc);
1387 FIXME("unhandled format %02x\n", *pFormat);
1395 unsigned char * WINAPI ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1396 unsigned char *pMemory,
1397 PFORMAT_STRING pFormat,
1398 PFORMAT_STRING pPointer,
1399 unsigned char fMustAlloc)
1401 PFORMAT_STRING desc;
1405 while (*pFormat != RPC_FC_END) {
1409 memcpy(pMemory, pStubMsg->Buffer, 2);
1410 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
1411 pStubMsg->Buffer += 2;
1416 memcpy(pMemory, pStubMsg->Buffer, 4);
1417 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
1418 pStubMsg->Buffer += 4;
1421 case RPC_FC_POINTER:
1422 *(unsigned char**)pMemory = NULL;
1423 TRACE("pointer => %p\n", pMemory);
1424 NdrPointerUnmarshall(pStubMsg, (unsigned char**)pMemory, pPointer, fMustAlloc);
1428 case RPC_FC_ALIGNM4:
1429 ALIGN_POINTER(pMemory, 3);
1431 case RPC_FC_ALIGNM8:
1432 ALIGN_POINTER(pMemory, 7);
1434 case RPC_FC_EMBEDDED_COMPLEX:
1435 pMemory += pFormat[1];
1437 desc = pFormat + *(const SHORT*)pFormat;
1438 size = EmbeddedComplexSize(pStubMsg, desc);
1439 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
1440 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
1441 memset(pMemory, 0, size); /* just in case */
1442 if (m) m(pStubMsg, &pMemory, desc, fMustAlloc);
1443 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
1450 FIXME("unhandled format %d\n", *pFormat);
1458 unsigned char * WINAPI ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1459 unsigned char *pMemory,
1460 PFORMAT_STRING pFormat,
1461 PFORMAT_STRING pPointer)
1463 PFORMAT_STRING desc;
1467 while (*pFormat != RPC_FC_END) {
1471 pStubMsg->BufferLength += 2;
1476 pStubMsg->BufferLength += 4;
1479 case RPC_FC_POINTER:
1480 NdrPointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
1484 case RPC_FC_ALIGNM4:
1485 ALIGN_POINTER(pMemory, 3);
1487 case RPC_FC_ALIGNM8:
1488 ALIGN_POINTER(pMemory, 7);
1490 case RPC_FC_EMBEDDED_COMPLEX:
1491 pMemory += pFormat[1];
1493 desc = pFormat + *(const SHORT*)pFormat;
1494 size = EmbeddedComplexSize(pStubMsg, desc);
1495 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
1496 if (m) m(pStubMsg, pMemory, desc);
1497 else FIXME("no buffersizer for embedded type %02x\n", *desc);
1504 FIXME("unhandled format %d\n", *pFormat);
1512 unsigned char * WINAPI ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
1513 unsigned char *pMemory,
1514 PFORMAT_STRING pFormat,
1515 PFORMAT_STRING pPointer)
1517 PFORMAT_STRING desc;
1521 while (*pFormat != RPC_FC_END) {
1531 case RPC_FC_POINTER:
1532 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
1536 case RPC_FC_ALIGNM4:
1537 ALIGN_POINTER(pMemory, 3);
1539 case RPC_FC_ALIGNM8:
1540 ALIGN_POINTER(pMemory, 7);
1542 case RPC_FC_EMBEDDED_COMPLEX:
1543 pMemory += pFormat[1];
1545 desc = pFormat + *(const SHORT*)pFormat;
1546 size = EmbeddedComplexSize(pStubMsg, desc);
1547 m = NdrFreer[*desc & NDR_TABLE_MASK];
1548 if (m) m(pStubMsg, pMemory, desc);
1549 else FIXME("no freer for embedded type %02x\n", *desc);
1556 FIXME("unhandled format %d\n", *pFormat);
1564 unsigned long WINAPI ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg,
1565 PFORMAT_STRING pFormat)
1567 PFORMAT_STRING desc;
1568 unsigned long size = 0;
1570 while (*pFormat != RPC_FC_END) {
1580 case RPC_FC_POINTER:
1583 case RPC_FC_ALIGNM4:
1584 ALIGN_LENGTH(size, 3);
1586 case RPC_FC_ALIGNM8:
1587 ALIGN_LENGTH(size, 7);
1589 case RPC_FC_EMBEDDED_COMPLEX:
1592 desc = pFormat + *(const SHORT*)pFormat;
1593 size += EmbeddedComplexSize(pStubMsg, desc);
1599 FIXME("unhandled format %d\n", *pFormat);
1607 /***********************************************************************
1608 * NdrComplexStructMarshall [RPCRT4.@]
1610 unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1611 unsigned char *pMemory,
1612 PFORMAT_STRING pFormat)
1614 PFORMAT_STRING conf_array = NULL;
1615 PFORMAT_STRING pointer_desc = NULL;
1616 unsigned char *OldMemory = pStubMsg->Memory;
1618 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1621 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1623 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1626 pStubMsg->Memory = pMemory;
1628 ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
1631 NdrConformantArrayMarshall(pStubMsg, pMemory, conf_array);
1633 pStubMsg->Memory = OldMemory;
1635 STD_OVERFLOW_CHECK(pStubMsg);
1640 /***********************************************************************
1641 * NdrComplexStructUnmarshall [RPCRT4.@]
1643 unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1644 unsigned char **ppMemory,
1645 PFORMAT_STRING pFormat,
1646 unsigned char fMustAlloc)
1648 unsigned size = *(const WORD*)(pFormat+2);
1649 PFORMAT_STRING conf_array = NULL;
1650 PFORMAT_STRING pointer_desc = NULL;
1651 unsigned char *pMemory;
1653 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1655 if (fMustAlloc || !*ppMemory)
1656 *ppMemory = NdrAllocate(pStubMsg, size);
1659 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1661 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1664 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
1667 NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
1672 /***********************************************************************
1673 * NdrComplexStructBufferSize [RPCRT4.@]
1675 void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1676 unsigned char *pMemory,
1677 PFORMAT_STRING pFormat)
1679 PFORMAT_STRING conf_array = NULL;
1680 PFORMAT_STRING pointer_desc = NULL;
1681 unsigned char *OldMemory = pStubMsg->Memory;
1683 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1686 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1688 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1691 pStubMsg->Memory = pMemory;
1693 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
1696 NdrConformantArrayBufferSize(pStubMsg, pMemory, conf_array);
1698 pStubMsg->Memory = OldMemory;
1701 /***********************************************************************
1702 * NdrComplexStructMemorySize [RPCRT4.@]
1704 unsigned long WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1705 PFORMAT_STRING pFormat)
1707 /* unsigned size = *(LPWORD)(pFormat+2); */
1708 PFORMAT_STRING conf_array = NULL;
1709 PFORMAT_STRING pointer_desc = NULL;
1711 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1714 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1716 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1722 /***********************************************************************
1723 * NdrComplexStructFree [RPCRT4.@]
1725 void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1726 unsigned char *pMemory,
1727 PFORMAT_STRING pFormat)
1729 PFORMAT_STRING conf_array = NULL;
1730 PFORMAT_STRING pointer_desc = NULL;
1731 unsigned char *OldMemory = pStubMsg->Memory;
1733 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1736 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1738 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1741 pStubMsg->Memory = pMemory;
1743 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
1746 NdrConformantArrayFree(pStubMsg, pMemory, conf_array);
1748 pStubMsg->Memory = OldMemory;
1751 /***********************************************************************
1752 * NdrConformantArrayMarshall [RPCRT4.@]
1754 unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1755 unsigned char *pMemory,
1756 PFORMAT_STRING pFormat)
1758 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1759 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1760 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1762 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1763 size = pStubMsg->MaxCount;
1765 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
1766 pStubMsg->Buffer += 4;
1768 memcpy(pStubMsg->Buffer, pMemory, size*esize);
1769 pStubMsg->BufferMark = pStubMsg->Buffer;
1770 pStubMsg->Buffer += size*esize;
1772 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
1774 STD_OVERFLOW_CHECK(pStubMsg);
1779 /***********************************************************************
1780 * NdrConformantArrayUnmarshall [RPCRT4.@]
1782 unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1783 unsigned char **ppMemory,
1784 PFORMAT_STRING pFormat,
1785 unsigned char fMustAlloc)
1787 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1788 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1789 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1791 pFormat = ReadConformance(pStubMsg, pFormat+4);
1792 size = pStubMsg->MaxCount;
1795 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1796 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1798 if (pStubMsg->ReuseBuffer && !*ppMemory)
1799 /* for servers, we may just point straight into the RPC buffer, I think
1800 * (I guess that's what MS does since MIDL code doesn't try to free) */
1801 *ppMemory = pStubMsg->Buffer;
1803 /* for clients, memory should be provided by caller */
1804 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1807 pStubMsg->BufferMark = pStubMsg->Buffer;
1808 pStubMsg->Buffer += size*esize;
1810 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
1815 /***********************************************************************
1816 * NdrConformantArrayBufferSize [RPCRT4.@]
1818 void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1819 unsigned char *pMemory,
1820 PFORMAT_STRING pFormat)
1822 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1823 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1824 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1826 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1827 size = pStubMsg->MaxCount;
1829 pStubMsg->BufferLength += size*esize;
1831 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1834 /***********************************************************************
1835 * NdrConformantArrayMemorySize [RPCRT4.@]
1837 unsigned long WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1838 PFORMAT_STRING pFormat)
1841 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1842 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1844 pFormat = ReadConformance(pStubMsg, pFormat+4);
1845 size = pStubMsg->MaxCount;
1847 EmbeddedPointerMemorySize(pStubMsg, pFormat);
1852 /***********************************************************************
1853 * NdrConformantArrayFree [RPCRT4.@]
1855 void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
1856 unsigned char *pMemory,
1857 PFORMAT_STRING pFormat)
1859 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1860 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1862 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
1866 /***********************************************************************
1867 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1869 unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
1870 unsigned char* pMemory,
1871 PFORMAT_STRING pFormat )
1878 /***********************************************************************
1879 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1881 unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
1882 unsigned char** ppMemory,
1883 PFORMAT_STRING pFormat,
1884 unsigned char fMustAlloc )
1891 /***********************************************************************
1892 * NdrConformantVaryingArrayFree [RPCRT4.@]
1894 void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
1895 unsigned char* pMemory,
1896 PFORMAT_STRING pFormat )
1902 /***********************************************************************
1903 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1905 void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
1906 unsigned char* pMemory, PFORMAT_STRING pFormat )
1912 /***********************************************************************
1913 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1915 unsigned long WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
1916 PFORMAT_STRING pFormat )
1923 /***********************************************************************
1924 * NdrComplexArrayMarshall [RPCRT4.@]
1926 unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1927 unsigned char *pMemory,
1928 PFORMAT_STRING pFormat)
1930 DWORD size = 0, count, def;
1931 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1933 def = *(const WORD*)&pFormat[2];
1936 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
1937 size = pStubMsg->MaxCount;
1938 TRACE("conformance=%ld\n", size);
1940 if (*(const DWORD*)pFormat != 0xffffffff)
1941 FIXME("compute variance\n");
1944 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
1945 pStubMsg->Buffer += 4;
1947 for (count=0; count<size; count++)
1948 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
1950 STD_OVERFLOW_CHECK(pStubMsg);
1955 /***********************************************************************
1956 * NdrComplexArrayUnmarshall [RPCRT4.@]
1958 unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1959 unsigned char **ppMemory,
1960 PFORMAT_STRING pFormat,
1961 unsigned char fMustAlloc)
1963 DWORD size = 0, count, esize;
1964 unsigned char *pMemory;
1965 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1969 pFormat = ReadConformance(pStubMsg, pFormat);
1970 size = pStubMsg->MaxCount;
1971 TRACE("conformance=%ld\n", size);
1975 esize = ComplexStructSize(pStubMsg, pFormat);
1977 if (fMustAlloc || !*ppMemory)
1978 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1980 pMemory = *ppMemory;
1981 for (count=0; count<size; count++)
1982 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
1987 /***********************************************************************
1988 * NdrComplexArrayBufferSize [RPCRT4.@]
1990 void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1991 unsigned char *pMemory,
1992 PFORMAT_STRING pFormat)
1994 DWORD size = 0, count, def;
1995 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1997 def = *(const WORD*)&pFormat[2];
2000 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2001 size = pStubMsg->MaxCount;
2002 TRACE("conformance=%ld\n", size);
2004 if (*(const DWORD*)pFormat != 0xffffffff)
2005 FIXME("compute variance\n");
2008 for (count=0; count<size; count++)
2009 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
2012 /***********************************************************************
2013 * NdrComplexArrayMemorySize [RPCRT4.@]
2015 unsigned long WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2016 PFORMAT_STRING pFormat)
2019 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2023 pFormat = ReadConformance(pStubMsg, pFormat);
2024 size = pStubMsg->MaxCount;
2025 TRACE("conformance=%ld\n", size);
2032 /***********************************************************************
2033 * NdrComplexArrayFree [RPCRT4.@]
2035 void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2036 unsigned char *pMemory,
2037 PFORMAT_STRING pFormat)
2039 DWORD size = 0, count, def;
2040 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2042 def = *(const WORD*)&pFormat[2];
2045 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2046 size = pStubMsg->MaxCount;
2047 TRACE("conformance=%ld\n", size);
2049 if (*(const DWORD*)pFormat != 0xffffffff)
2050 FIXME("compute variance\n");
2053 for (count=0; count<size; count++)
2054 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2057 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg)
2059 return MAKELONG(pStubMsg->dwDestContext,
2060 pStubMsg->RpcMsg->DataRepresentation);
2063 /***********************************************************************
2064 * NdrUserMarshalMarshall [RPCRT4.@]
2066 unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2067 unsigned char *pMemory,
2068 PFORMAT_STRING pFormat)
2070 /* unsigned flags = pFormat[1]; */
2071 unsigned index = *(const WORD*)&pFormat[2];
2072 unsigned long uflag = UserMarshalFlags(pStubMsg);
2073 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2074 TRACE("index=%d\n", index);
2077 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
2078 &uflag, pStubMsg->Buffer, pMemory);
2080 STD_OVERFLOW_CHECK(pStubMsg);
2085 /***********************************************************************
2086 * NdrUserMarshalUnmarshall [RPCRT4.@]
2088 unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2089 unsigned char **ppMemory,
2090 PFORMAT_STRING pFormat,
2091 unsigned char fMustAlloc)
2093 /* unsigned flags = pFormat[1];*/
2094 unsigned index = *(const WORD*)&pFormat[2];
2095 DWORD memsize = *(const WORD*)&pFormat[4];
2096 unsigned long uflag = UserMarshalFlags(pStubMsg);
2097 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2098 TRACE("index=%d\n", index);
2100 if (fMustAlloc || !*ppMemory)
2101 *ppMemory = NdrAllocate(pStubMsg, memsize);
2104 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
2105 &uflag, pStubMsg->Buffer, *ppMemory);
2110 /***********************************************************************
2111 * NdrUserMarshalBufferSize [RPCRT4.@]
2113 void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2114 unsigned char *pMemory,
2115 PFORMAT_STRING pFormat)
2117 /* unsigned flags = pFormat[1];*/
2118 unsigned index = *(const WORD*)&pFormat[2];
2119 DWORD bufsize = *(const WORD*)&pFormat[6];
2120 unsigned long uflag = UserMarshalFlags(pStubMsg);
2121 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2122 TRACE("index=%d\n", index);
2125 TRACE("size=%ld\n", bufsize);
2126 pStubMsg->BufferLength += bufsize;
2130 pStubMsg->BufferLength =
2131 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
2132 &uflag, pStubMsg->BufferLength, pMemory);
2135 /***********************************************************************
2136 * NdrUserMarshalMemorySize [RPCRT4.@]
2138 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2139 PFORMAT_STRING pFormat)
2141 unsigned index = *(const WORD*)&pFormat[2];
2142 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2143 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2144 TRACE("index=%d\n", index);
2149 /***********************************************************************
2150 * NdrUserMarshalFree [RPCRT4.@]
2152 void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
2153 unsigned char *pMemory,
2154 PFORMAT_STRING pFormat)
2156 /* unsigned flags = pFormat[1]; */
2157 unsigned index = *(const WORD*)&pFormat[2];
2158 unsigned long uflag = UserMarshalFlags(pStubMsg);
2159 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2160 TRACE("index=%d\n", index);
2162 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
2166 /***********************************************************************
2167 * NdrClearOutParameters [RPCRT4.@]
2169 void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
2170 PFORMAT_STRING pFormat,
2173 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
2176 /***********************************************************************
2177 * NdrConvert [RPCRT4.@]
2179 void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
2181 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
2182 /* FIXME: since this stub doesn't do any converting, the proper behavior
2183 is to raise an exception */
2186 /***********************************************************************
2187 * NdrConvert2 [RPCRT4.@]
2189 void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams )
2191 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2192 pStubMsg, pFormat, NumberParams);
2193 /* FIXME: since this stub doesn't do any converting, the proper behavior
2194 is to raise an exception */
2197 /***********************************************************************
2198 * NdrConformantStructMarshall [RPCRT4.@]
2200 unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2201 unsigned char *pMemory,
2202 PFORMAT_STRING pFormat)
2208 /***********************************************************************
2209 * NdrConformantStructUnmarshall [RPCRT4.@]
2211 unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2212 unsigned char **ppMemory,
2213 PFORMAT_STRING pFormat,
2214 unsigned char fMustAlloc)
2220 /***********************************************************************
2221 * NdrConformantStructBufferSize [RPCRT4.@]
2223 void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2224 unsigned char *pMemory,
2225 PFORMAT_STRING pFormat)
2230 /***********************************************************************
2231 * NdrConformantStructMemorySize [RPCRT4.@]
2233 unsigned long WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2234 PFORMAT_STRING pFormat)
2240 /***********************************************************************
2241 * NdrConformantStructFree [RPCRT4.@]
2243 void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2244 unsigned char *pMemory,
2245 PFORMAT_STRING pFormat)
2250 /***********************************************************************
2251 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2253 unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2254 unsigned char *pMemory,
2255 PFORMAT_STRING pFormat)
2261 /***********************************************************************
2262 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2264 unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2265 unsigned char **ppMemory,
2266 PFORMAT_STRING pFormat,
2267 unsigned char fMustAlloc)
2273 /***********************************************************************
2274 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2276 void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2277 unsigned char *pMemory,
2278 PFORMAT_STRING pFormat)
2283 /***********************************************************************
2284 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2286 unsigned long WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2287 PFORMAT_STRING pFormat)
2293 /***********************************************************************
2294 * NdrConformantVaryingStructFree [RPCRT4.@]
2296 void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2297 unsigned char *pMemory,
2298 PFORMAT_STRING pFormat)
2303 /***********************************************************************
2304 * NdrFixedArrayMarshall [RPCRT4.@]
2306 unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2307 unsigned char *pMemory,
2308 PFORMAT_STRING pFormat)
2314 /***********************************************************************
2315 * NdrFixedArrayUnmarshall [RPCRT4.@]
2317 unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2318 unsigned char **ppMemory,
2319 PFORMAT_STRING pFormat,
2320 unsigned char fMustAlloc)
2326 /***********************************************************************
2327 * NdrFixedArrayBufferSize [RPCRT4.@]
2329 void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2330 unsigned char *pMemory,
2331 PFORMAT_STRING pFormat)
2336 /***********************************************************************
2337 * NdrFixedArrayMemorySize [RPCRT4.@]
2339 unsigned long WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2340 PFORMAT_STRING pFormat)
2346 /***********************************************************************
2347 * NdrFixedArrayFree [RPCRT4.@]
2349 void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2350 unsigned char *pMemory,
2351 PFORMAT_STRING pFormat)
2356 /***********************************************************************
2357 * NdrVaryingArrayMarshall [RPCRT4.@]
2359 unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2360 unsigned char *pMemory,
2361 PFORMAT_STRING pFormat)
2367 /***********************************************************************
2368 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2370 unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2371 unsigned char **ppMemory,
2372 PFORMAT_STRING pFormat,
2373 unsigned char fMustAlloc)
2379 /***********************************************************************
2380 * NdrVaryingArrayBufferSize [RPCRT4.@]
2382 void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2383 unsigned char *pMemory,
2384 PFORMAT_STRING pFormat)
2389 /***********************************************************************
2390 * NdrVaryingArrayMemorySize [RPCRT4.@]
2392 unsigned long WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2393 PFORMAT_STRING pFormat)
2399 /***********************************************************************
2400 * NdrVaryingArrayFree [RPCRT4.@]
2402 void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2403 unsigned char *pMemory,
2404 PFORMAT_STRING pFormat)
2409 /***********************************************************************
2410 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2412 unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2413 unsigned char *pMemory,
2414 PFORMAT_STRING pFormat)
2420 /***********************************************************************
2421 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2423 unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2424 unsigned char **ppMemory,
2425 PFORMAT_STRING pFormat,
2426 unsigned char fMustAlloc)
2432 /***********************************************************************
2433 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2435 void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2436 unsigned char *pMemory,
2437 PFORMAT_STRING pFormat)
2442 /***********************************************************************
2443 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2445 unsigned long WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2446 PFORMAT_STRING pFormat)
2452 /***********************************************************************
2453 * NdrEncapsulatedUnionFree [RPCRT4.@]
2455 void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2456 unsigned char *pMemory,
2457 PFORMAT_STRING pFormat)
2462 /***********************************************************************
2463 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2465 unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2466 unsigned char *pMemory,
2467 PFORMAT_STRING pFormat)
2473 /***********************************************************************
2474 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2476 unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2477 unsigned char **ppMemory,
2478 PFORMAT_STRING pFormat,
2479 unsigned char fMustAlloc)
2485 /***********************************************************************
2486 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2488 void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2489 unsigned char *pMemory,
2490 PFORMAT_STRING pFormat)
2495 /***********************************************************************
2496 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2498 unsigned long WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2499 PFORMAT_STRING pFormat)
2505 /***********************************************************************
2506 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2508 void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2509 unsigned char *pMemory,
2510 PFORMAT_STRING pFormat)
2515 /***********************************************************************
2516 * NdrByteCountPointerMarshall [RPCRT4.@]
2518 unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2519 unsigned char *pMemory,
2520 PFORMAT_STRING pFormat)
2526 /***********************************************************************
2527 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2529 unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2530 unsigned char **ppMemory,
2531 PFORMAT_STRING pFormat,
2532 unsigned char fMustAlloc)
2538 /***********************************************************************
2539 * NdrByteCountPointerBufferSize [RPCRT4.@]
2541 void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2542 unsigned char *pMemory,
2543 PFORMAT_STRING pFormat)
2548 /***********************************************************************
2549 * NdrByteCountPointerMemorySize [RPCRT4.@]
2551 unsigned long WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2552 PFORMAT_STRING pFormat)
2558 /***********************************************************************
2559 * NdrByteCountPointerFree [RPCRT4.@]
2561 void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
2562 unsigned char *pMemory,
2563 PFORMAT_STRING pFormat)
2568 /***********************************************************************
2569 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2571 unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2572 unsigned char *pMemory,
2573 PFORMAT_STRING pFormat)
2579 /***********************************************************************
2580 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2582 unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2583 unsigned char **ppMemory,
2584 PFORMAT_STRING pFormat,
2585 unsigned char fMustAlloc)
2591 /***********************************************************************
2592 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2594 void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2595 unsigned char *pMemory,
2596 PFORMAT_STRING pFormat)
2601 /***********************************************************************
2602 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2604 unsigned long WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2605 PFORMAT_STRING pFormat)
2611 /***********************************************************************
2612 * NdrXmitOrRepAsFree [RPCRT4.@]
2614 void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
2615 unsigned char *pMemory,
2616 PFORMAT_STRING pFormat)
2621 /***********************************************************************
2622 * NdrClientContextMarshall
2624 unsigned char * WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2625 NDR_CCONTEXT ContextHandle,
2628 FIXME("(%p, %p, %d): stub\n", pStubMsg, ContextHandle, fCheck);
2632 /***********************************************************************
2633 * NdrClientContextUnmarshall
2635 unsigned char * WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2636 NDR_CCONTEXT * pContextHandle,
2637 RPC_BINDING_HANDLE BindHandle)
2639 FIXME("(%p, %p, %p): stub\n", pStubMsg, pContextHandle, BindHandle);