Sync to Wine-0_9_1:
[reactos.git] / reactos / lib / rpcrt4 / ndr_marshall.c
1 /*
2 * NDR data marshalling
3 *
4 * Copyright 2002 Greg Turner
5 *
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.
10 *
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.
15 *
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
19 *
20 * TODO:
21 * - figure out whether we *really* got this right
22 * - check for errors and throw exceptions
23 */
24
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <assert.h>
29
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winerror.h"
33 #include "winreg.h"
34
35 #include "ndr_misc.h"
36 #include "rpcndr.h"
37
38 #include "wine/unicode.h"
39 #include "wine/rpcfc.h"
40
41 #include "wine/debug.h"
42
43 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44
45 #define BUFFER_PARANOIA 20
46
47 #if defined(__i386__)
48 # define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
49 (*((UINT32 *)(pchar)) = (uint32))
50
51 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
52 (*((UINT32 *)(pchar)))
53 #else
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 */
61
62 # define LITTLE_ENDIAN_UINT32_READ(pchar) \
63 (MAKELONG( \
64 MAKEWORD(*(pchar), *((pchar)+1)), \
65 MAKEWORD(*((pchar)+2), *((pchar)+3))))
66 #endif
67
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 */
74
75 #define BIG_ENDIAN_UINT32_READ(pchar) \
76 (MAKELONG( \
77 MAKEWORD(*((pchar)+3), *((pchar)+2)), \
78 MAKEWORD(*((pchar)+1), *(pchar))))
79
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)
85 #else
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)
90 #endif
91
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)
98
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); \
102 } while (0)
103
104 #define NDR_TABLE_SIZE 128
105 #define NDR_TABLE_MASK 127
106
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,
110 /* 0x10 */
111 0,
112 /* 0x11 */
113 NdrPointerMarshall, NdrPointerMarshall,
114 NdrPointerMarshall, NdrPointerMarshall,
115 /* 0x15 */
116 NdrSimpleStructMarshall, NdrSimpleStructMarshall,
117 NdrConformantStructMarshall, NdrConformantStructMarshall,
118 NdrConformantVaryingStructMarshall,
119 NdrComplexStructMarshall,
120 /* 0x1b */
121 NdrConformantArrayMarshall,
122 NdrConformantVaryingArrayMarshall,
123 NdrFixedArrayMarshall, NdrFixedArrayMarshall,
124 NdrVaryingArrayMarshall, NdrVaryingArrayMarshall,
125 NdrComplexArrayMarshall,
126 /* 0x22 */
127 NdrConformantStringMarshall, 0, 0,
128 NdrConformantStringMarshall,
129 NdrNonConformantStringMarshall, 0, 0, 0,
130 /* 0x2a */
131 NdrEncapsulatedUnionMarshall,
132 NdrNonEncapsulatedUnionMarshall,
133 0,
134 NdrXmitOrRepAsMarshall, NdrXmitOrRepAsMarshall,
135 /* 0x2f */
136 NdrInterfacePointerMarshall,
137 /* 0xb0 */
138 0, 0, 0, 0,
139 NdrUserMarshalMarshall
140 };
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,
144 /* 0x10 */
145 0,
146 /* 0x11 */
147 NdrPointerUnmarshall, NdrPointerUnmarshall,
148 NdrPointerUnmarshall, NdrPointerUnmarshall,
149 /* 0x15 */
150 NdrSimpleStructUnmarshall, NdrSimpleStructUnmarshall,
151 NdrConformantStructUnmarshall, NdrConformantStructUnmarshall,
152 NdrConformantVaryingStructUnmarshall,
153 NdrComplexStructUnmarshall,
154 /* 0x1b */
155 NdrConformantArrayUnmarshall,
156 NdrConformantVaryingArrayUnmarshall,
157 NdrFixedArrayUnmarshall, NdrFixedArrayUnmarshall,
158 NdrVaryingArrayUnmarshall, NdrVaryingArrayUnmarshall,
159 NdrComplexArrayUnmarshall,
160 /* 0x22 */
161 NdrConformantStringUnmarshall, 0, 0,
162 NdrConformantStringUnmarshall,
163 NdrNonConformantStringUnmarshall, 0, 0, 0,
164 /* 0x2a */
165 NdrEncapsulatedUnionUnmarshall,
166 NdrNonEncapsulatedUnionUnmarshall,
167 0,
168 NdrXmitOrRepAsUnmarshall, NdrXmitOrRepAsUnmarshall,
169 /* 0x2f */
170 NdrInterfacePointerUnmarshall,
171 /* 0xb0 */
172 0, 0, 0, 0,
173 NdrUserMarshalUnmarshall
174 };
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,
178 /* 0x10 */
179 0,
180 /* 0x11 */
181 NdrPointerBufferSize, NdrPointerBufferSize,
182 NdrPointerBufferSize, NdrPointerBufferSize,
183 /* 0x15 */
184 NdrSimpleStructBufferSize, NdrSimpleStructBufferSize,
185 NdrConformantStructBufferSize, NdrConformantStructBufferSize,
186 NdrConformantVaryingStructBufferSize,
187 NdrComplexStructBufferSize,
188 /* 0x1b */
189 NdrConformantArrayBufferSize,
190 NdrConformantVaryingArrayBufferSize,
191 NdrFixedArrayBufferSize, NdrFixedArrayBufferSize,
192 NdrVaryingArrayBufferSize, NdrVaryingArrayBufferSize,
193 NdrComplexArrayBufferSize,
194 /* 0x22 */
195 NdrConformantStringBufferSize, 0, 0,
196 NdrConformantStringBufferSize,
197 NdrNonConformantStringBufferSize, 0, 0, 0,
198 /* 0x2a */
199 NdrEncapsulatedUnionBufferSize,
200 NdrNonEncapsulatedUnionBufferSize,
201 0,
202 NdrXmitOrRepAsBufferSize, NdrXmitOrRepAsBufferSize,
203 /* 0x2f */
204 NdrInterfacePointerBufferSize,
205 /* 0xb0 */
206 0, 0, 0, 0,
207 NdrUserMarshalBufferSize
208 };
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,
212 /* 0x10 */
213 0,
214 /* 0x11 */
215 NdrPointerMemorySize, NdrPointerMemorySize,
216 NdrPointerMemorySize, NdrPointerMemorySize,
217 /* 0x15 */
218 NdrSimpleStructMemorySize, NdrSimpleStructMemorySize,
219 0, 0, 0,
220 NdrComplexStructMemorySize,
221 /* 0x1b */
222 NdrConformantArrayMemorySize, 0, 0, 0, 0, 0,
223 NdrComplexArrayMemorySize,
224 /* 0x22 */
225 NdrConformantStringMemorySize, 0, 0,
226 NdrConformantStringMemorySize,
227 NdrNonConformantStringMemorySize, 0, 0, 0,
228 /* 0x2a */
229 0, 0, 0, 0, 0,
230 /* 0x2f */
231 NdrInterfacePointerMemorySize,
232 /* 0xb0 */
233 0, 0, 0, 0,
234 NdrUserMarshalMemorySize
235 };
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,
239 /* 0x10 */
240 0,
241 /* 0x11 */
242 NdrPointerFree, NdrPointerFree,
243 NdrPointerFree, NdrPointerFree,
244 /* 0x15 */
245 NdrSimpleStructFree, NdrSimpleStructFree,
246 NdrConformantStructFree, NdrConformantStructFree,
247 NdrConformantVaryingStructFree,
248 NdrComplexStructFree,
249 /* 0x1b */
250 NdrConformantArrayFree,
251 NdrConformantVaryingArrayFree,
252 NdrFixedArrayFree, NdrFixedArrayFree,
253 NdrVaryingArrayFree, NdrVaryingArrayFree,
254 NdrComplexArrayFree,
255 /* 0x22 */
256 0, 0, 0,
257 0, 0, 0, 0, 0,
258 /* 0x2a */
259 NdrEncapsulatedUnionFree,
260 NdrNonEncapsulatedUnionFree,
261 0,
262 NdrXmitOrRepAsFree, NdrXmitOrRepAsFree,
263 /* 0x2f */
264 NdrInterfacePointerFree,
265 /* 0xb0 */
266 0, 0, 0, 0,
267 NdrUserMarshalFree
268 };
269
270 void * WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, size_t len)
271 {
272 /* hmm, this is probably supposed to do more? */
273 return pStubMsg->pfnAllocate(len);
274 }
275
276 static void WINAPI NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
277 {
278 pStubMsg->pfnFree(Pointer);
279 }
280
281 PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
282 {
283 pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
284 pStubMsg->Buffer += 4;
285 TRACE("unmarshalled conformance is %ld\n", pStubMsg->MaxCount);
286 return pFormat+4;
287 }
288
289 PFORMAT_STRING ComputeConformance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
290 PFORMAT_STRING pFormat, ULONG_PTR def)
291 {
292 BYTE dtype = pFormat[0] & 0xf;
293 DWORD ofs = (DWORD)pFormat[2] | ((DWORD)pFormat[3] << 8);
294 LPVOID ptr = NULL;
295 DWORD data = 0;
296
297 if (pFormat[0] == 0xff) {
298 /* null descriptor */
299 pStubMsg->MaxCount = def;
300 goto finish_conf;
301 }
302
303 switch (pFormat[0] & 0xf0) {
304 case RPC_FC_NORMAL_CONFORMANCE:
305 TRACE("normal conformance, ofs=%ld\n", ofs);
306 ptr = pMemory + ofs;
307 break;
308 case RPC_FC_POINTER_CONFORMANCE:
309 TRACE("pointer conformance, ofs=%ld\n", ofs);
310 ptr = pStubMsg->Memory + ofs;
311 break;
312 case RPC_FC_TOP_LEVEL_CONFORMANCE:
313 TRACE("toplevel conformance, ofs=%ld\n", ofs);
314 if (pStubMsg->StackTop) {
315 ptr = pStubMsg->StackTop + ofs;
316 }
317 else {
318 /* -Os mode, MaxCount is already set */
319 goto finish_conf;
320 }
321 break;
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;
326 goto finish_conf;
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;
331 }
332 else {
333 /* ? */
334 goto done_conf_grab;
335 }
336 break;
337 default:
338 FIXME("unknown conformance type %x\n", pFormat[0] & 0xf0);
339 }
340
341 switch (pFormat[1]) {
342 case RPC_FC_DEREFERENCE:
343 ptr = *(LPVOID*)ptr;
344 break;
345 case RPC_FC_CALLBACK:
346 /* ofs is index into StubDesc->apfnExprEval */
347 FIXME("handle callback\n");
348 goto finish_conf;
349 default:
350 break;
351 }
352
353 switch (dtype) {
354 case RPC_FC_LONG:
355 case RPC_FC_ULONG:
356 data = *(DWORD*)ptr;
357 break;
358 case RPC_FC_SHORT:
359 data = *(SHORT*)ptr;
360 break;
361 case RPC_FC_USHORT:
362 data = *(USHORT*)ptr;
363 break;
364 case RPC_FC_SMALL:
365 data = *(CHAR*)ptr;
366 break;
367 case RPC_FC_USMALL:
368 data = *(UCHAR*)ptr;
369 break;
370 default:
371 FIXME("unknown conformance data type %x\n", dtype);
372 goto done_conf_grab;
373 }
374 TRACE("dereferenced data type %x at %p, got %ld\n", dtype, ptr, data);
375
376 done_conf_grab:
377 switch (pFormat[1]) {
378 case 0: /* no op */
379 pStubMsg->MaxCount = data;
380 break;
381 case RPC_FC_DEREFERENCE:
382 /* already handled */
383 break;
384 default:
385 FIXME("unknown conformance op %d\n", pFormat[1]);
386 goto finish_conf;
387 }
388
389 finish_conf:
390 TRACE("resulting conformance is %ld\n", pStubMsg->MaxCount);
391 return pFormat+4;
392 }
393
394
395 /*
396 * NdrConformantString:
397 *
398 * What MS calls a ConformantString is, in DCE terminology,
399 * a Varying-Conformant String.
400 * [
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')
405 * [
406 * data: CHARTYPE[maxlen]
407 * ]
408 * ], where CHARTYPE is the appropriate character type (specified externally)
409 *
410 */
411
412 /***********************************************************************
413 * NdrConformantStringMarshall [RPCRT4.@]
414 */
415 unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg,
416 unsigned char *pszMessage, PFORMAT_STRING pFormat)
417 {
418 unsigned long len, esize;
419 unsigned char *c;
420
421 TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
422
423 assert(pFormat);
424 if (pszMessage == NULL) {
425 TRACE("string=%s\n", debugstr_a(pszMessage));
426 len = 0;
427 esize = 0;
428 }
429 else if (*pFormat == RPC_FC_C_CSTRING) {
430 TRACE("string=%s\n", debugstr_a(pszMessage));
431 len = strlen(pszMessage)+1;
432 esize = 1;
433 }
434 else if (*pFormat == RPC_FC_C_WSTRING) {
435 TRACE("string=%s\n", debugstr_w((LPWSTR)pszMessage));
436 len = strlenW((LPWSTR)pszMessage)+1;
437 esize = 2;
438 }
439 else {
440 ERR("Unhandled string type: %#x\n", *pFormat);
441 /* FIXME: raise an exception. */
442 return NULL;
443 }
444
445 if (pFormat[1] != RPC_FC_PAD) {
446 FIXME("sized string format=%d\n", pFormat[1]);
447 }
448
449 assert( (pStubMsg->BufferLength >= (len*esize + 13)) && (pStubMsg->Buffer != NULL) );
450
451 c = pStubMsg->Buffer;
452 memset(c, 0, 12);
453 NDR_LOCAL_UINT32_WRITE(c, len); /* max length: strlen + 1 (for '\0') */
454 c += 8; /* offset: 0 */
455 NDR_LOCAL_UINT32_WRITE(c, len); /* actual length: (same) */
456 c += 4;
457 if (len != 0) {
458 memcpy(c, pszMessage, len*esize); /* the string itself */
459 c += len*esize;
460 }
461 pStubMsg->Buffer = c;
462
463 STD_OVERFLOW_CHECK(pStubMsg);
464
465 /* success */
466 return NULL; /* is this always right? */
467 }
468
469 /***********************************************************************
470 * NdrConformantStringBufferSize [RPCRT4.@]
471 */
472 void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
473 unsigned char* pMemory, PFORMAT_STRING pFormat)
474 {
475 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
476
477 assert(pFormat);
478 if (pMemory == NULL) {
479 /* we need 12 octets for the [maxlen, offset, len] DWORDS */
480 TRACE("string=NULL\n");
481 pStubMsg->BufferLength += 12 + BUFFER_PARANOIA;
482 }
483 else if (*pFormat == RPC_FC_C_CSTRING) {
484 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */
485 TRACE("string=%s\n", debugstr_a((char*)pMemory));
486 pStubMsg->BufferLength += strlen((char*)pMemory) + 13 + BUFFER_PARANOIA;
487 }
488 else if (*pFormat == RPC_FC_C_WSTRING) {
489 /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 2 octets for L'\0' */
490 TRACE("string=%s\n", debugstr_w((LPWSTR)pMemory));
491 pStubMsg->BufferLength += strlenW((LPWSTR)pMemory)*2 + 14 + BUFFER_PARANOIA;
492 }
493 else {
494 ERR("Unhandled string type: %#x\n", *pFormat);
495 /* FIXME: raise an exception */
496 }
497
498 if (pFormat[1] != RPC_FC_PAD) {
499 FIXME("sized string format=%d\n", pFormat[1]);
500 }
501 }
502
503 /************************************************************************
504 * NdrConformantStringMemorySize [RPCRT4.@]
505 */
506 unsigned long WINAPI NdrConformantStringMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
507 PFORMAT_STRING pFormat )
508 {
509 unsigned long rslt = 0;
510
511 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
512
513 assert(pStubMsg && pFormat);
514
515 if (*pFormat == RPC_FC_C_CSTRING) {
516 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer); /* maxlen */
517 }
518 else if (*pFormat == RPC_FC_C_WSTRING) {
519 rslt = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer)*2; /* maxlen */
520 }
521 else {
522 ERR("Unhandled string type: %#x\n", *pFormat);
523 /* FIXME: raise an exception */
524 }
525
526 if (pFormat[1] != RPC_FC_PAD) {
527 FIXME("sized string format=%d\n", pFormat[1]);
528 }
529
530 TRACE(" --> %lu\n", rslt);
531 return rslt;
532 }
533
534 /************************************************************************
535 * NdrConformantStringUnmarshall [RPCRT4.@]
536 */
537 unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
538 unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc )
539 {
540 unsigned long len, esize, ofs;
541 unsigned char *pMem;
542
543 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
544 pStubMsg, *ppMemory, pFormat, fMustAlloc);
545
546 assert(pFormat && ppMemory && pStubMsg);
547
548 pStubMsg->Buffer += 4;
549 ofs = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
550 pStubMsg->Buffer += 4;
551 len = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
552 pStubMsg->Buffer += 4;
553
554 if (*pFormat == RPC_FC_C_CSTRING) esize = 1;
555 else if (*pFormat == RPC_FC_C_WSTRING) esize = 2;
556 else {
557 ERR("Unhandled string type: %#x\n", *pFormat);
558 /* FIXME: raise an exception */
559 esize = 0;
560 }
561
562 if (pFormat[1] != RPC_FC_PAD) {
563 FIXME("sized string format=%d\n", pFormat[1]);
564 }
565
566 if (fMustAlloc) {
567 *ppMemory = NdrAllocate(pStubMsg, len*esize + BUFFER_PARANOIA);
568 } else {
569 if (pStubMsg->ReuseBuffer && !*ppMemory)
570 /* for servers, we may just point straight into the RPC buffer, I think
571 * (I guess that's what MS does since MIDL code doesn't try to free) */
572 *ppMemory = pStubMsg->Buffer - ofs*esize;
573 /* for clients, memory should be provided by caller */
574 }
575
576 if (len == 0) {
577 *ppMemory = NULL;
578 return NULL;
579 }
580
581 pMem = *ppMemory + ofs*esize;
582
583 if (pMem != pStubMsg->Buffer)
584 memcpy(pMem, pStubMsg->Buffer, len*esize);
585
586 pStubMsg->Buffer += len*esize;
587
588 if (*pFormat == RPC_FC_C_CSTRING) {
589 TRACE("string=%s\n", debugstr_a((char*)pMem));
590 }
591 else if (*pFormat == RPC_FC_C_WSTRING) {
592 TRACE("string=%s\n", debugstr_w((LPWSTR)pMem));
593 }
594
595 return NULL; /* FIXME: is this always right? */
596 }
597
598 /***********************************************************************
599 * NdrNonConformantStringMarshall [RPCRT4.@]
600 */
601 unsigned char * WINAPI NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE pStubMsg,
602 unsigned char *pMemory,
603 PFORMAT_STRING pFormat)
604 {
605 FIXME("stub\n");
606 return NULL;
607 }
608
609 /***********************************************************************
610 * NdrNonConformantStringUnmarshall [RPCRT4.@]
611 */
612 unsigned char * WINAPI NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
613 unsigned char **ppMemory,
614 PFORMAT_STRING pFormat,
615 unsigned char fMustAlloc)
616 {
617 FIXME("stub\n");
618 return NULL;
619 }
620
621 /***********************************************************************
622 * NdrNonConformantStringBufferSize [RPCRT4.@]
623 */
624 void WINAPI NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
625 unsigned char *pMemory,
626 PFORMAT_STRING pFormat)
627 {
628 FIXME("stub\n");
629 }
630
631 /***********************************************************************
632 * NdrNonConformantStringMemorySize [RPCRT4.@]
633 */
634 unsigned long WINAPI NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
635 PFORMAT_STRING pFormat)
636 {
637 FIXME("stub\n");
638 return 0;
639 }
640
641 static inline void dump_pointer_attr(unsigned char attr)
642 {
643 if (attr & RPC_FC_P_ALLOCALLNODES)
644 TRACE(" RPC_FC_P_ALLOCALLNODES");
645 if (attr & RPC_FC_P_DONTFREE)
646 TRACE(" RPC_FC_P_DONTFREE");
647 if (attr & RPC_FC_P_ONSTACK)
648 TRACE(" RPC_FC_P_ONSTACK");
649 if (attr & RPC_FC_P_SIMPLEPOINTER)
650 TRACE(" RPC_FC_P_SIMPLEPOINTER");
651 if (attr & RPC_FC_P_DEREF)
652 TRACE(" RPC_FC_P_DEREF");
653 TRACE("\n");
654 }
655
656 /***********************************************************************
657 * PointerMarshall
658 */
659 void WINAPI PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
660 unsigned char *Buffer,
661 unsigned char *Pointer,
662 PFORMAT_STRING pFormat)
663 {
664 unsigned type = pFormat[0], attr = pFormat[1];
665 PFORMAT_STRING desc;
666 NDR_MARSHALL m;
667
668 TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
669 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
670 pFormat += 2;
671 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
672 else desc = pFormat + *(const SHORT*)pFormat;
673 if (attr & RPC_FC_P_DEREF) {
674 Pointer = *(unsigned char**)Pointer;
675 TRACE("deref => %p\n", Pointer);
676 }
677
678 switch (type) {
679 case RPC_FC_RP: /* ref pointer (always non-null) */
680 #if 0 /* this causes problems for InstallShield so is disabled - we need more tests */
681 if (!Pointer)
682 RpcRaiseException(RPC_X_NULL_REF_POINTER);
683 #endif
684 break;
685 case RPC_FC_UP: /* unique pointer */
686 case RPC_FC_OP: /* object pointer - same as unique here */
687 TRACE("writing %p to buffer\n", Pointer);
688 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, (unsigned long)Pointer);
689 pStubMsg->Buffer += 4;
690 break;
691 case RPC_FC_FP:
692 default:
693 FIXME("unhandled ptr type=%02x\n", type);
694 RpcRaiseException(RPC_X_BAD_STUB_DATA);
695 }
696
697 TRACE("calling marshaller for type 0x%x\n", (int)*desc);
698
699 if (Pointer) {
700 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
701 if (m) m(pStubMsg, Pointer, desc);
702 else FIXME("no marshaller for data type=%02x\n", *desc);
703 }
704
705 STD_OVERFLOW_CHECK(pStubMsg);
706 }
707
708 /***********************************************************************
709 * PointerUnmarshall
710 */
711 void WINAPI PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
712 unsigned char *Buffer,
713 unsigned char **pPointer,
714 PFORMAT_STRING pFormat,
715 unsigned char fMustAlloc)
716 {
717 unsigned type = pFormat[0], attr = pFormat[1];
718 PFORMAT_STRING desc;
719 NDR_UNMARSHALL m;
720 DWORD pointer_id = 0;
721
722 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pFormat, fMustAlloc);
723 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
724 pFormat += 2;
725 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
726 else desc = pFormat + *(const SHORT*)pFormat;
727 if (attr & RPC_FC_P_DEREF) {
728 pPointer = *(unsigned char***)pPointer;
729 TRACE("deref => %p\n", pPointer);
730 }
731
732 switch (type) {
733 case RPC_FC_RP: /* ref pointer (always non-null) */
734 pointer_id = ~0UL;
735 break;
736 case RPC_FC_UP: /* unique pointer */
737 pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
738 pStubMsg->Buffer += 4;
739 break;
740 case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
741 pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
742 pStubMsg->Buffer += 4;
743 if (*pPointer)
744 FIXME("free object pointer %p\n", *pPointer);
745 break;
746 case RPC_FC_FP:
747 default:
748 FIXME("unhandled ptr type=%02x\n", type);
749 RpcRaiseException(RPC_X_BAD_STUB_DATA);
750 }
751
752 *pPointer = NULL;
753
754 if (pointer_id) {
755 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
756 if (m) m(pStubMsg, pPointer, desc, fMustAlloc);
757 else FIXME("no unmarshaller for data type=%02x\n", *desc);
758 }
759
760 TRACE("pointer=%p\n", *pPointer);
761 }
762
763 /***********************************************************************
764 * PointerBufferSize
765 */
766 void WINAPI PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
767 unsigned char *Pointer,
768 PFORMAT_STRING pFormat)
769 {
770 unsigned type = pFormat[0], attr = pFormat[1];
771 PFORMAT_STRING desc;
772 NDR_BUFFERSIZE m;
773
774 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
775 TRACE("type=%d, attr=%d\n", type, attr);
776 pFormat += 2;
777 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
778 else desc = pFormat + *(const SHORT*)pFormat;
779 if (attr & RPC_FC_P_DEREF) {
780 Pointer = *(unsigned char**)Pointer;
781 TRACE("deref => %p\n", Pointer);
782 }
783
784 switch (type) {
785 case RPC_FC_RP: /* ref pointer (always non-null) */
786 break;
787 case RPC_FC_OP:
788 case RPC_FC_UP:
789 pStubMsg->BufferLength += 4;
790 /* NULL pointer has no further representation */
791 if (!Pointer)
792 return;
793 break;
794 case RPC_FC_FP:
795 default:
796 FIXME("unhandled ptr type=%02x\n", type);
797 RpcRaiseException(RPC_X_BAD_STUB_DATA);
798 }
799
800 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
801 if (m) m(pStubMsg, Pointer, desc);
802 else FIXME("no buffersizer for data type=%02x\n", *desc);
803 }
804
805 /***********************************************************************
806 * PointerMemorySize [RPCRT4.@]
807 */
808 unsigned long WINAPI PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
809 unsigned char *Buffer,
810 PFORMAT_STRING pFormat)
811 {
812 unsigned type = pFormat[0], attr = pFormat[1];
813 PFORMAT_STRING desc;
814 NDR_MEMORYSIZE m;
815
816 FIXME("(%p,%p,%p): stub\n", pStubMsg, Buffer, pFormat);
817 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
818 pFormat += 2;
819 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
820 else desc = pFormat + *(const SHORT*)pFormat;
821 if (attr & RPC_FC_P_DEREF) {
822 TRACE("deref\n");
823 }
824
825 switch (type) {
826 case RPC_FC_RP: /* ref pointer (always non-null) */
827 break;
828 default:
829 FIXME("unhandled ptr type=%02x\n", type);
830 RpcRaiseException(RPC_X_BAD_STUB_DATA);
831 }
832
833 m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
834 if (m) m(pStubMsg, desc);
835 else FIXME("no memorysizer for data type=%02x\n", *desc);
836
837 return 0;
838 }
839
840 /***********************************************************************
841 * PointerFree [RPCRT4.@]
842 */
843 void WINAPI PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
844 unsigned char *Pointer,
845 PFORMAT_STRING pFormat)
846 {
847 unsigned type = pFormat[0], attr = pFormat[1];
848 PFORMAT_STRING desc;
849 NDR_FREE m;
850
851 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
852 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
853 if (attr & RPC_FC_P_DONTFREE) return;
854 pFormat += 2;
855 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
856 else desc = pFormat + *(const SHORT*)pFormat;
857 if (attr & RPC_FC_P_DEREF) {
858 Pointer = *(unsigned char**)Pointer;
859 TRACE("deref => %p\n", Pointer);
860 }
861
862 if (!Pointer) return;
863
864 m = NdrFreer[*desc & NDR_TABLE_MASK];
865 if (m) m(pStubMsg, Pointer, desc);
866
867 /* hmm... is this sensible?
868 * perhaps we should check if the memory comes from NdrAllocate,
869 * and deallocate only if so - checking if the pointer is between
870 * BufferStart and BufferEnd is probably no good since the buffer
871 * may be reallocated when the server wants to marshal the reply */
872 switch (*desc) {
873 case RPC_FC_BOGUS_STRUCT:
874 case RPC_FC_BOGUS_ARRAY:
875 case RPC_FC_USER_MARSHAL:
876 break;
877 default:
878 FIXME("unhandled data type=%02x\n", *desc);
879 case RPC_FC_CARRAY:
880 case RPC_FC_C_CSTRING:
881 case RPC_FC_C_WSTRING:
882 if (pStubMsg->ReuseBuffer) goto notfree;
883 break;
884 case RPC_FC_IP:
885 goto notfree;
886 }
887
888 if (attr & RPC_FC_P_ONSTACK) {
889 TRACE("not freeing stack ptr %p\n", Pointer);
890 return;
891 }
892 TRACE("freeing %p\n", Pointer);
893 NdrFree(pStubMsg, Pointer);
894 return;
895 notfree:
896 TRACE("not freeing %p\n", Pointer);
897 }
898
899 /***********************************************************************
900 * EmbeddedPointerMarshall
901 */
902 unsigned char * WINAPI EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
903 unsigned char *pMemory,
904 PFORMAT_STRING pFormat)
905 {
906 unsigned char *Mark = pStubMsg->BufferMark;
907 unsigned long Offset = pStubMsg->Offset;
908 unsigned ofs, rep, count, stride, xofs;
909
910 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
911
912 if (*pFormat != RPC_FC_PP) return NULL;
913 pFormat += 2;
914
915 while (pFormat[0] != RPC_FC_END) {
916 switch (pFormat[0]) {
917 default:
918 FIXME("unknown repeat type %d\n", pFormat[0]);
919 case RPC_FC_NO_REPEAT:
920 rep = 1;
921 stride = 0;
922 ofs = 0;
923 count = 1;
924 xofs = 0;
925 pFormat += 2;
926 break;
927 case RPC_FC_FIXED_REPEAT:
928 rep = *(const WORD*)&pFormat[2];
929 stride = *(const WORD*)&pFormat[4];
930 ofs = *(const WORD*)&pFormat[6];
931 count = *(const WORD*)&pFormat[8];
932 xofs = 0;
933 pFormat += 10;
934 break;
935 case RPC_FC_VARIABLE_REPEAT:
936 rep = pStubMsg->MaxCount;
937 stride = *(const WORD*)&pFormat[2];
938 ofs = *(const WORD*)&pFormat[4];
939 count = *(const WORD*)&pFormat[6];
940 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
941 pFormat += 8;
942 break;
943 }
944 /* ofs doesn't seem to matter in this context */
945 while (rep) {
946 PFORMAT_STRING info = pFormat;
947 unsigned char *membase = pMemory + xofs;
948 unsigned u;
949 for (u=0; u<count; u++,info+=8) {
950 unsigned char *memptr = membase + *(const SHORT*)&info[0];
951 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
952 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
953 }
954 rep--;
955 }
956 pFormat += 8 * count;
957 }
958
959 STD_OVERFLOW_CHECK(pStubMsg);
960
961 return NULL;
962 }
963
964 /***********************************************************************
965 * EmbeddedPointerUnmarshall
966 */
967 unsigned char * WINAPI EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
968 unsigned char **ppMemory,
969 PFORMAT_STRING pFormat,
970 unsigned char fMustAlloc)
971 {
972 unsigned char *Mark = pStubMsg->BufferMark;
973 unsigned long Offset = pStubMsg->Offset;
974 unsigned ofs, rep, count, stride, xofs;
975
976 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
977
978 if (*pFormat != RPC_FC_PP) return NULL;
979 pFormat += 2;
980
981 while (pFormat[0] != RPC_FC_END) {
982 switch (pFormat[0]) {
983 default:
984 FIXME("unknown repeat type %d\n", pFormat[0]);
985 case RPC_FC_NO_REPEAT:
986 rep = 1;
987 stride = 0;
988 ofs = 0;
989 count = 1;
990 xofs = 0;
991 pFormat += 2;
992 break;
993 case RPC_FC_FIXED_REPEAT:
994 rep = *(const WORD*)&pFormat[2];
995 stride = *(const WORD*)&pFormat[4];
996 ofs = *(const WORD*)&pFormat[6];
997 count = *(const WORD*)&pFormat[8];
998 xofs = 0;
999 pFormat += 10;
1000 break;
1001 case RPC_FC_VARIABLE_REPEAT:
1002 rep = pStubMsg->MaxCount;
1003 stride = *(const WORD*)&pFormat[2];
1004 ofs = *(const WORD*)&pFormat[4];
1005 count = *(const WORD*)&pFormat[6];
1006 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1007 pFormat += 8;
1008 break;
1009 }
1010 /* ofs doesn't seem to matter in this context */
1011 while (rep) {
1012 PFORMAT_STRING info = pFormat;
1013 unsigned char *membase = *ppMemory + xofs;
1014 unsigned u;
1015 for (u=0; u<count; u++,info+=8) {
1016 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1017 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1018 PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
1019 }
1020 rep--;
1021 }
1022 pFormat += 8 * count;
1023 }
1024
1025 return NULL;
1026 }
1027
1028 /***********************************************************************
1029 * EmbeddedPointerBufferSize
1030 */
1031 void WINAPI EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1032 unsigned char *pMemory,
1033 PFORMAT_STRING pFormat)
1034 {
1035 unsigned long Offset = pStubMsg->Offset;
1036 unsigned ofs, rep, count, stride, xofs;
1037
1038 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1039 if (*pFormat != RPC_FC_PP) return;
1040 pFormat += 2;
1041
1042 while (pFormat[0] != RPC_FC_END) {
1043 switch (pFormat[0]) {
1044 default:
1045 FIXME("unknown repeat type %d\n", pFormat[0]);
1046 case RPC_FC_NO_REPEAT:
1047 rep = 1;
1048 stride = 0;
1049 ofs = 0;
1050 count = 1;
1051 xofs = 0;
1052 pFormat += 2;
1053 break;
1054 case RPC_FC_FIXED_REPEAT:
1055 rep = *(const WORD*)&pFormat[2];
1056 stride = *(const WORD*)&pFormat[4];
1057 ofs = *(const WORD*)&pFormat[6];
1058 count = *(const WORD*)&pFormat[8];
1059 xofs = 0;
1060 pFormat += 10;
1061 break;
1062 case RPC_FC_VARIABLE_REPEAT:
1063 rep = pStubMsg->MaxCount;
1064 stride = *(const WORD*)&pFormat[2];
1065 ofs = *(const WORD*)&pFormat[4];
1066 count = *(const WORD*)&pFormat[6];
1067 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1068 pFormat += 8;
1069 break;
1070 }
1071 /* ofs doesn't seem to matter in this context */
1072 while (rep) {
1073 PFORMAT_STRING info = pFormat;
1074 unsigned char *membase = pMemory + xofs;
1075 unsigned u;
1076 for (u=0; u<count; u++,info+=8) {
1077 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1078 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1079 }
1080 rep--;
1081 }
1082 pFormat += 8 * count;
1083 }
1084 }
1085
1086 /***********************************************************************
1087 * EmbeddedPointerMemorySize
1088 */
1089 unsigned long WINAPI EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1090 PFORMAT_STRING pFormat)
1091 {
1092 unsigned long Offset = pStubMsg->Offset;
1093 unsigned char *Mark = pStubMsg->BufferMark;
1094 unsigned ofs, rep, count, stride, xofs;
1095
1096 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1097 if (*pFormat != RPC_FC_PP) return 0;
1098 pFormat += 2;
1099
1100 while (pFormat[0] != RPC_FC_END) {
1101 switch (pFormat[0]) {
1102 default:
1103 FIXME("unknown repeat type %d\n", pFormat[0]);
1104 case RPC_FC_NO_REPEAT:
1105 rep = 1;
1106 stride = 0;
1107 ofs = 0;
1108 count = 1;
1109 xofs = 0;
1110 pFormat += 2;
1111 break;
1112 case RPC_FC_FIXED_REPEAT:
1113 rep = *(const WORD*)&pFormat[2];
1114 stride = *(const WORD*)&pFormat[4];
1115 ofs = *(const WORD*)&pFormat[6];
1116 count = *(const WORD*)&pFormat[8];
1117 xofs = 0;
1118 pFormat += 10;
1119 break;
1120 case RPC_FC_VARIABLE_REPEAT:
1121 rep = pStubMsg->MaxCount;
1122 stride = *(const WORD*)&pFormat[2];
1123 ofs = *(const WORD*)&pFormat[4];
1124 count = *(const WORD*)&pFormat[6];
1125 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1126 pFormat += 8;
1127 break;
1128 }
1129 /* ofs doesn't seem to matter in this context */
1130 while (rep) {
1131 PFORMAT_STRING info = pFormat;
1132 unsigned u;
1133 for (u=0; u<count; u++,info+=8) {
1134 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1135 PointerMemorySize(pStubMsg, bufptr, info+4);
1136 }
1137 rep--;
1138 }
1139 pFormat += 8 * count;
1140 }
1141
1142 return 0;
1143 }
1144
1145 /***********************************************************************
1146 * EmbeddedPointerFree
1147 */
1148 void WINAPI EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1149 unsigned char *pMemory,
1150 PFORMAT_STRING pFormat)
1151 {
1152 unsigned long Offset = pStubMsg->Offset;
1153 unsigned ofs, rep, count, stride, xofs;
1154
1155 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1156 if (*pFormat != RPC_FC_PP) return;
1157 pFormat += 2;
1158
1159 while (pFormat[0] != RPC_FC_END) {
1160 switch (pFormat[0]) {
1161 default:
1162 FIXME("unknown repeat type %d\n", pFormat[0]);
1163 case RPC_FC_NO_REPEAT:
1164 rep = 1;
1165 stride = 0;
1166 ofs = 0;
1167 count = 1;
1168 xofs = 0;
1169 pFormat += 2;
1170 break;
1171 case RPC_FC_FIXED_REPEAT:
1172 rep = *(const WORD*)&pFormat[2];
1173 stride = *(const WORD*)&pFormat[4];
1174 ofs = *(const WORD*)&pFormat[6];
1175 count = *(const WORD*)&pFormat[8];
1176 xofs = 0;
1177 pFormat += 10;
1178 break;
1179 case RPC_FC_VARIABLE_REPEAT:
1180 rep = pStubMsg->MaxCount;
1181 stride = *(const WORD*)&pFormat[2];
1182 ofs = *(const WORD*)&pFormat[4];
1183 count = *(const WORD*)&pFormat[6];
1184 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1185 pFormat += 8;
1186 break;
1187 }
1188 /* ofs doesn't seem to matter in this context */
1189 while (rep) {
1190 PFORMAT_STRING info = pFormat;
1191 unsigned char *membase = pMemory + xofs;
1192 unsigned u;
1193 for (u=0; u<count; u++,info+=8) {
1194 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1195 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1196 }
1197 rep--;
1198 }
1199 pFormat += 8 * count;
1200 }
1201 }
1202
1203 /***********************************************************************
1204 * NdrPointerMarshall [RPCRT4.@]
1205 */
1206 unsigned char * WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1207 unsigned char *pMemory,
1208 PFORMAT_STRING pFormat)
1209 {
1210 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1211
1212 pStubMsg->BufferMark = pStubMsg->Buffer;
1213 PointerMarshall(pStubMsg, pStubMsg->Buffer, pMemory, pFormat);
1214
1215 STD_OVERFLOW_CHECK(pStubMsg);
1216
1217 return NULL;
1218 }
1219
1220 /***********************************************************************
1221 * NdrPointerUnmarshall [RPCRT4.@]
1222 */
1223 unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1224 unsigned char **ppMemory,
1225 PFORMAT_STRING pFormat,
1226 unsigned char fMustAlloc)
1227 {
1228 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1229
1230 pStubMsg->BufferMark = pStubMsg->Buffer;
1231 PointerUnmarshall(pStubMsg, pStubMsg->Buffer, ppMemory, pFormat, fMustAlloc);
1232
1233 return NULL;
1234 }
1235
1236 /***********************************************************************
1237 * NdrPointerBufferSize [RPCRT4.@]
1238 */
1239 void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1240 unsigned char *pMemory,
1241 PFORMAT_STRING pFormat)
1242 {
1243 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1244 PointerBufferSize(pStubMsg, pMemory, pFormat);
1245 }
1246
1247 /***********************************************************************
1248 * NdrPointerMemorySize [RPCRT4.@]
1249 */
1250 unsigned long WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1251 PFORMAT_STRING pFormat)
1252 {
1253 /* unsigned size = *(LPWORD)(pFormat+2); */
1254 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1255 PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat);
1256 return 0;
1257 }
1258
1259 /***********************************************************************
1260 * NdrPointerFree [RPCRT4.@]
1261 */
1262 void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1263 unsigned char *pMemory,
1264 PFORMAT_STRING pFormat)
1265 {
1266 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1267 PointerFree(pStubMsg, pMemory, pFormat);
1268 }
1269
1270 /***********************************************************************
1271 * NdrSimpleStructMarshall [RPCRT4.@]
1272 */
1273 unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1274 unsigned char *pMemory,
1275 PFORMAT_STRING pFormat)
1276 {
1277 unsigned size = *(const WORD*)(pFormat+2);
1278 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1279
1280 memcpy(pStubMsg->Buffer, pMemory, size);
1281 pStubMsg->BufferMark = pStubMsg->Buffer;
1282 pStubMsg->Buffer += size;
1283
1284 if (pFormat[0] != RPC_FC_STRUCT)
1285 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
1286
1287 /*
1288 * This test does not work when NdrSimpleStructMarshall is called
1289 * by an rpc-server to marshall data to return to the client because
1290 * BufferStart and BufferEnd are bogus. MIDL does not update them
1291 * when a new buffer is allocated in order to return data to the caller.
1292 */
1293 #if 0
1294 STD_OVERFLOW_CHECK(pStubMsg);
1295 #endif
1296
1297 return NULL;
1298 }
1299
1300 /***********************************************************************
1301 * NdrSimpleStructUnmarshall [RPCRT4.@]
1302 */
1303 unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1304 unsigned char **ppMemory,
1305 PFORMAT_STRING pFormat,
1306 unsigned char fMustAlloc)
1307 {
1308 unsigned size = *(const WORD*)(pFormat+2);
1309 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1310
1311 if (fMustAlloc) {
1312 *ppMemory = NdrAllocate(pStubMsg, size);
1313 memcpy(*ppMemory, pStubMsg->Buffer, size);
1314 } else {
1315 if (pStubMsg->ReuseBuffer && !*ppMemory)
1316 /* for servers, we may just point straight into the RPC buffer, I think
1317 * (I guess that's what MS does since MIDL code doesn't try to free) */
1318 *ppMemory = pStubMsg->Buffer;
1319 else
1320 /* for clients, memory should be provided by caller */
1321 memcpy(*ppMemory, pStubMsg->Buffer, size);
1322 }
1323
1324 pStubMsg->BufferMark = pStubMsg->Buffer;
1325 pStubMsg->Buffer += size;
1326
1327 if (pFormat[0] != RPC_FC_STRUCT)
1328 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat+4, fMustAlloc);
1329
1330 return NULL;
1331 }
1332
1333
1334 /***********************************************************************
1335 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1336 */
1337 void WINAPI NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1338 unsigned char *pMemory,
1339 unsigned char FormatChar)
1340 {
1341 FIXME("stub\n");
1342 }
1343
1344
1345 /***********************************************************************
1346 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1347 */
1348 void WINAPI NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1349 unsigned char *pMemory,
1350 unsigned char FormatChar)
1351 {
1352 FIXME("stub\n");
1353 }
1354
1355
1356 /***********************************************************************
1357 * NdrSimpleStructBufferSize [RPCRT4.@]
1358 */
1359 void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1360 unsigned char *pMemory,
1361 PFORMAT_STRING pFormat)
1362 {
1363 unsigned size = *(const WORD*)(pFormat+2);
1364 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1365 pStubMsg->BufferLength += size;
1366 if (pFormat[0] != RPC_FC_STRUCT)
1367 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
1368 }
1369
1370 /***********************************************************************
1371 * NdrSimpleStructMemorySize [RPCRT4.@]
1372 */
1373 unsigned long WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1374 PFORMAT_STRING pFormat)
1375 {
1376 /* unsigned size = *(LPWORD)(pFormat+2); */
1377 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1378 if (pFormat[0] != RPC_FC_STRUCT)
1379 EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
1380 return 0;
1381 }
1382
1383 /***********************************************************************
1384 * NdrSimpleStructFree [RPCRT4.@]
1385 */
1386 void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1387 unsigned char *pMemory,
1388 PFORMAT_STRING pFormat)
1389 {
1390 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1391 if (pFormat[0] != RPC_FC_STRUCT)
1392 EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
1393 }
1394
1395
1396 unsigned long WINAPI EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg,
1397 PFORMAT_STRING pFormat)
1398 {
1399 switch (*pFormat) {
1400 case RPC_FC_STRUCT:
1401 case RPC_FC_PSTRUCT:
1402 case RPC_FC_CSTRUCT:
1403 case RPC_FC_BOGUS_STRUCT:
1404 return *(const WORD*)&pFormat[2];
1405 case RPC_FC_USER_MARSHAL:
1406 return *(const WORD*)&pFormat[4];
1407 default:
1408 FIXME("unhandled embedded type %02x\n", *pFormat);
1409 }
1410 return 0;
1411 }
1412
1413
1414 unsigned char * WINAPI ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1415 unsigned char *pMemory,
1416 PFORMAT_STRING pFormat,
1417 PFORMAT_STRING pPointer)
1418 {
1419 PFORMAT_STRING desc;
1420 NDR_MARSHALL m;
1421 unsigned long size;
1422
1423 while (*pFormat != RPC_FC_END) {
1424 switch (*pFormat) {
1425 case RPC_FC_SHORT:
1426 case RPC_FC_USHORT:
1427 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
1428 memcpy(pStubMsg->Buffer, pMemory, 2);
1429 pStubMsg->Buffer += 2;
1430 pMemory += 2;
1431 break;
1432 case RPC_FC_LONG:
1433 case RPC_FC_ULONG:
1434 case RPC_FC_ENUM32:
1435 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
1436 memcpy(pStubMsg->Buffer, pMemory, 4);
1437 pStubMsg->Buffer += 4;
1438 pMemory += 4;
1439 break;
1440 case RPC_FC_POINTER:
1441 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
1442 NdrPointerMarshall(pStubMsg, *(unsigned char**)pMemory, pPointer);
1443 pPointer += 4;
1444 pMemory += 4;
1445 break;
1446 case RPC_FC_ALIGNM4:
1447 ALIGN_POINTER(pMemory, 3);
1448 break;
1449 case RPC_FC_ALIGNM8:
1450 ALIGN_POINTER(pMemory, 7);
1451 break;
1452 case RPC_FC_EMBEDDED_COMPLEX:
1453 pMemory += pFormat[1];
1454 pFormat += 2;
1455 desc = pFormat + *(const SHORT*)pFormat;
1456 size = EmbeddedComplexSize(pStubMsg, desc);
1457 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
1458 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
1459 if (m) m(pStubMsg, pMemory, desc);
1460 else FIXME("no marshaller for embedded type %02x\n", *desc);
1461 pMemory += size;
1462 pFormat += 2;
1463 continue;
1464 case RPC_FC_PAD:
1465 break;
1466 default:
1467 FIXME("unhandled format %02x\n", *pFormat);
1468 }
1469 pFormat++;
1470 }
1471
1472 return pMemory;
1473 }
1474
1475 unsigned char * WINAPI ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1476 unsigned char *pMemory,
1477 PFORMAT_STRING pFormat,
1478 PFORMAT_STRING pPointer,
1479 unsigned char fMustAlloc)
1480 {
1481 PFORMAT_STRING desc;
1482 NDR_UNMARSHALL m;
1483 unsigned long size;
1484
1485 while (*pFormat != RPC_FC_END) {
1486 switch (*pFormat) {
1487 case RPC_FC_SHORT:
1488 case RPC_FC_USHORT:
1489 memcpy(pMemory, pStubMsg->Buffer, 2);
1490 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
1491 pStubMsg->Buffer += 2;
1492 pMemory += 2;
1493 break;
1494 case RPC_FC_LONG:
1495 case RPC_FC_ULONG:
1496 case RPC_FC_ENUM32:
1497 memcpy(pMemory, pStubMsg->Buffer, 4);
1498 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
1499 pStubMsg->Buffer += 4;
1500 pMemory += 4;
1501 break;
1502 case RPC_FC_POINTER:
1503 *(unsigned char**)pMemory = NULL;
1504 TRACE("pointer => %p\n", pMemory);
1505 NdrPointerUnmarshall(pStubMsg, (unsigned char**)pMemory, pPointer, fMustAlloc);
1506 pPointer += 4;
1507 pMemory += 4;
1508 break;
1509 case RPC_FC_ALIGNM4:
1510 ALIGN_POINTER(pMemory, 3);
1511 break;
1512 case RPC_FC_ALIGNM8:
1513 ALIGN_POINTER(pMemory, 7);
1514 break;
1515 case RPC_FC_EMBEDDED_COMPLEX:
1516 pMemory += pFormat[1];
1517 pFormat += 2;
1518 desc = pFormat + *(const SHORT*)pFormat;
1519 size = EmbeddedComplexSize(pStubMsg, desc);
1520 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
1521 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
1522 memset(pMemory, 0, size); /* just in case */
1523 if (m) m(pStubMsg, &pMemory, desc, fMustAlloc);
1524 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
1525 pMemory += size;
1526 pFormat += 2;
1527 continue;
1528 case RPC_FC_PAD:
1529 break;
1530 default:
1531 FIXME("unhandled format %d\n", *pFormat);
1532 }
1533 pFormat++;
1534 }
1535
1536 return pMemory;
1537 }
1538
1539 unsigned char * WINAPI ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1540 unsigned char *pMemory,
1541 PFORMAT_STRING pFormat,
1542 PFORMAT_STRING pPointer)
1543 {
1544 PFORMAT_STRING desc;
1545 NDR_BUFFERSIZE m;
1546 unsigned long size;
1547
1548 while (*pFormat != RPC_FC_END) {
1549 switch (*pFormat) {
1550 case RPC_FC_SHORT:
1551 case RPC_FC_USHORT:
1552 pStubMsg->BufferLength += 2;
1553 pMemory += 2;
1554 break;
1555 case RPC_FC_LONG:
1556 case RPC_FC_ULONG:
1557 case RPC_FC_ENUM32:
1558 pStubMsg->BufferLength += 4;
1559 pMemory += 4;
1560 break;
1561 case RPC_FC_POINTER:
1562 NdrPointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
1563 pPointer += 4;
1564 pMemory += 4;
1565 break;
1566 case RPC_FC_ALIGNM4:
1567 ALIGN_POINTER(pMemory, 3);
1568 break;
1569 case RPC_FC_ALIGNM8:
1570 ALIGN_POINTER(pMemory, 7);
1571 break;
1572 case RPC_FC_EMBEDDED_COMPLEX:
1573 pMemory += pFormat[1];
1574 pFormat += 2;
1575 desc = pFormat + *(const SHORT*)pFormat;
1576 size = EmbeddedComplexSize(pStubMsg, desc);
1577 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
1578 if (m) m(pStubMsg, pMemory, desc);
1579 else FIXME("no buffersizer for embedded type %02x\n", *desc);
1580 pMemory += size;
1581 pFormat += 2;
1582 continue;
1583 case RPC_FC_PAD:
1584 break;
1585 default:
1586 FIXME("unhandled format %d\n", *pFormat);
1587 }
1588 pFormat++;
1589 }
1590
1591 return pMemory;
1592 }
1593
1594 unsigned char * WINAPI ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
1595 unsigned char *pMemory,
1596 PFORMAT_STRING pFormat,
1597 PFORMAT_STRING pPointer)
1598 {
1599 PFORMAT_STRING desc;
1600 NDR_FREE m;
1601 unsigned long size;
1602
1603 while (*pFormat != RPC_FC_END) {
1604 switch (*pFormat) {
1605 case RPC_FC_SHORT:
1606 case RPC_FC_USHORT:
1607 pMemory += 2;
1608 break;
1609 case RPC_FC_LONG:
1610 case RPC_FC_ULONG:
1611 case RPC_FC_ENUM32:
1612 pMemory += 4;
1613 break;
1614 case RPC_FC_POINTER:
1615 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
1616 pPointer += 4;
1617 pMemory += 4;
1618 break;
1619 case RPC_FC_ALIGNM4:
1620 ALIGN_POINTER(pMemory, 3);
1621 break;
1622 case RPC_FC_ALIGNM8:
1623 ALIGN_POINTER(pMemory, 7);
1624 break;
1625 case RPC_FC_EMBEDDED_COMPLEX:
1626 pMemory += pFormat[1];
1627 pFormat += 2;
1628 desc = pFormat + *(const SHORT*)pFormat;
1629 size = EmbeddedComplexSize(pStubMsg, desc);
1630 m = NdrFreer[*desc & NDR_TABLE_MASK];
1631 if (m) m(pStubMsg, pMemory, desc);
1632 else FIXME("no freer for embedded type %02x\n", *desc);
1633 pMemory += size;
1634 pFormat += 2;
1635 continue;
1636 case RPC_FC_PAD:
1637 break;
1638 default:
1639 FIXME("unhandled format %d\n", *pFormat);
1640 }
1641 pFormat++;
1642 }
1643
1644 return pMemory;
1645 }
1646
1647 unsigned long WINAPI ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg,
1648 PFORMAT_STRING pFormat)
1649 {
1650 PFORMAT_STRING desc;
1651 unsigned long size = 0;
1652
1653 while (*pFormat != RPC_FC_END) {
1654 switch (*pFormat) {
1655 case RPC_FC_SHORT:
1656 case RPC_FC_USHORT:
1657 size += 2;
1658 break;
1659 case RPC_FC_LONG:
1660 case RPC_FC_ULONG:
1661 size += 4;
1662 break;
1663 case RPC_FC_POINTER:
1664 size += 4;
1665 break;
1666 case RPC_FC_ALIGNM4:
1667 ALIGN_LENGTH(size, 3);
1668 break;
1669 case RPC_FC_ALIGNM8:
1670 ALIGN_LENGTH(size, 7);
1671 break;
1672 case RPC_FC_EMBEDDED_COMPLEX:
1673 size += pFormat[1];
1674 pFormat += 2;
1675 desc = pFormat + *(const SHORT*)pFormat;
1676 size += EmbeddedComplexSize(pStubMsg, desc);
1677 pFormat += 2;
1678 continue;
1679 case RPC_FC_PAD:
1680 break;
1681 default:
1682 FIXME("unhandled format %d\n", *pFormat);
1683 }
1684 pFormat++;
1685 }
1686
1687 return size;
1688 }
1689
1690 /***********************************************************************
1691 * NdrComplexStructMarshall [RPCRT4.@]
1692 */
1693 unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1694 unsigned char *pMemory,
1695 PFORMAT_STRING pFormat)
1696 {
1697 PFORMAT_STRING conf_array = NULL;
1698 PFORMAT_STRING pointer_desc = NULL;
1699 unsigned char *OldMemory = pStubMsg->Memory;
1700
1701 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1702
1703 pFormat += 4;
1704 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1705 pFormat += 2;
1706 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1707 pFormat += 2;
1708
1709 pStubMsg->Memory = pMemory;
1710
1711 ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
1712
1713 if (conf_array)
1714 NdrConformantArrayMarshall(pStubMsg, pMemory, conf_array);
1715
1716 pStubMsg->Memory = OldMemory;
1717
1718 STD_OVERFLOW_CHECK(pStubMsg);
1719
1720 return NULL;
1721 }
1722
1723 /***********************************************************************
1724 * NdrComplexStructUnmarshall [RPCRT4.@]
1725 */
1726 unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1727 unsigned char **ppMemory,
1728 PFORMAT_STRING pFormat,
1729 unsigned char fMustAlloc)
1730 {
1731 unsigned size = *(const WORD*)(pFormat+2);
1732 PFORMAT_STRING conf_array = NULL;
1733 PFORMAT_STRING pointer_desc = NULL;
1734 unsigned char *pMemory;
1735
1736 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1737
1738 if (fMustAlloc || !*ppMemory)
1739 *ppMemory = NdrAllocate(pStubMsg, size);
1740
1741 pFormat += 4;
1742 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1743 pFormat += 2;
1744 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1745 pFormat += 2;
1746
1747 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
1748
1749 if (conf_array)
1750 NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
1751
1752 return NULL;
1753 }
1754
1755 /***********************************************************************
1756 * NdrComplexStructBufferSize [RPCRT4.@]
1757 */
1758 void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1759 unsigned char *pMemory,
1760 PFORMAT_STRING pFormat)
1761 {
1762 PFORMAT_STRING conf_array = NULL;
1763 PFORMAT_STRING pointer_desc = NULL;
1764 unsigned char *OldMemory = pStubMsg->Memory;
1765
1766 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1767
1768 pFormat += 4;
1769 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1770 pFormat += 2;
1771 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1772 pFormat += 2;
1773
1774 pStubMsg->Memory = pMemory;
1775
1776 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
1777
1778 if (conf_array)
1779 NdrConformantArrayBufferSize(pStubMsg, pMemory, conf_array);
1780
1781 pStubMsg->Memory = OldMemory;
1782 }
1783
1784 /***********************************************************************
1785 * NdrComplexStructMemorySize [RPCRT4.@]
1786 */
1787 unsigned long WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1788 PFORMAT_STRING pFormat)
1789 {
1790 /* unsigned size = *(LPWORD)(pFormat+2); */
1791 PFORMAT_STRING conf_array = NULL;
1792 PFORMAT_STRING pointer_desc = NULL;
1793
1794 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1795
1796 pFormat += 4;
1797 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1798 pFormat += 2;
1799 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1800 pFormat += 2;
1801
1802 return 0;
1803 }
1804
1805 /***********************************************************************
1806 * NdrComplexStructFree [RPCRT4.@]
1807 */
1808 void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1809 unsigned char *pMemory,
1810 PFORMAT_STRING pFormat)
1811 {
1812 PFORMAT_STRING conf_array = NULL;
1813 PFORMAT_STRING pointer_desc = NULL;
1814 unsigned char *OldMemory = pStubMsg->Memory;
1815
1816 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1817
1818 pFormat += 4;
1819 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1820 pFormat += 2;
1821 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1822 pFormat += 2;
1823
1824 pStubMsg->Memory = pMemory;
1825
1826 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
1827
1828 if (conf_array)
1829 NdrConformantArrayFree(pStubMsg, pMemory, conf_array);
1830
1831 pStubMsg->Memory = OldMemory;
1832 }
1833
1834 /***********************************************************************
1835 * NdrConformantArrayMarshall [RPCRT4.@]
1836 */
1837 unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1838 unsigned char *pMemory,
1839 PFORMAT_STRING pFormat)
1840 {
1841 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1842 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1843 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1844
1845 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1846 size = pStubMsg->MaxCount;
1847
1848 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
1849 pStubMsg->Buffer += 4;
1850
1851 memcpy(pStubMsg->Buffer, pMemory, size*esize);
1852 pStubMsg->BufferMark = pStubMsg->Buffer;
1853 pStubMsg->Buffer += size*esize;
1854
1855 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
1856
1857 STD_OVERFLOW_CHECK(pStubMsg);
1858
1859 return NULL;
1860 }
1861
1862 /***********************************************************************
1863 * NdrConformantArrayUnmarshall [RPCRT4.@]
1864 */
1865 unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1866 unsigned char **ppMemory,
1867 PFORMAT_STRING pFormat,
1868 unsigned char fMustAlloc)
1869 {
1870 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1871 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1872 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1873
1874 pFormat = ReadConformance(pStubMsg, pFormat+4);
1875 size = pStubMsg->MaxCount;
1876
1877 if (fMustAlloc || !*ppMemory)
1878 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1879
1880 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1881
1882 pStubMsg->BufferMark = pStubMsg->Buffer;
1883 pStubMsg->Buffer += size*esize;
1884
1885 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
1886
1887 return NULL;
1888 }
1889
1890 /***********************************************************************
1891 * NdrConformantArrayBufferSize [RPCRT4.@]
1892 */
1893 void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1894 unsigned char *pMemory,
1895 PFORMAT_STRING pFormat)
1896 {
1897 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1898 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1899 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1900
1901 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1902 size = pStubMsg->MaxCount;
1903
1904 pStubMsg->BufferLength += size*esize;
1905
1906 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1907 }
1908
1909 /***********************************************************************
1910 * NdrConformantArrayMemorySize [RPCRT4.@]
1911 */
1912 unsigned long WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1913 PFORMAT_STRING pFormat)
1914 {
1915 DWORD size = 0;
1916 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1917 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1918
1919 pFormat = ReadConformance(pStubMsg, pFormat+4);
1920 size = pStubMsg->MaxCount;
1921
1922 EmbeddedPointerMemorySize(pStubMsg, pFormat);
1923
1924 return 0;
1925 }
1926
1927 /***********************************************************************
1928 * NdrConformantArrayFree [RPCRT4.@]
1929 */
1930 void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
1931 unsigned char *pMemory,
1932 PFORMAT_STRING pFormat)
1933 {
1934 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1935 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1936
1937 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
1938 }
1939
1940
1941 /***********************************************************************
1942 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1943 */
1944 unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
1945 unsigned char* pMemory,
1946 PFORMAT_STRING pFormat )
1947 {
1948 FIXME( "stub\n" );
1949 return NULL;
1950 }
1951
1952
1953 /***********************************************************************
1954 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1955 */
1956 unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
1957 unsigned char** ppMemory,
1958 PFORMAT_STRING pFormat,
1959 unsigned char fMustAlloc )
1960 {
1961 FIXME( "stub\n" );
1962 return NULL;
1963 }
1964
1965
1966 /***********************************************************************
1967 * NdrConformantVaryingArrayFree [RPCRT4.@]
1968 */
1969 void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
1970 unsigned char* pMemory,
1971 PFORMAT_STRING pFormat )
1972 {
1973 FIXME( "stub\n" );
1974 }
1975
1976
1977 /***********************************************************************
1978 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1979 */
1980 void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
1981 unsigned char* pMemory, PFORMAT_STRING pFormat )
1982 {
1983 FIXME( "stub\n" );
1984 }
1985
1986
1987 /***********************************************************************
1988 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1989 */
1990 unsigned long WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
1991 PFORMAT_STRING pFormat )
1992 {
1993 FIXME( "stub\n" );
1994 return 0;
1995 }
1996
1997
1998 /***********************************************************************
1999 * NdrComplexArrayMarshall [RPCRT4.@]
2000 */
2001 unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2002 unsigned char *pMemory,
2003 PFORMAT_STRING pFormat)
2004 {
2005 DWORD size = 0, count, def;
2006 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2007
2008 def = *(const WORD*)&pFormat[2];
2009 pFormat += 4;
2010
2011 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2012 size = pStubMsg->MaxCount;
2013 TRACE("conformance=%ld\n", size);
2014
2015 if (*(const DWORD*)pFormat != 0xffffffff)
2016 FIXME("compute variance\n");
2017 pFormat += 4;
2018
2019 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
2020 pStubMsg->Buffer += 4;
2021
2022 for (count=0; count<size; count++)
2023 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2024
2025 STD_OVERFLOW_CHECK(pStubMsg);
2026
2027 return NULL;
2028 }
2029
2030 /***********************************************************************
2031 * NdrComplexArrayUnmarshall [RPCRT4.@]
2032 */
2033 unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2034 unsigned char **ppMemory,
2035 PFORMAT_STRING pFormat,
2036 unsigned char fMustAlloc)
2037 {
2038 DWORD size = 0, count, esize;
2039 unsigned char *pMemory;
2040 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2041
2042 pFormat += 4;
2043
2044 pFormat = ReadConformance(pStubMsg, pFormat);
2045 size = pStubMsg->MaxCount;
2046 TRACE("conformance=%ld\n", size);
2047
2048 pFormat += 4;
2049
2050 esize = ComplexStructSize(pStubMsg, pFormat);
2051
2052 if (fMustAlloc || !*ppMemory)
2053 *ppMemory = NdrAllocate(pStubMsg, size*esize);
2054
2055 pMemory = *ppMemory;
2056 for (count=0; count<size; count++)
2057 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2058
2059 return NULL;
2060 }
2061
2062 /***********************************************************************
2063 * NdrComplexArrayBufferSize [RPCRT4.@]
2064 */
2065 void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2066 unsigned char *pMemory,
2067 PFORMAT_STRING pFormat)
2068 {
2069 DWORD size = 0, count, def;
2070 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2071
2072 def = *(const WORD*)&pFormat[2];
2073 pFormat += 4;
2074
2075 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2076 size = pStubMsg->MaxCount;
2077 TRACE("conformance=%ld\n", size);
2078
2079 if (*(const DWORD*)pFormat != 0xffffffff)
2080 FIXME("compute variance\n");
2081 pFormat += 4;
2082
2083 for (count=0; count<size; count++)
2084 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
2085 }
2086
2087 /***********************************************************************
2088 * NdrComplexArrayMemorySize [RPCRT4.@]
2089 */
2090 unsigned long WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2091 PFORMAT_STRING pFormat)
2092 {
2093 DWORD size = 0;
2094 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2095
2096 pFormat += 4;
2097
2098 pFormat = ReadConformance(pStubMsg, pFormat);
2099 size = pStubMsg->MaxCount;
2100 TRACE("conformance=%ld\n", size);
2101
2102 pFormat += 4;
2103
2104 return 0;
2105 }
2106
2107 /***********************************************************************
2108 * NdrComplexArrayFree [RPCRT4.@]
2109 */
2110 void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2111 unsigned char *pMemory,
2112 PFORMAT_STRING pFormat)
2113 {
2114 DWORD size = 0, count, def;
2115 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2116
2117 def = *(const WORD*)&pFormat[2];
2118 pFormat += 4;
2119
2120 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2121 size = pStubMsg->MaxCount;
2122 TRACE("conformance=%ld\n", size);
2123
2124 if (*(const DWORD*)pFormat != 0xffffffff)
2125 FIXME("compute variance\n");
2126 pFormat += 4;
2127
2128 for (count=0; count<size; count++)
2129 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2130 }
2131
2132 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg)
2133 {
2134 return MAKELONG(pStubMsg->dwDestContext,
2135 pStubMsg->RpcMsg->DataRepresentation);
2136 }
2137
2138 /***********************************************************************
2139 * NdrUserMarshalMarshall [RPCRT4.@]
2140 */
2141 unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2142 unsigned char *pMemory,
2143 PFORMAT_STRING pFormat)
2144 {
2145 /* unsigned flags = pFormat[1]; */
2146 unsigned index = *(const WORD*)&pFormat[2];
2147 unsigned long uflag = UserMarshalFlags(pStubMsg);
2148 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2149 TRACE("index=%d\n", index);
2150
2151 pStubMsg->Buffer =
2152 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
2153 &uflag, pStubMsg->Buffer, pMemory);
2154
2155 STD_OVERFLOW_CHECK(pStubMsg);
2156
2157 return NULL;
2158 }
2159
2160 /***********************************************************************
2161 * NdrUserMarshalUnmarshall [RPCRT4.@]
2162 */
2163 unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2164 unsigned char **ppMemory,
2165 PFORMAT_STRING pFormat,
2166 unsigned char fMustAlloc)
2167 {
2168 /* unsigned flags = pFormat[1];*/
2169 unsigned index = *(const WORD*)&pFormat[2];
2170 DWORD memsize = *(const WORD*)&pFormat[4];
2171 unsigned long uflag = UserMarshalFlags(pStubMsg);
2172 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2173 TRACE("index=%d\n", index);
2174
2175 if (fMustAlloc || !*ppMemory)
2176 *ppMemory = NdrAllocate(pStubMsg, memsize);
2177
2178 pStubMsg->Buffer =
2179 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
2180 &uflag, pStubMsg->Buffer, *ppMemory);
2181
2182 return NULL;
2183 }
2184
2185 /***********************************************************************
2186 * NdrUserMarshalBufferSize [RPCRT4.@]
2187 */
2188 void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2189 unsigned char *pMemory,
2190 PFORMAT_STRING pFormat)
2191 {
2192 /* unsigned flags = pFormat[1];*/
2193 unsigned index = *(const WORD*)&pFormat[2];
2194 DWORD bufsize = *(const WORD*)&pFormat[6];
2195 unsigned long uflag = UserMarshalFlags(pStubMsg);
2196 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2197 TRACE("index=%d\n", index);
2198
2199 if (bufsize) {
2200 TRACE("size=%ld\n", bufsize);
2201 pStubMsg->BufferLength += bufsize;
2202 return;
2203 }
2204
2205 pStubMsg->BufferLength =
2206 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
2207 &uflag, pStubMsg->BufferLength, pMemory);
2208 }
2209
2210 /***********************************************************************
2211 * NdrUserMarshalMemorySize [RPCRT4.@]
2212 */
2213 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2214 PFORMAT_STRING pFormat)
2215 {
2216 unsigned index = *(const WORD*)&pFormat[2];
2217 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2218 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2219 TRACE("index=%d\n", index);
2220
2221 return 0;
2222 }
2223
2224 /***********************************************************************
2225 * NdrUserMarshalFree [RPCRT4.@]
2226 */
2227 void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
2228 unsigned char *pMemory,
2229 PFORMAT_STRING pFormat)
2230 {
2231 /* unsigned flags = pFormat[1]; */
2232 unsigned index = *(const WORD*)&pFormat[2];
2233 unsigned long uflag = UserMarshalFlags(pStubMsg);
2234 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2235 TRACE("index=%d\n", index);
2236
2237 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
2238 &uflag, pMemory);
2239 }
2240
2241 /***********************************************************************
2242 * NdrClearOutParameters [RPCRT4.@]
2243 */
2244 void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
2245 PFORMAT_STRING pFormat,
2246 void *ArgAddr)
2247 {
2248 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
2249 }
2250
2251 /***********************************************************************
2252 * NdrConvert [RPCRT4.@]
2253 */
2254 void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
2255 {
2256 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
2257 /* FIXME: since this stub doesn't do any converting, the proper behavior
2258 is to raise an exception */
2259 }
2260
2261 /***********************************************************************
2262 * NdrConvert2 [RPCRT4.@]
2263 */
2264 void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams )
2265 {
2266 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2267 pStubMsg, pFormat, NumberParams);
2268 /* FIXME: since this stub doesn't do any converting, the proper behavior
2269 is to raise an exception */
2270 }
2271
2272 /***********************************************************************
2273 * NdrConformantStructMarshall [RPCRT4.@]
2274 */
2275 unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2276 unsigned char *pMemory,
2277 PFORMAT_STRING pFormat)
2278 {
2279 FIXME("stub\n");
2280 return NULL;
2281 }
2282
2283 /***********************************************************************
2284 * NdrConformantStructUnmarshall [RPCRT4.@]
2285 */
2286 unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2287 unsigned char **ppMemory,
2288 PFORMAT_STRING pFormat,
2289 unsigned char fMustAlloc)
2290 {
2291 FIXME("stub\n");
2292 return NULL;
2293 }
2294
2295 /***********************************************************************
2296 * NdrConformantStructBufferSize [RPCRT4.@]
2297 */
2298 void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2299 unsigned char *pMemory,
2300 PFORMAT_STRING pFormat)
2301 {
2302 FIXME("stub\n");
2303 }
2304
2305 /***********************************************************************
2306 * NdrConformantStructMemorySize [RPCRT4.@]
2307 */
2308 unsigned long WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2309 PFORMAT_STRING pFormat)
2310 {
2311 FIXME("stub\n");
2312 return 0;
2313 }
2314
2315 /***********************************************************************
2316 * NdrConformantStructFree [RPCRT4.@]
2317 */
2318 void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2319 unsigned char *pMemory,
2320 PFORMAT_STRING pFormat)
2321 {
2322 FIXME("stub\n");
2323 }
2324
2325 /***********************************************************************
2326 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2327 */
2328 unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2329 unsigned char *pMemory,
2330 PFORMAT_STRING pFormat)
2331 {
2332 FIXME("stub\n");
2333 return NULL;
2334 }
2335
2336 /***********************************************************************
2337 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2338 */
2339 unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2340 unsigned char **ppMemory,
2341 PFORMAT_STRING pFormat,
2342 unsigned char fMustAlloc)
2343 {
2344 FIXME("stub\n");
2345 return NULL;
2346 }
2347
2348 /***********************************************************************
2349 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2350 */
2351 void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2352 unsigned char *pMemory,
2353 PFORMAT_STRING pFormat)
2354 {
2355 FIXME("stub\n");
2356 }
2357
2358 /***********************************************************************
2359 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2360 */
2361 unsigned long WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2362 PFORMAT_STRING pFormat)
2363 {
2364 FIXME("stub\n");
2365 return 0;
2366 }
2367
2368 /***********************************************************************
2369 * NdrConformantVaryingStructFree [RPCRT4.@]
2370 */
2371 void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2372 unsigned char *pMemory,
2373 PFORMAT_STRING pFormat)
2374 {
2375 FIXME("stub\n");
2376 }
2377
2378 /***********************************************************************
2379 * NdrFixedArrayMarshall [RPCRT4.@]
2380 */
2381 unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2382 unsigned char *pMemory,
2383 PFORMAT_STRING pFormat)
2384 {
2385 FIXME("stub\n");
2386 return NULL;
2387 }
2388
2389 /***********************************************************************
2390 * NdrFixedArrayUnmarshall [RPCRT4.@]
2391 */
2392 unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2393 unsigned char **ppMemory,
2394 PFORMAT_STRING pFormat,
2395 unsigned char fMustAlloc)
2396 {
2397 FIXME("stub\n");
2398 return NULL;
2399 }
2400
2401 /***********************************************************************
2402 * NdrFixedArrayBufferSize [RPCRT4.@]
2403 */
2404 void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2405 unsigned char *pMemory,
2406 PFORMAT_STRING pFormat)
2407 {
2408 FIXME("stub\n");
2409 }
2410
2411 /***********************************************************************
2412 * NdrFixedArrayMemorySize [RPCRT4.@]
2413 */
2414 unsigned long WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2415 PFORMAT_STRING pFormat)
2416 {
2417 FIXME("stub\n");
2418 return 0;
2419 }
2420
2421 /***********************************************************************
2422 * NdrFixedArrayFree [RPCRT4.@]
2423 */
2424 void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2425 unsigned char *pMemory,
2426 PFORMAT_STRING pFormat)
2427 {
2428 FIXME("stub\n");
2429 }
2430
2431 /***********************************************************************
2432 * NdrVaryingArrayMarshall [RPCRT4.@]
2433 */
2434 unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2435 unsigned char *pMemory,
2436 PFORMAT_STRING pFormat)
2437 {
2438 FIXME("stub\n");
2439 return NULL;
2440 }
2441
2442 /***********************************************************************
2443 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2444 */
2445 unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2446 unsigned char **ppMemory,
2447 PFORMAT_STRING pFormat,
2448 unsigned char fMustAlloc)
2449 {
2450 FIXME("stub\n");
2451 return NULL;
2452 }
2453
2454 /***********************************************************************
2455 * NdrVaryingArrayBufferSize [RPCRT4.@]
2456 */
2457 void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2458 unsigned char *pMemory,
2459 PFORMAT_STRING pFormat)
2460 {
2461 FIXME("stub\n");
2462 }
2463
2464 /***********************************************************************
2465 * NdrVaryingArrayMemorySize [RPCRT4.@]
2466 */
2467 unsigned long WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2468 PFORMAT_STRING pFormat)
2469 {
2470 FIXME("stub\n");
2471 return 0;
2472 }
2473
2474 /***********************************************************************
2475 * NdrVaryingArrayFree [RPCRT4.@]
2476 */
2477 void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2478 unsigned char *pMemory,
2479 PFORMAT_STRING pFormat)
2480 {
2481 FIXME("stub\n");
2482 }
2483
2484 /***********************************************************************
2485 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2486 */
2487 unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2488 unsigned char *pMemory,
2489 PFORMAT_STRING pFormat)
2490 {
2491 FIXME("stub\n");
2492 return NULL;
2493 }
2494
2495 /***********************************************************************
2496 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2497 */
2498 unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2499 unsigned char **ppMemory,
2500 PFORMAT_STRING pFormat,
2501 unsigned char fMustAlloc)
2502 {
2503 FIXME("stub\n");
2504 return NULL;
2505 }
2506
2507 /***********************************************************************
2508 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2509 */
2510 void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2511 unsigned char *pMemory,
2512 PFORMAT_STRING pFormat)
2513 {
2514 FIXME("stub\n");
2515 }
2516
2517 /***********************************************************************
2518 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2519 */
2520 unsigned long WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2521 PFORMAT_STRING pFormat)
2522 {
2523 FIXME("stub\n");
2524 return 0;
2525 }
2526
2527 /***********************************************************************
2528 * NdrEncapsulatedUnionFree [RPCRT4.@]
2529 */
2530 void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2531 unsigned char *pMemory,
2532 PFORMAT_STRING pFormat)
2533 {
2534 FIXME("stub\n");
2535 }
2536
2537 /***********************************************************************
2538 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2539 */
2540 unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2541 unsigned char *pMemory,
2542 PFORMAT_STRING pFormat)
2543 {
2544 FIXME("stub\n");
2545 return NULL;
2546 }
2547
2548 /***********************************************************************
2549 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2550 */
2551 unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2552 unsigned char **ppMemory,
2553 PFORMAT_STRING pFormat,
2554 unsigned char fMustAlloc)
2555 {
2556 FIXME("stub\n");
2557 return NULL;
2558 }
2559
2560 /***********************************************************************
2561 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2562 */
2563 void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2564 unsigned char *pMemory,
2565 PFORMAT_STRING pFormat)
2566 {
2567 FIXME("stub\n");
2568 }
2569
2570 /***********************************************************************
2571 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2572 */
2573 unsigned long WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2574 PFORMAT_STRING pFormat)
2575 {
2576 FIXME("stub\n");
2577 return 0;
2578 }
2579
2580 /***********************************************************************
2581 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2582 */
2583 void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2584 unsigned char *pMemory,
2585 PFORMAT_STRING pFormat)
2586 {
2587 FIXME("stub\n");
2588 }
2589
2590 /***********************************************************************
2591 * NdrByteCountPointerMarshall [RPCRT4.@]
2592 */
2593 unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2594 unsigned char *pMemory,
2595 PFORMAT_STRING pFormat)
2596 {
2597 FIXME("stub\n");
2598 return NULL;
2599 }
2600
2601 /***********************************************************************
2602 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2603 */
2604 unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2605 unsigned char **ppMemory,
2606 PFORMAT_STRING pFormat,
2607 unsigned char fMustAlloc)
2608 {
2609 FIXME("stub\n");
2610 return NULL;
2611 }
2612
2613 /***********************************************************************
2614 * NdrByteCountPointerBufferSize [RPCRT4.@]
2615 */
2616 void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2617 unsigned char *pMemory,
2618 PFORMAT_STRING pFormat)
2619 {
2620 FIXME("stub\n");
2621 }
2622
2623 /***********************************************************************
2624 * NdrByteCountPointerMemorySize [RPCRT4.@]
2625 */
2626 unsigned long WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2627 PFORMAT_STRING pFormat)
2628 {
2629 FIXME("stub\n");
2630 return 0;
2631 }
2632
2633 /***********************************************************************
2634 * NdrByteCountPointerFree [RPCRT4.@]
2635 */
2636 void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
2637 unsigned char *pMemory,
2638 PFORMAT_STRING pFormat)
2639 {
2640 FIXME("stub\n");
2641 }
2642
2643 /***********************************************************************
2644 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2645 */
2646 unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2647 unsigned char *pMemory,
2648 PFORMAT_STRING pFormat)
2649 {
2650 FIXME("stub\n");
2651 return NULL;
2652 }
2653
2654 /***********************************************************************
2655 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2656 */
2657 unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2658 unsigned char **ppMemory,
2659 PFORMAT_STRING pFormat,
2660 unsigned char fMustAlloc)
2661 {
2662 FIXME("stub\n");
2663 return NULL;
2664 }
2665
2666 /***********************************************************************
2667 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2668 */
2669 void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2670 unsigned char *pMemory,
2671 PFORMAT_STRING pFormat)
2672 {
2673 FIXME("stub\n");
2674 }
2675
2676 /***********************************************************************
2677 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2678 */
2679 unsigned long WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2680 PFORMAT_STRING pFormat)
2681 {
2682 FIXME("stub\n");
2683 return 0;
2684 }
2685
2686 /***********************************************************************
2687 * NdrXmitOrRepAsFree [RPCRT4.@]
2688 */
2689 void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
2690 unsigned char *pMemory,
2691 PFORMAT_STRING pFormat)
2692 {
2693 FIXME("stub\n");
2694 }
2695
2696 /***********************************************************************
2697 * NdrClientContextMarshall
2698 */
2699 void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2700 NDR_CCONTEXT ContextHandle,
2701 int fCheck)
2702 {
2703 FIXME("(%p, %p, %d): stub\n", pStubMsg, ContextHandle, fCheck);
2704 }
2705
2706 /***********************************************************************
2707 * NdrClientContextUnmarshall
2708 */
2709 void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2710 NDR_CCONTEXT * pContextHandle,
2711 RPC_BINDING_HANDLE BindHandle)
2712 {
2713 FIXME("(%p, %p, %p): stub\n", pStubMsg, pContextHandle, BindHandle);
2714 }
2715
2716 void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2717 NDR_SCONTEXT ContextHandle,
2718 NDR_RUNDOWN RundownRoutine )
2719 {
2720 FIXME("(%p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine);
2721 }
2722
2723 NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
2724 {
2725 FIXME("(%p): stub\n", pStubMsg);
2726 return NULL;
2727 }
2728
2729 void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
2730 unsigned char* pMemory,
2731 PFORMAT_STRING pFormat)
2732 {
2733 FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
2734 }
2735
2736 NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
2737 PFORMAT_STRING pFormat)
2738 {
2739 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2740 return NULL;
2741 }
2742
2743 void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2744 NDR_SCONTEXT ContextHandle,
2745 NDR_RUNDOWN RundownRoutine,
2746 PFORMAT_STRING pFormat)
2747 {
2748 FIXME("(%p, %p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
2749 }
2750
2751 NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2752 PFORMAT_STRING pFormat)
2753 {
2754 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2755 return NULL;
2756 }
2757
2758 RPC_BINDING_HANDLE WINAPI NDRCContextBinding(NDR_CCONTEXT CContext)
2759 {
2760 FIXME("(%p): stub\n", CContext);
2761 return NULL;
2762 }