4b349c9a0be7c5a88e52929496e6e49fe421f116
[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 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
1435 memcpy(pStubMsg->Buffer, pMemory, 4);
1436 pStubMsg->Buffer += 4;
1437 pMemory += 4;
1438 break;
1439 case RPC_FC_POINTER:
1440 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
1441 NdrPointerMarshall(pStubMsg, *(unsigned char**)pMemory, pPointer);
1442 pPointer += 4;
1443 pMemory += 4;
1444 break;
1445 case RPC_FC_ALIGNM4:
1446 ALIGN_POINTER(pMemory, 3);
1447 break;
1448 case RPC_FC_ALIGNM8:
1449 ALIGN_POINTER(pMemory, 7);
1450 break;
1451 case RPC_FC_EMBEDDED_COMPLEX:
1452 pMemory += pFormat[1];
1453 pFormat += 2;
1454 desc = pFormat + *(const SHORT*)pFormat;
1455 size = EmbeddedComplexSize(pStubMsg, desc);
1456 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
1457 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
1458 if (m) m(pStubMsg, pMemory, desc);
1459 else FIXME("no marshaller for embedded type %02x\n", *desc);
1460 pMemory += size;
1461 pFormat += 2;
1462 continue;
1463 case RPC_FC_PAD:
1464 break;
1465 default:
1466 FIXME("unhandled format %02x\n", *pFormat);
1467 }
1468 pFormat++;
1469 }
1470
1471 return pMemory;
1472 }
1473
1474 unsigned char * WINAPI ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1475 unsigned char *pMemory,
1476 PFORMAT_STRING pFormat,
1477 PFORMAT_STRING pPointer,
1478 unsigned char fMustAlloc)
1479 {
1480 PFORMAT_STRING desc;
1481 NDR_UNMARSHALL m;
1482 unsigned long size;
1483
1484 while (*pFormat != RPC_FC_END) {
1485 switch (*pFormat) {
1486 case RPC_FC_SHORT:
1487 case RPC_FC_USHORT:
1488 memcpy(pMemory, pStubMsg->Buffer, 2);
1489 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
1490 pStubMsg->Buffer += 2;
1491 pMemory += 2;
1492 break;
1493 case RPC_FC_LONG:
1494 case RPC_FC_ULONG:
1495 memcpy(pMemory, pStubMsg->Buffer, 4);
1496 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
1497 pStubMsg->Buffer += 4;
1498 pMemory += 4;
1499 break;
1500 case RPC_FC_POINTER:
1501 *(unsigned char**)pMemory = NULL;
1502 TRACE("pointer => %p\n", pMemory);
1503 NdrPointerUnmarshall(pStubMsg, (unsigned char**)pMemory, pPointer, fMustAlloc);
1504 pPointer += 4;
1505 pMemory += 4;
1506 break;
1507 case RPC_FC_ALIGNM4:
1508 ALIGN_POINTER(pMemory, 3);
1509 break;
1510 case RPC_FC_ALIGNM8:
1511 ALIGN_POINTER(pMemory, 7);
1512 break;
1513 case RPC_FC_EMBEDDED_COMPLEX:
1514 pMemory += pFormat[1];
1515 pFormat += 2;
1516 desc = pFormat + *(const SHORT*)pFormat;
1517 size = EmbeddedComplexSize(pStubMsg, desc);
1518 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
1519 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
1520 memset(pMemory, 0, size); /* just in case */
1521 if (m) m(pStubMsg, &pMemory, desc, fMustAlloc);
1522 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
1523 pMemory += size;
1524 pFormat += 2;
1525 continue;
1526 case RPC_FC_PAD:
1527 break;
1528 default:
1529 FIXME("unhandled format %d\n", *pFormat);
1530 }
1531 pFormat++;
1532 }
1533
1534 return pMemory;
1535 }
1536
1537 unsigned char * WINAPI ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1538 unsigned char *pMemory,
1539 PFORMAT_STRING pFormat,
1540 PFORMAT_STRING pPointer)
1541 {
1542 PFORMAT_STRING desc;
1543 NDR_BUFFERSIZE m;
1544 unsigned long size;
1545
1546 while (*pFormat != RPC_FC_END) {
1547 switch (*pFormat) {
1548 case RPC_FC_SHORT:
1549 case RPC_FC_USHORT:
1550 pStubMsg->BufferLength += 2;
1551 pMemory += 2;
1552 break;
1553 case RPC_FC_LONG:
1554 case RPC_FC_ULONG:
1555 pStubMsg->BufferLength += 4;
1556 pMemory += 4;
1557 break;
1558 case RPC_FC_POINTER:
1559 NdrPointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
1560 pPointer += 4;
1561 pMemory += 4;
1562 break;
1563 case RPC_FC_ALIGNM4:
1564 ALIGN_POINTER(pMemory, 3);
1565 break;
1566 case RPC_FC_ALIGNM8:
1567 ALIGN_POINTER(pMemory, 7);
1568 break;
1569 case RPC_FC_EMBEDDED_COMPLEX:
1570 pMemory += pFormat[1];
1571 pFormat += 2;
1572 desc = pFormat + *(const SHORT*)pFormat;
1573 size = EmbeddedComplexSize(pStubMsg, desc);
1574 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
1575 if (m) m(pStubMsg, pMemory, desc);
1576 else FIXME("no buffersizer for embedded type %02x\n", *desc);
1577 pMemory += size;
1578 pFormat += 2;
1579 continue;
1580 case RPC_FC_PAD:
1581 break;
1582 default:
1583 FIXME("unhandled format %d\n", *pFormat);
1584 }
1585 pFormat++;
1586 }
1587
1588 return pMemory;
1589 }
1590
1591 unsigned char * WINAPI ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
1592 unsigned char *pMemory,
1593 PFORMAT_STRING pFormat,
1594 PFORMAT_STRING pPointer)
1595 {
1596 PFORMAT_STRING desc;
1597 NDR_FREE m;
1598 unsigned long size;
1599
1600 while (*pFormat != RPC_FC_END) {
1601 switch (*pFormat) {
1602 case RPC_FC_SHORT:
1603 case RPC_FC_USHORT:
1604 pMemory += 2;
1605 break;
1606 case RPC_FC_LONG:
1607 case RPC_FC_ULONG:
1608 pMemory += 4;
1609 break;
1610 case RPC_FC_POINTER:
1611 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
1612 pPointer += 4;
1613 pMemory += 4;
1614 break;
1615 case RPC_FC_ALIGNM4:
1616 ALIGN_POINTER(pMemory, 3);
1617 break;
1618 case RPC_FC_ALIGNM8:
1619 ALIGN_POINTER(pMemory, 7);
1620 break;
1621 case RPC_FC_EMBEDDED_COMPLEX:
1622 pMemory += pFormat[1];
1623 pFormat += 2;
1624 desc = pFormat + *(const SHORT*)pFormat;
1625 size = EmbeddedComplexSize(pStubMsg, desc);
1626 m = NdrFreer[*desc & NDR_TABLE_MASK];
1627 if (m) m(pStubMsg, pMemory, desc);
1628 else FIXME("no freer for embedded type %02x\n", *desc);
1629 pMemory += size;
1630 pFormat += 2;
1631 continue;
1632 case RPC_FC_PAD:
1633 break;
1634 default:
1635 FIXME("unhandled format %d\n", *pFormat);
1636 }
1637 pFormat++;
1638 }
1639
1640 return pMemory;
1641 }
1642
1643 unsigned long WINAPI ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg,
1644 PFORMAT_STRING pFormat)
1645 {
1646 PFORMAT_STRING desc;
1647 unsigned long size = 0;
1648
1649 while (*pFormat != RPC_FC_END) {
1650 switch (*pFormat) {
1651 case RPC_FC_SHORT:
1652 case RPC_FC_USHORT:
1653 size += 2;
1654 break;
1655 case RPC_FC_LONG:
1656 case RPC_FC_ULONG:
1657 size += 4;
1658 break;
1659 case RPC_FC_POINTER:
1660 size += 4;
1661 break;
1662 case RPC_FC_ALIGNM4:
1663 ALIGN_LENGTH(size, 3);
1664 break;
1665 case RPC_FC_ALIGNM8:
1666 ALIGN_LENGTH(size, 7);
1667 break;
1668 case RPC_FC_EMBEDDED_COMPLEX:
1669 size += pFormat[1];
1670 pFormat += 2;
1671 desc = pFormat + *(const SHORT*)pFormat;
1672 size += EmbeddedComplexSize(pStubMsg, desc);
1673 pFormat += 2;
1674 continue;
1675 case RPC_FC_PAD:
1676 break;
1677 default:
1678 FIXME("unhandled format %d\n", *pFormat);
1679 }
1680 pFormat++;
1681 }
1682
1683 return size;
1684 }
1685
1686 /***********************************************************************
1687 * NdrComplexStructMarshall [RPCRT4.@]
1688 */
1689 unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1690 unsigned char *pMemory,
1691 PFORMAT_STRING pFormat)
1692 {
1693 PFORMAT_STRING conf_array = NULL;
1694 PFORMAT_STRING pointer_desc = NULL;
1695 unsigned char *OldMemory = pStubMsg->Memory;
1696
1697 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1698
1699 pFormat += 4;
1700 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1701 pFormat += 2;
1702 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1703 pFormat += 2;
1704
1705 pStubMsg->Memory = pMemory;
1706
1707 ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
1708
1709 if (conf_array)
1710 NdrConformantArrayMarshall(pStubMsg, pMemory, conf_array);
1711
1712 pStubMsg->Memory = OldMemory;
1713
1714 STD_OVERFLOW_CHECK(pStubMsg);
1715
1716 return NULL;
1717 }
1718
1719 /***********************************************************************
1720 * NdrComplexStructUnmarshall [RPCRT4.@]
1721 */
1722 unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1723 unsigned char **ppMemory,
1724 PFORMAT_STRING pFormat,
1725 unsigned char fMustAlloc)
1726 {
1727 unsigned size = *(const WORD*)(pFormat+2);
1728 PFORMAT_STRING conf_array = NULL;
1729 PFORMAT_STRING pointer_desc = NULL;
1730 unsigned char *pMemory;
1731
1732 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1733
1734 if (fMustAlloc || !*ppMemory)
1735 *ppMemory = NdrAllocate(pStubMsg, size);
1736
1737 pFormat += 4;
1738 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1739 pFormat += 2;
1740 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1741 pFormat += 2;
1742
1743 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
1744
1745 if (conf_array)
1746 NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
1747
1748 return NULL;
1749 }
1750
1751 /***********************************************************************
1752 * NdrComplexStructBufferSize [RPCRT4.@]
1753 */
1754 void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1755 unsigned char *pMemory,
1756 PFORMAT_STRING pFormat)
1757 {
1758 PFORMAT_STRING conf_array = NULL;
1759 PFORMAT_STRING pointer_desc = NULL;
1760 unsigned char *OldMemory = pStubMsg->Memory;
1761
1762 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1763
1764 pFormat += 4;
1765 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1766 pFormat += 2;
1767 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1768 pFormat += 2;
1769
1770 pStubMsg->Memory = pMemory;
1771
1772 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
1773
1774 if (conf_array)
1775 NdrConformantArrayBufferSize(pStubMsg, pMemory, conf_array);
1776
1777 pStubMsg->Memory = OldMemory;
1778 }
1779
1780 /***********************************************************************
1781 * NdrComplexStructMemorySize [RPCRT4.@]
1782 */
1783 unsigned long WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1784 PFORMAT_STRING pFormat)
1785 {
1786 /* unsigned size = *(LPWORD)(pFormat+2); */
1787 PFORMAT_STRING conf_array = NULL;
1788 PFORMAT_STRING pointer_desc = NULL;
1789
1790 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1791
1792 pFormat += 4;
1793 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1794 pFormat += 2;
1795 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1796 pFormat += 2;
1797
1798 return 0;
1799 }
1800
1801 /***********************************************************************
1802 * NdrComplexStructFree [RPCRT4.@]
1803 */
1804 void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1805 unsigned char *pMemory,
1806 PFORMAT_STRING pFormat)
1807 {
1808 PFORMAT_STRING conf_array = NULL;
1809 PFORMAT_STRING pointer_desc = NULL;
1810 unsigned char *OldMemory = pStubMsg->Memory;
1811
1812 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1813
1814 pFormat += 4;
1815 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1816 pFormat += 2;
1817 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1818 pFormat += 2;
1819
1820 pStubMsg->Memory = pMemory;
1821
1822 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
1823
1824 if (conf_array)
1825 NdrConformantArrayFree(pStubMsg, pMemory, conf_array);
1826
1827 pStubMsg->Memory = OldMemory;
1828 }
1829
1830 /***********************************************************************
1831 * NdrConformantArrayMarshall [RPCRT4.@]
1832 */
1833 unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1834 unsigned char *pMemory,
1835 PFORMAT_STRING pFormat)
1836 {
1837 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1838 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1839 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1840
1841 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1842 size = pStubMsg->MaxCount;
1843
1844 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
1845 pStubMsg->Buffer += 4;
1846
1847 memcpy(pStubMsg->Buffer, pMemory, size*esize);
1848 pStubMsg->BufferMark = pStubMsg->Buffer;
1849 pStubMsg->Buffer += size*esize;
1850
1851 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
1852
1853 STD_OVERFLOW_CHECK(pStubMsg);
1854
1855 return NULL;
1856 }
1857
1858 /***********************************************************************
1859 * NdrConformantArrayUnmarshall [RPCRT4.@]
1860 */
1861 unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1862 unsigned char **ppMemory,
1863 PFORMAT_STRING pFormat,
1864 unsigned char fMustAlloc)
1865 {
1866 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1867 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1868 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1869
1870 pFormat = ReadConformance(pStubMsg, pFormat+4);
1871 size = pStubMsg->MaxCount;
1872
1873 if (fMustAlloc || !*ppMemory)
1874 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1875
1876 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1877
1878 pStubMsg->BufferMark = pStubMsg->Buffer;
1879 pStubMsg->Buffer += size*esize;
1880
1881 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
1882
1883 return NULL;
1884 }
1885
1886 /***********************************************************************
1887 * NdrConformantArrayBufferSize [RPCRT4.@]
1888 */
1889 void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1890 unsigned char *pMemory,
1891 PFORMAT_STRING pFormat)
1892 {
1893 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1894 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1895 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1896
1897 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1898 size = pStubMsg->MaxCount;
1899
1900 pStubMsg->BufferLength += size*esize;
1901
1902 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1903 }
1904
1905 /***********************************************************************
1906 * NdrConformantArrayMemorySize [RPCRT4.@]
1907 */
1908 unsigned long WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1909 PFORMAT_STRING pFormat)
1910 {
1911 DWORD size = 0;
1912 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1913 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1914
1915 pFormat = ReadConformance(pStubMsg, pFormat+4);
1916 size = pStubMsg->MaxCount;
1917
1918 EmbeddedPointerMemorySize(pStubMsg, pFormat);
1919
1920 return 0;
1921 }
1922
1923 /***********************************************************************
1924 * NdrConformantArrayFree [RPCRT4.@]
1925 */
1926 void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
1927 unsigned char *pMemory,
1928 PFORMAT_STRING pFormat)
1929 {
1930 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1931 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1932
1933 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
1934 }
1935
1936
1937 /***********************************************************************
1938 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1939 */
1940 unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
1941 unsigned char* pMemory,
1942 PFORMAT_STRING pFormat )
1943 {
1944 FIXME( "stub\n" );
1945 return NULL;
1946 }
1947
1948
1949 /***********************************************************************
1950 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1951 */
1952 unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
1953 unsigned char** ppMemory,
1954 PFORMAT_STRING pFormat,
1955 unsigned char fMustAlloc )
1956 {
1957 FIXME( "stub\n" );
1958 return NULL;
1959 }
1960
1961
1962 /***********************************************************************
1963 * NdrConformantVaryingArrayFree [RPCRT4.@]
1964 */
1965 void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
1966 unsigned char* pMemory,
1967 PFORMAT_STRING pFormat )
1968 {
1969 FIXME( "stub\n" );
1970 }
1971
1972
1973 /***********************************************************************
1974 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1975 */
1976 void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
1977 unsigned char* pMemory, PFORMAT_STRING pFormat )
1978 {
1979 FIXME( "stub\n" );
1980 }
1981
1982
1983 /***********************************************************************
1984 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1985 */
1986 unsigned long WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
1987 PFORMAT_STRING pFormat )
1988 {
1989 FIXME( "stub\n" );
1990 return 0;
1991 }
1992
1993
1994 /***********************************************************************
1995 * NdrComplexArrayMarshall [RPCRT4.@]
1996 */
1997 unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1998 unsigned char *pMemory,
1999 PFORMAT_STRING pFormat)
2000 {
2001 DWORD size = 0, count, def;
2002 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2003
2004 def = *(const WORD*)&pFormat[2];
2005 pFormat += 4;
2006
2007 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2008 size = pStubMsg->MaxCount;
2009 TRACE("conformance=%ld\n", size);
2010
2011 if (*(const DWORD*)pFormat != 0xffffffff)
2012 FIXME("compute variance\n");
2013 pFormat += 4;
2014
2015 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
2016 pStubMsg->Buffer += 4;
2017
2018 for (count=0; count<size; count++)
2019 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2020
2021 STD_OVERFLOW_CHECK(pStubMsg);
2022
2023 return NULL;
2024 }
2025
2026 /***********************************************************************
2027 * NdrComplexArrayUnmarshall [RPCRT4.@]
2028 */
2029 unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2030 unsigned char **ppMemory,
2031 PFORMAT_STRING pFormat,
2032 unsigned char fMustAlloc)
2033 {
2034 DWORD size = 0, count, esize;
2035 unsigned char *pMemory;
2036 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2037
2038 pFormat += 4;
2039
2040 pFormat = ReadConformance(pStubMsg, pFormat);
2041 size = pStubMsg->MaxCount;
2042 TRACE("conformance=%ld\n", size);
2043
2044 pFormat += 4;
2045
2046 esize = ComplexStructSize(pStubMsg, pFormat);
2047
2048 if (fMustAlloc || !*ppMemory)
2049 *ppMemory = NdrAllocate(pStubMsg, size*esize);
2050
2051 pMemory = *ppMemory;
2052 for (count=0; count<size; count++)
2053 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2054
2055 return NULL;
2056 }
2057
2058 /***********************************************************************
2059 * NdrComplexArrayBufferSize [RPCRT4.@]
2060 */
2061 void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2062 unsigned char *pMemory,
2063 PFORMAT_STRING pFormat)
2064 {
2065 DWORD size = 0, count, def;
2066 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2067
2068 def = *(const WORD*)&pFormat[2];
2069 pFormat += 4;
2070
2071 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2072 size = pStubMsg->MaxCount;
2073 TRACE("conformance=%ld\n", size);
2074
2075 if (*(const DWORD*)pFormat != 0xffffffff)
2076 FIXME("compute variance\n");
2077 pFormat += 4;
2078
2079 for (count=0; count<size; count++)
2080 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
2081 }
2082
2083 /***********************************************************************
2084 * NdrComplexArrayMemorySize [RPCRT4.@]
2085 */
2086 unsigned long WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2087 PFORMAT_STRING pFormat)
2088 {
2089 DWORD size = 0;
2090 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2091
2092 pFormat += 4;
2093
2094 pFormat = ReadConformance(pStubMsg, pFormat);
2095 size = pStubMsg->MaxCount;
2096 TRACE("conformance=%ld\n", size);
2097
2098 pFormat += 4;
2099
2100 return 0;
2101 }
2102
2103 /***********************************************************************
2104 * NdrComplexArrayFree [RPCRT4.@]
2105 */
2106 void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2107 unsigned char *pMemory,
2108 PFORMAT_STRING pFormat)
2109 {
2110 DWORD size = 0, count, def;
2111 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2112
2113 def = *(const WORD*)&pFormat[2];
2114 pFormat += 4;
2115
2116 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2117 size = pStubMsg->MaxCount;
2118 TRACE("conformance=%ld\n", size);
2119
2120 if (*(const DWORD*)pFormat != 0xffffffff)
2121 FIXME("compute variance\n");
2122 pFormat += 4;
2123
2124 for (count=0; count<size; count++)
2125 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2126 }
2127
2128 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg)
2129 {
2130 return MAKELONG(pStubMsg->dwDestContext,
2131 pStubMsg->RpcMsg->DataRepresentation);
2132 }
2133
2134 /***********************************************************************
2135 * NdrUserMarshalMarshall [RPCRT4.@]
2136 */
2137 unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2138 unsigned char *pMemory,
2139 PFORMAT_STRING pFormat)
2140 {
2141 /* unsigned flags = pFormat[1]; */
2142 unsigned index = *(const WORD*)&pFormat[2];
2143 unsigned long uflag = UserMarshalFlags(pStubMsg);
2144 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2145 TRACE("index=%d\n", index);
2146
2147 pStubMsg->Buffer =
2148 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
2149 &uflag, pStubMsg->Buffer, pMemory);
2150
2151 STD_OVERFLOW_CHECK(pStubMsg);
2152
2153 return NULL;
2154 }
2155
2156 /***********************************************************************
2157 * NdrUserMarshalUnmarshall [RPCRT4.@]
2158 */
2159 unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2160 unsigned char **ppMemory,
2161 PFORMAT_STRING pFormat,
2162 unsigned char fMustAlloc)
2163 {
2164 /* unsigned flags = pFormat[1];*/
2165 unsigned index = *(const WORD*)&pFormat[2];
2166 DWORD memsize = *(const WORD*)&pFormat[4];
2167 unsigned long uflag = UserMarshalFlags(pStubMsg);
2168 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2169 TRACE("index=%d\n", index);
2170
2171 if (fMustAlloc || !*ppMemory)
2172 *ppMemory = NdrAllocate(pStubMsg, memsize);
2173
2174 pStubMsg->Buffer =
2175 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
2176 &uflag, pStubMsg->Buffer, *ppMemory);
2177
2178 return NULL;
2179 }
2180
2181 /***********************************************************************
2182 * NdrUserMarshalBufferSize [RPCRT4.@]
2183 */
2184 void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2185 unsigned char *pMemory,
2186 PFORMAT_STRING pFormat)
2187 {
2188 /* unsigned flags = pFormat[1];*/
2189 unsigned index = *(const WORD*)&pFormat[2];
2190 DWORD bufsize = *(const WORD*)&pFormat[6];
2191 unsigned long uflag = UserMarshalFlags(pStubMsg);
2192 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2193 TRACE("index=%d\n", index);
2194
2195 if (bufsize) {
2196 TRACE("size=%ld\n", bufsize);
2197 pStubMsg->BufferLength += bufsize;
2198 return;
2199 }
2200
2201 pStubMsg->BufferLength =
2202 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
2203 &uflag, pStubMsg->BufferLength, pMemory);
2204 }
2205
2206 /***********************************************************************
2207 * NdrUserMarshalMemorySize [RPCRT4.@]
2208 */
2209 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2210 PFORMAT_STRING pFormat)
2211 {
2212 unsigned index = *(const WORD*)&pFormat[2];
2213 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2214 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2215 TRACE("index=%d\n", index);
2216
2217 return 0;
2218 }
2219
2220 /***********************************************************************
2221 * NdrUserMarshalFree [RPCRT4.@]
2222 */
2223 void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
2224 unsigned char *pMemory,
2225 PFORMAT_STRING pFormat)
2226 {
2227 /* unsigned flags = pFormat[1]; */
2228 unsigned index = *(const WORD*)&pFormat[2];
2229 unsigned long uflag = UserMarshalFlags(pStubMsg);
2230 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2231 TRACE("index=%d\n", index);
2232
2233 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
2234 &uflag, pMemory);
2235 }
2236
2237 /***********************************************************************
2238 * NdrClearOutParameters [RPCRT4.@]
2239 */
2240 void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
2241 PFORMAT_STRING pFormat,
2242 void *ArgAddr)
2243 {
2244 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
2245 }
2246
2247 /***********************************************************************
2248 * NdrConvert [RPCRT4.@]
2249 */
2250 void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
2251 {
2252 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
2253 /* FIXME: since this stub doesn't do any converting, the proper behavior
2254 is to raise an exception */
2255 }
2256
2257 /***********************************************************************
2258 * NdrConvert2 [RPCRT4.@]
2259 */
2260 void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams )
2261 {
2262 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2263 pStubMsg, pFormat, NumberParams);
2264 /* FIXME: since this stub doesn't do any converting, the proper behavior
2265 is to raise an exception */
2266 }
2267
2268 /***********************************************************************
2269 * NdrConformantStructMarshall [RPCRT4.@]
2270 */
2271 unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2272 unsigned char *pMemory,
2273 PFORMAT_STRING pFormat)
2274 {
2275 FIXME("stub\n");
2276 return NULL;
2277 }
2278
2279 /***********************************************************************
2280 * NdrConformantStructUnmarshall [RPCRT4.@]
2281 */
2282 unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2283 unsigned char **ppMemory,
2284 PFORMAT_STRING pFormat,
2285 unsigned char fMustAlloc)
2286 {
2287 FIXME("stub\n");
2288 return NULL;
2289 }
2290
2291 /***********************************************************************
2292 * NdrConformantStructBufferSize [RPCRT4.@]
2293 */
2294 void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2295 unsigned char *pMemory,
2296 PFORMAT_STRING pFormat)
2297 {
2298 FIXME("stub\n");
2299 }
2300
2301 /***********************************************************************
2302 * NdrConformantStructMemorySize [RPCRT4.@]
2303 */
2304 unsigned long WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2305 PFORMAT_STRING pFormat)
2306 {
2307 FIXME("stub\n");
2308 return 0;
2309 }
2310
2311 /***********************************************************************
2312 * NdrConformantStructFree [RPCRT4.@]
2313 */
2314 void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2315 unsigned char *pMemory,
2316 PFORMAT_STRING pFormat)
2317 {
2318 FIXME("stub\n");
2319 }
2320
2321 /***********************************************************************
2322 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2323 */
2324 unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2325 unsigned char *pMemory,
2326 PFORMAT_STRING pFormat)
2327 {
2328 FIXME("stub\n");
2329 return NULL;
2330 }
2331
2332 /***********************************************************************
2333 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2334 */
2335 unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2336 unsigned char **ppMemory,
2337 PFORMAT_STRING pFormat,
2338 unsigned char fMustAlloc)
2339 {
2340 FIXME("stub\n");
2341 return NULL;
2342 }
2343
2344 /***********************************************************************
2345 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2346 */
2347 void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2348 unsigned char *pMemory,
2349 PFORMAT_STRING pFormat)
2350 {
2351 FIXME("stub\n");
2352 }
2353
2354 /***********************************************************************
2355 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2356 */
2357 unsigned long WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2358 PFORMAT_STRING pFormat)
2359 {
2360 FIXME("stub\n");
2361 return 0;
2362 }
2363
2364 /***********************************************************************
2365 * NdrConformantVaryingStructFree [RPCRT4.@]
2366 */
2367 void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2368 unsigned char *pMemory,
2369 PFORMAT_STRING pFormat)
2370 {
2371 FIXME("stub\n");
2372 }
2373
2374 /***********************************************************************
2375 * NdrFixedArrayMarshall [RPCRT4.@]
2376 */
2377 unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2378 unsigned char *pMemory,
2379 PFORMAT_STRING pFormat)
2380 {
2381 FIXME("stub\n");
2382 return NULL;
2383 }
2384
2385 /***********************************************************************
2386 * NdrFixedArrayUnmarshall [RPCRT4.@]
2387 */
2388 unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2389 unsigned char **ppMemory,
2390 PFORMAT_STRING pFormat,
2391 unsigned char fMustAlloc)
2392 {
2393 FIXME("stub\n");
2394 return NULL;
2395 }
2396
2397 /***********************************************************************
2398 * NdrFixedArrayBufferSize [RPCRT4.@]
2399 */
2400 void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2401 unsigned char *pMemory,
2402 PFORMAT_STRING pFormat)
2403 {
2404 FIXME("stub\n");
2405 }
2406
2407 /***********************************************************************
2408 * NdrFixedArrayMemorySize [RPCRT4.@]
2409 */
2410 unsigned long WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2411 PFORMAT_STRING pFormat)
2412 {
2413 FIXME("stub\n");
2414 return 0;
2415 }
2416
2417 /***********************************************************************
2418 * NdrFixedArrayFree [RPCRT4.@]
2419 */
2420 void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2421 unsigned char *pMemory,
2422 PFORMAT_STRING pFormat)
2423 {
2424 FIXME("stub\n");
2425 }
2426
2427 /***********************************************************************
2428 * NdrVaryingArrayMarshall [RPCRT4.@]
2429 */
2430 unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2431 unsigned char *pMemory,
2432 PFORMAT_STRING pFormat)
2433 {
2434 FIXME("stub\n");
2435 return NULL;
2436 }
2437
2438 /***********************************************************************
2439 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2440 */
2441 unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2442 unsigned char **ppMemory,
2443 PFORMAT_STRING pFormat,
2444 unsigned char fMustAlloc)
2445 {
2446 FIXME("stub\n");
2447 return NULL;
2448 }
2449
2450 /***********************************************************************
2451 * NdrVaryingArrayBufferSize [RPCRT4.@]
2452 */
2453 void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2454 unsigned char *pMemory,
2455 PFORMAT_STRING pFormat)
2456 {
2457 FIXME("stub\n");
2458 }
2459
2460 /***********************************************************************
2461 * NdrVaryingArrayMemorySize [RPCRT4.@]
2462 */
2463 unsigned long WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2464 PFORMAT_STRING pFormat)
2465 {
2466 FIXME("stub\n");
2467 return 0;
2468 }
2469
2470 /***********************************************************************
2471 * NdrVaryingArrayFree [RPCRT4.@]
2472 */
2473 void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2474 unsigned char *pMemory,
2475 PFORMAT_STRING pFormat)
2476 {
2477 FIXME("stub\n");
2478 }
2479
2480 /***********************************************************************
2481 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2482 */
2483 unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2484 unsigned char *pMemory,
2485 PFORMAT_STRING pFormat)
2486 {
2487 FIXME("stub\n");
2488 return NULL;
2489 }
2490
2491 /***********************************************************************
2492 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2493 */
2494 unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2495 unsigned char **ppMemory,
2496 PFORMAT_STRING pFormat,
2497 unsigned char fMustAlloc)
2498 {
2499 FIXME("stub\n");
2500 return NULL;
2501 }
2502
2503 /***********************************************************************
2504 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2505 */
2506 void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2507 unsigned char *pMemory,
2508 PFORMAT_STRING pFormat)
2509 {
2510 FIXME("stub\n");
2511 }
2512
2513 /***********************************************************************
2514 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2515 */
2516 unsigned long WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2517 PFORMAT_STRING pFormat)
2518 {
2519 FIXME("stub\n");
2520 return 0;
2521 }
2522
2523 /***********************************************************************
2524 * NdrEncapsulatedUnionFree [RPCRT4.@]
2525 */
2526 void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2527 unsigned char *pMemory,
2528 PFORMAT_STRING pFormat)
2529 {
2530 FIXME("stub\n");
2531 }
2532
2533 /***********************************************************************
2534 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2535 */
2536 unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2537 unsigned char *pMemory,
2538 PFORMAT_STRING pFormat)
2539 {
2540 FIXME("stub\n");
2541 return NULL;
2542 }
2543
2544 /***********************************************************************
2545 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2546 */
2547 unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2548 unsigned char **ppMemory,
2549 PFORMAT_STRING pFormat,
2550 unsigned char fMustAlloc)
2551 {
2552 FIXME("stub\n");
2553 return NULL;
2554 }
2555
2556 /***********************************************************************
2557 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2558 */
2559 void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2560 unsigned char *pMemory,
2561 PFORMAT_STRING pFormat)
2562 {
2563 FIXME("stub\n");
2564 }
2565
2566 /***********************************************************************
2567 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2568 */
2569 unsigned long WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2570 PFORMAT_STRING pFormat)
2571 {
2572 FIXME("stub\n");
2573 return 0;
2574 }
2575
2576 /***********************************************************************
2577 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2578 */
2579 void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2580 unsigned char *pMemory,
2581 PFORMAT_STRING pFormat)
2582 {
2583 FIXME("stub\n");
2584 }
2585
2586 /***********************************************************************
2587 * NdrByteCountPointerMarshall [RPCRT4.@]
2588 */
2589 unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2590 unsigned char *pMemory,
2591 PFORMAT_STRING pFormat)
2592 {
2593 FIXME("stub\n");
2594 return NULL;
2595 }
2596
2597 /***********************************************************************
2598 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2599 */
2600 unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2601 unsigned char **ppMemory,
2602 PFORMAT_STRING pFormat,
2603 unsigned char fMustAlloc)
2604 {
2605 FIXME("stub\n");
2606 return NULL;
2607 }
2608
2609 /***********************************************************************
2610 * NdrByteCountPointerBufferSize [RPCRT4.@]
2611 */
2612 void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2613 unsigned char *pMemory,
2614 PFORMAT_STRING pFormat)
2615 {
2616 FIXME("stub\n");
2617 }
2618
2619 /***********************************************************************
2620 * NdrByteCountPointerMemorySize [RPCRT4.@]
2621 */
2622 unsigned long WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2623 PFORMAT_STRING pFormat)
2624 {
2625 FIXME("stub\n");
2626 return 0;
2627 }
2628
2629 /***********************************************************************
2630 * NdrByteCountPointerFree [RPCRT4.@]
2631 */
2632 void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
2633 unsigned char *pMemory,
2634 PFORMAT_STRING pFormat)
2635 {
2636 FIXME("stub\n");
2637 }
2638
2639 /***********************************************************************
2640 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2641 */
2642 unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2643 unsigned char *pMemory,
2644 PFORMAT_STRING pFormat)
2645 {
2646 FIXME("stub\n");
2647 return NULL;
2648 }
2649
2650 /***********************************************************************
2651 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2652 */
2653 unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2654 unsigned char **ppMemory,
2655 PFORMAT_STRING pFormat,
2656 unsigned char fMustAlloc)
2657 {
2658 FIXME("stub\n");
2659 return NULL;
2660 }
2661
2662 /***********************************************************************
2663 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2664 */
2665 void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2666 unsigned char *pMemory,
2667 PFORMAT_STRING pFormat)
2668 {
2669 FIXME("stub\n");
2670 }
2671
2672 /***********************************************************************
2673 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2674 */
2675 unsigned long WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2676 PFORMAT_STRING pFormat)
2677 {
2678 FIXME("stub\n");
2679 return 0;
2680 }
2681
2682 /***********************************************************************
2683 * NdrXmitOrRepAsFree [RPCRT4.@]
2684 */
2685 void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
2686 unsigned char *pMemory,
2687 PFORMAT_STRING pFormat)
2688 {
2689 FIXME("stub\n");
2690 }
2691
2692 /***********************************************************************
2693 * NdrClientContextMarshall
2694 */
2695 void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2696 NDR_CCONTEXT ContextHandle,
2697 int fCheck)
2698 {
2699 FIXME("(%p, %p, %d): stub\n", pStubMsg, ContextHandle, fCheck);
2700 }
2701
2702 /***********************************************************************
2703 * NdrClientContextUnmarshall
2704 */
2705 void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2706 NDR_CCONTEXT * pContextHandle,
2707 RPC_BINDING_HANDLE BindHandle)
2708 {
2709 FIXME("(%p, %p, %p): stub\n", pStubMsg, pContextHandle, BindHandle);
2710 }
2711
2712 void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2713 NDR_SCONTEXT ContextHandle,
2714 NDR_RUNDOWN RundownRoutine )
2715 {
2716 FIXME("(%p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine);
2717 }
2718
2719 NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
2720 {
2721 FIXME("(%p): stub\n", pStubMsg);
2722 return NULL;
2723 }
2724
2725 void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
2726 unsigned char* pMemory,
2727 PFORMAT_STRING pFormat)
2728 {
2729 FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
2730 }
2731
2732 NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
2733 PFORMAT_STRING pFormat)
2734 {
2735 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2736 return NULL;
2737 }
2738
2739 void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2740 NDR_SCONTEXT ContextHandle,
2741 NDR_RUNDOWN RundownRoutine,
2742 PFORMAT_STRING pFormat)
2743 {
2744 FIXME("(%p, %p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
2745 }
2746
2747 NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2748 PFORMAT_STRING pFormat)
2749 {
2750 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2751 return NULL;
2752 }
2753
2754 RPC_BINDING_HANDLE WINAPI NDRCContextBinding(NDR_CCONTEXT CContext)
2755 {
2756 FIXME("(%p): stub\n", CContext);
2757 return NULL;
2758 }