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 (pszMessage
== NULL
) {
421 TRACE("string=%s\n", debugstr_a(pszMessage
));
425 else if (*pFormat
== RPC_FC_C_CSTRING
) {
426 TRACE("string=%s\n", debugstr_a(pszMessage
));
427 len
= strlen(pszMessage
)+1;
430 else if (*pFormat
== RPC_FC_C_WSTRING
) {
431 TRACE("string=%s\n", debugstr_w((LPWSTR
)pszMessage
));
432 len
= strlenW((LPWSTR
)pszMessage
)+1;
436 ERR("Unhandled string type: %#x\n", *pFormat
);
437 /* FIXME: raise an exception. */
441 if (pFormat
[1] != RPC_FC_PAD
) {
442 FIXME("sized string format=%d\n", pFormat
[1]);
445 assert( (pStubMsg
->BufferLength
>= (len
*esize
+ 13)) && (pStubMsg
->Buffer
!= NULL
) );
447 c
= pStubMsg
->Buffer
;
449 NDR_LOCAL_UINT32_WRITE(c
, len
); /* max length: strlen + 1 (for '\0') */
450 c
+= 8; /* offset: 0 */
451 NDR_LOCAL_UINT32_WRITE(c
, len
); /* actual length: (same) */
454 memcpy(c
, pszMessage
, len
*esize
); /* the string itself */
457 pStubMsg
->Buffer
= c
;
459 STD_OVERFLOW_CHECK(pStubMsg
);
462 return NULL
; /* is this always right? */
465 /***********************************************************************
466 * NdrConformantStringBufferSize [RPCRT4.@]
468 void WINAPI
NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
469 unsigned char* pMemory
, PFORMAT_STRING pFormat
)
471 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg
, pMemory
, pFormat
);
474 if (pMemory
== NULL
) {
475 /* we need 12 octets for the [maxlen, offset, len] DWORDS */
476 TRACE("string=NULL\n");
477 pStubMsg
->BufferLength
+= 12 + BUFFER_PARANOIA
;
479 else if (*pFormat
== RPC_FC_C_CSTRING
) {
480 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */
481 TRACE("string=%s\n", debugstr_a(pMemory
));
482 pStubMsg
->BufferLength
+= strlen(pMemory
) + 13 + BUFFER_PARANOIA
;
484 else if (*pFormat
== RPC_FC_C_WSTRING
) {
485 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 2 octets for L'\0' */
486 TRACE("string=%s\n", debugstr_w((LPWSTR
)pMemory
));
487 pStubMsg
->BufferLength
+= strlenW((LPWSTR
)pMemory
)*2 + 14 + BUFFER_PARANOIA
;
490 ERR("Unhandled string type: %#x\n", *pFormat
);
491 /* FIXME: raise an exception */
494 if (pFormat
[1] != RPC_FC_PAD
) {
495 FIXME("sized string format=%d\n", pFormat
[1]);
499 /************************************************************************
500 * NdrConformantStringMemorySize [RPCRT4.@]
502 unsigned long WINAPI
NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg
,
503 PFORMAT_STRING pFormat
)
505 unsigned long rslt
= 0;
507 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg
, pFormat
);
509 assert(pStubMsg
&& pFormat
);
511 if (*pFormat
== RPC_FC_C_CSTRING
) {
512 rslt
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
); /* maxlen */
514 else if (*pFormat
== RPC_FC_C_WSTRING
) {
515 rslt
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
)*2; /* maxlen */
518 ERR("Unhandled string type: %#x\n", *pFormat
);
519 /* FIXME: raise an exception */
522 if (pFormat
[1] != RPC_FC_PAD
) {
523 FIXME("sized string format=%d\n", pFormat
[1]);
526 TRACE(" --> %lu\n", rslt
);
530 /************************************************************************
531 * NdrConformantStringUnmarshall [RPCRT4.@]
533 unsigned char *WINAPI
NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
,
534 unsigned char** ppMemory
, PFORMAT_STRING pFormat
, unsigned char fMustAlloc
)
536 unsigned long len
, esize
, ofs
;
539 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
540 pStubMsg
, *ppMemory
, pFormat
, fMustAlloc
);
542 assert(pFormat
&& ppMemory
&& pStubMsg
);
544 pStubMsg
->Buffer
+= 4;
545 ofs
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
546 pStubMsg
->Buffer
+= 4;
547 len
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
548 pStubMsg
->Buffer
+= 4;
550 if (*pFormat
== RPC_FC_C_CSTRING
) esize
= 1;
551 else if (*pFormat
== RPC_FC_C_WSTRING
) esize
= 2;
553 ERR("Unhandled string type: %#x\n", *pFormat
);
554 /* FIXME: raise an exception */
558 if (pFormat
[1] != RPC_FC_PAD
) {
559 FIXME("sized string format=%d\n", pFormat
[1]);
563 *ppMemory
= NdrAllocate(pStubMsg
, len
*esize
+ BUFFER_PARANOIA
);
565 if (pStubMsg
->ReuseBuffer
&& !*ppMemory
)
566 /* for servers, we may just point straight into the RPC buffer, I think
567 * (I guess that's what MS does since MIDL code doesn't try to free) */
568 *ppMemory
= pStubMsg
->Buffer
- ofs
*esize
;
569 /* for clients, memory should be provided by caller */
577 pMem
= *ppMemory
+ ofs
*esize
;
579 if (pMem
!= pStubMsg
->Buffer
)
580 memcpy(pMem
, pStubMsg
->Buffer
, len
*esize
);
582 pStubMsg
->Buffer
+= len
*esize
;
584 if (*pFormat
== RPC_FC_C_CSTRING
) {
585 TRACE("string=%s\n", debugstr_a(pMem
));
587 else if (*pFormat
== RPC_FC_C_WSTRING
) {
588 TRACE("string=%s\n", debugstr_w((LPWSTR
)pMem
));
591 return NULL
; /* FIXME: is this always right? */
594 static inline void dump_pointer_attr(unsigned char attr
)
596 if (attr
& RPC_FC_P_ALLOCALLNODES
)
597 TRACE(" RPC_FC_P_ALLOCALLNODES");
598 if (attr
& RPC_FC_P_DONTFREE
)
599 TRACE(" RPC_FC_P_DONTFREE");
600 if (attr
& RPC_FC_P_ONSTACK
)
601 TRACE(" RPC_FC_P_ONSTACK");
602 if (attr
& RPC_FC_P_SIMPLEPOINTER
)
603 TRACE(" RPC_FC_P_SIMPLEPOINTER");
604 if (attr
& RPC_FC_P_DEREF
)
605 TRACE(" RPC_FC_P_DEREF");
609 /***********************************************************************
612 void WINAPI
PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
613 unsigned char *Buffer
,
614 unsigned char *Pointer
,
615 PFORMAT_STRING pFormat
)
617 unsigned type
= pFormat
[0], attr
= pFormat
[1];
621 TRACE("(%p,%p,%p,%p)\n", pStubMsg
, Buffer
, Pointer
, pFormat
);
622 TRACE("type=0x%x, attr=", type
); dump_pointer_attr(attr
);
624 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
625 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
626 if (attr
& RPC_FC_P_DEREF
) {
627 Pointer
= *(unsigned char**)Pointer
;
628 TRACE("deref => %p\n", Pointer
);
632 case RPC_FC_RP
: /* ref pointer (always non-null) */
633 #if 0 /* this causes problems for InstallShield so is disabled - we need more tests */
635 RpcRaiseException(RPC_X_NULL_REF_POINTER
);
638 case RPC_FC_UP
: /* unique pointer */
639 case RPC_FC_OP
: /* object pointer - same as unique here */
640 TRACE("writing %p to buffer\n", Pointer
);
641 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, (unsigned long)Pointer
);
642 pStubMsg
->Buffer
+= 4;
646 FIXME("unhandled ptr type=%02x\n", type
);
647 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
650 TRACE("calling marshaller for type 0x%x\n", (int)*desc
);
653 m
= NdrMarshaller
[*desc
& NDR_TABLE_MASK
];
654 if (m
) m(pStubMsg
, Pointer
, desc
);
655 else FIXME("no marshaller for data type=%02x\n", *desc
);
658 STD_OVERFLOW_CHECK(pStubMsg
);
661 /***********************************************************************
664 void WINAPI
PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
665 unsigned char *Buffer
,
666 unsigned char **pPointer
,
667 PFORMAT_STRING pFormat
,
668 unsigned char fMustAlloc
)
670 unsigned type
= pFormat
[0], attr
= pFormat
[1];
673 DWORD pointer_id
= 0;
675 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg
, Buffer
, pPointer
, pFormat
, fMustAlloc
);
676 TRACE("type=0x%x, attr=", type
); dump_pointer_attr(attr
);
678 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
679 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
680 if (attr
& RPC_FC_P_DEREF
) {
681 pPointer
= *(unsigned char***)pPointer
;
682 TRACE("deref => %p\n", pPointer
);
686 case RPC_FC_RP
: /* ref pointer (always non-null) */
689 case RPC_FC_UP
: /* unique pointer */
690 pointer_id
= NDR_LOCAL_UINT32_READ(pStubMsg
->Buffer
);
691 pStubMsg
->Buffer
+= 4;
693 case RPC_FC_OP
: /* object pointer - we must free data before overwriting it */
696 FIXME("unhandled ptr type=%02x\n", type
);
697 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
703 m
= NdrUnmarshaller
[*desc
& NDR_TABLE_MASK
];
704 if (m
) m(pStubMsg
, pPointer
, desc
, fMustAlloc
);
705 else FIXME("no unmarshaller for data type=%02x\n", *desc
);
708 TRACE("pointer=%p\n", *pPointer
);
711 /***********************************************************************
714 void WINAPI
PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
715 unsigned char *Pointer
,
716 PFORMAT_STRING pFormat
)
718 unsigned type
= pFormat
[0], attr
= pFormat
[1];
722 TRACE("(%p,%p,%p)\n", pStubMsg
, Pointer
, pFormat
);
723 TRACE("type=%d, attr=%d\n", type
, attr
);
725 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
726 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
727 if (attr
& RPC_FC_P_DEREF
) {
728 Pointer
= *(unsigned char**)Pointer
;
729 TRACE("deref => %p\n", Pointer
);
733 case RPC_FC_RP
: /* ref pointer (always non-null) */
737 pStubMsg
->BufferLength
+= 4;
738 /* NULL pointer has no further representation */
744 FIXME("unhandled ptr type=%02x\n", type
);
745 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
748 m
= NdrBufferSizer
[*desc
& NDR_TABLE_MASK
];
749 if (m
) m(pStubMsg
, Pointer
, desc
);
750 else FIXME("no buffersizer for data type=%02x\n", *desc
);
753 /***********************************************************************
754 * PointerMemorySize [RPCRT4.@]
756 unsigned long WINAPI
PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
757 unsigned char *Buffer
,
758 PFORMAT_STRING pFormat
)
760 unsigned type
= pFormat
[0], attr
= pFormat
[1];
764 FIXME("(%p,%p,%p): stub\n", pStubMsg
, Buffer
, pFormat
);
765 TRACE("type=%d, attr=", type
); dump_pointer_attr(attr
);
767 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
768 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
769 if (attr
& RPC_FC_P_DEREF
) {
774 case RPC_FC_RP
: /* ref pointer (always non-null) */
777 FIXME("unhandled ptr type=%02x\n", type
);
778 RpcRaiseException(RPC_X_BAD_STUB_DATA
);
781 m
= NdrMemorySizer
[*desc
& NDR_TABLE_MASK
];
782 if (m
) m(pStubMsg
, desc
);
783 else FIXME("no memorysizer for data type=%02x\n", *desc
);
788 /***********************************************************************
789 * PointerFree [RPCRT4.@]
791 void WINAPI
PointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
792 unsigned char *Pointer
,
793 PFORMAT_STRING pFormat
)
795 unsigned type
= pFormat
[0], attr
= pFormat
[1];
799 TRACE("(%p,%p,%p)\n", pStubMsg
, Pointer
, pFormat
);
800 TRACE("type=%d, attr=", type
); dump_pointer_attr(attr
);
801 if (attr
& RPC_FC_P_DONTFREE
) return;
803 if (attr
& RPC_FC_P_SIMPLEPOINTER
) desc
= pFormat
;
804 else desc
= pFormat
+ *(const SHORT
*)pFormat
;
805 if (attr
& RPC_FC_P_DEREF
) {
806 Pointer
= *(unsigned char**)Pointer
;
807 TRACE("deref => %p\n", Pointer
);
810 if (!Pointer
) return;
812 m
= NdrFreer
[*desc
& NDR_TABLE_MASK
];
813 if (m
) m(pStubMsg
, Pointer
, desc
);
815 /* hmm... is this sensible?
816 * perhaps we should check if the memory comes from NdrAllocate,
817 * and deallocate only if so - checking if the pointer is between
818 * BufferStart and BufferEnd is probably no good since the buffer
819 * may be reallocated when the server wants to marshal the reply */
821 case RPC_FC_BOGUS_STRUCT
:
822 case RPC_FC_BOGUS_ARRAY
:
823 case RPC_FC_USER_MARSHAL
:
826 FIXME("unhandled data type=%02x\n", *desc
);
828 case RPC_FC_C_CSTRING
:
829 case RPC_FC_C_WSTRING
:
830 if (pStubMsg
->ReuseBuffer
) goto notfree
;
836 if (attr
& RPC_FC_P_ONSTACK
) {
837 TRACE("not freeing stack ptr %p\n", Pointer
);
840 TRACE("freeing %p\n", Pointer
);
841 NdrFree(pStubMsg
, Pointer
);
844 TRACE("not freeing %p\n", Pointer
);
847 /***********************************************************************
848 * EmbeddedPointerMarshall
850 unsigned char * WINAPI
EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
851 unsigned char *pMemory
,
852 PFORMAT_STRING pFormat
)
854 unsigned char *Mark
= pStubMsg
->BufferMark
;
855 unsigned long Offset
= pStubMsg
->Offset
;
856 unsigned ofs
, rep
, count
, stride
, xofs
;
858 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
860 if (*pFormat
!= RPC_FC_PP
) return NULL
;
863 while (pFormat
[0] != RPC_FC_END
) {
864 switch (pFormat
[0]) {
866 FIXME("unknown repeat type %d\n", pFormat
[0]);
867 case RPC_FC_NO_REPEAT
:
875 case RPC_FC_FIXED_REPEAT
:
876 rep
= *(const WORD
*)&pFormat
[2];
877 stride
= *(const WORD
*)&pFormat
[4];
878 ofs
= *(const WORD
*)&pFormat
[6];
879 count
= *(const WORD
*)&pFormat
[8];
883 case RPC_FC_VARIABLE_REPEAT
:
884 rep
= pStubMsg
->MaxCount
;
885 stride
= *(const WORD
*)&pFormat
[2];
886 ofs
= *(const WORD
*)&pFormat
[4];
887 count
= *(const WORD
*)&pFormat
[6];
888 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
892 /* ofs doesn't seem to matter in this context */
894 PFORMAT_STRING info
= pFormat
;
895 unsigned char *membase
= pMemory
+ xofs
;
897 for (u
=0; u
<count
; u
++,info
+=8) {
898 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
899 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
900 PointerMarshall(pStubMsg
, bufptr
, *(unsigned char**)memptr
, info
+4);
904 pFormat
+= 8 * count
;
907 STD_OVERFLOW_CHECK(pStubMsg
);
912 /***********************************************************************
913 * EmbeddedPointerUnmarshall
915 unsigned char * WINAPI
EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
916 unsigned char **ppMemory
,
917 PFORMAT_STRING pFormat
,
918 unsigned char fMustAlloc
)
920 unsigned char *Mark
= pStubMsg
->BufferMark
;
921 unsigned long Offset
= pStubMsg
->Offset
;
922 unsigned ofs
, rep
, count
, stride
, xofs
;
924 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
926 if (*pFormat
!= RPC_FC_PP
) return NULL
;
929 while (pFormat
[0] != RPC_FC_END
) {
930 switch (pFormat
[0]) {
932 FIXME("unknown repeat type %d\n", pFormat
[0]);
933 case RPC_FC_NO_REPEAT
:
941 case RPC_FC_FIXED_REPEAT
:
942 rep
= *(const WORD
*)&pFormat
[2];
943 stride
= *(const WORD
*)&pFormat
[4];
944 ofs
= *(const WORD
*)&pFormat
[6];
945 count
= *(const WORD
*)&pFormat
[8];
949 case RPC_FC_VARIABLE_REPEAT
:
950 rep
= pStubMsg
->MaxCount
;
951 stride
= *(const WORD
*)&pFormat
[2];
952 ofs
= *(const WORD
*)&pFormat
[4];
953 count
= *(const WORD
*)&pFormat
[6];
954 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
958 /* ofs doesn't seem to matter in this context */
960 PFORMAT_STRING info
= pFormat
;
961 unsigned char *membase
= *ppMemory
+ xofs
;
963 for (u
=0; u
<count
; u
++,info
+=8) {
964 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
965 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
966 PointerUnmarshall(pStubMsg
, bufptr
, (unsigned char**)memptr
, info
+4, fMustAlloc
);
970 pFormat
+= 8 * count
;
976 /***********************************************************************
977 * EmbeddedPointerBufferSize
979 void WINAPI
EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
980 unsigned char *pMemory
,
981 PFORMAT_STRING pFormat
)
983 unsigned long Offset
= pStubMsg
->Offset
;
984 unsigned ofs
, rep
, count
, stride
, xofs
;
986 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
987 if (*pFormat
!= RPC_FC_PP
) return;
990 while (pFormat
[0] != RPC_FC_END
) {
991 switch (pFormat
[0]) {
993 FIXME("unknown repeat type %d\n", pFormat
[0]);
994 case RPC_FC_NO_REPEAT
:
1002 case RPC_FC_FIXED_REPEAT
:
1003 rep
= *(const WORD
*)&pFormat
[2];
1004 stride
= *(const WORD
*)&pFormat
[4];
1005 ofs
= *(const WORD
*)&pFormat
[6];
1006 count
= *(const WORD
*)&pFormat
[8];
1010 case RPC_FC_VARIABLE_REPEAT
:
1011 rep
= pStubMsg
->MaxCount
;
1012 stride
= *(const WORD
*)&pFormat
[2];
1013 ofs
= *(const WORD
*)&pFormat
[4];
1014 count
= *(const WORD
*)&pFormat
[6];
1015 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1019 /* ofs doesn't seem to matter in this context */
1021 PFORMAT_STRING info
= pFormat
;
1022 unsigned char *membase
= pMemory
+ xofs
;
1024 for (u
=0; u
<count
; u
++,info
+=8) {
1025 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
1026 PointerBufferSize(pStubMsg
, *(unsigned char**)memptr
, info
+4);
1030 pFormat
+= 8 * count
;
1034 /***********************************************************************
1035 * EmbeddedPointerMemorySize
1037 unsigned long WINAPI
EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1038 PFORMAT_STRING pFormat
)
1040 unsigned long Offset
= pStubMsg
->Offset
;
1041 unsigned char *Mark
= pStubMsg
->BufferMark
;
1042 unsigned ofs
, rep
, count
, stride
, xofs
;
1044 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1045 if (*pFormat
!= RPC_FC_PP
) return 0;
1048 while (pFormat
[0] != RPC_FC_END
) {
1049 switch (pFormat
[0]) {
1051 FIXME("unknown repeat type %d\n", pFormat
[0]);
1052 case RPC_FC_NO_REPEAT
:
1060 case RPC_FC_FIXED_REPEAT
:
1061 rep
= *(const WORD
*)&pFormat
[2];
1062 stride
= *(const WORD
*)&pFormat
[4];
1063 ofs
= *(const WORD
*)&pFormat
[6];
1064 count
= *(const WORD
*)&pFormat
[8];
1068 case RPC_FC_VARIABLE_REPEAT
:
1069 rep
= pStubMsg
->MaxCount
;
1070 stride
= *(const WORD
*)&pFormat
[2];
1071 ofs
= *(const WORD
*)&pFormat
[4];
1072 count
= *(const WORD
*)&pFormat
[6];
1073 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1077 /* ofs doesn't seem to matter in this context */
1079 PFORMAT_STRING info
= pFormat
;
1081 for (u
=0; u
<count
; u
++,info
+=8) {
1082 unsigned char *bufptr
= Mark
+ *(const SHORT
*)&info
[2];
1083 PointerMemorySize(pStubMsg
, bufptr
, info
+4);
1087 pFormat
+= 8 * count
;
1093 /***********************************************************************
1094 * EmbeddedPointerFree
1096 void WINAPI
EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
1097 unsigned char *pMemory
,
1098 PFORMAT_STRING pFormat
)
1100 unsigned long Offset
= pStubMsg
->Offset
;
1101 unsigned ofs
, rep
, count
, stride
, xofs
;
1103 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1104 if (*pFormat
!= RPC_FC_PP
) return;
1107 while (pFormat
[0] != RPC_FC_END
) {
1108 switch (pFormat
[0]) {
1110 FIXME("unknown repeat type %d\n", pFormat
[0]);
1111 case RPC_FC_NO_REPEAT
:
1119 case RPC_FC_FIXED_REPEAT
:
1120 rep
= *(const WORD
*)&pFormat
[2];
1121 stride
= *(const WORD
*)&pFormat
[4];
1122 ofs
= *(const WORD
*)&pFormat
[6];
1123 count
= *(const WORD
*)&pFormat
[8];
1127 case RPC_FC_VARIABLE_REPEAT
:
1128 rep
= pStubMsg
->MaxCount
;
1129 stride
= *(const WORD
*)&pFormat
[2];
1130 ofs
= *(const WORD
*)&pFormat
[4];
1131 count
= *(const WORD
*)&pFormat
[6];
1132 xofs
= (pFormat
[1] == RPC_FC_VARIABLE_OFFSET
) ? Offset
* stride
: 0;
1136 /* ofs doesn't seem to matter in this context */
1138 PFORMAT_STRING info
= pFormat
;
1139 unsigned char *membase
= pMemory
+ xofs
;
1141 for (u
=0; u
<count
; u
++,info
+=8) {
1142 unsigned char *memptr
= membase
+ *(const SHORT
*)&info
[0];
1143 PointerFree(pStubMsg
, *(unsigned char**)memptr
, info
+4);
1147 pFormat
+= 8 * count
;
1151 /***********************************************************************
1152 * NdrPointerMarshall [RPCRT4.@]
1154 unsigned char * WINAPI
NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1155 unsigned char *pMemory
,
1156 PFORMAT_STRING pFormat
)
1158 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1160 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1161 PointerMarshall(pStubMsg
, pStubMsg
->Buffer
, pMemory
, pFormat
);
1163 STD_OVERFLOW_CHECK(pStubMsg
);
1168 /***********************************************************************
1169 * NdrPointerUnmarshall [RPCRT4.@]
1171 unsigned char * WINAPI
NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1172 unsigned char **ppMemory
,
1173 PFORMAT_STRING pFormat
,
1174 unsigned char fMustAlloc
)
1176 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1178 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1179 PointerUnmarshall(pStubMsg
, pStubMsg
->Buffer
, ppMemory
, pFormat
, fMustAlloc
);
1184 /***********************************************************************
1185 * NdrPointerBufferSize [RPCRT4.@]
1187 void WINAPI
NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1188 unsigned char *pMemory
,
1189 PFORMAT_STRING pFormat
)
1191 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1192 PointerBufferSize(pStubMsg
, pMemory
, pFormat
);
1195 /***********************************************************************
1196 * NdrPointerMemorySize [RPCRT4.@]
1198 unsigned long WINAPI
NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1199 PFORMAT_STRING pFormat
)
1201 /* unsigned size = *(LPWORD)(pFormat+2); */
1202 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1203 PointerMemorySize(pStubMsg
, pStubMsg
->Buffer
, pFormat
);
1207 /***********************************************************************
1208 * NdrPointerFree [RPCRT4.@]
1210 void WINAPI
NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
1211 unsigned char *pMemory
,
1212 PFORMAT_STRING pFormat
)
1214 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1215 PointerFree(pStubMsg
, pMemory
, pFormat
);
1218 /***********************************************************************
1219 * NdrSimpleStructMarshall [RPCRT4.@]
1221 unsigned char * WINAPI
NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1222 unsigned char *pMemory
,
1223 PFORMAT_STRING pFormat
)
1225 unsigned size
= *(const WORD
*)(pFormat
+2);
1226 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1228 memcpy(pStubMsg
->Buffer
, pMemory
, size
);
1229 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1230 pStubMsg
->Buffer
+= size
;
1232 if (pFormat
[0] != RPC_FC_STRUCT
)
1233 EmbeddedPointerMarshall(pStubMsg
, pMemory
, pFormat
+4);
1236 * This test does not work when NdrSimpleStructMarshall is called
1237 * by an rpc-server to marshall data to return to the client because
1238 * BufferStart and BufferEnd are bogus. MIDL does not update them
1239 * when a new buffer is allocated in order to return data to the caller.
1242 STD_OVERFLOW_CHECK(pStubMsg
);
1248 /***********************************************************************
1249 * NdrSimpleStructUnmarshall [RPCRT4.@]
1251 unsigned char * WINAPI
NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1252 unsigned char **ppMemory
,
1253 PFORMAT_STRING pFormat
,
1254 unsigned char fMustAlloc
)
1256 unsigned size
= *(const WORD
*)(pFormat
+2);
1257 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1260 *ppMemory
= NdrAllocate(pStubMsg
, size
);
1261 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
);
1263 if (pStubMsg
->ReuseBuffer
&& !*ppMemory
)
1264 /* for servers, we may just point straight into the RPC buffer, I think
1265 * (I guess that's what MS does since MIDL code doesn't try to free) */
1266 *ppMemory
= pStubMsg
->Buffer
;
1268 /* for clients, memory should be provided by caller */
1269 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
);
1272 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1273 pStubMsg
->Buffer
+= size
;
1275 if (pFormat
[0] != RPC_FC_STRUCT
)
1276 EmbeddedPointerUnmarshall(pStubMsg
, ppMemory
, pFormat
+4, fMustAlloc
);
1282 /***********************************************************************
1283 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1285 void WINAPI
NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1286 unsigned char *pMemory
,
1287 unsigned char FormatChar
)
1293 /***********************************************************************
1294 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1296 void WINAPI
NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1297 unsigned char *pMemory
,
1298 unsigned char FormatChar
)
1304 /***********************************************************************
1305 * NdrSimpleStructBufferSize [RPCRT4.@]
1307 void WINAPI
NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1308 unsigned char *pMemory
,
1309 PFORMAT_STRING pFormat
)
1311 unsigned size
= *(const WORD
*)(pFormat
+2);
1312 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1313 pStubMsg
->BufferLength
+= size
;
1314 if (pFormat
[0] != RPC_FC_STRUCT
)
1315 EmbeddedPointerBufferSize(pStubMsg
, pMemory
, pFormat
+4);
1318 /***********************************************************************
1319 * NdrSimpleStructMemorySize [RPCRT4.@]
1321 unsigned long WINAPI
NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1322 PFORMAT_STRING pFormat
)
1324 /* unsigned size = *(LPWORD)(pFormat+2); */
1325 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1326 if (pFormat
[0] != RPC_FC_STRUCT
)
1327 EmbeddedPointerMemorySize(pStubMsg
, pFormat
+4);
1331 /***********************************************************************
1332 * NdrSimpleStructFree [RPCRT4.@]
1334 void WINAPI
NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
1335 unsigned char *pMemory
,
1336 PFORMAT_STRING pFormat
)
1338 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1339 if (pFormat
[0] != RPC_FC_STRUCT
)
1340 EmbeddedPointerFree(pStubMsg
, pMemory
, pFormat
+4);
1344 unsigned long WINAPI
EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg
,
1345 PFORMAT_STRING pFormat
)
1349 case RPC_FC_PSTRUCT
:
1350 case RPC_FC_CSTRUCT
:
1351 case RPC_FC_BOGUS_STRUCT
:
1352 return *(const WORD
*)&pFormat
[2];
1353 case RPC_FC_USER_MARSHAL
:
1354 return *(const WORD
*)&pFormat
[4];
1356 FIXME("unhandled embedded type %02x\n", *pFormat
);
1362 unsigned char * WINAPI
ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1363 unsigned char *pMemory
,
1364 PFORMAT_STRING pFormat
,
1365 PFORMAT_STRING pPointer
)
1367 PFORMAT_STRING desc
;
1371 while (*pFormat
!= RPC_FC_END
) {
1375 TRACE("short=%d <= %p\n", *(WORD
*)pMemory
, pMemory
);
1376 memcpy(pStubMsg
->Buffer
, pMemory
, 2);
1377 pStubMsg
->Buffer
+= 2;
1382 TRACE("long=%ld <= %p\n", *(DWORD
*)pMemory
, pMemory
);
1383 memcpy(pStubMsg
->Buffer
, pMemory
, 4);
1384 pStubMsg
->Buffer
+= 4;
1387 case RPC_FC_POINTER
:
1388 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory
, pMemory
);
1389 NdrPointerMarshall(pStubMsg
, *(unsigned char**)pMemory
, pPointer
);
1393 case RPC_FC_ALIGNM4
:
1394 ALIGN_POINTER(pMemory
, 3);
1396 case RPC_FC_ALIGNM8
:
1397 ALIGN_POINTER(pMemory
, 7);
1399 case RPC_FC_EMBEDDED_COMPLEX
:
1400 pMemory
+= pFormat
[1];
1402 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1403 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1404 TRACE("embedded complex (size=%ld) <= %p\n", size
, pMemory
);
1405 m
= NdrMarshaller
[*desc
& NDR_TABLE_MASK
];
1406 if (m
) m(pStubMsg
, pMemory
, desc
);
1407 else FIXME("no marshaller for embedded type %02x\n", *desc
);
1414 FIXME("unhandled format %02x\n", *pFormat
);
1422 unsigned char * WINAPI
ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1423 unsigned char *pMemory
,
1424 PFORMAT_STRING pFormat
,
1425 PFORMAT_STRING pPointer
,
1426 unsigned char fMustAlloc
)
1428 PFORMAT_STRING desc
;
1432 while (*pFormat
!= RPC_FC_END
) {
1436 memcpy(pMemory
, pStubMsg
->Buffer
, 2);
1437 TRACE("short=%d => %p\n", *(WORD
*)pMemory
, pMemory
);
1438 pStubMsg
->Buffer
+= 2;
1443 memcpy(pMemory
, pStubMsg
->Buffer
, 4);
1444 TRACE("long=%ld => %p\n", *(DWORD
*)pMemory
, pMemory
);
1445 pStubMsg
->Buffer
+= 4;
1448 case RPC_FC_POINTER
:
1449 *(unsigned char**)pMemory
= NULL
;
1450 TRACE("pointer => %p\n", pMemory
);
1451 NdrPointerUnmarshall(pStubMsg
, (unsigned char**)pMemory
, pPointer
, fMustAlloc
);
1455 case RPC_FC_ALIGNM4
:
1456 ALIGN_POINTER(pMemory
, 3);
1458 case RPC_FC_ALIGNM8
:
1459 ALIGN_POINTER(pMemory
, 7);
1461 case RPC_FC_EMBEDDED_COMPLEX
:
1462 pMemory
+= pFormat
[1];
1464 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1465 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1466 TRACE("embedded complex (size=%ld) => %p\n", size
, pMemory
);
1467 m
= NdrUnmarshaller
[*desc
& NDR_TABLE_MASK
];
1468 memset(pMemory
, 0, size
); /* just in case */
1469 if (m
) m(pStubMsg
, &pMemory
, desc
, fMustAlloc
);
1470 else FIXME("no unmarshaller for embedded type %02x\n", *desc
);
1477 FIXME("unhandled format %d\n", *pFormat
);
1485 unsigned char * WINAPI
ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1486 unsigned char *pMemory
,
1487 PFORMAT_STRING pFormat
,
1488 PFORMAT_STRING pPointer
)
1490 PFORMAT_STRING desc
;
1494 while (*pFormat
!= RPC_FC_END
) {
1498 pStubMsg
->BufferLength
+= 2;
1503 pStubMsg
->BufferLength
+= 4;
1506 case RPC_FC_POINTER
:
1507 NdrPointerBufferSize(pStubMsg
, *(unsigned char**)pMemory
, pPointer
);
1511 case RPC_FC_ALIGNM4
:
1512 ALIGN_POINTER(pMemory
, 3);
1514 case RPC_FC_ALIGNM8
:
1515 ALIGN_POINTER(pMemory
, 7);
1517 case RPC_FC_EMBEDDED_COMPLEX
:
1518 pMemory
+= pFormat
[1];
1520 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1521 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1522 m
= NdrBufferSizer
[*desc
& NDR_TABLE_MASK
];
1523 if (m
) m(pStubMsg
, pMemory
, desc
);
1524 else FIXME("no buffersizer for embedded type %02x\n", *desc
);
1531 FIXME("unhandled format %d\n", *pFormat
);
1539 unsigned char * WINAPI
ComplexFree(PMIDL_STUB_MESSAGE pStubMsg
,
1540 unsigned char *pMemory
,
1541 PFORMAT_STRING pFormat
,
1542 PFORMAT_STRING pPointer
)
1544 PFORMAT_STRING desc
;
1548 while (*pFormat
!= RPC_FC_END
) {
1558 case RPC_FC_POINTER
:
1559 NdrPointerFree(pStubMsg
, *(unsigned char**)pMemory
, pPointer
);
1563 case RPC_FC_ALIGNM4
:
1564 ALIGN_POINTER(pMemory
, 3);
1566 case RPC_FC_ALIGNM8
:
1567 ALIGN_POINTER(pMemory
, 7);
1569 case RPC_FC_EMBEDDED_COMPLEX
:
1570 pMemory
+= pFormat
[1];
1572 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1573 size
= EmbeddedComplexSize(pStubMsg
, desc
);
1574 m
= NdrFreer
[*desc
& NDR_TABLE_MASK
];
1575 if (m
) m(pStubMsg
, pMemory
, desc
);
1576 else FIXME("no freer for embedded type %02x\n", *desc
);
1583 FIXME("unhandled format %d\n", *pFormat
);
1591 unsigned long WINAPI
ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg
,
1592 PFORMAT_STRING pFormat
)
1594 PFORMAT_STRING desc
;
1595 unsigned long size
= 0;
1597 while (*pFormat
!= RPC_FC_END
) {
1607 case RPC_FC_POINTER
:
1610 case RPC_FC_ALIGNM4
:
1611 ALIGN_LENGTH(size
, 3);
1613 case RPC_FC_ALIGNM8
:
1614 ALIGN_LENGTH(size
, 7);
1616 case RPC_FC_EMBEDDED_COMPLEX
:
1619 desc
= pFormat
+ *(const SHORT
*)pFormat
;
1620 size
+= EmbeddedComplexSize(pStubMsg
, desc
);
1626 FIXME("unhandled format %d\n", *pFormat
);
1634 /***********************************************************************
1635 * NdrComplexStructMarshall [RPCRT4.@]
1637 unsigned char * WINAPI
NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1638 unsigned char *pMemory
,
1639 PFORMAT_STRING pFormat
)
1641 PFORMAT_STRING conf_array
= NULL
;
1642 PFORMAT_STRING pointer_desc
= NULL
;
1643 unsigned char *OldMemory
= pStubMsg
->Memory
;
1645 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1648 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1650 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1653 pStubMsg
->Memory
= pMemory
;
1655 ComplexMarshall(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1658 NdrConformantArrayMarshall(pStubMsg
, pMemory
, conf_array
);
1660 pStubMsg
->Memory
= OldMemory
;
1662 STD_OVERFLOW_CHECK(pStubMsg
);
1667 /***********************************************************************
1668 * NdrComplexStructUnmarshall [RPCRT4.@]
1670 unsigned char * WINAPI
NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1671 unsigned char **ppMemory
,
1672 PFORMAT_STRING pFormat
,
1673 unsigned char fMustAlloc
)
1675 unsigned size
= *(const WORD
*)(pFormat
+2);
1676 PFORMAT_STRING conf_array
= NULL
;
1677 PFORMAT_STRING pointer_desc
= NULL
;
1678 unsigned char *pMemory
;
1680 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1682 if (fMustAlloc
|| !*ppMemory
)
1683 *ppMemory
= NdrAllocate(pStubMsg
, size
);
1686 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1688 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1691 pMemory
= ComplexUnmarshall(pStubMsg
, *ppMemory
, pFormat
, pointer_desc
, fMustAlloc
);
1694 NdrConformantArrayUnmarshall(pStubMsg
, &pMemory
, conf_array
, fMustAlloc
);
1699 /***********************************************************************
1700 * NdrComplexStructBufferSize [RPCRT4.@]
1702 void WINAPI
NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1703 unsigned char *pMemory
,
1704 PFORMAT_STRING pFormat
)
1706 PFORMAT_STRING conf_array
= NULL
;
1707 PFORMAT_STRING pointer_desc
= NULL
;
1708 unsigned char *OldMemory
= pStubMsg
->Memory
;
1710 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1713 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1715 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1718 pStubMsg
->Memory
= pMemory
;
1720 pMemory
= ComplexBufferSize(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1723 NdrConformantArrayBufferSize(pStubMsg
, pMemory
, conf_array
);
1725 pStubMsg
->Memory
= OldMemory
;
1728 /***********************************************************************
1729 * NdrComplexStructMemorySize [RPCRT4.@]
1731 unsigned long WINAPI
NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1732 PFORMAT_STRING pFormat
)
1734 /* unsigned size = *(LPWORD)(pFormat+2); */
1735 PFORMAT_STRING conf_array
= NULL
;
1736 PFORMAT_STRING pointer_desc
= NULL
;
1738 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1741 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1743 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1749 /***********************************************************************
1750 * NdrComplexStructFree [RPCRT4.@]
1752 void WINAPI
NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
1753 unsigned char *pMemory
,
1754 PFORMAT_STRING pFormat
)
1756 PFORMAT_STRING conf_array
= NULL
;
1757 PFORMAT_STRING pointer_desc
= NULL
;
1758 unsigned char *OldMemory
= pStubMsg
->Memory
;
1760 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1763 if (*(const WORD
*)pFormat
) conf_array
= pFormat
+ *(const WORD
*)pFormat
;
1765 if (*(const WORD
*)pFormat
) pointer_desc
= pFormat
+ *(const WORD
*)pFormat
;
1768 pStubMsg
->Memory
= pMemory
;
1770 pMemory
= ComplexFree(pStubMsg
, pMemory
, pFormat
, pointer_desc
);
1773 NdrConformantArrayFree(pStubMsg
, pMemory
, conf_array
);
1775 pStubMsg
->Memory
= OldMemory
;
1778 /***********************************************************************
1779 * NdrConformantArrayMarshall [RPCRT4.@]
1781 unsigned char * WINAPI
NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1782 unsigned char *pMemory
,
1783 PFORMAT_STRING pFormat
)
1785 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1786 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1787 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1789 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
+4, 0);
1790 size
= pStubMsg
->MaxCount
;
1792 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, size
);
1793 pStubMsg
->Buffer
+= 4;
1795 memcpy(pStubMsg
->Buffer
, pMemory
, size
*esize
);
1796 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1797 pStubMsg
->Buffer
+= size
*esize
;
1799 EmbeddedPointerMarshall(pStubMsg
, pMemory
, pFormat
);
1801 STD_OVERFLOW_CHECK(pStubMsg
);
1806 /***********************************************************************
1807 * NdrConformantArrayUnmarshall [RPCRT4.@]
1809 unsigned char * WINAPI
NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1810 unsigned char **ppMemory
,
1811 PFORMAT_STRING pFormat
,
1812 unsigned char fMustAlloc
)
1814 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1815 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1816 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1818 pFormat
= ReadConformance(pStubMsg
, pFormat
+4);
1819 size
= pStubMsg
->MaxCount
;
1822 *ppMemory
= NdrAllocate(pStubMsg
, size
*esize
);
1823 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
*esize
);
1825 if (pStubMsg
->ReuseBuffer
&& !*ppMemory
)
1826 /* for servers, we may just point straight into the RPC buffer, I think
1827 * (I guess that's what MS does since MIDL code doesn't try to free) */
1828 *ppMemory
= pStubMsg
->Buffer
;
1830 /* for clients, memory should be provided by caller */
1831 memcpy(*ppMemory
, pStubMsg
->Buffer
, size
*esize
);
1834 pStubMsg
->BufferMark
= pStubMsg
->Buffer
;
1835 pStubMsg
->Buffer
+= size
*esize
;
1837 EmbeddedPointerUnmarshall(pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1842 /***********************************************************************
1843 * NdrConformantArrayBufferSize [RPCRT4.@]
1845 void WINAPI
NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
1846 unsigned char *pMemory
,
1847 PFORMAT_STRING pFormat
)
1849 DWORD size
= 0, esize
= *(const WORD
*)(pFormat
+2);
1850 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1851 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1853 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
+4, 0);
1854 size
= pStubMsg
->MaxCount
;
1856 pStubMsg
->BufferLength
+= size
*esize
;
1858 EmbeddedPointerBufferSize(pStubMsg
, pMemory
, pFormat
);
1861 /***********************************************************************
1862 * NdrConformantArrayMemorySize [RPCRT4.@]
1864 unsigned long WINAPI
NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
1865 PFORMAT_STRING pFormat
)
1868 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
1869 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1871 pFormat
= ReadConformance(pStubMsg
, pFormat
+4);
1872 size
= pStubMsg
->MaxCount
;
1874 EmbeddedPointerMemorySize(pStubMsg
, pFormat
);
1879 /***********************************************************************
1880 * NdrConformantArrayFree [RPCRT4.@]
1882 void WINAPI
NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
1883 unsigned char *pMemory
,
1884 PFORMAT_STRING pFormat
)
1886 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1887 if (pFormat
[0] != RPC_FC_CARRAY
) FIXME("format=%d\n", pFormat
[0]);
1889 EmbeddedPointerFree(pStubMsg
, pMemory
, pFormat
);
1893 /***********************************************************************
1894 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1896 unsigned char* WINAPI
NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg
,
1897 unsigned char* pMemory
,
1898 PFORMAT_STRING pFormat
)
1905 /***********************************************************************
1906 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1908 unsigned char* WINAPI
NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
,
1909 unsigned char** ppMemory
,
1910 PFORMAT_STRING pFormat
,
1911 unsigned char fMustAlloc
)
1918 /***********************************************************************
1919 * NdrConformantVaryingArrayFree [RPCRT4.@]
1921 void WINAPI
NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg
,
1922 unsigned char* pMemory
,
1923 PFORMAT_STRING pFormat
)
1929 /***********************************************************************
1930 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1932 void WINAPI
NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg
,
1933 unsigned char* pMemory
, PFORMAT_STRING pFormat
)
1939 /***********************************************************************
1940 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1942 unsigned long WINAPI
NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg
,
1943 PFORMAT_STRING pFormat
)
1950 /***********************************************************************
1951 * NdrComplexArrayMarshall [RPCRT4.@]
1953 unsigned char * WINAPI
NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1954 unsigned char *pMemory
,
1955 PFORMAT_STRING pFormat
)
1957 DWORD size
= 0, count
, def
;
1958 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
1960 def
= *(const WORD
*)&pFormat
[2];
1963 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
1964 size
= pStubMsg
->MaxCount
;
1965 TRACE("conformance=%ld\n", size
);
1967 if (*(const DWORD
*)pFormat
!= 0xffffffff)
1968 FIXME("compute variance\n");
1971 NDR_LOCAL_UINT32_WRITE(pStubMsg
->Buffer
, size
);
1972 pStubMsg
->Buffer
+= 4;
1974 for (count
=0; count
<size
; count
++)
1975 pMemory
= ComplexMarshall(pStubMsg
, pMemory
, pFormat
, NULL
);
1977 STD_OVERFLOW_CHECK(pStubMsg
);
1982 /***********************************************************************
1983 * NdrComplexArrayUnmarshall [RPCRT4.@]
1985 unsigned char * WINAPI
NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
1986 unsigned char **ppMemory
,
1987 PFORMAT_STRING pFormat
,
1988 unsigned char fMustAlloc
)
1990 DWORD size
= 0, count
, esize
;
1991 unsigned char *pMemory
;
1992 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
1996 pFormat
= ReadConformance(pStubMsg
, pFormat
);
1997 size
= pStubMsg
->MaxCount
;
1998 TRACE("conformance=%ld\n", size
);
2002 esize
= ComplexStructSize(pStubMsg
, pFormat
);
2004 if (fMustAlloc
|| !*ppMemory
)
2005 *ppMemory
= NdrAllocate(pStubMsg
, size
*esize
);
2007 pMemory
= *ppMemory
;
2008 for (count
=0; count
<size
; count
++)
2009 pMemory
= ComplexUnmarshall(pStubMsg
, pMemory
, pFormat
, NULL
, fMustAlloc
);
2014 /***********************************************************************
2015 * NdrComplexArrayBufferSize [RPCRT4.@]
2017 void WINAPI
NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2018 unsigned char *pMemory
,
2019 PFORMAT_STRING pFormat
)
2021 DWORD size
= 0, count
, def
;
2022 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2024 def
= *(const WORD
*)&pFormat
[2];
2027 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
2028 size
= pStubMsg
->MaxCount
;
2029 TRACE("conformance=%ld\n", size
);
2031 if (*(const DWORD
*)pFormat
!= 0xffffffff)
2032 FIXME("compute variance\n");
2035 for (count
=0; count
<size
; count
++)
2036 pMemory
= ComplexBufferSize(pStubMsg
, pMemory
, pFormat
, NULL
);
2039 /***********************************************************************
2040 * NdrComplexArrayMemorySize [RPCRT4.@]
2042 unsigned long WINAPI
NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2043 PFORMAT_STRING pFormat
)
2046 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
2050 pFormat
= ReadConformance(pStubMsg
, pFormat
);
2051 size
= pStubMsg
->MaxCount
;
2052 TRACE("conformance=%ld\n", size
);
2059 /***********************************************************************
2060 * NdrComplexArrayFree [RPCRT4.@]
2062 void WINAPI
NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2063 unsigned char *pMemory
,
2064 PFORMAT_STRING pFormat
)
2066 DWORD size
= 0, count
, def
;
2067 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2069 def
= *(const WORD
*)&pFormat
[2];
2072 pFormat
= ComputeConformance(pStubMsg
, pMemory
, pFormat
, def
);
2073 size
= pStubMsg
->MaxCount
;
2074 TRACE("conformance=%ld\n", size
);
2076 if (*(const DWORD
*)pFormat
!= 0xffffffff)
2077 FIXME("compute variance\n");
2080 for (count
=0; count
<size
; count
++)
2081 pMemory
= ComplexFree(pStubMsg
, pMemory
, pFormat
, NULL
);
2084 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg
)
2086 return MAKELONG(pStubMsg
->dwDestContext
,
2087 pStubMsg
->RpcMsg
->DataRepresentation
);
2090 /***********************************************************************
2091 * NdrUserMarshalMarshall [RPCRT4.@]
2093 unsigned char * WINAPI
NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2094 unsigned char *pMemory
,
2095 PFORMAT_STRING pFormat
)
2097 /* unsigned flags = pFormat[1]; */
2098 unsigned index
= *(const WORD
*)&pFormat
[2];
2099 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2100 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2101 TRACE("index=%d\n", index
);
2104 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnMarshall(
2105 &uflag
, pStubMsg
->Buffer
, pMemory
);
2107 STD_OVERFLOW_CHECK(pStubMsg
);
2112 /***********************************************************************
2113 * NdrUserMarshalUnmarshall [RPCRT4.@]
2115 unsigned char * WINAPI
NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2116 unsigned char **ppMemory
,
2117 PFORMAT_STRING pFormat
,
2118 unsigned char fMustAlloc
)
2120 /* unsigned flags = pFormat[1];*/
2121 unsigned index
= *(const WORD
*)&pFormat
[2];
2122 DWORD memsize
= *(const WORD
*)&pFormat
[4];
2123 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2124 TRACE("(%p,%p,%p,%d)\n", pStubMsg
, ppMemory
, pFormat
, fMustAlloc
);
2125 TRACE("index=%d\n", index
);
2127 if (fMustAlloc
|| !*ppMemory
)
2128 *ppMemory
= NdrAllocate(pStubMsg
, memsize
);
2131 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnUnmarshall(
2132 &uflag
, pStubMsg
->Buffer
, *ppMemory
);
2137 /***********************************************************************
2138 * NdrUserMarshalBufferSize [RPCRT4.@]
2140 void WINAPI
NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2141 unsigned char *pMemory
,
2142 PFORMAT_STRING pFormat
)
2144 /* unsigned flags = pFormat[1];*/
2145 unsigned index
= *(const WORD
*)&pFormat
[2];
2146 DWORD bufsize
= *(const WORD
*)&pFormat
[6];
2147 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2148 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2149 TRACE("index=%d\n", index
);
2152 TRACE("size=%ld\n", bufsize
);
2153 pStubMsg
->BufferLength
+= bufsize
;
2157 pStubMsg
->BufferLength
=
2158 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnBufferSize(
2159 &uflag
, pStubMsg
->BufferLength
, pMemory
);
2162 /***********************************************************************
2163 * NdrUserMarshalMemorySize [RPCRT4.@]
2165 unsigned long WINAPI
NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2166 PFORMAT_STRING pFormat
)
2168 unsigned index
= *(const WORD
*)&pFormat
[2];
2169 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2170 FIXME("(%p,%p): stub\n", pStubMsg
, pFormat
);
2171 TRACE("index=%d\n", index
);
2176 /***********************************************************************
2177 * NdrUserMarshalFree [RPCRT4.@]
2179 void WINAPI
NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg
,
2180 unsigned char *pMemory
,
2181 PFORMAT_STRING pFormat
)
2183 /* unsigned flags = pFormat[1]; */
2184 unsigned index
= *(const WORD
*)&pFormat
[2];
2185 unsigned long uflag
= UserMarshalFlags(pStubMsg
);
2186 TRACE("(%p,%p,%p)\n", pStubMsg
, pMemory
, pFormat
);
2187 TRACE("index=%d\n", index
);
2189 pStubMsg
->StubDesc
->aUserMarshalQuadruple
[index
].pfnFree(
2193 /***********************************************************************
2194 * NdrClearOutParameters [RPCRT4.@]
2196 void WINAPI
NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg
,
2197 PFORMAT_STRING pFormat
,
2200 FIXME("(%p,%p,%p): stub\n", pStubMsg
, pFormat
, ArgAddr
);
2203 /***********************************************************************
2204 * NdrConvert [RPCRT4.@]
2206 void WINAPI
NdrConvert( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
)
2208 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg
, pFormat
);
2209 /* FIXME: since this stub doesn't do any converting, the proper behavior
2210 is to raise an exception */
2213 /***********************************************************************
2214 * NdrConvert2 [RPCRT4.@]
2216 void WINAPI
NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg
, PFORMAT_STRING pFormat
, long NumberParams
)
2218 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2219 pStubMsg
, pFormat
, NumberParams
);
2220 /* FIXME: since this stub doesn't do any converting, the proper behavior
2221 is to raise an exception */
2224 /***********************************************************************
2225 * NdrConformantStructMarshall [RPCRT4.@]
2227 unsigned char * WINAPI
NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2228 unsigned char *pMemory
,
2229 PFORMAT_STRING pFormat
)
2235 /***********************************************************************
2236 * NdrConformantStructUnmarshall [RPCRT4.@]
2238 unsigned char * WINAPI
NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2239 unsigned char **ppMemory
,
2240 PFORMAT_STRING pFormat
,
2241 unsigned char fMustAlloc
)
2247 /***********************************************************************
2248 * NdrConformantStructBufferSize [RPCRT4.@]
2250 void WINAPI
NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2251 unsigned char *pMemory
,
2252 PFORMAT_STRING pFormat
)
2257 /***********************************************************************
2258 * NdrConformantStructMemorySize [RPCRT4.@]
2260 unsigned long WINAPI
NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2261 PFORMAT_STRING pFormat
)
2267 /***********************************************************************
2268 * NdrConformantStructFree [RPCRT4.@]
2270 void WINAPI
NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
2271 unsigned char *pMemory
,
2272 PFORMAT_STRING pFormat
)
2277 /***********************************************************************
2278 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2280 unsigned char * WINAPI
NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2281 unsigned char *pMemory
,
2282 PFORMAT_STRING pFormat
)
2288 /***********************************************************************
2289 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2291 unsigned char * WINAPI
NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2292 unsigned char **ppMemory
,
2293 PFORMAT_STRING pFormat
,
2294 unsigned char fMustAlloc
)
2300 /***********************************************************************
2301 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2303 void WINAPI
NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2304 unsigned char *pMemory
,
2305 PFORMAT_STRING pFormat
)
2310 /***********************************************************************
2311 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2313 unsigned long WINAPI
NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2314 PFORMAT_STRING pFormat
)
2320 /***********************************************************************
2321 * NdrConformantVaryingStructFree [RPCRT4.@]
2323 void WINAPI
NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg
,
2324 unsigned char *pMemory
,
2325 PFORMAT_STRING pFormat
)
2330 /***********************************************************************
2331 * NdrFixedArrayMarshall [RPCRT4.@]
2333 unsigned char * WINAPI
NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2334 unsigned char *pMemory
,
2335 PFORMAT_STRING pFormat
)
2341 /***********************************************************************
2342 * NdrFixedArrayUnmarshall [RPCRT4.@]
2344 unsigned char * WINAPI
NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2345 unsigned char **ppMemory
,
2346 PFORMAT_STRING pFormat
,
2347 unsigned char fMustAlloc
)
2353 /***********************************************************************
2354 * NdrFixedArrayBufferSize [RPCRT4.@]
2356 void WINAPI
NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2357 unsigned char *pMemory
,
2358 PFORMAT_STRING pFormat
)
2363 /***********************************************************************
2364 * NdrFixedArrayMemorySize [RPCRT4.@]
2366 unsigned long WINAPI
NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2367 PFORMAT_STRING pFormat
)
2373 /***********************************************************************
2374 * NdrFixedArrayFree [RPCRT4.@]
2376 void WINAPI
NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2377 unsigned char *pMemory
,
2378 PFORMAT_STRING pFormat
)
2383 /***********************************************************************
2384 * NdrVaryingArrayMarshall [RPCRT4.@]
2386 unsigned char * WINAPI
NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2387 unsigned char *pMemory
,
2388 PFORMAT_STRING pFormat
)
2394 /***********************************************************************
2395 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2397 unsigned char * WINAPI
NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2398 unsigned char **ppMemory
,
2399 PFORMAT_STRING pFormat
,
2400 unsigned char fMustAlloc
)
2406 /***********************************************************************
2407 * NdrVaryingArrayBufferSize [RPCRT4.@]
2409 void WINAPI
NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2410 unsigned char *pMemory
,
2411 PFORMAT_STRING pFormat
)
2416 /***********************************************************************
2417 * NdrVaryingArrayMemorySize [RPCRT4.@]
2419 unsigned long WINAPI
NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2420 PFORMAT_STRING pFormat
)
2426 /***********************************************************************
2427 * NdrVaryingArrayFree [RPCRT4.@]
2429 void WINAPI
NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg
,
2430 unsigned char *pMemory
,
2431 PFORMAT_STRING pFormat
)
2436 /***********************************************************************
2437 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2439 unsigned char * WINAPI
NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2440 unsigned char *pMemory
,
2441 PFORMAT_STRING pFormat
)
2447 /***********************************************************************
2448 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2450 unsigned char * WINAPI
NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2451 unsigned char **ppMemory
,
2452 PFORMAT_STRING pFormat
,
2453 unsigned char fMustAlloc
)
2459 /***********************************************************************
2460 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2462 void WINAPI
NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2463 unsigned char *pMemory
,
2464 PFORMAT_STRING pFormat
)
2469 /***********************************************************************
2470 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2472 unsigned long WINAPI
NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2473 PFORMAT_STRING pFormat
)
2479 /***********************************************************************
2480 * NdrEncapsulatedUnionFree [RPCRT4.@]
2482 void WINAPI
NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg
,
2483 unsigned char *pMemory
,
2484 PFORMAT_STRING pFormat
)
2489 /***********************************************************************
2490 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2492 unsigned char * WINAPI
NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2493 unsigned char *pMemory
,
2494 PFORMAT_STRING pFormat
)
2500 /***********************************************************************
2501 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2503 unsigned char * WINAPI
NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2504 unsigned char **ppMemory
,
2505 PFORMAT_STRING pFormat
,
2506 unsigned char fMustAlloc
)
2512 /***********************************************************************
2513 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2515 void WINAPI
NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2516 unsigned char *pMemory
,
2517 PFORMAT_STRING pFormat
)
2522 /***********************************************************************
2523 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2525 unsigned long WINAPI
NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2526 PFORMAT_STRING pFormat
)
2532 /***********************************************************************
2533 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2535 void WINAPI
NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg
,
2536 unsigned char *pMemory
,
2537 PFORMAT_STRING pFormat
)
2542 /***********************************************************************
2543 * NdrByteCountPointerMarshall [RPCRT4.@]
2545 unsigned char * WINAPI
NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2546 unsigned char *pMemory
,
2547 PFORMAT_STRING pFormat
)
2553 /***********************************************************************
2554 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2556 unsigned char * WINAPI
NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2557 unsigned char **ppMemory
,
2558 PFORMAT_STRING pFormat
,
2559 unsigned char fMustAlloc
)
2565 /***********************************************************************
2566 * NdrByteCountPointerBufferSize [RPCRT4.@]
2568 void WINAPI
NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2569 unsigned char *pMemory
,
2570 PFORMAT_STRING pFormat
)
2575 /***********************************************************************
2576 * NdrByteCountPointerMemorySize [RPCRT4.@]
2578 unsigned long WINAPI
NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2579 PFORMAT_STRING pFormat
)
2585 /***********************************************************************
2586 * NdrByteCountPointerFree [RPCRT4.@]
2588 void WINAPI
NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg
,
2589 unsigned char *pMemory
,
2590 PFORMAT_STRING pFormat
)
2595 /***********************************************************************
2596 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2598 unsigned char * WINAPI
NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2599 unsigned char *pMemory
,
2600 PFORMAT_STRING pFormat
)
2606 /***********************************************************************
2607 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2609 unsigned char * WINAPI
NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2610 unsigned char **ppMemory
,
2611 PFORMAT_STRING pFormat
,
2612 unsigned char fMustAlloc
)
2618 /***********************************************************************
2619 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2621 void WINAPI
NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg
,
2622 unsigned char *pMemory
,
2623 PFORMAT_STRING pFormat
)
2628 /***********************************************************************
2629 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2631 unsigned long WINAPI
NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg
,
2632 PFORMAT_STRING pFormat
)
2638 /***********************************************************************
2639 * NdrXmitOrRepAsFree [RPCRT4.@]
2641 void WINAPI
NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg
,
2642 unsigned char *pMemory
,
2643 PFORMAT_STRING pFormat
)
2648 /***********************************************************************
2649 * NdrClientContextMarshall
2651 void WINAPI
NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2652 NDR_CCONTEXT ContextHandle
,
2655 FIXME("(%p, %p, %d): stub\n", pStubMsg
, ContextHandle
, fCheck
);
2658 /***********************************************************************
2659 * NdrClientContextUnmarshall
2661 void WINAPI
NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg
,
2662 NDR_CCONTEXT
* pContextHandle
,
2663 RPC_BINDING_HANDLE BindHandle
)
2665 FIXME("(%p, %p, %p): stub\n", pStubMsg
, pContextHandle
, BindHandle
);