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
,
129 NdrNonConformantStringMarshall
, 0, 0, 0,
131 NdrEncapsulatedUnionMarshall
,
132 NdrNonEncapsulatedUnionMarshall
,
134 NdrXmitOrRepAsMarshall
, NdrXmitOrRepAsMarshall
,
136 NdrInterfacePointerMarshall
,
139 NdrUserMarshalMarshall
141 NDR_UNMARSHALL NdrUnmarshaller
[NDR_TABLE_SIZE
] = {
142 0, 0, 0, 0, 0, 0, 0, 0,
143 0, 0, 0, 0, 0, 0, 0, 0,
147 NdrPointerUnmarshall
, NdrPointerUnmarshall
,
148 NdrPointerUnmarshall
, NdrPointerUnmarshall
,
150 NdrSimpleStructUnmarshall
, NdrSimpleStructUnmarshall
,
151 NdrConformantStructUnmarshall
, NdrConformantStructUnmarshall
,
152 NdrConformantVaryingStructUnmarshall
,
153 NdrComplexStructUnmarshall
,
155 NdrConformantArrayUnmarshall
,
156 NdrConformantVaryingArrayUnmarshall
,
157 NdrFixedArrayUnmarshall
, NdrFixedArrayUnmarshall
,
158 NdrVaryingArrayUnmarshall
, NdrVaryingArrayUnmarshall
,
159 NdrComplexArrayUnmarshall
,
161 NdrConformantStringUnmarshall
, 0, 0,
162 NdrConformantStringUnmarshall
,
163 NdrNonConformantStringUnmarshall
, 0, 0, 0,
165 NdrEncapsulatedUnionUnmarshall
,
166 NdrNonEncapsulatedUnionUnmarshall
,
168 NdrXmitOrRepAsUnmarshall
, NdrXmitOrRepAsUnmarshall
,
170 NdrInterfacePointerUnmarshall
,
173 NdrUserMarshalUnmarshall
175 NDR_BUFFERSIZE NdrBufferSizer
[NDR_TABLE_SIZE
] = {
176 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0,
181 NdrPointerBufferSize
, NdrPointerBufferSize
,
182 NdrPointerBufferSize
, NdrPointerBufferSize
,
184 NdrSimpleStructBufferSize
, NdrSimpleStructBufferSize
,
185 NdrConformantStructBufferSize
, NdrConformantStructBufferSize
,
186 NdrConformantVaryingStructBufferSize
,
187 NdrComplexStructBufferSize
,
189 NdrConformantArrayBufferSize
,
190 NdrConformantVaryingArrayBufferSize
,
191 NdrFixedArrayBufferSize
, NdrFixedArrayBufferSize
,
192 NdrVaryingArrayBufferSize
, NdrVaryingArrayBufferSize
,
193 NdrComplexArrayBufferSize
,
195 NdrConformantStringBufferSize
, 0, 0,
196 NdrConformantStringBufferSize
,
197 NdrNonConformantStringBufferSize
, 0, 0, 0,
199 NdrEncapsulatedUnionBufferSize
,
200 NdrNonEncapsulatedUnionBufferSize
,
202 NdrXmitOrRepAsBufferSize
, NdrXmitOrRepAsBufferSize
,
204 NdrInterfacePointerBufferSize
,
207 NdrUserMarshalBufferSize
209 NDR_MEMORYSIZE NdrMemorySizer
[NDR_TABLE_SIZE
] = {
210 0, 0, 0, 0, 0, 0, 0, 0,
211 0, 0, 0, 0, 0, 0, 0, 0,
215 NdrPointerMemorySize
, NdrPointerMemorySize
,
216 NdrPointerMemorySize
, NdrPointerMemorySize
,
218 NdrSimpleStructMemorySize
, NdrSimpleStructMemorySize
,
220 NdrComplexStructMemorySize
,
222 NdrConformantArrayMemorySize
, 0, 0, 0, 0, 0,
223 NdrComplexArrayMemorySize
,
225 NdrConformantStringMemorySize
, 0, 0,
226 NdrConformantStringMemorySize
,
227 NdrNonConformantStringMemorySize
, 0, 0, 0,
231 NdrInterfacePointerMemorySize
,
234 NdrUserMarshalMemorySize
236 NDR_FREE NdrFreer
[NDR_TABLE_SIZE
] = {
237 0, 0, 0, 0, 0, 0, 0, 0,
238 0, 0, 0, 0, 0, 0, 0, 0,
242 NdrPointerFree
, NdrPointerFree
,
243 NdrPointerFree
, NdrPointerFree
,
245 NdrSimpleStructFree
, NdrSimpleStructFree
,
246 NdrConformantStructFree
, NdrConformantStructFree
,
247 NdrConformantVaryingStructFree
,
248 NdrComplexStructFree
,
250 NdrConformantArrayFree
,
251 NdrConformantVaryingArrayFree
,
252 NdrFixedArrayFree
, NdrFixedArrayFree
,
253 NdrVaryingArrayFree
, NdrVaryingArrayFree
,
259 NdrEncapsulatedUnionFree
,
260 NdrNonEncapsulatedUnionFree
,
262 NdrXmitOrRepAsFree
, NdrXmitOrRepAsFree
,
264 NdrInterfacePointerFree
,
270 void * WINAPI
NdrAllocate(MIDL_STUB_MESSAGE
*pStubMsg
, size_t len
)
272 /* hmm, this is probably supposed to do more? */
273 return pStubMsg
->pfnAllocate(len
);
276 static void WINAPI
NdrFree(MIDL_STUB_MESSAGE
*pStubMsg
, unsigned char *Pointer
)
278 pStubMsg
->pfnFree(Pointer
);
281 PFORMAT_STRING
ReadConformance(MIDL_STUB_MESSAGE
*pStubMsg
, PFORMAT_STRING pFormat
)
283 pStubMsg
->MaxCount
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
284 pStubMsg
->Buffer
+= 4;
285 TRACE("unmarshalled conformance is %ld\n", pStubMsg
->MaxCount
);
289 PFORMAT_STRING
ComputeConformance(MIDL_STUB_MESSAGE
*pStubMsg
, unsigned char *pMemory
,
290 PFORMAT_STRING pFormat
, ULONG_PTR def
)
292 BYTE dtype
= pFormat
[0] & 0xf;
293 DWORD ofs
= (DWORD
)pFormat
[2] | ((DWORD
)pFormat
[3] << 8);
297 if (pFormat
[0] == 0xff) {
298 /* null descriptor */
299 pStubMsg
->MaxCount
= def
;
303 switch (pFormat
[0] & 0xf0) {
304 case RPC_FC_NORMAL_CONFORMANCE
:
305 TRACE("normal conformance, ofs=%ld\n", ofs
);
308 case RPC_FC_POINTER_CONFORMANCE
:
309 TRACE("pointer conformance, ofs=%ld\n", ofs
);
310 ptr
= pStubMsg
->Memory
+ ofs
;
312 case RPC_FC_TOP_LEVEL_CONFORMANCE
:
313 TRACE("toplevel conformance, ofs=%ld\n", ofs
);
314 if (pStubMsg
->StackTop
) {
315 ptr
= pStubMsg
->StackTop
+ ofs
;
318 /* -Os mode, MaxCount is already set */
322 case RPC_FC_CONSTANT_CONFORMANCE
:
323 data
= ofs
| ((DWORD
)pFormat
[1] << 16);
324 TRACE("constant conformance, val=%ld\n", data
);
325 pStubMsg
->MaxCount
= data
;
327 case RPC_FC_TOP_LEVEL_MULTID_CONFORMANCE
:
328 FIXME("toplevel multidimensional conformance, ofs=%ld\n", ofs
);
329 if (pStubMsg
->StackTop
) {
330 ptr
= pStubMsg
->StackTop
+ ofs
;
338 FIXME("unknown conformance type %x\n", pFormat
[0] & 0xf0);
341 switch (pFormat
[1]) {
342 case RPC_FC_DEREFERENCE
:
345 case RPC_FC_CALLBACK
:
346 /* ofs is index into StubDesc->apfnExprEval */
347 FIXME("handle callback\n");
362 data
= *(USHORT
*)ptr
;
371 FIXME("unknown conformance data type %x\n", dtype
);
374 TRACE("dereferenced data type %x at %p, got %ld\n", dtype
, ptr
, data
);
377 switch (pFormat
[1]) {
379 pStubMsg
->MaxCount
= data
;
381 case RPC_FC_DEREFERENCE
:
382 /* already handled */
385 FIXME("unknown conformance op %d\n", pFormat
[1]);
390 TRACE("resulting conformance is %ld\n", pStubMsg
->MaxCount
);
396 * NdrConformantString:
398 * What MS calls a ConformantString is, in DCE terminology,
399 * a Varying-Conformant String.
401 * maxlen: DWORD (max # of CHARTYPE characters, inclusive of '\0')
402 * offset: DWORD (actual string data begins at (offset) CHARTYPE's
403 * into unmarshalled string)
404 * length: DWORD (# of CHARTYPE characters, inclusive of '\0')
406 * data: CHARTYPE[maxlen]
408 * ], where CHARTYPE is the appropriate character type (specified externally)
412 /***********************************************************************
413 * NdrConformantStringMarshall [RPCRT4.@]
415 unsigned char *WINAPI
NdrConformantStringMarshall(MIDL_STUB_MESSAGE
*pStubMsg
,
416 unsigned char *pszMessage
, PFORMAT_STRING pFormat
)
418 unsigned long len
, esize
;
421 TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg
, pszMessage
, pFormat
);
424 if (*pFormat
== RPC_FC_C_CSTRING
) {
425 TRACE("string=%s\n", debugstr_a((char*)pszMessage
));
426 len
= strlen((char*)pszMessage
)+1;
429 else if (*pFormat
== RPC_FC_C_WSTRING
) {
430 TRACE("string=%s\n", debugstr_w((LPWSTR
)pszMessage
));
431 len
= strlenW((LPWSTR
)pszMessage
)+1;
435 ERR("Unhandled string type: %#x\n", *pFormat
);
436 /* FIXME: raise an exception. */
440 if (pFormat
[1] != RPC_FC_PAD
) {
441 FIXME("sized string format=%d\n", pFormat
[1]);
444 assert( (pStubMsg
->BufferLength
>= (len
*esize
+ 13)) && (pStubMsg
->Buffer
!= NULL
) );
446 c
= pStubMsg
->Buffer
;
448 NDR_LOCAL_UINT32_WRITE(c
, len
); /* max length: strlen + 1 (for '\0') */
449 c
+= 8; /* offset: 0 */
450 NDR_LOCAL_UINT32_WRITE(c
, len
); /* actual length: (same) */
452 memcpy(c
, pszMessage
, len
*esize
); /* the string itself */
454 pStubMsg
->Buffer
= c
;
456 STD_OVERFLOW_CHECK(pStubMsg
);
459 return NULL
; /* is this always right? */
462 /***********************************************************************
463 * NdrConformantStringBufferSize [RPCRT4.@]
465 void WINAPI
NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
466 unsigned char* pMemory
, PFORMAT_STRING pFormat
)
468 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg
, pMemory
, pFormat
);
471 if (*pFormat
== RPC_FC_C_CSTRING
) {
472 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */
473 TRACE("string=%s\n", debugstr_a((char*)pMemory
));
474 pStubMsg
->BufferLength
+= strlen((char*)pMemory
) + 13 + BUFFER_PARANOIA
;
476 else if (*pFormat
== RPC_FC_C_WSTRING
) {
477 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 2 octets for L'\0' */
478 TRACE("string=%s\n", debugstr_w((LPWSTR
)pMemory
));
479 pStubMsg
->BufferLength
+= strlenW((LPWSTR
)pMemory
)*2 + 14 + BUFFER_PARANOIA
;
482 ERR("Unhandled string type: %#x\n", *pFormat
);
483 /* FIXME: raise an exception */
486 if (pFormat
[1] != RPC_FC_PAD
) {
487 FIXME("sized string format=%d\n", pFormat
[1]);
491 /************************************************************************
492 * NdrConformantStringMemorySize [RPCRT4.@]
494 unsigned long WINAPI
NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg
,
495 PFORMAT_STRING pFormat
)
497 unsigned long rslt
= 0;
499 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg
, pFormat
);
501 assert(pStubMsg
&& pFormat
);
503 if (*pFormat
== RPC_FC_C_CSTRING
) {
504 rslt
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
); /* maxlen */
506 else if (*pFormat
== RPC_FC_C_WSTRING
) {
507 rslt
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
)*2; /* maxlen */
510 ERR("Unhandled string type: %#x\n", *pFormat
);
511 /* FIXME: raise an exception */
514 if (pFormat
[1] != RPC_FC_PAD
) {
515 FIXME("sized string format=%d\n", pFormat
[1]);
518 TRACE(" --> %lu\n", rslt
);
522 /************************************************************************
523 * NdrConformantStringUnmarshall [RPCRT4.@]
525 unsigned char *WINAPI
NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
,
526 unsigned char** ppMemory
, PFORMAT_STRING pFormat
, unsigned char fMustAlloc
)
528 unsigned long len
, esize
, ofs
;
531 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
532 pStubMsg
, *ppMemory
, pFormat
, fMustAlloc
);
534 assert(pFormat
&& ppMemory
&& pStubMsg
);
536 pStubMsg
->Buffer
+= 4;
537 ofs
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
538 pStubMsg
->Buffer
+= 4;
539 len
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
540 pStubMsg
->Buffer
+= 4;
542 if (*pFormat
== RPC_FC_C_CSTRING
) esize
= 1;
543 else if (*pFormat
== RPC_FC_C_WSTRING
) esize
= 2;
545 ERR("Unhandled string type: %#x\n", *pFormat
);
546 /* FIXME: raise an exception */
550 if (pFormat
[1] != RPC_FC_PAD
) {
551 FIXME("sized string format=%d\n", pFormat
[1]);
555 *ppMemory
= NdrAllocate(pStubMsg
, len
*esize
+ BUFFER_PARANOIA
);
557 if (pStubMsg
->ReuseBuffer
&& !*ppMemory
)
558 /* for servers, we may just point straight into the RPC buffer, I think
559 * (I guess that's what MS does since MIDL code doesn't try to free) */
560 *ppMemory
= pStubMsg
->Buffer
- ofs
*esize
;
561 /* for clients, memory should be provided by caller */
564 pMem
= *ppMemory
+ ofs
*esize
;
566 if (pMem
!= pStubMsg
->Buffer
)
567 memcpy(pMem
, pStubMsg
->Buffer
, len
*esize
);
569 pStubMsg
->Buffer
+= len
*esize
;
571 if (*pFormat
== RPC_FC_C_CSTRING
) {
572 TRACE("string=%s\n", debugstr_a((char*)pMem
));
574 else if (*pFormat
== RPC_FC_C_WSTRING
) {
575 TRACE("string=%s\n", debugstr_w((LPWSTR
)pMem
));
578 return NULL
; /* FIXME: is this always right? */
581 /***********************************************************************
582 * NdrNonConformantStringMarshall [RPCRT4.@]
584 unsigned char * WINAPI
NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
585 unsigned char *pMemory
,
586 PFORMAT_STRING pFormat
)
592 /***********************************************************************
593 * NdrNonConformantStringUnmarshall [RPCRT4.@]
595 unsigned char * WINAPI
NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
596 unsigned char **ppMemory
,
597 PFORMAT_STRING pFormat
,
598 unsigned char fMustAlloc
)
604 /***********************************************************************
605 * NdrNonConformantStringBufferSize [RPCRT4.@]
607 void WINAPI
NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
608 unsigned char *pMemory
,
609 PFORMAT_STRING pFormat
)
614 /***********************************************************************
615 * NdrNonConformantStringMemorySize [RPCRT4.@]
617 unsigned long WINAPI
NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
618 PFORMAT_STRING pFormat
)
624 static inline void dump_pointer_attr(unsigned char attr
)
626 if (attr
& RPC_FC_P_ALLOCALLNODES
)
627 TRACE(" RPC_FC_P_ALLOCALLNODES");
628 if (attr
& RPC_FC_P_DONTFREE
)
629 TRACE(" RPC_FC_P_DONTFREE");
630 if (attr
& RPC_FC_P_ONSTACK
)
631 TRACE(" RPC_FC_P_ONSTACK");
632 if (attr
& RPC_FC_P_SIMPLEPOINTER
)
633 TRACE(" RPC_FC_P_SIMPLEPOINTER");
634 if (attr
& RPC_FC_P_DEREF
)
635 TRACE(" RPC_FC_P_DEREF");
639 /***********************************************************************
642 void WINAPI
PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
643 unsigned char *Buffer
,
644 unsigned char *Pointer
,
645 PFORMAT_STRING pFormat
)
647 unsigned type
= pFormat
[0], attr
= pFormat
[1];
651 TRACE("(%p,%p,%p,%p)\n", pStubMsg
, Buffer
, Pointer
, pFormat
);
652 TRACE("type=0x%x, attr=", type
); dump_pointer_attr(attr
);
654 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
655 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
656 if (attr
& RPC_FC_P_DEREF
) {
657 Pointer
= *(unsigned char**)Pointer
;
658 TRACE("deref => %p\n", Pointer
);
662 case RPC_FC_RP
: /* ref pointer (always non-null) */
663 #if 0 /* this causes problems for InstallShield so is disabled - we need more tests */
665 RpcRaiseException(RPC_X_NULL_REF_POINTER
);
668 case RPC_FC_UP
: /* unique pointer */
669 case RPC_FC_OP
: /* object pointer - same as unique here */
670 TRACE("writing %p to buffer\n", Pointer
);
671 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, (unsigned long)Pointer
);
672 pStubMsg
->Buffer
+= 4;
676 FIXME("unhandled ptr type=%02x\n", type
);
677 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
680 TRACE("calling marshaller for type 0x%x\n", (int)*desc
);
683 m
= NdrMarshaller
[*desc
& NDR_TABLE_MASK
];
684 if (m
) m(pStubMsg
, Pointer
, desc
);
685 else FIXME("no marshaller for data type=%02x\n", *desc
);
688 STD_OVERFLOW_CHECK(pStubMsg
);
691 /***********************************************************************
694 void WINAPI
PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
695 unsigned char *Buffer
,
696 unsigned char **pPointer
,
697 PFORMAT_STRING pFormat
,
698 unsigned char fMustAlloc
)
700 unsigned type
= pFormat
[0], attr
= pFormat
[1];
703 DWORD pointer_id
= 0;
705 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg
, Buffer
, pPointer
, pFormat
, fMustAlloc
);
706 TRACE("type=0x%x, attr=", type
); dump_pointer_attr(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 pPointer
= *(unsigned char***)pPointer
;
712 TRACE("deref => %p\n", pPointer
);
716 case RPC_FC_RP
: /* ref pointer (always non-null) */
719 case RPC_FC_UP
: /* unique pointer */
720 pointer_id
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
721 pStubMsg
->Buffer
+= 4;
723 case RPC_FC_OP
: /* object pointer - we must free data before overwriting it */
724 pointer_id
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
725 pStubMsg
->Buffer
+= 4;
727 FIXME("free object pointer %p\n", *pPointer
);
731 FIXME("unhandled ptr type=%02x\n", type
);
732 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
738 m
= NdrUnmarshaller
[*desc
& NDR_TABLE_MASK
];
739 if (m
) m(pStubMsg
, pPointer
, desc
, fMustAlloc
);
740 else FIXME("no unmarshaller for data type=%02x\n", *desc
);
743 TRACE("pointer=%p\n", *pPointer
);
746 /***********************************************************************
749 void WINAPI
PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
750 unsigned char *Pointer
,
751 PFORMAT_STRING pFormat
)
753 unsigned type
= pFormat
[0], attr
= pFormat
[1];
757 TRACE("(%p,%p,%p)\n", pStubMsg
, Pointer
, pFormat
);
758 TRACE("type=%d, attr=%d\n", type
, attr
);
760 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
761 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
762 if (attr
& RPC_FC_P_DEREF
) {
763 Pointer
= *(unsigned char**)Pointer
;
764 TRACE("deref => %p\n", Pointer
);
768 case RPC_FC_RP
: /* ref pointer (always non-null) */
772 pStubMsg
->BufferLength
+= 4;
773 /* NULL pointer has no further representation */
779 FIXME("unhandled ptr type=%02x\n", type
);
780 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
783 m
= NdrBufferSizer
[*desc
& NDR_TABLE_MASK
];
784 if (m
) m(pStubMsg
, Pointer
, desc
);
785 else FIXME("no buffersizer for data type=%02x\n", *desc
);
788 /***********************************************************************
789 * PointerMemorySize [RPCRT4.@]
791 unsigned long WINAPI
PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
792 unsigned char *Buffer
,
793 PFORMAT_STRING pFormat
)
795 unsigned type
= pFormat
[0], attr
= pFormat
[1];
799 FIXME("(%p,%p,%p): stub\n", pStubMsg
, Buffer
, pFormat
);
800 TRACE("type=%d, attr=", type
); dump_pointer_attr(attr
);
802 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
803 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
804 if (attr
& RPC_FC_P_DEREF
) {
809 case RPC_FC_RP
: /* ref pointer (always non-null) */
812 FIXME("unhandled ptr type=%02x\n", type
);
813 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
816 m
= NdrMemorySizer
[*desc
& NDR_TABLE_MASK
];
817 if (m
) m(pStubMsg
, desc
);
818 else FIXME("no memorysizer for data type=%02x\n", *desc
);
823 /***********************************************************************
824 * PointerFree [RPCRT4.@]
826 void WINAPI
PointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
827 unsigned char *Pointer
,
828 PFORMAT_STRING pFormat
)
830 unsigned type
= pFormat
[0], attr
= pFormat
[1];
834 TRACE("(%p,%p,%p)\n", pStubMsg
, Pointer
, pFormat
);
835 TRACE("type=%d, attr=", type
); dump_pointer_attr(attr
);
836 if (attr
& RPC_FC_P_DONTFREE
) return;
838 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
839 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
840 if (attr
& RPC_FC_P_DEREF
) {
841 Pointer
= *(unsigned char**)Pointer
;
842 TRACE("deref => %p\n", Pointer
);
845 if (!Pointer
) return;
847 m
= NdrFreer
[*desc
& NDR_TABLE_MASK
];
848 if (m
) m(pStubMsg
, Pointer
, desc
);
850 /* hmm... is this sensible?
851 * perhaps we should check if the memory comes from NdrAllocate,
852 * and deallocate only if so - checking if the pointer is between
853 * BufferStart and BufferEnd is probably no good since the buffer
854 * may be reallocated when the server wants to marshal the reply */
856 case RPC_FC_BOGUS_STRUCT
:
857 case RPC_FC_BOGUS_ARRAY
:
858 case RPC_FC_USER_MARSHAL
:
861 FIXME("unhandled data type=%02x\n", *desc
);
863 case RPC_FC_C_CSTRING
:
864 case RPC_FC_C_WSTRING
:
865 if (pStubMsg
->ReuseBuffer
) goto notfree
;
871 if (attr
& RPC_FC_P_ONSTACK
) {
872 TRACE("not freeing stack ptr %p\n", Pointer
);
875 TRACE("freeing %p\n", Pointer
);
876 NdrFree(pStubMsg
, Pointer
);
879 TRACE("not freeing %p\n", Pointer
);
882 /***********************************************************************
883 * EmbeddedPointerMarshall
885 unsigned char * WINAPI
EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
886 unsigned char *pMemory
,
887 PFORMAT_STRING pFormat
)
889 unsigned char *Mark
= pStubMsg
->BufferMark
;
890 unsigned long Offset
= pStubMsg
->Offset
;
891 unsigned ofs
, rep
, count
, stride
, xofs
;
893 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
895 if (*pFormat
!= RPC_FC_PP
) return NULL
;
898 while (pFormat
[0] != RPC_FC_END
) {
899 switch (pFormat
[0]) {
901 FIXME("unknown repeat type %d\n", pFormat
[0]);
902 case RPC_FC_NO_REPEAT
:
910 case RPC_FC_FIXED_REPEAT
:
911 rep
= *(const WORD
*)&pFormat
[2];
912 stride
= *(const WORD
*)&pFormat
[4];
913 ofs
= *(const WORD
*)&pFormat
[6];
914 count
= *(const WORD
*)&pFormat
[8];
918 case RPC_FC_VARIABLE_REPEAT
:
919 rep
= pStubMsg
->MaxCount
;
920 stride
= *(const WORD
*)&pFormat
[2];
921 ofs
= *(const WORD
*)&pFormat
[4];
922 count
= *(const WORD
*)&pFormat
[6];
923 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
927 /* ofs doesn't seem to matter in this context */
929 PFORMAT_STRING info
= pFormat
;
930 unsigned char *membase
= pMemory
+ xofs
;
932 for (u
=0; u
<count
; u
++,info
+=8) {
933 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
934 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
935 PointerMarshall(pStubMsg
, bufptr
, *(unsigned char**)memptr
, info
+4);
939 pFormat
+= 8 * count
;
942 STD_OVERFLOW_CHECK(pStubMsg
);
947 /***********************************************************************
948 * EmbeddedPointerUnmarshall
950 unsigned char * WINAPI
EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
951 unsigned char **ppMemory
,
952 PFORMAT_STRING pFormat
,
953 unsigned char fMustAlloc
)
955 unsigned char *Mark
= pStubMsg
->BufferMark
;
956 unsigned long Offset
= pStubMsg
->Offset
;
957 unsigned ofs
, rep
, count
, stride
, xofs
;
959 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
961 if (*pFormat
!= RPC_FC_PP
) return NULL
;
964 while (pFormat
[0] != RPC_FC_END
) {
965 switch (pFormat
[0]) {
967 FIXME("unknown repeat type %d\n", pFormat
[0]);
968 case RPC_FC_NO_REPEAT
:
976 case RPC_FC_FIXED_REPEAT
:
977 rep
= *(const WORD
*)&pFormat
[2];
978 stride
= *(const WORD
*)&pFormat
[4];
979 ofs
= *(const WORD
*)&pFormat
[6];
980 count
= *(const WORD
*)&pFormat
[8];
984 case RPC_FC_VARIABLE_REPEAT
:
985 rep
= pStubMsg
->MaxCount
;
986 stride
= *(const WORD
*)&pFormat
[2];
987 ofs
= *(const WORD
*)&pFormat
[4];
988 count
= *(const WORD
*)&pFormat
[6];
989 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
993 /* ofs doesn't seem to matter in this context */
995 PFORMAT_STRING info
= pFormat
;
996 unsigned char *membase
= *ppMemory
+ xofs
;
998 for (u
=0; u
<count
; u
++,info
+=8) {
999 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
1000 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
1001 PointerUnmarshall(pStubMsg
, bufptr
, (unsigned char**)memptr
, info
+4, fMustAlloc
);
1005 pFormat
+= 8 * count
;
1011 /***********************************************************************
1012 * EmbeddedPointerBufferSize
1014 void WINAPI
EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1015 unsigned char *pMemory
,
1016 PFORMAT_STRING pFormat
)
1018 unsigned long Offset
= pStubMsg
->Offset
;
1019 unsigned ofs
, rep
, count
, stride
, xofs
;
1021 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1022 if (*pFormat
!= RPC_FC_PP
) return;
1025 while (pFormat
[0] != RPC_FC_END
) {
1026 switch (pFormat
[0]) {
1028 FIXME("unknown repeat type %d\n", pFormat
[0]);
1029 case RPC_FC_NO_REPEAT
:
1037 case RPC_FC_FIXED_REPEAT
:
1038 rep
= *(const WORD
*)&pFormat
[2];
1039 stride
= *(const WORD
*)&pFormat
[4];
1040 ofs
= *(const WORD
*)&pFormat
[6];
1041 count
= *(const WORD
*)&pFormat
[8];
1045 case RPC_FC_VARIABLE_REPEAT
:
1046 rep
= pStubMsg
->MaxCount
;
1047 stride
= *(const WORD
*)&pFormat
[2];
1048 ofs
= *(const WORD
*)&pFormat
[4];
1049 count
= *(const WORD
*)&pFormat
[6];
1050 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1054 /* ofs doesn't seem to matter in this context */
1056 PFORMAT_STRING info
= pFormat
;
1057 unsigned char *membase
= pMemory
+ xofs
;
1059 for (u
=0; u
<count
; u
++,info
+=8) {
1060 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
1061 PointerBufferSize(pStubMsg
, *(unsigned char**)memptr
, info
+4);
1065 pFormat
+= 8 * count
;
1069 /***********************************************************************
1070 * EmbeddedPointerMemorySize
1072 unsigned long WINAPI
EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1073 PFORMAT_STRING pFormat
)
1075 unsigned long Offset
= pStubMsg
->Offset
;
1076 unsigned char *Mark
= pStubMsg
->BufferMark
;
1077 unsigned ofs
, rep
, count
, stride
, xofs
;
1079 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1080 if (*pFormat
!= RPC_FC_PP
) return 0;
1083 while (pFormat
[0] != RPC_FC_END
) {
1084 switch (pFormat
[0]) {
1086 FIXME("unknown repeat type %d\n", pFormat
[0]);
1087 case RPC_FC_NO_REPEAT
:
1095 case RPC_FC_FIXED_REPEAT
:
1096 rep
= *(const WORD
*)&pFormat
[2];
1097 stride
= *(const WORD
*)&pFormat
[4];
1098 ofs
= *(const WORD
*)&pFormat
[6];
1099 count
= *(const WORD
*)&pFormat
[8];
1103 case RPC_FC_VARIABLE_REPEAT
:
1104 rep
= pStubMsg
->MaxCount
;
1105 stride
= *(const WORD
*)&pFormat
[2];
1106 ofs
= *(const WORD
*)&pFormat
[4];
1107 count
= *(const WORD
*)&pFormat
[6];
1108 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1112 /* ofs doesn't seem to matter in this context */
1114 PFORMAT_STRING info
= pFormat
;
1116 for (u
=0; u
<count
; u
++,info
+=8) {
1117 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
1118 PointerMemorySize(pStubMsg
, bufptr
, info
+4);
1122 pFormat
+= 8 * count
;
1128 /***********************************************************************
1129 * EmbeddedPointerFree
1131 void WINAPI
EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
1132 unsigned char *pMemory
,
1133 PFORMAT_STRING pFormat
)
1135 unsigned long Offset
= pStubMsg
->Offset
;
1136 unsigned ofs
, rep
, count
, stride
, xofs
;
1138 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1139 if (*pFormat
!= RPC_FC_PP
) return;
1142 while (pFormat
[0] != RPC_FC_END
) {
1143 switch (pFormat
[0]) {
1145 FIXME("unknown repeat type %d\n", pFormat
[0]);
1146 case RPC_FC_NO_REPEAT
:
1154 case RPC_FC_FIXED_REPEAT
:
1155 rep
= *(const WORD
*)&pFormat
[2];
1156 stride
= *(const WORD
*)&pFormat
[4];
1157 ofs
= *(const WORD
*)&pFormat
[6];
1158 count
= *(const WORD
*)&pFormat
[8];
1162 case RPC_FC_VARIABLE_REPEAT
:
1163 rep
= pStubMsg
->MaxCount
;
1164 stride
= *(const WORD
*)&pFormat
[2];
1165 ofs
= *(const WORD
*)&pFormat
[4];
1166 count
= *(const WORD
*)&pFormat
[6];
1167 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1171 /* ofs doesn't seem to matter in this context */
1173 PFORMAT_STRING info
= pFormat
;
1174 unsigned char *membase
= pMemory
+ xofs
;
1176 for (u
=0; u
<count
; u
++,info
+=8) {
1177 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
1178 PointerFree(pStubMsg
, *(unsigned char**)memptr
, info
+4);
1182 pFormat
+= 8 * count
;
1186 /***********************************************************************
1187 * NdrPointerMarshall [RPCRT4.@]
1189 unsigned char * WINAPI
NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1190 unsigned char *pMemory
,
1191 PFORMAT_STRING pFormat
)
1193 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1195 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1196 PointerMarshall(pStubMsg
, pStubMsg
->Buffer
, pMemory
, pFormat
);
1198 STD_OVERFLOW_CHECK(pStubMsg
);
1203 /***********************************************************************
1204 * NdrPointerUnmarshall [RPCRT4.@]
1206 unsigned char * WINAPI
NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1207 unsigned char **ppMemory
,
1208 PFORMAT_STRING pFormat
,
1209 unsigned char fMustAlloc
)
1211 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1213 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1214 PointerUnmarshall(pStubMsg
, pStubMsg
->Buffer
, ppMemory
, pFormat
, fMustAlloc
);
1219 /***********************************************************************
1220 * NdrPointerBufferSize [RPCRT4.@]
1222 void WINAPI
NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1223 unsigned char *pMemory
,
1224 PFORMAT_STRING pFormat
)
1226 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1227 PointerBufferSize(pStubMsg
, pMemory
, pFormat
);
1230 /***********************************************************************
1231 * NdrPointerMemorySize [RPCRT4.@]
1233 unsigned long WINAPI
NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1234 PFORMAT_STRING pFormat
)
1236 /* unsigned size = *(LPWORD)(pFormat+2); */
1237 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1238 PointerMemorySize(pStubMsg
, pStubMsg
->Buffer
, pFormat
);
1242 /***********************************************************************
1243 * NdrPointerFree [RPCRT4.@]
1245 void WINAPI
NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
1246 unsigned char *pMemory
,
1247 PFORMAT_STRING pFormat
)
1249 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1250 PointerFree(pStubMsg
, pMemory
, pFormat
);
1253 /***********************************************************************
1254 * NdrSimpleStructMarshall [RPCRT4.@]
1256 unsigned char * WINAPI
NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1257 unsigned char *pMemory
,
1258 PFORMAT_STRING pFormat
)
1260 unsigned size
= *(const WORD
*)(pFormat
+2);
1261 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1263 memcpy(pStubMsg
->Buffer
, pMemory
, size
);
1264 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1265 pStubMsg
->Buffer
+= size
;
1267 if (pFormat
[0] != RPC_FC_STRUCT
)
1268 EmbeddedPointerMarshall(pStubMsg
, pMemory
, pFormat
+4);
1270 STD_OVERFLOW_CHECK(pStubMsg
);
1275 /***********************************************************************
1276 * NdrSimpleStructUnmarshall [RPCRT4.@]
1278 unsigned char * WINAPI
NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1279 unsigned char **ppMemory
,
1280 PFORMAT_STRING pFormat
,
1281 unsigned char fMustAlloc
)
1283 unsigned size
= *(const WORD
*)(pFormat
+2);
1284 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1287 *ppMemory
= NdrAllocate(pStubMsg
, size
);
1288 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
);
1290 if (pStubMsg
->ReuseBuffer
&& !*ppMemory
)
1291 /* for servers, we may just point straight into the RPC buffer, I think
1292 * (I guess that's what MS does since MIDL code doesn't try to free) */
1293 *ppMemory
= pStubMsg
->Buffer
;
1295 /* for clients, memory should be provided by caller */
1296 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
);
1299 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1300 pStubMsg
->Buffer
+= size
;
1302 if (pFormat
[0] != RPC_FC_STRUCT
)
1303 EmbeddedPointerUnmarshall(pStubMsg
, ppMemory
, pFormat
+4, fMustAlloc
);
1309 /***********************************************************************
1310 * NdrSimpleStructUnmarshall [RPCRT4.@]
1312 void WINAPI
NdrSimpleTypeMarshall( PMIDL_STUB_MESSAGE pStubMsg
, unsigned char* pMemory
,
1313 unsigned char FormatChar
)
1319 /***********************************************************************
1320 * NdrSimpleStructUnmarshall [RPCRT4.@]
1322 void WINAPI
NdrSimpleTypeUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
, unsigned char* pMemory
,
1323 unsigned char FormatChar
)
1329 /***********************************************************************
1330 * NdrSimpleStructBufferSize [RPCRT4.@]
1332 void WINAPI
NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1333 unsigned char *pMemory
,
1334 PFORMAT_STRING pFormat
)
1336 unsigned size
= *(const WORD
*)(pFormat
+2);
1337 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1338 pStubMsg
->BufferLength
+= size
;
1339 if (pFormat
[0] != RPC_FC_STRUCT
)
1340 EmbeddedPointerBufferSize(pStubMsg
, pMemory
, pFormat
+4);
1343 /***********************************************************************
1344 * NdrSimpleStructMemorySize [RPCRT4.@]
1346 unsigned long WINAPI
NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1347 PFORMAT_STRING pFormat
)
1349 /* unsigned size = *(LPWORD)(pFormat+2); */
1350 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1351 if (pFormat
[0] != RPC_FC_STRUCT
)
1352 EmbeddedPointerMemorySize(pStubMsg
, pFormat
+4);
1356 /***********************************************************************
1357 * NdrSimpleStructFree [RPCRT4.@]
1359 void WINAPI
NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
1360 unsigned char *pMemory
,
1361 PFORMAT_STRING pFormat
)
1363 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1364 if (pFormat
[0] != RPC_FC_STRUCT
)
1365 EmbeddedPointerFree(pStubMsg
, pMemory
, pFormat
+4);
1369 unsigned long WINAPI
EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg
,
1370 PFORMAT_STRING pFormat
)
1374 case RPC_FC_PSTRUCT
:
1375 case RPC_FC_CSTRUCT
:
1376 case RPC_FC_BOGUS_STRUCT
:
1377 return *(const WORD
*)&pFormat
[2];
1378 case RPC_FC_USER_MARSHAL
:
1379 return *(const WORD
*)&pFormat
[4];
1381 FIXME("unhandled embedded type %02x\n", *pFormat
);
1387 unsigned char * WINAPI
ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1388 unsigned char *pMemory
,
1389 PFORMAT_STRING pFormat
,
1390 PFORMAT_STRING pPointer
)
1392 PFORMAT_STRING desc
;
1396 while (*pFormat
!= RPC_FC_END
) {
1400 TRACE("short=%d <= %p\n", *(WORD
*)pMemory
, pMemory
);
1401 memcpy(pStubMsg
->Buffer
, pMemory
, 2);
1402 pStubMsg
->Buffer
+= 2;
1407 TRACE("long=%ld <= %p\n", *(DWORD
*)pMemory
, pMemory
);
1408 memcpy(pStubMsg
->Buffer
, pMemory
, 4);
1409 pStubMsg
->Buffer
+= 4;
1412 case RPC_FC_POINTER
:
1413 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory
, pMemory
);
1414 NdrPointerMarshall(pStubMsg
, *(unsigned char**)pMemory
, pPointer
);
1418 case RPC_FC_ALIGNM4
:
1419 ALIGN_POINTER(pMemory
, 3);
1421 case RPC_FC_ALIGNM8
:
1422 ALIGN_POINTER(pMemory
, 7);
1424 case RPC_FC_EMBEDDED_COMPLEX
:
1425 pMemory
+= pFormat
[1];
1427 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1428 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1429 TRACE("embedded complex (size=%ld) <= %p\n", size
, pMemory
);
1430 m
= NdrMarshaller
[*desc
& NDR_TABLE_MASK
];
1431 if (m
) m(pStubMsg
, pMemory
, desc
);
1432 else FIXME("no marshaller for embedded type %02x\n", *desc
);
1439 FIXME("unhandled format %02x\n", *pFormat
);
1447 unsigned char * WINAPI
ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1448 unsigned char *pMemory
,
1449 PFORMAT_STRING pFormat
,
1450 PFORMAT_STRING pPointer
,
1451 unsigned char fMustAlloc
)
1453 PFORMAT_STRING desc
;
1457 while (*pFormat
!= RPC_FC_END
) {
1461 memcpy(pMemory
, pStubMsg
->Buffer
, 2);
1462 TRACE("short=%d => %p\n", *(WORD
*)pMemory
, pMemory
);
1463 pStubMsg
->Buffer
+= 2;
1468 memcpy(pMemory
, pStubMsg
->Buffer
, 4);
1469 TRACE("long=%ld => %p\n", *(DWORD
*)pMemory
, pMemory
);
1470 pStubMsg
->Buffer
+= 4;
1473 case RPC_FC_POINTER
:
1474 *(unsigned char**)pMemory
= NULL
;
1475 TRACE("pointer => %p\n", pMemory
);
1476 NdrPointerUnmarshall(pStubMsg
, (unsigned char**)pMemory
, pPointer
, fMustAlloc
);
1480 case RPC_FC_ALIGNM4
:
1481 ALIGN_POINTER(pMemory
, 3);
1483 case RPC_FC_ALIGNM8
:
1484 ALIGN_POINTER(pMemory
, 7);
1486 case RPC_FC_EMBEDDED_COMPLEX
:
1487 pMemory
+= pFormat
[1];
1489 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1490 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1491 TRACE("embedded complex (size=%ld) => %p\n", size
, pMemory
);
1492 m
= NdrUnmarshaller
[*desc
& NDR_TABLE_MASK
];
1493 memset(pMemory
, 0, size
); /* just in case */
1494 if (m
) m(pStubMsg
, &pMemory
, desc
, fMustAlloc
);
1495 else FIXME("no unmarshaller for embedded type %02x\n", *desc
);
1502 FIXME("unhandled format %d\n", *pFormat
);
1510 unsigned char * WINAPI
ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1511 unsigned char *pMemory
,
1512 PFORMAT_STRING pFormat
,
1513 PFORMAT_STRING pPointer
)
1515 PFORMAT_STRING desc
;
1519 while (*pFormat
!= RPC_FC_END
) {
1523 pStubMsg
->BufferLength
+= 2;
1528 pStubMsg
->BufferLength
+= 4;
1531 case RPC_FC_POINTER
:
1532 NdrPointerBufferSize(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
= NdrBufferSizer
[*desc
& NDR_TABLE_MASK
];
1548 if (m
) m(pStubMsg
, pMemory
, desc
);
1549 else FIXME("no buffersizer for embedded type %02x\n", *desc
);
1556 FIXME("unhandled format %d\n", *pFormat
);
1564 unsigned char * WINAPI
ComplexFree(PMIDL_STUB_MESSAGE pStubMsg
,
1565 unsigned char *pMemory
,
1566 PFORMAT_STRING pFormat
,
1567 PFORMAT_STRING pPointer
)
1569 PFORMAT_STRING desc
;
1573 while (*pFormat
!= RPC_FC_END
) {
1583 case RPC_FC_POINTER
:
1584 NdrPointerFree(pStubMsg
, *(unsigned char**)pMemory
, pPointer
);
1588 case RPC_FC_ALIGNM4
:
1589 ALIGN_POINTER(pMemory
, 3);
1591 case RPC_FC_ALIGNM8
:
1592 ALIGN_POINTER(pMemory
, 7);
1594 case RPC_FC_EMBEDDED_COMPLEX
:
1595 pMemory
+= pFormat
[1];
1597 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1598 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1599 m
= NdrFreer
[*desc
& NDR_TABLE_MASK
];
1600 if (m
) m(pStubMsg
, pMemory
, desc
);
1601 else FIXME("no freer for embedded type %02x\n", *desc
);
1608 FIXME("unhandled format %d\n", *pFormat
);
1616 unsigned long WINAPI
ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg
,
1617 PFORMAT_STRING pFormat
)
1619 PFORMAT_STRING desc
;
1620 unsigned long size
= 0;
1622 while (*pFormat
!= RPC_FC_END
) {
1632 case RPC_FC_POINTER
:
1635 case RPC_FC_ALIGNM4
:
1636 ALIGN_LENGTH(size
, 3);
1638 case RPC_FC_ALIGNM8
:
1639 ALIGN_LENGTH(size
, 7);
1641 case RPC_FC_EMBEDDED_COMPLEX
:
1644 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1645 size
+= EmbeddedComplexSize(pStubMsg
, desc
);
1651 FIXME("unhandled format %d\n", *pFormat
);
1659 /***********************************************************************
1660 * NdrComplexStructMarshall [RPCRT4.@]
1662 unsigned char * WINAPI
NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1663 unsigned char *pMemory
,
1664 PFORMAT_STRING pFormat
)
1666 PFORMAT_STRING conf_array
= NULL
;
1667 PFORMAT_STRING pointer_desc
= NULL
;
1668 unsigned char *OldMemory
= pStubMsg
->Memory
;
1670 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1673 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1675 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1678 pStubMsg
->Memory
= pMemory
;
1680 ComplexMarshall(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1683 NdrConformantArrayMarshall(pStubMsg
, pMemory
, conf_array
);
1685 pStubMsg
->Memory
= OldMemory
;
1687 STD_OVERFLOW_CHECK(pStubMsg
);
1692 /***********************************************************************
1693 * NdrComplexStructUnmarshall [RPCRT4.@]
1695 unsigned char * WINAPI
NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1696 unsigned char **ppMemory
,
1697 PFORMAT_STRING pFormat
,
1698 unsigned char fMustAlloc
)
1700 unsigned size
= *(const WORD
*)(pFormat
+2);
1701 PFORMAT_STRING conf_array
= NULL
;
1702 PFORMAT_STRING pointer_desc
= NULL
;
1703 unsigned char *pMemory
;
1705 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1707 if (fMustAlloc
|| !*ppMemory
)
1708 *ppMemory
= NdrAllocate(pStubMsg
, size
);
1711 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1713 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1716 pMemory
= ComplexUnmarshall(pStubMsg
, *ppMemory
, pFormat
, pointer_desc
, fMustAlloc
);
1719 NdrConformantArrayUnmarshall(pStubMsg
, &pMemory
, conf_array
, fMustAlloc
);
1724 /***********************************************************************
1725 * NdrComplexStructBufferSize [RPCRT4.@]
1727 void WINAPI
NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1728 unsigned char *pMemory
,
1729 PFORMAT_STRING pFormat
)
1731 PFORMAT_STRING conf_array
= NULL
;
1732 PFORMAT_STRING pointer_desc
= NULL
;
1733 unsigned char *OldMemory
= pStubMsg
->Memory
;
1735 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1738 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1740 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1743 pStubMsg
->Memory
= pMemory
;
1745 pMemory
= ComplexBufferSize(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1748 NdrConformantArrayBufferSize(pStubMsg
, pMemory
, conf_array
);
1750 pStubMsg
->Memory
= OldMemory
;
1753 /***********************************************************************
1754 * NdrComplexStructMemorySize [RPCRT4.@]
1756 unsigned long WINAPI
NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1757 PFORMAT_STRING pFormat
)
1759 /* unsigned size = *(LPWORD)(pFormat+2); */
1760 PFORMAT_STRING conf_array
= NULL
;
1761 PFORMAT_STRING pointer_desc
= NULL
;
1763 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1766 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1768 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1774 /***********************************************************************
1775 * NdrComplexStructFree [RPCRT4.@]
1777 void WINAPI
NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
1778 unsigned char *pMemory
,
1779 PFORMAT_STRING pFormat
)
1781 PFORMAT_STRING conf_array
= NULL
;
1782 PFORMAT_STRING pointer_desc
= NULL
;
1783 unsigned char *OldMemory
= pStubMsg
->Memory
;
1785 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1788 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1790 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1793 pStubMsg
->Memory
= pMemory
;
1795 pMemory
= ComplexFree(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1798 NdrConformantArrayFree(pStubMsg
, pMemory
, conf_array
);
1800 pStubMsg
->Memory
= OldMemory
;
1803 /***********************************************************************
1804 * NdrConformantArrayMarshall [RPCRT4.@]
1806 unsigned char * WINAPI
NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1807 unsigned char *pMemory
,
1808 PFORMAT_STRING pFormat
)
1810 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1811 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1812 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1814 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
+4, 0);
1815 size
= pStubMsg
->MaxCount
;
1817 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, size
);
1818 pStubMsg
->Buffer
+= 4;
1820 memcpy(pStubMsg
->Buffer
, pMemory
, size
*esize
);
1821 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1822 pStubMsg
->Buffer
+= size
*esize
;
1824 EmbeddedPointerMarshall(pStubMsg
, pMemory
, pFormat
);
1826 STD_OVERFLOW_CHECK(pStubMsg
);
1831 /***********************************************************************
1832 * NdrConformantArrayUnmarshall [RPCRT4.@]
1834 unsigned char * WINAPI
NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1835 unsigned char **ppMemory
,
1836 PFORMAT_STRING pFormat
,
1837 unsigned char fMustAlloc
)
1839 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1840 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1841 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1843 pFormat
= ReadConformance(pStubMsg
, pFormat
+4);
1844 size
= pStubMsg
->MaxCount
;
1846 if (fMustAlloc
|| !*ppMemory
)
1847 *ppMemory
= NdrAllocate(pStubMsg
, size
*esize
);
1849 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
*esize
);
1851 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1852 pStubMsg
->Buffer
+= size
*esize
;
1854 EmbeddedPointerUnmarshall(pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1859 /***********************************************************************
1860 * NdrConformantArrayBufferSize [RPCRT4.@]
1862 void WINAPI
NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1863 unsigned char *pMemory
,
1864 PFORMAT_STRING pFormat
)
1866 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1867 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1868 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1870 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
+4, 0);
1871 size
= pStubMsg
->MaxCount
;
1873 pStubMsg
->BufferLength
+= size
*esize
;
1875 EmbeddedPointerBufferSize(pStubMsg
, pMemory
, pFormat
);
1878 /***********************************************************************
1879 * NdrConformantArrayMemorySize [RPCRT4.@]
1881 unsigned long WINAPI
NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1882 PFORMAT_STRING pFormat
)
1885 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1886 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1888 pFormat
= ReadConformance(pStubMsg
, pFormat
+4);
1889 size
= pStubMsg
->MaxCount
;
1891 EmbeddedPointerMemorySize(pStubMsg
, pFormat
);
1896 /***********************************************************************
1897 * NdrConformantArrayFree [RPCRT4.@]
1899 void WINAPI
NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
1900 unsigned char *pMemory
,
1901 PFORMAT_STRING pFormat
)
1903 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1904 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1906 EmbeddedPointerFree(pStubMsg
, pMemory
, pFormat
);
1910 /***********************************************************************
1911 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1913 unsigned char* WINAPI
NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg
,
1914 unsigned char* pMemory
,
1915 PFORMAT_STRING pFormat
)
1922 /***********************************************************************
1923 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1925 unsigned char* WINAPI
NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
,
1926 unsigned char** ppMemory
,
1927 PFORMAT_STRING pFormat
,
1928 unsigned char fMustAlloc
)
1935 /***********************************************************************
1936 * NdrConformantVaryingArrayFree [RPCRT4.@]
1938 void WINAPI
NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg
,
1939 unsigned char* pMemory
,
1940 PFORMAT_STRING pFormat
)
1946 /***********************************************************************
1947 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1949 void WINAPI
NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg
,
1950 unsigned char* pMemory
, PFORMAT_STRING pFormat
)
1956 /***********************************************************************
1957 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1959 unsigned long WINAPI
NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg
,
1960 PFORMAT_STRING pFormat
)
1967 /***********************************************************************
1968 * NdrComplexArrayMarshall [RPCRT4.@]
1970 unsigned char * WINAPI
NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1971 unsigned char *pMemory
,
1972 PFORMAT_STRING pFormat
)
1974 DWORD size
= 0, count
, def
;
1975 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1977 def
= *(const WORD
*)&pFormat
[2];
1980 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
1981 size
= pStubMsg
->MaxCount
;
1982 TRACE("conformance=%ld\n", size
);
1984 if (*(const DWORD
*)pFormat
!= 0xffffffff)
1985 FIXME("compute variance\n");
1988 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, size
);
1989 pStubMsg
->Buffer
+= 4;
1991 for (count
=0; count
<size
; count
++)
1992 pMemory
= ComplexMarshall(pStubMsg
, pMemory
, pFormat
, NULL
);
1994 STD_OVERFLOW_CHECK(pStubMsg
);
1999 /***********************************************************************
2000 * NdrComplexArrayUnmarshall [RPCRT4.@]
2002 unsigned char * WINAPI
NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2003 unsigned char **ppMemory
,
2004 PFORMAT_STRING pFormat
,
2005 unsigned char fMustAlloc
)
2007 DWORD size
= 0, count
, esize
;
2008 unsigned char *pMemory
;
2009 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
2013 pFormat
= ReadConformance(pStubMsg
, pFormat
);
2014 size
= pStubMsg
->MaxCount
;
2015 TRACE("conformance=%ld\n", size
);
2019 esize
= ComplexStructSize(pStubMsg
, pFormat
);
2021 if (fMustAlloc
|| !*ppMemory
)
2022 *ppMemory
= NdrAllocate(pStubMsg
, size
*esize
);
2024 pMemory
= *ppMemory
;
2025 for (count
=0; count
<size
; count
++)
2026 pMemory
= ComplexUnmarshall(pStubMsg
, pMemory
, pFormat
, NULL
, fMustAlloc
);
2031 /***********************************************************************
2032 * NdrComplexArrayBufferSize [RPCRT4.@]
2034 void WINAPI
NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2035 unsigned char *pMemory
,
2036 PFORMAT_STRING pFormat
)
2038 DWORD size
= 0, count
, def
;
2039 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2041 def
= *(const WORD
*)&pFormat
[2];
2044 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
2045 size
= pStubMsg
->MaxCount
;
2046 TRACE("conformance=%ld\n", size
);
2048 if (*(const DWORD
*)pFormat
!= 0xffffffff)
2049 FIXME("compute variance\n");
2052 for (count
=0; count
<size
; count
++)
2053 pMemory
= ComplexBufferSize(pStubMsg
, pMemory
, pFormat
, NULL
);
2056 /***********************************************************************
2057 * NdrComplexArrayMemorySize [RPCRT4.@]
2059 unsigned long WINAPI
NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2060 PFORMAT_STRING pFormat
)
2063 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
2067 pFormat
= ReadConformance(pStubMsg
, pFormat
);
2068 size
= pStubMsg
->MaxCount
;
2069 TRACE("conformance=%ld\n", size
);
2076 /***********************************************************************
2077 * NdrComplexArrayFree [RPCRT4.@]
2079 void WINAPI
NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2080 unsigned char *pMemory
,
2081 PFORMAT_STRING pFormat
)
2083 DWORD size
= 0, count
, def
;
2084 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2086 def
= *(const WORD
*)&pFormat
[2];
2089 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
2090 size
= pStubMsg
->MaxCount
;
2091 TRACE("conformance=%ld\n", size
);
2093 if (*(const DWORD
*)pFormat
!= 0xffffffff)
2094 FIXME("compute variance\n");
2097 for (count
=0; count
<size
; count
++)
2098 pMemory
= ComplexFree(pStubMsg
, pMemory
, pFormat
, NULL
);
2101 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg
)
2103 return MAKELONG(pStubMsg
->dwDestContext
,
2104 pStubMsg
->RpcMsg
->DataRepresentation
);
2107 /***********************************************************************
2108 * NdrUserMarshalMarshall [RPCRT4.@]
2110 unsigned char * WINAPI
NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2111 unsigned char *pMemory
,
2112 PFORMAT_STRING pFormat
)
2114 /* unsigned flags = pFormat[1]; */
2115 unsigned index
= *(const WORD
*)&pFormat
[2];
2116 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2117 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2118 TRACE("index=%d\n", index
);
2121 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnMarshall(
2122 &uflag
, pStubMsg
->Buffer
, pMemory
);
2124 STD_OVERFLOW_CHECK(pStubMsg
);
2129 /***********************************************************************
2130 * NdrUserMarshalUnmarshall [RPCRT4.@]
2132 unsigned char * WINAPI
NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2133 unsigned char **ppMemory
,
2134 PFORMAT_STRING pFormat
,
2135 unsigned char fMustAlloc
)
2137 /* unsigned flags = pFormat[1];*/
2138 unsigned index
= *(const WORD
*)&pFormat
[2];
2139 DWORD memsize
= *(const WORD
*)&pFormat
[4];
2140 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2141 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
2142 TRACE("index=%d\n", index
);
2144 if (fMustAlloc
|| !*ppMemory
)
2145 *ppMemory
= NdrAllocate(pStubMsg
, memsize
);
2148 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnUnmarshall(
2149 &uflag
, pStubMsg
->Buffer
, *ppMemory
);
2154 /***********************************************************************
2155 * NdrUserMarshalBufferSize [RPCRT4.@]
2157 void WINAPI
NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2158 unsigned char *pMemory
,
2159 PFORMAT_STRING pFormat
)
2161 /* unsigned flags = pFormat[1];*/
2162 unsigned index
= *(const WORD
*)&pFormat
[2];
2163 DWORD bufsize
= *(const WORD
*)&pFormat
[6];
2164 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2165 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2166 TRACE("index=%d\n", index
);
2169 TRACE("size=%ld\n", bufsize
);
2170 pStubMsg
->BufferLength
+= bufsize
;
2174 pStubMsg
->BufferLength
=
2175 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnBufferSize(
2176 &uflag
, pStubMsg
->BufferLength
, pMemory
);
2179 /***********************************************************************
2180 * NdrUserMarshalMemorySize [RPCRT4.@]
2182 unsigned long WINAPI
NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2183 PFORMAT_STRING pFormat
)
2185 unsigned index
= *(const WORD
*)&pFormat
[2];
2186 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2187 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
2188 TRACE("index=%d\n", index
);
2193 /***********************************************************************
2194 * NdrUserMarshalFree [RPCRT4.@]
2196 void WINAPI
NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg
,
2197 unsigned char *pMemory
,
2198 PFORMAT_STRING pFormat
)
2200 /* unsigned flags = pFormat[1]; */
2201 unsigned index
= *(const WORD
*)&pFormat
[2];
2202 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2203 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2204 TRACE("index=%d\n", index
);
2206 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnFree(
2210 /***********************************************************************
2211 * NdrClearOutParameters [RPCRT4.@]
2213 void WINAPI
NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg
,
2214 PFORMAT_STRING pFormat
,
2217 FIXME("(%p,%p,%p): stub\n", pStubMsg
, pFormat
, ArgAddr
);
2220 /***********************************************************************
2221 * NdrConvert [RPCRT4.@]
2223 void WINAPI
NdrConvert( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
)
2225 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg
, pFormat
);
2226 /* FIXME: since this stub doesn't do any converting, the proper behavior
2227 is to raise an exception */
2230 /***********************************************************************
2231 * NdrConvert2 [RPCRT4.@]
2233 void WINAPI
NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
, long NumberParams
)
2235 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2236 pStubMsg
, pFormat
, NumberParams
);
2237 /* FIXME: since this stub doesn't do any converting, the proper behavior
2238 is to raise an exception */
2241 /***********************************************************************
2242 * NdrConformantStructMarshall [RPCRT4.@]
2244 unsigned char * WINAPI
NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2245 unsigned char *pMemory
,
2246 PFORMAT_STRING pFormat
)
2252 /***********************************************************************
2253 * NdrConformantStructUnmarshall [RPCRT4.@]
2255 unsigned char * WINAPI
NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2256 unsigned char **ppMemory
,
2257 PFORMAT_STRING pFormat
,
2258 unsigned char fMustAlloc
)
2264 /***********************************************************************
2265 * NdrConformantStructBufferSize [RPCRT4.@]
2267 void WINAPI
NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2268 unsigned char *pMemory
,
2269 PFORMAT_STRING pFormat
)
2274 /***********************************************************************
2275 * NdrConformantStructMemorySize [RPCRT4.@]
2277 unsigned long WINAPI
NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2278 PFORMAT_STRING pFormat
)
2284 /***********************************************************************
2285 * NdrConformantStructFree [RPCRT4.@]
2287 void WINAPI
NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
2288 unsigned char *pMemory
,
2289 PFORMAT_STRING pFormat
)
2294 /***********************************************************************
2295 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2297 unsigned char * WINAPI
NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2298 unsigned char *pMemory
,
2299 PFORMAT_STRING pFormat
)
2305 /***********************************************************************
2306 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2308 unsigned char * WINAPI
NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2309 unsigned char **ppMemory
,
2310 PFORMAT_STRING pFormat
,
2311 unsigned char fMustAlloc
)
2317 /***********************************************************************
2318 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2320 void WINAPI
NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2321 unsigned char *pMemory
,
2322 PFORMAT_STRING pFormat
)
2327 /***********************************************************************
2328 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2330 unsigned long WINAPI
NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2331 PFORMAT_STRING pFormat
)
2337 /***********************************************************************
2338 * NdrConformantVaryingStructFree [RPCRT4.@]
2340 void WINAPI
NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
2341 unsigned char *pMemory
,
2342 PFORMAT_STRING pFormat
)
2347 /***********************************************************************
2348 * NdrFixedArrayMarshall [RPCRT4.@]
2350 unsigned char * WINAPI
NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2351 unsigned char *pMemory
,
2352 PFORMAT_STRING pFormat
)
2358 /***********************************************************************
2359 * NdrFixedArrayUnmarshall [RPCRT4.@]
2361 unsigned char * WINAPI
NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2362 unsigned char **ppMemory
,
2363 PFORMAT_STRING pFormat
,
2364 unsigned char fMustAlloc
)
2370 /***********************************************************************
2371 * NdrFixedArrayBufferSize [RPCRT4.@]
2373 void WINAPI
NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2374 unsigned char *pMemory
,
2375 PFORMAT_STRING pFormat
)
2380 /***********************************************************************
2381 * NdrFixedArrayMemorySize [RPCRT4.@]
2383 unsigned long WINAPI
NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2384 PFORMAT_STRING pFormat
)
2390 /***********************************************************************
2391 * NdrFixedArrayFree [RPCRT4.@]
2393 void WINAPI
NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2394 unsigned char *pMemory
,
2395 PFORMAT_STRING pFormat
)
2400 /***********************************************************************
2401 * NdrVaryingArrayMarshall [RPCRT4.@]
2403 unsigned char * WINAPI
NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2404 unsigned char *pMemory
,
2405 PFORMAT_STRING pFormat
)
2411 /***********************************************************************
2412 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2414 unsigned char * WINAPI
NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2415 unsigned char **ppMemory
,
2416 PFORMAT_STRING pFormat
,
2417 unsigned char fMustAlloc
)
2423 /***********************************************************************
2424 * NdrVaryingArrayBufferSize [RPCRT4.@]
2426 void WINAPI
NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2427 unsigned char *pMemory
,
2428 PFORMAT_STRING pFormat
)
2433 /***********************************************************************
2434 * NdrVaryingArrayMemorySize [RPCRT4.@]
2436 unsigned long WINAPI
NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2437 PFORMAT_STRING pFormat
)
2443 /***********************************************************************
2444 * NdrVaryingArrayFree [RPCRT4.@]
2446 void WINAPI
NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2447 unsigned char *pMemory
,
2448 PFORMAT_STRING pFormat
)
2453 /***********************************************************************
2454 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2456 unsigned char * WINAPI
NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2457 unsigned char *pMemory
,
2458 PFORMAT_STRING pFormat
)
2464 /***********************************************************************
2465 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2467 unsigned char * WINAPI
NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2468 unsigned char **ppMemory
,
2469 PFORMAT_STRING pFormat
,
2470 unsigned char fMustAlloc
)
2476 /***********************************************************************
2477 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2479 void WINAPI
NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2480 unsigned char *pMemory
,
2481 PFORMAT_STRING pFormat
)
2486 /***********************************************************************
2487 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2489 unsigned long WINAPI
NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2490 PFORMAT_STRING pFormat
)
2496 /***********************************************************************
2497 * NdrEncapsulatedUnionFree [RPCRT4.@]
2499 void WINAPI
NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg
,
2500 unsigned char *pMemory
,
2501 PFORMAT_STRING pFormat
)
2506 /***********************************************************************
2507 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2509 unsigned char * WINAPI
NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2510 unsigned char *pMemory
,
2511 PFORMAT_STRING pFormat
)
2517 /***********************************************************************
2518 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2520 unsigned char * WINAPI
NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2521 unsigned char **ppMemory
,
2522 PFORMAT_STRING pFormat
,
2523 unsigned char fMustAlloc
)
2529 /***********************************************************************
2530 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2532 void WINAPI
NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2533 unsigned char *pMemory
,
2534 PFORMAT_STRING pFormat
)
2539 /***********************************************************************
2540 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2542 unsigned long WINAPI
NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2543 PFORMAT_STRING pFormat
)
2549 /***********************************************************************
2550 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2552 void WINAPI
NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg
,
2553 unsigned char *pMemory
,
2554 PFORMAT_STRING pFormat
)
2559 /***********************************************************************
2560 * NdrByteCountPointerMarshall [RPCRT4.@]
2562 unsigned char * WINAPI
NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2563 unsigned char *pMemory
,
2564 PFORMAT_STRING pFormat
)
2570 /***********************************************************************
2571 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2573 unsigned char * WINAPI
NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2574 unsigned char **ppMemory
,
2575 PFORMAT_STRING pFormat
,
2576 unsigned char fMustAlloc
)
2582 /***********************************************************************
2583 * NdrByteCountPointerBufferSize [RPCRT4.@]
2585 void WINAPI
NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2586 unsigned char *pMemory
,
2587 PFORMAT_STRING pFormat
)
2592 /***********************************************************************
2593 * NdrByteCountPointerMemorySize [RPCRT4.@]
2595 unsigned long WINAPI
NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2596 PFORMAT_STRING pFormat
)
2602 /***********************************************************************
2603 * NdrByteCountPointerFree [RPCRT4.@]
2605 void WINAPI
NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
2606 unsigned char *pMemory
,
2607 PFORMAT_STRING pFormat
)
2612 /***********************************************************************
2613 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2615 unsigned char * WINAPI
NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2616 unsigned char *pMemory
,
2617 PFORMAT_STRING pFormat
)
2623 /***********************************************************************
2624 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2626 unsigned char * WINAPI
NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2627 unsigned char **ppMemory
,
2628 PFORMAT_STRING pFormat
,
2629 unsigned char fMustAlloc
)
2635 /***********************************************************************
2636 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2638 void WINAPI
NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2639 unsigned char *pMemory
,
2640 PFORMAT_STRING pFormat
)
2645 /***********************************************************************
2646 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2648 unsigned long WINAPI
NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2649 PFORMAT_STRING pFormat
)
2655 /***********************************************************************
2656 * NdrXmitOrRepAsFree [RPCRT4.@]
2658 void WINAPI
NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg
,
2659 unsigned char *pMemory
,
2660 PFORMAT_STRING pFormat
)
2665 /***********************************************************************
2666 * NdrClientContextMarshall
2668 void WINAPI
NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2669 NDR_CCONTEXT ContextHandle
,
2672 FIXME("(%p, %p, %d): stub\n", pStubMsg
, ContextHandle
, fCheck
);
2675 /***********************************************************************
2676 * NdrClientContextUnmarshall
2678 void WINAPI
NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2679 NDR_CCONTEXT
* pContextHandle
,
2680 RPC_BINDING_HANDLE BindHandle
)
2682 FIXME("(%p, %p, %p): stub\n", pStubMsg
, pContextHandle
, BindHandle
);
2685 void WINAPI
NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2686 NDR_SCONTEXT ContextHandle
,
2687 NDR_RUNDOWN RundownRoutine
)
2689 FIXME("(%p, %p, %p): stub\n", pStubMsg
, ContextHandle
, RundownRoutine
);
2692 NDR_SCONTEXT WINAPI
NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
)
2694 FIXME("(%p): stub\n", pStubMsg
);
2698 void WINAPI
NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg
,
2699 unsigned char* pMemory
,
2700 PFORMAT_STRING pFormat
)
2702 FIXME("(%p, %p, %p): stub\n", pStubMsg
, pMemory
, pFormat
);
2705 NDR_SCONTEXT WINAPI
NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg
,
2706 PFORMAT_STRING pFormat
)
2708 FIXME("(%p, %p): stub\n", pStubMsg
, pFormat
);
2712 void WINAPI
NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2713 NDR_SCONTEXT ContextHandle
,
2714 NDR_RUNDOWN RundownRoutine
,
2715 PFORMAT_STRING pFormat
)
2717 FIXME("(%p, %p, %p, %p): stub\n", pStubMsg
, ContextHandle
, RundownRoutine
, pFormat
);
2720 NDR_SCONTEXT WINAPI
NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2721 PFORMAT_STRING pFormat
)
2723 FIXME("(%p, %p): stub\n", pStubMsg
, pFormat
);
2727 RPC_BINDING_HANDLE WINAPI
NDRCContextBinding(NDR_CCONTEXT CContext
)
2729 FIXME("(%p): stub\n", CContext
);