Sync to Wine-20050830:
[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 case RPC_FC_FP:
742 default:
743 FIXME("unhandled ptr type=%02x\n", type);
744 RpcRaiseException(RPC_X_BAD_STUB_DATA);
745 }
746
747 *pPointer = NULL;
748
749 if (pointer_id) {
750 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
751 if (m) m(pStubMsg, pPointer, desc, fMustAlloc);
752 else FIXME("no unmarshaller for data type=%02x\n", *desc);
753 }
754
755 TRACE("pointer=%p\n", *pPointer);
756 }
757
758 /***********************************************************************
759 * PointerBufferSize
760 */
761 void WINAPI PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
762 unsigned char *Pointer,
763 PFORMAT_STRING pFormat)
764 {
765 unsigned type = pFormat[0], attr = pFormat[1];
766 PFORMAT_STRING desc;
767 NDR_BUFFERSIZE m;
768
769 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
770 TRACE("type=%d, attr=%d\n", type, attr);
771 pFormat += 2;
772 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
773 else desc = pFormat + *(const SHORT*)pFormat;
774 if (attr & RPC_FC_P_DEREF) {
775 Pointer = *(unsigned char**)Pointer;
776 TRACE("deref => %p\n", Pointer);
777 }
778
779 switch (type) {
780 case RPC_FC_RP: /* ref pointer (always non-null) */
781 break;
782 case RPC_FC_OP:
783 case RPC_FC_UP:
784 pStubMsg->BufferLength += 4;
785 /* NULL pointer has no further representation */
786 if (!Pointer)
787 return;
788 break;
789 case RPC_FC_FP:
790 default:
791 FIXME("unhandled ptr type=%02x\n", type);
792 RpcRaiseException(RPC_X_BAD_STUB_DATA);
793 }
794
795 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
796 if (m) m(pStubMsg, Pointer, desc);
797 else FIXME("no buffersizer for data type=%02x\n", *desc);
798 }
799
800 /***********************************************************************
801 * PointerMemorySize [RPCRT4.@]
802 */
803 unsigned long WINAPI PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
804 unsigned char *Buffer,
805 PFORMAT_STRING pFormat)
806 {
807 unsigned type = pFormat[0], attr = pFormat[1];
808 PFORMAT_STRING desc;
809 NDR_MEMORYSIZE m;
810
811 FIXME("(%p,%p,%p): stub\n", pStubMsg, Buffer, pFormat);
812 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
813 pFormat += 2;
814 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
815 else desc = pFormat + *(const SHORT*)pFormat;
816 if (attr & RPC_FC_P_DEREF) {
817 TRACE("deref\n");
818 }
819
820 switch (type) {
821 case RPC_FC_RP: /* ref pointer (always non-null) */
822 break;
823 default:
824 FIXME("unhandled ptr type=%02x\n", type);
825 RpcRaiseException(RPC_X_BAD_STUB_DATA);
826 }
827
828 m = NdrMemorySizer[*desc & NDR_TABLE_MASK];
829 if (m) m(pStubMsg, desc);
830 else FIXME("no memorysizer for data type=%02x\n", *desc);
831
832 return 0;
833 }
834
835 /***********************************************************************
836 * PointerFree [RPCRT4.@]
837 */
838 void WINAPI PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
839 unsigned char *Pointer,
840 PFORMAT_STRING pFormat)
841 {
842 unsigned type = pFormat[0], attr = pFormat[1];
843 PFORMAT_STRING desc;
844 NDR_FREE m;
845
846 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
847 TRACE("type=%d, attr=", type); dump_pointer_attr(attr);
848 if (attr & RPC_FC_P_DONTFREE) return;
849 pFormat += 2;
850 if (attr & RPC_FC_P_SIMPLEPOINTER) desc = pFormat;
851 else desc = pFormat + *(const SHORT*)pFormat;
852 if (attr & RPC_FC_P_DEREF) {
853 Pointer = *(unsigned char**)Pointer;
854 TRACE("deref => %p\n", Pointer);
855 }
856
857 if (!Pointer) return;
858
859 m = NdrFreer[*desc & NDR_TABLE_MASK];
860 if (m) m(pStubMsg, Pointer, desc);
861
862 /* hmm... is this sensible?
863 * perhaps we should check if the memory comes from NdrAllocate,
864 * and deallocate only if so - checking if the pointer is between
865 * BufferStart and BufferEnd is probably no good since the buffer
866 * may be reallocated when the server wants to marshal the reply */
867 switch (*desc) {
868 case RPC_FC_BOGUS_STRUCT:
869 case RPC_FC_BOGUS_ARRAY:
870 case RPC_FC_USER_MARSHAL:
871 break;
872 default:
873 FIXME("unhandled data type=%02x\n", *desc);
874 case RPC_FC_CARRAY:
875 case RPC_FC_C_CSTRING:
876 case RPC_FC_C_WSTRING:
877 if (pStubMsg->ReuseBuffer) goto notfree;
878 break;
879 case RPC_FC_IP:
880 goto notfree;
881 }
882
883 if (attr & RPC_FC_P_ONSTACK) {
884 TRACE("not freeing stack ptr %p\n", Pointer);
885 return;
886 }
887 TRACE("freeing %p\n", Pointer);
888 NdrFree(pStubMsg, Pointer);
889 return;
890 notfree:
891 TRACE("not freeing %p\n", Pointer);
892 }
893
894 /***********************************************************************
895 * EmbeddedPointerMarshall
896 */
897 unsigned char * WINAPI EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
898 unsigned char *pMemory,
899 PFORMAT_STRING pFormat)
900 {
901 unsigned char *Mark = pStubMsg->BufferMark;
902 unsigned long Offset = pStubMsg->Offset;
903 unsigned ofs, rep, count, stride, xofs;
904
905 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
906
907 if (*pFormat != RPC_FC_PP) return NULL;
908 pFormat += 2;
909
910 while (pFormat[0] != RPC_FC_END) {
911 switch (pFormat[0]) {
912 default:
913 FIXME("unknown repeat type %d\n", pFormat[0]);
914 case RPC_FC_NO_REPEAT:
915 rep = 1;
916 stride = 0;
917 ofs = 0;
918 count = 1;
919 xofs = 0;
920 pFormat += 2;
921 break;
922 case RPC_FC_FIXED_REPEAT:
923 rep = *(const WORD*)&pFormat[2];
924 stride = *(const WORD*)&pFormat[4];
925 ofs = *(const WORD*)&pFormat[6];
926 count = *(const WORD*)&pFormat[8];
927 xofs = 0;
928 pFormat += 10;
929 break;
930 case RPC_FC_VARIABLE_REPEAT:
931 rep = pStubMsg->MaxCount;
932 stride = *(const WORD*)&pFormat[2];
933 ofs = *(const WORD*)&pFormat[4];
934 count = *(const WORD*)&pFormat[6];
935 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
936 pFormat += 8;
937 break;
938 }
939 /* ofs doesn't seem to matter in this context */
940 while (rep) {
941 PFORMAT_STRING info = pFormat;
942 unsigned char *membase = pMemory + xofs;
943 unsigned u;
944 for (u=0; u<count; u++,info+=8) {
945 unsigned char *memptr = membase + *(const SHORT*)&info[0];
946 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
947 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
948 }
949 rep--;
950 }
951 pFormat += 8 * count;
952 }
953
954 STD_OVERFLOW_CHECK(pStubMsg);
955
956 return NULL;
957 }
958
959 /***********************************************************************
960 * EmbeddedPointerUnmarshall
961 */
962 unsigned char * WINAPI EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
963 unsigned char **ppMemory,
964 PFORMAT_STRING pFormat,
965 unsigned char fMustAlloc)
966 {
967 unsigned char *Mark = pStubMsg->BufferMark;
968 unsigned long Offset = pStubMsg->Offset;
969 unsigned ofs, rep, count, stride, xofs;
970
971 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
972
973 if (*pFormat != RPC_FC_PP) return NULL;
974 pFormat += 2;
975
976 while (pFormat[0] != RPC_FC_END) {
977 switch (pFormat[0]) {
978 default:
979 FIXME("unknown repeat type %d\n", pFormat[0]);
980 case RPC_FC_NO_REPEAT:
981 rep = 1;
982 stride = 0;
983 ofs = 0;
984 count = 1;
985 xofs = 0;
986 pFormat += 2;
987 break;
988 case RPC_FC_FIXED_REPEAT:
989 rep = *(const WORD*)&pFormat[2];
990 stride = *(const WORD*)&pFormat[4];
991 ofs = *(const WORD*)&pFormat[6];
992 count = *(const WORD*)&pFormat[8];
993 xofs = 0;
994 pFormat += 10;
995 break;
996 case RPC_FC_VARIABLE_REPEAT:
997 rep = pStubMsg->MaxCount;
998 stride = *(const WORD*)&pFormat[2];
999 ofs = *(const WORD*)&pFormat[4];
1000 count = *(const WORD*)&pFormat[6];
1001 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1002 pFormat += 8;
1003 break;
1004 }
1005 /* ofs doesn't seem to matter in this context */
1006 while (rep) {
1007 PFORMAT_STRING info = pFormat;
1008 unsigned char *membase = *ppMemory + xofs;
1009 unsigned u;
1010 for (u=0; u<count; u++,info+=8) {
1011 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1012 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1013 PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
1014 }
1015 rep--;
1016 }
1017 pFormat += 8 * count;
1018 }
1019
1020 return NULL;
1021 }
1022
1023 /***********************************************************************
1024 * EmbeddedPointerBufferSize
1025 */
1026 void WINAPI EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1027 unsigned char *pMemory,
1028 PFORMAT_STRING pFormat)
1029 {
1030 unsigned long Offset = pStubMsg->Offset;
1031 unsigned ofs, rep, count, stride, xofs;
1032
1033 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1034 if (*pFormat != RPC_FC_PP) return;
1035 pFormat += 2;
1036
1037 while (pFormat[0] != RPC_FC_END) {
1038 switch (pFormat[0]) {
1039 default:
1040 FIXME("unknown repeat type %d\n", pFormat[0]);
1041 case RPC_FC_NO_REPEAT:
1042 rep = 1;
1043 stride = 0;
1044 ofs = 0;
1045 count = 1;
1046 xofs = 0;
1047 pFormat += 2;
1048 break;
1049 case RPC_FC_FIXED_REPEAT:
1050 rep = *(const WORD*)&pFormat[2];
1051 stride = *(const WORD*)&pFormat[4];
1052 ofs = *(const WORD*)&pFormat[6];
1053 count = *(const WORD*)&pFormat[8];
1054 xofs = 0;
1055 pFormat += 10;
1056 break;
1057 case RPC_FC_VARIABLE_REPEAT:
1058 rep = pStubMsg->MaxCount;
1059 stride = *(const WORD*)&pFormat[2];
1060 ofs = *(const WORD*)&pFormat[4];
1061 count = *(const WORD*)&pFormat[6];
1062 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1063 pFormat += 8;
1064 break;
1065 }
1066 /* ofs doesn't seem to matter in this context */
1067 while (rep) {
1068 PFORMAT_STRING info = pFormat;
1069 unsigned char *membase = pMemory + xofs;
1070 unsigned u;
1071 for (u=0; u<count; u++,info+=8) {
1072 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1073 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1074 }
1075 rep--;
1076 }
1077 pFormat += 8 * count;
1078 }
1079 }
1080
1081 /***********************************************************************
1082 * EmbeddedPointerMemorySize
1083 */
1084 unsigned long WINAPI EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1085 PFORMAT_STRING pFormat)
1086 {
1087 unsigned long Offset = pStubMsg->Offset;
1088 unsigned char *Mark = pStubMsg->BufferMark;
1089 unsigned ofs, rep, count, stride, xofs;
1090
1091 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1092 if (*pFormat != RPC_FC_PP) return 0;
1093 pFormat += 2;
1094
1095 while (pFormat[0] != RPC_FC_END) {
1096 switch (pFormat[0]) {
1097 default:
1098 FIXME("unknown repeat type %d\n", pFormat[0]);
1099 case RPC_FC_NO_REPEAT:
1100 rep = 1;
1101 stride = 0;
1102 ofs = 0;
1103 count = 1;
1104 xofs = 0;
1105 pFormat += 2;
1106 break;
1107 case RPC_FC_FIXED_REPEAT:
1108 rep = *(const WORD*)&pFormat[2];
1109 stride = *(const WORD*)&pFormat[4];
1110 ofs = *(const WORD*)&pFormat[6];
1111 count = *(const WORD*)&pFormat[8];
1112 xofs = 0;
1113 pFormat += 10;
1114 break;
1115 case RPC_FC_VARIABLE_REPEAT:
1116 rep = pStubMsg->MaxCount;
1117 stride = *(const WORD*)&pFormat[2];
1118 ofs = *(const WORD*)&pFormat[4];
1119 count = *(const WORD*)&pFormat[6];
1120 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1121 pFormat += 8;
1122 break;
1123 }
1124 /* ofs doesn't seem to matter in this context */
1125 while (rep) {
1126 PFORMAT_STRING info = pFormat;
1127 unsigned u;
1128 for (u=0; u<count; u++,info+=8) {
1129 unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
1130 PointerMemorySize(pStubMsg, bufptr, info+4);
1131 }
1132 rep--;
1133 }
1134 pFormat += 8 * count;
1135 }
1136
1137 return 0;
1138 }
1139
1140 /***********************************************************************
1141 * EmbeddedPointerFree
1142 */
1143 void WINAPI EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1144 unsigned char *pMemory,
1145 PFORMAT_STRING pFormat)
1146 {
1147 unsigned long Offset = pStubMsg->Offset;
1148 unsigned ofs, rep, count, stride, xofs;
1149
1150 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1151 if (*pFormat != RPC_FC_PP) return;
1152 pFormat += 2;
1153
1154 while (pFormat[0] != RPC_FC_END) {
1155 switch (pFormat[0]) {
1156 default:
1157 FIXME("unknown repeat type %d\n", pFormat[0]);
1158 case RPC_FC_NO_REPEAT:
1159 rep = 1;
1160 stride = 0;
1161 ofs = 0;
1162 count = 1;
1163 xofs = 0;
1164 pFormat += 2;
1165 break;
1166 case RPC_FC_FIXED_REPEAT:
1167 rep = *(const WORD*)&pFormat[2];
1168 stride = *(const WORD*)&pFormat[4];
1169 ofs = *(const WORD*)&pFormat[6];
1170 count = *(const WORD*)&pFormat[8];
1171 xofs = 0;
1172 pFormat += 10;
1173 break;
1174 case RPC_FC_VARIABLE_REPEAT:
1175 rep = pStubMsg->MaxCount;
1176 stride = *(const WORD*)&pFormat[2];
1177 ofs = *(const WORD*)&pFormat[4];
1178 count = *(const WORD*)&pFormat[6];
1179 xofs = (pFormat[1] == RPC_FC_VARIABLE_OFFSET) ? Offset * stride : 0;
1180 pFormat += 8;
1181 break;
1182 }
1183 /* ofs doesn't seem to matter in this context */
1184 while (rep) {
1185 PFORMAT_STRING info = pFormat;
1186 unsigned char *membase = pMemory + xofs;
1187 unsigned u;
1188 for (u=0; u<count; u++,info+=8) {
1189 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1190 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1191 }
1192 rep--;
1193 }
1194 pFormat += 8 * count;
1195 }
1196 }
1197
1198 /***********************************************************************
1199 * NdrPointerMarshall [RPCRT4.@]
1200 */
1201 unsigned char * WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1202 unsigned char *pMemory,
1203 PFORMAT_STRING pFormat)
1204 {
1205 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1206
1207 pStubMsg->BufferMark = pStubMsg->Buffer;
1208 PointerMarshall(pStubMsg, pStubMsg->Buffer, pMemory, pFormat);
1209
1210 STD_OVERFLOW_CHECK(pStubMsg);
1211
1212 return NULL;
1213 }
1214
1215 /***********************************************************************
1216 * NdrPointerUnmarshall [RPCRT4.@]
1217 */
1218 unsigned char * WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1219 unsigned char **ppMemory,
1220 PFORMAT_STRING pFormat,
1221 unsigned char fMustAlloc)
1222 {
1223 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1224
1225 pStubMsg->BufferMark = pStubMsg->Buffer;
1226 PointerUnmarshall(pStubMsg, pStubMsg->Buffer, ppMemory, pFormat, fMustAlloc);
1227
1228 return NULL;
1229 }
1230
1231 /***********************************************************************
1232 * NdrPointerBufferSize [RPCRT4.@]
1233 */
1234 void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1235 unsigned char *pMemory,
1236 PFORMAT_STRING pFormat)
1237 {
1238 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1239 PointerBufferSize(pStubMsg, pMemory, pFormat);
1240 }
1241
1242 /***********************************************************************
1243 * NdrPointerMemorySize [RPCRT4.@]
1244 */
1245 unsigned long WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1246 PFORMAT_STRING pFormat)
1247 {
1248 /* unsigned size = *(LPWORD)(pFormat+2); */
1249 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1250 PointerMemorySize(pStubMsg, pStubMsg->Buffer, pFormat);
1251 return 0;
1252 }
1253
1254 /***********************************************************************
1255 * NdrPointerFree [RPCRT4.@]
1256 */
1257 void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1258 unsigned char *pMemory,
1259 PFORMAT_STRING pFormat)
1260 {
1261 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1262 PointerFree(pStubMsg, pMemory, pFormat);
1263 }
1264
1265 /***********************************************************************
1266 * NdrSimpleStructMarshall [RPCRT4.@]
1267 */
1268 unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1269 unsigned char *pMemory,
1270 PFORMAT_STRING pFormat)
1271 {
1272 unsigned size = *(const WORD*)(pFormat+2);
1273 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1274
1275 memcpy(pStubMsg->Buffer, pMemory, size);
1276 pStubMsg->BufferMark = pStubMsg->Buffer;
1277 pStubMsg->Buffer += size;
1278
1279 if (pFormat[0] != RPC_FC_STRUCT)
1280 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
1281
1282 /*
1283 * This test does not work when NdrSimpleStructMarshall is called
1284 * by an rpc-server to marshall data to return to the client because
1285 * BufferStart and BufferEnd are bogus. MIDL does not update them
1286 * when a new buffer is allocated in order to return data to the caller.
1287 */
1288 #if 0
1289 STD_OVERFLOW_CHECK(pStubMsg);
1290 #endif
1291
1292 return NULL;
1293 }
1294
1295 /***********************************************************************
1296 * NdrSimpleStructUnmarshall [RPCRT4.@]
1297 */
1298 unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1299 unsigned char **ppMemory,
1300 PFORMAT_STRING pFormat,
1301 unsigned char fMustAlloc)
1302 {
1303 unsigned size = *(const WORD*)(pFormat+2);
1304 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1305
1306 if (fMustAlloc) {
1307 *ppMemory = NdrAllocate(pStubMsg, size);
1308 memcpy(*ppMemory, pStubMsg->Buffer, size);
1309 } else {
1310 if (pStubMsg->ReuseBuffer && !*ppMemory)
1311 /* for servers, we may just point straight into the RPC buffer, I think
1312 * (I guess that's what MS does since MIDL code doesn't try to free) */
1313 *ppMemory = pStubMsg->Buffer;
1314 else
1315 /* for clients, memory should be provided by caller */
1316 memcpy(*ppMemory, pStubMsg->Buffer, size);
1317 }
1318
1319 pStubMsg->BufferMark = pStubMsg->Buffer;
1320 pStubMsg->Buffer += size;
1321
1322 if (pFormat[0] != RPC_FC_STRUCT)
1323 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat+4, fMustAlloc);
1324
1325 return NULL;
1326 }
1327
1328
1329 /***********************************************************************
1330 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1331 */
1332 void WINAPI NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1333 unsigned char *pMemory,
1334 unsigned char FormatChar)
1335 {
1336 FIXME("stub\n");
1337 }
1338
1339
1340 /***********************************************************************
1341 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1342 */
1343 void WINAPI NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1344 unsigned char *pMemory,
1345 unsigned char FormatChar)
1346 {
1347 FIXME("stub\n");
1348 }
1349
1350
1351 /***********************************************************************
1352 * NdrSimpleStructBufferSize [RPCRT4.@]
1353 */
1354 void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1355 unsigned char *pMemory,
1356 PFORMAT_STRING pFormat)
1357 {
1358 unsigned size = *(const WORD*)(pFormat+2);
1359 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1360 pStubMsg->BufferLength += size;
1361 if (pFormat[0] != RPC_FC_STRUCT)
1362 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
1363 }
1364
1365 /***********************************************************************
1366 * NdrSimpleStructMemorySize [RPCRT4.@]
1367 */
1368 unsigned long WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1369 PFORMAT_STRING pFormat)
1370 {
1371 /* unsigned size = *(LPWORD)(pFormat+2); */
1372 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1373 if (pFormat[0] != RPC_FC_STRUCT)
1374 EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
1375 return 0;
1376 }
1377
1378 /***********************************************************************
1379 * NdrSimpleStructFree [RPCRT4.@]
1380 */
1381 void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1382 unsigned char *pMemory,
1383 PFORMAT_STRING pFormat)
1384 {
1385 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1386 if (pFormat[0] != RPC_FC_STRUCT)
1387 EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
1388 }
1389
1390
1391 unsigned long WINAPI EmbeddedComplexSize(PMIDL_STUB_MESSAGE pStubMsg,
1392 PFORMAT_STRING pFormat)
1393 {
1394 switch (*pFormat) {
1395 case RPC_FC_STRUCT:
1396 case RPC_FC_PSTRUCT:
1397 case RPC_FC_CSTRUCT:
1398 case RPC_FC_BOGUS_STRUCT:
1399 return *(const WORD*)&pFormat[2];
1400 case RPC_FC_USER_MARSHAL:
1401 return *(const WORD*)&pFormat[4];
1402 default:
1403 FIXME("unhandled embedded type %02x\n", *pFormat);
1404 }
1405 return 0;
1406 }
1407
1408
1409 unsigned char * WINAPI ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1410 unsigned char *pMemory,
1411 PFORMAT_STRING pFormat,
1412 PFORMAT_STRING pPointer)
1413 {
1414 PFORMAT_STRING desc;
1415 NDR_MARSHALL m;
1416 unsigned long size;
1417
1418 while (*pFormat != RPC_FC_END) {
1419 switch (*pFormat) {
1420 case RPC_FC_SHORT:
1421 case RPC_FC_USHORT:
1422 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
1423 memcpy(pStubMsg->Buffer, pMemory, 2);
1424 pStubMsg->Buffer += 2;
1425 pMemory += 2;
1426 break;
1427 case RPC_FC_LONG:
1428 case RPC_FC_ULONG:
1429 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
1430 memcpy(pStubMsg->Buffer, pMemory, 4);
1431 pStubMsg->Buffer += 4;
1432 pMemory += 4;
1433 break;
1434 case RPC_FC_POINTER:
1435 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
1436 NdrPointerMarshall(pStubMsg, *(unsigned char**)pMemory, pPointer);
1437 pPointer += 4;
1438 pMemory += 4;
1439 break;
1440 case RPC_FC_ALIGNM4:
1441 ALIGN_POINTER(pMemory, 3);
1442 break;
1443 case RPC_FC_ALIGNM8:
1444 ALIGN_POINTER(pMemory, 7);
1445 break;
1446 case RPC_FC_EMBEDDED_COMPLEX:
1447 pMemory += pFormat[1];
1448 pFormat += 2;
1449 desc = pFormat + *(const SHORT*)pFormat;
1450 size = EmbeddedComplexSize(pStubMsg, desc);
1451 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
1452 m = NdrMarshaller[*desc & NDR_TABLE_MASK];
1453 if (m) m(pStubMsg, pMemory, desc);
1454 else FIXME("no marshaller for embedded type %02x\n", *desc);
1455 pMemory += size;
1456 pFormat += 2;
1457 continue;
1458 case RPC_FC_PAD:
1459 break;
1460 default:
1461 FIXME("unhandled format %02x\n", *pFormat);
1462 }
1463 pFormat++;
1464 }
1465
1466 return pMemory;
1467 }
1468
1469 unsigned char * WINAPI ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1470 unsigned char *pMemory,
1471 PFORMAT_STRING pFormat,
1472 PFORMAT_STRING pPointer,
1473 unsigned char fMustAlloc)
1474 {
1475 PFORMAT_STRING desc;
1476 NDR_UNMARSHALL m;
1477 unsigned long size;
1478
1479 while (*pFormat != RPC_FC_END) {
1480 switch (*pFormat) {
1481 case RPC_FC_SHORT:
1482 case RPC_FC_USHORT:
1483 memcpy(pMemory, pStubMsg->Buffer, 2);
1484 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
1485 pStubMsg->Buffer += 2;
1486 pMemory += 2;
1487 break;
1488 case RPC_FC_LONG:
1489 case RPC_FC_ULONG:
1490 memcpy(pMemory, pStubMsg->Buffer, 4);
1491 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
1492 pStubMsg->Buffer += 4;
1493 pMemory += 4;
1494 break;
1495 case RPC_FC_POINTER:
1496 *(unsigned char**)pMemory = NULL;
1497 TRACE("pointer => %p\n", pMemory);
1498 NdrPointerUnmarshall(pStubMsg, (unsigned char**)pMemory, pPointer, fMustAlloc);
1499 pPointer += 4;
1500 pMemory += 4;
1501 break;
1502 case RPC_FC_ALIGNM4:
1503 ALIGN_POINTER(pMemory, 3);
1504 break;
1505 case RPC_FC_ALIGNM8:
1506 ALIGN_POINTER(pMemory, 7);
1507 break;
1508 case RPC_FC_EMBEDDED_COMPLEX:
1509 pMemory += pFormat[1];
1510 pFormat += 2;
1511 desc = pFormat + *(const SHORT*)pFormat;
1512 size = EmbeddedComplexSize(pStubMsg, desc);
1513 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
1514 m = NdrUnmarshaller[*desc & NDR_TABLE_MASK];
1515 memset(pMemory, 0, size); /* just in case */
1516 if (m) m(pStubMsg, &pMemory, desc, fMustAlloc);
1517 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
1518 pMemory += size;
1519 pFormat += 2;
1520 continue;
1521 case RPC_FC_PAD:
1522 break;
1523 default:
1524 FIXME("unhandled format %d\n", *pFormat);
1525 }
1526 pFormat++;
1527 }
1528
1529 return pMemory;
1530 }
1531
1532 unsigned char * WINAPI ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1533 unsigned char *pMemory,
1534 PFORMAT_STRING pFormat,
1535 PFORMAT_STRING pPointer)
1536 {
1537 PFORMAT_STRING desc;
1538 NDR_BUFFERSIZE m;
1539 unsigned long size;
1540
1541 while (*pFormat != RPC_FC_END) {
1542 switch (*pFormat) {
1543 case RPC_FC_SHORT:
1544 case RPC_FC_USHORT:
1545 pStubMsg->BufferLength += 2;
1546 pMemory += 2;
1547 break;
1548 case RPC_FC_LONG:
1549 case RPC_FC_ULONG:
1550 pStubMsg->BufferLength += 4;
1551 pMemory += 4;
1552 break;
1553 case RPC_FC_POINTER:
1554 NdrPointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
1555 pPointer += 4;
1556 pMemory += 4;
1557 break;
1558 case RPC_FC_ALIGNM4:
1559 ALIGN_POINTER(pMemory, 3);
1560 break;
1561 case RPC_FC_ALIGNM8:
1562 ALIGN_POINTER(pMemory, 7);
1563 break;
1564 case RPC_FC_EMBEDDED_COMPLEX:
1565 pMemory += pFormat[1];
1566 pFormat += 2;
1567 desc = pFormat + *(const SHORT*)pFormat;
1568 size = EmbeddedComplexSize(pStubMsg, desc);
1569 m = NdrBufferSizer[*desc & NDR_TABLE_MASK];
1570 if (m) m(pStubMsg, pMemory, desc);
1571 else FIXME("no buffersizer for embedded type %02x\n", *desc);
1572 pMemory += size;
1573 pFormat += 2;
1574 continue;
1575 case RPC_FC_PAD:
1576 break;
1577 default:
1578 FIXME("unhandled format %d\n", *pFormat);
1579 }
1580 pFormat++;
1581 }
1582
1583 return pMemory;
1584 }
1585
1586 unsigned char * WINAPI ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
1587 unsigned char *pMemory,
1588 PFORMAT_STRING pFormat,
1589 PFORMAT_STRING pPointer)
1590 {
1591 PFORMAT_STRING desc;
1592 NDR_FREE m;
1593 unsigned long size;
1594
1595 while (*pFormat != RPC_FC_END) {
1596 switch (*pFormat) {
1597 case RPC_FC_SHORT:
1598 case RPC_FC_USHORT:
1599 pMemory += 2;
1600 break;
1601 case RPC_FC_LONG:
1602 case RPC_FC_ULONG:
1603 pMemory += 4;
1604 break;
1605 case RPC_FC_POINTER:
1606 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
1607 pPointer += 4;
1608 pMemory += 4;
1609 break;
1610 case RPC_FC_ALIGNM4:
1611 ALIGN_POINTER(pMemory, 3);
1612 break;
1613 case RPC_FC_ALIGNM8:
1614 ALIGN_POINTER(pMemory, 7);
1615 break;
1616 case RPC_FC_EMBEDDED_COMPLEX:
1617 pMemory += pFormat[1];
1618 pFormat += 2;
1619 desc = pFormat + *(const SHORT*)pFormat;
1620 size = EmbeddedComplexSize(pStubMsg, desc);
1621 m = NdrFreer[*desc & NDR_TABLE_MASK];
1622 if (m) m(pStubMsg, pMemory, desc);
1623 else FIXME("no freer for embedded type %02x\n", *desc);
1624 pMemory += size;
1625 pFormat += 2;
1626 continue;
1627 case RPC_FC_PAD:
1628 break;
1629 default:
1630 FIXME("unhandled format %d\n", *pFormat);
1631 }
1632 pFormat++;
1633 }
1634
1635 return pMemory;
1636 }
1637
1638 unsigned long WINAPI ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg,
1639 PFORMAT_STRING pFormat)
1640 {
1641 PFORMAT_STRING desc;
1642 unsigned long size = 0;
1643
1644 while (*pFormat != RPC_FC_END) {
1645 switch (*pFormat) {
1646 case RPC_FC_SHORT:
1647 case RPC_FC_USHORT:
1648 size += 2;
1649 break;
1650 case RPC_FC_LONG:
1651 case RPC_FC_ULONG:
1652 size += 4;
1653 break;
1654 case RPC_FC_POINTER:
1655 size += 4;
1656 break;
1657 case RPC_FC_ALIGNM4:
1658 ALIGN_LENGTH(size, 3);
1659 break;
1660 case RPC_FC_ALIGNM8:
1661 ALIGN_LENGTH(size, 7);
1662 break;
1663 case RPC_FC_EMBEDDED_COMPLEX:
1664 size += pFormat[1];
1665 pFormat += 2;
1666 desc = pFormat + *(const SHORT*)pFormat;
1667 size += EmbeddedComplexSize(pStubMsg, desc);
1668 pFormat += 2;
1669 continue;
1670 case RPC_FC_PAD:
1671 break;
1672 default:
1673 FIXME("unhandled format %d\n", *pFormat);
1674 }
1675 pFormat++;
1676 }
1677
1678 return size;
1679 }
1680
1681 /***********************************************************************
1682 * NdrComplexStructMarshall [RPCRT4.@]
1683 */
1684 unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1685 unsigned char *pMemory,
1686 PFORMAT_STRING pFormat)
1687 {
1688 PFORMAT_STRING conf_array = NULL;
1689 PFORMAT_STRING pointer_desc = NULL;
1690 unsigned char *OldMemory = pStubMsg->Memory;
1691
1692 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1693
1694 pFormat += 4;
1695 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1696 pFormat += 2;
1697 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1698 pFormat += 2;
1699
1700 pStubMsg->Memory = pMemory;
1701
1702 ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
1703
1704 if (conf_array)
1705 NdrConformantArrayMarshall(pStubMsg, pMemory, conf_array);
1706
1707 pStubMsg->Memory = OldMemory;
1708
1709 STD_OVERFLOW_CHECK(pStubMsg);
1710
1711 return NULL;
1712 }
1713
1714 /***********************************************************************
1715 * NdrComplexStructUnmarshall [RPCRT4.@]
1716 */
1717 unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1718 unsigned char **ppMemory,
1719 PFORMAT_STRING pFormat,
1720 unsigned char fMustAlloc)
1721 {
1722 unsigned size = *(const WORD*)(pFormat+2);
1723 PFORMAT_STRING conf_array = NULL;
1724 PFORMAT_STRING pointer_desc = NULL;
1725 unsigned char *pMemory;
1726
1727 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1728
1729 if (fMustAlloc || !*ppMemory)
1730 *ppMemory = NdrAllocate(pStubMsg, size);
1731
1732 pFormat += 4;
1733 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1734 pFormat += 2;
1735 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1736 pFormat += 2;
1737
1738 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
1739
1740 if (conf_array)
1741 NdrConformantArrayUnmarshall(pStubMsg, &pMemory, conf_array, fMustAlloc);
1742
1743 return NULL;
1744 }
1745
1746 /***********************************************************************
1747 * NdrComplexStructBufferSize [RPCRT4.@]
1748 */
1749 void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1750 unsigned char *pMemory,
1751 PFORMAT_STRING pFormat)
1752 {
1753 PFORMAT_STRING conf_array = NULL;
1754 PFORMAT_STRING pointer_desc = NULL;
1755 unsigned char *OldMemory = pStubMsg->Memory;
1756
1757 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1758
1759 pFormat += 4;
1760 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1761 pFormat += 2;
1762 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1763 pFormat += 2;
1764
1765 pStubMsg->Memory = pMemory;
1766
1767 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
1768
1769 if (conf_array)
1770 NdrConformantArrayBufferSize(pStubMsg, pMemory, conf_array);
1771
1772 pStubMsg->Memory = OldMemory;
1773 }
1774
1775 /***********************************************************************
1776 * NdrComplexStructMemorySize [RPCRT4.@]
1777 */
1778 unsigned long WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1779 PFORMAT_STRING pFormat)
1780 {
1781 /* unsigned size = *(LPWORD)(pFormat+2); */
1782 PFORMAT_STRING conf_array = NULL;
1783 PFORMAT_STRING pointer_desc = NULL;
1784
1785 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1786
1787 pFormat += 4;
1788 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1789 pFormat += 2;
1790 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1791 pFormat += 2;
1792
1793 return 0;
1794 }
1795
1796 /***********************************************************************
1797 * NdrComplexStructFree [RPCRT4.@]
1798 */
1799 void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg,
1800 unsigned char *pMemory,
1801 PFORMAT_STRING pFormat)
1802 {
1803 PFORMAT_STRING conf_array = NULL;
1804 PFORMAT_STRING pointer_desc = NULL;
1805 unsigned char *OldMemory = pStubMsg->Memory;
1806
1807 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1808
1809 pFormat += 4;
1810 if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
1811 pFormat += 2;
1812 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
1813 pFormat += 2;
1814
1815 pStubMsg->Memory = pMemory;
1816
1817 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
1818
1819 if (conf_array)
1820 NdrConformantArrayFree(pStubMsg, pMemory, conf_array);
1821
1822 pStubMsg->Memory = OldMemory;
1823 }
1824
1825 /***********************************************************************
1826 * NdrConformantArrayMarshall [RPCRT4.@]
1827 */
1828 unsigned char * WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1829 unsigned char *pMemory,
1830 PFORMAT_STRING pFormat)
1831 {
1832 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1833 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1834 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1835
1836 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1837 size = pStubMsg->MaxCount;
1838
1839 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
1840 pStubMsg->Buffer += 4;
1841
1842 memcpy(pStubMsg->Buffer, pMemory, size*esize);
1843 pStubMsg->BufferMark = pStubMsg->Buffer;
1844 pStubMsg->Buffer += size*esize;
1845
1846 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
1847
1848 STD_OVERFLOW_CHECK(pStubMsg);
1849
1850 return NULL;
1851 }
1852
1853 /***********************************************************************
1854 * NdrConformantArrayUnmarshall [RPCRT4.@]
1855 */
1856 unsigned char * WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1857 unsigned char **ppMemory,
1858 PFORMAT_STRING pFormat,
1859 unsigned char fMustAlloc)
1860 {
1861 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1862 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1863 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1864
1865 pFormat = ReadConformance(pStubMsg, pFormat+4);
1866 size = pStubMsg->MaxCount;
1867
1868 if (fMustAlloc) {
1869 *ppMemory = NdrAllocate(pStubMsg, size*esize);
1870 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1871 } else {
1872 if (pStubMsg->ReuseBuffer && !*ppMemory)
1873 /* for servers, we may just point straight into the RPC buffer, I think
1874 * (I guess that's what MS does since MIDL code doesn't try to free) */
1875 *ppMemory = pStubMsg->Buffer;
1876 else
1877 /* for clients, memory should be provided by caller */
1878 memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
1879 }
1880
1881 pStubMsg->BufferMark = pStubMsg->Buffer;
1882 pStubMsg->Buffer += size*esize;
1883
1884 EmbeddedPointerUnmarshall(pStubMsg, ppMemory, pFormat, fMustAlloc);
1885
1886 return NULL;
1887 }
1888
1889 /***********************************************************************
1890 * NdrConformantArrayBufferSize [RPCRT4.@]
1891 */
1892 void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
1893 unsigned char *pMemory,
1894 PFORMAT_STRING pFormat)
1895 {
1896 DWORD size = 0, esize = *(const WORD*)(pFormat+2);
1897 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1898 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1899
1900 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1901 size = pStubMsg->MaxCount;
1902
1903 pStubMsg->BufferLength += size*esize;
1904
1905 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1906 }
1907
1908 /***********************************************************************
1909 * NdrConformantArrayMemorySize [RPCRT4.@]
1910 */
1911 unsigned long WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
1912 PFORMAT_STRING pFormat)
1913 {
1914 DWORD size = 0;
1915 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
1916 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1917
1918 pFormat = ReadConformance(pStubMsg, pFormat+4);
1919 size = pStubMsg->MaxCount;
1920
1921 EmbeddedPointerMemorySize(pStubMsg, pFormat);
1922
1923 return 0;
1924 }
1925
1926 /***********************************************************************
1927 * NdrConformantArrayFree [RPCRT4.@]
1928 */
1929 void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
1930 unsigned char *pMemory,
1931 PFORMAT_STRING pFormat)
1932 {
1933 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1934 if (pFormat[0] != RPC_FC_CARRAY) FIXME("format=%d\n", pFormat[0]);
1935
1936 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
1937 }
1938
1939
1940 /***********************************************************************
1941 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
1942 */
1943 unsigned char* WINAPI NdrConformantVaryingArrayMarshall( PMIDL_STUB_MESSAGE pStubMsg,
1944 unsigned char* pMemory,
1945 PFORMAT_STRING pFormat )
1946 {
1947 FIXME( "stub\n" );
1948 return NULL;
1949 }
1950
1951
1952 /***********************************************************************
1953 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
1954 */
1955 unsigned char* WINAPI NdrConformantVaryingArrayUnmarshall( PMIDL_STUB_MESSAGE pStubMsg,
1956 unsigned char** ppMemory,
1957 PFORMAT_STRING pFormat,
1958 unsigned char fMustAlloc )
1959 {
1960 FIXME( "stub\n" );
1961 return NULL;
1962 }
1963
1964
1965 /***********************************************************************
1966 * NdrConformantVaryingArrayFree [RPCRT4.@]
1967 */
1968 void WINAPI NdrConformantVaryingArrayFree( PMIDL_STUB_MESSAGE pStubMsg,
1969 unsigned char* pMemory,
1970 PFORMAT_STRING pFormat )
1971 {
1972 FIXME( "stub\n" );
1973 }
1974
1975
1976 /***********************************************************************
1977 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
1978 */
1979 void WINAPI NdrConformantVaryingArrayBufferSize( PMIDL_STUB_MESSAGE pStubMsg,
1980 unsigned char* pMemory, PFORMAT_STRING pFormat )
1981 {
1982 FIXME( "stub\n" );
1983 }
1984
1985
1986 /***********************************************************************
1987 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
1988 */
1989 unsigned long WINAPI NdrConformantVaryingArrayMemorySize( PMIDL_STUB_MESSAGE pStubMsg,
1990 PFORMAT_STRING pFormat )
1991 {
1992 FIXME( "stub\n" );
1993 return 0;
1994 }
1995
1996
1997 /***********************************************************************
1998 * NdrComplexArrayMarshall [RPCRT4.@]
1999 */
2000 unsigned char * WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2001 unsigned char *pMemory,
2002 PFORMAT_STRING pFormat)
2003 {
2004 DWORD size = 0, count, def;
2005 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2006
2007 def = *(const WORD*)&pFormat[2];
2008 pFormat += 4;
2009
2010 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2011 size = pStubMsg->MaxCount;
2012 TRACE("conformance=%ld\n", size);
2013
2014 if (*(const DWORD*)pFormat != 0xffffffff)
2015 FIXME("compute variance\n");
2016 pFormat += 4;
2017
2018 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, size);
2019 pStubMsg->Buffer += 4;
2020
2021 for (count=0; count<size; count++)
2022 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2023
2024 STD_OVERFLOW_CHECK(pStubMsg);
2025
2026 return NULL;
2027 }
2028
2029 /***********************************************************************
2030 * NdrComplexArrayUnmarshall [RPCRT4.@]
2031 */
2032 unsigned char * WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2033 unsigned char **ppMemory,
2034 PFORMAT_STRING pFormat,
2035 unsigned char fMustAlloc)
2036 {
2037 DWORD size = 0, count, esize;
2038 unsigned char *pMemory;
2039 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2040
2041 pFormat += 4;
2042
2043 pFormat = ReadConformance(pStubMsg, pFormat);
2044 size = pStubMsg->MaxCount;
2045 TRACE("conformance=%ld\n", size);
2046
2047 pFormat += 4;
2048
2049 esize = ComplexStructSize(pStubMsg, pFormat);
2050
2051 if (fMustAlloc || !*ppMemory)
2052 *ppMemory = NdrAllocate(pStubMsg, size*esize);
2053
2054 pMemory = *ppMemory;
2055 for (count=0; count<size; count++)
2056 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2057
2058 return NULL;
2059 }
2060
2061 /***********************************************************************
2062 * NdrComplexArrayBufferSize [RPCRT4.@]
2063 */
2064 void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2065 unsigned char *pMemory,
2066 PFORMAT_STRING pFormat)
2067 {
2068 DWORD size = 0, count, def;
2069 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2070
2071 def = *(const WORD*)&pFormat[2];
2072 pFormat += 4;
2073
2074 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2075 size = pStubMsg->MaxCount;
2076 TRACE("conformance=%ld\n", size);
2077
2078 if (*(const DWORD*)pFormat != 0xffffffff)
2079 FIXME("compute variance\n");
2080 pFormat += 4;
2081
2082 for (count=0; count<size; count++)
2083 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
2084 }
2085
2086 /***********************************************************************
2087 * NdrComplexArrayMemorySize [RPCRT4.@]
2088 */
2089 unsigned long WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2090 PFORMAT_STRING pFormat)
2091 {
2092 DWORD size = 0;
2093 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2094
2095 pFormat += 4;
2096
2097 pFormat = ReadConformance(pStubMsg, pFormat);
2098 size = pStubMsg->MaxCount;
2099 TRACE("conformance=%ld\n", size);
2100
2101 pFormat += 4;
2102
2103 return 0;
2104 }
2105
2106 /***********************************************************************
2107 * NdrComplexArrayFree [RPCRT4.@]
2108 */
2109 void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2110 unsigned char *pMemory,
2111 PFORMAT_STRING pFormat)
2112 {
2113 DWORD size = 0, count, def;
2114 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2115
2116 def = *(const WORD*)&pFormat[2];
2117 pFormat += 4;
2118
2119 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2120 size = pStubMsg->MaxCount;
2121 TRACE("conformance=%ld\n", size);
2122
2123 if (*(const DWORD*)pFormat != 0xffffffff)
2124 FIXME("compute variance\n");
2125 pFormat += 4;
2126
2127 for (count=0; count<size; count++)
2128 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2129 }
2130
2131 unsigned long UserMarshalFlags(PMIDL_STUB_MESSAGE pStubMsg)
2132 {
2133 return MAKELONG(pStubMsg->dwDestContext,
2134 pStubMsg->RpcMsg->DataRepresentation);
2135 }
2136
2137 /***********************************************************************
2138 * NdrUserMarshalMarshall [RPCRT4.@]
2139 */
2140 unsigned char * WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2141 unsigned char *pMemory,
2142 PFORMAT_STRING pFormat)
2143 {
2144 /* unsigned flags = pFormat[1]; */
2145 unsigned index = *(const WORD*)&pFormat[2];
2146 unsigned long uflag = UserMarshalFlags(pStubMsg);
2147 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2148 TRACE("index=%d\n", index);
2149
2150 pStubMsg->Buffer =
2151 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
2152 &uflag, pStubMsg->Buffer, pMemory);
2153
2154 STD_OVERFLOW_CHECK(pStubMsg);
2155
2156 return NULL;
2157 }
2158
2159 /***********************************************************************
2160 * NdrUserMarshalUnmarshall [RPCRT4.@]
2161 */
2162 unsigned char * WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2163 unsigned char **ppMemory,
2164 PFORMAT_STRING pFormat,
2165 unsigned char fMustAlloc)
2166 {
2167 /* unsigned flags = pFormat[1];*/
2168 unsigned index = *(const WORD*)&pFormat[2];
2169 DWORD memsize = *(const WORD*)&pFormat[4];
2170 unsigned long uflag = UserMarshalFlags(pStubMsg);
2171 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
2172 TRACE("index=%d\n", index);
2173
2174 if (fMustAlloc || !*ppMemory)
2175 *ppMemory = NdrAllocate(pStubMsg, memsize);
2176
2177 pStubMsg->Buffer =
2178 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
2179 &uflag, pStubMsg->Buffer, *ppMemory);
2180
2181 return NULL;
2182 }
2183
2184 /***********************************************************************
2185 * NdrUserMarshalBufferSize [RPCRT4.@]
2186 */
2187 void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2188 unsigned char *pMemory,
2189 PFORMAT_STRING pFormat)
2190 {
2191 /* unsigned flags = pFormat[1];*/
2192 unsigned index = *(const WORD*)&pFormat[2];
2193 DWORD bufsize = *(const WORD*)&pFormat[6];
2194 unsigned long uflag = UserMarshalFlags(pStubMsg);
2195 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2196 TRACE("index=%d\n", index);
2197
2198 if (bufsize) {
2199 TRACE("size=%ld\n", bufsize);
2200 pStubMsg->BufferLength += bufsize;
2201 return;
2202 }
2203
2204 pStubMsg->BufferLength =
2205 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
2206 &uflag, pStubMsg->BufferLength, pMemory);
2207 }
2208
2209 /***********************************************************************
2210 * NdrUserMarshalMemorySize [RPCRT4.@]
2211 */
2212 unsigned long WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2213 PFORMAT_STRING pFormat)
2214 {
2215 unsigned index = *(const WORD*)&pFormat[2];
2216 /* DWORD memsize = *(const WORD*)&pFormat[4]; */
2217 FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
2218 TRACE("index=%d\n", index);
2219
2220 return 0;
2221 }
2222
2223 /***********************************************************************
2224 * NdrUserMarshalFree [RPCRT4.@]
2225 */
2226 void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg,
2227 unsigned char *pMemory,
2228 PFORMAT_STRING pFormat)
2229 {
2230 /* unsigned flags = pFormat[1]; */
2231 unsigned index = *(const WORD*)&pFormat[2];
2232 unsigned long uflag = UserMarshalFlags(pStubMsg);
2233 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
2234 TRACE("index=%d\n", index);
2235
2236 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
2237 &uflag, pMemory);
2238 }
2239
2240 /***********************************************************************
2241 * NdrClearOutParameters [RPCRT4.@]
2242 */
2243 void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg,
2244 PFORMAT_STRING pFormat,
2245 void *ArgAddr)
2246 {
2247 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
2248 }
2249
2250 /***********************************************************************
2251 * NdrConvert [RPCRT4.@]
2252 */
2253 void WINAPI NdrConvert( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat )
2254 {
2255 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
2256 /* FIXME: since this stub doesn't do any converting, the proper behavior
2257 is to raise an exception */
2258 }
2259
2260 /***********************************************************************
2261 * NdrConvert2 [RPCRT4.@]
2262 */
2263 void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, long NumberParams )
2264 {
2265 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
2266 pStubMsg, pFormat, NumberParams);
2267 /* FIXME: since this stub doesn't do any converting, the proper behavior
2268 is to raise an exception */
2269 }
2270
2271 /***********************************************************************
2272 * NdrConformantStructMarshall [RPCRT4.@]
2273 */
2274 unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2275 unsigned char *pMemory,
2276 PFORMAT_STRING pFormat)
2277 {
2278 FIXME("stub\n");
2279 return NULL;
2280 }
2281
2282 /***********************************************************************
2283 * NdrConformantStructUnmarshall [RPCRT4.@]
2284 */
2285 unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2286 unsigned char **ppMemory,
2287 PFORMAT_STRING pFormat,
2288 unsigned char fMustAlloc)
2289 {
2290 FIXME("stub\n");
2291 return NULL;
2292 }
2293
2294 /***********************************************************************
2295 * NdrConformantStructBufferSize [RPCRT4.@]
2296 */
2297 void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2298 unsigned char *pMemory,
2299 PFORMAT_STRING pFormat)
2300 {
2301 FIXME("stub\n");
2302 }
2303
2304 /***********************************************************************
2305 * NdrConformantStructMemorySize [RPCRT4.@]
2306 */
2307 unsigned long WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2308 PFORMAT_STRING pFormat)
2309 {
2310 FIXME("stub\n");
2311 return 0;
2312 }
2313
2314 /***********************************************************************
2315 * NdrConformantStructFree [RPCRT4.@]
2316 */
2317 void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2318 unsigned char *pMemory,
2319 PFORMAT_STRING pFormat)
2320 {
2321 FIXME("stub\n");
2322 }
2323
2324 /***********************************************************************
2325 * NdrConformantVaryingStructMarshall [RPCRT4.@]
2326 */
2327 unsigned char * WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2328 unsigned char *pMemory,
2329 PFORMAT_STRING pFormat)
2330 {
2331 FIXME("stub\n");
2332 return NULL;
2333 }
2334
2335 /***********************************************************************
2336 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
2337 */
2338 unsigned char * WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2339 unsigned char **ppMemory,
2340 PFORMAT_STRING pFormat,
2341 unsigned char fMustAlloc)
2342 {
2343 FIXME("stub\n");
2344 return NULL;
2345 }
2346
2347 /***********************************************************************
2348 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
2349 */
2350 void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2351 unsigned char *pMemory,
2352 PFORMAT_STRING pFormat)
2353 {
2354 FIXME("stub\n");
2355 }
2356
2357 /***********************************************************************
2358 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
2359 */
2360 unsigned long WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2361 PFORMAT_STRING pFormat)
2362 {
2363 FIXME("stub\n");
2364 return 0;
2365 }
2366
2367 /***********************************************************************
2368 * NdrConformantVaryingStructFree [RPCRT4.@]
2369 */
2370 void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg,
2371 unsigned char *pMemory,
2372 PFORMAT_STRING pFormat)
2373 {
2374 FIXME("stub\n");
2375 }
2376
2377 /***********************************************************************
2378 * NdrFixedArrayMarshall [RPCRT4.@]
2379 */
2380 unsigned char * WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2381 unsigned char *pMemory,
2382 PFORMAT_STRING pFormat)
2383 {
2384 FIXME("stub\n");
2385 return NULL;
2386 }
2387
2388 /***********************************************************************
2389 * NdrFixedArrayUnmarshall [RPCRT4.@]
2390 */
2391 unsigned char * WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2392 unsigned char **ppMemory,
2393 PFORMAT_STRING pFormat,
2394 unsigned char fMustAlloc)
2395 {
2396 FIXME("stub\n");
2397 return NULL;
2398 }
2399
2400 /***********************************************************************
2401 * NdrFixedArrayBufferSize [RPCRT4.@]
2402 */
2403 void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2404 unsigned char *pMemory,
2405 PFORMAT_STRING pFormat)
2406 {
2407 FIXME("stub\n");
2408 }
2409
2410 /***********************************************************************
2411 * NdrFixedArrayMemorySize [RPCRT4.@]
2412 */
2413 unsigned long WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2414 PFORMAT_STRING pFormat)
2415 {
2416 FIXME("stub\n");
2417 return 0;
2418 }
2419
2420 /***********************************************************************
2421 * NdrFixedArrayFree [RPCRT4.@]
2422 */
2423 void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2424 unsigned char *pMemory,
2425 PFORMAT_STRING pFormat)
2426 {
2427 FIXME("stub\n");
2428 }
2429
2430 /***********************************************************************
2431 * NdrVaryingArrayMarshall [RPCRT4.@]
2432 */
2433 unsigned char * WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2434 unsigned char *pMemory,
2435 PFORMAT_STRING pFormat)
2436 {
2437 FIXME("stub\n");
2438 return NULL;
2439 }
2440
2441 /***********************************************************************
2442 * NdrVaryingArrayUnmarshall [RPCRT4.@]
2443 */
2444 unsigned char * WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2445 unsigned char **ppMemory,
2446 PFORMAT_STRING pFormat,
2447 unsigned char fMustAlloc)
2448 {
2449 FIXME("stub\n");
2450 return NULL;
2451 }
2452
2453 /***********************************************************************
2454 * NdrVaryingArrayBufferSize [RPCRT4.@]
2455 */
2456 void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2457 unsigned char *pMemory,
2458 PFORMAT_STRING pFormat)
2459 {
2460 FIXME("stub\n");
2461 }
2462
2463 /***********************************************************************
2464 * NdrVaryingArrayMemorySize [RPCRT4.@]
2465 */
2466 unsigned long WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2467 PFORMAT_STRING pFormat)
2468 {
2469 FIXME("stub\n");
2470 return 0;
2471 }
2472
2473 /***********************************************************************
2474 * NdrVaryingArrayFree [RPCRT4.@]
2475 */
2476 void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg,
2477 unsigned char *pMemory,
2478 PFORMAT_STRING pFormat)
2479 {
2480 FIXME("stub\n");
2481 }
2482
2483 /***********************************************************************
2484 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
2485 */
2486 unsigned char * WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2487 unsigned char *pMemory,
2488 PFORMAT_STRING pFormat)
2489 {
2490 FIXME("stub\n");
2491 return NULL;
2492 }
2493
2494 /***********************************************************************
2495 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
2496 */
2497 unsigned char * WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2498 unsigned char **ppMemory,
2499 PFORMAT_STRING pFormat,
2500 unsigned char fMustAlloc)
2501 {
2502 FIXME("stub\n");
2503 return NULL;
2504 }
2505
2506 /***********************************************************************
2507 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
2508 */
2509 void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2510 unsigned char *pMemory,
2511 PFORMAT_STRING pFormat)
2512 {
2513 FIXME("stub\n");
2514 }
2515
2516 /***********************************************************************
2517 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
2518 */
2519 unsigned long WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2520 PFORMAT_STRING pFormat)
2521 {
2522 FIXME("stub\n");
2523 return 0;
2524 }
2525
2526 /***********************************************************************
2527 * NdrEncapsulatedUnionFree [RPCRT4.@]
2528 */
2529 void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2530 unsigned char *pMemory,
2531 PFORMAT_STRING pFormat)
2532 {
2533 FIXME("stub\n");
2534 }
2535
2536 /***********************************************************************
2537 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
2538 */
2539 unsigned char * WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2540 unsigned char *pMemory,
2541 PFORMAT_STRING pFormat)
2542 {
2543 FIXME("stub\n");
2544 return NULL;
2545 }
2546
2547 /***********************************************************************
2548 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
2549 */
2550 unsigned char * WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2551 unsigned char **ppMemory,
2552 PFORMAT_STRING pFormat,
2553 unsigned char fMustAlloc)
2554 {
2555 FIXME("stub\n");
2556 return NULL;
2557 }
2558
2559 /***********************************************************************
2560 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
2561 */
2562 void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2563 unsigned char *pMemory,
2564 PFORMAT_STRING pFormat)
2565 {
2566 FIXME("stub\n");
2567 }
2568
2569 /***********************************************************************
2570 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
2571 */
2572 unsigned long WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2573 PFORMAT_STRING pFormat)
2574 {
2575 FIXME("stub\n");
2576 return 0;
2577 }
2578
2579 /***********************************************************************
2580 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
2581 */
2582 void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg,
2583 unsigned char *pMemory,
2584 PFORMAT_STRING pFormat)
2585 {
2586 FIXME("stub\n");
2587 }
2588
2589 /***********************************************************************
2590 * NdrByteCountPointerMarshall [RPCRT4.@]
2591 */
2592 unsigned char * WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2593 unsigned char *pMemory,
2594 PFORMAT_STRING pFormat)
2595 {
2596 FIXME("stub\n");
2597 return NULL;
2598 }
2599
2600 /***********************************************************************
2601 * NdrByteCountPointerUnmarshall [RPCRT4.@]
2602 */
2603 unsigned char * WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2604 unsigned char **ppMemory,
2605 PFORMAT_STRING pFormat,
2606 unsigned char fMustAlloc)
2607 {
2608 FIXME("stub\n");
2609 return NULL;
2610 }
2611
2612 /***********************************************************************
2613 * NdrByteCountPointerBufferSize [RPCRT4.@]
2614 */
2615 void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2616 unsigned char *pMemory,
2617 PFORMAT_STRING pFormat)
2618 {
2619 FIXME("stub\n");
2620 }
2621
2622 /***********************************************************************
2623 * NdrByteCountPointerMemorySize [RPCRT4.@]
2624 */
2625 unsigned long WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2626 PFORMAT_STRING pFormat)
2627 {
2628 FIXME("stub\n");
2629 return 0;
2630 }
2631
2632 /***********************************************************************
2633 * NdrByteCountPointerFree [RPCRT4.@]
2634 */
2635 void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg,
2636 unsigned char *pMemory,
2637 PFORMAT_STRING pFormat)
2638 {
2639 FIXME("stub\n");
2640 }
2641
2642 /***********************************************************************
2643 * NdrXmitOrRepAsMarshall [RPCRT4.@]
2644 */
2645 unsigned char * WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2646 unsigned char *pMemory,
2647 PFORMAT_STRING pFormat)
2648 {
2649 FIXME("stub\n");
2650 return NULL;
2651 }
2652
2653 /***********************************************************************
2654 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
2655 */
2656 unsigned char * WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2657 unsigned char **ppMemory,
2658 PFORMAT_STRING pFormat,
2659 unsigned char fMustAlloc)
2660 {
2661 FIXME("stub\n");
2662 return NULL;
2663 }
2664
2665 /***********************************************************************
2666 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
2667 */
2668 void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
2669 unsigned char *pMemory,
2670 PFORMAT_STRING pFormat)
2671 {
2672 FIXME("stub\n");
2673 }
2674
2675 /***********************************************************************
2676 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
2677 */
2678 unsigned long WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg,
2679 PFORMAT_STRING pFormat)
2680 {
2681 FIXME("stub\n");
2682 return 0;
2683 }
2684
2685 /***********************************************************************
2686 * NdrXmitOrRepAsFree [RPCRT4.@]
2687 */
2688 void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg,
2689 unsigned char *pMemory,
2690 PFORMAT_STRING pFormat)
2691 {
2692 FIXME("stub\n");
2693 }
2694
2695 /***********************************************************************
2696 * NdrClientContextMarshall
2697 */
2698 void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2699 NDR_CCONTEXT ContextHandle,
2700 int fCheck)
2701 {
2702 FIXME("(%p, %p, %d): stub\n", pStubMsg, ContextHandle, fCheck);
2703 }
2704
2705 /***********************************************************************
2706 * NdrClientContextUnmarshall
2707 */
2708 void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2709 NDR_CCONTEXT * pContextHandle,
2710 RPC_BINDING_HANDLE BindHandle)
2711 {
2712 FIXME("(%p, %p, %p): stub\n", pStubMsg, pContextHandle, BindHandle);
2713 }
2714
2715 void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2716 NDR_SCONTEXT ContextHandle,
2717 NDR_RUNDOWN RundownRoutine )
2718 {
2719 FIXME("(%p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine);
2720 }
2721
2722 NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
2723 {
2724 FIXME("(%p): stub\n", pStubMsg);
2725 return NULL;
2726 }
2727
2728 void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg,
2729 unsigned char* pMemory,
2730 PFORMAT_STRING pFormat)
2731 {
2732 FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
2733 }
2734
2735 NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg,
2736 PFORMAT_STRING pFormat)
2737 {
2738 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2739 return NULL;
2740 }
2741
2742 void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2743 NDR_SCONTEXT ContextHandle,
2744 NDR_RUNDOWN RundownRoutine,
2745 PFORMAT_STRING pFormat)
2746 {
2747 FIXME("(%p, %p, %p, %p): stub\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
2748 }
2749
2750 NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
2751 PFORMAT_STRING pFormat)
2752 {
2753 FIXME("(%p, %p): stub\n", pStubMsg, pFormat);
2754 return NULL;
2755 }
2756
2757 RPC_BINDING_HANDLE WINAPI NDRCContextBinding(NDR_CCONTEXT CContext)
2758 {
2759 FIXME("(%p): stub\n", CContext);
2760 return NULL;
2761 }