Changes in crossover-wine-src-6.1.0 except for configure
[wine/hacks.git] / dlls / rpcrt4 / tests / ndr_marshall.c
blob163ef9eaae6b384a29728799eeed746245571a78
1 /*
2 * Unit test suite for ndr marshalling functions
4 * Copyright 2006 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define NTDDI_WIN2K 0x05000000
24 #define NTDDI_VERSION NTDDI_WIN2K /* for some MIDL_STUB_MESSAGE fields */
26 #include "wine/test.h"
27 #include <windef.h>
28 #include <winbase.h>
29 #include <winnt.h>
30 #include <winerror.h>
32 #include "rpc.h"
33 #include "rpcdce.h"
34 #include "rpcproxy.h"
35 #include "oaidl.h"
38 static int my_alloc_called;
39 static int my_free_called;
40 static void * CALLBACK my_alloc(size_t size)
42 my_alloc_called++;
43 return NdrOleAllocate(size);
46 static void CALLBACK my_free(void *ptr)
48 my_free_called++;
49 NdrOleFree(ptr);
52 static const MIDL_STUB_DESC Object_StubDesc =
54 NULL,
55 my_alloc,
56 my_free,
57 { 0 },
62 NULL, /* format string, filled in by tests */
63 1, /* -error bounds_check flag */
64 0x20000, /* Ndr library version */
66 0x50100a4, /* MIDL Version 5.1.164 */
68 NULL,
69 0, /* notify & notify_flag routine table */
70 1, /* Flags */
71 0, /* Reserved3 */
72 0, /* Reserved4 */
73 0 /* Reserved5 */
77 static void test_ndr_simple_type(void)
79 RPC_MESSAGE RpcMessage;
80 MIDL_STUB_MESSAGE StubMsg;
81 MIDL_STUB_DESC StubDesc;
82 long l, l2 = 0;
84 StubDesc = Object_StubDesc;
85 StubDesc.pFormatTypes = NULL;
87 NdrClientInitializeNew(
88 &RpcMessage,
89 &StubMsg,
90 &StubDesc,
91 0);
93 StubMsg.BufferLength = 16;
94 StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
95 l = 0xcafebabe;
96 NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, 8 /* FC_LONG */);
97 ok(StubMsg.Buffer == StubMsg.BufferStart + 4, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
98 ok(*(long*)StubMsg.BufferStart == l, "%ld\n", *(long*)StubMsg.BufferStart);
100 StubMsg.Buffer = StubMsg.BufferStart + 1;
101 NdrSimpleTypeMarshall(&StubMsg, (unsigned char*)&l, 8 /* FC_LONG */);
102 ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
103 ok(*(long*)(StubMsg.BufferStart + 4) == l, "%ld\n", *(long*)StubMsg.BufferStart);
105 StubMsg.Buffer = StubMsg.BufferStart + 1;
106 NdrSimpleTypeUnmarshall(&StubMsg, (unsigned char*)&l2, 8 /* FC_LONG */);
107 ok(StubMsg.Buffer == StubMsg.BufferStart + 8, "%p %p\n", StubMsg.Buffer, StubMsg.BufferStart);
108 ok(l2 == l, "%ld\n", l2);
110 HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
113 static void test_pointer_marshal(const unsigned char *formattypes,
114 void *memsrc,
115 long srcsize,
116 const void *wiredata,
117 long wiredatalen,
118 int(*cmp)(const void*,const void*,size_t),
119 long num_additional_allocs,
120 const char *msgpfx)
122 RPC_MESSAGE RpcMessage;
123 MIDL_STUB_MESSAGE StubMsg;
124 MIDL_STUB_DESC StubDesc;
125 DWORD size;
126 void *ptr;
127 unsigned char *mem, *mem_orig;
129 my_alloc_called = my_free_called = 0;
130 if(!cmp)
131 cmp = memcmp;
133 StubDesc = Object_StubDesc;
134 StubDesc.pFormatTypes = formattypes;
136 NdrClientInitializeNew(
137 &RpcMessage,
138 &StubMsg,
139 &StubDesc,
142 StubMsg.BufferLength = 0;
143 NdrPointerBufferSize( &StubMsg,
144 memsrc,
145 formattypes );
146 ok(StubMsg.BufferLength >= wiredatalen, "%s: length %d\n", msgpfx, StubMsg.BufferLength);
148 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
149 StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
150 StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
152 memset(StubMsg.BufferStart, 0x0, StubMsg.BufferLength); /* This is a hack to clear the padding between the ptr and longlong/double */
154 ptr = NdrPointerMarshall( &StubMsg, memsrc, formattypes );
155 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
156 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
157 ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled\n", msgpfx);
159 StubMsg.Buffer = StubMsg.BufferStart;
160 StubMsg.MemorySize = 0;
162 if (0)
164 /* NdrPointerMemorySize crashes under Wine */
165 size = NdrPointerMemorySize( &StubMsg, formattypes );
166 ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size);
167 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
168 if(formattypes[1] & 0x10 /* FC_POINTER_DEREF */)
169 ok(size == srcsize + 4, "%s: mem size %u\n", msgpfx, size);
170 else
171 ok(size == srcsize, "%s: mem size %u\n", msgpfx, size);
173 StubMsg.Buffer = StubMsg.BufferStart;
174 StubMsg.MemorySize = 16;
175 size = NdrPointerMemorySize( &StubMsg, formattypes );
176 ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size);
177 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
178 if(formattypes[1] & 0x10 /* FC_POINTER_DEREF */)
179 ok(size == srcsize + 4 + 16, "%s: mem size %u\n", msgpfx, size);
180 else
181 ok(size == srcsize + 16, "%s: mem size %u\n", msgpfx, size);
183 StubMsg.Buffer = StubMsg.BufferStart;
184 StubMsg.MemorySize = 1;
185 size = NdrPointerMemorySize( &StubMsg, formattypes );
186 ok(size == StubMsg.MemorySize, "%s: mem size %u size %u\n", msgpfx, StubMsg.MemorySize, size);
187 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
188 if(formattypes[1] & 0x10 /* FC_POINTER_DEREF */)
189 ok(size == srcsize + 4 + (srcsize == 8 ? 8 : 4), "%s: mem size %u\n", msgpfx, size);
190 else
191 ok(size == srcsize + (srcsize == 8 ? 8 : 4), "%s: mem size %u\n", msgpfx, size);
194 size = srcsize;
195 if(formattypes[1] & 0x10) size += 4;
197 StubMsg.Buffer = StubMsg.BufferStart;
198 StubMsg.MemorySize = 0;
199 mem_orig = mem = HeapAlloc(GetProcessHeap(), 0, size);
201 if(formattypes[1] & 0x10 /* FC_POINTER_DEREF */)
202 *(void**)mem = NULL;
203 ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 );
204 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
205 ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig);
206 ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
207 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
208 ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize);
209 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
210 my_alloc_called = 0;
212 /* reset the buffer and call with must alloc */
213 StubMsg.Buffer = StubMsg.BufferStart;
214 if(formattypes[1] & 0x10 /* FC_POINTER_DEREF */)
215 *(void**)mem = NULL;
216 ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 1 );
217 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
218 /* doesn't allocate mem in this case */
219 todo_wine {
220 ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig);
222 ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
223 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
224 ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize);
226 todo_wine {
227 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
229 my_alloc_called = 0;
230 if(formattypes[0] != 0x11 /* FC_RP */)
232 /* now pass the address of a NULL ptr */
233 mem = NULL;
234 StubMsg.Buffer = StubMsg.BufferStart;
235 ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 );
236 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
237 ok(mem != StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem points to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart);
238 ok(!cmp(mem, memsrc, size), "%s: incorrectly unmarshaled\n", msgpfx);
239 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
240 ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize);
241 ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
242 my_alloc_called = 0;
243 NdrPointerFree(&StubMsg, mem, formattypes);
245 /* again pass address of NULL ptr, but pretend we're a server */
246 mem = NULL;
247 StubMsg.Buffer = StubMsg.BufferStart;
248 StubMsg.IsClient = 0;
249 ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 );
250 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
251 todo_wine {
252 ok(mem == StubMsg.BufferStart + wiredatalen - srcsize, "%s: mem doesn't point to buffer %p %p\n", msgpfx, mem, StubMsg.BufferStart);
254 ok(!cmp(mem, memsrc, size), "%s: incorrecly unmarshaled\n", msgpfx);
255 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p len %ld\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart, wiredatalen);
256 ok(StubMsg.MemorySize == 0, "%s: memorysize %d\n", msgpfx, StubMsg.MemorySize);
257 todo_wine {
258 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
259 my_alloc_called = 0;
262 HeapFree(GetProcessHeap(), 0, mem_orig);
263 HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
266 static int deref_cmp(const void *s1, const void *s2, size_t num)
268 return memcmp(*(const void *const *)s1, *(const void *const *)s2, num);
272 static void test_simple_types(void)
274 unsigned char wiredata[16];
275 unsigned char ch;
276 unsigned char *ch_ptr;
277 unsigned short s;
278 unsigned int i;
279 unsigned long l;
280 ULONGLONG ll;
281 float f;
282 double d;
284 static const unsigned char fmtstr_up_char[] =
286 0x12, 0x8, /* FC_UP [simple_pointer] */
287 0x2, /* FC_CHAR */
288 0x5c, /* FC_PAD */
290 static const unsigned char fmtstr_up_byte[] =
292 0x12, 0x8, /* FC_UP [simple_pointer] */
293 0x1, /* FC_BYTE */
294 0x5c, /* FC_PAD */
296 static const unsigned char fmtstr_up_small[] =
298 0x12, 0x8, /* FC_UP [simple_pointer] */
299 0x3, /* FC_SMALL */
300 0x5c, /* FC_PAD */
302 static const unsigned char fmtstr_up_usmall[] =
304 0x12, 0x8, /* FC_UP [simple_pointer] */
305 0x4, /* FC_USMALL */
306 0x5c, /* FC_PAD */
308 static const unsigned char fmtstr_rp_char[] =
310 0x11, 0x8, /* FC_RP [simple_pointer] */
311 0x2, /* FC_CHAR */
312 0x5c, /* FC_PAD */
314 static const unsigned char fmtstr_rpup_char[] =
316 0x11, 0x14, /* FC_RP [alloced_on_stack] */
317 NdrFcShort( 0x2 ), /* Offset= 2 (4) */
318 0x12, 0x8, /* FC_UP [simple_pointer] */
319 0x2, /* FC_CHAR */
320 0x5c, /* FC_PAD */
322 static const unsigned char fmtstr_rpup_char2[] =
324 0x11, 0x04, /* FC_RP [alloced_on_stack] */
325 NdrFcShort( 0x2 ), /* Offset= 2 (4) */
326 0x12, 0x8, /* FC_UP [simple_pointer] */
327 0x2, /* FC_CHAR */
328 0x5c, /* FC_PAD */
331 static const unsigned char fmtstr_up_wchar[] =
333 0x12, 0x8, /* FC_UP [simple_pointer] */
334 0x5, /* FC_WCHAR */
335 0x5c, /* FC_PAD */
337 static const unsigned char fmtstr_up_short[] =
339 0x12, 0x8, /* FC_UP [simple_pointer] */
340 0x6, /* FC_SHORT */
341 0x5c, /* FC_PAD */
343 static const unsigned char fmtstr_up_ushort[] =
345 0x12, 0x8, /* FC_UP [simple_pointer] */
346 0x7, /* FC_USHORT */
347 0x5c, /* FC_PAD */
349 static const unsigned char fmtstr_up_enum16[] =
351 0x12, 0x8, /* FC_UP [simple_pointer] */
352 0xd, /* FC_ENUM16 */
353 0x5c, /* FC_PAD */
355 static const unsigned char fmtstr_up_long[] =
357 0x12, 0x8, /* FC_UP [simple_pointer] */
358 0x8, /* FC_LONG */
359 0x5c, /* FC_PAD */
361 static const unsigned char fmtstr_up_ulong[] =
363 0x12, 0x8, /* FC_UP [simple_pointer] */
364 0x9, /* FC_ULONG */
365 0x5c, /* FC_PAD */
367 static const unsigned char fmtstr_up_enum32[] =
369 0x12, 0x8, /* FC_UP [simple_pointer] */
370 0xe, /* FC_ENUM32 */
371 0x5c, /* FC_PAD */
373 static const unsigned char fmtstr_up_errorstatus[] =
375 0x12, 0x8, /* FC_UP [simple_pointer] */
376 0x10, /* FC_ERROR_STATUS_T */
377 0x5c, /* FC_PAD */
380 static const unsigned char fmtstr_up_longlong[] =
382 0x12, 0x8, /* FC_UP [simple_pointer] */
383 0xb, /* FC_HYPER */
384 0x5c, /* FC_PAD */
386 static const unsigned char fmtstr_up_float[] =
388 0x12, 0x8, /* FC_UP [simple_pointer] */
389 0xa, /* FC_FLOAT */
390 0x5c, /* FC_PAD */
392 static const unsigned char fmtstr_up_double[] =
394 0x12, 0x8, /* FC_UP [simple_pointer] */
395 0xc, /* FC_DOUBLE */
396 0x5c, /* FC_PAD */
399 ch = 0xa5;
400 ch_ptr = &ch;
401 *(void**)wiredata = ch_ptr;
402 wiredata[sizeof(void*)] = ch;
404 test_pointer_marshal(fmtstr_up_char, ch_ptr, 1, wiredata, 5, NULL, 0, "up_char");
405 test_pointer_marshal(fmtstr_up_byte, ch_ptr, 1, wiredata, 5, NULL, 0, "up_byte");
406 test_pointer_marshal(fmtstr_up_small, ch_ptr, 1, wiredata, 5, NULL, 0, "up_small");
407 test_pointer_marshal(fmtstr_up_usmall, ch_ptr, 1, wiredata, 5, NULL, 0, "up_usmall");
409 test_pointer_marshal(fmtstr_rp_char, ch_ptr, 1, &ch, 1, NULL, 0, "rp_char");
411 test_pointer_marshal(fmtstr_rpup_char, &ch_ptr, 1, wiredata, 5, deref_cmp, 1, "rpup_char");
412 test_pointer_marshal(fmtstr_rpup_char2, ch_ptr, 1, wiredata, 5, NULL, 0, "rpup_char2");
414 s = 0xa597;
415 *(void**)wiredata = &s;
416 *(unsigned short*)(wiredata + sizeof(void*)) = s;
418 test_pointer_marshal(fmtstr_up_wchar, &s, 2, wiredata, 6, NULL, 0, "up_wchar");
419 test_pointer_marshal(fmtstr_up_short, &s, 2, wiredata, 6, NULL, 0, "up_short");
420 test_pointer_marshal(fmtstr_up_ushort, &s, 2, wiredata, 6, NULL, 0, "up_ushort");
422 i = s;
423 *(void**)wiredata = &i;
424 test_pointer_marshal(fmtstr_up_enum16, &i, 2, wiredata, 6, NULL, 0, "up_enum16");
426 l = 0xcafebabe;
427 *(void**)wiredata = &l;
428 *(unsigned long*)(wiredata + sizeof(void*)) = l;
430 test_pointer_marshal(fmtstr_up_long, &l, 4, wiredata, 8, NULL, 0, "up_long");
431 test_pointer_marshal(fmtstr_up_ulong, &l, 4, wiredata, 8, NULL, 0, "up_ulong");
432 test_pointer_marshal(fmtstr_up_enum32, &l, 4, wiredata, 8, NULL, 0, "up_emun32");
433 test_pointer_marshal(fmtstr_up_errorstatus, &l, 4, wiredata, 8, NULL, 0, "up_errorstatus");
435 ll = ((ULONGLONG)0xcafebabe) << 32 | 0xdeadbeef;
436 *(void**)wiredata = &ll;
437 *(void**)(wiredata + sizeof(void*)) = NULL;
438 *(ULONGLONG*)(wiredata + 2 * sizeof(void*)) = ll;
439 test_pointer_marshal(fmtstr_up_longlong, &ll, 8, wiredata, 16, NULL, 0, "up_longlong");
441 f = 3.1415;
442 *(void**)wiredata = &f;
443 *(float*)(wiredata + sizeof(void*)) = f;
444 test_pointer_marshal(fmtstr_up_float, &f, 4, wiredata, 8, NULL, 0, "up_float");
446 d = 3.1415;
447 *(void**)wiredata = &d;
448 *(void**)(wiredata + sizeof(void*)) = NULL;
449 *(double*)(wiredata + 2 * sizeof(void*)) = d;
450 test_pointer_marshal(fmtstr_up_double, &d, 8, wiredata, 16, NULL, 0, "up_double");
454 static void test_simple_struct_marshal(const unsigned char *formattypes,
455 void *memsrc,
456 long srcsize,
457 const void *wiredata,
458 long wiredatalen,
459 int(*cmp)(const void*,const void*,size_t),
460 long num_additional_allocs,
461 const char *msgpfx)
463 RPC_MESSAGE RpcMessage;
464 MIDL_STUB_MESSAGE StubMsg;
465 MIDL_STUB_DESC StubDesc;
466 DWORD size;
467 void *ptr;
468 unsigned char *mem, *mem_orig;
470 my_alloc_called = my_free_called = 0;
471 if(!cmp)
472 cmp = memcmp;
474 StubDesc = Object_StubDesc;
475 StubDesc.pFormatTypes = formattypes;
477 NdrClientInitializeNew(&RpcMessage, &StubMsg, &StubDesc, 0);
479 StubMsg.BufferLength = 0;
480 NdrSimpleStructBufferSize( &StubMsg, (unsigned char *)memsrc, formattypes );
481 ok(StubMsg.BufferLength >= wiredatalen, "%s: length %d\n", msgpfx, StubMsg.BufferLength);
482 StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
483 StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
484 ptr = NdrSimpleStructMarshall( &StubMsg, (unsigned char*)memsrc, formattypes );
485 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
486 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
487 ok(!memcmp(StubMsg.BufferStart, wiredata, wiredatalen), "%s: incorrectly marshaled %08x %08x %08x\n", msgpfx, *(DWORD*)StubMsg.BufferStart,*((DWORD*)StubMsg.BufferStart+1),*((DWORD*)StubMsg.BufferStart+2));
489 if (0)
491 /* FIXME: Causes Wine to crash */
492 StubMsg.Buffer = StubMsg.BufferStart;
493 StubMsg.MemorySize = 0;
494 size = NdrSimpleStructMemorySize( &StubMsg, formattypes );
495 ok(size == StubMsg.MemorySize, "%s: size != MemorySize\n", msgpfx);
496 ok(size == srcsize, "%s: mem size %u\n", msgpfx, size);
497 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
499 StubMsg.Buffer = StubMsg.BufferStart;
500 size = NdrSimpleStructMemorySize( &StubMsg, formattypes );
501 todo_wine {
502 ok(size == StubMsg.MemorySize, "%s: size != MemorySize\n", msgpfx);
504 ok(StubMsg.MemorySize == ((srcsize + 3) & ~3) + srcsize, "%s: mem size %u\n", msgpfx, size);
505 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
507 size = srcsize;
508 /*** Unmarshalling first with must_alloc false ***/
510 StubMsg.Buffer = StubMsg.BufferStart;
511 StubMsg.MemorySize = 0;
512 mem_orig = mem = HeapAlloc(GetProcessHeap(), 0, srcsize);
513 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 );
514 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
515 ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
516 ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig);
517 ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
518 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
519 my_alloc_called = 0;
520 ok(StubMsg.MemorySize == 0, "%s: memorysize touched in unmarshal\n", msgpfx);
522 /* if we're a server we still use the suppiled memory */
523 StubMsg.Buffer = StubMsg.BufferStart;
524 StubMsg.IsClient = 0;
525 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 );
526 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
527 ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig);
528 ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
529 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
530 my_alloc_called = 0;
531 ok(StubMsg.MemorySize == 0, "%s: memorysize touched in unmarshal\n", msgpfx);
533 /* ...unless we pass a NULL ptr, then the buffer is used.
534 Passing a NULL ptr while we're a client && !must_alloc
535 crashes on Windows, so we won't do that. */
537 mem = NULL;
538 StubMsg.IsClient = 0;
539 StubMsg.Buffer = StubMsg.BufferStart;
540 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 );
541 ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
542 ok(mem == StubMsg.BufferStart, "%s: mem not equal buffer\n", msgpfx);
543 ok(!cmp(mem, memsrc, srcsize), "%s: incorrectly unmarshaled\n", msgpfx);
544 ok(my_alloc_called == num_additional_allocs, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
545 my_alloc_called = 0;
546 ok(StubMsg.MemorySize == 0, "%s: memorysize touched in unmarshal\n", msgpfx);
548 /*** now must_alloc is true ***/
550 /* with must_alloc set we always allocate new memory whether or not we're
551 a server and also when passing NULL */
552 mem = mem_orig;
553 StubMsg.IsClient = 1;
554 StubMsg.Buffer = StubMsg.BufferStart;
555 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 1 );
556 ok(ptr == NULL, "ret %p\n", ptr);
557 ok(mem != mem_orig, "mem not changed %p %p\n", mem, mem_orig);
558 ok(!cmp(mem, memsrc, srcsize), "incorrectly unmarshaled\n");
559 ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
560 my_alloc_called = 0;
561 ok(StubMsg.MemorySize == 0, "memorysize touched in unmarshal\n");
563 mem = NULL;
564 StubMsg.Buffer = StubMsg.BufferStart;
565 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 1 );
566 ok(ptr == NULL, "ret %p\n", ptr);
567 ok(mem != mem_orig, "mem not changed %p %p\n", mem, mem_orig);
568 ok(!cmp(mem, memsrc, srcsize), "incorrectly unmarshaled\n");
569 ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
570 my_alloc_called = 0;
571 ok(StubMsg.MemorySize == 0, "memorysize touched in unmarshal\n");
573 mem = mem_orig;
574 StubMsg.Buffer = StubMsg.BufferStart;
575 StubMsg.IsClient = 0;
576 StubMsg.ReuseBuffer = 1;
577 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 1 );
578 ok(ptr == NULL, "ret %p\n", ptr);
579 ok(mem != mem_orig, "mem not changed %p %p\n", mem, mem_orig);
580 ok(mem != StubMsg.BufferStart, "mem is buffer mem\n");
581 ok(!cmp(mem, memsrc, srcsize), "incorrectly unmarshaled\n");
582 ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
583 my_alloc_called = 0;
584 ok(StubMsg.MemorySize == 0, "memorysize touched in unmarshal\n");
586 mem = NULL;
587 StubMsg.Buffer = StubMsg.BufferStart;
588 StubMsg.IsClient = 0;
589 StubMsg.ReuseBuffer = 1;
590 ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 1 );
591 ok(ptr == NULL, "ret %p\n", ptr);
592 ok(mem != StubMsg.BufferStart, "mem is buffer mem\n");
593 ok(!cmp(mem, memsrc, srcsize), "incorrectly unmarshaled\n");
594 ok(my_alloc_called == num_additional_allocs + 1, "%s: my_alloc got called %d times\n", msgpfx, my_alloc_called);
595 my_alloc_called = 0;
596 ok(StubMsg.MemorySize == 0, "memorysize touched in unmarshal\n");
600 typedef struct
602 long l1;
603 long *pl1;
604 char *pc1;
605 } ps1_t;
607 static int ps1_cmp(const void *s1, const void *s2, size_t num)
609 const ps1_t *p1, *p2;
611 p1 = s1;
612 p2 = s2;
614 if(p1->l1 != p2->l1)
615 return 1;
617 if(p1->pl1 && p2->pl1)
619 if(*p1->pl1 != *p2->pl1)
620 return 1;
622 else if(p1->pl1 || p1->pl1)
623 return 1;
625 if(p1->pc1 && p2->pc1)
627 if(*p1->pc1 != *p2->pc1)
628 return 1;
630 else if(p1->pc1 || p1->pc1)
631 return 1;
633 return 0;
636 static void test_simple_struct(void)
638 unsigned char wiredata[28];
639 unsigned long wiredatalen;
640 long l;
641 char c;
642 ps1_t ps1;
644 static const unsigned char fmtstr_simple_struct[] =
646 0x12, 0x0, /* FC_UP */
647 NdrFcShort( 0x2 ), /* Offset=2 */
648 0x15, 0x3, /* FC_STRUCT [align 4] */
649 NdrFcShort( 0x18 ), /* [size 24] */
650 0x6, /* FC_SHORT */
651 0x2, /* FC_CHAR */
652 0x38, /* FC_ALIGNM4 */
653 0x8, /* FC_LONG */
654 0x8, /* FC_LONG */
655 0x39, /* FC_ALIGNM8 */
656 0xb, /* FC_HYPER */
657 0x5b, /* FC_END */
659 struct {
660 short s;
661 char c;
662 long l1, l2;
663 LONGLONG ll;
664 } s1;
666 static const unsigned char fmtstr_pointer_struct[] =
668 0x12, 0x0, /* FC_UP */
669 NdrFcShort( 0x2 ), /* Offset=2 */
670 0x16, 0x3, /* FC_PSTRUCT [align 4] */
671 NdrFcShort( 0xc ), /* [size 12] */
672 0x4b, /* FC_PP */
673 0x5c, /* FC_PAD */
674 0x46, /* FC_NO_REPEAT */
675 0x5c, /* FC_PAD */
676 NdrFcShort( 0x4 ), /* 4 */
677 NdrFcShort( 0x4 ), /* 4 */
678 0x13, 0x8, /* FC_OP [simple_pointer] */
679 0x8, /* FC_LONG */
680 0x5c, /* FC_PAD */
681 0x46, /* FC_NO_REPEAT */
682 0x5c, /* FC_PAD */
683 NdrFcShort( 0x8 ), /* 8 */
684 NdrFcShort( 0x8 ), /* 8 */
685 0x13, 0x8, /* FC_OP [simple_pointer] */
686 0x2, /* FC_CHAR */
687 0x5c, /* FC_PAD */
688 0x5b, /* FC_END */
689 0x8, /* FC_LONG */
690 0x8, /* FC_LONG */
691 0x8, /* FC_LONG */
692 0x5c, /* FC_PAD */
693 0x5b, /* FC_END */
697 /* FC_STRUCT */
698 s1.s = 0x1234;
699 s1.c = 0xa5;
700 s1.l1 = 0xdeadbeef;
701 s1.l2 = 0xcafebabe;
702 s1.ll = ((LONGLONG) 0xbadefeed << 32) | 0x2468ace0;
704 wiredatalen = 24;
705 memcpy(wiredata, &s1, wiredatalen);
706 test_simple_struct_marshal(fmtstr_simple_struct + 4, &s1, 24, wiredata, 24, NULL, 0, "struct");
708 *(void**)wiredata = &s1;
709 memcpy(wiredata + 4, &s1, wiredatalen);
710 if (0)
712 /* one of the unmarshallings crashes Wine */
713 test_pointer_marshal(fmtstr_simple_struct, &s1, 24, wiredata, 28, NULL, 0, "struct");
716 /* FC_PSTRUCT */
717 ps1.l1 = 0xdeadbeef;
718 l = 0xcafebabe;
719 ps1.pl1 = &l;
720 c = 'a';
721 ps1.pc1 = &c;
722 memcpy(wiredata + 4, &ps1, 12);
723 memcpy(wiredata + 16, &l, 4);
724 memcpy(wiredata + 20, &c, 1);
726 test_simple_struct_marshal(fmtstr_pointer_struct + 4, &ps1, 17, wiredata + 4, 17, ps1_cmp, 2, "pointer_struct");
727 *(void**)wiredata = &ps1;
728 if (0)
730 /* one of the unmarshallings crashes Wine */
731 test_pointer_marshal(fmtstr_pointer_struct, &ps1, 17, wiredata, 21, ps1_cmp, 2, "pointer_struct");
735 static void test_complex_struct(void)
737 RPC_MESSAGE RpcMessage;
738 MIDL_STUB_MESSAGE StubMsg;
739 MIDL_STUB_DESC StubDesc;
740 void *memsrc, *ptr;
741 FUNCDESC fd;
742 ELEMDESC params[2];
743 TYPEDESC td[4];
744 FUNCDESC *dst;
746 static const unsigned char fmtstr_funcdesc[] =
748 /* 0 */ 0x11, 0x14, /* FC_RP [alloced_on_stack] */
749 /* 2 */ NdrFcShort( 0x2 ), /* Offset= 2 (4) */
750 /* 4 */ 0x13, 0x0, /* FC_OP */
751 /* 6 */ NdrFcShort( 0xaa ), /* Offset= 170 (176) */
753 /** TYPEDESC union **/
754 /* 8 */ 0x2b, /* FC_NON_ENCAPSULATED_UNION */
755 0x7, /* FC_USHORT */
756 /* 10 */ 0x7, /* Corr desc: FC_USHORT */
757 0x0, /* */
758 /* 12 */ NdrFcShort( 0x4 ), /* 4 */
759 /* 14 */ NdrFcShort( 0x2 ), /* Offset= 2 (16) */
760 /* 16 */ NdrFcShort( 0x4 ), /* 4 */
761 /* 18 */ NdrFcShort( 0x4 ), /* 4 */
762 /* 20 */ NdrFcLong( 0x1a ), /* 26 */
763 /* 24 */ NdrFcShort( 0x16 ), /* Offset= 22 (46) */
764 /* 26 */ NdrFcLong( 0x1b ), /* 27 */
765 /* 30 */ NdrFcShort( 0x10 ), /* Offset= 16 (46) */
766 /* 32 */ NdrFcLong( 0x1c ), /* 28 */
767 /* 36 */ NdrFcShort( 0xe ), /* Offset= 14 (50) */
768 /* 38 */ NdrFcLong( 0x1d ), /* 29 */
769 /* 42 */ NdrFcShort( 0x8008 ), /* Simple arm type: FC_LONG */
770 /* 44 */ NdrFcShort( 0x0 ), /* Offset= 0 */
771 /* 46 */ 0x13, 0x0, /* FC_OP */
772 /* 48 */ NdrFcShort( 0x24 ), /* Offset= 36 (84) */
773 /* 50 */ 0x13, 0x0, /* FC_OP */
774 /* 52 */ NdrFcShort( 0x10 ), /* Offset= 16 (68) */
776 /** ARRAYDESC carray **/
777 /* 54 */ 0x1b, /* FC_CARRAY */
778 0x3, /* 3 */
779 /* 56 */ NdrFcShort( 0x8 ), /* 8 */
780 /* 58 */ 0x7, /* Corr desc: FC_USHORT */
781 0x0, /* */
782 /* 60 */ NdrFcShort( 0xfffc ), /* -4 */
783 /* 62 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
784 0x0, /* 0 */
785 /* 64 */ NdrFcShort( 0x92 ), /* Offset= 146 (210) */
786 /* 66 */ 0x5c, /* FC_PAD */
787 0x5b, /* FC_END */
789 /** ARRADESC **/
790 /* 68 */ 0x1a, /* FC_BOGUS_STRUCT */
791 0x3, /* 3 */
792 /* 70 */ NdrFcShort( 0x4 ), /* 4 */
793 /* 72 */ NdrFcShort( 0xffffffee ), /* Offset= -18 (54) */
794 /* 74 */ NdrFcShort( 0x0 ), /* Offset= 0 */
795 /* 76 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
796 0x0, /* 0 */
797 /* 78 */ NdrFcShort( 0x6 ), /* Offset= 6 (84) */
798 /* 80 */ 0x6, /* FC_SHORT */
799 0x3e, /* FC_STRUCTPAD2 */
800 /* 82 */ 0x5c, /* FC_PAD */
801 0x5b, /* FC_END */
803 /** TYPEDESC **/
804 /* 84 */ 0x1a, /* FC_BOGUS_STRUCT */
805 0x3, /* 3 */
806 /* 86 */ NdrFcShort( 0x8 ), /* 8 */
807 /* 88 */ NdrFcShort( 0x0 ), /* 0 */
808 /* 90 */ NdrFcShort( 0x0 ), /* Offset= 0 */
809 /* 92 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
810 0x0, /* 0 */
811 /* 94 */ NdrFcShort( 0xffffffaa ), /* Offset= -86 (8) */
812 /* 96 */ 0x6, /* FC_SHORT */
813 0x3e, /* FC_STRUCTPAD2 */
814 /* 98 */ 0x5c, /* FC_PAD */
815 0x5b, /* FC_END */
817 /** PARAMDESCEX **/
819 /* 100 */ 0x1a, /* FC_BOGUS_STRUCT */
820 0x3, /* 3 */
821 /* 102 */ NdrFcShort( 0x18 ), /* 24 */
822 /* 104 */ NdrFcShort( 0x0 ), /* 0 */
823 /* 106 */ NdrFcShort( 0x0 ), /* Offset= 0 */
824 /* 108 */ 0x8, /* FC_LONG */
825 0x4c, /* FC_EMBEDDED_COMPLEX */
826 /* 110 */ 0x4, /* 4 */
827 NdrFcShort( 0xffffff01 ), /* Offset= -255 (1110) */ /* FIXME!! */
828 0x5b, /* FC_END */
831 /** PARAMDESC **/
832 /* 114 */ 0x1a, /* FC_BOGUS_STRUCT */
833 0x3, /* 3 */
834 /* 116 */ NdrFcShort( 0x8 ), /* 8 */
835 /* 118 */ NdrFcShort( 0x0 ), /* 0 */
836 /* 120 */ NdrFcShort( 0x6 ), /* Offset= 6 (126) */
837 /* 122 */ 0x36, /* FC_POINTER */
838 0x6, /* FC_SHORT */
839 /* 124 */ 0x3e, /* FC_STRUCTPAD2 */
840 0x5b, /* FC_END */
841 /* 126 */
842 0x13, 0x0, /* FC_OP */
843 /* 128 */ NdrFcShort( 0xffffffe4 ), /* Offset= -28 (100) */
845 /** ELEMDESC **/
846 /* 130 */
847 0x1a, /* FC_BOGUS_STRUCT */
848 0x3, /* 3 */
849 /* 132 */ NdrFcShort( 0x10 ), /* 16 */
850 /* 134 */ NdrFcShort( 0x0 ), /* 0 */
851 /* 136 */ NdrFcShort( 0x0 ), /* 0 */
852 /* 138 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
853 0x0, /* 0 */
854 /* 140 */ NdrFcShort( 0xffffffc8 ), /* Offset= -56 (84) */
855 /* 142 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
856 0x0, /* 0 */
857 /* 144 */ NdrFcShort( 0xffffffe2 ), /* Offset= -30 (114) */
858 /* 146 */ 0x5c, /* FC_PAD */
859 0x5b, /* FC_END */
862 /* 148 */
863 0x1b, /* FC_CARRAY */
864 0x3, /* 3 */
865 /* 150 */ NdrFcShort( 0x4 ), /* 4 */
866 /* 152 */ 0x16, /* Corr desc: field pointer, FC_SHORT */
867 0x0, /* */
868 /* 154 */ NdrFcShort( 0x1e ), /* 30 */
869 /* 156 */ 0x8, /* FC_LONG */
870 0x5b, /* FC_END */
872 /* 158 */
873 0x21, /* FC_BOGUS_ARRAY */
874 0x3, /* 3 */
875 /* 160 */ NdrFcShort( 0x0 ), /* 0 */
876 /* 162 */ 0x16, /* Corr desc: field pointer, FC_SHORT */
877 0x0, /* */
878 /* 164 */ NdrFcShort( 0x18 ), /* 24 */
879 /* 166 */ NdrFcLong( 0xffffffff ), /* -1 */
880 /* 170 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
881 0x0, /* 0 */
882 /* 172 */ NdrFcShort( 0xffffffd6 ), /* Offset= -42 (130) */
883 /* 174 */ 0x5c, /* FC_PAD */
884 0x5b, /* FC_END */
885 /** FUNCDESC **/
886 /* 176 */ 0x1a, /* FC_BOGUS_STRUCT */
887 0x3, /* 3 */
888 /* 178 */ NdrFcShort( 0x34 ), /* 52 */
889 /* 180 */ NdrFcShort( 0x0 ), /* 0 */
890 /* 182 */ NdrFcShort( 0x14 ), /* Offset= 20 (202) */
891 /* 184 */ 0x8, /* FC_LONG */
892 0x36, /* FC_POINTER */
893 /* 186 */ 0x36, /* FC_POINTER */
894 0xe, /* FC_ENUM32 */
895 /* 188 */ 0xe, /* FC_ENUM32 */
896 0xe, /* FC_ENUM32 */
897 /* 190 */ 0x6, /* FC_SHORT */
898 0x6, /* FC_SHORT */
899 /* 192 */ 0x6, /* FC_SHORT */
900 0x6, /* FC_SHORT */
901 /* 194 */ 0x4c, /* FC_EMBEDDED_COMPLEX */
902 0x0, /* 0 */
903 /* 196 */ NdrFcShort( 0xffffffbe ), /* Offset= -66 (130) */
904 /* 198 */ 0x6, /* FC_SHORT */
905 0x3e, /* FC_STRUCTPAD2 */
906 /* 200 */ 0x5c, /* FC_PAD */
907 0x5b, /* FC_END */
908 /* 202 */
909 0x13, 0x0, /* FC_OP */
910 /* 204 */ NdrFcShort( 0xffffffc8 ), /* Offset= -56 (148) */
911 /* 206 */
912 0x13, 0x0, /* FC_OP */
913 /* 208 */ NdrFcShort( 0xffffffce ), /* Offset= -50 (158) */
915 /** SAFEARRAYBOUND **/
916 /* 210 */
917 0x15, /* FC_STRUCT */
918 0x3, /* 3 */
919 /* 212 */ NdrFcShort( 0x8 ), /* 8 */
920 /* 214 */ 0x8, /* FC_LONG */
921 0x8, /* FC_LONG */
922 /* 216 */ 0x5c, /* FC_PAD */
923 0x5b, /* FC_END */
926 StubDesc = Object_StubDesc;
927 StubDesc.pFormatTypes = fmtstr_funcdesc;
929 memsrc = &fd;
930 memset(&fd, 0, sizeof(fd));
932 fd.memid = 0xcafebabe;
933 fd.lprgscode = NULL;
934 fd.lprgelemdescParam = params;
935 params[0].tdesc.vt = VT_PTR;
936 U(params[0].tdesc).lptdesc = &td[0];
937 U(params[0].tdesc).lptdesc->vt = VT_SAFEARRAY;
938 U(*U(params[0].tdesc).lptdesc).lptdesc = &td[1];
939 U(*U(params[0].tdesc).lptdesc).lptdesc->vt = VT_R8;
940 U(params[0]).paramdesc.pparamdescex = NULL;
941 U(params[0]).paramdesc.wParamFlags = 0xbeef;
943 params[1].tdesc.vt = VT_I4;
944 /* U(params[1].tdesc).vt = VT_PTR;
945 U(params[1].tdesc).lptdesc = &td[2];
946 U(params[1].tdesc).lptdesc->vt = VT_SAFEARRAY;
947 U(*U(params[1].tdesc).lptdesc).lptdesc = &td[3];
948 U(*U(params[1].tdesc).lptdesc).lptdesc->vt = VT_R8;*/
949 U(params[1]).paramdesc.pparamdescex = NULL;
950 U(params[1]).paramdesc.wParamFlags = 0xdead;
951 fd.funckind = 0;
952 fd.invkind = 1;
953 fd.callconv = 4;
954 fd.cParams = 2;
955 fd.cParamsOpt = 0;
956 fd.oVft = 8;
957 fd.cScodes = 0;
958 fd.elemdescFunc.tdesc.vt = VT_R8;
959 U(fd.elemdescFunc).paramdesc.pparamdescex = NULL;
960 U(fd.elemdescFunc).paramdesc.wParamFlags = 0xcafe;
961 fd.wFuncFlags = 0;
963 NdrClientInitializeNew(&RpcMessage, &StubMsg, &StubDesc, 0);
965 StubMsg.BufferLength = 0;
966 StubMsg.PointerLength = 0;
968 NdrComplexStructBufferSize( &StubMsg, (unsigned char *)memsrc, fmtstr_funcdesc + 176 );
969 ok(StubMsg.BufferLength >= 96, "buffer size %d\n", StubMsg.BufferLength);
971 StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, StubMsg.BufferLength);
972 StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
974 ptr = NdrComplexStructMarshall( &StubMsg, memsrc, fmtstr_funcdesc + 176 );
976 ok(StubMsg.Buffer - StubMsg.BufferStart == 96, "marshaled length %d\n", StubMsg.Buffer - StubMsg.BufferStart);
978 /* Compare upto the first embedded union (elemdescFunc) */
979 ok(!memcmp(StubMsg.BufferStart, &fd, 32), "top level differ\n");
980 /* discriminant */
981 ok(!memcmp(StubMsg.BufferStart + 32, &fd.elemdescFunc.tdesc.vt, sizeof(short)), "discrimants differ\n");
982 /* now the vt itself */
983 ok(!memcmp(StubMsg.BufferStart + 34, &fd.elemdescFunc.tdesc.vt, sizeof(short)), "vts differ\n");
984 /* paramdesc */
985 ok(!memcmp(StubMsg.BufferStart + 36, &U(fd.elemdescFunc).paramdesc, sizeof(PARAMDESC)), "paramdesc differ\n");
986 /* param array discrim */
987 ok(!memcmp(StubMsg.BufferStart + 44, &fd.cParams, sizeof(short)), "param array discrim differs\n");
989 ok(!memcmp(StubMsg.BufferStart + 48, &params[0].tdesc.vt, sizeof(short)), "param[0] first vt differ\n");
990 ok(!memcmp(StubMsg.BufferStart + 52, &params[0].tdesc, 6), "param[0] first tdesc differ\n");
991 ok(!memcmp(StubMsg.BufferStart + 60, &U(params[0]).paramdesc, 6), "param[0] paramdesc differ\n");
993 ok(!memcmp(StubMsg.BufferStart + 68, &params[1].tdesc.vt, sizeof(short)), "param[1] first vt differ\n");
994 ok(!memcmp(StubMsg.BufferStart + 70, &params[1].tdesc.vt, sizeof(short)), "param[1] first tdesc differ\n");
995 ok(!memcmp(StubMsg.BufferStart + 72, &U(params[1]).paramdesc, 6), "param[1] paramdesc differ\n");
997 ok(!memcmp(StubMsg.BufferStart + 80, &U(params[0].tdesc).lptdesc->vt, sizeof(short)), "param[0] 2nd vt differ\n");
998 ok(!memcmp(StubMsg.BufferStart + 84, U(params[0].tdesc).lptdesc, 6), "param[0] 2nd tdesc differ\n");
1000 ok(!memcmp(StubMsg.BufferStart + 92, &U(*U(params[0].tdesc).lptdesc).lptdesc->vt, sizeof(short)), "param[0] 3rd vt differ\n");
1001 ok(!memcmp(StubMsg.BufferStart + 94, &U(*U(params[0].tdesc).lptdesc).lptdesc->vt, 2), "param[0] 3rd tdesc differ\n");
1003 StubMsg.Buffer = StubMsg.BufferStart;
1004 StubMsg.MemorySize = 0;
1006 dst = HeapAlloc(GetProcessHeap(), 0, 1000);
1007 NdrComplexStructUnmarshall( &StubMsg, (void*)&dst, fmtstr_funcdesc + 176, 1);
1008 ok(dst->cParams == fd.cParams, "params not right\n");
1009 ok(U(*U(dst->lprgelemdescParam[0].tdesc).lptdesc).lptdesc->vt == U(*U(params[0].tdesc).lptdesc).lptdesc->vt, "param[0] tdesc differ\n");
1012 static void test_fullpointer_xlat(void)
1014 PFULL_PTR_XLAT_TABLES pXlatTables;
1015 ULONG RefId;
1016 int ret;
1017 void *Pointer;
1019 pXlatTables = NdrFullPointerXlatInit(2, XLAT_CLIENT);
1021 /* "marshaling" phase */
1023 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId);
1024 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1025 ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%x\n", RefId);
1027 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0, &RefId);
1028 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1029 ok(RefId == 0x1, "RefId should be 0x1 instead of 0x%x\n", RefId);
1031 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebabe, 0, &RefId);
1032 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1033 ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId);
1035 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0, &RefId);
1036 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1037 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1039 ret = NdrFullPointerQueryPointer(pXlatTables, NULL, 0, &RefId);
1040 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1041 ok(RefId == 0, "RefId should be 0 instead of 0x%x\n", RefId);
1043 /* "unmarshaling" phase */
1045 ret = NdrFullPointerQueryRefId(pXlatTables, 0x2, 0, &Pointer);
1046 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1047 ok(Pointer == (void *)0xcafebabe, "Pointer should be 0xcafebabe instead of %p\n", Pointer);
1049 ret = NdrFullPointerQueryRefId(pXlatTables, 0x4, 0, &Pointer);
1050 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1051 ok(Pointer == NULL, "Pointer should be NULL instead of %p\n", Pointer);
1053 NdrFullPointerInsertRefId(pXlatTables, 0x4, (void *)0xdeadbabe);
1055 ret = NdrFullPointerQueryRefId(pXlatTables, 0x4, 1, &Pointer);
1056 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1057 ok(Pointer == (void *)0xdeadbabe, "Pointer should be (void *)0xdeadbabe instead of %p\n", Pointer);
1059 NdrFullPointerXlatFree(pXlatTables);
1061 pXlatTables = NdrFullPointerXlatInit(2, XLAT_SERVER);
1063 /* "unmarshaling" phase */
1065 ret = NdrFullPointerQueryRefId(pXlatTables, 0x2, 1, &Pointer);
1066 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1067 ok(Pointer == NULL, "Pointer should be NULL instead of %p\n", Pointer);
1069 NdrFullPointerInsertRefId(pXlatTables, 0x2, (void *)0xcafebabe);
1071 ret = NdrFullPointerQueryRefId(pXlatTables, 0x2, 0, &Pointer);
1072 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1073 ok(Pointer == (void *)0xcafebabe, "Pointer should be (void *)0xcafebabe instead of %p\n", Pointer);
1075 ret = NdrFullPointerQueryRefId(pXlatTables, 0x2, 1, &Pointer);
1076 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1077 ok(Pointer == (void *)0xcafebabe, "Pointer should be (void *)0xcafebabe instead of %p\n", Pointer);
1079 /* "marshaling" phase */
1081 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId);
1082 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1083 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1085 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId);
1086 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1087 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1089 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0, &RefId);
1090 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1091 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1093 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebabe, 0, &RefId);
1094 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1095 ok(RefId == 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId);
1097 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0, &RefId);
1098 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1099 ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId);
1101 /* "freeing" phase */
1103 ret = NdrFullPointerFree(pXlatTables, (void *)0xcafebeef);
1104 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1106 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 0x20, &RefId);
1107 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1108 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1110 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xcafebeef, 1, &RefId);
1111 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1112 ok(RefId == 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId);
1114 ret = NdrFullPointerFree(pXlatTables, (void *)0xcafebabe);
1115 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1117 ret = NdrFullPointerFree(pXlatTables, (void *)0xdeadbeef);
1118 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1120 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 0x20, &RefId);
1121 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1122 ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId);
1124 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 1, &RefId);
1125 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1126 ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId);
1128 ret = NdrFullPointerQueryPointer(pXlatTables, (void *)0xdeadbeef, 1, &RefId);
1129 ok(ret == 1, "ret should be 1 instead of 0x%x\n", ret);
1130 ok(RefId == 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId);
1132 ret = NdrFullPointerFree(pXlatTables, (void *)0xdeadbeef);
1133 ok(ret == 0, "ret should be 0 instead of 0x%x\n", ret);
1135 NdrFullPointerXlatFree(pXlatTables);
1138 static void test_client_init(void)
1140 MIDL_STUB_MESSAGE stubMsg;
1141 RPC_MESSAGE rpcMsg;
1143 memset(&stubMsg, 0xcc, sizeof(stubMsg));
1145 NdrClientInitializeNew(&rpcMsg, &stubMsg, &Object_StubDesc, 1);
1147 #define TEST_ZERO(field, fmt) ok(stubMsg.field == 0, #field " should have be set to zero instead of " fmt "\n", stubMsg.field)
1148 #define TEST_POINTER_UNSET(field) ok(stubMsg.field == (void *)0xcccccccc, #field " should have be unset instead of %p\n", stubMsg.field)
1149 #define TEST_ULONG_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have be unset instead of 0x%x\n", stubMsg.field)
1150 #define TEST_ULONG_PTR_UNSET(field) ok(stubMsg.field == 0xcccccccc, #field " should have be unset instead of 0x%lx\n", stubMsg.field)
1152 ok(stubMsg.RpcMsg == &rpcMsg, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg, stubMsg.RpcMsg);
1153 TEST_POINTER_UNSET(Buffer);
1154 TEST_ZERO(BufferStart, "%p");
1155 TEST_ZERO(BufferEnd, "%p");
1156 TEST_POINTER_UNSET(BufferMark);
1157 TEST_ZERO(BufferLength, "%d");
1158 TEST_ULONG_UNSET(MemorySize);
1159 TEST_POINTER_UNSET(Memory);
1160 ok(stubMsg.IsClient == 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg.IsClient);
1161 TEST_ZERO(ReuseBuffer, "%d");
1162 TEST_ZERO(pAllocAllNodesContext, "%p");
1163 TEST_ZERO(pPointerQueueState, "%p");
1164 TEST_ZERO(IgnoreEmbeddedPointers, "%d");
1165 TEST_ZERO(PointerBufferMark, "%p");
1166 TEST_ZERO(fBufferValid, "%d");
1167 TEST_ZERO(uFlags, "%d");
1168 /* FIXME: UniquePtrCount */
1169 TEST_ULONG_PTR_UNSET(MaxCount);
1170 TEST_ULONG_UNSET(Offset);
1171 TEST_ULONG_UNSET(ActualCount);
1172 ok(stubMsg.pfnAllocate == my_alloc, "stubMsg.pfnAllocate should have been %p instead of %p\n", my_alloc, stubMsg.pfnAllocate);
1173 ok(stubMsg.pfnFree == my_free, "stubMsg.pfnFree should have been %p instead of %p\n", my_free, stubMsg.pfnFree);
1174 TEST_ZERO(StackTop, "%p");
1175 TEST_POINTER_UNSET(pPresentedType);
1176 TEST_POINTER_UNSET(pTransmitType);
1177 TEST_POINTER_UNSET(SavedHandle);
1178 ok(stubMsg.StubDesc == &Object_StubDesc, "stubMsg.StubDesc should have been %p instead of %p\n", &Object_StubDesc, stubMsg.StubDesc);
1179 TEST_POINTER_UNSET(FullPtrXlatTables);
1180 TEST_ZERO(FullPtrRefId, "%d");
1181 TEST_ZERO(PointerLength, "%d");
1182 TEST_ZERO(fInDontFree, "%d");
1183 TEST_ZERO(fDontCallFreeInst, "%d");
1184 TEST_ZERO(fInOnlyParam, "%d");
1185 TEST_ZERO(fHasReturn, "%d");
1186 TEST_ZERO(fHasExtensions, "%d");
1187 TEST_ZERO(fHasNewCorrDesc, "%d");
1188 TEST_ZERO(fUnused, "%d");
1189 ok(stubMsg.fUnused2 == 0xffffcccc, "stubMsg.fUnused2 should have been 0xcccc instead of 0x%x\n", stubMsg.fUnused2);
1190 ok(stubMsg.dwDestContext == MSHCTX_DIFFERENTMACHINE, "stubMsg.dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n", stubMsg.dwDestContext);
1191 TEST_ZERO(pvDestContext, "%p");
1192 TEST_POINTER_UNSET(SavedContextHandles);
1193 TEST_ULONG_UNSET(ParamNumber);
1194 TEST_ZERO(pRpcChannelBuffer, "%p");
1195 TEST_ZERO(pArrayInfo, "%p");
1196 TEST_POINTER_UNSET(SizePtrCountArray);
1197 TEST_POINTER_UNSET(SizePtrOffsetArray);
1198 TEST_POINTER_UNSET(SizePtrLengthArray);
1199 TEST_POINTER_UNSET(pArgQueue);
1200 TEST_ZERO(dwStubPhase, "%d");
1201 /* FIXME: where does this value come from? */
1202 trace("LowStackMark is %p\n", stubMsg.LowStackMark);
1203 TEST_ZERO(pAsyncMsg, "%p");
1204 TEST_ZERO(pCorrInfo, "%p");
1205 TEST_ZERO(pCorrMemory, "%p");
1206 TEST_ZERO(pMemoryList, "%p");
1207 TEST_POINTER_UNSET(pCSInfo);
1208 TEST_POINTER_UNSET(ConformanceMark);
1209 TEST_POINTER_UNSET(VarianceMark);
1210 ok(stubMsg.Unused == 0xcccccccc, "Unused should have be unset instead of 0x%x\n", stubMsg.Unused);
1211 TEST_POINTER_UNSET(pContext);
1212 TEST_POINTER_UNSET(ContextHandleHash);
1213 TEST_POINTER_UNSET(pUserMarshalList);
1214 TEST_ULONG_UNSET(Reserved51_3);
1215 TEST_ULONG_UNSET(Reserved51_4);
1216 TEST_ULONG_UNSET(Reserved51_5);
1217 #undef TEST_ULONG_UNSET
1218 #undef TEST_POINTER_UNSET
1219 #undef TEST_ZERO
1223 static void test_ndr_allocate(void)
1225 RPC_MESSAGE RpcMessage;
1226 MIDL_STUB_MESSAGE StubMsg;
1227 MIDL_STUB_DESC StubDesc;
1228 void *p1, *p2;
1229 struct tag_mem_list_t
1231 DWORD magic;
1232 void *ptr;
1233 struct tag_mem_list_t *next;
1234 } *mem_list;
1235 const DWORD magic_MEML = 'M' << 24 | 'E' << 16 | 'M' << 8 | 'L';
1237 StubDesc = Object_StubDesc;
1238 NdrClientInitializeNew(&RpcMessage, &StubMsg, &StubDesc, 0);
1240 ok(StubMsg.pMemoryList == NULL, "memlist %p\n", StubMsg.pMemoryList);
1241 my_alloc_called = my_free_called = 0;
1242 p1 = NdrAllocate(&StubMsg, 10);
1243 p2 = NdrAllocate(&StubMsg, 20);
1244 ok(my_alloc_called == 2, "alloc called %d\n", my_alloc_called);
1245 mem_list = StubMsg.pMemoryList;
1246 todo_wine {
1247 ok(mem_list != NULL, "mem_list NULL\n");
1249 if(mem_list)
1251 ok(mem_list->magic == magic_MEML, "magic %08x\n", mem_list->magic);
1252 ok(mem_list->ptr == p2, "ptr != p2\n");
1253 ok(mem_list->next != NULL, "next NULL\n");
1254 mem_list = mem_list->next;
1255 if(mem_list)
1257 ok(mem_list->magic == magic_MEML, "magic %08x\n", mem_list->magic);
1258 ok(mem_list->ptr == p1, "ptr != p2\n");
1259 ok(mem_list->next == NULL, "next %p\n", mem_list->next);
1262 /* NdrFree isn't exported so we can't test free'ing */
1265 static void test_conformant_array(void)
1267 RPC_MESSAGE RpcMessage;
1268 MIDL_STUB_MESSAGE StubMsg;
1269 MIDL_STUB_DESC StubDesc;
1270 void *ptr;
1271 unsigned char *mem, *mem_orig;
1272 unsigned char memsrc[20];
1274 static const unsigned char fmtstr_conf_array[] =
1276 0x1b, /* FC_CARRAY */
1277 0x0, /* align */
1278 NdrFcShort( 0x1 ), /* elem size */
1279 0x40, /* Corr desc: const */
1280 0x0,
1281 NdrFcShort(0x10), /* const = 0x10 */
1282 0x1, /* FC_BYTE */
1283 0x5b /* FC_END */
1286 StubDesc = Object_StubDesc;
1287 StubDesc.pFormatTypes = fmtstr_conf_array;
1289 NdrClientInitializeNew(
1290 &RpcMessage,
1291 &StubMsg,
1292 &StubDesc,
1295 StubMsg.BufferLength = 0;
1296 NdrConformantArrayBufferSize( &StubMsg,
1297 memsrc,
1298 fmtstr_conf_array );
1299 ok(StubMsg.BufferLength >= 20, "length %d\n", StubMsg.BufferLength);
1301 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1302 StubMsg.RpcMsg->Buffer = StubMsg.BufferStart = StubMsg.Buffer = HeapAlloc(GetProcessHeap(), 0, StubMsg.BufferLength);
1303 StubMsg.BufferEnd = StubMsg.BufferStart + StubMsg.BufferLength;
1305 ptr = NdrConformantArrayMarshall( &StubMsg, memsrc, fmtstr_conf_array );
1306 ok(ptr == NULL, "ret %p\n", ptr);
1307 ok(StubMsg.Buffer - StubMsg.BufferStart == 20, "Buffer %p Start %p len %d\n", StubMsg.Buffer, StubMsg.BufferStart, 20);
1308 ok(!memcmp(StubMsg.BufferStart + 4, memsrc, 16), "incorrectly marshaled\n");
1310 StubMsg.Buffer = StubMsg.BufferStart;
1311 StubMsg.MemorySize = 0;
1312 mem = NULL;
1314 /* Client */
1315 my_alloc_called = 0;
1316 /* passing mem == NULL with must_alloc == 0 crashes under Windows */
1317 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 1);
1318 ok(mem != NULL, "mem not alloced\n");
1319 ok(mem != StubMsg.BufferStart + 4, "mem pointing at buffer\n");
1320 ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called);
1322 my_alloc_called = 0;
1323 StubMsg.Buffer = StubMsg.BufferStart;
1324 mem_orig = mem;
1325 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 0);
1326 ok(mem == mem_orig, "mem alloced\n");
1327 ok(mem != StubMsg.BufferStart + 4, "mem pointing at buffer\n");
1328 ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
1330 my_alloc_called = 0;
1331 StubMsg.Buffer = StubMsg.BufferStart;
1332 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 1);
1333 ok(mem != mem_orig, "mem not alloced\n");
1334 ok(mem != StubMsg.BufferStart + 4, "mem pointing at buffer\n");
1335 ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called);
1337 my_free_called = 0;
1338 StubMsg.Buffer = StubMsg.BufferStart;
1339 NdrConformantArrayFree( &StubMsg, mem, fmtstr_conf_array );
1340 ok(my_free_called == 0, "free called %d\n", my_free_called);
1341 StubMsg.pfnFree(mem);
1343 /* Server */
1344 my_alloc_called = 0;
1345 StubMsg.IsClient = 0;
1346 mem = NULL;
1347 StubMsg.Buffer = StubMsg.BufferStart;
1348 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 0);
1349 todo_wine {
1350 ok(mem == StubMsg.BufferStart + 4, "mem not pointing at buffer\n");
1351 ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
1353 my_alloc_called = 0;
1354 mem = NULL;
1355 StubMsg.Buffer = StubMsg.BufferStart;
1356 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 1);
1357 ok(mem != StubMsg.BufferStart + 4, "mem pointing at buffer\n");
1358 ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called);
1359 StubMsg.pfnFree(mem);
1361 my_alloc_called = 0;
1362 mem = mem_orig;
1363 StubMsg.Buffer = StubMsg.BufferStart;
1364 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 0);
1365 ok(mem == mem_orig, "mem alloced\n");
1366 ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
1368 my_alloc_called = 0;
1369 mem = mem_orig;
1370 StubMsg.Buffer = StubMsg.BufferStart;
1371 NdrConformantArrayUnmarshall( &StubMsg, &mem, fmtstr_conf_array, 1);
1372 ok(mem != StubMsg.BufferStart + 4, "mem pointing at buffer\n");
1373 ok(my_alloc_called == 1, "alloc called %d\n", my_alloc_called);
1374 StubMsg.pfnFree(mem);
1375 StubMsg.pfnFree(mem_orig);
1377 HeapFree(GetProcessHeap(), 0, StubMsg.RpcMsg->Buffer);
1380 START_TEST( ndr_marshall )
1382 test_ndr_simple_type();
1383 test_simple_types();
1384 test_simple_struct();
1385 test_complex_struct();
1386 test_fullpointer_xlat();
1387 test_client_init();
1388 test_ndr_allocate();
1389 test_conformant_array();