ReactOS 0.4.16-dev-1946-g52006dd
ndr_marshall.c
Go to the documentation of this file.
1/*
2 * NDR data marshalling
3 *
4 * Copyright 2002 Greg Turner
5 * Copyright 2003-2006 CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * TODO:
22 * - String structs
23 * - Byte count pointers
24 * - transmit_as/represent as
25 * - Multi-dimensional arrays
26 * - Conversion functions (NdrConvert)
27 * - Checks for integer addition overflow in user marshall functions
28 */
29
30#include <assert.h>
31#include <stdarg.h>
32#include <stdio.h>
33#include <string.h>
34#include <limits.h>
35
36#include "windef.h"
37#include "winbase.h"
38#include "winerror.h"
39
40#include "ndr_misc.h"
41#include "rpcndr.h"
42#include "ndrtypes.h"
43
44#include "wine/debug.h"
45
47
48#if defined(__i386__)
49# define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
50 (*((UINT32 *)(pchar)) = (uint32))
51
52# define LITTLE_ENDIAN_UINT32_READ(pchar) \
53 (*((UINT32 *)(pchar)))
54#else
55 /* these would work for i386 too, but less efficient */
56# define LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32) \
57 (*(pchar) = LOBYTE(LOWORD(uint32)), \
58 *((pchar)+1) = HIBYTE(LOWORD(uint32)), \
59 *((pchar)+2) = LOBYTE(HIWORD(uint32)), \
60 *((pchar)+3) = HIBYTE(HIWORD(uint32)))
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
74#define BIG_ENDIAN_UINT32_READ(pchar) \
75 (MAKELONG( \
76 MAKEWORD(*((pchar)+3), *((pchar)+2)), \
77 MAKEWORD(*((pchar)+1), *(pchar))))
78
79#ifdef NDR_LOCAL_IS_BIG_ENDIAN
80# define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
81 BIG_ENDIAN_UINT32_WRITE(pchar, uint32)
82# define NDR_LOCAL_UINT32_READ(pchar) \
83 BIG_ENDIAN_UINT32_READ(pchar)
84#else
85# define NDR_LOCAL_UINT32_WRITE(pchar, uint32) \
86 LITTLE_ENDIAN_UINT32_WRITE(pchar, uint32)
87# define NDR_LOCAL_UINT32_READ(pchar) \
88 LITTLE_ENDIAN_UINT32_READ(pchar)
89#endif
90
91static inline void align_length( ULONG *len, unsigned int align )
92{
93 *len = (*len + align - 1) & ~(align - 1);
94}
95
96static inline void align_pointer( unsigned char **ptr, unsigned int align )
97{
98 ULONG_PTR mask = align - 1;
99 *ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
100}
101
102static inline void align_pointer_clear( unsigned char **ptr, unsigned int align )
103{
104 ULONG_PTR mask = align - 1;
105 memset( *ptr, 0, (align - (ULONG_PTR)*ptr) & mask );
106 *ptr = (unsigned char *)(((ULONG_PTR)*ptr + mask) & ~mask);
107}
108
109static inline void align_pointer_offset( unsigned char **ptr, unsigned char *base, unsigned int align )
110{
111 ULONG_PTR mask = align - 1;
112 *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
113}
114
115static inline void align_pointer_offset_clear( unsigned char **ptr, unsigned char *base, unsigned int align )
116{
117 ULONG_PTR mask = align - 1;
118 memset( *ptr, 0, (align - (ULONG_PTR)(*ptr - base)) & mask );
119 *ptr = base + (((ULONG_PTR)(*ptr - base) + mask) & ~mask);
120}
121
122#define STD_OVERFLOW_CHECK(_Msg) do { \
123 TRACE("buffer=%Id/%ld\n", _Msg->Buffer - (unsigned char *)_Msg->RpcMsg->Buffer, _Msg->BufferLength); \
124 if (_Msg->Buffer > (unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength) \
125 ERR("buffer overflow %Id bytes\n", _Msg->Buffer - ((unsigned char *)_Msg->RpcMsg->Buffer + _Msg->BufferLength)); \
126 } while (0)
127
128#define NDR_POINTER_ID_BASE 0x20000
129#define NDR_POINTER_ID(pStubMsg) (NDR_POINTER_ID_BASE + ((pStubMsg)->UniquePtrCount++) * 4)
130#define NDR_TABLE_SIZE 128
131#define NDR_TABLE_MASK 127
132
133static unsigned char *WINAPI NdrBaseTypeMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
134static unsigned char *WINAPI NdrBaseTypeUnmarshall(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char);
136static void WINAPI NdrBaseTypeFree(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
138
139static unsigned char *WINAPI NdrContextHandleMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
141static unsigned char *WINAPI NdrContextHandleUnmarshall(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char);
142
143static unsigned char *WINAPI NdrRangeMarshall(PMIDL_STUB_MESSAGE,unsigned char *, PFORMAT_STRING);
144static void WINAPI NdrRangeBufferSize(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
146static void WINAPI NdrRangeFree(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING);
147
149
150static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
151 unsigned char *pMemory,
152 PFORMAT_STRING pFormat,
153 PFORMAT_STRING pPointer);
154static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
155 unsigned char *pMemory,
156 PFORMAT_STRING pFormat,
157 PFORMAT_STRING pPointer);
158static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
159 unsigned char *pMemory,
160 PFORMAT_STRING pFormat,
161 PFORMAT_STRING pPointer,
162 unsigned char fMustAlloc);
164 PFORMAT_STRING pFormat,
165 PFORMAT_STRING pPointer);
166static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
167 unsigned char *pMemory,
168 PFORMAT_STRING pFormat,
169 PFORMAT_STRING pPointer);
170
172 0,
177 /* 0x10 */
179 /* 0x11 */
182 /* 0x15 */
187 /* 0x1b */
193 /* 0x22 */
197 /* 0x2a */
202 /* 0x2f */
204 /* 0x30 */
206 /* 0xb1 */
207 0, 0, 0,
209 0, 0,
210 /* 0xb7 */
214};
216 0,
221 /* 0x10 */
223 /* 0x11 */
226 /* 0x15 */
231 /* 0x1b */
237 /* 0x22 */
241 /* 0x2a */
246 /* 0x2f */
248 /* 0x30 */
250 /* 0xb1 */
251 0, 0, 0,
253 0, 0,
254 /* 0xb7 */
258};
260 0,
265 /* 0x10 */
267 /* 0x11 */
270 /* 0x15 */
275 /* 0x1b */
281 /* 0x22 */
285 /* 0x2a */
290 /* 0x2f */
292 /* 0x30 */
294 /* 0xb1 */
295 0, 0, 0,
297 0, 0,
298 /* 0xb7 */
302};
304 0,
309 /* 0x10 */
311 /* 0x11 */
314 /* 0x15 */
319 /* 0x1b */
325 /* 0x22 */
329 /* 0x2a */
334 /* 0x2f */
336 /* 0x30 */
337 0,
338 /* 0xb1 */
339 0, 0, 0,
341 0, 0,
342 /* 0xb7 */
346};
348 0,
353 /* 0x10 */
355 /* 0x11 */
358 /* 0x15 */
363 /* 0x1b */
369 /* 0x22 */
370 0, 0, 0,
371 0, 0, 0, 0, 0,
372 /* 0x2a */
375 0,
377 /* 0x2f */
379 /* 0x30 */
380 0,
381 /* 0xb1 */
382 0, 0, 0,
384 0, 0,
385 /* 0xb7 */
389};
390
391typedef struct _NDR_MEMORY_LIST
392{
398
399#define MEML_MAGIC ('M' << 24 | 'E' << 16 | 'M' << 8 | 'L')
400
401/***********************************************************************
402 * NdrAllocate [RPCRT4.@]
403 *
404 * Allocates a block of memory using pStubMsg->pfnAllocate.
405 *
406 * PARAMS
407 * pStubMsg [I/O] MIDL_STUB_MESSAGE structure.
408 * len [I] Size of memory block to allocate.
409 *
410 * RETURNS
411 * The memory block of size len that was allocated.
412 *
413 * NOTES
414 * The memory block is always 8-byte aligned.
415 * If the function is unable to allocate memory an RPC_X_NO_MEMORY
416 * exception is raised.
417 */
419{
420 SIZE_T aligned_len;
421 SIZE_T adjusted_len;
422 void *p;
423 NDR_MEMORY_LIST *mem_list;
424
425 aligned_len = (len + 7) & ~7;
426 adjusted_len = aligned_len + sizeof(NDR_MEMORY_LIST);
427 /* check for overflow */
428 if (adjusted_len < len)
429 {
430 ERR("overflow of adjusted_len %Id, len %Id\n", adjusted_len, len);
432 }
433
434 p = pStubMsg->pfnAllocate(adjusted_len);
436
437 mem_list = (NDR_MEMORY_LIST *)((char *)p + aligned_len);
438 mem_list->magic = MEML_MAGIC;
439 mem_list->size = aligned_len;
440 mem_list->reserved = 0;
441 mem_list->next = pStubMsg->pMemoryList;
442 pStubMsg->pMemoryList = mem_list;
443
444 TRACE("-- %p\n", p);
445 return p;
446}
447
449{
450 void *mem = NdrAllocate(stubmsg, len);
451 memset(mem, 0, len);
452 return mem;
453}
454
455static void NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
456{
457 TRACE("(%p, %p)\n", pStubMsg, Pointer);
458
459 pStubMsg->pfnFree(Pointer);
460}
461
463{
464 return (*(const ULONG *)pFormat != -1);
465}
466
467static inline PFORMAT_STRING SkipConformance(const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
468{
469 return pFormat + 4 + pStubMsg->CorrDespIncrement;
470}
471
473{
474 align_pointer(&pStubMsg->Buffer, 4);
475 if (pStubMsg->Buffer + 4 > pStubMsg->BufferEnd)
477 pStubMsg->MaxCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
478 pStubMsg->Buffer += 4;
479 TRACE("unmarshalled conformance is %Id\n", pStubMsg->MaxCount);
480 return SkipConformance(pStubMsg, pFormat);
481}
482
483static inline PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, ULONG MaxValue)
484{
485 if (pFormat && !IsConformanceOrVariancePresent(pFormat))
486 {
487 pStubMsg->Offset = 0;
488 pStubMsg->ActualCount = pStubMsg->MaxCount;
489 goto done;
490 }
491
492 align_pointer(&pStubMsg->Buffer, 4);
493 if (pStubMsg->Buffer + 8 > pStubMsg->BufferEnd)
495 pStubMsg->Offset = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
496 pStubMsg->Buffer += 4;
497 TRACE("offset is %ld\n", pStubMsg->Offset);
498 pStubMsg->ActualCount = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
499 pStubMsg->Buffer += 4;
500 TRACE("variance is %ld\n", pStubMsg->ActualCount);
501
502 if ((pStubMsg->ActualCount > MaxValue) ||
503 (pStubMsg->ActualCount + pStubMsg->Offset > MaxValue))
504 {
505 ERR("invalid array bound(s): ActualCount = %ld, Offset = %ld, MaxValue = %ld\n",
506 pStubMsg->ActualCount, pStubMsg->Offset, MaxValue);
508 return NULL;
509 }
510
511done:
512 return SkipConformance(pStubMsg, pFormat);
513}
514
515/* writes the conformance value to the buffer */
516static inline void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
517{
518 align_pointer_clear(&pStubMsg->Buffer, 4);
519 if (pStubMsg->Buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
521 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->MaxCount);
522 pStubMsg->Buffer += 4;
523}
524
525/* writes the variance values to the buffer */
526static inline void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
527{
528 align_pointer_clear(&pStubMsg->Buffer, 4);
529 if (pStubMsg->Buffer + 8 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
531 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->Offset);
532 pStubMsg->Buffer += 4;
533 NDR_LOCAL_UINT32_WRITE(pStubMsg->Buffer, pStubMsg->ActualCount);
534 pStubMsg->Buffer += 4;
535}
536
537/* requests buffer space for the conformance value */
538static inline void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
539{
540 align_length(&pStubMsg->BufferLength, 4);
541 if (pStubMsg->BufferLength + 4 < pStubMsg->BufferLength)
543 pStubMsg->BufferLength += 4;
544}
545
546/* requests buffer space for the variance values */
547static inline void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
548{
549 align_length(&pStubMsg->BufferLength, 4);
550 if (pStubMsg->BufferLength + 8 < pStubMsg->BufferLength)
552 pStubMsg->BufferLength += 8;
553}
554
556 MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory,
557 PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount)
558{
559 BYTE dtype = pFormat[0] & 0xf;
560 short ofs = *(const short *)&pFormat[2];
561 LPVOID ptr = NULL;
562 ULONG_PTR data = 0;
563
564 if (!IsConformanceOrVariancePresent(pFormat)) {
565 /* null descriptor */
566 *pCount = def;
567 goto finish_conf;
568 }
569
570 switch (pFormat[0] & 0xf0) {
572 TRACE("normal conformance, ofs=%d\n", ofs);
573 ptr = pMemory;
574 break;
576 TRACE("pointer conformance, ofs=%d\n", ofs);
577 ptr = pStubMsg->Memory;
578 break;
580 TRACE("toplevel conformance, ofs=%d\n", ofs);
581 if (pStubMsg->StackTop) {
582 ptr = pStubMsg->StackTop;
583 }
584 else {
585 /* -Os mode, *pCount is already set */
586 goto finish_conf;
587 }
588 break;
590 data = ofs | ((DWORD)pFormat[1] << 16);
591 TRACE("constant conformance, val=%Id\n", data);
592 *pCount = data;
593 goto finish_conf;
595 FIXME("toplevel multidimensional conformance, ofs=%d\n", ofs);
596 if (pStubMsg->StackTop) {
597 ptr = pStubMsg->StackTop;
598 }
599 else {
600 /* ? */
601 goto done_conf_grab;
602 }
603 break;
604 default:
605 FIXME("unknown conformance type %x, expect crash.\n", pFormat[0] & 0xf0);
606 goto finish_conf;
607 }
608
609 switch (pFormat[1]) {
610 case FC_DEREFERENCE:
611 ptr = *(LPVOID*)((char *)ptr + ofs);
612 break;
613 case FC_CALLBACK:
614 {
615 unsigned char *old_stack_top = pStubMsg->StackTop;
616 ULONG_PTR max_count, old_max_count = pStubMsg->MaxCount;
617
618 pStubMsg->StackTop = ptr;
619
620 /* ofs is index into StubDesc->apfnExprEval */
621 TRACE("callback conformance into apfnExprEval[%d]\n", ofs);
622 pStubMsg->StubDesc->apfnExprEval[ofs](pStubMsg);
623
624 pStubMsg->StackTop = old_stack_top;
625
626 /* the callback function always stores the computed value in MaxCount */
627 max_count = pStubMsg->MaxCount;
628 pStubMsg->MaxCount = old_max_count;
629 *pCount = max_count;
630 goto finish_conf;
631 }
632 default:
633 ptr = (char *)ptr + ofs;
634 break;
635 }
636
637 switch (dtype) {
638 case FC_LONG:
639 case FC_ULONG:
640 data = *(DWORD*)ptr;
641 break;
642 case FC_SHORT:
643 data = *(SHORT*)ptr;
644 break;
645 case FC_USHORT:
646 data = *(USHORT*)ptr;
647 break;
648 case FC_CHAR:
649 case FC_SMALL:
650 data = *(CHAR*)ptr;
651 break;
652 case FC_BYTE:
653 case FC_USMALL:
654 data = *(UCHAR*)ptr;
655 break;
656 case FC_HYPER:
657 data = *(ULONGLONG *)ptr;
658 break;
659 default:
660 FIXME("unknown conformance data type %x\n", dtype);
661 goto done_conf_grab;
662 }
663 TRACE("dereferenced data type %x at %p, got %Id\n", dtype, ptr, data);
664
665done_conf_grab:
666 switch (pFormat[1]) {
667 case FC_DEREFERENCE: /* already handled */
668 case 0: /* no op */
669 *pCount = data;
670 break;
671 case FC_ADD_1:
672 *pCount = data + 1;
673 break;
674 case FC_SUB_1:
675 *pCount = data - 1;
676 break;
677 case FC_MULT_2:
678 *pCount = data * 2;
679 break;
680 case FC_DIV_2:
681 *pCount = data / 2;
682 break;
683 default:
684 FIXME("unknown conformance op %d\n", pFormat[1]);
685 goto finish_conf;
686 }
687
688finish_conf:
689 TRACE("resulting conformance is %Id\n", *pCount);
690
691 return SkipConformance(pStubMsg, pFormat);
692}
693
695{
696 return SkipConformance( pStubMsg, pFormat );
697}
698
699/* multiply two numbers together, raising an RPC_S_INVALID_BOUND exception if
700 * the result overflows 32-bits */
702{
704 if (ret > 0xffffffff)
705 {
707 return 0;
708 }
709 return ret;
710}
711
712static inline void safe_buffer_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
713{
714 if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
715 (pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength))
717 pStubMsg->Buffer += size;
718}
719
721{
722 if (pStubMsg->BufferLength + size < pStubMsg->BufferLength) /* integer overflow of pStubMsg->BufferSize */
723 {
724 ERR("buffer length overflow - BufferLength = %lu, size = %lu\n",
725 pStubMsg->BufferLength, size);
727 }
728 pStubMsg->BufferLength += size;
729}
730
731/* copies data from the buffer, checking that there is enough data in the buffer
732 * to do so */
733static inline void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size)
734{
735 if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
736 (pStubMsg->Buffer + size > pStubMsg->BufferEnd))
737 {
738 ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %lu\n",
739 pStubMsg->Buffer, pStubMsg->BufferEnd, size);
741 }
742 if (p == pStubMsg->Buffer)
743 ERR("pointer is the same as the buffer\n");
744 memcpy(p, pStubMsg->Buffer, size);
745 pStubMsg->Buffer += size;
746}
747
748/* copies data to the buffer, checking that there is enough space to do so */
749static inline void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size)
750{
751 if ((pStubMsg->Buffer + size < pStubMsg->Buffer) || /* integer overflow of pStubMsg->Buffer */
752 (pStubMsg->Buffer + size > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength))
753 {
754 ERR("buffer overflow - Buffer = %p, BufferEnd = %p, size = %lu\n",
755 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength,
756 size);
758 }
759 memcpy(pStubMsg->Buffer, p, size);
760 pStubMsg->Buffer += size;
761}
762
763/* verify that string data sitting in the buffer is valid and safe to
764 * unmarshall */
766{
767 ULONG i;
768
769 /* verify the buffer is safe to access */
770 if ((pStubMsg->Buffer + bufsize < pStubMsg->Buffer) ||
771 (pStubMsg->Buffer + bufsize > pStubMsg->BufferEnd))
772 {
773 ERR("bufsize 0x%lx exceeded buffer end %p of buffer %p\n", bufsize,
774 pStubMsg->BufferEnd, pStubMsg->Buffer);
776 }
777
778 /* strings must always have null terminating bytes */
779 if (bufsize < esize)
780 {
781 ERR("invalid string length of %ld\n", bufsize / esize);
783 }
784
785 for (i = bufsize - esize; i < bufsize; i++)
786 if (pStubMsg->Buffer[i] != 0)
787 {
788 ERR("string not null-terminated at byte position %ld, data is 0x%x\n",
789 i, pStubMsg->Buffer[i]);
791 }
792}
793
794static inline void dump_pointer_attr(unsigned char attr)
795{
797 TRACE(" FC_ALLOCATE_ALL_NODES");
798 if (attr & FC_DONT_FREE)
799 TRACE(" FC_DONT_FREE");
801 TRACE(" FC_ALLOCED_ON_STACK");
803 TRACE(" FC_SIMPLE_POINTER");
805 TRACE(" FC_POINTER_DEREF");
806 TRACE("\n");
807}
808
809/***********************************************************************
810 * PointerMarshall [internal]
811 */
813 unsigned char *Buffer,
814 unsigned char *Pointer,
815 PFORMAT_STRING pFormat)
816{
817 unsigned type = pFormat[0], attr = pFormat[1];
820 ULONG pointer_id;
821 BOOL pointer_needs_marshaling;
822
823 TRACE("(%p,%p,%p,%p)\n", pStubMsg, Buffer, Pointer, pFormat);
824 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
825 pFormat += 2;
826 if (attr & FC_SIMPLE_POINTER) desc = pFormat;
827 else desc = pFormat + *(const SHORT*)pFormat;
828
829 switch (type) {
830 case FC_RP: /* ref pointer (always non-null) */
831 if (!Pointer)
832 {
833 ERR("NULL ref pointer is not allowed\n");
835 }
836 pointer_needs_marshaling = TRUE;
837 break;
838 case FC_UP: /* unique pointer */
839 case FC_OP: /* object pointer - same as unique here */
840 if (Pointer)
841 pointer_needs_marshaling = TRUE;
842 else
843 pointer_needs_marshaling = FALSE;
844 pointer_id = Pointer ? NDR_POINTER_ID(pStubMsg) : 0;
845 TRACE("writing 0x%08lx to buffer\n", pointer_id);
846 NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
847 break;
848 case FC_FP:
849 pointer_needs_marshaling = !NdrFullPointerQueryPointer(
850 pStubMsg->FullPtrXlatTables, Pointer, 1, &pointer_id);
851 TRACE("writing 0x%08lx to buffer\n", pointer_id);
852 NDR_LOCAL_UINT32_WRITE(Buffer, pointer_id);
853 break;
854 default:
855 FIXME("unhandled ptr type=%02x\n", type);
857 return;
858 }
859
860 TRACE("calling marshaller for type 0x%x\n", (int)*desc);
861
862 if (pointer_needs_marshaling) {
863 if (attr & FC_POINTER_DEREF) {
864 Pointer = *(unsigned char**)Pointer;
865 TRACE("deref => %p\n", Pointer);
866 }
868 if (m) m(pStubMsg, Pointer, desc);
869 else FIXME("no marshaller for data type=%02x\n", *desc);
870 }
871
872 STD_OVERFLOW_CHECK(pStubMsg);
873}
874
875/* pPointer is the pointer that we will unmarshal into; pSrcPointer is the
876 * pointer to memory which we may attempt to reuse if non-NULL. Usually these
877 * are the same; for the case when they aren't, see EmbeddedPointerUnmarshall().
878 *
879 * fMustAlloc seems to determine whether we can allocate from the buffer (if we
880 * are on the server side). It's ignored here, since we can't allocate a pointer
881 * from the buffer. */
883 unsigned char *Buffer,
884 unsigned char **pPointer,
885 unsigned char *pSrcPointer,
886 PFORMAT_STRING pFormat,
887 unsigned char fMustAlloc)
888{
889 unsigned type = pFormat[0], attr = pFormat[1];
892 DWORD pointer_id = 0;
893 BOOL pointer_needs_unmarshaling, need_alloc = FALSE, inner_must_alloc = FALSE;
894
895 TRACE("(%p,%p,%p,%p,%p,%d)\n", pStubMsg, Buffer, pPointer, pSrcPointer, pFormat, fMustAlloc);
896 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
897 pFormat += 2;
898 if (attr & FC_SIMPLE_POINTER) desc = pFormat;
899 else desc = pFormat + *(const SHORT*)pFormat;
900
901 switch (type) {
902 case FC_RP: /* ref pointer (always non-null) */
903 pointer_needs_unmarshaling = TRUE;
904 break;
905 case FC_UP: /* unique pointer */
906 pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
907 TRACE("pointer_id is 0x%08lx\n", pointer_id);
908 if (pointer_id)
909 pointer_needs_unmarshaling = TRUE;
910 else {
911 *pPointer = NULL;
912 pointer_needs_unmarshaling = FALSE;
913 }
914 break;
915 case FC_OP: /* object pointer - we must free data before overwriting it */
916 pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
917 TRACE("pointer_id is 0x%08lx\n", pointer_id);
918
919 /* An object pointer always allocates new memory (it cannot point to the
920 * buffer). */
921 inner_must_alloc = TRUE;
922
923 if (pSrcPointer)
924 FIXME("free object pointer %p\n", pSrcPointer);
925 if (pointer_id)
926 pointer_needs_unmarshaling = TRUE;
927 else
928 {
929 *pPointer = NULL;
930 pointer_needs_unmarshaling = FALSE;
931 }
932 break;
933 case FC_FP:
934 pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
935 TRACE("pointer_id is 0x%08lx\n", pointer_id);
936 pointer_needs_unmarshaling = !NdrFullPointerQueryRefId(
937 pStubMsg->FullPtrXlatTables, pointer_id, 1, (void **)pPointer);
938 break;
939 default:
940 FIXME("unhandled ptr type=%02x\n", type);
942 return;
943 }
944
945 if (pointer_needs_unmarshaling) {
946 unsigned char **current_ptr = pPointer;
947 if (pStubMsg->IsClient) {
948 TRACE("client\n");
949 /* Try to use the existing (source) pointer to unmarshall the data into
950 * so that [in, out] or [out, ref] parameters behave correctly. If the
951 * source pointer is NULL and we are not dereferencing, we must force the
952 * inner marshalling routine to allocate, since otherwise it will crash. */
953 if (pSrcPointer)
954 {
955 TRACE("setting *pPointer to %p\n", pSrcPointer);
956 *pPointer = pSrcPointer;
957 }
958 else
959 need_alloc = inner_must_alloc = TRUE;
960 } else {
961 TRACE("server\n");
962 /* We can use an existing source pointer here only if it is on-stack,
963 * probably since otherwise NdrPointerFree() might later try to free a
964 * pointer we don't know the provenance of. Otherwise we must always
965 * allocate if we are dereferencing. We never need to force the inner
966 * routine to allocate here, since it will either write into an existing
967 * pointer, or use a pointer to the buffer. */
969 {
970 if (pSrcPointer && (attr & FC_ALLOCED_ON_STACK))
971 *pPointer = pSrcPointer;
972 else
973 need_alloc = TRUE;
974 }
975 else
976 *pPointer = NULL;
977 }
978
980 FIXME("FC_ALLOCATE_ALL_NODES not implemented\n");
981
982 if (attr & FC_POINTER_DEREF) {
983 if (need_alloc)
984 *pPointer = NdrAllocateZero(pStubMsg, sizeof(void *));
985
986 current_ptr = *(unsigned char***)current_ptr;
987 TRACE("deref => %p\n", current_ptr);
988 }
990 if (m) m(pStubMsg, current_ptr, desc, inner_must_alloc);
991 else FIXME("no unmarshaller for data type=%02x\n", *desc);
992
993 if (type == FC_FP)
994 NdrFullPointerInsertRefId(pStubMsg->FullPtrXlatTables, pointer_id,
995 *pPointer);
996 }
997
998 TRACE("pointer=%p\n", *pPointer);
999}
1000
1001/***********************************************************************
1002 * PointerBufferSize [internal]
1003 */
1005 unsigned char *Pointer,
1006 PFORMAT_STRING pFormat)
1007{
1008 unsigned type = pFormat[0], attr = pFormat[1];
1011 BOOL pointer_needs_sizing;
1012 ULONG pointer_id;
1013
1014 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
1015 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
1016 pFormat += 2;
1017 if (attr & FC_SIMPLE_POINTER) desc = pFormat;
1018 else desc = pFormat + *(const SHORT*)pFormat;
1019
1020 switch (type) {
1021 case FC_RP: /* ref pointer (always non-null) */
1022 if (!Pointer)
1023 {
1024 ERR("NULL ref pointer is not allowed\n");
1026 }
1027 break;
1028 case FC_OP:
1029 case FC_UP:
1030 /* NULL pointer has no further representation */
1031 if (!Pointer)
1032 return;
1033 break;
1034 case FC_FP:
1035 pointer_needs_sizing = !NdrFullPointerQueryPointer(
1036 pStubMsg->FullPtrXlatTables, Pointer, 0, &pointer_id);
1037 if (!pointer_needs_sizing)
1038 return;
1039 break;
1040 default:
1041 FIXME("unhandled ptr type=%02x\n", type);
1043 return;
1044 }
1045
1046 if (attr & FC_POINTER_DEREF) {
1047 Pointer = *(unsigned char**)Pointer;
1048 TRACE("deref => %p\n", Pointer);
1049 }
1050
1052 if (m) m(pStubMsg, Pointer, desc);
1053 else FIXME("no buffersizer for data type=%02x\n", *desc);
1054}
1055
1056/***********************************************************************
1057 * PointerMemorySize [internal]
1058 */
1060 unsigned char *Buffer, PFORMAT_STRING pFormat)
1061{
1062 unsigned type = pFormat[0], attr = pFormat[1];
1065 DWORD pointer_id = 0;
1066 BOOL pointer_needs_sizing;
1067
1068 TRACE("(%p,%p,%p)\n", pStubMsg, Buffer, pFormat);
1069 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
1070 pFormat += 2;
1071 if (attr & FC_SIMPLE_POINTER) desc = pFormat;
1072 else desc = pFormat + *(const SHORT*)pFormat;
1073
1074 switch (type) {
1075 case FC_RP: /* ref pointer (always non-null) */
1076 pointer_needs_sizing = TRUE;
1077 break;
1078 case FC_UP: /* unique pointer */
1079 case FC_OP: /* object pointer - we must free data before overwriting it */
1080 pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
1081 TRACE("pointer_id is 0x%08lx\n", pointer_id);
1082 if (pointer_id)
1083 pointer_needs_sizing = TRUE;
1084 else
1085 pointer_needs_sizing = FALSE;
1086 break;
1087 case FC_FP:
1088 {
1089 void *pointer;
1090 pointer_id = NDR_LOCAL_UINT32_READ(Buffer);
1091 TRACE("pointer_id is 0x%08lx\n", pointer_id);
1092 pointer_needs_sizing = !NdrFullPointerQueryRefId(
1093 pStubMsg->FullPtrXlatTables, pointer_id, 1, &pointer);
1094 break;
1095 }
1096 default:
1097 FIXME("unhandled ptr type=%02x\n", type);
1099 return 0;
1100 }
1101
1102 if (attr & FC_POINTER_DEREF) {
1103 align_length(&pStubMsg->MemorySize, sizeof(void*));
1104 pStubMsg->MemorySize += sizeof(void*);
1105 TRACE("deref\n");
1106 }
1107
1108 if (pointer_needs_sizing) {
1110 if (m) m(pStubMsg, desc);
1111 else FIXME("no memorysizer for data type=%02x\n", *desc);
1112 }
1113
1114 return pStubMsg->MemorySize;
1115}
1116
1117/***********************************************************************
1118 * PointerFree [internal]
1119 */
1120static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
1121 unsigned char *Pointer,
1122 PFORMAT_STRING pFormat)
1123{
1124 unsigned type = pFormat[0], attr = pFormat[1];
1126 NDR_FREE m;
1127 unsigned char *current_pointer = Pointer;
1128
1129 TRACE("(%p,%p,%p)\n", pStubMsg, Pointer, pFormat);
1130 TRACE("type=0x%x, attr=", type); dump_pointer_attr(attr);
1131 if (attr & FC_DONT_FREE) return;
1132 pFormat += 2;
1133 if (attr & FC_SIMPLE_POINTER) desc = pFormat;
1134 else desc = pFormat + *(const SHORT*)pFormat;
1135
1136 if (!Pointer) return;
1137
1138 if (type == FC_FP) {
1139 int pointer_needs_freeing = NdrFullPointerFree(
1140 pStubMsg->FullPtrXlatTables, Pointer);
1141 if (!pointer_needs_freeing)
1142 return;
1143 }
1144
1145 if (attr & FC_POINTER_DEREF) {
1146 current_pointer = *(unsigned char**)Pointer;
1147 TRACE("deref => %p\n", current_pointer);
1148 }
1149
1151 if (m) m(pStubMsg, current_pointer, desc);
1152
1153 /* this check stops us from trying to free buffer memory. we don't have to
1154 * worry about clients, since they won't call this function.
1155 * we don't have to check for the buffer being reallocated because
1156 * BufferStart and BufferEnd won't be reset when allocating memory for
1157 * sending the response. we don't have to check for the new buffer here as
1158 * it won't be used a type memory, only for buffer memory */
1159 if (Pointer >= pStubMsg->BufferStart && Pointer <= pStubMsg->BufferEnd)
1160 goto notfree;
1161
1162 if (attr & FC_ALLOCED_ON_STACK) {
1163 TRACE("not freeing stack ptr %p\n", Pointer);
1164 return;
1165 }
1166 TRACE("freeing %p\n", Pointer);
1167 NdrFree(pStubMsg, Pointer);
1168 return;
1169notfree:
1170 TRACE("not freeing %p\n", Pointer);
1171}
1172
1173/***********************************************************************
1174 * EmbeddedPointerMarshall
1175 */
1176static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg,
1177 unsigned char *pMemory,
1178 PFORMAT_STRING pFormat)
1179{
1180 unsigned char *Mark = pStubMsg->BufferMark;
1181 unsigned rep, count, stride;
1182 unsigned i;
1183 unsigned char *saved_buffer = NULL;
1184
1185 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1186
1187 if (*pFormat != FC_PP) return NULL;
1188 pFormat += 2;
1189
1190 if (pStubMsg->PointerBufferMark)
1191 {
1192 saved_buffer = pStubMsg->Buffer;
1193 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1194 pStubMsg->PointerBufferMark = NULL;
1195 }
1196
1197 while (pFormat[0] != FC_END) {
1198 switch (pFormat[0]) {
1199 default:
1200 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1201 /* fallthrough */
1202 case FC_NO_REPEAT:
1203 rep = 1;
1204 stride = 0;
1205 count = 1;
1206 pFormat += 2;
1207 break;
1208 case FC_FIXED_REPEAT:
1209 rep = *(const WORD*)&pFormat[2];
1210 stride = *(const WORD*)&pFormat[4];
1211 count = *(const WORD*)&pFormat[8];
1212 pFormat += 10;
1213 break;
1214 case FC_VARIABLE_REPEAT:
1215 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1216 stride = *(const WORD*)&pFormat[2];
1217 count = *(const WORD*)&pFormat[6];
1218 pFormat += 8;
1219 break;
1220 }
1221 for (i = 0; i < rep; i++) {
1222 PFORMAT_STRING info = pFormat;
1223 unsigned char *membase = pMemory + (i * stride);
1224 unsigned char *bufbase = Mark + (i * stride);
1225 unsigned u;
1226
1227 for (u=0; u<count; u++,info+=8) {
1228 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1229 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1230 unsigned char *saved_memory = pStubMsg->Memory;
1231
1232 pStubMsg->Memory = membase;
1233 PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
1234 pStubMsg->Memory = saved_memory;
1235 }
1236 }
1237 pFormat += 8 * count;
1238 }
1239
1240 if (saved_buffer)
1241 {
1242 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1243 pStubMsg->Buffer = saved_buffer;
1244 }
1245
1246 STD_OVERFLOW_CHECK(pStubMsg);
1247
1248 return NULL;
1249}
1250
1251/* rpcrt4 does something bizarre with embedded pointers: instead of copying the
1252 * struct/array/union from the buffer to memory and then unmarshalling pointers
1253 * into it, it unmarshals pointers into the buffer itself and then copies it to
1254 * memory. However, it will still attempt to use a user-supplied pointer where
1255 * appropriate (i.e. one on stack). Therefore we need to pass both pointers to
1256 * this function and to PointerUnmarshall: the pointer (to the buffer) that we
1257 * will actually unmarshal into (pDstBuffer), and the pointer (to memory) that
1258 * we will attempt to use for storage if possible (pSrcMemoryPtrs). */
1259static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
1260 unsigned char *pDstBuffer,
1261 unsigned char *pSrcMemoryPtrs,
1262 PFORMAT_STRING pFormat,
1263 unsigned char fMustAlloc)
1264{
1265 unsigned char *Mark = pStubMsg->BufferMark;
1266 unsigned rep, count, stride;
1267 unsigned i;
1268 unsigned char *saved_buffer = NULL;
1269
1270 TRACE("(%p,%p,%p,%p,%d)\n", pStubMsg, pDstBuffer, pSrcMemoryPtrs, pFormat, fMustAlloc);
1271
1272 if (*pFormat != FC_PP) return NULL;
1273 pFormat += 2;
1274
1275 if (pStubMsg->PointerBufferMark)
1276 {
1277 saved_buffer = pStubMsg->Buffer;
1278 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1279 pStubMsg->PointerBufferMark = NULL;
1280 }
1281
1282 while (pFormat[0] != FC_END) {
1283 TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
1284 switch (pFormat[0]) {
1285 default:
1286 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1287 /* fallthrough */
1288 case FC_NO_REPEAT:
1289 rep = 1;
1290 stride = 0;
1291 count = 1;
1292 pFormat += 2;
1293 break;
1294 case FC_FIXED_REPEAT:
1295 rep = *(const WORD*)&pFormat[2];
1296 stride = *(const WORD*)&pFormat[4];
1297 count = *(const WORD*)&pFormat[8];
1298 pFormat += 10;
1299 break;
1300 case FC_VARIABLE_REPEAT:
1301 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1302 stride = *(const WORD*)&pFormat[2];
1303 count = *(const WORD*)&pFormat[6];
1304 pFormat += 8;
1305 break;
1306 }
1307 for (i = 0; i < rep; i++) {
1308 PFORMAT_STRING info = pFormat;
1309 unsigned char *bufdstbase = pDstBuffer + (i * stride);
1310 unsigned char *memsrcbase = pSrcMemoryPtrs + (i * stride);
1311 unsigned char *bufbase = Mark + (i * stride);
1312 unsigned u;
1313
1314 for (u=0; u<count; u++,info+=8) {
1315 unsigned char **bufdstptr = (unsigned char **)(bufdstbase + *(const SHORT*)&info[2]);
1316 unsigned char **memsrcptr = (unsigned char **)(memsrcbase + *(const SHORT*)&info[0]);
1317 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1318 PointerUnmarshall(pStubMsg, bufptr, bufdstptr, *memsrcptr, info+4, fMustAlloc);
1319 }
1320 }
1321 pFormat += 8 * count;
1322 }
1323
1324 if (saved_buffer)
1325 {
1326 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1327 pStubMsg->Buffer = saved_buffer;
1328 }
1329
1330 return NULL;
1331}
1332
1333/***********************************************************************
1334 * EmbeddedPointerBufferSize
1335 */
1337 unsigned char *pMemory,
1338 PFORMAT_STRING pFormat)
1339{
1340 unsigned rep, count, stride;
1341 unsigned i;
1342 ULONG saved_buffer_length = 0;
1343
1344 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1345
1346 if (pStubMsg->IgnoreEmbeddedPointers) return;
1347
1348 if (*pFormat != FC_PP) return;
1349 pFormat += 2;
1350
1351 if (pStubMsg->PointerLength)
1352 {
1353 saved_buffer_length = pStubMsg->BufferLength;
1354 pStubMsg->BufferLength = pStubMsg->PointerLength;
1355 pStubMsg->PointerLength = 0;
1356 }
1357
1358 while (pFormat[0] != FC_END) {
1359 switch (pFormat[0]) {
1360 default:
1361 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1362 /* fallthrough */
1363 case FC_NO_REPEAT:
1364 rep = 1;
1365 stride = 0;
1366 count = 1;
1367 pFormat += 2;
1368 break;
1369 case FC_FIXED_REPEAT:
1370 rep = *(const WORD*)&pFormat[2];
1371 stride = *(const WORD*)&pFormat[4];
1372 count = *(const WORD*)&pFormat[8];
1373 pFormat += 10;
1374 break;
1375 case FC_VARIABLE_REPEAT:
1376 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1377 stride = *(const WORD*)&pFormat[2];
1378 count = *(const WORD*)&pFormat[6];
1379 pFormat += 8;
1380 break;
1381 }
1382 for (i = 0; i < rep; i++) {
1383 PFORMAT_STRING info = pFormat;
1384 unsigned char *membase = pMemory + (i * stride);
1385 unsigned u;
1386
1387 for (u=0; u<count; u++,info+=8) {
1388 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1389 unsigned char *saved_memory = pStubMsg->Memory;
1390
1391 pStubMsg->Memory = membase;
1392 PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
1393 pStubMsg->Memory = saved_memory;
1394 }
1395 }
1396 pFormat += 8 * count;
1397 }
1398
1399 if (saved_buffer_length)
1400 {
1401 pStubMsg->PointerLength = pStubMsg->BufferLength;
1402 pStubMsg->BufferLength = saved_buffer_length;
1403 }
1404}
1405
1406/***********************************************************************
1407 * EmbeddedPointerMemorySize [internal]
1408 */
1410 PFORMAT_STRING pFormat)
1411{
1412 unsigned char *Mark = pStubMsg->BufferMark;
1413 unsigned rep, count, stride;
1414 unsigned i;
1415 unsigned char *saved_buffer = NULL;
1416
1417 TRACE("(%p,%p)\n", pStubMsg, pFormat);
1418
1419 if (pStubMsg->IgnoreEmbeddedPointers) return 0;
1420
1421 if (pStubMsg->PointerBufferMark)
1422 {
1423 saved_buffer = pStubMsg->Buffer;
1424 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
1425 pStubMsg->PointerBufferMark = NULL;
1426 }
1427
1428 if (*pFormat != FC_PP) return 0;
1429 pFormat += 2;
1430
1431 while (pFormat[0] != FC_END) {
1432 switch (pFormat[0]) {
1433 default:
1434 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1435 /* fallthrough */
1436 case FC_NO_REPEAT:
1437 rep = 1;
1438 stride = 0;
1439 count = 1;
1440 pFormat += 2;
1441 break;
1442 case FC_FIXED_REPEAT:
1443 rep = *(const WORD*)&pFormat[2];
1444 stride = *(const WORD*)&pFormat[4];
1445 count = *(const WORD*)&pFormat[8];
1446 pFormat += 10;
1447 break;
1448 case FC_VARIABLE_REPEAT:
1449 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1450 stride = *(const WORD*)&pFormat[2];
1451 count = *(const WORD*)&pFormat[6];
1452 pFormat += 8;
1453 break;
1454 }
1455 for (i = 0; i < rep; i++) {
1456 PFORMAT_STRING info = pFormat;
1457 unsigned char *bufbase = Mark + (i * stride);
1458 unsigned u;
1459 for (u=0; u<count; u++,info+=8) {
1460 unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
1461 PointerMemorySize(pStubMsg, bufptr, info+4);
1462 }
1463 }
1464 pFormat += 8 * count;
1465 }
1466
1467 if (saved_buffer)
1468 {
1469 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
1470 pStubMsg->Buffer = saved_buffer;
1471 }
1472
1473 return 0;
1474}
1475
1476/***********************************************************************
1477 * EmbeddedPointerFree [internal]
1478 */
1480 unsigned char *pMemory,
1481 PFORMAT_STRING pFormat)
1482{
1483 unsigned rep, count, stride;
1484 unsigned i;
1485
1486 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1487 if (*pFormat != FC_PP) return;
1488 pFormat += 2;
1489
1490 while (pFormat[0] != FC_END) {
1491 switch (pFormat[0]) {
1492 default:
1493 FIXME("unknown repeat type %d; assuming no repeat\n", pFormat[0]);
1494 /* fallthrough */
1495 case FC_NO_REPEAT:
1496 rep = 1;
1497 stride = 0;
1498 count = 1;
1499 pFormat += 2;
1500 break;
1501 case FC_FIXED_REPEAT:
1502 rep = *(const WORD*)&pFormat[2];
1503 stride = *(const WORD*)&pFormat[4];
1504 count = *(const WORD*)&pFormat[8];
1505 pFormat += 10;
1506 break;
1507 case FC_VARIABLE_REPEAT:
1508 rep = (pFormat[1] == FC_VARIABLE_OFFSET) ? pStubMsg->ActualCount : pStubMsg->MaxCount;
1509 stride = *(const WORD*)&pFormat[2];
1510 count = *(const WORD*)&pFormat[6];
1511 pFormat += 8;
1512 break;
1513 }
1514 for (i = 0; i < rep; i++) {
1515 PFORMAT_STRING info = pFormat;
1516 unsigned char *membase = pMemory + (i * stride);
1517 unsigned u;
1518
1519 for (u=0; u<count; u++,info+=8) {
1520 unsigned char *memptr = membase + *(const SHORT*)&info[0];
1521 unsigned char *saved_memory = pStubMsg->Memory;
1522
1523 pStubMsg->Memory = membase;
1524 PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
1525 pStubMsg->Memory = saved_memory;
1526 }
1527 }
1528 pFormat += 8 * count;
1529 }
1530}
1531
1532/***********************************************************************
1533 * NdrPointerMarshall [RPCRT4.@]
1534 */
1536 unsigned char *pMemory,
1537 PFORMAT_STRING pFormat)
1538{
1539 unsigned char *Buffer;
1540
1541 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1542
1543 /* Increment the buffer here instead of in PointerMarshall,
1544 * as that is used by embedded pointers which already handle the incrementing
1545 * the buffer, and shouldn't write any additional pointer data to the wire */
1546 if (*pFormat != FC_RP)
1547 {
1548 align_pointer_clear(&pStubMsg->Buffer, 4);
1549 Buffer = pStubMsg->Buffer;
1550 safe_buffer_increment(pStubMsg, 4);
1551 }
1552 else
1553 Buffer = pStubMsg->Buffer;
1554
1555 PointerMarshall(pStubMsg, Buffer, pMemory, pFormat);
1556
1557 return NULL;
1558}
1559
1560/***********************************************************************
1561 * NdrPointerUnmarshall [RPCRT4.@]
1562 */
1564 unsigned char **ppMemory,
1565 PFORMAT_STRING pFormat,
1566 unsigned char fMustAlloc)
1567{
1568 unsigned char *Buffer;
1569
1570 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1571
1572 if (*pFormat == FC_RP)
1573 {
1574 Buffer = pStubMsg->Buffer;
1575 /* Do the NULL ref pointer check here because embedded pointers can be
1576 * NULL if the type the pointer is embedded in was allocated rather than
1577 * being passed in by the client */
1578 if (pStubMsg->IsClient && !*ppMemory)
1579 {
1580 ERR("NULL ref pointer is not allowed\n");
1582 }
1583 }
1584 else
1585 {
1586 /* Increment the buffer here instead of in PointerUnmarshall,
1587 * as that is used by embedded pointers which already handle the incrementing
1588 * the buffer, and shouldn't read any additional pointer data from the
1589 * buffer */
1590 align_pointer(&pStubMsg->Buffer, 4);
1591 Buffer = pStubMsg->Buffer;
1592 safe_buffer_increment(pStubMsg, 4);
1593 }
1594
1595 PointerUnmarshall(pStubMsg, Buffer, ppMemory, *ppMemory, pFormat, fMustAlloc);
1596
1597 return NULL;
1598}
1599
1600/***********************************************************************
1601 * NdrPointerBufferSize [RPCRT4.@]
1602 */
1604 unsigned char *pMemory,
1605 PFORMAT_STRING pFormat)
1606{
1607 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1608
1609 /* Increment the buffer length here instead of in PointerBufferSize,
1610 * as that is used by embedded pointers which already handle the buffer
1611 * length, and shouldn't write anything more to the wire */
1612 if (*pFormat != FC_RP)
1613 {
1614 align_length(&pStubMsg->BufferLength, 4);
1615 safe_buffer_length_increment(pStubMsg, 4);
1616 }
1617
1618 PointerBufferSize(pStubMsg, pMemory, pFormat);
1619}
1620
1621/***********************************************************************
1622 * NdrPointerMemorySize [RPCRT4.@]
1623 */
1625 PFORMAT_STRING pFormat)
1626{
1627 unsigned char *Buffer = pStubMsg->Buffer;
1628 if (*pFormat != FC_RP)
1629 {
1630 align_pointer(&pStubMsg->Buffer, 4);
1631 safe_buffer_increment(pStubMsg, 4);
1632 }
1633 align_length(&pStubMsg->MemorySize, sizeof(void *));
1634 return PointerMemorySize(pStubMsg, Buffer, pFormat);
1635}
1636
1637/***********************************************************************
1638 * NdrPointerFree [RPCRT4.@]
1639 */
1641 unsigned char *pMemory,
1642 PFORMAT_STRING pFormat)
1643{
1644 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1645 PointerFree(pStubMsg, pMemory, pFormat);
1646}
1647
1648/***********************************************************************
1649 * NdrSimpleTypeMarshall [RPCRT4.@]
1650 */
1652 unsigned char FormatChar )
1653{
1654 NdrBaseTypeMarshall(pStubMsg, pMemory, &FormatChar);
1655}
1656
1657/***********************************************************************
1658 * NdrSimpleTypeUnmarshall [RPCRT4.@]
1659 *
1660 * Unmarshall a base type.
1661 *
1662 * NOTES
1663 * Doesn't check that the buffer is long enough before copying, so the caller
1664 * should do this.
1665 */
1667 unsigned char FormatChar )
1668{
1669#define BASE_TYPE_UNMARSHALL(type) \
1670 align_pointer(&pStubMsg->Buffer, sizeof(type)); \
1671 TRACE("pMemory: %p\n", pMemory); \
1672 *(type *)pMemory = *(type *)pStubMsg->Buffer; \
1673 pStubMsg->Buffer += sizeof(type);
1674
1675 switch(FormatChar)
1676 {
1677 case FC_BYTE:
1678 case FC_CHAR:
1679 case FC_SMALL:
1680 case FC_USMALL:
1682 TRACE("value: 0x%02x\n", *pMemory);
1683 break;
1684 case FC_WCHAR:
1685 case FC_SHORT:
1686 case FC_USHORT:
1688 TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
1689 break;
1690 case FC_LONG:
1691 case FC_ULONG:
1692 case FC_ERROR_STATUS_T:
1693 case FC_ENUM32:
1695 TRACE("value: 0x%08lx\n", *(ULONG *)pMemory);
1696 break;
1697 case FC_FLOAT:
1698 BASE_TYPE_UNMARSHALL(float);
1699 TRACE("value: %f\n", *(float *)pMemory);
1700 break;
1701 case FC_DOUBLE:
1702 BASE_TYPE_UNMARSHALL(double);
1703 TRACE("value: %f\n", *(double *)pMemory);
1704 break;
1705 case FC_HYPER:
1707 TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG *)pMemory));
1708 break;
1709 case FC_ENUM16:
1710 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
1711 TRACE("pMemory: %p\n", pMemory);
1712 /* 16-bits on the wire, but int in memory */
1713 *(UINT *)pMemory = *(USHORT *)pStubMsg->Buffer;
1714 pStubMsg->Buffer += sizeof(USHORT);
1715 TRACE("value: 0x%08x\n", *(UINT *)pMemory);
1716 break;
1717 case FC_INT3264:
1718 align_pointer(&pStubMsg->Buffer, sizeof(INT));
1719 /* 32-bits on the wire, but int_ptr in memory */
1720 *(INT_PTR *)pMemory = *(INT *)pStubMsg->Buffer;
1721 pStubMsg->Buffer += sizeof(INT);
1722 TRACE("value: 0x%08Ix\n", *(INT_PTR *)pMemory);
1723 break;
1724 case FC_UINT3264:
1725 align_pointer(&pStubMsg->Buffer, sizeof(UINT));
1726 /* 32-bits on the wire, but int_ptr in memory */
1727 *(UINT_PTR *)pMemory = *(UINT *)pStubMsg->Buffer;
1728 pStubMsg->Buffer += sizeof(UINT);
1729 TRACE("value: 0x%08Ix\n", *(UINT_PTR *)pMemory);
1730 break;
1731 case FC_IGNORE:
1732 break;
1733 default:
1734 FIXME("Unhandled base type: 0x%02x\n", FormatChar);
1735 }
1736#undef BASE_TYPE_UNMARSHALL
1737}
1738
1739/***********************************************************************
1740 * NdrSimpleStructMarshall [RPCRT4.@]
1741 */
1743 unsigned char *pMemory,
1744 PFORMAT_STRING pFormat)
1745{
1746 unsigned size = *(const WORD*)(pFormat+2);
1747 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1748
1749 align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
1750
1751 pStubMsg->BufferMark = pStubMsg->Buffer;
1752 safe_copy_to_buffer(pStubMsg, pMemory, size);
1753
1754 if (pFormat[0] != FC_STRUCT)
1755 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat+4);
1756
1757 return NULL;
1758}
1759
1760/***********************************************************************
1761 * NdrSimpleStructUnmarshall [RPCRT4.@]
1762 */
1764 unsigned char **ppMemory,
1765 PFORMAT_STRING pFormat,
1766 unsigned char fMustAlloc)
1767{
1768 unsigned size = *(const WORD*)(pFormat+2);
1769 unsigned char *saved_buffer;
1770 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
1771
1772 align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
1773
1774 if (fMustAlloc)
1775 *ppMemory = NdrAllocateZero(pStubMsg, size);
1776 else
1777 {
1778 if (!pStubMsg->IsClient && !*ppMemory)
1779 /* for servers, we just point straight into the RPC buffer */
1780 *ppMemory = pStubMsg->Buffer;
1781 }
1782
1783 saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
1784 safe_buffer_increment(pStubMsg, size);
1785 if (pFormat[0] == FC_PSTRUCT)
1786 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat+4, fMustAlloc);
1787
1788 TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
1789 if (*ppMemory != saved_buffer)
1790 memcpy(*ppMemory, saved_buffer, size);
1791
1792 return NULL;
1793}
1794
1795/***********************************************************************
1796 * NdrSimpleStructBufferSize [RPCRT4.@]
1797 */
1799 unsigned char *pMemory,
1800 PFORMAT_STRING pFormat)
1801{
1802 unsigned size = *(const WORD*)(pFormat+2);
1803 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1804
1805 align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
1806
1808 if (pFormat[0] != FC_STRUCT)
1809 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
1810}
1811
1812/***********************************************************************
1813 * NdrSimpleStructMemorySize [RPCRT4.@]
1814 */
1816 PFORMAT_STRING pFormat)
1817{
1818 unsigned short size = *(const WORD *)(pFormat+2);
1819
1820 TRACE("(%p,%p)\n", pStubMsg, pFormat);
1821
1822 align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
1823 pStubMsg->MemorySize += size;
1824 safe_buffer_increment(pStubMsg, size);
1825
1826 if (pFormat[0] != FC_STRUCT)
1827 EmbeddedPointerMemorySize(pStubMsg, pFormat+4);
1828 return pStubMsg->MemorySize;
1829}
1830
1831/***********************************************************************
1832 * NdrSimpleStructFree [RPCRT4.@]
1833 */
1835 unsigned char *pMemory,
1836 PFORMAT_STRING pFormat)
1837{
1838 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
1839 if (pFormat[0] != FC_STRUCT)
1840 EmbeddedPointerFree(pStubMsg, pMemory, pFormat+4);
1841}
1842
1843/* Array helpers */
1844
1846 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
1847 PFORMAT_STRING pFormat)
1848{
1849 DWORD count;
1850
1851 switch (fc)
1852 {
1853 case FC_CARRAY:
1854 ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1855 SizeConformance(pStubMsg);
1856 break;
1857 case FC_CVARRAY:
1858 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
1859 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
1860 SizeConformance(pStubMsg);
1861 break;
1862 case FC_C_CSTRING:
1863 case FC_C_WSTRING:
1864 if (fc == FC_C_CSTRING)
1865 {
1866 TRACE("string=%s\n", debugstr_a((const char *)pMemory));
1867 pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
1868 }
1869 else
1870 {
1871 TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
1872 pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
1873 }
1874
1875 if (pFormat[1] == FC_STRING_SIZED)
1876 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
1877 else
1878 pStubMsg->MaxCount = pStubMsg->ActualCount;
1879
1880 SizeConformance(pStubMsg);
1881 break;
1882 case FC_BOGUS_ARRAY:
1883 count = *(const WORD *)(pFormat + 2);
1884 pFormat += 4;
1885 if (IsConformanceOrVariancePresent(pFormat)) SizeConformance(pStubMsg);
1886 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, count);
1887 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
1888 break;
1889 default:
1890 ERR("unknown array format 0x%x\n", fc);
1892 }
1893}
1894
1895static inline void array_buffer_size(
1896 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
1897 PFORMAT_STRING pFormat, unsigned char fHasPointers)
1898{
1899 DWORD i, size;
1900 DWORD esize;
1901 unsigned char alignment;
1902
1903 switch (fc)
1904 {
1905 case FC_CARRAY:
1906 esize = *(const WORD*)(pFormat+2);
1907 alignment = pFormat[1] + 1;
1908
1909 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1910
1911 align_length(&pStubMsg->BufferLength, alignment);
1912
1913 size = safe_multiply(esize, pStubMsg->MaxCount);
1914 /* conformance value plus array */
1916
1917 if (fHasPointers)
1918 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1919 break;
1920 case FC_CVARRAY:
1921 esize = *(const WORD*)(pFormat+2);
1922 alignment = pFormat[1] + 1;
1923
1924 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1925 pFormat = SkipVariance(pStubMsg, pFormat);
1926
1927 SizeVariance(pStubMsg);
1928
1929 align_length(&pStubMsg->BufferLength, alignment);
1930
1931 size = safe_multiply(esize, pStubMsg->ActualCount);
1933
1934 if (fHasPointers)
1935 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
1936 break;
1937 case FC_C_CSTRING:
1938 case FC_C_WSTRING:
1939 if (fc == FC_C_CSTRING)
1940 esize = 1;
1941 else
1942 esize = 2;
1943
1944 SizeVariance(pStubMsg);
1945
1946 size = safe_multiply(esize, pStubMsg->ActualCount);
1948 break;
1949 case FC_BOGUS_ARRAY:
1950 alignment = pFormat[1] + 1;
1951 pFormat = SkipConformance(pStubMsg, pFormat + 4);
1952 if (IsConformanceOrVariancePresent(pFormat)) SizeVariance(pStubMsg);
1953 pFormat = SkipVariance(pStubMsg, pFormat);
1954
1955 align_length(&pStubMsg->BufferLength, alignment);
1956
1957 size = pStubMsg->ActualCount;
1958 for (i = 0; i < size; i++)
1959 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, NULL);
1960 break;
1961 default:
1962 ERR("unknown array format 0x%x\n", fc);
1964 }
1965}
1966
1968 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
1969 PFORMAT_STRING pFormat)
1970{
1971 ULONG def;
1972 BOOL conformance_present;
1973
1974 switch (fc)
1975 {
1976 case FC_CARRAY:
1977 ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
1978 WriteConformance(pStubMsg);
1979 break;
1980 case FC_CVARRAY:
1981 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, 0);
1982 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
1983 WriteConformance(pStubMsg);
1984 break;
1985 case FC_C_CSTRING:
1986 case FC_C_WSTRING:
1987 if (fc == FC_C_CSTRING)
1988 {
1989 TRACE("string=%s\n", debugstr_a((const char *)pMemory));
1990 pStubMsg->ActualCount = strlen((const char *)pMemory)+1;
1991 }
1992 else
1993 {
1994 TRACE("string=%s\n", debugstr_w((LPCWSTR)pMemory));
1995 pStubMsg->ActualCount = lstrlenW((LPCWSTR)pMemory)+1;
1996 }
1997 if (pFormat[1] == FC_STRING_SIZED)
1998 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 2, 0);
1999 else
2000 pStubMsg->MaxCount = pStubMsg->ActualCount;
2001 pStubMsg->Offset = 0;
2002 WriteConformance(pStubMsg);
2003 break;
2004 case FC_BOGUS_ARRAY:
2005 def = *(const WORD *)(pFormat + 2);
2006 pFormat += 4;
2007 conformance_present = IsConformanceOrVariancePresent(pFormat);
2008 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
2009 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2010 if (conformance_present) WriteConformance(pStubMsg);
2011 break;
2012 default:
2013 ERR("unknown array format 0x%x\n", fc);
2015 }
2016}
2017
2019 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory,
2020 PFORMAT_STRING pFormat, unsigned char fHasPointers)
2021{
2022 DWORD i, size;
2023 DWORD esize;
2024 unsigned char alignment;
2025
2026 switch (fc)
2027 {
2028 case FC_CARRAY:
2029 esize = *(const WORD*)(pFormat+2);
2030 alignment = pFormat[1] + 1;
2031
2032 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2033
2035
2036 size = safe_multiply(esize, pStubMsg->MaxCount);
2037 if (fHasPointers)
2038 pStubMsg->BufferMark = pStubMsg->Buffer;
2039 safe_copy_to_buffer(pStubMsg, pMemory, size);
2040
2041 if (fHasPointers)
2042 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2043 break;
2044 case FC_CVARRAY:
2045 esize = *(const WORD*)(pFormat+2);
2046 alignment = pFormat[1] + 1;
2047
2048 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2049 pFormat = SkipVariance(pStubMsg, pFormat);
2050
2051 WriteVariance(pStubMsg);
2052
2054
2055 size = safe_multiply(esize, pStubMsg->ActualCount);
2056
2057 if (fHasPointers)
2058 pStubMsg->BufferMark = pStubMsg->Buffer;
2059 safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, size);
2060
2061 if (fHasPointers)
2062 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
2063 break;
2064 case FC_C_CSTRING:
2065 case FC_C_WSTRING:
2066 if (fc == FC_C_CSTRING)
2067 esize = 1;
2068 else
2069 esize = 2;
2070
2071 WriteVariance(pStubMsg);
2072
2073 size = safe_multiply(esize, pStubMsg->ActualCount);
2074 safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
2075 break;
2076 case FC_BOGUS_ARRAY:
2077 alignment = pFormat[1] + 1;
2078 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2079 if (IsConformanceOrVariancePresent(pFormat)) WriteVariance(pStubMsg);
2080 pFormat = SkipVariance(pStubMsg, pFormat);
2081
2083
2084 size = pStubMsg->ActualCount;
2085 for (i = 0; i < size; i++)
2086 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, NULL);
2087 break;
2088 default:
2089 ERR("unknown array format 0x%x\n", fc);
2091 }
2092}
2093
2095 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
2096{
2097 DWORD def, esize;
2098
2099 switch (fc)
2100 {
2101 case FC_CARRAY:
2102 esize = *(const WORD*)(pFormat+2);
2103 pFormat = ReadConformance(pStubMsg, pFormat+4);
2104 return safe_multiply(esize, pStubMsg->MaxCount);
2105 case FC_CVARRAY:
2106 esize = *(const WORD*)(pFormat+2);
2107 pFormat = ReadConformance(pStubMsg, pFormat+4);
2108 return safe_multiply(esize, pStubMsg->MaxCount);
2109 case FC_C_CSTRING:
2110 case FC_C_WSTRING:
2111 if (fc == FC_C_CSTRING)
2112 esize = 1;
2113 else
2114 esize = 2;
2115
2116 if (pFormat[1] == FC_STRING_SIZED)
2117 ReadConformance(pStubMsg, pFormat + 2);
2118 else
2119 ReadConformance(pStubMsg, NULL);
2120 return safe_multiply(esize, pStubMsg->MaxCount);
2121 case FC_BOGUS_ARRAY:
2122 def = *(const WORD *)(pFormat + 2);
2123 pFormat += 4;
2124 if (IsConformanceOrVariancePresent(pFormat)) pFormat = ReadConformance(pStubMsg, pFormat);
2125 else
2126 {
2127 pStubMsg->MaxCount = def;
2128 pFormat = SkipConformance( pStubMsg, pFormat );
2129 }
2130 pFormat = SkipVariance( pStubMsg, pFormat );
2131
2132 esize = ComplexStructSize(pStubMsg, pFormat);
2133 return safe_multiply(pStubMsg->MaxCount, esize);
2134 default:
2135 ERR("unknown array format 0x%x\n", fc);
2137 }
2138}
2139
2141 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory,
2142 PFORMAT_STRING pFormat, unsigned char fMustAlloc,
2143 unsigned char fUseBufferMemoryServer, unsigned char fUnmarshall)
2144{
2145 ULONG bufsize, memsize;
2146 WORD esize;
2147 unsigned char alignment;
2148 unsigned char *saved_buffer, *pMemory;
2149 ULONG i, offset, count;
2150
2151 switch (fc)
2152 {
2153 case FC_CARRAY:
2154 esize = *(const WORD*)(pFormat+2);
2155 alignment = pFormat[1] + 1;
2156
2157 bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
2158
2159 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2160
2161 align_pointer(&pStubMsg->Buffer, alignment);
2162
2163 if (fUnmarshall)
2164 {
2165 if (fMustAlloc)
2166 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2167 else
2168 {
2169 if (fUseBufferMemoryServer && !pStubMsg->IsClient && !*ppMemory)
2170 /* for servers, we just point straight into the RPC buffer */
2171 *ppMemory = pStubMsg->Buffer;
2172 }
2173
2174 saved_buffer = pStubMsg->Buffer;
2175 safe_buffer_increment(pStubMsg, bufsize);
2176
2177 pStubMsg->BufferMark = saved_buffer;
2178 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
2179
2180 TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
2181 if (*ppMemory != saved_buffer)
2182 memcpy(*ppMemory, saved_buffer, bufsize);
2183 }
2184 return bufsize;
2185 case FC_CVARRAY:
2186 esize = *(const WORD*)(pFormat+2);
2187 alignment = pFormat[1] + 1;
2188
2189 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2190
2191 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2192
2193 align_pointer(&pStubMsg->Buffer, alignment);
2194
2195 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2196 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2197
2198 if (fUnmarshall)
2199 {
2200 offset = pStubMsg->Offset;
2201
2202 if (!fMustAlloc && !*ppMemory)
2203 fMustAlloc = TRUE;
2204 if (fMustAlloc)
2205 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2206 saved_buffer = pStubMsg->Buffer;
2207 safe_buffer_increment(pStubMsg, bufsize);
2208
2209 pStubMsg->BufferMark = saved_buffer;
2210 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat,
2211 fMustAlloc);
2212
2213 memcpy(*ppMemory + offset, saved_buffer, bufsize);
2214 }
2215 return bufsize;
2216 case FC_C_CSTRING:
2217 case FC_C_WSTRING:
2218 if (fc == FC_C_CSTRING)
2219 esize = 1;
2220 else
2221 esize = 2;
2222
2223 ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
2224
2225 if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
2226 {
2227 ERR("buffer size %ld must equal memory size %Id for non-sized conformant strings\n",
2228 pStubMsg->ActualCount, pStubMsg->MaxCount);
2230 }
2231 if (pStubMsg->Offset)
2232 {
2233 ERR("conformant strings can't have Offset (%ld)\n", pStubMsg->Offset);
2235 }
2236
2237 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2238 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2239
2240 validate_string_data(pStubMsg, bufsize, esize);
2241
2242 if (fUnmarshall)
2243 {
2244 if (fMustAlloc)
2245 *ppMemory = NdrAllocate(pStubMsg, memsize);
2246 else
2247 {
2248 if (fUseBufferMemoryServer && !pStubMsg->IsClient &&
2249 !*ppMemory && (pStubMsg->MaxCount == pStubMsg->ActualCount))
2250 /* if the data in the RPC buffer is big enough, we just point
2251 * straight into it */
2252 *ppMemory = pStubMsg->Buffer;
2253 else if (!*ppMemory)
2254 *ppMemory = NdrAllocate(pStubMsg, memsize);
2255 }
2256
2257 if (*ppMemory == pStubMsg->Buffer)
2258 safe_buffer_increment(pStubMsg, bufsize);
2259 else
2260 safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
2261
2262 if (*pFormat == FC_C_CSTRING)
2263 TRACE("string=%s\n", debugstr_a((char*)*ppMemory));
2264 else
2265 TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory));
2266 }
2267 return bufsize;
2268
2269 case FC_BOGUS_ARRAY:
2270 alignment = pFormat[1] + 1;
2271 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2272 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2273
2274 esize = ComplexStructSize(pStubMsg, pFormat);
2275 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2276
2277 assert( fUnmarshall );
2278
2279 if (!fMustAlloc && !*ppMemory)
2280 fMustAlloc = TRUE;
2281 if (fMustAlloc)
2282 *ppMemory = NdrAllocateZero(pStubMsg, memsize);
2283
2284 align_pointer(&pStubMsg->Buffer, alignment);
2285 saved_buffer = pStubMsg->Buffer;
2286
2287 pMemory = *ppMemory;
2288 count = pStubMsg->ActualCount;
2289 for (i = 0; i < count; i++)
2290 pMemory = ComplexUnmarshall(pStubMsg, pMemory, pFormat, NULL, fMustAlloc);
2291 return pStubMsg->Buffer - saved_buffer;
2292
2293 default:
2294 ERR("unknown array format 0x%x\n", fc);
2296 }
2297}
2298
2299static inline void array_memory_size(
2300 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat,
2301 unsigned char fHasPointers)
2302{
2303 ULONG i, count, SavedMemorySize;
2304 ULONG bufsize, memsize;
2305 DWORD esize;
2306 unsigned char alignment;
2307
2308 switch (fc)
2309 {
2310 case FC_CARRAY:
2311 esize = *(const WORD*)(pFormat+2);
2312 alignment = pFormat[1] + 1;
2313
2314 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2315
2316 bufsize = memsize = safe_multiply(esize, pStubMsg->MaxCount);
2317 pStubMsg->MemorySize += memsize;
2318
2319 align_pointer(&pStubMsg->Buffer, alignment);
2320 if (fHasPointers)
2321 pStubMsg->BufferMark = pStubMsg->Buffer;
2322 safe_buffer_increment(pStubMsg, bufsize);
2323
2324 if (fHasPointers)
2325 EmbeddedPointerMemorySize(pStubMsg, pFormat);
2326 break;
2327 case FC_CVARRAY:
2328 esize = *(const WORD*)(pFormat+2);
2329 alignment = pFormat[1] + 1;
2330
2331 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2332
2333 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2334
2335 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2336 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2337 pStubMsg->MemorySize += memsize;
2338
2339 align_pointer(&pStubMsg->Buffer, alignment);
2340 if (fHasPointers)
2341 pStubMsg->BufferMark = pStubMsg->Buffer;
2342 safe_buffer_increment(pStubMsg, bufsize);
2343
2344 if (fHasPointers)
2345 EmbeddedPointerMemorySize(pStubMsg, pFormat);
2346 break;
2347 case FC_C_CSTRING:
2348 case FC_C_WSTRING:
2349 if (fc == FC_C_CSTRING)
2350 esize = 1;
2351 else
2352 esize = 2;
2353
2354 ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
2355
2356 if (pFormat[1] != FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
2357 {
2358 ERR("buffer size %ld must equal memory size %Id for non-sized conformant strings\n",
2359 pStubMsg->ActualCount, pStubMsg->MaxCount);
2361 }
2362 if (pStubMsg->Offset)
2363 {
2364 ERR("conformant strings can't have Offset (%ld)\n", pStubMsg->Offset);
2366 }
2367
2368 memsize = safe_multiply(esize, pStubMsg->MaxCount);
2369 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2370
2371 validate_string_data(pStubMsg, bufsize, esize);
2372
2373 safe_buffer_increment(pStubMsg, bufsize);
2374 pStubMsg->MemorySize += memsize;
2375 break;
2376 case FC_BOGUS_ARRAY:
2377 alignment = pFormat[1] + 1;
2378 pFormat = SkipConformance(pStubMsg, pFormat + 4);
2379 pFormat = ReadVariance(pStubMsg, pFormat, pStubMsg->MaxCount);
2380
2381 align_pointer(&pStubMsg->Buffer, alignment);
2382
2383 SavedMemorySize = pStubMsg->MemorySize;
2384
2385 esize = ComplexStructSize(pStubMsg, pFormat);
2386 memsize = safe_multiply(pStubMsg->MaxCount, esize);
2387
2388 count = pStubMsg->ActualCount;
2389 for (i = 0; i < count; i++)
2390 ComplexStructMemorySize(pStubMsg, pFormat, NULL);
2391
2392 pStubMsg->MemorySize = SavedMemorySize + memsize;
2393 break;
2394 default:
2395 ERR("unknown array format 0x%x\n", fc);
2397 }
2398}
2399
2400static inline void array_free(
2401 unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg,
2402 unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
2403{
2404 DWORD i, count;
2405
2406 switch (fc)
2407 {
2408 case FC_CARRAY:
2409 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2410 if (fHasPointers)
2411 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2412 break;
2413 case FC_CVARRAY:
2414 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat+4, 0);
2415 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
2416 if (fHasPointers)
2417 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
2418 break;
2419 case FC_C_CSTRING:
2420 case FC_C_WSTRING:
2421 /* No embedded pointers so nothing to do */
2422 break;
2423 case FC_BOGUS_ARRAY:
2424 count = *(const WORD *)(pFormat + 2);
2425 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat + 4, count);
2426 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
2427
2428 count = pStubMsg->ActualCount;
2429 for (i = 0; i < count; i++)
2430 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
2431 break;
2432 default:
2433 ERR("unknown array format 0x%x\n", fc);
2435 }
2436}
2437
2438/*
2439 * NdrConformantString:
2440 *
2441 * What MS calls a ConformantString is, in DCE terminology,
2442 * a Varying-Conformant String.
2443 * [
2444 * maxlen: DWORD (max # of CHARTYPE characters, inclusive of '\0')
2445 * offset: DWORD (actual string data begins at (offset) CHARTYPE's
2446 * into unmarshalled string)
2447 * length: DWORD (# of CHARTYPE characters, inclusive of '\0')
2448 * [
2449 * data: CHARTYPE[maxlen]
2450 * ]
2451 * ], where CHARTYPE is the appropriate character type (specified externally)
2452 *
2453 */
2454
2455/***********************************************************************
2456 * NdrConformantStringMarshall [RPCRT4.@]
2457 */
2459 unsigned char *pszMessage, PFORMAT_STRING pFormat)
2460{
2461 TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
2462
2463 if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
2464 ERR("Unhandled string type: %#x\n", pFormat[0]);
2466 }
2467
2468 /* allow compiler to optimise inline function by passing constant into
2469 * these functions */
2470 if (pFormat[0] == FC_C_CSTRING) {
2472 pFormat);
2473 array_write_variance_and_marshall(FC_C_CSTRING, pStubMsg, pszMessage,
2474 pFormat, TRUE /* fHasPointers */);
2475 } else {
2477 pFormat);
2478 array_write_variance_and_marshall(FC_C_WSTRING, pStubMsg, pszMessage,
2479 pFormat, TRUE /* fHasPointers */);
2480 }
2481
2482 return NULL;
2483}
2484
2485/***********************************************************************
2486 * NdrConformantStringBufferSize [RPCRT4.@]
2487 */
2489 unsigned char* pMemory, PFORMAT_STRING pFormat)
2490{
2491 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
2492
2493 if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
2494 ERR("Unhandled string type: %#x\n", pFormat[0]);
2496 }
2497
2498 /* allow compiler to optimise inline function by passing constant into
2499 * these functions */
2500 if (pFormat[0] == FC_C_CSTRING) {
2502 pFormat);
2503 array_buffer_size(FC_C_CSTRING, pStubMsg, pMemory, pFormat,
2504 TRUE /* fHasPointers */);
2505 } else {
2507 pFormat);
2508 array_buffer_size(FC_C_WSTRING, pStubMsg, pMemory, pFormat,
2509 TRUE /* fHasPointers */);
2510 }
2511}
2512
2513/************************************************************************
2514 * NdrConformantStringMemorySize [RPCRT4.@]
2515 */
2517 PFORMAT_STRING pFormat )
2518{
2519 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
2520
2521 if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
2522 ERR("Unhandled string type: %#x\n", pFormat[0]);
2524 }
2525
2526 /* allow compiler to optimise inline function by passing constant into
2527 * these functions */
2528 if (pFormat[0] == FC_C_CSTRING) {
2529 array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
2530 array_memory_size(FC_C_CSTRING, pStubMsg, pFormat,
2531 TRUE /* fHasPointers */);
2532 } else {
2533 array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
2534 array_memory_size(FC_C_WSTRING, pStubMsg, pFormat,
2535 TRUE /* fHasPointers */);
2536 }
2537
2538 return pStubMsg->MemorySize;
2539}
2540
2541/************************************************************************
2542 * NdrConformantStringUnmarshall [RPCRT4.@]
2543 */
2545 unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc )
2546{
2547 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
2548 pStubMsg, *ppMemory, pFormat, fMustAlloc);
2549
2550 if (pFormat[0] != FC_C_CSTRING && pFormat[0] != FC_C_WSTRING) {
2551 ERR("Unhandled string type: %#x\n", *pFormat);
2553 }
2554
2555 /* allow compiler to optimise inline function by passing constant into
2556 * these functions */
2557 if (pFormat[0] == FC_C_CSTRING) {
2558 array_read_conformance(FC_C_CSTRING, pStubMsg, pFormat);
2560 pFormat, fMustAlloc,
2561 TRUE /* fUseBufferMemoryServer */,
2562 TRUE /* fUnmarshall */);
2563 } else {
2564 array_read_conformance(FC_C_WSTRING, pStubMsg, pFormat);
2566 pFormat, fMustAlloc,
2567 TRUE /* fUseBufferMemoryServer */,
2568 TRUE /* fUnmarshall */);
2569 }
2570
2571 return NULL;
2572}
2573
2574/***********************************************************************
2575 * NdrNonConformantStringMarshall [RPCRT4.@]
2576 */
2578 unsigned char *pMemory,
2579 PFORMAT_STRING pFormat)
2580{
2581 ULONG esize, size, maxsize;
2582
2583 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
2584
2585 maxsize = *(const USHORT *)&pFormat[2];
2586
2587 if (*pFormat == FC_CSTRING)
2588 {
2589 ULONG i = 0;
2590 const char *str = (const char *)pMemory;
2591 while (i < maxsize && str[i]) i++;
2592 TRACE("string=%s\n", debugstr_an(str, i));
2593 pStubMsg->ActualCount = i + 1;
2594 esize = 1;
2595 }
2596 else if (*pFormat == FC_WSTRING)
2597 {
2598 ULONG i = 0;
2599 const WCHAR *str = (const WCHAR *)pMemory;
2600 while (i < maxsize && str[i]) i++;
2601 TRACE("string=%s\n", debugstr_wn(str, i));
2602 pStubMsg->ActualCount = i + 1;
2603 esize = 2;
2604 }
2605 else
2606 {
2607 ERR("Unhandled string type: %#x\n", *pFormat);
2609 }
2610
2611 pStubMsg->Offset = 0;
2612 WriteVariance(pStubMsg);
2613
2614 size = safe_multiply(esize, pStubMsg->ActualCount);
2615 safe_copy_to_buffer(pStubMsg, pMemory, size); /* the string itself */
2616
2617 return NULL;
2618}
2619
2620/***********************************************************************
2621 * NdrNonConformantStringUnmarshall [RPCRT4.@]
2622 */
2624 unsigned char **ppMemory,
2625 PFORMAT_STRING pFormat,
2626 unsigned char fMustAlloc)
2627{
2628 ULONG bufsize, memsize, esize, maxsize;
2629
2630 TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n",
2631 pStubMsg, *ppMemory, pFormat, fMustAlloc);
2632
2633 maxsize = *(const USHORT *)&pFormat[2];
2634
2635 ReadVariance(pStubMsg, NULL, maxsize);
2636 if (pStubMsg->Offset)
2637 {
2638 ERR("non-conformant strings can't have Offset (%ld)\n", pStubMsg->Offset);
2640 }
2641
2642 if (*pFormat == FC_CSTRING) esize = 1;
2643 else if (*pFormat == FC_WSTRING) esize = 2;
2644 else
2645 {
2646 ERR("Unhandled string type: %#x\n", *pFormat);
2648 }
2649
2650 memsize = esize * maxsize;
2651 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2652
2653 validate_string_data(pStubMsg, bufsize, esize);
2654
2655 if (!fMustAlloc && !*ppMemory)
2656 fMustAlloc = TRUE;
2657 if (fMustAlloc)
2658 *ppMemory = NdrAllocate(pStubMsg, memsize);
2659
2660 safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
2661
2662 if (*pFormat == FC_CSTRING) {
2663 TRACE("string=%s\n", debugstr_an((char*)*ppMemory, pStubMsg->ActualCount));
2664 }
2665 else if (*pFormat == FC_WSTRING) {
2666 TRACE("string=%s\n", debugstr_wn((LPWSTR)*ppMemory, pStubMsg->ActualCount));
2667 }
2668
2669 return NULL;
2670}
2671
2672/***********************************************************************
2673 * NdrNonConformantStringBufferSize [RPCRT4.@]
2674 */
2676 unsigned char *pMemory,
2677 PFORMAT_STRING pFormat)
2678{
2679 ULONG esize, maxsize;
2680
2681 TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
2682
2683 maxsize = *(const USHORT *)&pFormat[2];
2684
2685 SizeVariance(pStubMsg);
2686
2687 if (*pFormat == FC_CSTRING)
2688 {
2689 ULONG i = 0;
2690 const char *str = (const char *)pMemory;
2691 while (i < maxsize && str[i]) i++;
2692 TRACE("string=%s\n", debugstr_an(str, i));
2693 pStubMsg->ActualCount = i + 1;
2694 esize = 1;
2695 }
2696 else if (*pFormat == FC_WSTRING)
2697 {
2698 ULONG i = 0;
2699 const WCHAR *str = (const WCHAR *)pMemory;
2700 while (i < maxsize && str[i]) i++;
2701 TRACE("string=%s\n", debugstr_wn(str, i));
2702 pStubMsg->ActualCount = i + 1;
2703 esize = 2;
2704 }
2705 else
2706 {
2707 ERR("Unhandled string type: %#x\n", *pFormat);
2709 }
2710
2711 safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
2712}
2713
2714/***********************************************************************
2715 * NdrNonConformantStringMemorySize [RPCRT4.@]
2716 */
2718 PFORMAT_STRING pFormat)
2719{
2720 ULONG bufsize, memsize, esize, maxsize;
2721
2722 TRACE("(pStubMsg == ^%p, pFormat == ^%p)\n", pStubMsg, pFormat);
2723
2724 maxsize = *(const USHORT *)&pFormat[2];
2725
2726 ReadVariance(pStubMsg, NULL, maxsize);
2727
2728 if (pStubMsg->Offset)
2729 {
2730 ERR("non-conformant strings can't have Offset (%ld)\n", pStubMsg->Offset);
2732 }
2733
2734 if (*pFormat == FC_CSTRING) esize = 1;
2735 else if (*pFormat == FC_WSTRING) esize = 2;
2736 else
2737 {
2738 ERR("Unhandled string type: %#x\n", *pFormat);
2740 }
2741
2742 memsize = esize * maxsize;
2743 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
2744
2745 validate_string_data(pStubMsg, bufsize, esize);
2746
2747 safe_buffer_increment(pStubMsg, bufsize);
2748 pStubMsg->MemorySize += memsize;
2749
2750 return pStubMsg->MemorySize;
2751}
2752
2753/* Complex types */
2754
2755#include "pshpack1.h"
2756typedef struct
2757{
2758 unsigned char type;
2759 unsigned char flags_type; /* flags in upper nibble, type in lower nibble */
2762} NDR_RANGE;
2763#include "poppack.h"
2764
2766 PFORMAT_STRING pFormat)
2767{
2768 switch (*pFormat) {
2769 case FC_STRUCT:
2770 case FC_PSTRUCT:
2771 case FC_CSTRUCT:
2772 case FC_BOGUS_STRUCT:
2773 case FC_SMFARRAY:
2774 case FC_SMVARRAY:
2775 case FC_CSTRING:
2776 return *(const WORD*)&pFormat[2];
2777 case FC_LGFARRAY:
2778 case FC_LGVARRAY:
2779 return *(const ULONG*)&pFormat[2];
2780 case FC_USER_MARSHAL:
2781 return *(const WORD*)&pFormat[4];
2782 case FC_RANGE: {
2783 switch (((const NDR_RANGE *)pFormat)->flags_type & 0xf) {
2784 case FC_BYTE:
2785 case FC_CHAR:
2786 case FC_SMALL:
2787 case FC_USMALL:
2788 return sizeof(UCHAR);
2789 case FC_WCHAR:
2790 case FC_SHORT:
2791 case FC_USHORT:
2792 return sizeof(USHORT);
2793 case FC_LONG:
2794 case FC_ULONG:
2795 case FC_ENUM32:
2796 return sizeof(ULONG);
2797 case FC_FLOAT:
2798 return sizeof(float);
2799 case FC_DOUBLE:
2800 return sizeof(double);
2801 case FC_HYPER:
2802 return sizeof(ULONGLONG);
2803 case FC_ENUM16:
2804 return sizeof(UINT);
2805 default:
2806 ERR("unknown type 0x%x\n", ((const NDR_RANGE *)pFormat)->flags_type & 0xf);
2808 }
2809 }
2811 pFormat += 2;
2812 pFormat = SkipConformance(pStubMsg, pFormat);
2813 pFormat += *(const SHORT*)pFormat;
2814 return *(const SHORT*)pFormat;
2815 case FC_IP:
2816 return sizeof(void *);
2817 case FC_WSTRING:
2818 return *(const WORD*)&pFormat[2] * 2;
2819 default:
2820 FIXME("unhandled embedded type %02x\n", *pFormat);
2821 }
2822 return 0;
2823}
2824
2825
2827 PFORMAT_STRING pFormat)
2828{
2830
2831 if (!m)
2832 {
2833 FIXME("no memorysizer for data type=%02x\n", *pFormat);
2834 return 0;
2835 }
2836
2837 return m(pStubMsg, pFormat);
2838}
2839
2840
2841static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg,
2842 unsigned char *pMemory,
2843 PFORMAT_STRING pFormat,
2844 PFORMAT_STRING pPointer)
2845{
2846 unsigned char *mem_base = pMemory;
2849 ULONG size;
2850
2851 while (*pFormat != FC_END) {
2852 switch (*pFormat) {
2853 case FC_BYTE:
2854 case FC_CHAR:
2855 case FC_SMALL:
2856 case FC_USMALL:
2857 TRACE("byte=%d <= %p\n", *(WORD*)pMemory, pMemory);
2858 safe_copy_to_buffer(pStubMsg, pMemory, 1);
2859 pMemory += 1;
2860 break;
2861 case FC_WCHAR:
2862 case FC_SHORT:
2863 case FC_USHORT:
2864 TRACE("short=%d <= %p\n", *(WORD*)pMemory, pMemory);
2865 safe_copy_to_buffer(pStubMsg, pMemory, 2);
2866 pMemory += 2;
2867 break;
2868 case FC_ENUM16:
2869 {
2870 USHORT val = *(DWORD *)pMemory;
2871 TRACE("enum16=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
2872 if (32767 < *(DWORD*)pMemory)
2874 safe_copy_to_buffer(pStubMsg, &val, 2);
2875 pMemory += 4;
2876 break;
2877 }
2878 case FC_LONG:
2879 case FC_ULONG:
2880 case FC_ENUM32:
2881 TRACE("long=%ld <= %p\n", *(DWORD*)pMemory, pMemory);
2882 safe_copy_to_buffer(pStubMsg, pMemory, 4);
2883 pMemory += 4;
2884 break;
2885 case FC_INT3264:
2886 case FC_UINT3264:
2887 {
2888 UINT val = *(UINT_PTR *)pMemory;
2889 TRACE("int3264=%Id <= %p\n", *(UINT_PTR *)pMemory, pMemory);
2890 safe_copy_to_buffer(pStubMsg, &val, sizeof(UINT));
2891 pMemory += sizeof(UINT_PTR);
2892 break;
2893 }
2894 case FC_FLOAT:
2895 TRACE("float=%f <= %p\n", *(float*)pMemory, pMemory);
2896 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
2897 pMemory += sizeof(float);
2898 break;
2899 case FC_HYPER:
2900 TRACE("longlong=%s <= %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
2901 safe_copy_to_buffer(pStubMsg, pMemory, 8);
2902 pMemory += 8;
2903 break;
2904 case FC_DOUBLE:
2905 TRACE("double=%f <= %p\n", *(double*)pMemory, pMemory);
2906 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
2907 pMemory += sizeof(double);
2908 break;
2909 case FC_RP:
2910 case FC_UP:
2911 case FC_OP:
2912 case FC_FP:
2913 case FC_POINTER:
2914 {
2915 unsigned char *saved_buffer;
2916 BOOL pointer_buffer_mark_set = FALSE;
2917 TRACE("pointer=%p <= %p\n", *(unsigned char**)pMemory, pMemory);
2918 TRACE("pStubMsg->Buffer before %p\n", pStubMsg->Buffer);
2919 if (*pFormat != FC_POINTER)
2920 pPointer = pFormat;
2921 if (*pPointer != FC_RP)
2922 align_pointer_clear(&pStubMsg->Buffer, 4);
2923 saved_buffer = pStubMsg->Buffer;
2924 if (pStubMsg->PointerBufferMark)
2925 {
2926 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
2927 pStubMsg->PointerBufferMark = NULL;
2928 pointer_buffer_mark_set = TRUE;
2929 }
2930 else if (*pPointer != FC_RP)
2931 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
2932 PointerMarshall(pStubMsg, saved_buffer, *(unsigned char**)pMemory, pPointer);
2933 if (pointer_buffer_mark_set)
2934 {
2935 STD_OVERFLOW_CHECK(pStubMsg);
2936 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
2937 pStubMsg->Buffer = saved_buffer;
2938 if (*pPointer != FC_RP)
2939 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
2940 }
2941 TRACE("pStubMsg->Buffer after %p\n", pStubMsg->Buffer);
2942 if (*pFormat == FC_POINTER)
2943 pPointer += 4;
2944 else
2945 pFormat += 4;
2946 pMemory += sizeof(void *);
2947 break;
2948 }
2949 case FC_ALIGNM2:
2950 align_pointer_offset(&pMemory, mem_base, 2);
2951 break;
2952 case FC_ALIGNM4:
2953 align_pointer_offset(&pMemory, mem_base, 4);
2954 break;
2955 case FC_ALIGNM8:
2956 align_pointer_offset(&pMemory, mem_base, 8);
2957 break;
2958 case FC_STRUCTPAD1:
2959 case FC_STRUCTPAD2:
2960 case FC_STRUCTPAD3:
2961 case FC_STRUCTPAD4:
2962 case FC_STRUCTPAD5:
2963 case FC_STRUCTPAD6:
2964 case FC_STRUCTPAD7:
2965 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
2966 break;
2968 pMemory += pFormat[1];
2969 pFormat += 2;
2970 desc = pFormat + *(const SHORT*)pFormat;
2971 size = EmbeddedComplexSize(pStubMsg, desc);
2972 TRACE("embedded complex (size=%ld) <= %p\n", size, pMemory);
2974 if (m)
2975 {
2976 /* for some reason interface pointers aren't generated as
2977 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
2978 * they still need the dereferencing treatment that pointers are
2979 * given */
2980 if (*desc == FC_IP)
2981 m(pStubMsg, *(unsigned char **)pMemory, desc);
2982 else
2983 m(pStubMsg, pMemory, desc);
2984 }
2985 else FIXME("no marshaller for embedded type %02x\n", *desc);
2986 pMemory += size;
2987 pFormat += 2;
2988 continue;
2989 case FC_PAD:
2990 break;
2991 default:
2992 FIXME("unhandled format 0x%02x\n", *pFormat);
2993 }
2994 pFormat++;
2995 }
2996
2997 return pMemory;
2998}
2999
3000static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
3001 unsigned char *pMemory,
3002 PFORMAT_STRING pFormat,
3003 PFORMAT_STRING pPointer,
3004 unsigned char fMustAlloc)
3005{
3006 unsigned char *mem_base = pMemory;
3009 ULONG size;
3010
3011 while (*pFormat != FC_END) {
3012 switch (*pFormat) {
3013 case FC_BYTE:
3014 case FC_CHAR:
3015 case FC_SMALL:
3016 case FC_USMALL:
3017 safe_copy_from_buffer(pStubMsg, pMemory, 1);
3018 TRACE("byte=%d => %p\n", *(WORD*)pMemory, pMemory);
3019 pMemory += 1;
3020 break;
3021 case FC_WCHAR:
3022 case FC_SHORT:
3023 case FC_USHORT:
3024 safe_copy_from_buffer(pStubMsg, pMemory, 2);
3025 TRACE("short=%d => %p\n", *(WORD*)pMemory, pMemory);
3026 pMemory += 2;
3027 break;
3028 case FC_ENUM16:
3029 {
3030 WORD val;
3031 safe_copy_from_buffer(pStubMsg, &val, 2);
3032 *(DWORD*)pMemory = val;
3033 TRACE("enum16=%ld => %p\n", *(DWORD*)pMemory, pMemory);
3034 if (32767 < *(DWORD*)pMemory)
3036 pMemory += 4;
3037 break;
3038 }
3039 case FC_LONG:
3040 case FC_ULONG:
3041 case FC_ENUM32:
3042 safe_copy_from_buffer(pStubMsg, pMemory, 4);
3043 TRACE("long=%ld => %p\n", *(DWORD*)pMemory, pMemory);
3044 pMemory += 4;
3045 break;
3046 case FC_INT3264:
3047 {
3048 INT val;
3049 safe_copy_from_buffer(pStubMsg, &val, 4);
3050 *(INT_PTR *)pMemory = val;
3051 TRACE("int3264=%Id => %p\n", *(INT_PTR*)pMemory, pMemory);
3052 pMemory += sizeof(INT_PTR);
3053 break;
3054 }
3055 case FC_UINT3264:
3056 {
3057 UINT val;
3058 safe_copy_from_buffer(pStubMsg, &val, 4);
3059 *(UINT_PTR *)pMemory = val;
3060 TRACE("uint3264=%Id => %p\n", *(UINT_PTR*)pMemory, pMemory);
3061 pMemory += sizeof(UINT_PTR);
3062 break;
3063 }
3064 case FC_FLOAT:
3065 safe_copy_from_buffer(pStubMsg, pMemory, sizeof(float));
3066 TRACE("float=%f => %p\n", *(float*)pMemory, pMemory);
3067 pMemory += sizeof(float);
3068 break;
3069 case FC_HYPER:
3070 safe_copy_from_buffer(pStubMsg, pMemory, 8);
3071 TRACE("longlong=%s => %p\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory), pMemory);
3072 pMemory += 8;
3073 break;
3074 case FC_DOUBLE:
3075 safe_copy_from_buffer(pStubMsg, pMemory, sizeof(double));
3076 TRACE("double=%f => %p\n", *(double*)pMemory, pMemory);
3077 pMemory += sizeof(double);
3078 break;
3079 case FC_RP:
3080 case FC_UP:
3081 case FC_OP:
3082 case FC_FP:
3083 case FC_POINTER:
3084 {
3085 unsigned char *saved_buffer;
3086 BOOL pointer_buffer_mark_set = FALSE;
3087 TRACE("pointer => %p\n", pMemory);
3088 if (*pFormat != FC_POINTER)
3089 pPointer = pFormat;
3090 if (*pPointer != FC_RP)
3091 align_pointer(&pStubMsg->Buffer, 4);
3092 saved_buffer = pStubMsg->Buffer;
3093 if (pStubMsg->PointerBufferMark)
3094 {
3095 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3096 pStubMsg->PointerBufferMark = NULL;
3097 pointer_buffer_mark_set = TRUE;
3098 }
3099 else if (*pPointer != FC_RP)
3100 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3101
3102 PointerUnmarshall(pStubMsg, saved_buffer, (unsigned char**)pMemory, *(unsigned char**)pMemory, pPointer, fMustAlloc);
3103 if (pointer_buffer_mark_set)
3104 {
3105 STD_OVERFLOW_CHECK(pStubMsg);
3106 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
3107 pStubMsg->Buffer = saved_buffer;
3108 if (*pPointer != FC_RP)
3109 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3110 }
3111 if (*pFormat == FC_POINTER)
3112 pPointer += 4;
3113 else
3114 pFormat += 4;
3115 pMemory += sizeof(void *);
3116 break;
3117 }
3118 case FC_ALIGNM2:
3119 align_pointer_offset_clear(&pMemory, mem_base, 2);
3120 break;
3121 case FC_ALIGNM4:
3122 align_pointer_offset_clear(&pMemory, mem_base, 4);
3123 break;
3124 case FC_ALIGNM8:
3125 align_pointer_offset_clear(&pMemory, mem_base, 8);
3126 break;
3127 case FC_STRUCTPAD1:
3128 case FC_STRUCTPAD2:
3129 case FC_STRUCTPAD3:
3130 case FC_STRUCTPAD4:
3131 case FC_STRUCTPAD5:
3132 case FC_STRUCTPAD6:
3133 case FC_STRUCTPAD7:
3134 memset(pMemory, 0, *pFormat - FC_STRUCTPAD1 + 1);
3135 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3136 break;
3138 pMemory += pFormat[1];
3139 pFormat += 2;
3140 desc = pFormat + *(const SHORT*)pFormat;
3141 size = EmbeddedComplexSize(pStubMsg, desc);
3142 TRACE("embedded complex (size=%ld) => %p\n", size, pMemory);
3143 if (fMustAlloc)
3144 /* we can't pass fMustAlloc=TRUE into the marshaller for this type
3145 * since the type is part of the memory block that is encompassed by
3146 * the whole complex type. Memory is forced to allocate when pointers
3147 * are set to NULL, so we emulate that part of fMustAlloc=TRUE by
3148 * clearing the memory we pass in to the unmarshaller */
3149 memset(pMemory, 0, size);
3151 if (m)
3152 {
3153 /* for some reason interface pointers aren't generated as
3154 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3155 * they still need the dereferencing treatment that pointers are
3156 * given */
3157 if (*desc == FC_IP)
3158 m(pStubMsg, (unsigned char **)pMemory, desc, FALSE);
3159 else
3160 m(pStubMsg, &pMemory, desc, FALSE);
3161 }
3162 else FIXME("no unmarshaller for embedded type %02x\n", *desc);
3163 pMemory += size;
3164 pFormat += 2;
3165 continue;
3166 case FC_PAD:
3167 break;
3168 default:
3169 FIXME("unhandled format %d\n", *pFormat);
3170 }
3171 pFormat++;
3172 }
3173
3174 return pMemory;
3175}
3176
3177static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
3178 unsigned char *pMemory,
3179 PFORMAT_STRING pFormat,
3180 PFORMAT_STRING pPointer)
3181{
3182 unsigned char *mem_base = pMemory;
3185 ULONG size;
3186
3187 while (*pFormat != FC_END) {
3188 switch (*pFormat) {
3189 case FC_BYTE:
3190 case FC_CHAR:
3191 case FC_SMALL:
3192 case FC_USMALL:
3193 safe_buffer_length_increment(pStubMsg, 1);
3194 pMemory += 1;
3195 break;
3196 case FC_WCHAR:
3197 case FC_SHORT:
3198 case FC_USHORT:
3199 safe_buffer_length_increment(pStubMsg, 2);
3200 pMemory += 2;
3201 break;
3202 case FC_ENUM16:
3203 safe_buffer_length_increment(pStubMsg, 2);
3204 pMemory += 4;
3205 break;
3206 case FC_LONG:
3207 case FC_ULONG:
3208 case FC_ENUM32:
3209 case FC_FLOAT:
3210 safe_buffer_length_increment(pStubMsg, 4);
3211 pMemory += 4;
3212 break;
3213 case FC_INT3264:
3214 case FC_UINT3264:
3215 safe_buffer_length_increment(pStubMsg, 4);
3216 pMemory += sizeof(INT_PTR);
3217 break;
3218 case FC_HYPER:
3219 case FC_DOUBLE:
3220 safe_buffer_length_increment(pStubMsg, 8);
3221 pMemory += 8;
3222 break;
3223 case FC_RP:
3224 case FC_UP:
3225 case FC_OP:
3226 case FC_FP:
3227 case FC_POINTER:
3228 if (*pFormat != FC_POINTER)
3229 pPointer = pFormat;
3230 if (!pStubMsg->IgnoreEmbeddedPointers)
3231 {
3232 int saved_buffer_length = pStubMsg->BufferLength;
3233 pStubMsg->BufferLength = pStubMsg->PointerLength;
3234 pStubMsg->PointerLength = 0;
3235 if(!pStubMsg->BufferLength)
3236 ERR("BufferLength == 0??\n");
3237 PointerBufferSize(pStubMsg, *(unsigned char**)pMemory, pPointer);
3238 pStubMsg->PointerLength = pStubMsg->BufferLength;
3239 pStubMsg->BufferLength = saved_buffer_length;
3240 }
3241 if (*pPointer != FC_RP)
3242 {
3243 align_length(&pStubMsg->BufferLength, 4);
3244 safe_buffer_length_increment(pStubMsg, 4);
3245 }
3246 if (*pFormat == FC_POINTER)
3247 pPointer += 4;
3248 else
3249 pFormat += 4;
3250 pMemory += sizeof(void*);
3251 break;
3252 case FC_ALIGNM2:
3253 align_pointer_offset(&pMemory, mem_base, 2);
3254 break;
3255 case FC_ALIGNM4:
3256 align_pointer_offset(&pMemory, mem_base, 4);
3257 break;
3258 case FC_ALIGNM8:
3259 align_pointer_offset(&pMemory, mem_base, 8);
3260 break;
3261 case FC_STRUCTPAD1:
3262 case FC_STRUCTPAD2:
3263 case FC_STRUCTPAD3:
3264 case FC_STRUCTPAD4:
3265 case FC_STRUCTPAD5:
3266 case FC_STRUCTPAD6:
3267 case FC_STRUCTPAD7:
3268 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3269 break;
3271 pMemory += pFormat[1];
3272 pFormat += 2;
3273 desc = pFormat + *(const SHORT*)pFormat;
3274 size = EmbeddedComplexSize(pStubMsg, desc);
3276 if (m)
3277 {
3278 /* for some reason interface pointers aren't generated as
3279 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3280 * they still need the dereferencing treatment that pointers are
3281 * given */
3282 if (*desc == FC_IP)
3283 m(pStubMsg, *(unsigned char **)pMemory, desc);
3284 else
3285 m(pStubMsg, pMemory, desc);
3286 }
3287 else FIXME("no buffersizer for embedded type %02x\n", *desc);
3288 pMemory += size;
3289 pFormat += 2;
3290 continue;
3291 case FC_PAD:
3292 break;
3293 default:
3294 FIXME("unhandled format 0x%02x\n", *pFormat);
3295 }
3296 pFormat++;
3297 }
3298
3299 return pMemory;
3300}
3301
3302static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg,
3303 unsigned char *pMemory,
3304 PFORMAT_STRING pFormat,
3305 PFORMAT_STRING pPointer)
3306{
3307 unsigned char *mem_base = pMemory;
3309 NDR_FREE m;
3310 ULONG size;
3311
3312 while (*pFormat != FC_END) {
3313 switch (*pFormat) {
3314 case FC_BYTE:
3315 case FC_CHAR:
3316 case FC_SMALL:
3317 case FC_USMALL:
3318 pMemory += 1;
3319 break;
3320 case FC_WCHAR:
3321 case FC_SHORT:
3322 case FC_USHORT:
3323 pMemory += 2;
3324 break;
3325 case FC_LONG:
3326 case FC_ULONG:
3327 case FC_ENUM16:
3328 case FC_ENUM32:
3329 case FC_FLOAT:
3330 pMemory += 4;
3331 break;
3332 case FC_INT3264:
3333 case FC_UINT3264:
3334 pMemory += sizeof(INT_PTR);
3335 break;
3336 case FC_HYPER:
3337 case FC_DOUBLE:
3338 pMemory += 8;
3339 break;
3340 case FC_RP:
3341 case FC_UP:
3342 case FC_OP:
3343 case FC_FP:
3344 case FC_POINTER:
3345 if (*pFormat != FC_POINTER)
3346 pPointer = pFormat;
3347 NdrPointerFree(pStubMsg, *(unsigned char**)pMemory, pPointer);
3348 if (*pFormat == FC_POINTER)
3349 pPointer += 4;
3350 else
3351 pFormat += 4;
3352 pMemory += sizeof(void *);
3353 break;
3354 case FC_ALIGNM2:
3355 align_pointer_offset(&pMemory, mem_base, 2);
3356 break;
3357 case FC_ALIGNM4:
3358 align_pointer_offset(&pMemory, mem_base, 4);
3359 break;
3360 case FC_ALIGNM8:
3361 align_pointer_offset(&pMemory, mem_base, 8);
3362 break;
3363 case FC_STRUCTPAD1:
3364 case FC_STRUCTPAD2:
3365 case FC_STRUCTPAD3:
3366 case FC_STRUCTPAD4:
3367 case FC_STRUCTPAD5:
3368 case FC_STRUCTPAD6:
3369 case FC_STRUCTPAD7:
3370 pMemory += *pFormat - FC_STRUCTPAD1 + 1;
3371 break;
3373 pMemory += pFormat[1];
3374 pFormat += 2;
3375 desc = pFormat + *(const SHORT*)pFormat;
3376 size = EmbeddedComplexSize(pStubMsg, desc);
3378 if (m)
3379 {
3380 /* for some reason interface pointers aren't generated as
3381 * FC_POINTER, but instead as FC_EMBEDDED_COMPLEX, yet
3382 * they still need the dereferencing treatment that pointers are
3383 * given */
3384 if (*desc == FC_IP)
3385 m(pStubMsg, *(unsigned char **)pMemory, desc);
3386 else
3387 m(pStubMsg, pMemory, desc);
3388 }
3389 pMemory += size;
3390 pFormat += 2;
3391 continue;
3392 case FC_PAD:
3393 break;
3394 default:
3395 FIXME("unhandled format 0x%02x\n", *pFormat);
3396 }
3397 pFormat++;
3398 }
3399
3400 return pMemory;
3401}
3402
3404 PFORMAT_STRING pFormat,
3405 PFORMAT_STRING pPointer)
3406{
3408 ULONG size = 0;
3409
3410 while (*pFormat != FC_END) {
3411 switch (*pFormat) {
3412 case FC_BYTE:
3413 case FC_CHAR:
3414 case FC_SMALL:
3415 case FC_USMALL:
3416 size += 1;
3417 safe_buffer_increment(pStubMsg, 1);
3418 break;
3419 case FC_WCHAR:
3420 case FC_SHORT:
3421 case FC_USHORT:
3422 size += 2;
3423 safe_buffer_increment(pStubMsg, 2);
3424 break;
3425 case FC_ENUM16:
3426 size += 4;
3427 safe_buffer_increment(pStubMsg, 2);
3428 break;
3429 case FC_LONG:
3430 case FC_ULONG:
3431 case FC_ENUM32:
3432 case FC_FLOAT:
3433 size += 4;
3434 safe_buffer_increment(pStubMsg, 4);
3435 break;
3436 case FC_INT3264:
3437 case FC_UINT3264:
3438 size += sizeof(INT_PTR);
3439 safe_buffer_increment(pStubMsg, 4);
3440 break;
3441 case FC_HYPER:
3442 case FC_DOUBLE:
3443 size += 8;
3444 safe_buffer_increment(pStubMsg, 8);
3445 break;
3446 case FC_RP:
3447 case FC_UP:
3448 case FC_OP:
3449 case FC_FP:
3450 case FC_POINTER:
3451 {
3452 unsigned char *saved_buffer;
3453 BOOL pointer_buffer_mark_set = FALSE;
3454 if (*pFormat != FC_POINTER)
3455 pPointer = pFormat;
3456 if (*pPointer != FC_RP)
3457 align_pointer(&pStubMsg->Buffer, 4);
3458 saved_buffer = pStubMsg->Buffer;
3459 if (pStubMsg->PointerBufferMark)
3460 {
3461 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3462 pStubMsg->PointerBufferMark = NULL;
3463 pointer_buffer_mark_set = TRUE;
3464 }
3465 else if (*pPointer != FC_RP)
3466 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3467
3468 if (!pStubMsg->IgnoreEmbeddedPointers)
3469 PointerMemorySize(pStubMsg, saved_buffer, pPointer);
3470 if (pointer_buffer_mark_set)
3471 {
3472 STD_OVERFLOW_CHECK(pStubMsg);
3473 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
3474 pStubMsg->Buffer = saved_buffer;
3475 if (*pPointer != FC_RP)
3476 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
3477 }
3478 if (*pFormat == FC_POINTER)
3479 pPointer += 4;
3480 else
3481 pFormat += 4;
3482 size += sizeof(void *);
3483 break;
3484 }
3485 case FC_ALIGNM2:
3486 align_length(&size, 2);
3487 break;
3488 case FC_ALIGNM4:
3489 align_length(&size, 4);
3490 break;
3491 case FC_ALIGNM8:
3492 align_length(&size, 8);
3493 break;
3494 case FC_STRUCTPAD1:
3495 case FC_STRUCTPAD2:
3496 case FC_STRUCTPAD3:
3497 case FC_STRUCTPAD4:
3498 case FC_STRUCTPAD5:
3499 case FC_STRUCTPAD6:
3500 case FC_STRUCTPAD7:
3501 size += *pFormat - FC_STRUCTPAD1 + 1;
3502 break;
3504 size += pFormat[1];
3505 pFormat += 2;
3506 desc = pFormat + *(const SHORT*)pFormat;
3507 size += EmbeddedComplexMemorySize(pStubMsg, desc);
3508 pFormat += 2;
3509 continue;
3510 case FC_PAD:
3511 break;
3512 default:
3513 FIXME("unhandled format 0x%02x\n", *pFormat);
3514 }
3515 pFormat++;
3516 }
3517
3518 return size;
3519}
3520
3522{
3524 ULONG size = 0;
3525
3526 while (*pFormat != FC_END) {
3527 switch (*pFormat) {
3528 case FC_BYTE:
3529 case FC_CHAR:
3530 case FC_SMALL:
3531 case FC_USMALL:
3532 size += 1;
3533 break;
3534 case FC_WCHAR:
3535 case FC_SHORT:
3536 case FC_USHORT:
3537 size += 2;
3538 break;
3539 case FC_LONG:
3540 case FC_ULONG:
3541 case FC_ENUM16:
3542 case FC_ENUM32:
3543 case FC_FLOAT:
3544 size += 4;
3545 break;
3546 case FC_INT3264:
3547 case FC_UINT3264:
3548 size += sizeof(INT_PTR);
3549 break;
3550 case FC_HYPER:
3551 case FC_DOUBLE:
3552 size += 8;
3553 break;
3554 case FC_RP:
3555 case FC_UP:
3556 case FC_OP:
3557 case FC_FP:
3558 case FC_POINTER:
3559 size += sizeof(void *);
3560 if (*pFormat != FC_POINTER)
3561 pFormat += 4;
3562 break;
3563 case FC_ALIGNM2:
3564 align_length(&size, 2);
3565 break;
3566 case FC_ALIGNM4:
3567 align_length(&size, 4);
3568 break;
3569 case FC_ALIGNM8:
3570 align_length(&size, 8);
3571 break;
3572 case FC_STRUCTPAD1:
3573 case FC_STRUCTPAD2:
3574 case FC_STRUCTPAD3:
3575 case FC_STRUCTPAD4:
3576 case FC_STRUCTPAD5:
3577 case FC_STRUCTPAD6:
3578 case FC_STRUCTPAD7:
3579 size += *pFormat - FC_STRUCTPAD1 + 1;
3580 break;
3582 size += pFormat[1];
3583 pFormat += 2;
3584 desc = pFormat + *(const SHORT*)pFormat;
3585 size += EmbeddedComplexSize(pStubMsg, desc);
3586 pFormat += 2;
3587 continue;
3588 case FC_PAD:
3589 break;
3590 default:
3591 FIXME("unhandled format 0x%02x\n", *pFormat);
3592 }
3593 pFormat++;
3594 }
3595
3596 return size;
3597}
3598
3599/***********************************************************************
3600 * NdrComplexStructMarshall [RPCRT4.@]
3601 */
3603 unsigned char *pMemory,
3604 PFORMAT_STRING pFormat)
3605{
3606 PFORMAT_STRING conf_array = NULL;
3607 PFORMAT_STRING pointer_desc = NULL;
3608 unsigned char *OldMemory = pStubMsg->Memory;
3609 BOOL pointer_buffer_mark_set = FALSE;
3610 ULONG count = 0;
3611 ULONG max_count = 0;
3612 ULONG offset = 0;
3613
3614 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
3615
3616 if (!pStubMsg->PointerBufferMark)
3617 {
3618 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
3619 /* save buffer length */
3620 ULONG saved_buffer_length = pStubMsg->BufferLength;
3621
3622 /* get the buffer pointer after complex array data, but before
3623 * pointer data */
3624 pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
3625 pStubMsg->IgnoreEmbeddedPointers = 1;
3626 NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat);
3627 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
3628
3629 /* save it for use by embedded pointer code later */
3630 pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
3631 TRACE("difference = 0x%Ix\n", pStubMsg->PointerBufferMark - pStubMsg->Buffer);
3632 pointer_buffer_mark_set = TRUE;
3633
3634 /* restore the original buffer length */
3635 pStubMsg->BufferLength = saved_buffer_length;
3636 }
3637
3638 align_pointer_clear(&pStubMsg->Buffer, pFormat[1] + 1);
3639
3640 pFormat += 4;
3641 if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
3642 pFormat += 2;
3643 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
3644 pFormat += 2;
3645
3646 pStubMsg->Memory = pMemory;
3647
3648 if (conf_array)
3649 {
3650 ULONG struct_size = ComplexStructSize(pStubMsg, pFormat);
3651 array_compute_and_write_conformance(conf_array[0], pStubMsg,
3652 pMemory + struct_size, conf_array);
3653 /* these could be changed in ComplexMarshall so save them for later */
3654 max_count = pStubMsg->MaxCount;
3655 count = pStubMsg->ActualCount;
3656 offset = pStubMsg->Offset;
3657 }
3658
3659 pMemory = ComplexMarshall(pStubMsg, pMemory, pFormat, pointer_desc);
3660
3661 if (conf_array)
3662 {
3663 pStubMsg->MaxCount = max_count;
3664 pStubMsg->ActualCount = count;
3665 pStubMsg->Offset = offset;
3666 array_write_variance_and_marshall(conf_array[0], pStubMsg, pMemory,
3667 conf_array, TRUE /* fHasPointers */);
3668 }
3669
3670 pStubMsg->Memory = OldMemory;
3671
3672 if (pointer_buffer_mark_set)
3673 {
3674 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3675 pStubMsg->PointerBufferMark = NULL;
3676 }
3677
3678 STD_OVERFLOW_CHECK(pStubMsg);
3679
3680 return NULL;
3681}
3682
3683/***********************************************************************
3684 * NdrComplexStructUnmarshall [RPCRT4.@]
3685 */
3687 unsigned char **ppMemory,
3688 PFORMAT_STRING pFormat,
3689 unsigned char fMustAlloc)
3690{
3691 unsigned size = *(const WORD*)(pFormat+2);
3692 PFORMAT_STRING conf_array = NULL;
3693 PFORMAT_STRING pointer_desc = NULL;
3694 unsigned char *pMemory;
3695 BOOL pointer_buffer_mark_set = FALSE;
3696 ULONG count = 0;
3697 ULONG max_count = 0;
3698 ULONG offset = 0;
3699 ULONG array_size = 0;
3700
3701 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
3702
3703 if (!pStubMsg->PointerBufferMark)
3704 {
3705 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
3706 /* save buffer pointer */
3707 unsigned char *saved_buffer = pStubMsg->Buffer;
3708
3709 /* get the buffer pointer after complex array data, but before
3710 * pointer data */
3711 pStubMsg->IgnoreEmbeddedPointers = 1;
3712 NdrComplexStructMemorySize(pStubMsg, pFormat);
3713 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
3714
3715 /* save it for use by embedded pointer code later */
3716 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
3717 TRACE("difference = 0x%Ix\n", pStubMsg->PointerBufferMark - saved_buffer);
3718 pointer_buffer_mark_set = TRUE;
3719
3720 /* restore the original buffer */
3721 pStubMsg->Buffer = saved_buffer;
3722 }
3723
3724 align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
3725
3726 pFormat += 4;
3727 if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
3728 pFormat += 2;
3729 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
3730 pFormat += 2;
3731
3732 if (conf_array)
3733 {
3734 array_size = array_read_conformance(conf_array[0], pStubMsg, conf_array);
3735 size += array_size;
3736
3737 /* these could be changed in ComplexMarshall so save them for later */
3738 max_count = pStubMsg->MaxCount;
3739 count = pStubMsg->ActualCount;
3740 offset = pStubMsg->Offset;
3741 }
3742
3743 if (!fMustAlloc && !*ppMemory)
3744 fMustAlloc = TRUE;
3745 if (fMustAlloc)
3746 *ppMemory = NdrAllocateZero(pStubMsg, size);
3747
3748 pMemory = ComplexUnmarshall(pStubMsg, *ppMemory, pFormat, pointer_desc, fMustAlloc);
3749
3750 if (conf_array)
3751 {
3752 pStubMsg->MaxCount = max_count;
3753 pStubMsg->ActualCount = count;
3754 pStubMsg->Offset = offset;
3755 if (fMustAlloc)
3757 array_read_variance_and_unmarshall(conf_array[0], pStubMsg, &pMemory,
3758 conf_array, FALSE,
3759 FALSE /* fUseBufferMemoryServer */,
3760 TRUE /* fUnmarshall */);
3761 }
3762
3763 if (pointer_buffer_mark_set)
3764 {
3765 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
3766 pStubMsg->PointerBufferMark = NULL;
3767 }
3768
3769 return NULL;
3770}
3771
3772/***********************************************************************
3773 * NdrComplexStructBufferSize [RPCRT4.@]
3774 */
3776 unsigned char *pMemory,
3777 PFORMAT_STRING pFormat)
3778{
3779 PFORMAT_STRING conf_array = NULL;
3780 PFORMAT_STRING pointer_desc = NULL;
3781 unsigned char *OldMemory = pStubMsg->Memory;
3782 int pointer_length_set = 0;
3783 ULONG count = 0;
3784 ULONG max_count = 0;
3785 ULONG offset = 0;
3786
3787 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
3788
3789 align_length(&pStubMsg->BufferLength, pFormat[1] + 1);
3790
3791 if(!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
3792 {
3793 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
3794 ULONG saved_buffer_length = pStubMsg->BufferLength;
3795
3796 /* get the buffer length after complex struct data, but before
3797 * pointer data */
3798 pStubMsg->IgnoreEmbeddedPointers = 1;
3799 NdrComplexStructBufferSize(pStubMsg, pMemory, pFormat);
3800 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
3801
3802 /* save it for use by embedded pointer code later */
3803 pStubMsg->PointerLength = pStubMsg->BufferLength;
3804 pointer_length_set = 1;
3805 TRACE("difference = 0x%lx\n", pStubMsg->PointerLength - saved_buffer_length);
3806
3807 /* restore the original buffer length */
3808 pStubMsg->BufferLength = saved_buffer_length;
3809 }
3810
3811 pFormat += 4;
3812 if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
3813 pFormat += 2;
3814 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
3815 pFormat += 2;
3816
3817 pStubMsg->Memory = pMemory;
3818
3819 if (conf_array)
3820 {
3821 ULONG struct_size = ComplexStructSize(pStubMsg, pFormat);
3822 array_compute_and_size_conformance(conf_array[0], pStubMsg, pMemory + struct_size,
3823 conf_array);
3824
3825 /* these could be changed in ComplexMarshall so save them for later */
3826 max_count = pStubMsg->MaxCount;
3827 count = pStubMsg->ActualCount;
3828 offset = pStubMsg->Offset;
3829 }
3830
3831 pMemory = ComplexBufferSize(pStubMsg, pMemory, pFormat, pointer_desc);
3832
3833 if (conf_array)
3834 {
3835 pStubMsg->MaxCount = max_count;
3836 pStubMsg->ActualCount = count;
3837 pStubMsg->Offset = offset;
3838 array_buffer_size(conf_array[0], pStubMsg, pMemory, conf_array,
3839 TRUE /* fHasPointers */);
3840 }
3841
3842 pStubMsg->Memory = OldMemory;
3843
3844 if(pointer_length_set)
3845 {
3846 pStubMsg->BufferLength = pStubMsg->PointerLength;
3847 pStubMsg->PointerLength = 0;
3848 }
3849
3850}
3851
3852/***********************************************************************
3853 * NdrComplexStructMemorySize [RPCRT4.@]
3854 */
3856 PFORMAT_STRING pFormat)
3857{
3858 unsigned size = *(const WORD*)(pFormat+2);
3859 PFORMAT_STRING conf_array = NULL;
3860 PFORMAT_STRING pointer_desc = NULL;
3861 ULONG count = 0;
3862 ULONG max_count = 0;
3863 ULONG offset = 0;
3864
3865 TRACE("(%p,%p)\n", pStubMsg, pFormat);
3866
3867 align_pointer(&pStubMsg->Buffer, pFormat[1] + 1);
3868
3869 pFormat += 4;
3870 if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
3871 pFormat += 2;
3872 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
3873 pFormat += 2;
3874
3875 if (conf_array)
3876 {
3877 array_read_conformance(conf_array[0], pStubMsg, conf_array);
3878
3879 /* these could be changed in ComplexStructMemorySize so save them for
3880 * later */
3881 max_count = pStubMsg->MaxCount;
3882 count = pStubMsg->ActualCount;
3883 offset = pStubMsg->Offset;
3884 }
3885
3886 ComplexStructMemorySize(pStubMsg, pFormat, pointer_desc);
3887
3888 if (conf_array)
3889 {
3890 pStubMsg->MaxCount = max_count;
3891 pStubMsg->ActualCount = count;
3892 pStubMsg->Offset = offset;
3893 array_memory_size(conf_array[0], pStubMsg, conf_array,
3894 TRUE /* fHasPointers */);
3895 }
3896
3897 return size;
3898}
3899
3900/***********************************************************************
3901 * NdrComplexStructFree [RPCRT4.@]
3902 */
3904 unsigned char *pMemory,
3905 PFORMAT_STRING pFormat)
3906{
3907 PFORMAT_STRING conf_array = NULL;
3908 PFORMAT_STRING pointer_desc = NULL;
3909 unsigned char *OldMemory = pStubMsg->Memory;
3910
3911 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
3912
3913 pFormat += 4;
3914 if (*(const SHORT*)pFormat) conf_array = pFormat + *(const SHORT*)pFormat;
3915 pFormat += 2;
3916 if (*(const WORD*)pFormat) pointer_desc = pFormat + *(const WORD*)pFormat;
3917 pFormat += 2;
3918
3919 pStubMsg->Memory = pMemory;
3920
3921 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, pointer_desc);
3922
3923 if (conf_array)
3924 array_free(conf_array[0], pStubMsg, pMemory, conf_array,
3925 TRUE /* fHasPointers */);
3926
3927 pStubMsg->Memory = OldMemory;
3928}
3929
3930/***********************************************************************
3931 * NdrConformantArrayMarshall [RPCRT4.@]
3932 */
3934 unsigned char *pMemory,
3935 PFORMAT_STRING pFormat)
3936{
3937 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
3938 if (pFormat[0] != FC_CARRAY)
3939 {
3940 ERR("invalid format = 0x%x\n", pFormat[0]);
3942 }
3943
3945 pFormat);
3947 TRUE /* fHasPointers */);
3948
3949 return NULL;
3950}
3951
3952/***********************************************************************
3953 * NdrConformantArrayUnmarshall [RPCRT4.@]
3954 */
3956 unsigned char **ppMemory,
3957 PFORMAT_STRING pFormat,
3958 unsigned char fMustAlloc)
3959{
3960 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
3961 if (pFormat[0] != FC_CARRAY)
3962 {
3963 ERR("invalid format = 0x%x\n", pFormat[0]);
3965 }
3966
3967 array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
3968 array_read_variance_and_unmarshall(FC_CARRAY, pStubMsg, ppMemory, pFormat,
3969 fMustAlloc,
3970 TRUE /* fUseBufferMemoryServer */,
3971 TRUE /* fUnmarshall */);
3972
3973 return NULL;
3974}
3975
3976/***********************************************************************
3977 * NdrConformantArrayBufferSize [RPCRT4.@]
3978 */
3980 unsigned char *pMemory,
3981 PFORMAT_STRING pFormat)
3982{
3983 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
3984 if (pFormat[0] != FC_CARRAY)
3985 {
3986 ERR("invalid format = 0x%x\n", pFormat[0]);
3988 }
3989
3991 array_buffer_size(FC_CARRAY, pStubMsg, pMemory, pFormat,
3992 TRUE /* fHasPointers */);
3993}
3994
3995/***********************************************************************
3996 * NdrConformantArrayMemorySize [RPCRT4.@]
3997 */
3999 PFORMAT_STRING pFormat)
4000{
4001 TRACE("(%p,%p)\n", pStubMsg, pFormat);
4002 if (pFormat[0] != FC_CARRAY)
4003 {
4004 ERR("invalid format = 0x%x\n", pFormat[0]);
4006 }
4007
4008 array_read_conformance(FC_CARRAY, pStubMsg, pFormat);
4009 array_memory_size(FC_CARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
4010
4011 return pStubMsg->MemorySize;
4012}
4013
4014/***********************************************************************
4015 * NdrConformantArrayFree [RPCRT4.@]
4016 */
4018 unsigned char *pMemory,
4019 PFORMAT_STRING pFormat)
4020{
4021 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4022 if (pFormat[0] != FC_CARRAY)
4023 {
4024 ERR("invalid format = 0x%x\n", pFormat[0]);
4026 }
4027
4028 array_free(FC_CARRAY, pStubMsg, pMemory, pFormat,
4029 TRUE /* fHasPointers */);
4030}
4031
4032
4033/***********************************************************************
4034 * NdrConformantVaryingArrayMarshall [RPCRT4.@]
4035 */
4037 unsigned char* pMemory,
4038 PFORMAT_STRING pFormat )
4039{
4040 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4041
4042 if (pFormat[0] != FC_CVARRAY)
4043 {
4044 ERR("invalid format type %x\n", pFormat[0]);
4046 return NULL;
4047 }
4048
4050 pFormat);
4052 pFormat, TRUE /* fHasPointers */);
4053
4054 return NULL;
4055}
4056
4057
4058/***********************************************************************
4059 * NdrConformantVaryingArrayUnmarshall [RPCRT4.@]
4060 */
4062 unsigned char** ppMemory,
4063 PFORMAT_STRING pFormat,
4064 unsigned char fMustAlloc )
4065{
4066 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
4067
4068 if (pFormat[0] != FC_CVARRAY)
4069 {
4070 ERR("invalid format type %x\n", pFormat[0]);
4072 return NULL;
4073 }
4074
4075 array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
4077 pFormat, fMustAlloc,
4078 TRUE /* fUseBufferMemoryServer */,
4079 TRUE /* fUnmarshall */);
4080
4081 return NULL;
4082}
4083
4084
4085/***********************************************************************
4086 * NdrConformantVaryingArrayFree [RPCRT4.@]
4087 */
4089 unsigned char* pMemory,
4090 PFORMAT_STRING pFormat )
4091{
4092 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4093
4094 if (pFormat[0] != FC_CVARRAY)
4095 {
4096 ERR("invalid format type %x\n", pFormat[0]);
4098 return;
4099 }
4100
4101 array_free(FC_CVARRAY, pStubMsg, pMemory, pFormat,
4102 TRUE /* fHasPointers */);
4103}
4104
4105
4106/***********************************************************************
4107 * NdrConformantVaryingArrayBufferSize [RPCRT4.@]
4108 */
4110 unsigned char* pMemory, PFORMAT_STRING pFormat )
4111{
4112 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4113
4114 if (pFormat[0] != FC_CVARRAY)
4115 {
4116 ERR("invalid format type %x\n", pFormat[0]);
4118 return;
4119 }
4120
4122 pFormat);
4123 array_buffer_size(FC_CVARRAY, pStubMsg, pMemory, pFormat,
4124 TRUE /* fHasPointers */);
4125}
4126
4127
4128/***********************************************************************
4129 * NdrConformantVaryingArrayMemorySize [RPCRT4.@]
4130 */
4132 PFORMAT_STRING pFormat )
4133{
4134 TRACE("(%p, %p)\n", pStubMsg, pFormat);
4135
4136 if (pFormat[0] != FC_CVARRAY)
4137 {
4138 ERR("invalid format type %x\n", pFormat[0]);
4140 return pStubMsg->MemorySize;
4141 }
4142
4143 array_read_conformance(FC_CVARRAY, pStubMsg, pFormat);
4144 array_memory_size(FC_CVARRAY, pStubMsg, pFormat,
4145 TRUE /* fHasPointers */);
4146
4147 return pStubMsg->MemorySize;
4148}
4149
4150
4151/***********************************************************************
4152 * NdrComplexArrayMarshall [RPCRT4.@]
4153 */
4155 unsigned char *pMemory,
4156 PFORMAT_STRING pFormat)
4157{
4158 BOOL pointer_buffer_mark_set = FALSE;
4159
4160 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4161
4162 if (pFormat[0] != FC_BOGUS_ARRAY)
4163 {
4164 ERR("invalid format type %x\n", pFormat[0]);
4166 return NULL;
4167 }
4168
4169 if (!pStubMsg->PointerBufferMark)
4170 {
4171 /* save buffer fields that may be changed by buffer sizer functions
4172 * and that may be needed later on */
4173 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
4174 ULONG saved_buffer_length = pStubMsg->BufferLength;
4175 ULONG_PTR saved_max_count = pStubMsg->MaxCount;
4176 ULONG saved_offset = pStubMsg->Offset;
4177 ULONG saved_actual_count = pStubMsg->ActualCount;
4178
4179 /* get the buffer pointer after complex array data, but before
4180 * pointer data */
4181 pStubMsg->BufferLength = pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer;
4182 pStubMsg->IgnoreEmbeddedPointers = 1;
4183 NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
4184 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
4185
4186 /* save it for use by embedded pointer code later */
4187 pStubMsg->PointerBufferMark = (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength;
4188 TRACE("difference = 0x%Ix\n", pStubMsg->Buffer - (unsigned char *)pStubMsg->RpcMsg->Buffer);
4189 pointer_buffer_mark_set = TRUE;
4190
4191 /* restore fields */
4192 pStubMsg->ActualCount = saved_actual_count;
4193 pStubMsg->Offset = saved_offset;
4194 pStubMsg->MaxCount = saved_max_count;
4195 pStubMsg->BufferLength = saved_buffer_length;
4196 }
4197
4200 pMemory, pFormat, TRUE /* fHasPointers */);
4201
4202 STD_OVERFLOW_CHECK(pStubMsg);
4203
4204 if (pointer_buffer_mark_set)
4205 {
4206 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
4207 pStubMsg->PointerBufferMark = NULL;
4208 }
4209
4210 return NULL;
4211}
4212
4213/***********************************************************************
4214 * NdrComplexArrayUnmarshall [RPCRT4.@]
4215 */
4217 unsigned char **ppMemory,
4218 PFORMAT_STRING pFormat,
4219 unsigned char fMustAlloc)
4220{
4221 unsigned char *saved_buffer;
4222 BOOL pointer_buffer_mark_set = FALSE;
4223 int saved_ignore_embedded;
4224
4225 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
4226
4227 if (pFormat[0] != FC_BOGUS_ARRAY)
4228 {
4229 ERR("invalid format type %x\n", pFormat[0]);
4231 return NULL;
4232 }
4233
4234 saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
4235 /* save buffer pointer */
4236 saved_buffer = pStubMsg->Buffer;
4237 /* get the buffer pointer after complex array data, but before
4238 * pointer data */
4239 pStubMsg->IgnoreEmbeddedPointers = 1;
4240 pStubMsg->MemorySize = 0;
4241 NdrComplexArrayMemorySize(pStubMsg, pFormat);
4242 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
4243
4244 TRACE("difference = 0x%Ix\n", pStubMsg->Buffer - saved_buffer);
4245 if (!pStubMsg->PointerBufferMark)
4246 {
4247 /* save it for use by embedded pointer code later */
4248 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
4249 pointer_buffer_mark_set = TRUE;
4250 }
4251 /* restore the original buffer */
4252 pStubMsg->Buffer = saved_buffer;
4253
4254 array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
4255 array_read_variance_and_unmarshall(FC_BOGUS_ARRAY, pStubMsg, ppMemory, pFormat, fMustAlloc,
4256 TRUE /* fUseBufferMemoryServer */, TRUE /* fUnmarshall */);
4257
4258 if (pointer_buffer_mark_set)
4259 {
4260 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
4261 pStubMsg->PointerBufferMark = NULL;
4262 }
4263
4264 return NULL;
4265}
4266
4267/***********************************************************************
4268 * NdrComplexArrayBufferSize [RPCRT4.@]
4269 */
4271 unsigned char *pMemory,
4272 PFORMAT_STRING pFormat)
4273{
4274 int pointer_length_set = 0;
4275
4276 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4277
4278 if (pFormat[0] != FC_BOGUS_ARRAY)
4279 {
4280 ERR("invalid format type %x\n", pFormat[0]);
4282 return;
4283 }
4284
4285 if (!pStubMsg->IgnoreEmbeddedPointers && !pStubMsg->PointerLength)
4286 {
4287 /* save buffer fields that may be changed by buffer sizer functions
4288 * and that may be needed later on */
4289 int saved_ignore_embedded = pStubMsg->IgnoreEmbeddedPointers;
4290 ULONG saved_buffer_length = pStubMsg->BufferLength;
4291 ULONG_PTR saved_max_count = pStubMsg->MaxCount;
4292 ULONG saved_offset = pStubMsg->Offset;
4293 ULONG saved_actual_count = pStubMsg->ActualCount;
4294
4295 /* get the buffer pointer after complex array data, but before
4296 * pointer data */
4297 pStubMsg->IgnoreEmbeddedPointers = 1;
4298 NdrComplexArrayBufferSize(pStubMsg, pMemory, pFormat);
4299 pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded;
4300
4301 /* save it for use by embedded pointer code later */
4302 pStubMsg->PointerLength = pStubMsg->BufferLength;
4303 pointer_length_set = 1;
4304
4305 /* restore fields */
4306 pStubMsg->ActualCount = saved_actual_count;
4307 pStubMsg->Offset = saved_offset;
4308 pStubMsg->MaxCount = saved_max_count;
4309 pStubMsg->BufferLength = saved_buffer_length;
4310 }
4311
4313 array_buffer_size(FC_BOGUS_ARRAY, pStubMsg, pMemory, pFormat, TRUE /* fHasPointers */);
4314
4315 if(pointer_length_set)
4316 {
4317 pStubMsg->BufferLength = pStubMsg->PointerLength;
4318 pStubMsg->PointerLength = 0;
4319 }
4320}
4321
4322/***********************************************************************
4323 * NdrComplexArrayMemorySize [RPCRT4.@]
4324 */
4326 PFORMAT_STRING pFormat)
4327{
4328 TRACE("(%p,%p)\n", pStubMsg, pFormat);
4329
4330 if (pFormat[0] != FC_BOGUS_ARRAY)
4331 {
4332 ERR("invalid format type %x\n", pFormat[0]);
4334 return 0;
4335 }
4336
4337 array_read_conformance(FC_BOGUS_ARRAY, pStubMsg, pFormat);
4338 array_memory_size(FC_BOGUS_ARRAY, pStubMsg, pFormat, TRUE /* fHasPointers */);
4339 return pStubMsg->MemorySize;
4340}
4341
4342/***********************************************************************
4343 * NdrComplexArrayFree [RPCRT4.@]
4344 */
4346 unsigned char *pMemory,
4347 PFORMAT_STRING pFormat)
4348{
4349 ULONG i, count, def;
4350
4351 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4352
4353 if (pFormat[0] != FC_BOGUS_ARRAY)
4354 {
4355 ERR("invalid format type %x\n", pFormat[0]);
4357 return;
4358 }
4359
4360 def = *(const WORD*)&pFormat[2];
4361 pFormat += 4;
4362
4363 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, def);
4364 TRACE("conformance = %Id\n", pStubMsg->MaxCount);
4365
4366 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, pStubMsg->MaxCount);
4367 TRACE("variance = %ld\n", pStubMsg->ActualCount);
4368
4369 count = pStubMsg->ActualCount;
4370 for (i = 0; i < count; i++)
4371 pMemory = ComplexFree(pStubMsg, pMemory, pFormat, NULL);
4372}
4373
4375 USER_MARSHAL_CB_TYPE cbtype, PFORMAT_STRING pFormat,
4376 USER_MARSHAL_CB *umcb)
4377{
4378 umcb->Flags = MAKELONG(pStubMsg->dwDestContext,
4379 pStubMsg->RpcMsg->DataRepresentation);
4380 umcb->pStubMsg = pStubMsg;
4381 umcb->pReserve = NULL;
4383 umcb->CBType = cbtype;
4384 umcb->pFormat = pFormat;
4385 umcb->pTypeFormat = NULL /* FIXME */;
4386}
4387
4388#define USER_MARSHAL_PTR_PREFIX \
4389 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
4390 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
4391
4392/***********************************************************************
4393 * NdrUserMarshalMarshall [RPCRT4.@]
4394 */
4396 unsigned char *pMemory,
4397 PFORMAT_STRING pFormat)
4398{
4399 unsigned flags = pFormat[1];
4400 unsigned index = *(const WORD*)&pFormat[2];
4401 unsigned char *saved_buffer = NULL;
4402 USER_MARSHAL_CB umcb;
4403
4404 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4405 TRACE("index=%d\n", index);
4406
4407 UserMarshalCB(pStubMsg, USER_MARSHAL_CB_MARSHALL, pFormat, &umcb);
4408
4410 {
4411 align_pointer_clear(&pStubMsg->Buffer, 4);
4413 pStubMsg->Buffer += 4;
4414 if (pStubMsg->PointerBufferMark)
4415 {
4416 saved_buffer = pStubMsg->Buffer;
4417 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
4418 pStubMsg->PointerBufferMark = NULL;
4419 }
4420 align_pointer_clear(&pStubMsg->Buffer, 8);
4421 }
4422 else
4423 align_pointer_clear(&pStubMsg->Buffer, (flags & 0xf) + 1);
4424
4425 pStubMsg->Buffer =
4426 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnMarshall(
4427 &umcb.Flags, pStubMsg->Buffer, pMemory);
4428
4429 if (saved_buffer)
4430 {
4431 STD_OVERFLOW_CHECK(pStubMsg);
4432 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
4433 pStubMsg->Buffer = saved_buffer;
4434 }
4435
4436 STD_OVERFLOW_CHECK(pStubMsg);
4437
4438 return NULL;
4439}
4440
4441/***********************************************************************
4442 * NdrUserMarshalUnmarshall [RPCRT4.@]
4443 */
4445 unsigned char **ppMemory,
4446 PFORMAT_STRING pFormat,
4447 unsigned char fMustAlloc)
4448{
4449 unsigned flags = pFormat[1];
4450 unsigned index = *(const WORD*)&pFormat[2];
4451 DWORD memsize = *(const WORD*)&pFormat[4];
4452 unsigned char *saved_buffer = NULL;
4453 USER_MARSHAL_CB umcb;
4454
4455 TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
4456 TRACE("index=%d\n", index);
4457
4458 UserMarshalCB(pStubMsg, USER_MARSHAL_CB_UNMARSHALL, pFormat, &umcb);
4459
4461 {
4462 align_pointer(&pStubMsg->Buffer, 4);
4463 /* skip pointer prefix */
4464 pStubMsg->Buffer += 4;
4465 if (pStubMsg->PointerBufferMark)
4466 {
4467 saved_buffer = pStubMsg->Buffer;
4468 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
4469 pStubMsg->PointerBufferMark = NULL;
4470 }
4471 align_pointer(&pStubMsg->Buffer, 8);
4472 }
4473 else
4474 align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
4475
4476 if (!fMustAlloc && !*ppMemory)
4477 fMustAlloc = TRUE;
4478 if (fMustAlloc)
4479 {
4480 *ppMemory = NdrAllocate(pStubMsg, memsize);
4481 memset(*ppMemory, 0, memsize);
4482 }
4483
4484 pStubMsg->Buffer =
4485 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnUnmarshall(
4486 &umcb.Flags, pStubMsg->Buffer, *ppMemory);
4487
4488 if (saved_buffer)
4489 {
4490 STD_OVERFLOW_CHECK(pStubMsg);
4491 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
4492 pStubMsg->Buffer = saved_buffer;
4493 }
4494
4495 return NULL;
4496}
4497
4498/***********************************************************************
4499 * NdrUserMarshalBufferSize [RPCRT4.@]
4500 */
4502 unsigned char *pMemory,
4503 PFORMAT_STRING pFormat)
4504{
4505 unsigned flags = pFormat[1];
4506 unsigned index = *(const WORD*)&pFormat[2];
4507 DWORD bufsize = *(const WORD*)&pFormat[6];
4508 USER_MARSHAL_CB umcb;
4509 ULONG saved_buffer_length = 0;
4510
4511 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4512 TRACE("index=%d\n", index);
4513
4514 UserMarshalCB(pStubMsg, USER_MARSHAL_CB_BUFFER_SIZE, pFormat, &umcb);
4515
4517 {
4518 align_length(&pStubMsg->BufferLength, 4);
4519 /* skip pointer prefix */
4520 safe_buffer_length_increment(pStubMsg, 4);
4521 if (pStubMsg->IgnoreEmbeddedPointers)
4522 return;
4523 if (pStubMsg->PointerLength)
4524 {
4525 saved_buffer_length = pStubMsg->BufferLength;
4526 pStubMsg->BufferLength = pStubMsg->PointerLength;
4527 pStubMsg->PointerLength = 0;
4528 }
4529 align_length(&pStubMsg->BufferLength, 8);
4530 }
4531 else
4532 align_length(&pStubMsg->BufferLength, (flags & 0xf) + 1);
4533
4534 if (bufsize) {
4535 TRACE("size=%ld\n", bufsize);
4537 }
4538 else
4539 pStubMsg->BufferLength =
4540 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnBufferSize(
4541 &umcb.Flags, pStubMsg->BufferLength, pMemory);
4542
4543 if (saved_buffer_length)
4544 {
4545 pStubMsg->PointerLength = pStubMsg->BufferLength;
4546 pStubMsg->BufferLength = saved_buffer_length;
4547 }
4548
4549}
4550
4551/***********************************************************************
4552 * NdrUserMarshalMemorySize [RPCRT4.@]
4553 */
4555 PFORMAT_STRING pFormat)
4556{
4557 unsigned flags = pFormat[1];
4558 unsigned index = *(const WORD*)&pFormat[2];
4559 DWORD memsize = *(const WORD*)&pFormat[4];
4560 DWORD bufsize = *(const WORD*)&pFormat[6];
4561
4562 TRACE("(%p,%p)\n", pStubMsg, pFormat);
4563 TRACE("index=%d\n", index);
4564
4565 pStubMsg->MemorySize += memsize;
4566
4568 {
4569 align_pointer(&pStubMsg->Buffer, 4);
4570 /* skip pointer prefix */
4571 pStubMsg->Buffer += 4;
4572 if (pStubMsg->IgnoreEmbeddedPointers)
4573 return pStubMsg->MemorySize;
4574 align_pointer(&pStubMsg->Buffer, 8);
4575 }
4576 else
4577 align_pointer(&pStubMsg->Buffer, (flags & 0xf) + 1);
4578
4579 if (!bufsize)
4580 FIXME("not implemented for varying buffer size\n");
4581
4582 pStubMsg->Buffer += bufsize;
4583
4584 return pStubMsg->MemorySize;
4585}
4586
4587/***********************************************************************
4588 * NdrUserMarshalFree [RPCRT4.@]
4589 */
4591 unsigned char *pMemory,
4592 PFORMAT_STRING pFormat)
4593{
4594/* unsigned flags = pFormat[1]; */
4595 unsigned index = *(const WORD*)&pFormat[2];
4596 USER_MARSHAL_CB umcb;
4597
4598 TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
4599 TRACE("index=%d\n", index);
4600
4601 UserMarshalCB(pStubMsg, USER_MARSHAL_CB_FREE, pFormat, &umcb);
4602
4603 pStubMsg->StubDesc->aUserMarshalQuadruple[index].pfnFree(
4604 &umcb.Flags, pMemory);
4605}
4606
4607/***********************************************************************
4608 * NdrGetUserMarshalInfo [RPCRT4.@]
4609 */
4611{
4613
4614 TRACE("(%p,%lu,%p)\n", flags, level, umi);
4615
4616 if (level != 1)
4617 return RPC_S_INVALID_ARG;
4618
4619 memset(&umi->Level1, 0, sizeof(umi->Level1));
4620 umi->InformationLevel = level;
4621
4623 return RPC_S_INVALID_ARG;
4624
4625 umi->Level1.pfnAllocate = umcb->pStubMsg->pfnAllocate;
4626 umi->Level1.pfnFree = umcb->pStubMsg->pfnFree;
4628
4629 switch (umcb->CBType)
4630 {
4633 {
4634 RPC_MESSAGE *msg = umcb->pStubMsg->RpcMsg;
4635 unsigned char *buffer_start = msg->Buffer;
4636 unsigned char *buffer_end =
4637 (unsigned char *)msg->Buffer + msg->BufferLength;
4638
4639 if (umcb->pStubMsg->Buffer < buffer_start ||
4640 umcb->pStubMsg->Buffer > buffer_end)
4641 return RPC_X_INVALID_BUFFER;
4642
4643 umi->Level1.Buffer = umcb->pStubMsg->Buffer;
4644 umi->Level1.BufferSize = buffer_end - umcb->pStubMsg->Buffer;
4645 break;
4646 }
4649 break;
4650 default:
4651 WARN("unrecognised CBType %d\n", umcb->CBType);
4652 }
4653
4654 return RPC_S_OK;
4655}
4656
4657/***********************************************************************
4658 * NdrClearOutParameters [RPCRT4.@]
4659 */
4661 PFORMAT_STRING pFormat,
4662 void *ArgAddr)
4663{
4664 FIXME("(%p,%p,%p): stub\n", pStubMsg, pFormat, ArgAddr);
4665}
4666
4667/***********************************************************************
4668 * NdrConvert [RPCRT4.@]
4669 */
4671{
4672 FIXME("(pStubMsg == ^%p, pFormat == ^%p): stub.\n", pStubMsg, pFormat);
4673 /* FIXME: since this stub doesn't do any converting, the proper behavior
4674 is to raise an exception */
4675}
4676
4677/***********************************************************************
4678 * NdrConvert2 [RPCRT4.@]
4679 */
4680void WINAPI NdrConvert2( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, LONG NumberParams )
4681{
4682 FIXME("(pStubMsg == ^%p, pFormat == ^%p, NumberParams == %ld): stub.\n",
4683 pStubMsg, pFormat, NumberParams);
4684 /* FIXME: since this stub doesn't do any converting, the proper behavior
4685 is to raise an exception */
4686}
4687
4688#include "pshpack1.h"
4690{
4691 unsigned char type;
4692 unsigned char alignment;
4693 unsigned short memory_size;
4696#include "poppack.h"
4697
4698/***********************************************************************
4699 * NdrConformantStructMarshall [RPCRT4.@]
4700 */
4702 unsigned char *pMemory,
4703 PFORMAT_STRING pFormat)
4704{
4705 const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
4706 PFORMAT_STRING pCArrayFormat;
4707 ULONG esize, bufsize;
4708
4709 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4710
4711 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
4712 if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
4713 {
4714 ERR("invalid format type %x\n", pCStructFormat->type);
4716 return NULL;
4717 }
4718
4719 pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
4720 pCStructFormat->offset_to_array_description;
4721 if (*pCArrayFormat != FC_CARRAY)
4722 {
4723 ERR("invalid array format type %x\n", pCStructFormat->type);
4725 return NULL;
4726 }
4727 esize = *(const WORD*)(pCArrayFormat+2);
4728
4729 ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size,
4730 pCArrayFormat + 4, 0);
4731
4732 WriteConformance(pStubMsg);
4733
4734 align_pointer_clear(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
4735
4736 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
4737
4738 bufsize = safe_multiply(esize, pStubMsg->MaxCount);
4739 if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */
4740 {
4741 ERR("integer overflow of memory_size %u with bufsize %lu\n",
4742 pCStructFormat->memory_size, bufsize);
4744 }
4745 /* copy constant sized part of struct */
4746 pStubMsg->BufferMark = pStubMsg->Buffer;
4747 safe_copy_to_buffer(pStubMsg, pMemory, pCStructFormat->memory_size + bufsize);
4748
4749 if (pCStructFormat->type == FC_CPSTRUCT)
4750 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
4751
4752 return NULL;
4753}
4754
4755/***********************************************************************
4756 * NdrConformantStructUnmarshall [RPCRT4.@]
4757 */
4759 unsigned char **ppMemory,
4760 PFORMAT_STRING pFormat,
4761 unsigned char fMustAlloc)
4762{
4763 const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
4764 PFORMAT_STRING pCArrayFormat;
4765 ULONG esize, bufsize;
4766 unsigned char *saved_buffer;
4767
4768 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
4769
4770 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
4771 if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
4772 {
4773 ERR("invalid format type %x\n", pCStructFormat->type);
4775 return NULL;
4776 }
4777 pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
4778 pCStructFormat->offset_to_array_description;
4779 if (*pCArrayFormat != FC_CARRAY)
4780 {
4781 ERR("invalid array format type %x\n", pCStructFormat->type);
4783 return NULL;
4784 }
4785 esize = *(const WORD*)(pCArrayFormat+2);
4786
4787 pCArrayFormat = ReadConformance(pStubMsg, pCArrayFormat + 4);
4788
4789 align_pointer(&pStubMsg->Buffer, pCStructFormat->alignment + 1);
4790
4791 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
4792
4793 bufsize = safe_multiply(esize, pStubMsg->MaxCount);
4794 if (pCStructFormat->memory_size + bufsize < pCStructFormat->memory_size) /* integer overflow */
4795 {
4796 ERR("integer overflow of memory_size %u with bufsize %lu\n",
4797 pCStructFormat->memory_size, bufsize);
4799 }
4800
4801 if (fMustAlloc)
4802 {
4803 SIZE_T size = pCStructFormat->memory_size + bufsize;
4804 *ppMemory = NdrAllocateZero(pStubMsg, size);
4805 }
4806 else
4807 {
4808 if (!pStubMsg->IsClient && !*ppMemory)
4809 /* for servers, we just point straight into the RPC buffer */
4810 *ppMemory = pStubMsg->Buffer;
4811 }
4812
4813 saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
4814 safe_buffer_increment(pStubMsg, pCStructFormat->memory_size + bufsize);
4815 if (pCStructFormat->type == FC_CPSTRUCT)
4816 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
4817
4818 TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
4819 if (*ppMemory != saved_buffer)
4820 memcpy(*ppMemory, saved_buffer, pCStructFormat->memory_size + bufsize);
4821
4822 return NULL;
4823}
4824
4825/***********************************************************************
4826 * NdrConformantStructBufferSize [RPCRT4.@]
4827 */
4829 unsigned char *pMemory,
4830 PFORMAT_STRING pFormat)
4831{
4832 const NDR_CSTRUCT_FORMAT * pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
4833 PFORMAT_STRING pCArrayFormat;
4834 ULONG esize;
4835
4836 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4837
4838 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
4839 if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
4840 {
4841 ERR("invalid format type %x\n", pCStructFormat->type);
4843 return;
4844 }
4845 pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
4846 pCStructFormat->offset_to_array_description;
4847 if (*pCArrayFormat != FC_CARRAY)
4848 {
4849 ERR("invalid array format type %x\n", pCStructFormat->type);
4851 return;
4852 }
4853 esize = *(const WORD*)(pCArrayFormat+2);
4854
4855 pCArrayFormat = ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size, pCArrayFormat+4, 0);
4856 SizeConformance(pStubMsg);
4857
4858 align_length(&pStubMsg->BufferLength, pCStructFormat->alignment + 1);
4859
4860 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
4861
4862 safe_buffer_length_increment(pStubMsg, pCStructFormat->memory_size);
4863 safe_buffer_length_increment(pStubMsg, safe_multiply(pStubMsg->MaxCount, esize));
4864
4865 if (pCStructFormat->type == FC_CPSTRUCT)
4866 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
4867}
4868
4869/***********************************************************************
4870 * NdrConformantStructMemorySize [RPCRT4.@]
4871 */
4873 PFORMAT_STRING pFormat)
4874{
4875 FIXME("stub\n");
4876 return 0;
4877}
4878
4879/***********************************************************************
4880 * NdrConformantStructFree [RPCRT4.@]
4881 */
4883 unsigned char *pMemory,
4884 PFORMAT_STRING pFormat)
4885{
4886 const NDR_CSTRUCT_FORMAT *pCStructFormat = (const NDR_CSTRUCT_FORMAT *)pFormat;
4887 PFORMAT_STRING pCArrayFormat;
4888
4889 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4890
4891 pFormat += sizeof(NDR_CSTRUCT_FORMAT);
4892 if ((pCStructFormat->type != FC_CPSTRUCT) && (pCStructFormat->type != FC_CSTRUCT))
4893 {
4894 ERR("invalid format type %x\n", pCStructFormat->type);
4896 return;
4897 }
4898
4899 pCArrayFormat = (const unsigned char *)&pCStructFormat->offset_to_array_description +
4900 pCStructFormat->offset_to_array_description;
4901 if (*pCArrayFormat != FC_CARRAY)
4902 {
4903 ERR("invalid array format type %x\n", pCStructFormat->type);
4905 return;
4906 }
4907
4908 ComputeConformance(pStubMsg, pMemory + pCStructFormat->memory_size,
4909 pCArrayFormat + 4, 0);
4910
4911 TRACE("memory_size = %d\n", pCStructFormat->memory_size);
4912
4913 /* copy constant sized part of struct */
4914 pStubMsg->BufferMark = pStubMsg->Buffer;
4915
4916 if (pCStructFormat->type == FC_CPSTRUCT)
4917 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
4918}
4919
4920/***********************************************************************
4921 * NdrConformantVaryingStructMarshall [RPCRT4.@]
4922 */
4924 unsigned char *pMemory,
4925 PFORMAT_STRING pFormat)
4926{
4927 const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
4928 PFORMAT_STRING pCVArrayFormat;
4929
4930 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
4931
4932 pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
4933 if (pCVStructFormat->type != FC_CVSTRUCT)
4934 {
4935 ERR("invalid format type %x\n", pCVStructFormat->type);
4937 return NULL;
4938 }
4939
4940 pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
4941 pCVStructFormat->offset_to_array_description;
4942
4943 array_compute_and_write_conformance(*pCVArrayFormat, pStubMsg,
4944 pMemory + pCVStructFormat->memory_size,
4945 pCVArrayFormat);
4946
4947 align_pointer_clear(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
4948
4949 TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
4950
4951 /* write constant sized part */
4952 pStubMsg->BufferMark = pStubMsg->Buffer;
4953 safe_copy_to_buffer(pStubMsg, pMemory, pCVStructFormat->memory_size);
4954
4955 array_write_variance_and_marshall(*pCVArrayFormat, pStubMsg,
4956 pMemory + pCVStructFormat->memory_size,
4957 pCVArrayFormat, FALSE /* fHasPointers */);
4958
4959 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
4960
4961 return NULL;
4962}
4963
4964/***********************************************************************
4965 * NdrConformantVaryingStructUnmarshall [RPCRT4.@]
4966 */
4968 unsigned char **ppMemory,
4969 PFORMAT_STRING pFormat,
4970 unsigned char fMustAlloc)
4971{
4972 const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
4973 PFORMAT_STRING pCVArrayFormat;
4974 ULONG memsize, bufsize;
4975 unsigned char *saved_buffer, *saved_array_buffer;
4976 ULONG offset;
4977 unsigned char *array_memory;
4978
4979 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
4980
4981 pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
4982 if (pCVStructFormat->type != FC_CVSTRUCT)
4983 {
4984 ERR("invalid format type %x\n", pCVStructFormat->type);
4986 return NULL;
4987 }
4988
4989 pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
4990 pCVStructFormat->offset_to_array_description;
4991
4992 memsize = array_read_conformance(*pCVArrayFormat, pStubMsg,
4993 pCVArrayFormat);
4994
4995 align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
4996
4997 TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
4998
4999 /* work out how much memory to allocate if we need to do so */
5000 if (!fMustAlloc && !*ppMemory)
5001 fMustAlloc = TRUE;
5002 if (fMustAlloc)
5003 {
5004 SIZE_T size = pCVStructFormat->memory_size + memsize;
5005 *ppMemory = NdrAllocateZero(pStubMsg, size);
5006 }
5007
5008 /* mark the start of the constant data */
5009 saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
5010 safe_buffer_increment(pStubMsg, pCVStructFormat->memory_size);
5011
5012 array_memory = *ppMemory + pCVStructFormat->memory_size;
5013 bufsize = array_read_variance_and_unmarshall(*pCVArrayFormat, pStubMsg,
5014 &array_memory, pCVArrayFormat,
5015 FALSE /* fMustAlloc */,
5016 FALSE /* fUseServerBufferMemory */,
5017 FALSE /* fUnmarshall */);
5018
5019 /* save offset in case unmarshalling pointers changes it */
5020 offset = pStubMsg->Offset;
5021
5022 /* mark the start of the array data */
5023 saved_array_buffer = pStubMsg->Buffer;
5024 safe_buffer_increment(pStubMsg, bufsize);
5025
5026 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
5027
5028 /* copy the constant data */
5029 memcpy(*ppMemory, saved_buffer, pCVStructFormat->memory_size);
5030 /* copy the array data */
5031 TRACE("copying %p to %p\n", saved_array_buffer, *ppMemory + pCVStructFormat->memory_size);
5032 memcpy(*ppMemory + pCVStructFormat->memory_size + offset,
5033 saved_array_buffer, bufsize);
5034
5035 if (*pCVArrayFormat == FC_C_CSTRING)
5036 TRACE("string=%s\n", debugstr_a((char *)(*ppMemory + pCVStructFormat->memory_size)));
5037 else if (*pCVArrayFormat == FC_C_WSTRING)
5038 TRACE("string=%s\n", debugstr_w((WCHAR *)(*ppMemory + pCVStructFormat->memory_size)));
5039
5040 return NULL;
5041}
5042
5043/***********************************************************************
5044 * NdrConformantVaryingStructBufferSize [RPCRT4.@]
5045 */
5047 unsigned char *pMemory,
5048 PFORMAT_STRING pFormat)
5049{
5050 const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
5051 PFORMAT_STRING pCVArrayFormat;
5052
5053 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5054
5055 pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
5056 if (pCVStructFormat->type != FC_CVSTRUCT)
5057 {
5058 ERR("invalid format type %x\n", pCVStructFormat->type);
5060 return;
5061 }
5062
5063 pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
5064 pCVStructFormat->offset_to_array_description;
5065 array_compute_and_size_conformance(*pCVArrayFormat, pStubMsg,
5066 pMemory + pCVStructFormat->memory_size,
5067 pCVArrayFormat);
5068
5069 align_length(&pStubMsg->BufferLength, pCVStructFormat->alignment + 1);
5070
5071 TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
5072
5073 safe_buffer_length_increment(pStubMsg, pCVStructFormat->memory_size);
5074
5075 array_buffer_size(*pCVArrayFormat, pStubMsg,
5076 pMemory + pCVStructFormat->memory_size, pCVArrayFormat,
5077 FALSE /* fHasPointers */);
5078
5079 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
5080}
5081
5082/***********************************************************************
5083 * NdrConformantVaryingStructMemorySize [RPCRT4.@]
5084 */
5086 PFORMAT_STRING pFormat)
5087{
5088 const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
5089 PFORMAT_STRING pCVArrayFormat;
5090
5091 TRACE("(%p, %p)\n", pStubMsg, pFormat);
5092
5093 pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
5094 if (pCVStructFormat->type != FC_CVSTRUCT)
5095 {
5096 ERR("invalid format type %x\n", pCVStructFormat->type);
5098 return 0;
5099 }
5100
5101 pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
5102 pCVStructFormat->offset_to_array_description;
5103 array_read_conformance(*pCVArrayFormat, pStubMsg, pCVArrayFormat);
5104
5105 align_pointer(&pStubMsg->Buffer, pCVStructFormat->alignment + 1);
5106
5107 TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
5108
5109 safe_buffer_increment(pStubMsg, pCVStructFormat->memory_size);
5110 array_memory_size(*pCVArrayFormat, pStubMsg, pCVArrayFormat,
5111 FALSE /* fHasPointers */);
5112
5113 pStubMsg->MemorySize += pCVStructFormat->memory_size;
5114
5115 EmbeddedPointerMemorySize(pStubMsg, pFormat);
5116
5117 return pStubMsg->MemorySize;
5118}
5119
5120/***********************************************************************
5121 * NdrConformantVaryingStructFree [RPCRT4.@]
5122 */
5124 unsigned char *pMemory,
5125 PFORMAT_STRING pFormat)
5126{
5127 const NDR_CVSTRUCT_FORMAT *pCVStructFormat = (const NDR_CVSTRUCT_FORMAT *)pFormat;
5128 PFORMAT_STRING pCVArrayFormat;
5129
5130 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5131
5132 pFormat += sizeof(NDR_CVSTRUCT_FORMAT);
5133 if (pCVStructFormat->type != FC_CVSTRUCT)
5134 {
5135 ERR("invalid format type %x\n", pCVStructFormat->type);
5137 return;
5138 }
5139
5140 pCVArrayFormat = (const unsigned char *)&pCVStructFormat->offset_to_array_description +
5141 pCVStructFormat->offset_to_array_description;
5142 array_free(*pCVArrayFormat, pStubMsg,
5143 pMemory + pCVStructFormat->memory_size, pCVArrayFormat,
5144 FALSE /* fHasPointers */);
5145
5146 TRACE("memory_size = %d\n", pCVStructFormat->memory_size);
5147
5148 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
5149}
5150
5151#include "pshpack1.h"
5152typedef struct
5153{
5154 unsigned char type;
5155 unsigned char alignment;
5156 unsigned short total_size;
5158
5159typedef struct
5160{
5161 unsigned char type;
5162 unsigned char alignment;
5165#include "poppack.h"
5166
5167/***********************************************************************
5168 * NdrFixedArrayMarshall [RPCRT4.@]
5169 */
5171 unsigned char *pMemory,
5172 PFORMAT_STRING pFormat)
5173{
5174 const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
5175 ULONG total_size;
5176
5177 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5178
5179 if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
5180 (pSmFArrayFormat->type != FC_LGFARRAY))
5181 {
5182 ERR("invalid format type %x\n", pSmFArrayFormat->type);
5184 return NULL;
5185 }
5186
5187 align_pointer_clear(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
5188
5189 if (pSmFArrayFormat->type == FC_SMFARRAY)
5190 {
5191 total_size = pSmFArrayFormat->total_size;
5192 pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
5193 }
5194 else
5195 {
5196 const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
5197 total_size = pLgFArrayFormat->total_size;
5198 pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
5199 }
5200
5201 pStubMsg->BufferMark = pStubMsg->Buffer;
5202 safe_copy_to_buffer(pStubMsg, pMemory, total_size);
5203
5204 pFormat = EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
5205
5206 return NULL;
5207}
5208
5209/***********************************************************************
5210 * NdrFixedArrayUnmarshall [RPCRT4.@]
5211 */
5213 unsigned char **ppMemory,
5214 PFORMAT_STRING pFormat,
5215 unsigned char fMustAlloc)
5216{
5217 const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
5218 ULONG total_size;
5219 unsigned char *saved_buffer;
5220
5221 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
5222
5223 if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
5224 (pSmFArrayFormat->type != FC_LGFARRAY))
5225 {
5226 ERR("invalid format type %x\n", pSmFArrayFormat->type);
5228 return NULL;
5229 }
5230
5231 align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
5232
5233 if (pSmFArrayFormat->type == FC_SMFARRAY)
5234 {
5235 total_size = pSmFArrayFormat->total_size;
5236 pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
5237 }
5238 else
5239 {
5240 const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
5241 total_size = pLgFArrayFormat->total_size;
5242 pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
5243 }
5244
5245 if (fMustAlloc)
5246 *ppMemory = NdrAllocateZero(pStubMsg, total_size);
5247 else
5248 {
5249 if (!pStubMsg->IsClient && !*ppMemory)
5250 /* for servers, we just point straight into the RPC buffer */
5251 *ppMemory = pStubMsg->Buffer;
5252 }
5253
5254 saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
5255 safe_buffer_increment(pStubMsg, total_size);
5256 pFormat = EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
5257
5258 TRACE("copying %p to %p\n", saved_buffer, *ppMemory);
5259 if (*ppMemory != saved_buffer)
5260 memcpy(*ppMemory, saved_buffer, total_size);
5261
5262 return NULL;
5263}
5264
5265/***********************************************************************
5266 * NdrFixedArrayBufferSize [RPCRT4.@]
5267 */
5269 unsigned char *pMemory,
5270 PFORMAT_STRING pFormat)
5271{
5272 const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
5273 ULONG total_size;
5274
5275 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5276
5277 if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
5278 (pSmFArrayFormat->type != FC_LGFARRAY))
5279 {
5280 ERR("invalid format type %x\n", pSmFArrayFormat->type);
5282 return;
5283 }
5284
5285 align_length(&pStubMsg->BufferLength, pSmFArrayFormat->alignment + 1);
5286
5287 if (pSmFArrayFormat->type == FC_SMFARRAY)
5288 {
5289 total_size = pSmFArrayFormat->total_size;
5290 pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
5291 }
5292 else
5293 {
5294 const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
5295 total_size = pLgFArrayFormat->total_size;
5296 pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
5297 }
5298 safe_buffer_length_increment(pStubMsg, total_size);
5299
5300 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
5301}
5302
5303/***********************************************************************
5304 * NdrFixedArrayMemorySize [RPCRT4.@]
5305 */
5307 PFORMAT_STRING pFormat)
5308{
5309 const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
5310 ULONG total_size;
5311
5312 TRACE("(%p, %p)\n", pStubMsg, pFormat);
5313
5314 if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
5315 (pSmFArrayFormat->type != FC_LGFARRAY))
5316 {
5317 ERR("invalid format type %x\n", pSmFArrayFormat->type);
5319 return 0;
5320 }
5321
5322 align_pointer(&pStubMsg->Buffer, pSmFArrayFormat->alignment + 1);
5323
5324 if (pSmFArrayFormat->type == FC_SMFARRAY)
5325 {
5326 total_size = pSmFArrayFormat->total_size;
5327 pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
5328 }
5329 else
5330 {
5331 const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
5332 total_size = pLgFArrayFormat->total_size;
5333 pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
5334 }
5335 pStubMsg->BufferMark = pStubMsg->Buffer;
5336 safe_buffer_increment(pStubMsg, total_size);
5337 pStubMsg->MemorySize += total_size;
5338
5339 EmbeddedPointerMemorySize(pStubMsg, pFormat);
5340
5341 return total_size;
5342}
5343
5344/***********************************************************************
5345 * NdrFixedArrayFree [RPCRT4.@]
5346 */
5348 unsigned char *pMemory,
5349 PFORMAT_STRING pFormat)
5350{
5351 const NDR_SMFARRAY_FORMAT *pSmFArrayFormat = (const NDR_SMFARRAY_FORMAT *)pFormat;
5352
5353 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5354
5355 if ((pSmFArrayFormat->type != FC_SMFARRAY) &&
5356 (pSmFArrayFormat->type != FC_LGFARRAY))
5357 {
5358 ERR("invalid format type %x\n", pSmFArrayFormat->type);
5360 return;
5361 }
5362
5363 if (pSmFArrayFormat->type == FC_SMFARRAY)
5364 pFormat = (const unsigned char *)(pSmFArrayFormat + 1);
5365 else
5366 {
5367 const NDR_LGFARRAY_FORMAT *pLgFArrayFormat = (const NDR_LGFARRAY_FORMAT *)pFormat;
5368 pFormat = (const unsigned char *)(pLgFArrayFormat + 1);
5369 }
5370
5371 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
5372}
5373
5374/***********************************************************************
5375 * NdrVaryingArrayMarshall [RPCRT4.@]
5376 */
5378 unsigned char *pMemory,
5379 PFORMAT_STRING pFormat)
5380{
5381 unsigned char alignment;
5382 DWORD elements, esize;
5383 ULONG bufsize;
5384
5385 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5386
5387 if ((pFormat[0] != FC_SMVARRAY) &&
5388 (pFormat[0] != FC_LGVARRAY))
5389 {
5390 ERR("invalid format type %x\n", pFormat[0]);
5392 return NULL;
5393 }
5394
5395 alignment = pFormat[1] + 1;
5396
5397 if (pFormat[0] == FC_SMVARRAY)
5398 {
5399 pFormat += 2;
5400 pFormat += sizeof(WORD);
5401 elements = *(const WORD*)pFormat;
5402 pFormat += sizeof(WORD);
5403 }
5404 else
5405 {
5406 pFormat += 2;
5407 pFormat += sizeof(DWORD);
5408 elements = *(const DWORD*)pFormat;
5409 pFormat += sizeof(DWORD);
5410 }
5411
5412 esize = *(const WORD*)pFormat;
5413 pFormat += sizeof(WORD);
5414
5415 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
5416 if ((pStubMsg->ActualCount > elements) ||
5417 (pStubMsg->ActualCount + pStubMsg->Offset > elements))
5418 {
5420 return NULL;
5421 }
5422
5423 WriteVariance(pStubMsg);
5424
5426
5427 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
5428 pStubMsg->BufferMark = pStubMsg->Buffer;
5429 safe_copy_to_buffer(pStubMsg, pMemory + pStubMsg->Offset, bufsize);
5430
5431 EmbeddedPointerMarshall(pStubMsg, pMemory, pFormat);
5432
5433 return NULL;
5434}
5435
5436/***********************************************************************
5437 * NdrVaryingArrayUnmarshall [RPCRT4.@]
5438 */
5440 unsigned char **ppMemory,
5441 PFORMAT_STRING pFormat,
5442 unsigned char fMustAlloc)
5443{
5444 unsigned char alignment;
5445 DWORD size, elements, esize;
5446 ULONG bufsize;
5447 unsigned char *saved_buffer;
5448 ULONG offset;
5449
5450 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
5451
5452 if ((pFormat[0] != FC_SMVARRAY) &&
5453 (pFormat[0] != FC_LGVARRAY))
5454 {
5455 ERR("invalid format type %x\n", pFormat[0]);
5457 return NULL;
5458 }
5459
5460 alignment = pFormat[1] + 1;
5461
5462 if (pFormat[0] == FC_SMVARRAY)
5463 {
5464 pFormat += 2;
5465 size = *(const WORD*)pFormat;
5466 pFormat += sizeof(WORD);
5467 elements = *(const WORD*)pFormat;
5468 pFormat += sizeof(WORD);
5469 }
5470 else
5471 {
5472 pFormat += 2;
5473 size = *(const DWORD*)pFormat;
5474 pFormat += sizeof(DWORD);
5475 elements = *(const DWORD*)pFormat;
5476 pFormat += sizeof(DWORD);
5477 }
5478
5479 esize = *(const WORD*)pFormat;
5480 pFormat += sizeof(WORD);
5481
5482 pFormat = ReadVariance(pStubMsg, pFormat, elements);
5483
5484 align_pointer(&pStubMsg->Buffer, alignment);
5485
5486 bufsize = safe_multiply(esize, pStubMsg->ActualCount);
5487 offset = pStubMsg->Offset;
5488
5489 if (!fMustAlloc && !*ppMemory)
5490 fMustAlloc = TRUE;
5491 if (fMustAlloc)
5492 *ppMemory = NdrAllocateZero(pStubMsg, size);
5493 saved_buffer = pStubMsg->BufferMark = pStubMsg->Buffer;
5494 safe_buffer_increment(pStubMsg, bufsize);
5495
5496 EmbeddedPointerUnmarshall(pStubMsg, saved_buffer, *ppMemory, pFormat, fMustAlloc);
5497
5498 memcpy(*ppMemory + offset, saved_buffer, bufsize);
5499
5500 return NULL;
5501}
5502
5503/***********************************************************************
5504 * NdrVaryingArrayBufferSize [RPCRT4.@]
5505 */
5507 unsigned char *pMemory,
5508 PFORMAT_STRING pFormat)
5509{
5510 unsigned char alignment;
5511 DWORD elements, esize;
5512
5513 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5514
5515 if ((pFormat[0] != FC_SMVARRAY) &&
5516 (pFormat[0] != FC_LGVARRAY))
5517 {
5518 ERR("invalid format type %x\n", pFormat[0]);
5520 return;
5521 }
5522
5523 alignment = pFormat[1] + 1;
5524
5525 if (pFormat[0] == FC_SMVARRAY)
5526 {
5527 pFormat += 2;
5528 pFormat += sizeof(WORD);
5529 elements = *(const WORD*)pFormat;
5530 pFormat += sizeof(WORD);
5531 }
5532 else
5533 {
5534 pFormat += 2;
5535 pFormat += sizeof(DWORD);
5536 elements = *(const DWORD*)pFormat;
5537 pFormat += sizeof(DWORD);
5538 }
5539
5540 esize = *(const WORD*)pFormat;
5541 pFormat += sizeof(WORD);
5542
5543 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
5544 if ((pStubMsg->ActualCount > elements) ||
5545 (pStubMsg->ActualCount + pStubMsg->Offset > elements))
5546 {
5548 return;
5549 }
5550
5551 SizeVariance(pStubMsg);
5552
5553 align_length(&pStubMsg->BufferLength, alignment);
5554
5555 safe_buffer_length_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
5556
5557 EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat);
5558}
5559
5560/***********************************************************************
5561 * NdrVaryingArrayMemorySize [RPCRT4.@]
5562 */
5564 PFORMAT_STRING pFormat)
5565{
5566 unsigned char alignment;
5567 DWORD size, elements, esize;
5568
5569 TRACE("(%p, %p)\n", pStubMsg, pFormat);
5570
5571 if ((pFormat[0] != FC_SMVARRAY) &&
5572 (pFormat[0] != FC_LGVARRAY))
5573 {
5574 ERR("invalid format type %x\n", pFormat[0]);
5576 return 0;
5577 }
5578
5579 alignment = pFormat[1] + 1;
5580
5581 if (pFormat[0] == FC_SMVARRAY)
5582 {
5583 pFormat += 2;
5584 size = *(const WORD*)pFormat;
5585 pFormat += sizeof(WORD);
5586 elements = *(const WORD*)pFormat;
5587 pFormat += sizeof(WORD);
5588 }
5589 else
5590 {
5591 pFormat += 2;
5592 size = *(const DWORD*)pFormat;
5593 pFormat += sizeof(DWORD);
5594 elements = *(const DWORD*)pFormat;
5595 pFormat += sizeof(DWORD);
5596 }
5597
5598 esize = *(const WORD*)pFormat;
5599 pFormat += sizeof(WORD);
5600
5601 pFormat = ReadVariance(pStubMsg, pFormat, elements);
5602
5603 align_pointer(&pStubMsg->Buffer, alignment);
5604
5605 safe_buffer_increment(pStubMsg, safe_multiply(esize, pStubMsg->ActualCount));
5606 pStubMsg->MemorySize += size;
5607
5608 EmbeddedPointerMemorySize(pStubMsg, pFormat);
5609
5610 return pStubMsg->MemorySize;
5611}
5612
5613/***********************************************************************
5614 * NdrVaryingArrayFree [RPCRT4.@]
5615 */
5617 unsigned char *pMemory,
5618 PFORMAT_STRING pFormat)
5619{
5620 DWORD elements;
5621
5622 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
5623
5624 if ((pFormat[0] != FC_SMVARRAY) &&
5625 (pFormat[0] != FC_LGVARRAY))
5626 {
5627 ERR("invalid format type %x\n", pFormat[0]);
5629 return;
5630 }
5631
5632 if (pFormat[0] == FC_SMVARRAY)
5633 {
5634 pFormat += 2;
5635 pFormat += sizeof(WORD);
5636 elements = *(const WORD*)pFormat;
5637 pFormat += sizeof(WORD);
5638 }
5639 else
5640 {
5641 pFormat += 2;
5642 pFormat += sizeof(DWORD);
5643 elements = *(const DWORD*)pFormat;
5644 pFormat += sizeof(DWORD);
5645 }
5646
5647 pFormat += sizeof(WORD);
5648
5649 pFormat = ComputeVariance(pStubMsg, pMemory, pFormat, 0);
5650 if ((pStubMsg->ActualCount > elements) ||
5651 (pStubMsg->ActualCount + pStubMsg->Offset > elements))
5652 {
5654 return;
5655 }
5656
5657 EmbeddedPointerFree(pStubMsg, pMemory, pFormat);
5658}
5659
5660static ULONG get_discriminant(unsigned char fc, const unsigned char *pMemory)
5661{
5662 switch (fc)
5663 {
5664 case FC_BYTE:
5665 case FC_CHAR:
5666 case FC_SMALL:
5667 case FC_USMALL:
5668 return *pMemory;
5669 case FC_WCHAR:
5670 case FC_SHORT:
5671 case FC_USHORT:
5672 case FC_ENUM16:
5673 return *(const USHORT *)pMemory;
5674 case FC_LONG:
5675 case FC_ULONG:
5676 case FC_ENUM32:
5677 return *(const ULONG *)pMemory;
5678 default:
5679 FIXME("Unhandled base type: 0x%02x\n", fc);
5680 return 0;
5681 }
5682}
5683
5685 ULONG discriminant,
5686 PFORMAT_STRING pFormat)
5687{
5688 unsigned short num_arms, arm, type;
5689
5690 num_arms = *(const SHORT*)pFormat & 0x0fff;
5691 pFormat += 2;
5692 for(arm = 0; arm < num_arms; arm++)
5693 {
5694 if(discriminant == *(const ULONG*)pFormat)
5695 {
5696 pFormat += 4;
5697 break;
5698 }
5699 pFormat += 6;
5700 }
5701
5702 type = *(const unsigned short*)pFormat;
5703 TRACE("type %04x\n", type);
5704 if(arm == num_arms) /* default arm extras */
5705 {
5706 if(type == 0xffff)
5707 {
5708 ERR("no arm for 0x%lx and no default case\n", discriminant);
5710 return NULL;
5711 }
5712 if(type == 0)
5713 {
5714 TRACE("falling back to empty default case for 0x%lx\n", discriminant);
5715 return NULL;
5716 }
5717 }
5718 return pFormat;
5719}
5720
5721static unsigned char *union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
5722{
5723 unsigned short type;
5724
5725 pFormat += 2;
5726
5727 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
5728 if(!pFormat)
5729 return NULL;
5730
5731 type = *(const unsigned short*)pFormat;
5732 if((type & 0xff00) == 0x8000)
5733 {
5734 unsigned char basetype = LOBYTE(type);
5735 return NdrBaseTypeMarshall(pStubMsg, pMemory, &basetype);
5736 }
5737 else
5738 {
5739 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
5741 if (m)
5742 {
5743 unsigned char *saved_buffer = NULL;
5744 BOOL pointer_buffer_mark_set = FALSE;
5745 switch(*desc)
5746 {
5747 case FC_RP:
5748 case FC_UP:
5749 case FC_OP:
5750 case FC_FP:
5751 align_pointer_clear(&pStubMsg->Buffer, 4);
5752 saved_buffer = pStubMsg->Buffer;
5753 if (pStubMsg->PointerBufferMark)
5754 {
5755 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
5756 pStubMsg->PointerBufferMark = NULL;
5757 pointer_buffer_mark_set = TRUE;
5758 }
5759 else
5760 safe_buffer_increment(pStubMsg, 4); /* for pointer ID */
5761
5762 PointerMarshall(pStubMsg, saved_buffer, *(unsigned char **)pMemory, desc);
5763 if (pointer_buffer_mark_set)
5764 {
5765 STD_OVERFLOW_CHECK(pStubMsg);
5766 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
5767 if (saved_buffer + 4 > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
5768 {
5769 ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n",
5770 saved_buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
5772 }
5773 pStubMsg->Buffer = saved_buffer + 4;
5774 }
5775 break;
5776 case FC_IP:
5777 /* must be dereferenced first */
5778 m(pStubMsg, *(unsigned char **)pMemory, desc);
5779 break;
5780 default:
5781 m(pStubMsg, pMemory, desc);
5782 }
5783 }
5784 else if (*desc)
5785 FIXME("no marshaller for embedded type %02x\n", *desc);
5786 }
5787 return NULL;
5788}
5789
5790static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg,
5791 unsigned char **ppMemory,
5792 ULONG discriminant,
5793 PFORMAT_STRING pFormat,
5794 unsigned char fMustAlloc)
5795{
5796 unsigned short type;
5797
5798 pFormat += 2;
5799
5800 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
5801 if(!pFormat)
5802 return NULL;
5803
5804 type = *(const unsigned short*)pFormat;
5805 if((type & 0xff00) == 0x8000)
5806 {
5807 unsigned char basetype = LOBYTE(type);
5808 return NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &basetype, FALSE);
5809 }
5810 else
5811 {
5812 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
5814 if (m)
5815 {
5816 unsigned char *saved_buffer = NULL;
5817 BOOL pointer_buffer_mark_set = FALSE;
5818 switch(*desc)
5819 {
5820 case FC_RP:
5821 case FC_UP:
5822 case FC_OP:
5823 case FC_FP:
5824 align_pointer(&pStubMsg->Buffer, 4);
5825 saved_buffer = pStubMsg->Buffer;
5826 if (pStubMsg->PointerBufferMark)
5827 {
5828 pStubMsg->Buffer = pStubMsg->PointerBufferMark;
5829 pStubMsg->PointerBufferMark = NULL;
5830 pointer_buffer_mark_set = TRUE;
5831 }
5832 else
5833 pStubMsg->Buffer += 4; /* for pointer ID */
5834
5835 if (saved_buffer + 4 > pStubMsg->BufferEnd)
5836 {
5837 ERR("buffer overflow - saved_buffer = %p, BufferEnd = %p\n",
5838 saved_buffer, pStubMsg->BufferEnd);
5840 }
5841
5842 PointerUnmarshall(pStubMsg, saved_buffer, *(unsigned char ***)ppMemory, **(unsigned char ***)ppMemory, desc, fMustAlloc);
5843 if (pointer_buffer_mark_set)
5844 {
5845 STD_OVERFLOW_CHECK(pStubMsg);
5846 pStubMsg->PointerBufferMark = pStubMsg->Buffer;
5847 pStubMsg->Buffer = saved_buffer + 4;
5848 }
5849 break;
5850 case FC_IP:
5851 /* must be dereferenced first */
5852 m(pStubMsg, *(unsigned char ***)ppMemory, desc, fMustAlloc);
5853 break;
5854 default:
5855 m(pStubMsg, ppMemory, desc, fMustAlloc);
5856 }
5857 }
5858 else if (*desc)
5859 FIXME("no marshaller for embedded type %02x\n", *desc);
5860 }
5861 return NULL;
5862}
5863
5865 unsigned char *pMemory,
5866 ULONG discriminant,
5867 PFORMAT_STRING pFormat)
5868{
5869 unsigned short type;
5870
5871 pFormat += 2;
5872
5873 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
5874 if(!pFormat)
5875 return;
5876
5877 type = *(const unsigned short*)pFormat;
5878 if((type & 0xff00) == 0x8000)
5879 {
5880 unsigned char basetype = LOBYTE(type);
5881 NdrBaseTypeBufferSize(pStubMsg, pMemory, &basetype);
5882 }
5883 else
5884 {
5885 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
5887 if (m)
5888 {
5889 switch(*desc)
5890 {
5891 case FC_RP:
5892 case FC_UP:
5893 case FC_OP:
5894 case FC_FP:
5895 align_length(&pStubMsg->BufferLength, 4);
5896 safe_buffer_length_increment(pStubMsg, 4); /* for pointer ID */
5897 if (!pStubMsg->IgnoreEmbeddedPointers)
5898 {
5899 int saved_buffer_length = pStubMsg->BufferLength;
5900 pStubMsg->BufferLength = pStubMsg->PointerLength;
5901 pStubMsg->PointerLength = 0;
5902 if(!pStubMsg->BufferLength)
5903 ERR("BufferLength == 0??\n");
5904 PointerBufferSize(pStubMsg, *(unsigned char **)pMemory, desc);
5905 pStubMsg->PointerLength = pStubMsg->BufferLength;
5906#ifdef __REACTOS__
5907 pStubMsg->BufferLength += saved_buffer_length;
5908#else
5909 pStubMsg->BufferLength = saved_buffer_length;
5910#endif
5911 }
5912 break;
5913 case FC_IP:
5914 /* must be dereferenced first */
5915 m(pStubMsg, *(unsigned char **)pMemory, desc);
5916 break;
5917 default:
5918 m(pStubMsg, pMemory, desc);
5919 }
5920 }
5921 else if (*desc)
5922 FIXME("no buffersizer for embedded type %02x\n", *desc);
5923 }
5924}
5925
5927 ULONG discriminant,
5928 PFORMAT_STRING pFormat)
5929{
5930 unsigned short type, size;
5931
5932 size = *(const unsigned short*)pFormat;
5933 pStubMsg->Memory += size;
5934 pFormat += 2;
5935
5936 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
5937 if(!pFormat)
5938 return 0;
5939
5940 type = *(const unsigned short*)pFormat;
5941 if((type & 0xff00) == 0x8000)
5942 {
5943 return NdrBaseTypeMemorySize(pStubMsg, pFormat);
5944 }
5945 else
5946 {
5947 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
5949 unsigned char *saved_buffer;
5950 if (m)
5951 {
5952 switch(*desc)
5953 {
5954 case FC_RP:
5955 case FC_UP:
5956 case FC_OP:
5957 case FC_FP:
5958 align_pointer(&pStubMsg->Buffer, 4);
5959 saved_buffer = pStubMsg->Buffer;
5960 safe_buffer_increment(pStubMsg, 4);
5961 align_length(&pStubMsg->MemorySize, sizeof(void *));
5962 pStubMsg->MemorySize += sizeof(void *);
5963 if (!pStubMsg->IgnoreEmbeddedPointers)
5964 PointerMemorySize(pStubMsg, saved_buffer, pFormat);
5965 break;
5966 default:
5967 return m(pStubMsg, desc);
5968 }
5969 }
5970 else if (*desc)
5971 FIXME("no marshaller for embedded type %02x\n", *desc);
5972 }
5973
5974 TRACE("size %d\n", size);
5975 return size;
5976}
5977
5979 unsigned char *pMemory,
5980 ULONG discriminant,
5981 PFORMAT_STRING pFormat)
5982{
5983 unsigned short type;
5984
5985 pFormat += 2;
5986
5987 pFormat = get_arm_offset_from_union_arm_selector(pStubMsg, discriminant, pFormat);
5988 if(!pFormat)
5989 return;
5990
5991 type = *(const unsigned short*)pFormat;
5992 if((type & 0xff00) != 0x8000)
5993 {
5994 PFORMAT_STRING desc = pFormat + *(const SHORT*)pFormat;
5996 if (m)
5997 {
5998 switch(*desc)
5999 {
6000 case FC_RP:
6001 case FC_UP:
6002 case FC_OP:
6003 case FC_FP:
6004 PointerFree(pStubMsg, *(unsigned char **)pMemory, desc);
6005 break;
6006 case FC_IP:
6007 /* must be dereferenced first */
6008 m(pStubMsg, *(unsigned char **)pMemory, desc);
6009 break;
6010 default:
6011 m(pStubMsg, pMemory, desc);
6012 }
6013 }
6014 }
6015}
6016
6017/***********************************************************************
6018 * NdrEncapsulatedUnionMarshall [RPCRT4.@]
6019 */
6021 unsigned char *pMemory,
6022 PFORMAT_STRING pFormat)
6023{
6024 unsigned char switch_type;
6025 unsigned char increment;
6026 ULONG switch_value;
6027
6028 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6029 pFormat++;
6030
6031 switch_type = *pFormat & 0xf;
6032 increment = (*pFormat & 0xf0) >> 4;
6033 pFormat++;
6034
6035 align_pointer_clear(&pStubMsg->Buffer, increment);
6036
6037 switch_value = get_discriminant(switch_type, pMemory);
6038 TRACE("got switch value 0x%lx\n", switch_value);
6039
6040 NdrBaseTypeMarshall(pStubMsg, pMemory, &switch_type);
6041 pMemory += increment;
6042
6043 return union_arm_marshall(pStubMsg, pMemory, switch_value, pFormat);
6044}
6045
6046/***********************************************************************
6047 * NdrEncapsulatedUnionUnmarshall [RPCRT4.@]
6048 */
6050 unsigned char **ppMemory,
6051 PFORMAT_STRING pFormat,
6052 unsigned char fMustAlloc)
6053{
6054 unsigned char switch_type;
6055 unsigned char increment;
6056 ULONG switch_value;
6057 unsigned short size;
6058 unsigned char *pMemoryArm;
6059
6060 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
6061 pFormat++;
6062
6063 switch_type = *pFormat & 0xf;
6064 increment = (*pFormat & 0xf0) >> 4;
6065 pFormat++;
6066
6067 align_pointer(&pStubMsg->Buffer, increment);
6068 switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
6069 TRACE("got switch value 0x%lx\n", switch_value);
6070
6071 size = *(const unsigned short*)pFormat + increment;
6072 if (!fMustAlloc && !*ppMemory)
6073 fMustAlloc = TRUE;
6074 if (fMustAlloc)
6075 *ppMemory = NdrAllocate(pStubMsg, size);
6076
6077 /* we can't pass fMustAlloc=TRUE into the marshaller for the arm
6078 * since the arm is part of the memory block that is encompassed by
6079 * the whole union. Memory is forced to allocate when pointers
6080 * are set to NULL, so we emulate that part of fMustAlloc=TRUE by
6081 * clearing the memory we pass in to the unmarshaller */
6082 if (fMustAlloc)
6083 memset(*ppMemory, 0, size);
6084
6085 NdrBaseTypeUnmarshall(pStubMsg, ppMemory, &switch_type, FALSE);
6086 pMemoryArm = *ppMemory + increment;
6087
6088 return union_arm_unmarshall(pStubMsg, &pMemoryArm, switch_value, pFormat, FALSE);
6089}
6090
6091/***********************************************************************
6092 * NdrEncapsulatedUnionBufferSize [RPCRT4.@]
6093 */
6095 unsigned char *pMemory,
6096 PFORMAT_STRING pFormat)
6097{
6098 unsigned char switch_type;
6099 unsigned char increment;
6100 ULONG switch_value;
6101
6102 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6103 pFormat++;
6104
6105 switch_type = *pFormat & 0xf;
6106 increment = (*pFormat & 0xf0) >> 4;
6107 pFormat++;
6108
6109 align_length(&pStubMsg->BufferLength, increment);
6110 switch_value = get_discriminant(switch_type, pMemory);
6111 TRACE("got switch value 0x%lx\n", switch_value);
6112
6113 /* Add discriminant size */
6114 NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&switch_value, &switch_type);
6115 pMemory += increment;
6116
6117 union_arm_buffer_size(pStubMsg, pMemory, switch_value, pFormat);
6118}
6119
6120/***********************************************************************
6121 * NdrEncapsulatedUnionMemorySize [RPCRT4.@]
6122 */
6124 PFORMAT_STRING pFormat)
6125{
6126 unsigned char switch_type;
6127 unsigned char increment;
6128 ULONG switch_value;
6129
6130 switch_type = *pFormat & 0xf;
6131 increment = (*pFormat & 0xf0) >> 4;
6132 pFormat++;
6133
6134 align_pointer(&pStubMsg->Buffer, increment);
6135 switch_value = get_discriminant(switch_type, pStubMsg->Buffer);
6136 TRACE("got switch value 0x%lx\n", switch_value);
6137
6138 pStubMsg->Memory += increment;
6139
6140 return increment + union_arm_memory_size(pStubMsg, switch_value, pFormat + *(const SHORT*)pFormat);
6141}
6142
6143/***********************************************************************
6144 * NdrEncapsulatedUnionFree [RPCRT4.@]
6145 */
6147 unsigned char *pMemory,
6148 PFORMAT_STRING pFormat)
6149{
6150 unsigned char switch_type;
6151 unsigned char increment;
6152 ULONG switch_value;
6153
6154 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6155 pFormat++;
6156
6157 switch_type = *pFormat & 0xf;
6158 increment = (*pFormat & 0xf0) >> 4;
6159 pFormat++;
6160
6161 switch_value = get_discriminant(switch_type, pMemory);
6162 TRACE("got switch value 0x%lx\n", switch_value);
6163
6164 pMemory += increment;
6165
6166 union_arm_free(pStubMsg, pMemory, switch_value, pFormat);
6167}
6168
6169/***********************************************************************
6170 * NdrNonEncapsulatedUnionMarshall [RPCRT4.@]
6171 */
6173 unsigned char *pMemory,
6174 PFORMAT_STRING pFormat)
6175{
6176 unsigned char switch_type;
6177
6178 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6179 pFormat++;
6180
6181 switch_type = *pFormat;
6182 pFormat++;
6183
6184 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
6185 TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount);
6186 /* Marshall discriminant */
6187 NdrBaseTypeMarshall(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type);
6188
6189 return union_arm_marshall(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
6190}
6191
6193 PFORMAT_STRING *ppFormat)
6194{
6195 LONG discriminant = 0;
6196
6197 switch(**ppFormat)
6198 {
6199 case FC_BYTE:
6200 case FC_CHAR:
6201 case FC_SMALL:
6202 case FC_USMALL:
6203 {
6204 UCHAR d;
6205 safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
6206 discriminant = d;
6207 break;
6208 }
6209 case FC_WCHAR:
6210 case FC_SHORT:
6211 case FC_USHORT:
6212 case FC_ENUM16:
6213 {
6214 USHORT d;
6215 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6216 safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
6217 discriminant = d;
6218 break;
6219 }
6220 case FC_LONG:
6221 case FC_ULONG:
6222 {
6223 ULONG d;
6224 align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
6225 safe_copy_from_buffer(pStubMsg, &d, sizeof(d));
6226 discriminant = d;
6227 break;
6228 }
6229 default:
6230 FIXME("Unhandled base type: 0x%02x\n", **ppFormat);
6231 }
6232 (*ppFormat)++;
6233
6234 *ppFormat = SkipConformance(pStubMsg, *ppFormat);
6235 return discriminant;
6236}
6237
6238/**********************************************************************
6239 * NdrNonEncapsulatedUnionUnmarshall [RPCRT4.@]
6240 */
6242 unsigned char **ppMemory,
6243 PFORMAT_STRING pFormat,
6244 unsigned char fMustAlloc)
6245{
6246 LONG discriminant;
6247 unsigned short size;
6248
6249 TRACE("(%p, %p, %p, %d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
6250 pFormat++;
6251
6252 /* Unmarshall discriminant */
6253 discriminant = unmarshall_discriminant(pStubMsg, &pFormat);
6254 TRACE("unmarshalled discriminant %lx\n", discriminant);
6255
6256 pFormat += *(const SHORT*)pFormat;
6257
6258 size = *(const unsigned short*)pFormat;
6259
6260 if (!fMustAlloc && !*ppMemory)
6261 fMustAlloc = TRUE;
6262 if (fMustAlloc)
6263 *ppMemory = NdrAllocate(pStubMsg, size);
6264
6265 /* we can't pass fMustAlloc=TRUE into the marshaller for the arm
6266 * since the arm is part of the memory block that is encompassed by
6267 * the whole union. Memory is forced to allocate when pointers
6268 * are set to NULL, so we emulate that part of fMustAlloc=TRUE by
6269 * clearing the memory we pass in to the unmarshaller */
6270 if (fMustAlloc)
6271 memset(*ppMemory, 0, size);
6272
6273 return union_arm_unmarshall(pStubMsg, ppMemory, discriminant, pFormat, FALSE);
6274}
6275
6276/***********************************************************************
6277 * NdrNonEncapsulatedUnionBufferSize [RPCRT4.@]
6278 */
6280 unsigned char *pMemory,
6281 PFORMAT_STRING pFormat)
6282{
6283 unsigned char switch_type;
6284
6285 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6286 pFormat++;
6287
6288 switch_type = *pFormat;
6289 pFormat++;
6290
6291 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
6292 TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount);
6293 /* Add discriminant size */
6294 NdrBaseTypeBufferSize(pStubMsg, (unsigned char *)&pStubMsg->MaxCount, &switch_type);
6295
6296 union_arm_buffer_size(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
6297}
6298
6299/***********************************************************************
6300 * NdrNonEncapsulatedUnionMemorySize [RPCRT4.@]
6301 */
6303 PFORMAT_STRING pFormat)
6304{
6305 ULONG discriminant;
6306
6307 pFormat++;
6308 /* Unmarshall discriminant */
6309 discriminant = unmarshall_discriminant(pStubMsg, &pFormat);
6310 TRACE("unmarshalled discriminant 0x%lx\n", discriminant);
6311
6312 return union_arm_memory_size(pStubMsg, discriminant, pFormat + *(const SHORT*)pFormat);
6313}
6314
6315/***********************************************************************
6316 * NdrNonEncapsulatedUnionFree [RPCRT4.@]
6317 */
6319 unsigned char *pMemory,
6320 PFORMAT_STRING pFormat)
6321{
6322 TRACE("(%p, %p, %p)\n", pStubMsg, pMemory, pFormat);
6323 pFormat++;
6324 pFormat++;
6325
6326 pFormat = ComputeConformance(pStubMsg, pMemory, pFormat, 0);
6327 TRACE("got switch value 0x%Ix\n", pStubMsg->MaxCount);
6328
6329 union_arm_free(pStubMsg, pMemory, pStubMsg->MaxCount, pFormat + *(const SHORT*)pFormat);
6330}
6331
6332/***********************************************************************
6333 * NdrByteCountPointerMarshall [RPCRT4.@]
6334 */
6336 unsigned char *pMemory,
6337 PFORMAT_STRING pFormat)
6338{
6339 FIXME("stub\n");
6340 return NULL;
6341}
6342
6343/***********************************************************************
6344 * NdrByteCountPointerUnmarshall [RPCRT4.@]
6345 */
6347 unsigned char **ppMemory,
6348 PFORMAT_STRING pFormat,
6349 unsigned char fMustAlloc)
6350{
6351 FIXME("stub\n");
6352 return NULL;
6353}
6354
6355/***********************************************************************
6356 * NdrByteCountPointerBufferSize [RPCRT4.@]
6357 */
6359 unsigned char *pMemory,
6360 PFORMAT_STRING pFormat)
6361{
6362 FIXME("stub\n");
6363}
6364
6365/***********************************************************************
6366 * NdrByteCountPointerMemorySize [internal]
6367 */
6369 PFORMAT_STRING pFormat)
6370{
6371 FIXME("stub\n");
6372 return 0;
6373}
6374
6375/***********************************************************************
6376 * NdrByteCountPointerFree [RPCRT4.@]
6377 */
6379 unsigned char *pMemory,
6380 PFORMAT_STRING pFormat)
6381{
6382 FIXME("stub\n");
6383}
6384
6385/***********************************************************************
6386 * NdrXmitOrRepAsMarshall [RPCRT4.@]
6387 */
6389 unsigned char *pMemory,
6390 PFORMAT_STRING pFormat)
6391{
6392 FIXME("stub\n");
6393 return NULL;
6394}
6395
6396/***********************************************************************
6397 * NdrXmitOrRepAsUnmarshall [RPCRT4.@]
6398 */
6400 unsigned char **ppMemory,
6401 PFORMAT_STRING pFormat,
6402 unsigned char fMustAlloc)
6403{
6404 FIXME("stub\n");
6405 return NULL;
6406}
6407
6408/***********************************************************************
6409 * NdrXmitOrRepAsBufferSize [RPCRT4.@]
6410 */
6412 unsigned char *pMemory,
6413 PFORMAT_STRING pFormat)
6414{
6415 FIXME("stub\n");
6416}
6417
6418/***********************************************************************
6419 * NdrXmitOrRepAsMemorySize [RPCRT4.@]
6420 */
6422 PFORMAT_STRING pFormat)
6423{
6424 FIXME("stub\n");
6425 return 0;
6426}
6427
6428/***********************************************************************
6429 * NdrXmitOrRepAsFree [RPCRT4.@]
6430 */
6432 unsigned char *pMemory,
6433 PFORMAT_STRING pFormat)
6434{
6435 FIXME("stub\n");
6436}
6437
6438/***********************************************************************
6439 * NdrRangeMarshall [internal]
6440 */
6441static unsigned char *WINAPI NdrRangeMarshall(
6442 PMIDL_STUB_MESSAGE pStubMsg,
6443 unsigned char *pMemory,
6444 PFORMAT_STRING pFormat)
6445{
6446 const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
6447 unsigned char base_type;
6448
6449 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6450
6451 if (pRange->type != FC_RANGE)
6452 {
6453 ERR("invalid format type %x\n", pRange->type);
6455 return NULL;
6456 }
6457
6458 base_type = pRange->flags_type & 0xf;
6459
6460 return NdrBaseTypeMarshall(pStubMsg, pMemory, &base_type);
6461}
6462
6463/***********************************************************************
6464 * NdrRangeUnmarshall [RPCRT4.@]
6465 */
6467 PMIDL_STUB_MESSAGE pStubMsg,
6468 unsigned char **ppMemory,
6469 PFORMAT_STRING pFormat,
6470 unsigned char fMustAlloc)
6471{
6472 const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
6473 unsigned char base_type;
6474
6475 TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
6476
6477 if (pRange->type != FC_RANGE)
6478 {
6479 ERR("invalid format type %x\n", pRange->type);
6481 return NULL;
6482 }
6483 base_type = pRange->flags_type & 0xf;
6484
6485 TRACE("base_type = 0x%02x, low_value = %ld, high_value = %ld\n",
6486 base_type, pRange->low_value, pRange->high_value);
6487
6488#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec) \
6489 do \
6490 { \
6491 align_pointer(&pStubMsg->Buffer, sizeof(wire_type)); \
6492 if (!fMustAlloc && !*ppMemory) \
6493 fMustAlloc = TRUE; \
6494 if (fMustAlloc) \
6495 *ppMemory = NdrAllocate(pStubMsg, sizeof(mem_type)); \
6496 if (pStubMsg->Buffer + sizeof(wire_type) > pStubMsg->BufferEnd) \
6497 { \
6498 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n", \
6499 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength); \
6500 RpcRaiseException(RPC_X_BAD_STUB_DATA); \
6501 } \
6502 if ((*(wire_type *)pStubMsg->Buffer < (mem_type)pRange->low_value) || \
6503 (*(wire_type *)pStubMsg->Buffer > (mem_type)pRange->high_value)) \
6504 { \
6505 ERR("value exceeded bounds: " format_spec ", low: " format_spec ", high: " format_spec "\n", \
6506 *(wire_type *)pStubMsg->Buffer, (mem_type)pRange->low_value, \
6507 (mem_type)pRange->high_value); \
6508 RpcRaiseException(RPC_S_INVALID_BOUND); \
6509 return NULL; \
6510 } \
6511 TRACE("*ppMemory: %p\n", *ppMemory); \
6512 **(mem_type **)ppMemory = *(wire_type *)pStubMsg->Buffer; \
6513 pStubMsg->Buffer += sizeof(wire_type); \
6514 } while (0)
6515
6516 switch(base_type)
6517 {
6518 case FC_CHAR:
6519 case FC_SMALL:
6521 TRACE("value: 0x%02x\n", **ppMemory);
6522 break;
6523 case FC_BYTE:
6524 case FC_USMALL:
6525 RANGE_UNMARSHALL(CHAR, CHAR, "%u");
6526 TRACE("value: 0x%02x\n", **ppMemory);
6527 break;
6528 case FC_WCHAR: /* FIXME: valid? */
6529 case FC_USHORT:
6531 TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
6532 break;
6533 case FC_SHORT:
6535 TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
6536 break;
6537 case FC_LONG:
6538 case FC_ENUM32:
6539 RANGE_UNMARSHALL(LONG, LONG, "%ld");
6540 TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory);
6541 break;
6542 case FC_ULONG:
6543 RANGE_UNMARSHALL(ULONG, ULONG, "%lu");
6544 TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory);
6545 break;
6546 case FC_ENUM16:
6548 TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
6549 break;
6550 case FC_FLOAT:
6551 case FC_DOUBLE:
6552 case FC_HYPER:
6553 default:
6554 ERR("invalid range base type: 0x%02x\n", base_type);
6556 }
6557
6558 return NULL;
6559}
6560
6561/***********************************************************************
6562 * NdrRangeBufferSize [internal]
6563 */
6565 PMIDL_STUB_MESSAGE pStubMsg,
6566 unsigned char *pMemory,
6567 PFORMAT_STRING pFormat)
6568{
6569 const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
6570 unsigned char base_type;
6571
6572 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6573
6574 if (pRange->type != FC_RANGE)
6575 {
6576 ERR("invalid format type %x\n", pRange->type);
6578 }
6579 base_type = pRange->flags_type & 0xf;
6580
6581 NdrBaseTypeBufferSize(pStubMsg, pMemory, &base_type);
6582}
6583
6584/***********************************************************************
6585 * NdrRangeMemorySize [internal]
6586 */
6588 PMIDL_STUB_MESSAGE pStubMsg,
6589 PFORMAT_STRING pFormat)
6590{
6591 const NDR_RANGE *pRange = (const NDR_RANGE *)pFormat;
6592 unsigned char base_type;
6593
6594 if (pRange->type != FC_RANGE)
6595 {
6596 ERR("invalid format type %x\n", pRange->type);
6598 return 0;
6599 }
6600 base_type = pRange->flags_type & 0xf;
6601
6602 return NdrBaseTypeMemorySize(pStubMsg, &base_type);
6603}
6604
6605/***********************************************************************
6606 * NdrRangeFree [internal]
6607 */
6609 unsigned char *pMemory,
6610 PFORMAT_STRING pFormat)
6611{
6612 TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6613
6614 /* nothing to do */
6615}
6616
6617/***********************************************************************
6618 * NdrBaseTypeMarshall [internal]
6619 */
6620static unsigned char *WINAPI NdrBaseTypeMarshall(
6621 PMIDL_STUB_MESSAGE pStubMsg,
6622 unsigned char *pMemory,
6623 PFORMAT_STRING pFormat)
6624{
6625 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6626
6627 switch(*pFormat)
6628 {
6629 case FC_BYTE:
6630 case FC_CHAR:
6631 case FC_SMALL:
6632 case FC_USMALL:
6633 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(UCHAR));
6634 TRACE("value: 0x%02x\n", *pMemory);
6635 break;
6636 case FC_WCHAR:
6637 case FC_SHORT:
6638 case FC_USHORT:
6639 align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
6640 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(USHORT));
6641 TRACE("value: 0x%04x\n", *(USHORT *)pMemory);
6642 break;
6643 case FC_LONG:
6644 case FC_ULONG:
6645 case FC_ERROR_STATUS_T:
6646 case FC_ENUM32:
6647 align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONG));
6648 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONG));
6649 TRACE("value: 0x%08lx\n", *(ULONG *)pMemory);
6650 break;
6651 case FC_FLOAT:
6652 align_pointer_clear(&pStubMsg->Buffer, sizeof(float));
6653 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(float));
6654 break;
6655 case FC_DOUBLE:
6656 align_pointer_clear(&pStubMsg->Buffer, sizeof(double));
6657 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(double));
6658 break;
6659 case FC_HYPER:
6660 align_pointer_clear(&pStubMsg->Buffer, sizeof(ULONGLONG));
6661 safe_copy_to_buffer(pStubMsg, pMemory, sizeof(ULONGLONG));
6662 TRACE("value: %s\n", wine_dbgstr_longlong(*(ULONGLONG*)pMemory));
6663 break;
6664 case FC_ENUM16:
6665 {
6666 USHORT val = *(UINT *)pMemory;
6667 /* only 16-bits on the wire, so do a sanity check */
6668 if (*(UINT *)pMemory > SHRT_MAX)
6670 align_pointer_clear(&pStubMsg->Buffer, sizeof(USHORT));
6671 safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
6672 TRACE("value: 0x%04x\n", *(UINT *)pMemory);
6673 break;
6674 }
6675 case FC_INT3264:
6676 case FC_UINT3264:
6677 {
6678 UINT val = *(UINT_PTR *)pMemory;
6679 align_pointer_clear(&pStubMsg->Buffer, sizeof(UINT));
6680 safe_copy_to_buffer(pStubMsg, &val, sizeof(val));
6681 break;
6682 }
6683 case FC_IGNORE:
6684 break;
6685 default:
6686 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6687 }
6688
6689 /* FIXME: what is the correct return value? */
6690 return NULL;
6691}
6692
6693/***********************************************************************
6694 * NdrBaseTypeUnmarshall [internal]
6695 */
6696static unsigned char *WINAPI NdrBaseTypeUnmarshall(
6697 PMIDL_STUB_MESSAGE pStubMsg,
6698 unsigned char **ppMemory,
6699 PFORMAT_STRING pFormat,
6700 unsigned char fMustAlloc)
6701{
6702 TRACE("pStubMsg: %p, ppMemory: %p, type: 0x%02x, fMustAlloc: %s\n", pStubMsg, ppMemory, *pFormat, fMustAlloc ? "true" : "false");
6703
6704#define BASE_TYPE_UNMARSHALL(type) do { \
6705 align_pointer(&pStubMsg->Buffer, sizeof(type)); \
6706 if (!fMustAlloc && !pStubMsg->IsClient && !*ppMemory) \
6707 { \
6708 *ppMemory = pStubMsg->Buffer; \
6709 TRACE("*ppMemory: %p\n", *ppMemory); \
6710 safe_buffer_increment(pStubMsg, sizeof(type)); \
6711 } \
6712 else \
6713 { \
6714 if (fMustAlloc) \
6715 *ppMemory = NdrAllocate(pStubMsg, sizeof(type)); \
6716 TRACE("*ppMemory: %p\n", *ppMemory); \
6717 safe_copy_from_buffer(pStubMsg, *ppMemory, sizeof(type)); \
6718 } \
6719 } while (0)
6720
6721 switch(*pFormat)
6722 {
6723 case FC_BYTE:
6724 case FC_CHAR:
6725 case FC_SMALL:
6726 case FC_USMALL:
6728 TRACE("value: 0x%02x\n", **ppMemory);
6729 break;
6730 case FC_WCHAR:
6731 case FC_SHORT:
6732 case FC_USHORT:
6734 TRACE("value: 0x%04x\n", **(USHORT **)ppMemory);
6735 break;
6736 case FC_LONG:
6737 case FC_ULONG:
6738 case FC_ERROR_STATUS_T:
6739 case FC_ENUM32:
6741 TRACE("value: 0x%08lx\n", **(ULONG **)ppMemory);
6742 break;
6743 case FC_FLOAT:
6744 BASE_TYPE_UNMARSHALL(float);
6745 TRACE("value: %f\n", **(float **)ppMemory);
6746 break;
6747 case FC_DOUBLE:
6748 BASE_TYPE_UNMARSHALL(double);
6749 TRACE("value: %f\n", **(double **)ppMemory);
6750 break;
6751 case FC_HYPER:
6753 TRACE("value: %s\n", wine_dbgstr_longlong(**(ULONGLONG **)ppMemory));
6754 break;
6755 case FC_ENUM16:
6756 {
6757 USHORT val;
6758 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6759 if (!fMustAlloc && !*ppMemory)
6760 fMustAlloc = TRUE;
6761 if (fMustAlloc)
6762 *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT));
6763 safe_copy_from_buffer(pStubMsg, &val, sizeof(USHORT));
6764 /* 16-bits on the wire, but int in memory */
6765 **(UINT **)ppMemory = val;
6766 TRACE("value: 0x%08x\n", **(UINT **)ppMemory);
6767 break;
6768 }
6769 case FC_INT3264:
6770 if (sizeof(INT_PTR) == sizeof(INT)) BASE_TYPE_UNMARSHALL(INT);
6771 else
6772 {
6773 INT val;
6774 align_pointer(&pStubMsg->Buffer, sizeof(INT));
6775 if (!fMustAlloc && !*ppMemory)
6776 fMustAlloc = TRUE;
6777 if (fMustAlloc)
6778 *ppMemory = NdrAllocate(pStubMsg, sizeof(INT_PTR));
6779 safe_copy_from_buffer(pStubMsg, &val, sizeof(INT));
6780 **(INT_PTR **)ppMemory = val;
6781 TRACE("value: 0x%08Ix\n", **(INT_PTR **)ppMemory);
6782 }
6783 break;
6784 case FC_UINT3264:
6785 if (sizeof(UINT_PTR) == sizeof(UINT)) BASE_TYPE_UNMARSHALL(UINT);
6786 else
6787 {
6788 UINT val;
6789 align_pointer(&pStubMsg->Buffer, sizeof(UINT));
6790 if (!fMustAlloc && !*ppMemory)
6791 fMustAlloc = TRUE;
6792 if (fMustAlloc)
6793 *ppMemory = NdrAllocate(pStubMsg, sizeof(UINT_PTR));
6794 safe_copy_from_buffer(pStubMsg, &val, sizeof(UINT));
6795 **(UINT_PTR **)ppMemory = val;
6796 TRACE("value: 0x%08Ix\n", **(UINT_PTR **)ppMemory);
6797 }
6798 break;
6799 case FC_IGNORE:
6800 break;
6801 default:
6802 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6803 }
6804#undef BASE_TYPE_UNMARSHALL
6805
6806 /* FIXME: what is the correct return value? */
6807
6808 return NULL;
6809}
6810
6811/***********************************************************************
6812 * NdrBaseTypeBufferSize [internal]
6813 */
6815 PMIDL_STUB_MESSAGE pStubMsg,
6816 unsigned char *pMemory,
6817 PFORMAT_STRING pFormat)
6818{
6819 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6820
6821 switch(*pFormat)
6822 {
6823 case FC_BYTE:
6824 case FC_CHAR:
6825 case FC_SMALL:
6826 case FC_USMALL:
6827 safe_buffer_length_increment(pStubMsg, sizeof(UCHAR));
6828 break;
6829 case FC_WCHAR:
6830 case FC_SHORT:
6831 case FC_USHORT:
6832 case FC_ENUM16:
6833 align_length(&pStubMsg->BufferLength, sizeof(USHORT));
6834 safe_buffer_length_increment(pStubMsg, sizeof(USHORT));
6835 break;
6836 case FC_LONG:
6837 case FC_ULONG:
6838 case FC_ENUM32:
6839 case FC_INT3264:
6840 case FC_UINT3264:
6841 align_length(&pStubMsg->BufferLength, sizeof(ULONG));
6842 safe_buffer_length_increment(pStubMsg, sizeof(ULONG));
6843 break;
6844 case FC_FLOAT:
6845 align_length(&pStubMsg->BufferLength, sizeof(float));
6846 safe_buffer_length_increment(pStubMsg, sizeof(float));
6847 break;
6848 case FC_DOUBLE:
6849 align_length(&pStubMsg->BufferLength, sizeof(double));
6850 safe_buffer_length_increment(pStubMsg, sizeof(double));
6851 break;
6852 case FC_HYPER:
6853 align_length(&pStubMsg->BufferLength, sizeof(ULONGLONG));
6854 safe_buffer_length_increment(pStubMsg, sizeof(ULONGLONG));
6855 break;
6856 case FC_ERROR_STATUS_T:
6857 align_length(&pStubMsg->BufferLength, sizeof(error_status_t));
6859 break;
6860 case FC_IGNORE:
6861 break;
6862 default:
6863 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6864 }
6865}
6866
6867/***********************************************************************
6868 * NdrBaseTypeMemorySize [internal]
6869 */
6871 PMIDL_STUB_MESSAGE pStubMsg,
6872 PFORMAT_STRING pFormat)
6873{
6874 TRACE("pStubMsg %p, type 0x%02x\n", pStubMsg, *pFormat);
6875
6876 switch(*pFormat)
6877 {
6878 case FC_BYTE:
6879 case FC_CHAR:
6880 case FC_SMALL:
6881 case FC_USMALL:
6882 safe_buffer_increment(pStubMsg, sizeof(UCHAR));
6883 pStubMsg->MemorySize += sizeof(UCHAR);
6884 return sizeof(UCHAR);
6885 case FC_WCHAR:
6886 case FC_SHORT:
6887 case FC_USHORT:
6888 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6889 safe_buffer_increment(pStubMsg, sizeof(USHORT));
6890 align_length(&pStubMsg->MemorySize, sizeof(USHORT));
6891 pStubMsg->MemorySize += sizeof(USHORT);
6892 return sizeof(USHORT);
6893 case FC_LONG:
6894 case FC_ULONG:
6895 case FC_ENUM32:
6896 align_pointer(&pStubMsg->Buffer, sizeof(ULONG));
6897 safe_buffer_increment(pStubMsg, sizeof(ULONG));
6898 align_length(&pStubMsg->MemorySize, sizeof(ULONG));
6899 pStubMsg->MemorySize += sizeof(ULONG);
6900 return sizeof(ULONG);
6901 case FC_FLOAT:
6902 align_pointer(&pStubMsg->Buffer, sizeof(float));
6903 safe_buffer_increment(pStubMsg, sizeof(float));
6904 align_length(&pStubMsg->MemorySize, sizeof(float));
6905 pStubMsg->MemorySize += sizeof(float);
6906 return sizeof(float);
6907 case FC_DOUBLE:
6908 align_pointer(&pStubMsg->Buffer, sizeof(double));
6909 safe_buffer_increment(pStubMsg, sizeof(double));
6910 align_length(&pStubMsg->MemorySize, sizeof(double));
6911 pStubMsg->MemorySize += sizeof(double);
6912 return sizeof(double);
6913 case FC_HYPER:
6914 align_pointer(&pStubMsg->Buffer, sizeof(ULONGLONG));
6915 safe_buffer_increment(pStubMsg, sizeof(ULONGLONG));
6916 align_length(&pStubMsg->MemorySize, sizeof(ULONGLONG));
6917 pStubMsg->MemorySize += sizeof(ULONGLONG);
6918 return sizeof(ULONGLONG);
6919 case FC_ERROR_STATUS_T:
6920 align_pointer(&pStubMsg->Buffer, sizeof(error_status_t));
6921 safe_buffer_increment(pStubMsg, sizeof(error_status_t));
6922 align_length(&pStubMsg->MemorySize, sizeof(error_status_t));
6923 pStubMsg->MemorySize += sizeof(error_status_t);
6924 return sizeof(error_status_t);
6925 case FC_ENUM16:
6926 align_pointer(&pStubMsg->Buffer, sizeof(USHORT));
6927 safe_buffer_increment(pStubMsg, sizeof(USHORT));
6928 align_length(&pStubMsg->MemorySize, sizeof(UINT));
6929 pStubMsg->MemorySize += sizeof(UINT);
6930 return sizeof(UINT);
6931 case FC_INT3264:
6932 case FC_UINT3264:
6933 align_pointer(&pStubMsg->Buffer, sizeof(UINT));
6934 safe_buffer_increment(pStubMsg, sizeof(UINT));
6935 align_length(&pStubMsg->MemorySize, sizeof(UINT_PTR));
6936 pStubMsg->MemorySize += sizeof(UINT_PTR);
6937 return sizeof(UINT_PTR);
6938 case FC_IGNORE:
6939 align_length(&pStubMsg->MemorySize, sizeof(void *));
6940 pStubMsg->MemorySize += sizeof(void *);
6941 return sizeof(void *);
6942 default:
6943 FIXME("Unhandled base type: 0x%02x\n", *pFormat);
6944 return 0;
6945 }
6946}
6947
6948/***********************************************************************
6949 * NdrBaseTypeFree [internal]
6950 */
6952 unsigned char *pMemory,
6953 PFORMAT_STRING pFormat)
6954{
6955 TRACE("pStubMsg %p pMemory %p type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6956
6957 /* nothing to do */
6958}
6959
6960/***********************************************************************
6961 * NdrContextHandleBufferSize [internal]
6962 */
6964 PMIDL_STUB_MESSAGE pStubMsg,
6965 unsigned char *pMemory,
6966 PFORMAT_STRING pFormat)
6967{
6968 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6969
6970 if (*pFormat != FC_BIND_CONTEXT)
6971 {
6972 ERR("invalid format type %x\n", *pFormat);
6974 }
6975 align_length(&pStubMsg->BufferLength, 4);
6977}
6978
6979/***********************************************************************
6980 * NdrContextHandleMarshall [internal]
6981 */
6982static unsigned char *WINAPI NdrContextHandleMarshall(
6983 PMIDL_STUB_MESSAGE pStubMsg,
6984 unsigned char *pMemory,
6985 PFORMAT_STRING pFormat)
6986{
6987 TRACE("pStubMsg %p, pMemory %p, type 0x%02x\n", pStubMsg, pMemory, *pFormat);
6988
6989 if (*pFormat != FC_BIND_CONTEXT)
6990 {
6991 ERR("invalid format type %x\n", *pFormat);
6993 }
6994 TRACE("flags: 0x%02x\n", pFormat[1]);
6995
6996 if (pStubMsg->IsClient)
6997 {
6998 if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
7000 else
7002 }
7003 else
7004 {
7005 NDR_SCONTEXT ctxt = CONTAINING_RECORD(pMemory, struct _NDR_SCONTEXT, userContext);
7006 NDR_RUNDOWN rundown = pStubMsg->StubDesc->apfnNdrRundownRoutines[pFormat[2]];
7007 NdrServerContextNewMarshall(pStubMsg, ctxt, rundown, pFormat);
7008 }
7009
7010 return NULL;
7011}
7012
7013/***********************************************************************
7014 * NdrContextHandleUnmarshall [internal]
7015 */
7017 PMIDL_STUB_MESSAGE pStubMsg,
7018 unsigned char **ppMemory,
7019 PFORMAT_STRING pFormat,
7020 unsigned char fMustAlloc)
7021{
7022 TRACE("pStubMsg %p, ppMemory %p, pFormat %p, fMustAlloc %s\n", pStubMsg,
7023 ppMemory, pFormat, fMustAlloc ? "TRUE": "FALSE");
7024
7025 if (*pFormat != FC_BIND_CONTEXT)
7026 {
7027 ERR("invalid format type %x\n", *pFormat);
7029 }
7030 TRACE("flags: 0x%02x\n", pFormat[1]);
7031
7032 if (pStubMsg->IsClient)
7033 {
7034 NDR_CCONTEXT *ccontext;
7035 if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
7036 ccontext = *(NDR_CCONTEXT **)ppMemory;
7037 else
7038 ccontext = (NDR_CCONTEXT *)ppMemory;
7039 /* [out]-only or [ret] param */
7041 *ccontext = NULL;
7042 NdrClientContextUnmarshall(pStubMsg, ccontext, pStubMsg->RpcMsg->Handle);
7043 }
7044 else
7045 {
7046 NDR_SCONTEXT ctxt;
7047 ctxt = NdrServerContextNewUnmarshall(pStubMsg, pFormat);
7048 if (pFormat[1] & HANDLE_PARAM_IS_VIA_PTR)
7049 *(void **)ppMemory = NDRSContextValue(ctxt);
7050 else
7051 *(void **)ppMemory = *NDRSContextValue(ctxt);
7052 }
7053
7054 return NULL;
7055}
7056
7057/***********************************************************************
7058 * NdrClientContextMarshall [RPCRT4.@]
7059 */
7061 NDR_CCONTEXT ContextHandle,
7062 int fCheck)
7063{
7064 TRACE("(%p, %p, %d)\n", pStubMsg, ContextHandle, fCheck);
7065
7066 align_pointer_clear(&pStubMsg->Buffer, 4);
7067
7068 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7069 {
7070 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7071 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7073 }
7074
7075 /* FIXME: what does fCheck do? */
7076 NDRCContextMarshall(ContextHandle,
7077 pStubMsg->Buffer);
7078
7079 pStubMsg->Buffer += cbNDRContext;
7080}
7081
7082/***********************************************************************
7083 * NdrClientContextUnmarshall [RPCRT4.@]
7084 */
7086 NDR_CCONTEXT * pContextHandle,
7087 RPC_BINDING_HANDLE BindHandle)
7088{
7089 TRACE("(%p, %p, %p)\n", pStubMsg, pContextHandle, BindHandle);
7090
7091 align_pointer(&pStubMsg->Buffer, 4);
7092
7093 if (pStubMsg->Buffer + cbNDRContext > pStubMsg->BufferEnd)
7095
7096 NDRCContextUnmarshall(pContextHandle,
7097 BindHandle,
7098 pStubMsg->Buffer,
7099 pStubMsg->RpcMsg->DataRepresentation);
7100
7101 pStubMsg->Buffer += cbNDRContext;
7102}
7103
7105 NDR_SCONTEXT ContextHandle,
7106 NDR_RUNDOWN RundownRoutine )
7107{
7108 TRACE("(%p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine);
7109
7110 align_pointer(&pStubMsg->Buffer, 4);
7111
7112 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7113 {
7114 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7115 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7117 }
7118
7119 NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
7120 pStubMsg->Buffer, RundownRoutine, NULL,
7122 pStubMsg->Buffer += cbNDRContext;
7123}
7124
7126{
7127 NDR_SCONTEXT ContextHandle;
7128
7129 TRACE("(%p)\n", pStubMsg);
7130
7131 align_pointer(&pStubMsg->Buffer, 4);
7132
7133 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7134 {
7135 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7136 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7138 }
7139
7140 ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
7141 pStubMsg->Buffer,
7142 pStubMsg->RpcMsg->DataRepresentation,
7144 pStubMsg->Buffer += cbNDRContext;
7145
7146 return ContextHandle;
7147}
7148
7150 unsigned char* pMemory,
7151 PFORMAT_STRING pFormat)
7152{
7153 FIXME("(%p, %p, %p): stub\n", pStubMsg, pMemory, pFormat);
7154}
7155
7157 PFORMAT_STRING pFormat)
7158{
7159 RPC_SYNTAX_IDENTIFIER *if_id = NULL;
7161
7162 TRACE("(%p, %p)\n", pStubMsg, pFormat);
7163
7164 if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
7166 if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
7168 if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
7169 {
7170 RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
7171 if_id = &sif->InterfaceId;
7172 }
7173
7174 return NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle, NULL,
7175 pStubMsg->RpcMsg->DataRepresentation, if_id,
7176 flags);
7177}
7178
7180 NDR_SCONTEXT ContextHandle,
7181 NDR_RUNDOWN RundownRoutine,
7182 PFORMAT_STRING pFormat)
7183{
7184 RPC_SYNTAX_IDENTIFIER *if_id = NULL;
7186
7187 TRACE("(%p, %p, %p, %p)\n", pStubMsg, ContextHandle, RundownRoutine, pFormat);
7188
7189 align_pointer(&pStubMsg->Buffer, 4);
7190
7191 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7192 {
7193 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7194 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7196 }
7197
7198 if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
7200 if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
7202 if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
7203 {
7204 RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
7205 if_id = &sif->InterfaceId;
7206 }
7207
7208 NDRSContextMarshall2(pStubMsg->RpcMsg->Handle, ContextHandle,
7209 pStubMsg->Buffer, RundownRoutine, if_id, flags);
7210 pStubMsg->Buffer += cbNDRContext;
7211}
7212
7214 PFORMAT_STRING pFormat)
7215{
7216 NDR_SCONTEXT ContextHandle;
7217 RPC_SYNTAX_IDENTIFIER *if_id = NULL;
7219
7220 TRACE("(%p, %p)\n", pStubMsg, pFormat);
7221
7222 align_pointer(&pStubMsg->Buffer, 4);
7223
7224 if (pStubMsg->Buffer + cbNDRContext > (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
7225 {
7226 ERR("buffer overflow - Buffer = %p, BufferEnd = %p\n",
7227 pStubMsg->Buffer, (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength);
7229 }
7230
7231 if (pFormat[1] & NDR_CONTEXT_HANDLE_SERIALIZE)
7233 if (pFormat[1] & NDR_CONTEXT_HANDLE_NOSERIALIZE)
7235 if (pFormat[1] & NDR_STRICT_CONTEXT_HANDLE)
7236 {
7237 RPC_SERVER_INTERFACE *sif = pStubMsg->StubDesc->RpcInterfaceInformation;
7238 if_id = &sif->InterfaceId;
7239 }
7240
7241 ContextHandle = NDRSContextUnmarshall2(pStubMsg->RpcMsg->Handle,
7242 pStubMsg->Buffer,
7243 pStubMsg->RpcMsg->DataRepresentation,
7244 if_id, flags);
7245 pStubMsg->Buffer += cbNDRContext;
7246
7247 return ContextHandle;
7248}
7249
7250/***********************************************************************
7251 * NdrCorrelationInitialize [RPCRT4.@]
7252 *
7253 * Initializes correlation validity checking.
7254 *
7255 * PARAMS
7256 * pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
7257 * pMemory [I] Pointer to memory to use as a cache.
7258 * CacheSize [I] Size of the memory pointed to by pMemory.
7259 * Flags [I] Reserved. Set to zero.
7260 *
7261 * RETURNS
7262 * Nothing.
7263 */
7265{
7266 TRACE("(%p, %p, %ld, 0x%lx)\n", pStubMsg, pMemory, CacheSize, Flags);
7267
7268 if (pStubMsg->CorrDespIncrement == 0)
7269 pStubMsg->CorrDespIncrement = 2; /* size of the normal (non-range) /robust payload */
7270
7271 pStubMsg->fHasNewCorrDesc = TRUE;
7272 pStubMsg->pCorrInfo = pMemory;
7273}
7274
7275/***********************************************************************
7276 * NdrCorrelationPass [RPCRT4.@]
7277 *
7278 * Performs correlation validity checking.
7279 *
7280 * PARAMS
7281 * pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
7282 *
7283 * RETURNS
7284 * Nothing.
7285 */
7287{
7288 FIXME("(%p): stub\n", pStubMsg);
7289}
7290
7291/***********************************************************************
7292 * NdrCorrelationFree [RPCRT4.@]
7293 *
7294 * Frees any resources used while unmarshalling parameters that need
7295 * correlation validity checking.
7296 *
7297 * PARAMS
7298 * pStubMsg [I] MIDL_STUB_MESSAGE used during unmarshalling.
7299 *
7300 * RETURNS
7301 * Nothing.
7302 */
7304{
7305 /* FIXME: free memory */
7306}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
unsigned long error_status_t
Definition: basetyps.h:83
PFOR_CONTEXT fc
Definition: for.c:57
Definition: bufpool.h:45
static VOID Mark(PGUI_CONSOLE_DATA GuiData)
Definition: conwnd.c:300
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define lstrlenW
Definition: compat.h:750
static unsigned char * ComplexUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer, unsigned char fMustAlloc)
static unsigned char * union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrConformantVaryingStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static ULONG safe_multiply(ULONG a, ULONG b)
Definition: ndr_marshall.c:701
void WINAPI NdrContextHandleSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrFixedArrayFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static unsigned char * union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, ULONG discriminant, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
void WINAPI NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void safe_copy_to_buffer(MIDL_STUB_MESSAGE *pStubMsg, const void *p, ULONG size)
Definition: ndr_marshall.c:749
void WINAPI NdrConformantStructFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void array_buffer_size(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
static ULONG array_read_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static ULONG EmbeddedComplexMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrSimpleStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
PFORMAT_STRING ComputeConformanceOrVariance(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG_PTR def, ULONG_PTR *pCount)
Definition: ndr_marshall.c:555
void WINAPI NdrServerContextMarshall(PMIDL_STUB_MESSAGE pStubMsg, NDR_SCONTEXT ContextHandle, NDR_RUNDOWN RundownRoutine)
#define NDR_LOCAL_UINT32_WRITE(pchar, uint32)
Definition: ndr_marshall.c:85
#define MEML_MAGIC
Definition: ndr_marshall.c:399
static unsigned char * ComplexMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
void WINAPI NdrCorrelationPass(PMIDL_STUB_MESSAGE pStubMsg)
static unsigned char *WINAPI NdrRangeMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
static unsigned char * EmbeddedPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void EmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
struct _NDR_CSTRUCT_FORMAT NDR_CSTRUCT_FORMAT
static void WINAPI NdrRangeFree(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
void WINAPI NdrConvert2(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, LONG NumberParams)
static void UserMarshalCB(PMIDL_STUB_MESSAGE pStubMsg, USER_MARSHAL_CB_TYPE cbtype, PFORMAT_STRING pFormat, USER_MARSHAL_CB *umcb)
static void SizeConformance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:538
unsigned char *WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
void WINAPI NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
unsigned char *WINAPI NdrConformantStringMarshall(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *pszMessage, PFORMAT_STRING pFormat)
static void WriteConformance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:516
static BOOL IsConformanceOrVariancePresent(PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:462
void WINAPI NdrServerContextNewMarshall(PMIDL_STUB_MESSAGE pStubMsg, NDR_SCONTEXT ContextHandle, NDR_RUNDOWN RundownRoutine, PFORMAT_STRING pFormat)
static void SizeVariance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:547
void WINAPI NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static PFORMAT_STRING SkipConformance(const PMIDL_STUB_MESSAGE pStubMsg, const PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:467
static unsigned char * ComplexBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
unsigned char *WINAPI NdrConformantArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static ULONG WINAPI NdrByteCountPointerMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING)
unsigned char *WINAPI NdrByteCountPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
#define BASE_TYPE_UNMARSHALL(type)
void WINAPI NdrPointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
RPC_STATUS RPC_ENTRY NdrGetUserMarshalInfo(ULONG *flags, ULONG level, NDR_USER_MARSHAL_INFO *umi)
static unsigned char *WINAPI NdrBaseTypeUnmarshall(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
void WINAPI NdrXmitOrRepAsFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static PFORMAT_STRING get_arm_offset_from_union_arm_selector(PMIDL_STUB_MESSAGE pStubMsg, ULONG discriminant, PFORMAT_STRING pFormat)
ULONG WINAPI NdrNonEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
ULONG WINAPI NdrXmitOrRepAsMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrConformantArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
unsigned char *WINAPI NdrConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static void align_pointer_offset(unsigned char **ptr, unsigned char *base, unsigned int align)
Definition: ndr_marshall.c:109
void WINAPI NdrByteCountPointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrConformantVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void align_length(ULONG *len, unsigned int align)
Definition: ndr_marshall.c:91
void WINAPI NdrCorrelationFree(PMIDL_STUB_MESSAGE pStubMsg)
static PFORMAT_STRING SkipVariance(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:694
void WINAPI NdrComplexArrayFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, unsigned char FormatChar)
static void WINAPI NdrBaseTypeFree(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
static void safe_copy_from_buffer(MIDL_STUB_MESSAGE *pStubMsg, void *p, ULONG size)
Definition: ndr_marshall.c:733
void WINAPI NdrVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
#define RANGE_UNMARSHALL(mem_type, wire_type, format_spec)
static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)
ULONG WINAPI NdrFixedArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
void WINAPI NdrConformantVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void array_free(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
static void NdrFree(MIDL_STUB_MESSAGE *pStubMsg, unsigned char *Pointer)
Definition: ndr_marshall.c:455
void WINAPI NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void safe_buffer_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
Definition: ndr_marshall.c:712
NDR_SCONTEXT WINAPI NdrContextHandleInitialize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
void WINAPI NdrSimpleStructFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
#define USER_MARSHAL_PTR_PREFIX
void WINAPI NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrNonEncapsulatedUnionMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void WINAPI NdrRangeBufferSize(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
void WINAPI NdrClientContextMarshall(PMIDL_STUB_MESSAGE pStubMsg, NDR_CCONTEXT ContextHandle, int fCheck)
unsigned char *WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
void WINAPI NdrClearOutParameters(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, void *ArgAddr)
void WINAPI NdrConformantVaryingArrayFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static ULONG WINAPI NdrBaseTypeMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING)
unsigned char *WINAPI NdrConformantVaryingStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void WINAPI NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
ULONG WINAPI NdrConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static void array_memory_size(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, unsigned char fHasPointers)
NDR_SCONTEXT WINAPI NdrServerContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg)
static PFORMAT_STRING ReadVariance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat, ULONG MaxValue)
Definition: ndr_marshall.c:483
static void align_pointer(unsigned char **ptr, unsigned int align)
Definition: ndr_marshall.c:96
unsigned char *WINAPI NdrNonConformantStringMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void PointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char *Pointer, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:812
unsigned char *WINAPI NdrNonConformantStringUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
unsigned char *WINAPI NdrFixedArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
#define NDR_LOCAL_UINT32_READ(pchar)
Definition: ndr_marshall.c:87
unsigned char *WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static ULONG EmbeddedPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrUserMarshalUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
void WINAPI NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void align_pointer_offset_clear(unsigned char **ptr, unsigned char *base, unsigned int align)
Definition: ndr_marshall.c:115
void WINAPI NdrComplexStructFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrComplexArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static void dump_pointer_attr(unsigned char attr)
Definition: ndr_marshall.c:794
static unsigned char *WINAPI NdrContextHandleMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
unsigned char *WINAPI NdrVaryingArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrUserMarshalMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
const NDR_MEMORYSIZE NdrMemorySizer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:303
unsigned char *WINAPI NdrXmitOrRepAsMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrConformantArrayFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrByteCountPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrClientContextUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, NDR_CCONTEXT *pContextHandle, RPC_BINDING_HANDLE BindHandle)
ULONG ComplexStructSize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static void array_compute_and_size_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static ULONG union_arm_memory_size(PMIDL_STUB_MESSAGE pStubMsg, ULONG discriminant, PFORMAT_STRING pFormat)
void WINAPI NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
const NDR_BUFFERSIZE NdrBufferSizer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:259
void WINAPI NdrXmitOrRepAsBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrRangeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
ULONG WINAPI NdrUserMarshalMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static LONG unmarshall_discriminant(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING *ppFormat)
NDR_SCONTEXT WINAPI NdrServerContextNewUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static ULONG get_discriminant(unsigned char fc, const unsigned char *pMemory)
unsigned char *WINAPI NdrComplexArrayMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrNonEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void PointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Pointer, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrConformantArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
const NDR_MARSHALL NdrMarshaller[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:171
ULONG WINAPI NdrPointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrNonEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static ULONG WINAPI NdrRangeMemorySize(PMIDL_STUB_MESSAGE, PFORMAT_STRING)
static void safe_buffer_length_increment(MIDL_STUB_MESSAGE *pStubMsg, ULONG size)
Definition: ndr_marshall.c:720
static unsigned char * ComplexFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
#define NDR_TABLE_SIZE
Definition: ndr_marshall.c:130
void *WINAPI NdrAllocate(MIDL_STUB_MESSAGE *pStubMsg, SIZE_T len)
Definition: ndr_marshall.c:418
static ULONG ComplexStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, PFORMAT_STRING pPointer)
static ULONG EmbeddedComplexSize(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
static unsigned char * EmbeddedPointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pDstBuffer, unsigned char *pSrcMemoryPtrs, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
void WINAPI NdrCorrelationInitialize(PMIDL_STUB_MESSAGE pStubMsg, void *pMemory, ULONG CacheSize, ULONG Flags)
void WINAPI NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void align_pointer_clear(unsigned char **ptr, unsigned int align)
Definition: ndr_marshall.c:102
#define NDR_POINTER_ID(pStubMsg)
Definition: ndr_marshall.c:129
static void union_arm_free(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
ULONG WINAPI NdrEncapsulatedUnionMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrComplexArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static ULONG PointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, PFORMAT_STRING pFormat)
static void union_arm_buffer_size(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, ULONG discriminant, PFORMAT_STRING pFormat)
struct _NDR_MEMORY_LIST NDR_MEMORY_LIST
static void array_compute_and_write_conformance(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrXmitOrRepAsUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static void array_write_variance_and_marshall(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, unsigned char fHasPointers)
void WINAPI NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrFixedArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
const NDR_UNMARSHALL NdrUnmarshaller[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:215
void WINAPI NdrUserMarshalBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void EmbeddedPointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrEncapsulatedUnionUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
ULONG WINAPI NdrNonConformantStringMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrConformantVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
void WINAPI NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, unsigned char FormatChar)
void WINAPI NdrConvert(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
#define NDR_TABLE_MASK
Definition: ndr_marshall.c:131
static ULONG array_read_variance_and_unmarshall(unsigned char fc, PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc, unsigned char fUseBufferMemoryServer, unsigned char fUnmarshall)
#define STD_OVERFLOW_CHECK(_Msg)
Definition: ndr_marshall.c:122
void WINAPI NdrEncapsulatedUnionFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
ULONG WINAPI NdrConformantStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
struct _NDR_CSTRUCT_FORMAT NDR_CVSTRUCT_FORMAT
static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *Buffer, unsigned char **pPointer, unsigned char *pSrcPointer, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
Definition: ndr_marshall.c:882
unsigned char *WINAPI NdrConformantVaryingArrayUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
static unsigned char *WINAPI NdrBaseTypeMarshall(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
void WINAPI NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
unsigned char *WINAPI NdrPointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
void WINAPI NdrConformantVaryingStructFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static unsigned char *WINAPI NdrContextHandleUnmarshall(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
void WINAPI NdrUserMarshalFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void * NdrAllocateZero(MIDL_STUB_MESSAGE *stubmsg, SIZE_T len)
Definition: ndr_marshall.c:448
const NDR_FREE NdrFreer[NDR_TABLE_SIZE]
Definition: ndr_marshall.c:347
static void validate_string_data(MIDL_STUB_MESSAGE *pStubMsg, ULONG bufsize, ULONG esize)
Definition: ndr_marshall.c:765
void WINAPI NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
static void WriteVariance(MIDL_STUB_MESSAGE *pStubMsg)
Definition: ndr_marshall.c:526
ULONG WINAPI NdrVaryingArrayMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
ULONG WINAPI NdrConformantVaryingStructMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
static PFORMAT_STRING ReadConformance(MIDL_STUB_MESSAGE *pStubMsg, PFORMAT_STRING pFormat)
Definition: ndr_marshall.c:472
static void WINAPI NdrBaseTypeBufferSize(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
#define assert(x)
Definition: debug.h:53
return ret
Definition: mutex.c:146
#define ULONG_PTR
Definition: config.h:101
int align(int length, int align)
Definition: dsound8.c:36
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Character const *const size_t const max_count
Definition: fullpath.cpp:66
FxMemoryObject * pMemory
GLint level
Definition: gl.h:1546
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei stride
Definition: glext.h:5848
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLsizei const GLvoid * pointer
Definition: glext.h:5848
GLuint index
Definition: glext.h:6031
GLenum GLint GLuint mask
Definition: glext.h:6028
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLbitfield flags
Definition: glext.h:7161
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
GLenum GLsizei len
Definition: glext.h:6722
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define SHRT_MAX
Definition: limits.h:37
#define buffer_end
Definition: intsym.h:274
#define buffer_start
Definition: intsym.h:267
#define LOBYTE(W)
Definition: jmemdos.c:487
#define d
Definition: ke_i.h:81
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_wn
Definition: kernel32.h:33
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1204
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:91
static float(__cdecl *square_half_float)(float x
static UINT array_size
Definition: msctf.cpp:39
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
NDR_SCONTEXT WINAPI NDRSContextUnmarshall2(RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation, void *CtxGuard, ULONG Flags)
void WINAPI NDRCContextUnmarshall(NDR_CCONTEXT *CContext, RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation)
void WINAPI NDRSContextMarshall2(RPC_BINDING_HANDLE hBinding, NDR_SCONTEXT SContext, void *pBuff, NDR_RUNDOWN userRunDownIn, void *CtxGuard, ULONG Flags)
void WINAPI NDRCContextMarshall(NDR_CCONTEXT CContext, void *pBuff)
int WINAPI NdrFullPointerFree(PFULL_PTR_XLAT_TABLES pXlatTables, void *Pointer)
int WINAPI NdrFullPointerQueryRefId(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId, unsigned char QueryType, void **ppPointer)
int WINAPI NdrFullPointerQueryPointer(PFULL_PTR_XLAT_TABLES pXlatTables, void *pPointer, unsigned char QueryType, ULONG *pRefId)
void WINAPI NdrFullPointerInsertRefId(PFULL_PTR_XLAT_TABLES pXlatTables, ULONG RefId, void *pPointer)
void(WINAPI * NDR_BUFFERSIZE)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:55
static PFORMAT_STRING ComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
Definition: ndr_misc.h:37
unsigned char *(WINAPI * NDR_UNMARSHALL)(PMIDL_STUB_MESSAGE, unsigned char **, PFORMAT_STRING, unsigned char)
Definition: ndr_misc.h:54
static PFORMAT_STRING ComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
Definition: ndr_misc.h:42
ULONG(WINAPI * NDR_MEMORYSIZE)(PMIDL_STUB_MESSAGE, PFORMAT_STRING)
Definition: ndr_misc.h:56
unsigned char *(WINAPI * NDR_MARSHALL)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:53
void(WINAPI * NDR_FREE)(PMIDL_STUB_MESSAGE, unsigned char *, PFORMAT_STRING)
Definition: ndr_misc.h:57
unsigned char *WINAPI NdrInterfacePointerMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:277
unsigned char *WINAPI NdrInterfacePointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
Definition: ndr_ole.c:306
void WINAPI NdrInterfacePointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:342
ULONG WINAPI NdrInterfacePointerMemorySize(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:360
void WINAPI NdrInterfacePointerFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:379
#define DWORD
Definition: nt_native.h:44
@ arm
Definition: optimize.h:109
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define INT
Definition: polytest.cpp:20
#define FC_POINTER_DEREF
Definition: ndrtypes.h:276
#define FC_DONT_FREE
Definition: ndrtypes.h:273
#define FC_TOP_LEVEL_CONFORMANCE
Definition: ndrtypes.h:300
#define FC_POINTER_CONFORMANCE
Definition: ndrtypes.h:299
#define HANDLE_PARAM_IS_OUT
Definition: ndrtypes.h:281
#define FC_ALLOCATE_ALL_NODES
Definition: ndrtypes.h:272
#define NDR_CONTEXT_HANDLE_SERIALIZE
Definition: ndrtypes.h:287
#define USER_MARSHAL_POINTER
Definition: ndrtypes.h:306
@ FC_STRUCTPAD4
Definition: ndrtypes.h:213
@ FC_ADD_1
Definition: ndrtypes.h:246
@ FC_USMALL
Definition: ndrtypes.h:138
@ FC_INT3264
Definition: ndrtypes.h:268
@ FC_STRUCT
Definition: ndrtypes.h:157
@ FC_SUB_1
Definition: ndrtypes.h:247
@ FC_SMALL
Definition: ndrtypes.h:137
@ FC_BOGUS_STRUCT
Definition: ndrtypes.h:162
@ FC_CPSTRUCT
Definition: ndrtypes.h:160
@ FC_DEREFERENCE
Definition: ndrtypes.h:243
@ FC_C_CSTRING
Definition: ndrtypes.h:172
@ FC_IGNORE
Definition: ndrtypes.h:149
@ FC_ALIGNM4
Definition: ndrtypes.h:203
@ FC_DOUBLE
Definition: ndrtypes.h:146
@ FC_SMFARRAY
Definition: ndrtypes.h:166
@ FC_USHORT
Definition: ndrtypes.h:141
@ FC_ALIGNM2
Definition: ndrtypes.h:202
@ FC_ENUM16
Definition: ndrtypes.h:147
@ FC_C_WSTRING
Definition: ndrtypes.h:175
@ FC_ERROR_STATUS_T
Definition: ndrtypes.h:150
@ FC_LONG
Definition: ndrtypes.h:142
@ FC_CHAR
Definition: ndrtypes.h:136
@ FC_RANGE
Definition: ndrtypes.h:266
@ FC_OP
Definition: ndrtypes.h:154
@ FC_HYPER
Definition: ndrtypes.h:145
@ FC_NO_REPEAT
Definition: ndrtypes.h:222
@ FC_LGVARRAY
Definition: ndrtypes.h:169
@ FC_STRUCTPAD1
Definition: ndrtypes.h:210
@ FC_CVSTRUCT
Definition: ndrtypes.h:161
@ FC_EMBEDDED_COMPLEX
Definition: ndrtypes.h:233
@ FC_CSTRING
Definition: ndrtypes.h:176
@ FC_BOGUS_ARRAY
Definition: ndrtypes.h:170
@ FC_ULONG
Definition: ndrtypes.h:143
@ FC_STRUCTPAD7
Definition: ndrtypes.h:216
@ FC_PP
Definition: ndrtypes.h:228
@ FC_ALIGNM8
Definition: ndrtypes.h:204
@ FC_MULT_2
Definition: ndrtypes.h:245
@ FC_UP
Definition: ndrtypes.h:153
@ FC_CARRAY
Definition: ndrtypes.h:164
@ FC_SMVARRAY
Definition: ndrtypes.h:168
@ FC_NON_ENCAPSULATED_UNION
Definition: ndrtypes.h:182
@ FC_POINTER
Definition: ndrtypes.h:200
@ FC_CALLBACK
Definition: ndrtypes.h:249
@ FC_PAD
Definition: ndrtypes.h:254
@ FC_STRING_SIZED
Definition: ndrtypes.h:218
@ FC_RP
Definition: ndrtypes.h:152
@ FC_FIXED_REPEAT
Definition: ndrtypes.h:223
@ FC_PSTRUCT
Definition: ndrtypes.h:158
@ FC_STRUCTPAD5
Definition: ndrtypes.h:214
@ FC_WSTRING
Definition: ndrtypes.h:179
@ FC_FLOAT
Definition: ndrtypes.h:144
@ FC_STRUCTPAD2
Definition: ndrtypes.h:211
@ FC_USER_MARSHAL
Definition: ndrtypes.h:261
@ FC_CSTRUCT
Definition: ndrtypes.h:159
@ FC_ENUM32
Definition: ndrtypes.h:148
@ FC_BIND_CONTEXT
Definition: ndrtypes.h:191
@ FC_CVARRAY
Definition: ndrtypes.h:165
@ FC_VARIABLE_OFFSET
Definition: ndrtypes.h:226
@ FC_STRUCTPAD6
Definition: ndrtypes.h:215
@ FC_FP
Definition: ndrtypes.h:155
@ FC_BYTE
Definition: ndrtypes.h:135
@ FC_END
Definition: ndrtypes.h:253
@ FC_DIV_2
Definition: ndrtypes.h:244
@ FC_UINT3264
Definition: ndrtypes.h:269
@ FC_STRUCTPAD3
Definition: ndrtypes.h:212
@ FC_IP
Definition: ndrtypes.h:189
@ FC_LGFARRAY
Definition: ndrtypes.h:167
@ FC_VARIABLE_REPEAT
Definition: ndrtypes.h:224
@ FC_SHORT
Definition: ndrtypes.h:140
@ FC_WCHAR
Definition: ndrtypes.h:139
#define FC_NORMAL_CONFORMANCE
Definition: ndrtypes.h:298
#define HANDLE_PARAM_IS_IN
Definition: ndrtypes.h:280
#define FC_SIMPLE_POINTER
Definition: ndrtypes.h:275
#define NDR_CONTEXT_HANDLE_NOSERIALIZE
Definition: ndrtypes.h:286
#define FC_TOP_LEVEL_MULTID_CONFORMANCE
Definition: ndrtypes.h:302
#define FC_CONSTANT_CONFORMANCE
Definition: ndrtypes.h:301
#define FC_ALLOCED_ON_STACK
Definition: ndrtypes.h:274
#define NDR_STRICT_CONTEXT_HANDLE
Definition: ndrtypes.h:285
#define HANDLE_PARAM_IS_VIA_PTR
Definition: ndrtypes.h:279
const WCHAR * str
#define RPC_CONTEXT_HANDLE_DEFAULT_FLAGS
Definition: rpcdcep.h:56
#define RPC_CONTEXT_HANDLE_DONT_SERIALIZE
Definition: rpcdcep.h:59
#define RPC_CONTEXT_HANDLE_SERIALIZE
Definition: rpcdcep.h:58
const unsigned char * PFORMAT_STRING
Definition: rpcndr.h:159
USER_MARSHAL_CB_TYPE
Definition: rpcndr.h:306
@ USER_MARSHAL_CB_BUFFER_SIZE
Definition: rpcndr.h:307
@ USER_MARSHAL_CB_UNMARSHALL
Definition: rpcndr.h:309
@ USER_MARSHAL_CB_FREE
Definition: rpcndr.h:310
@ USER_MARSHAL_CB_MARSHALL
Definition: rpcndr.h:308
#define cbNDRContext
Definition: rpcndr.h:116
void(__RPC_USER * NDR_RUNDOWN)(void *context)
Definition: rpcndr.h:118
#define USER_MARSHAL_CB_SIGNATURE
Definition: rpcndr.h:301
#define NDRSContextValue(hContext)
Definition: rpcndr.h:115
#define RPC_S_INVALID_ARG
Definition: rpcnterr.h:23
#define RPC_X_INVALID_BUFFER
Definition: rpcnterr.h:40
#define RPC_X_NO_MEMORY
Definition: rpcnterr.h:35
#define RPC_S_OK
Definition: rpcnterr.h:22
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:213
#define RPC_ENTRY
Definition: rpc.h:63
long RPC_STATUS
Definition: rpc.h:48
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
_In_ size_t const maxsize
Definition: strftime.cpp:120
unsigned char alignment
unsigned char type
ULONG low_value
unsigned char type
ULONG high_value
unsigned char flags_type
unsigned char alignment
unsigned char type
unsigned short total_size
ULONG PointerLength
Definition: rpcndr.h:216
PNDR_CORRELATION_INFO pCorrInfo
Definition: rpcndr.h:245
unsigned char * StackTop
Definition: rpcndr.h:209
unsigned char CorrDespIncrement
Definition: rpcndr.h:201
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:236
void * pMemoryList
Definition: rpcndr.h:247
unsigned char * Buffer
Definition: rpcndr.h:186
struct _FULL_PTR_XLAT_TABLES * FullPtrXlatTables
Definition: rpcndr.h:214
ULONG BufferLength
Definition: rpcndr.h:190
int IgnoreEmbeddedPointers
Definition: rpcndr.h:199
ULONG MemorySize
Definition: rpcndr.h:191
unsigned char * BufferMark
Definition: rpcndr.h:189
unsigned char * BufferEnd
Definition: rpcndr.h:188
DWORD dwDestContext
Definition: rpcndr.h:232
unsigned char * Memory
Definition: rpcndr.h:192
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:185
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:213
unsigned char IsClient
Definition: rpcndr.h:193
unsigned char * BufferStart
Definition: rpcndr.h:187
unsigned int fHasNewCorrDesc
Definition: rpcndr.h:222
unsigned char * PointerBufferMark
Definition: rpcndr.h:200
ULONG ActualCount
Definition: rpcndr.h:206
ULONG_PTR MaxCount
Definition: rpcndr.h:204
unsigned char alignment
short offset_to_array_description
unsigned char type
unsigned short memory_size
struct _NDR_MEMORY_LIST * next
Definition: ndr_marshall.c:396
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:543
NDR_USER_MARSHAL_INFO_LEVEL1 Level1
Definition: rpcndr.h:552
void * Buffer
Definition: rpcdcep.h:40
ULONG DataRepresentation
Definition: rpcdcep.h:39
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:104
PFORMAT_STRING pFormat
Definition: rpcndr.h:320
USER_MARSHAL_CB_TYPE CBType
Definition: rpcndr.h:319
PFORMAT_STRING pTypeFormat
Definition: rpcndr.h:321
PFORMAT_STRING pReserve
Definition: rpcndr.h:317
ULONG Signature
Definition: rpcndr.h:318
PMIDL_STUB_MESSAGE pStubMsg
Definition: rpcndr.h:316
Definition: cookie.c:202
Definition: mem.c:349
static unsigned int bufptr
Definition: tncon.cpp:77
int32_t INT_PTR
Definition: typedefs.h:64
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777
#define WINAPI
Definition: msvc.h:6
#define RPC_S_INVALID_BOUND
Definition: winerror.h:1400
#define RPC_S_INVALID_TAG
Definition: winerror.h:1399
#define RPC_X_ENUM_VALUE_OUT_OF_RANGE
Definition: winerror.h:1445
#define RPC_X_BAD_STUB_DATA
Definition: winerror.h:1447
#define RPC_X_NULL_REF_POINTER
Definition: winerror.h:1444
#define RPC_S_INTERNAL_ERROR
Definition: winerror.h:1431
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193