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
23 #define NTDDI_WIN2K 0x05000000
24 #define NTDDI_VERSION NTDDI_WIN2K /* for some MIDL_STUB_MESSAGE fields */
26 #include "wine/test.h"
37 static int my_alloc_called
;
38 static int my_free_called
;
39 static void * CALLBACK
my_alloc(SIZE_T size
)
42 return NdrOleAllocate(size
);
45 static void CALLBACK
my_free(void *ptr
)
51 static const MIDL_STUB_DESC Object_StubDesc
=
61 NULL
, /* format string, filled in by tests */
62 1, /* -error bounds_check flag */
63 0x20000, /* Ndr library version */
65 0x50100a4, /* MIDL Version 5.1.164 */
68 0, /* notify & notify_flag routine table */
75 static RPC_DISPATCH_FUNCTION IFoo_table
[] =
80 static RPC_DISPATCH_TABLE IFoo_v0_0_DispatchTable
=
86 static const RPC_SERVER_INTERFACE IFoo___RpcServerInterface
=
88 sizeof(RPC_SERVER_INTERFACE
),
89 {{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x34}},{0,0}},
90 {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},
91 &IFoo_v0_0_DispatchTable
,
99 static RPC_IF_HANDLE IFoo_v0_0_s_ifspec
= (RPC_IF_HANDLE
)& IFoo___RpcServerInterface
;
100 static BOOL use_pointer_ids
= FALSE
;
102 static void determine_pointer_marshalling_style(void)
104 RPC_MESSAGE RpcMessage
;
105 MIDL_STUB_MESSAGE StubMsg
;
106 MIDL_STUB_DESC StubDesc
;
109 static const unsigned char fmtstr_up_char
[] =
111 0x12, 0x8, /* FC_UP [simple_pointer] */
116 StubDesc
= Object_StubDesc
;
117 StubDesc
.pFormatTypes
= NULL
;
119 NdrClientInitializeNew(
125 StubMsg
.BufferLength
= 8;
126 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
127 NdrPointerMarshall(&StubMsg
, (unsigned char*)&ch
, fmtstr_up_char
);
128 ok(StubMsg
.Buffer
== StubMsg
.BufferStart
+ 5, "%p %p\n", StubMsg
.Buffer
, StubMsg
.BufferStart
);
130 use_pointer_ids
= (*(unsigned int *)StubMsg
.BufferStart
!= (UINT_PTR
)&ch
);
131 trace("Pointer marshalling using %s\n", use_pointer_ids
? "pointer ids" : "pointer value");
133 HeapFree(GetProcessHeap(), 0, StubMsg
.BufferStart
);
136 static void test_ndr_simple_type(void)
138 RPC_MESSAGE RpcMessage
;
139 MIDL_STUB_MESSAGE StubMsg
;
140 MIDL_STUB_DESC StubDesc
;
143 StubDesc
= Object_StubDesc
;
144 StubDesc
.pFormatTypes
= NULL
;
146 NdrClientInitializeNew(
152 StubMsg
.BufferLength
= 16;
153 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
155 NdrSimpleTypeMarshall(&StubMsg
, (unsigned char*)&l
, 8 /* FC_LONG */);
156 ok(StubMsg
.Buffer
== StubMsg
.BufferStart
+ 4, "%p %p\n", StubMsg
.Buffer
, StubMsg
.BufferStart
);
157 ok(*(LONG
*)StubMsg
.BufferStart
== l
, "%d\n", *(LONG
*)StubMsg
.BufferStart
);
159 StubMsg
.Buffer
= StubMsg
.BufferStart
+ 1;
160 NdrSimpleTypeMarshall(&StubMsg
, (unsigned char*)&l
, 8 /* FC_LONG */);
161 ok(StubMsg
.Buffer
== StubMsg
.BufferStart
+ 8, "%p %p\n", StubMsg
.Buffer
, StubMsg
.BufferStart
);
162 ok(*(LONG
*)(StubMsg
.BufferStart
+ 4) == l
, "%d\n", *(LONG
*)StubMsg
.BufferStart
);
164 StubMsg
.Buffer
= StubMsg
.BufferStart
+ 1;
165 NdrSimpleTypeUnmarshall(&StubMsg
, (unsigned char*)&l2
, 8 /* FC_LONG */);
166 ok(StubMsg
.Buffer
== StubMsg
.BufferStart
+ 8, "%p %p\n", StubMsg
.Buffer
, StubMsg
.BufferStart
);
167 ok(l2
== l
, "%d\n", l2
);
169 HeapFree(GetProcessHeap(), 0, StubMsg
.BufferStart
);
172 static void test_pointer_marshal(const unsigned char *formattypes
,
173 void *memsrc
, DWORD srcsize
,
174 const void *wiredata
,
176 int(*cmp
)(const void*,const void*,size_t),
177 int num_additional_allocs
,
180 RPC_MESSAGE RpcMessage
;
181 MIDL_STUB_MESSAGE StubMsg
;
182 MIDL_STUB_DESC StubDesc
;
185 unsigned char *mem
, *mem_orig
;
187 my_alloc_called
= my_free_called
= 0;
191 StubDesc
= Object_StubDesc
;
192 StubDesc
.pFormatTypes
= formattypes
;
194 NdrClientInitializeNew(
200 StubMsg
.BufferLength
= 0;
201 NdrPointerBufferSize( &StubMsg
,
204 ok(StubMsg
.BufferLength
>= wiredatalen
, "%s: length %d\n", msgpfx
, StubMsg
.BufferLength
);
206 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
207 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
208 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
210 memset(StubMsg
.BufferStart
, 0x0, StubMsg
.BufferLength
); /* This is a hack to clear the padding between the ptr and longlong/double */
212 ptr
= NdrPointerMarshall( &StubMsg
, memsrc
, formattypes
);
213 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
214 if (srcsize
== 8 && wiredatalen
== 16 && StubMsg
.Buffer
- StubMsg
.BufferStart
== 12)
216 /* win9x doesn't align 8-byte types properly */
221 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
222 ok(!memcmp(StubMsg
.BufferStart
, wiredata
, wiredatalen
), "%s: incorrectly marshaled\n", msgpfx
);
225 StubMsg
.Buffer
= StubMsg
.BufferStart
;
226 StubMsg
.MemorySize
= 0;
228 size
= NdrPointerMemorySize( &StubMsg
, formattypes
);
229 ok(size
== StubMsg
.MemorySize
, "%s: mem size %u size %u\n", msgpfx
, StubMsg
.MemorySize
, size
);
230 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
231 if(formattypes
[1] & 0x10 /* FC_POINTER_DEREF */)
232 ok(size
== srcsize
+ sizeof(void *), "%s: mem size %u\n", msgpfx
, size
);
234 ok(size
== srcsize
, "%s: mem size %u\n", msgpfx
, size
);
236 StubMsg
.Buffer
= StubMsg
.BufferStart
;
237 StubMsg
.MemorySize
= 16;
238 size
= NdrPointerMemorySize( &StubMsg
, formattypes
);
239 ok(size
== StubMsg
.MemorySize
, "%s: mem size %u size %u\n", msgpfx
, StubMsg
.MemorySize
, size
);
240 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
241 if(formattypes
[1] & 0x10 /* FC_POINTER_DEREF */)
242 ok(size
== srcsize
+ sizeof(void *) + 16, "%s: mem size %u\n", msgpfx
, size
);
244 ok(size
== srcsize
+ 16, "%s: mem size %u\n", msgpfx
, size
);
246 StubMsg
.Buffer
= StubMsg
.BufferStart
;
247 StubMsg
.MemorySize
= 1;
248 size
= NdrPointerMemorySize( &StubMsg
, formattypes
);
249 ok(size
== StubMsg
.MemorySize
, "%s: mem size %u size %u\n", msgpfx
, StubMsg
.MemorySize
, size
);
250 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
251 if(formattypes
[1] & 0x10 /* FC_POINTER_DEREF */)
252 ok(size
== srcsize
+ sizeof(void *) + (srcsize
== 8 ? 8 : sizeof(void *)), "%s: mem size %u\n", msgpfx
, size
);
254 ok(size
== srcsize
+ (srcsize
== 8 ? 8 : sizeof(void *)), "%s: mem size %u\n", msgpfx
, size
);
257 if(formattypes
[1] & 0x10) size
+= 4;
259 StubMsg
.Buffer
= StubMsg
.BufferStart
;
260 StubMsg
.MemorySize
= 0;
261 mem_orig
= mem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, size
);
263 if(formattypes
[1] & 0x10 /* FC_POINTER_DEREF */)
265 ptr
= NdrPointerUnmarshall( &StubMsg
, &mem
, formattypes
, 0 );
266 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
267 ok(mem
== mem_orig
, "%s: mem has changed %p %p\n", msgpfx
, mem
, mem_orig
);
268 ok(!cmp(mem
, memsrc
, srcsize
), "%s: incorrectly unmarshaled\n", msgpfx
);
269 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
270 ok(StubMsg
.MemorySize
== 0, "%s: memorysize %d\n", msgpfx
, StubMsg
.MemorySize
);
271 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
274 /* reset the buffer and call with must alloc */
275 StubMsg
.Buffer
= StubMsg
.BufferStart
;
276 if(formattypes
[1] & 0x10 /* FC_POINTER_DEREF */)
278 ptr
= NdrPointerUnmarshall( &StubMsg
, &mem
, formattypes
, 1 );
279 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
280 /* doesn't allocate mem in this case */
282 ok(mem
== mem_orig
, "%s: mem has changed %p %p\n", msgpfx
, mem
, mem_orig
);
284 ok(!cmp(mem
, memsrc
, srcsize
), "%s: incorrectly unmarshaled\n", msgpfx
);
285 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
286 ok(StubMsg
.MemorySize
== 0, "%s: memorysize %d\n", msgpfx
, StubMsg
.MemorySize
);
289 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
292 if(formattypes
[0] != 0x11 /* FC_RP */)
294 /* now pass the address of a NULL ptr */
296 StubMsg
.Buffer
= StubMsg
.BufferStart
;
297 ptr
= NdrPointerUnmarshall( &StubMsg
, &mem
, formattypes
, 0 );
298 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
299 ok(mem
!= StubMsg
.BufferStart
+ wiredatalen
- srcsize
, "%s: mem points to buffer %p %p\n", msgpfx
, mem
, StubMsg
.BufferStart
);
300 ok(!cmp(mem
, memsrc
, size
), "%s: incorrectly unmarshaled\n", msgpfx
);
301 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
302 ok(StubMsg
.MemorySize
== 0, "%s: memorysize %d\n", msgpfx
, StubMsg
.MemorySize
);
303 ok(my_alloc_called
== num_additional_allocs
+ 1, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
305 NdrPointerFree(&StubMsg
, mem
, formattypes
);
307 /* again pass address of NULL ptr, but pretend we're a server */
308 if (0) /* crashes on Win9x and NT4 */
311 StubMsg
.Buffer
= StubMsg
.BufferStart
;
312 StubMsg
.IsClient
= 0;
313 ptr
= NdrPointerUnmarshall( &StubMsg
, &mem
, formattypes
, 0 );
314 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
315 if (formattypes
[2] == 0xd /* FC_ENUM16 */)
316 ok(mem
!= StubMsg
.BufferStart
+ wiredatalen
- srcsize
, "%s: mem points to buffer %p %p\n", msgpfx
, mem
, StubMsg
.BufferStart
);
318 ok(mem
== StubMsg
.BufferStart
+ wiredatalen
- srcsize
, "%s: mem doesn't point to buffer %p %p\n", msgpfx
, mem
, StubMsg
.BufferStart
);
319 ok(!cmp(mem
, memsrc
, size
), "%s: incorrectly unmarshaled\n", msgpfx
);
320 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p len %d\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
, wiredatalen
);
321 ok(StubMsg
.MemorySize
== 0, "%s: memorysize %d\n", msgpfx
, StubMsg
.MemorySize
);
322 if (formattypes
[2] != 0xd /* FC_ENUM16 */) {
323 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
328 HeapFree(GetProcessHeap(), 0, mem_orig
);
329 HeapFree(GetProcessHeap(), 0, StubMsg
.BufferStart
);
332 static int deref_cmp(const void *s1
, const void *s2
, size_t num
)
334 return memcmp(*(const void *const *)s1
, *(const void *const *)s2
, num
);
338 static void test_simple_types(void)
340 unsigned char wiredata
[16];
342 unsigned char *ch_ptr
;
350 static const unsigned char fmtstr_up_char
[] =
352 0x12, 0x8, /* FC_UP [simple_pointer] */
356 static const unsigned char fmtstr_up_byte
[] =
358 0x12, 0x8, /* FC_UP [simple_pointer] */
362 static const unsigned char fmtstr_up_small
[] =
364 0x12, 0x8, /* FC_UP [simple_pointer] */
368 static const unsigned char fmtstr_up_usmall
[] =
370 0x12, 0x8, /* FC_UP [simple_pointer] */
374 static const unsigned char fmtstr_rp_char
[] =
376 0x11, 0x8, /* FC_RP [simple_pointer] */
380 static const unsigned char fmtstr_rpup_char
[] =
382 0x11, 0x14, /* FC_RP [alloced_on_stack] */
383 NdrFcShort( 0x2 ), /* Offset= 2 (4) */
384 0x12, 0x8, /* FC_UP [simple_pointer] */
388 static const unsigned char fmtstr_rpup_char2
[] =
390 0x11, 0x04, /* FC_RP [alloced_on_stack] */
391 NdrFcShort( 0x2 ), /* Offset= 2 (4) */
392 0x12, 0x8, /* FC_UP [simple_pointer] */
397 static const unsigned char fmtstr_up_wchar
[] =
399 0x12, 0x8, /* FC_UP [simple_pointer] */
403 static const unsigned char fmtstr_up_short
[] =
405 0x12, 0x8, /* FC_UP [simple_pointer] */
409 static const unsigned char fmtstr_up_ushort
[] =
411 0x12, 0x8, /* FC_UP [simple_pointer] */
415 static const unsigned char fmtstr_up_enum16
[] =
417 0x12, 0x8, /* FC_UP [simple_pointer] */
421 static const unsigned char fmtstr_up_long
[] =
423 0x12, 0x8, /* FC_UP [simple_pointer] */
427 static const unsigned char fmtstr_up_ulong
[] =
429 0x12, 0x8, /* FC_UP [simple_pointer] */
433 static const unsigned char fmtstr_up_enum32
[] =
435 0x12, 0x8, /* FC_UP [simple_pointer] */
439 static const unsigned char fmtstr_up_errorstatus
[] =
441 0x12, 0x8, /* FC_UP [simple_pointer] */
442 0x10, /* FC_ERROR_STATUS_T */
446 static const unsigned char fmtstr_up_longlong
[] =
448 0x12, 0x8, /* FC_UP [simple_pointer] */
452 static const unsigned char fmtstr_up_float
[] =
454 0x12, 0x8, /* FC_UP [simple_pointer] */
458 static const unsigned char fmtstr_up_double
[] =
460 0x12, 0x8, /* FC_UP [simple_pointer] */
468 *(unsigned int *)wiredata
= 0x20000;
470 *(unsigned int *)wiredata
= (UINT_PTR
)ch_ptr
;
473 test_pointer_marshal(fmtstr_up_char
, ch_ptr
, 1, wiredata
, 5, NULL
, 0, "up_char");
474 test_pointer_marshal(fmtstr_up_byte
, ch_ptr
, 1, wiredata
, 5, NULL
, 0, "up_byte");
475 test_pointer_marshal(fmtstr_up_small
, ch_ptr
, 1, wiredata
, 5, NULL
, 0, "up_small");
476 test_pointer_marshal(fmtstr_up_usmall
, ch_ptr
, 1, wiredata
, 5, NULL
, 0, "up_usmall");
478 test_pointer_marshal(fmtstr_rp_char
, ch_ptr
, 1, &ch
, 1, NULL
, 0, "rp_char");
480 test_pointer_marshal(fmtstr_rpup_char
, &ch_ptr
, 1, wiredata
, 5, deref_cmp
, 1, "rpup_char");
481 test_pointer_marshal(fmtstr_rpup_char2
, ch_ptr
, 1, wiredata
, 5, NULL
, 0, "rpup_char2");
485 *(unsigned int *)wiredata
= 0x20000;
487 *(unsigned int *)wiredata
= (UINT_PTR
)&s
;
488 *(unsigned short*)(wiredata
+ 4) = s
;
490 test_pointer_marshal(fmtstr_up_wchar
, &s
, 2, wiredata
, 6, NULL
, 0, "up_wchar");
491 test_pointer_marshal(fmtstr_up_short
, &s
, 2, wiredata
, 6, NULL
, 0, "up_short");
492 test_pointer_marshal(fmtstr_up_ushort
, &s
, 2, wiredata
, 6, NULL
, 0, "up_ushort");
496 *(unsigned int *)wiredata
= 0x20000;
498 *(unsigned int *)wiredata
= (UINT_PTR
)&i
;
499 *(unsigned short*)(wiredata
+ 4) = i
;
500 test_pointer_marshal(fmtstr_up_enum16
, &i
, 4, wiredata
, 6, NULL
, 0, "up_enum16");
504 *(unsigned int *)wiredata
= 0x20000;
506 *(unsigned int *)wiredata
= (UINT_PTR
)&l
;
507 *(ULONG
*)(wiredata
+ 4) = l
;
509 test_pointer_marshal(fmtstr_up_long
, &l
, 4, wiredata
, 8, NULL
, 0, "up_long");
510 test_pointer_marshal(fmtstr_up_ulong
, &l
, 4, wiredata
, 8, NULL
, 0, "up_ulong");
511 test_pointer_marshal(fmtstr_up_enum32
, &l
, 4, wiredata
, 8, NULL
, 0, "up_emun32");
512 test_pointer_marshal(fmtstr_up_errorstatus
, &l
, 4, wiredata
, 8, NULL
, 0, "up_errorstatus");
514 ll
= ((ULONGLONG
)0xcafebabe) << 32 | 0xdeadbeef;
516 *(unsigned int *)wiredata
= 0x20000;
518 *(unsigned int *)wiredata
= (UINT_PTR
)&ll
;
519 *(unsigned int *)(wiredata
+ 4) = 0;
520 *(ULONGLONG
*)(wiredata
+ 8) = ll
;
521 test_pointer_marshal(fmtstr_up_longlong
, &ll
, 8, wiredata
, 16, NULL
, 0, "up_longlong");
525 *(unsigned int *)wiredata
= 0x20000;
527 *(unsigned int *)wiredata
= (UINT_PTR
)&f
;
528 *(float*)(wiredata
+ 4) = f
;
529 test_pointer_marshal(fmtstr_up_float
, &f
, 4, wiredata
, 8, NULL
, 0, "up_float");
533 *(unsigned int *)wiredata
= 0x20000;
535 *(unsigned int *)wiredata
= (UINT_PTR
)&d
;
536 *(unsigned int *)(wiredata
+ 4) = 0;
537 *(double*)(wiredata
+ 8) = d
;
538 test_pointer_marshal(fmtstr_up_double
, &d
, 8, wiredata
, 16, NULL
, 0, "up_double");
542 static void test_nontrivial_pointer_types(void)
544 RPC_MESSAGE RpcMessage
;
545 MIDL_STUB_MESSAGE StubMsg
;
546 MIDL_STUB_DESC StubDesc
;
552 unsigned char *mem
, *mem_orig
;
554 static const unsigned char fmtstr_ref_unique_out
[] =
556 0x12, 0x8, /* FC_UP [simple_pointer] */
559 0x11, 0x14, /* FC_RP [alloced_on_stack] [pointer_deref] */
560 NdrFcShort( 0xfffffffa ), /* Offset= -6 (0) */
567 StubDesc
= Object_StubDesc
;
568 StubDesc
.pFormatTypes
= fmtstr_ref_unique_out
;
570 NdrClientInitializeNew(
576 StubMsg
.BufferLength
= 0;
577 NdrPointerBufferSize( &StubMsg
,
579 &fmtstr_ref_unique_out
[4] );
581 /* Windows overestimates the buffer size */
582 ok(StubMsg
.BufferLength
>= 5, "length %d\n", StubMsg
.BufferLength
);
584 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
585 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
586 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
588 ptr
= NdrPointerMarshall( &StubMsg
, (unsigned char *)p1
, &fmtstr_ref_unique_out
[4] );
589 ok(ptr
== NULL
, "ret %p\n", ptr
);
590 size
= StubMsg
.Buffer
- StubMsg
.BufferStart
;
591 ok(size
== 5, "Buffer %p Start %p len %d\n", StubMsg
.Buffer
, StubMsg
.BufferStart
, size
);
592 ok(*(unsigned int *)StubMsg
.BufferStart
!= 0, "pointer ID marshalled incorrectly\n");
593 ok(*(unsigned char *)(StubMsg
.BufferStart
+ 4) == 0x22, "char data marshalled incorrectly: 0x%x\n",
594 *(unsigned char *)(StubMsg
.BufferStart
+ 4));
596 StubMsg
.Buffer
= StubMsg
.BufferStart
;
597 StubMsg
.MemorySize
= 0;
602 StubMsg
.Buffer
= StubMsg
.BufferStart
;
603 mem
= mem_orig
= HeapAlloc(GetProcessHeap(), 0, sizeof(void *));
604 *(void **)mem
= NULL
;
605 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 0);
606 ok(mem
== mem_orig
, "mem alloced\n");
607 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
610 StubMsg
.Buffer
= StubMsg
.BufferStart
;
611 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 1);
613 ok(mem
== mem_orig
, "mem alloced\n");
614 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
618 StubMsg
.Buffer
= StubMsg
.BufferStart
;
619 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
620 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
622 mem
= my_alloc(sizeof(void *));
623 *(void **)mem
= NULL
;
625 StubMsg
.Buffer
= StubMsg
.BufferStart
;
626 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
627 ok(my_free_called
== 0, "free called %d\n", my_free_called
);
630 mem
= my_alloc(sizeof(void *));
631 *(void **)mem
= my_alloc(sizeof(char));
633 StubMsg
.Buffer
= StubMsg
.BufferStart
;
634 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
635 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
640 StubMsg
.IsClient
= 0;
642 StubMsg
.Buffer
= StubMsg
.BufferStart
;
643 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 0);
644 ok(mem
!= StubMsg
.BufferStart
, "mem pointing at buffer\n");
646 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
647 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
651 StubMsg
.Buffer
= StubMsg
.BufferStart
;
652 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 1);
653 ok(mem
!= StubMsg
.BufferStart
, "mem pointing at buffer\n");
655 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
656 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
660 *(void **)mem
= NULL
;
661 StubMsg
.Buffer
= StubMsg
.BufferStart
;
662 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 0);
664 ok(mem
== mem_orig
, "mem alloced\n");
665 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
670 *(void **)mem
= NULL
;
671 StubMsg
.Buffer
= StubMsg
.BufferStart
;
672 NdrPointerUnmarshall( &StubMsg
, &mem
, &fmtstr_ref_unique_out
[4], 1);
674 ok(mem
== mem_orig
, "mem alloced\n");
675 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
678 mem
= my_alloc(sizeof(void *));
679 *(void **)mem
= NULL
;
681 StubMsg
.Buffer
= StubMsg
.BufferStart
;
682 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
683 ok(my_free_called
== 0, "free called %d\n", my_free_called
);
686 mem
= my_alloc(sizeof(void *));
687 *(void **)mem
= my_alloc(sizeof(char));
689 StubMsg
.Buffer
= StubMsg
.BufferStart
;
690 NdrPointerFree( &StubMsg
, mem
, &fmtstr_ref_unique_out
[4] );
691 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
694 HeapFree(GetProcessHeap(), 0, mem_orig
);
695 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
698 static void test_simple_struct_marshal(const unsigned char *formattypes
,
699 void *memsrc
, DWORD srcsize
,
700 const void *wiredata
,
702 int(*cmp
)(const void*,const void*,size_t),
703 int num_additional_allocs
,
706 RPC_MESSAGE RpcMessage
;
707 MIDL_STUB_MESSAGE StubMsg
;
708 MIDL_STUB_DESC StubDesc
;
711 unsigned char *mem
, *mem_orig
;
713 my_alloc_called
= my_free_called
= 0;
717 StubDesc
= Object_StubDesc
;
718 StubDesc
.pFormatTypes
= formattypes
;
720 NdrClientInitializeNew(&RpcMessage
, &StubMsg
, &StubDesc
, 0);
722 StubMsg
.BufferLength
= 0;
723 NdrSimpleStructBufferSize( &StubMsg
, memsrc
, formattypes
);
724 ok(StubMsg
.BufferLength
>= wiredatalen
, "%s: length %d\n", msgpfx
, StubMsg
.BufferLength
);
725 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
726 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
727 ptr
= NdrSimpleStructMarshall( &StubMsg
, memsrc
, formattypes
);
728 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
729 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
);
730 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));
732 StubMsg
.Buffer
= StubMsg
.BufferStart
;
733 StubMsg
.MemorySize
= 0;
734 size
= NdrSimpleStructMemorySize( &StubMsg
, formattypes
);
735 ok(size
== StubMsg
.MemorySize
, "%s: size != MemorySize\n", msgpfx
);
736 ok(size
== srcsize
, "%s: mem size %u\n", msgpfx
, size
);
737 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
);
739 StubMsg
.Buffer
= StubMsg
.BufferStart
;
740 size
= NdrSimpleStructMemorySize( &StubMsg
, formattypes
);
741 ok(size
== StubMsg
.MemorySize
, "%s: size != MemorySize\n", msgpfx
);
742 ok(StubMsg
.MemorySize
== ((srcsize
+ 3) & ~3) + srcsize
, "%s: mem size %u\n", msgpfx
, size
);
743 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
);
745 /*** Unmarshalling first with must_alloc false ***/
747 StubMsg
.Buffer
= StubMsg
.BufferStart
;
748 StubMsg
.MemorySize
= 0;
749 mem_orig
= mem
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, srcsize
);
750 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 0 );
751 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
752 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== wiredatalen
, "%s: Buffer %p Start %p\n", msgpfx
, StubMsg
.Buffer
, StubMsg
.BufferStart
);
753 ok(mem
== mem_orig
, "%s: mem has changed %p %p\n", msgpfx
, mem
, mem_orig
);
754 ok(!cmp(mem
, memsrc
, srcsize
), "%s: incorrectly unmarshaled\n", msgpfx
);
755 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
757 ok(StubMsg
.MemorySize
== 0, "%s: memorysize touched in unmarshal\n", msgpfx
);
759 /* If we're a server we still use the supplied memory */
760 StubMsg
.Buffer
= StubMsg
.BufferStart
;
761 StubMsg
.IsClient
= 0;
762 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 0 );
763 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
764 ok(mem
== mem_orig
, "%s: mem has changed %p %p\n", msgpfx
, mem
, mem_orig
);
765 ok(!cmp(mem
, memsrc
, srcsize
), "%s: incorrectly unmarshaled\n", msgpfx
);
766 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
768 ok(StubMsg
.MemorySize
== 0, "%s: memorysize touched in unmarshal\n", msgpfx
);
770 /* ...unless we pass a NULL ptr, then the buffer is used.
771 Passing a NULL ptr while we're a client && !must_alloc
772 crashes on Windows, so we won't do that. */
774 if (0) /* crashes on Win9x and NT4 */
777 StubMsg
.IsClient
= 0;
778 StubMsg
.Buffer
= StubMsg
.BufferStart
;
779 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, FALSE
);
780 ok(ptr
== NULL
, "%s: ret %p\n", msgpfx
, ptr
);
781 ok(mem
== StubMsg
.BufferStart
, "%s: mem not equal buffer\n", msgpfx
);
782 ok(!cmp(mem
, memsrc
, srcsize
), "%s: incorrectly unmarshaled\n", msgpfx
);
783 ok(my_alloc_called
== num_additional_allocs
, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
785 ok(StubMsg
.MemorySize
== 0, "%s: memorysize touched in unmarshal\n", msgpfx
);
788 /*** now must_alloc is true ***/
790 /* with must_alloc set we always allocate new memory whether or not we're
791 a server and also when passing NULL */
793 StubMsg
.IsClient
= 1;
794 StubMsg
.Buffer
= StubMsg
.BufferStart
;
795 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 1 );
796 ok(ptr
== NULL
, "ret %p\n", ptr
);
797 ok(mem
!= mem_orig
, "mem not changed %p %p\n", mem
, mem_orig
);
798 ok(!cmp(mem
, memsrc
, srcsize
), "incorrectly unmarshaled\n");
799 ok(my_alloc_called
== num_additional_allocs
+ 1, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
801 ok(StubMsg
.MemorySize
== 0, "memorysize touched in unmarshal\n");
804 StubMsg
.Buffer
= StubMsg
.BufferStart
;
805 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 1 );
806 ok(ptr
== NULL
, "ret %p\n", ptr
);
807 ok(mem
!= mem_orig
, "mem not changed %p %p\n", mem
, mem_orig
);
808 ok(!cmp(mem
, memsrc
, srcsize
), "incorrectly unmarshaled\n");
809 ok(my_alloc_called
== num_additional_allocs
+ 1, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
811 ok(StubMsg
.MemorySize
== 0, "memorysize touched in unmarshal\n");
814 StubMsg
.Buffer
= StubMsg
.BufferStart
;
815 StubMsg
.IsClient
= 0;
816 StubMsg
.ReuseBuffer
= 1;
817 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 1 );
818 ok(ptr
== NULL
, "ret %p\n", ptr
);
819 ok(mem
!= mem_orig
, "mem not changed %p %p\n", mem
, mem_orig
);
820 ok(mem
!= StubMsg
.BufferStart
, "mem is buffer mem\n");
821 ok(!cmp(mem
, memsrc
, srcsize
), "incorrectly unmarshaled\n");
822 ok(my_alloc_called
== num_additional_allocs
+ 1, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
824 ok(StubMsg
.MemorySize
== 0, "memorysize touched in unmarshal\n");
827 StubMsg
.Buffer
= StubMsg
.BufferStart
;
828 StubMsg
.IsClient
= 0;
829 StubMsg
.ReuseBuffer
= 1;
830 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, &mem
, formattypes
, 1 );
831 ok(ptr
== NULL
, "ret %p\n", ptr
);
832 ok(mem
!= StubMsg
.BufferStart
, "mem is buffer mem\n");
833 ok(!cmp(mem
, memsrc
, srcsize
), "incorrectly unmarshaled\n");
834 ok(my_alloc_called
== num_additional_allocs
+ 1, "%s: my_alloc got called %d times\n", msgpfx
, my_alloc_called
);
836 ok(StubMsg
.MemorySize
== 0, "memorysize touched in unmarshal\n");
838 HeapFree(GetProcessHeap(), 0, mem_orig
);
839 HeapFree(GetProcessHeap(), 0, StubMsg
.BufferStart
);
849 static int ps1_cmp(const void *s1
, const void *s2
, size_t num
)
851 const ps1_t
*p1
, *p2
;
859 if(p1
->pl1
&& p2
->pl1
)
861 if(*p1
->pl1
!= *p2
->pl1
)
864 else if(p1
->pl1
|| p2
->pl1
)
867 if(p1
->pc1
&& p2
->pc1
)
869 if(*p1
->pc1
!= *p2
->pc1
)
872 else if(p1
->pc1
|| p2
->pc1
)
878 static void test_simple_struct(void)
880 unsigned char wiredata
[28];
886 static const unsigned char fmtstr_simple_struct
[] =
888 0x12, 0x0, /* FC_UP */
889 NdrFcShort( 0x2 ), /* Offset=2 */
890 0x15, 0x3, /* FC_STRUCT [align 4] */
891 NdrFcShort( 0x18 ), /* [size 24] */
894 0x38, /* FC_ALIGNM4 */
897 0x39, /* FC_ALIGNM8 */
908 static const unsigned char fmtstr_pointer_struct
[] =
910 0x12, 0x0, /* FC_UP */
911 NdrFcShort( 0x2 ), /* Offset=2 */
913 0x1a, /* FC_BOGUS_STRUCT */
915 NdrFcShort(0x18), /* [size 24] */
917 NdrFcShort(0x8), /* Offset= 8 (266) */
919 0x39, /* FC_ALIGNM8 */
920 0x36, /* FC_POINTER */
921 0x36, /* FC_POINTER */
924 0x12, 0x8, /* FC_UP [simple_pointer] */
927 0x12, 0x8, /* FC_UP [simple_pointer] */
931 0x16, 0x3, /* FC_PSTRUCT [align 4] */
932 NdrFcShort( 0xc ), /* [size 12] */
935 0x46, /* FC_NO_REPEAT */
937 NdrFcShort( 0x4 ), /* 4 */
938 NdrFcShort( 0x4 ), /* 4 */
939 0x13, 0x8, /* FC_OP [simple_pointer] */
942 0x46, /* FC_NO_REPEAT */
944 NdrFcShort( 0x8 ), /* 8 */
945 NdrFcShort( 0x8 ), /* 8 */
946 0x13, 0x8, /* FC_OP [simple_pointer] */
958 /* zero the entire structure, including the holes */
959 memset(&s1
, 0, sizeof(s1
));
966 s1
.ll
= ((LONGLONG
) 0xbadefeed << 32) | 0x2468ace0;
969 memcpy(wiredata
, &s1
, wiredatalen
);
970 test_simple_struct_marshal(fmtstr_simple_struct
+ 4, &s1
, 24, wiredata
, 24, NULL
, 0, "struct");
973 *(unsigned int *)wiredata
= 0x20000;
975 *(unsigned int *)wiredata
= (UINT_PTR
)&s1
;
976 memcpy(wiredata
+ 4, &s1
, wiredatalen
);
977 test_pointer_marshal(fmtstr_simple_struct
, &s1
, 24, wiredata
, 28, NULL
, 0, "struct");
979 if (sizeof(void *) == 8) return; /* it cannot be represented as a simple struct on Win64 */
981 /* zero the entire structure, including the hole */
982 memset(&ps1
, 0, sizeof(ps1
));
990 *(unsigned int *)(wiredata
+ 4) = 0xdeadbeef;
993 *(unsigned int *)(wiredata
+ 8) = 0x20000;
994 *(unsigned int *)(wiredata
+ 12) = 0x20004;
998 *(unsigned int *)(wiredata
+ 8) = (UINT_PTR
)&l
;
999 *(unsigned int *)(wiredata
+ 12) = (UINT_PTR
)&c
;
1001 memcpy(wiredata
+ 16, &l
, 4);
1002 memcpy(wiredata
+ 20, &c
, 1);
1004 test_simple_struct_marshal(fmtstr_pointer_struct
+ 4, &ps1
, 17, wiredata
+ 4, 17, ps1_cmp
, 2, "pointer_struct");
1005 if (use_pointer_ids
)
1007 *(unsigned int *)wiredata
= 0x20000;
1008 *(unsigned int *)(wiredata
+ 8) = 0x20004;
1009 *(unsigned int *)(wiredata
+ 12) = 0x20008;
1012 *(unsigned int *)wiredata
= (UINT_PTR
)&ps1
;
1013 test_pointer_marshal(fmtstr_pointer_struct
, &ps1
, 17, wiredata
, 21, ps1_cmp
, 2, "pointer_struct");
1016 static void test_fullpointer_xlat(void)
1018 PFULL_PTR_XLAT_TABLES pXlatTables
;
1023 pXlatTables
= NdrFullPointerXlatInit(2, XLAT_CLIENT
);
1025 /* "marshaling" phase */
1027 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 1, &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 *)0xcafebeef, 0, &RefId
);
1032 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1033 ok(RefId
== 0x1, "RefId should be 0x1 instead of 0x%x\n", RefId
);
1035 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebabe, 0, &RefId
);
1036 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1037 ok(RefId
== 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId
);
1039 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xdeadbeef, 0, &RefId
);
1040 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1041 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1043 ret
= NdrFullPointerQueryPointer(pXlatTables
, NULL
, 0, &RefId
);
1044 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1045 ok(RefId
== 0, "RefId should be 0 instead of 0x%x\n", RefId
);
1047 /* "unmarshaling" phase */
1049 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x0, 0, &Pointer
);
1050 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1052 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x2, 0, &Pointer
);
1053 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1054 ok(Pointer
== (void *)0xcafebabe, "Pointer should be 0xcafebabe instead of %p\n", Pointer
);
1056 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x4, 0, &Pointer
);
1057 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1058 ok(Pointer
== NULL
, "Pointer should be NULL instead of %p\n", Pointer
);
1060 NdrFullPointerInsertRefId(pXlatTables
, 0x4, (void *)0xdeadbabe);
1062 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x4, 1, &Pointer
);
1063 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1064 ok(Pointer
== (void *)0xdeadbabe, "Pointer should be (void *)0xdeadbabe instead of %p\n", Pointer
);
1066 NdrFullPointerXlatFree(pXlatTables
);
1068 pXlatTables
= NdrFullPointerXlatInit(2, XLAT_SERVER
);
1070 /* "unmarshaling" phase */
1072 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x2, 1, &Pointer
);
1073 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1074 ok(Pointer
== NULL
, "Pointer should be NULL instead of %p\n", Pointer
);
1076 NdrFullPointerInsertRefId(pXlatTables
, 0x2, (void *)0xcafebabe);
1078 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x2, 0, &Pointer
);
1079 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1080 ok(Pointer
== (void *)0xcafebabe, "Pointer should be (void *)0xcafebabe instead of %p\n", Pointer
);
1082 ret
= NdrFullPointerQueryRefId(pXlatTables
, 0x2, 1, &Pointer
);
1083 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1084 ok(Pointer
== (void *)0xcafebabe, "Pointer should be (void *)0xcafebabe instead of %p\n", Pointer
);
1086 /* "marshaling" phase */
1088 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 1, &RefId
);
1089 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1090 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1092 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 1, &RefId
);
1093 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1094 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1096 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 0, &RefId
);
1097 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1098 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1100 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebabe, 0, &RefId
);
1101 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1102 ok(RefId
== 0x2, "RefId should be 0x2 instead of 0x%x\n", RefId
);
1104 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xdeadbeef, 0, &RefId
);
1105 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1106 ok(RefId
== 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId
);
1108 /* "freeing" phase */
1110 ret
= NdrFullPointerFree(pXlatTables
, (void *)0xcafebeef);
1111 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1113 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 0x20, &RefId
);
1114 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1115 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1117 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xcafebeef, 1, &RefId
);
1118 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1119 ok(RefId
== 0x3, "RefId should be 0x3 instead of 0x%x\n", RefId
);
1121 ret
= NdrFullPointerFree(pXlatTables
, (void *)0xcafebabe);
1122 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1124 ret
= NdrFullPointerFree(pXlatTables
, (void *)0xdeadbeef);
1125 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1127 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xdeadbeef, 0x20, &RefId
);
1128 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1129 ok(RefId
== 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId
);
1131 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xdeadbeef, 1, &RefId
);
1132 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1133 ok(RefId
== 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId
);
1135 ret
= NdrFullPointerQueryPointer(pXlatTables
, (void *)0xdeadbeef, 1, &RefId
);
1136 ok(ret
== 1, "ret should be 1 instead of 0x%x\n", ret
);
1137 ok(RefId
== 0x4, "RefId should be 0x4 instead of 0x%x\n", RefId
);
1139 ret
= NdrFullPointerFree(pXlatTables
, (void *)0xdeadbeef);
1140 ok(ret
== 0, "ret should be 0 instead of 0x%x\n", ret
);
1142 NdrFullPointerXlatFree(pXlatTables
);
1145 /* verify stub data that is identical between client and server */
1146 static void test_common_stub_data( const char *prefix
, const MIDL_STUB_MESSAGE
*stubMsg
)
1150 memset(&unset_ptr
, 0xcc, sizeof(unset_ptr
));
1152 #define TEST_ZERO(field, fmt) ok(stubMsg->field == 0, "%s: " #field " should have been set to zero instead of " fmt "\n", prefix, stubMsg->field)
1153 #define TEST_POINTER_UNSET(field) ok(stubMsg->field == unset_ptr, "%s: " #field " should have been unset instead of %p\n", prefix, stubMsg->field)
1154 #define TEST_ULONG_UNSET(field) ok(stubMsg->field == 0xcccccccc, "%s: " #field " should have been unset instead of 0x%x\n", prefix, stubMsg->field)
1155 #define TEST_ULONG_PTR_UNSET(field) ok(stubMsg->field == (ULONG_PTR)unset_ptr, "%s: " #field " should have been unset instead of 0x%lx\n", prefix, stubMsg->field)
1157 TEST_POINTER_UNSET(BufferMark
);
1158 TEST_ULONG_UNSET(MemorySize
);
1159 TEST_POINTER_UNSET(Memory
);
1160 TEST_ZERO(pAllocAllNodesContext
, "%p");
1161 ok(stubMsg
->pPointerQueueState
== 0 ||
1162 broken(stubMsg
->pPointerQueueState
== unset_ptr
), /* win2k */
1163 "%s: pPointerQueueState should have been unset instead of %p\n",
1164 prefix
, stubMsg
->pPointerQueueState
);
1165 TEST_ZERO(IgnoreEmbeddedPointers
, "%d");
1166 TEST_ZERO(PointerBufferMark
, "%p");
1167 ok( stubMsg
->uFlags
== 0 ||
1168 broken(stubMsg
->uFlags
== 0xcc), /* win9x */
1169 "%s: uFlags should have been set to zero instead of 0x%x\n", prefix
, stubMsg
->uFlags
);
1170 /* FIXME: UniquePtrCount */
1171 TEST_ULONG_PTR_UNSET(MaxCount
);
1172 TEST_ULONG_UNSET(Offset
);
1173 TEST_ULONG_UNSET(ActualCount
);
1174 ok(stubMsg
->pfnAllocate
== my_alloc
, "%s: pfnAllocate should have been %p instead of %p\n",
1175 prefix
, my_alloc
, stubMsg
->pfnAllocate
);
1176 ok(stubMsg
->pfnFree
== my_free
, "%s: pfnFree should have been %p instead of %p\n",
1177 prefix
, my_free
, stubMsg
->pfnFree
);
1178 TEST_ZERO(StackTop
, "%p");
1179 TEST_POINTER_UNSET(pPresentedType
);
1180 TEST_POINTER_UNSET(pTransmitType
);
1181 TEST_POINTER_UNSET(SavedHandle
);
1182 ok(stubMsg
->StubDesc
== &Object_StubDesc
, "%s: StubDesc should have been %p instead of %p\n",
1183 prefix
, &Object_StubDesc
, stubMsg
->StubDesc
);
1184 TEST_ZERO(FullPtrRefId
, "%d");
1185 ok( stubMsg
->PointerLength
== 0 ||
1186 broken(stubMsg
->PointerLength
== 1), /* win9x, nt4 */
1187 "%s: pAsyncMsg should have been set to zero instead of %d\n", prefix
, stubMsg
->PointerLength
);
1188 TEST_ZERO(fInDontFree
, "%d");
1189 TEST_ZERO(fDontCallFreeInst
, "%d");
1190 ok( stubMsg
->fHasReturn
== 0 || broken(stubMsg
->fHasReturn
), /* win9x, nt4 */
1191 "%s: fHasReturn should have been set to zero instead of %d\n", prefix
, stubMsg
->fHasReturn
);
1192 TEST_ZERO(fHasExtensions
, "%d");
1193 TEST_ZERO(fHasNewCorrDesc
, "%d");
1194 ok(stubMsg
->fIsIn
== 0 || broken(stubMsg
->fIsIn
), /* win9x, nt4 */
1195 "%s: fIsIn should have been set to 0 instead of %d\n", prefix
, stubMsg
->fIsIn
);
1196 TEST_ZERO(fIsOicf
, "%d");
1197 ok(stubMsg
->fBufferValid
== 0,
1198 "%s: fBufferValid should have been set to 0 instead of %d\n", prefix
, stubMsg
->fBufferValid
);
1199 TEST_ZERO(fNeedMCCP
, "%d");
1200 ok(stubMsg
->fUnused
== 0 ||
1201 stubMsg
->fUnused
== -2, /* Vista */
1202 "%s: fUnused should have been set to 0 or -2 instead of %d\n", prefix
, stubMsg
->fUnused
);
1203 ok(stubMsg
->fUnused2
== 0xffffcccc, "%s: fUnused2 should have been 0xffffcccc instead of 0x%x\n",
1204 prefix
, stubMsg
->fUnused2
);
1205 ok(stubMsg
->dwDestContext
== MSHCTX_DIFFERENTMACHINE
,
1206 "%s: dwDestContext should have been MSHCTX_DIFFERENTMACHINE instead of %d\n",
1207 prefix
, stubMsg
->dwDestContext
);
1208 TEST_ZERO(pvDestContext
, "%p");
1209 TEST_POINTER_UNSET(SavedContextHandles
);
1210 TEST_ULONG_UNSET(ParamNumber
);
1211 TEST_ZERO(pRpcChannelBuffer
, "%p");
1212 TEST_ZERO(pArrayInfo
, "%p");
1213 TEST_POINTER_UNSET(SizePtrCountArray
);
1214 TEST_POINTER_UNSET(SizePtrOffsetArray
);
1215 TEST_POINTER_UNSET(SizePtrLengthArray
);
1216 TEST_POINTER_UNSET(pArgQueue
);
1217 TEST_ZERO(dwStubPhase
, "%d");
1218 /* FIXME: where does this value come from? */
1219 trace("%s: LowStackMark is %p\n", prefix
, stubMsg
->LowStackMark
);
1220 ok( stubMsg
->pAsyncMsg
== 0 || broken(stubMsg
->pAsyncMsg
== unset_ptr
), /* win9x, nt4 */
1221 "%s: pAsyncMsg should have been set to zero instead of %p\n", prefix
, stubMsg
->pAsyncMsg
);
1222 ok( stubMsg
->pCorrInfo
== 0 || broken(stubMsg
->pCorrInfo
== unset_ptr
), /* win9x, nt4 */
1223 "%s: pCorrInfo should have been set to zero instead of %p\n", prefix
, stubMsg
->pCorrInfo
);
1224 ok( stubMsg
->pCorrMemory
== 0 || broken(stubMsg
->pCorrMemory
== unset_ptr
), /* win9x, nt4 */
1225 "%s: pCorrMemory should have been set to zero instead of %p\n", prefix
, stubMsg
->pCorrMemory
);
1226 ok( stubMsg
->pMemoryList
== 0 || broken(stubMsg
->pMemoryList
== unset_ptr
), /* win9x, nt4 */
1227 "%s: pMemoryList should have been set to zero instead of %p\n", prefix
, stubMsg
->pMemoryList
);
1228 TEST_POINTER_UNSET(pCSInfo
);
1229 TEST_POINTER_UNSET(ConformanceMark
);
1230 TEST_POINTER_UNSET(VarianceMark
);
1231 ok(stubMsg
->Unused
== (ULONG_PTR
)unset_ptr
, "%s: Unused should have be unset instead of 0x%lx\n",
1232 prefix
, stubMsg
->Unused
);
1233 TEST_POINTER_UNSET(pContext
);
1234 TEST_POINTER_UNSET(ContextHandleHash
);
1235 TEST_POINTER_UNSET(pUserMarshalList
);
1236 TEST_ULONG_PTR_UNSET(Reserved51_3
);
1237 TEST_ULONG_PTR_UNSET(Reserved51_4
);
1238 TEST_ULONG_PTR_UNSET(Reserved51_5
);
1240 #undef TEST_ULONG_PTR_UNSET
1241 #undef TEST_ULONG_UNSET
1242 #undef TEST_POINTER_UNSET
1246 static void test_client_init(void)
1248 MIDL_STUB_MESSAGE stubMsg
;
1252 memset(&rpcMsg
, 0xcc, sizeof(rpcMsg
));
1253 memset(&stubMsg
, 0xcc, sizeof(stubMsg
));
1254 memset(&unset_ptr
, 0xcc, sizeof(unset_ptr
));
1256 NdrClientInitializeNew(&rpcMsg
, &stubMsg
, &Object_StubDesc
, 1);
1258 test_common_stub_data( "NdrClientInitializeNew", &stubMsg
);
1260 ok(stubMsg
.RpcMsg
== &rpcMsg
, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg
, stubMsg
.RpcMsg
);
1261 ok(rpcMsg
.Handle
== NULL
, "rpcMsg.Handle should have been NULL instead of %p\n", rpcMsg
.Handle
);
1262 ok(rpcMsg
.Buffer
== unset_ptr
, "rpcMsg.Buffer should have been unset instead of %p\n",
1264 ok(rpcMsg
.BufferLength
== 0xcccccccc, "rpcMsg.BufferLength should have been unset instead of %d\n", rpcMsg
.BufferLength
);
1265 ok(rpcMsg
.ProcNum
== 0x8001, "rpcMsg.ProcNum should have been 0x8001 instead of 0x%x\n", rpcMsg
.ProcNum
);
1266 ok(rpcMsg
.TransferSyntax
== unset_ptr
, "rpcMsg.TransferSyntax should have been unset instead of %p\n", rpcMsg
.TransferSyntax
);
1267 ok(rpcMsg
.RpcInterfaceInformation
== Object_StubDesc
.RpcInterfaceInformation
,
1268 "rpcMsg.RpcInterfaceInformation should have been %p instead of %p\n",
1269 Object_StubDesc
.RpcInterfaceInformation
, rpcMsg
.RpcInterfaceInformation
);
1270 /* Note: ReservedForRuntime not tested */
1271 ok(rpcMsg
.ManagerEpv
== unset_ptr
, "rpcMsg.ManagerEpv should have been unset instead of %p\n", rpcMsg
.ManagerEpv
);
1272 ok(rpcMsg
.ImportContext
== unset_ptr
, "rpcMsg.ImportContext should have been unset instead of %p\n", rpcMsg
.ImportContext
);
1273 ok(rpcMsg
.RpcFlags
== 0, "rpcMsg.RpcFlags should have been 0 instead of 0x%x\n", rpcMsg
.RpcFlags
);
1275 ok(stubMsg
.Buffer
== unset_ptr
, "stubMsg.Buffer should have been unset instead of %p\n",
1277 ok(stubMsg
.BufferStart
== NULL
, "stubMsg.BufferStart should have been NULL instead of %p\n",
1278 stubMsg
.BufferStart
);
1279 ok(stubMsg
.BufferEnd
== NULL
, "stubMsg.BufferEnd should have been NULL instead of %p\n",
1281 ok(stubMsg
.BufferLength
== 0, "stubMsg.BufferLength should have been 0 instead of %u\n",
1282 stubMsg
.BufferLength
);
1283 ok(stubMsg
.IsClient
== 1, "stubMsg.IsClient should have been 1 instead of %u\n", stubMsg
.IsClient
);
1284 ok(stubMsg
.ReuseBuffer
== 0, "stubMsg.ReuseBuffer should have been 0 instead of %d\n",
1285 stubMsg
.ReuseBuffer
);
1286 ok(stubMsg
.CorrDespIncrement
== 0, "stubMsg.CorrDespIncrement should have been 0 instead of %d\n",
1287 stubMsg
.CorrDespIncrement
);
1288 ok(stubMsg
.FullPtrXlatTables
== unset_ptr
, "stubMsg.FullPtrXlatTables should have been unset instead of %p\n",
1289 stubMsg
.FullPtrXlatTables
);
1292 static void test_server_init(void)
1294 MIDL_STUB_MESSAGE stubMsg
;
1297 unsigned char buffer
[256];
1299 memset(&rpcMsg
, 0, sizeof(rpcMsg
));
1300 rpcMsg
.Buffer
= buffer
;
1301 rpcMsg
.BufferLength
= sizeof(buffer
);
1302 rpcMsg
.RpcFlags
= RPC_BUFFER_COMPLETE
;
1304 memset(&stubMsg
, 0xcc, sizeof(stubMsg
));
1306 ret
= NdrServerInitializeNew(&rpcMsg
, &stubMsg
, &Object_StubDesc
);
1307 ok(ret
== NULL
, "NdrServerInitializeNew should have returned NULL instead of %p\n", ret
);
1309 test_common_stub_data( "NdrServerInitializeNew", &stubMsg
);
1311 ok(stubMsg
.RpcMsg
== &rpcMsg
, "stubMsg.RpcMsg should have been %p instead of %p\n", &rpcMsg
, stubMsg
.RpcMsg
);
1312 ok(stubMsg
.Buffer
== buffer
, "stubMsg.Buffer should have been %p instead of %p\n", buffer
, stubMsg
.Buffer
);
1313 ok(stubMsg
.BufferStart
== buffer
, "stubMsg.BufferStart should have been %p instead of %p\n", buffer
, stubMsg
.BufferStart
);
1314 ok(stubMsg
.BufferEnd
== buffer
+ sizeof(buffer
), "stubMsg.BufferEnd should have been %p instead of %p\n", buffer
+ sizeof(buffer
), stubMsg
.BufferEnd
);
1316 ok(stubMsg
.BufferLength
== 0, "stubMsg.BufferLength should have been 0 instead of %u\n", stubMsg
.BufferLength
);
1317 ok(stubMsg
.IsClient
== 0, "stubMsg.IsClient should have been 0 instead of %u\n", stubMsg
.IsClient
);
1318 ok(stubMsg
.ReuseBuffer
== 0 ||
1319 broken(stubMsg
.ReuseBuffer
== 1), /* win2k */
1320 "stubMsg.ReuseBuffer should have been set to zero instead of %d\n", stubMsg
.ReuseBuffer
);
1321 ok(stubMsg
.CorrDespIncrement
== 0xcc ||
1322 stubMsg
.CorrDespIncrement
== 0,
1323 "CorrDespIncrement should have been unset instead of 0x%x\n", stubMsg
.CorrDespIncrement
);
1324 ok(stubMsg
.FullPtrXlatTables
== 0, "stubMsg.BufferLength should have been 0 instead of %p\n", stubMsg
.FullPtrXlatTables
);
1327 static void test_ndr_allocate(void)
1329 RPC_MESSAGE RpcMessage
;
1330 MIDL_STUB_MESSAGE StubMsg
;
1331 MIDL_STUB_DESC StubDesc
;
1333 struct tag_mem_list_v2_t
1338 struct tag_mem_list_v2_t
*next
;
1340 const DWORD magic_MEML
= 'M' << 24 | 'E' << 16 | 'M' << 8 | 'L';
1342 StubDesc
= Object_StubDesc
;
1343 NdrClientInitializeNew(&RpcMessage
, &StubMsg
, &StubDesc
, 0);
1345 my_alloc_called
= my_free_called
= 0;
1346 p1
= NdrAllocate(&StubMsg
, 10);
1347 p2
= NdrAllocate(&StubMsg
, 24);
1348 ok(my_alloc_called
== 2, "alloc called %d\n", my_alloc_called
);
1349 ok(StubMsg
.pMemoryList
!= NULL
, "StubMsg.pMemoryList NULL\n");
1350 if(StubMsg
.pMemoryList
)
1352 mem_list_v2
= StubMsg
.pMemoryList
;
1353 if (mem_list_v2
->size
== 24)
1355 trace("v2 mem list format\n");
1356 ok((char *)mem_list_v2
== (char *)p2
+ 24, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p2
+ 24, mem_list_v2
);
1357 ok(mem_list_v2
->magic
== magic_MEML
, "magic %08x\n", mem_list_v2
->magic
);
1358 ok(mem_list_v2
->size
== 24, "wrong size for p2 %d\n", mem_list_v2
->size
);
1359 ok(mem_list_v2
->unknown
== 0, "wrong unknown for p2 0x%x\n", mem_list_v2
->unknown
);
1360 ok(mem_list_v2
->next
!= NULL
, "next NULL\n");
1361 mem_list_v2
= mem_list_v2
->next
;
1364 ok((char *)mem_list_v2
== (char *)p1
+ 16, "expected mem_list_v2 pointer %p, but got %p\n", (char *)p1
+ 16, mem_list_v2
);
1365 ok(mem_list_v2
->magic
== magic_MEML
, "magic %08x\n", mem_list_v2
->magic
);
1366 ok(mem_list_v2
->size
== 16, "wrong size for p1 %d\n", mem_list_v2
->size
);
1367 ok(mem_list_v2
->unknown
== 0, "wrong unknown for p1 0x%x\n", mem_list_v2
->unknown
);
1368 ok(mem_list_v2
->next
== NULL
, "next %p\n", mem_list_v2
->next
);
1371 else win_skip("v1 mem list format\n");
1373 /* NdrFree isn't exported so we can't test free'ing */
1376 static void test_conformant_array(void)
1378 RPC_MESSAGE RpcMessage
;
1379 MIDL_STUB_MESSAGE StubMsg
;
1380 MIDL_STUB_DESC StubDesc
;
1382 unsigned char *mem
, *mem_orig
;
1383 unsigned char memsrc
[20];
1386 static const unsigned char fmtstr_conf_array
[] =
1388 0x1b, /* FC_CARRAY */
1390 NdrFcShort( 0x1 ), /* elem size */
1391 0x40, /* Corr desc: const */
1393 NdrFcShort(0x10), /* const = 0x10 */
1398 for (i
= 0; i
< sizeof(memsrc
); i
++)
1401 StubDesc
= Object_StubDesc
;
1402 StubDesc
.pFormatTypes
= fmtstr_conf_array
;
1404 NdrClientInitializeNew(
1410 StubMsg
.BufferLength
= 0;
1411 NdrConformantArrayBufferSize( &StubMsg
,
1413 fmtstr_conf_array
);
1414 ok(StubMsg
.BufferLength
>= 20, "length %d\n", StubMsg
.BufferLength
);
1416 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1417 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
1418 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
1420 ptr
= NdrConformantArrayMarshall( &StubMsg
, memsrc
, fmtstr_conf_array
);
1421 ok(ptr
== NULL
, "ret %p\n", ptr
);
1422 ok(StubMsg
.Buffer
- StubMsg
.BufferStart
== 20, "Buffer %p Start %p len %d\n", StubMsg
.Buffer
, StubMsg
.BufferStart
, 20);
1423 ok(!memcmp(StubMsg
.BufferStart
+ 4, memsrc
, 16), "incorrectly marshaled\n");
1425 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1426 StubMsg
.MemorySize
= 0;
1430 my_alloc_called
= 0;
1431 /* passing mem == NULL with must_alloc == 0 crashes under Windows */
1432 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 1);
1433 ok(mem
!= NULL
, "mem not alloced\n");
1434 ok(mem
!= StubMsg
.BufferStart
+ 4, "mem pointing at buffer\n");
1435 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1437 my_alloc_called
= 0;
1438 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1440 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 0);
1441 ok(mem
== mem_orig
, "mem alloced\n");
1442 ok(mem
!= StubMsg
.BufferStart
+ 4, "mem pointing at buffer\n");
1443 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1445 my_alloc_called
= 0;
1446 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1447 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 1);
1448 ok(mem
!= mem_orig
, "mem not alloced\n");
1449 ok(mem
!= StubMsg
.BufferStart
+ 4, "mem pointing at buffer\n");
1450 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1453 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1454 NdrConformantArrayFree( &StubMsg
, mem
, fmtstr_conf_array
);
1455 ok(my_free_called
== 0, "free called %d\n", my_free_called
);
1456 StubMsg
.pfnFree(mem
);
1459 my_alloc_called
= 0;
1460 StubMsg
.IsClient
= 0;
1462 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1463 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 0);
1464 ok(mem
== StubMsg
.BufferStart
+ 4 || broken(!mem
), /* win9x, nt4 */
1465 "mem not pointing at buffer %p/%p\n", mem
, StubMsg
.BufferStart
+ 4);
1466 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1467 my_alloc_called
= 0;
1469 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1470 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 1);
1471 ok(mem
!= StubMsg
.BufferStart
+ 4, "mem pointing at buffer\n");
1472 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1473 StubMsg
.pfnFree(mem
);
1475 my_alloc_called
= 0;
1477 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1478 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 0);
1479 ok(mem
== mem_orig
, "mem alloced\n");
1480 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1482 my_alloc_called
= 0;
1484 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1485 NdrConformantArrayUnmarshall( &StubMsg
, &mem
, fmtstr_conf_array
, 1);
1486 ok(mem
!= StubMsg
.BufferStart
+ 4, "mem pointing at buffer\n");
1487 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1488 StubMsg
.pfnFree(mem
);
1489 StubMsg
.pfnFree(mem_orig
);
1491 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
1494 static void test_conformant_string(void)
1496 RPC_MESSAGE RpcMessage
;
1497 MIDL_STUB_MESSAGE StubMsg
;
1498 MIDL_STUB_DESC StubDesc
;
1501 unsigned char *mem
, *mem_orig
;
1502 char memsrc
[] = "This is a test string";
1504 static const unsigned char fmtstr_conf_str
[] =
1506 0x11, 0x8, /* FC_RP [simple_pointer] */
1507 0x22, /* FC_C_CSTRING */
1511 StubDesc
= Object_StubDesc
;
1512 StubDesc
.pFormatTypes
= fmtstr_conf_str
;
1514 memset( &StubMsg
, 0, sizeof(StubMsg
) ); /* needed on win9x and nt4 */
1515 NdrClientInitializeNew(
1521 StubMsg
.BufferLength
= 0;
1522 NdrPointerBufferSize( &StubMsg
,
1523 (unsigned char *)memsrc
,
1525 ok(StubMsg
.BufferLength
>= sizeof(memsrc
) + 12, "length %d\n", StubMsg
.BufferLength
);
1527 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1528 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
1529 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
1531 ptr
= NdrPointerMarshall( &StubMsg
, (unsigned char *)memsrc
, fmtstr_conf_str
);
1532 ok(ptr
== NULL
, "ret %p\n", ptr
);
1533 size
= StubMsg
.Buffer
- StubMsg
.BufferStart
;
1534 ok(size
== sizeof(memsrc
) + 12, "Buffer %p Start %p len %d\n",
1535 StubMsg
.Buffer
, StubMsg
.BufferStart
, size
);
1536 ok(!memcmp(StubMsg
.BufferStart
+ 12, memsrc
, sizeof(memsrc
)), "incorrectly marshaled\n");
1538 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1539 StubMsg
.MemorySize
= 0;
1543 my_alloc_called
= 0;
1544 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1545 mem
= mem_orig
= HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc
));
1546 /* Windows apparently checks string length on the output buffer to determine its size... */
1547 memset( mem
, 'x', sizeof(memsrc
) - 1 );
1548 mem
[sizeof(memsrc
) - 1] = 0;
1549 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 0);
1550 ok(mem
== mem_orig
, "mem not alloced\n");
1551 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1553 my_alloc_called
= 0;
1554 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1555 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 1);
1557 ok(mem
== mem_orig
, "mem not alloced\n");
1558 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1562 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1563 NdrPointerFree( &StubMsg
, mem
, fmtstr_conf_str
);
1564 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
1568 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1569 NdrPointerFree( &StubMsg
, mem
, fmtstr_conf_str
);
1570 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
1573 my_alloc_called
= 0;
1574 StubMsg
.IsClient
= 0;
1576 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1577 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 0);
1578 ok(mem
== StubMsg
.BufferStart
+ 12 || broken(!mem
), /* win9x, nt4 */
1579 "mem not pointing at buffer %p/%p\n", mem
, StubMsg
.BufferStart
+ 12 );
1580 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1582 my_alloc_called
= 0;
1584 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1585 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 1);
1587 ok(mem
== StubMsg
.BufferStart
+ 12 || broken(!mem
), /* win9x, nt4 */
1588 "mem not pointing at buffer %p/%p\n", mem
, StubMsg
.BufferStart
+ 12 );
1589 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1592 my_alloc_called
= 0;
1593 mem
= mem_orig
= HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc
));
1594 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1595 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 0);
1596 ok(mem
== StubMsg
.BufferStart
+ 12 || broken(!mem
), /* win9x, nt4 */
1597 "mem not pointing at buffer %p/%p\n", mem
, StubMsg
.BufferStart
+ 12 );
1598 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1600 my_alloc_called
= 0;
1602 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1603 NdrPointerUnmarshall( &StubMsg
, &mem
, fmtstr_conf_str
, 1);
1605 ok(mem
== StubMsg
.BufferStart
+ 12 || broken(!mem
), /* win9x, nt4 */
1606 "mem not pointing at buffer %p/%p\n", mem
, StubMsg
.BufferStart
+ 12 );
1607 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1612 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1613 NdrPointerFree( &StubMsg
, mem
, fmtstr_conf_str
);
1614 ok(my_free_called
== 1, "free called %d\n", my_free_called
);
1616 HeapFree(GetProcessHeap(), 0, mem_orig
);
1617 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
1620 static void test_nonconformant_string(void)
1622 RPC_MESSAGE RpcMessage
;
1623 MIDL_STUB_MESSAGE StubMsg
;
1624 MIDL_STUB_DESC StubDesc
;
1627 unsigned char *mem
, *mem_orig
;
1628 unsigned char memsrc
[10] = "This is";
1629 unsigned char memsrc2
[10] = "This is a";
1631 static const unsigned char fmtstr_nonconf_str
[] =
1633 0x26, /* FC_CSTRING */
1635 NdrFcShort( 0xa ), /* 10 */
1638 StubDesc
= Object_StubDesc
;
1639 StubDesc
.pFormatTypes
= fmtstr_nonconf_str
;
1642 NdrClientInitializeNew(
1648 StubMsg
.BufferLength
= 0;
1650 NdrNonConformantStringBufferSize( &StubMsg
, memsrc
, fmtstr_nonconf_str
);
1651 ok(StubMsg
.BufferLength
>= strlen((char *)memsrc
) + 1 + 8, "length %d\n", StubMsg
.BufferLength
);
1653 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1654 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
1655 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
1657 ptr
= NdrNonConformantStringMarshall( &StubMsg
, memsrc
, fmtstr_nonconf_str
);
1658 ok(ptr
== NULL
, "ret %p\n", ptr
);
1659 size
= StubMsg
.Buffer
- StubMsg
.BufferStart
;
1660 ok(size
== strlen((char *)memsrc
) + 1 + 8, "Buffer %p Start %p len %d\n",
1661 StubMsg
.Buffer
, StubMsg
.BufferStart
, size
);
1662 ok(!memcmp(StubMsg
.BufferStart
+ 8, memsrc
, strlen((char *)memsrc
) + 1), "incorrectly marshaled\n");
1664 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1665 StubMsg
.MemorySize
= 0;
1669 my_alloc_called
= 0;
1670 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1671 mem
= mem_orig
= HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc
));
1672 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1673 ok(mem
== mem_orig
, "mem alloced\n");
1674 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1676 my_alloc_called
= 0;
1677 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1678 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 1);
1680 ok(mem
== mem_orig
, "mem alloced\n");
1682 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1685 my_alloc_called
= 0;
1686 StubMsg
.IsClient
= 0;
1688 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1689 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1690 ok(mem
!= mem_orig
, "mem not alloced\n");
1691 ok(mem
!= StubMsg
.BufferStart
+ 8, "mem pointing at buffer\n");
1692 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1695 my_alloc_called
= 0;
1697 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1698 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1699 ok(mem
== mem_orig
, "mem alloced\n");
1700 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1702 my_alloc_called
= 0;
1704 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1705 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 1);
1707 ok(mem
== mem_orig
, "mem alloced\n");
1709 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1711 HeapFree(GetProcessHeap(), 0, mem_orig
);
1712 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
1715 NdrClientInitializeNew(
1721 StubMsg
.BufferLength
= 0;
1723 NdrNonConformantStringBufferSize( &StubMsg
, memsrc2
, fmtstr_nonconf_str
);
1724 ok(StubMsg
.BufferLength
>= strlen((char *)memsrc2
) + 1 + 8, "length %d\n", StubMsg
.BufferLength
);
1726 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1727 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
1728 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
1730 ptr
= NdrNonConformantStringMarshall( &StubMsg
, memsrc2
, fmtstr_nonconf_str
);
1731 ok(ptr
== NULL
, "ret %p\n", ptr
);
1732 size
= StubMsg
.Buffer
- StubMsg
.BufferStart
;
1733 ok(size
== strlen((char *)memsrc2
) + 1 + 8, "Buffer %p Start %p len %d\n",
1734 StubMsg
.Buffer
, StubMsg
.BufferStart
, size
);
1735 ok(!memcmp(StubMsg
.BufferStart
+ 8, memsrc2
, strlen((char *)memsrc2
) + 1), "incorrectly marshaled\n");
1737 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1738 StubMsg
.MemorySize
= 0;
1742 my_alloc_called
= 0;
1743 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1744 mem
= mem_orig
= HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc
));
1745 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1746 ok(mem
== mem_orig
, "mem alloced\n");
1747 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1749 my_alloc_called
= 0;
1750 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1751 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 1);
1753 ok(mem
== mem_orig
, "mem alloced\n");
1755 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1758 my_alloc_called
= 0;
1759 StubMsg
.IsClient
= 0;
1761 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1762 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1763 ok(mem
!= mem_orig
, "mem not alloced\n");
1764 ok(mem
!= StubMsg
.BufferStart
+ 8, "mem pointing at buffer\n");
1765 ok(my_alloc_called
== 1, "alloc called %d\n", my_alloc_called
);
1768 my_alloc_called
= 0;
1770 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1771 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 0);
1772 ok(mem
== mem_orig
, "mem alloced\n");
1773 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1775 my_alloc_called
= 0;
1777 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1778 NdrNonConformantStringUnmarshall( &StubMsg
, &mem
, fmtstr_nonconf_str
, 1);
1780 ok(mem
== mem_orig
, "mem alloced\n");
1782 ok(my_alloc_called
== 0, "alloc called %d\n", my_alloc_called
);
1784 HeapFree(GetProcessHeap(), 0, mem_orig
);
1785 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
1788 static void test_conf_complex_struct(void)
1790 RPC_MESSAGE RpcMessage
;
1791 MIDL_STUB_MESSAGE StubMsg
;
1792 MIDL_STUB_DESC StubDesc
;
1798 unsigned int *array
[1];
1800 struct conf_complex
*memsrc
;
1801 struct conf_complex
*mem
;
1803 static const unsigned char fmtstr_complex_struct
[] =
1806 0x1b, /* FC_CARRAY */
1808 /* 2 */ NdrFcShort( 0x4 ), /* 4 */
1809 /* 4 */ 0x8, /* Corr desc: FC_LONG */
1811 /* 6 */ NdrFcShort( 0xfffc ), /* -4 */
1816 0x48, /* FC_VARIABLE_REPEAT */
1817 0x49, /* FC_FIXED_OFFSET */
1818 /* 12 */ NdrFcShort( 0x4 ), /* 4 */
1819 /* 14 */ NdrFcShort( 0x0 ), /* 0 */
1820 /* 16 */ NdrFcShort( 0x1 ), /* 1 */
1821 /* 18 */ NdrFcShort( 0x0 ), /* 0 */
1822 /* 20 */ NdrFcShort( 0x0 ), /* 0 */
1823 /* 22 */ 0x12, 0x8, /* FC_UP [simple_pointer] */
1824 /* 24 */ 0x8, /* FC_LONG */
1830 /* 28 */ 0x5c, /* FC_PAD */
1833 0x1a, /* FC_BOGUS_STRUCT */
1835 /* 32 */ NdrFcShort( 0x4 ), /* 4 */
1836 /* 34 */ NdrFcShort( 0xffffffde ), /* Offset= -34 (0) */
1837 /* 36 */ NdrFcShort( 0x0 ), /* Offset= 0 (36) */
1838 /* 38 */ 0x8, /* FC_LONG */
1842 memsrc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
1843 FIELD_OFFSET(struct conf_complex
, array
[20]));
1846 StubDesc
= Object_StubDesc
;
1847 StubDesc
.pFormatTypes
= fmtstr_complex_struct
;
1849 NdrClientInitializeNew(
1855 StubMsg
.BufferLength
= 0;
1856 NdrComplexStructBufferSize( &StubMsg
,
1857 (unsigned char *)memsrc
,
1858 &fmtstr_complex_struct
[30] );
1859 ok(StubMsg
.BufferLength
>= 28, "length %d\n", StubMsg
.BufferLength
);
1861 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
1862 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
1863 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
1865 ptr
= NdrComplexStructMarshall( &StubMsg
, (unsigned char *)memsrc
,
1866 &fmtstr_complex_struct
[30] );
1867 ok(ptr
== NULL
, "ret %p\n", ptr
);
1868 ok(*(unsigned int *)StubMsg
.BufferStart
== 20, "Conformance should have been 20 instead of %d\n", *(unsigned int *)StubMsg
.BufferStart
);
1869 ok(*(unsigned int *)(StubMsg
.BufferStart
+ 4) == 20, "conf_complex.size should have been 20 instead of %d\n", *(unsigned int *)(StubMsg
.BufferStart
+ 4));
1870 for (i
= 0; i
< 20; i
++)
1871 ok(*(unsigned int *)(StubMsg
.BufferStart
+ 8 + i
* 4) == 0, "pointer id for conf_complex.array[%d] should have been 0 instead of 0x%x\n", i
, *(unsigned int *)(StubMsg
.BufferStart
+ 8 + i
* 4));
1874 my_alloc_called
= 0;
1875 StubMsg
.IsClient
= 0;
1877 StubMsg
.Buffer
= StubMsg
.BufferStart
;
1878 ptr
= NdrComplexStructUnmarshall( &StubMsg
, (unsigned char **)&mem
, &fmtstr_complex_struct
[30], 0);
1879 ok(ptr
== NULL
, "ret %p\n", ptr
);
1880 ok(mem
->size
== 20, "mem->size wasn't unmarshalled correctly (%d)\n", mem
->size
);
1881 ok(mem
->array
[0] == NULL
, "mem->array[0] wasn't unmarshalled correctly (%p)\n", mem
->array
[0]);
1882 StubMsg
.pfnFree(mem
);
1884 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
1885 HeapFree(GetProcessHeap(), 0, memsrc
);
1889 static void test_conf_complex_array(void)
1891 RPC_MESSAGE RpcMessage
;
1892 MIDL_STUB_MESSAGE StubMsg
;
1893 MIDL_STUB_DESC StubDesc
;
1898 unsigned int dim1
, dim2
;
1901 struct conf_complex memsrc
;
1902 struct conf_complex
*mem
;
1903 DWORD
*buf
, expected_length
;
1905 static const unsigned char fmtstr_complex_array
[] =
1908 /* 0 */ 0x21, /* FC_BOGUS_ARRAY */
1910 /* 2 */ NdrFcShort( 0x0 ), /* 0 */
1911 /* 4 */ 0x19, 0x0, /* Corr desc: field pointer, FC_ULONG */
1912 /* 6 */ NdrFcShort( 0x4 ), /* 4 */
1913 /* 8 */ NdrFcLong( 0xffffffff ), /* -1 */
1914 /* 12 */ 0x8, /* FC_LONG */
1917 0x21, /* FC_BOGUS_ARRAY */
1919 /* 16 */ NdrFcShort( 0x0 ), /* 0 */
1920 /* 18 */ 0x19, /* Corr desc: field pointer, FC_ULONG */
1922 /* 20 */ NdrFcShort( 0x0 ), /* 0 */
1923 /* 22 */ NdrFcLong( 0xffffffff ), /* -1 */
1924 /* 26 */ 0x12, 0x0, /* FC_UP */
1925 /* 28 */ NdrFcShort( 0xffe4 ), /* Offset= -28 (0) */
1926 /* 30 */ 0x5c, /* FC_PAD */
1930 /* 32 */ 0x1a, /* FC_BOGUS_STRUCT */
1932 /* 34 */ NdrFcShort( 0x10 ), /* 16 */
1933 /* 36 */ NdrFcShort( 0x0 ), /* 0 */
1934 /* 38 */ NdrFcShort( 0x6 ), /* Offset= 6 (44) */
1935 /* 40 */ 0x8, /* FC_LONG */
1937 /* 42 */ 0x36, /* FC_POINTER */
1940 0x12, 0x0, /* FC_UP */
1941 /* 46 */ NdrFcShort( 0xffe0 ), /* Offset= -32 (14) */
1944 0x16, /* FC_PSTRUCT */
1946 /* 34 */ NdrFcShort( 0xc ), /* 12 */
1947 /* 36 */ 0x4b, /* FC_PP */
1949 /* 38 */ 0x46, /* FC_NO_REPEAT */
1951 /* 40 */ NdrFcShort( 0x8 ), /* 8 */
1952 /* 42 */ NdrFcShort( 0x8 ), /* 8 */
1953 /* 44 */ 0x12, 0x0, /* FC_UP */
1954 /* 46 */ NdrFcShort( 0xffe0 ), /* Offset= -32 (14) */
1955 /* 48 */ 0x5b, /* FC_END */
1957 /* 50 */ 0x8, /* FC_LONG */
1959 /* 52 */ 0x5c, /* FC_PAD */
1967 memsrc
.array
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, memsrc
.dim1
* sizeof(DWORD
*));
1969 for(i
= 0; i
< memsrc
.dim1
; i
++)
1971 memsrc
.array
[i
] = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, memsrc
.dim2
* sizeof(DWORD
));
1972 for(j
= 0; j
< memsrc
.dim2
; j
++)
1973 memsrc
.array
[i
][j
] = i
* memsrc
.dim2
+ j
;
1976 StubDesc
= Object_StubDesc
;
1977 StubDesc
.pFormatTypes
= fmtstr_complex_array
;
1979 NdrClientInitializeNew(
1985 StubMsg
.BufferLength
= 0;
1988 NdrComplexStructBufferSize( &StubMsg
,
1989 (unsigned char *)&memsrc
,
1990 &fmtstr_complex_array
[32] );
1992 NdrSimpleStructBufferSize( &StubMsg
,
1993 (unsigned char *)&memsrc
,
1994 &fmtstr_complex_array
[32] );
1997 expected_length
= (4 + memsrc
.dim1
* (2 + memsrc
.dim2
)) * 4;
1998 if (StubMsg
.BufferLength
== 96)
2000 win_skip("Tests crash on Win9x, WinMe and NT4\n");
2003 ok(StubMsg
.BufferLength
>= expected_length
, "length %d\n", StubMsg
.BufferLength
);
2005 /*NdrGetBuffer(&_StubMsg, _StubMsg.BufferLength, NULL);*/
2006 StubMsg
.RpcMsg
->Buffer
= StubMsg
.BufferStart
= StubMsg
.Buffer
= HeapAlloc(GetProcessHeap(), 0, StubMsg
.BufferLength
);
2007 StubMsg
.BufferEnd
= StubMsg
.BufferStart
+ StubMsg
.BufferLength
;
2010 ptr
= NdrComplexStructMarshall( &StubMsg
, (unsigned char *)&memsrc
,
2011 &fmtstr_complex_array
[32] );
2013 ptr
= NdrSimpleStructMarshall( &StubMsg
, (unsigned char *)&memsrc
,
2014 &fmtstr_complex_array
[32] );
2017 ok(ptr
== NULL
, "ret %p\n", ptr
);
2018 ok((char*)StubMsg
.Buffer
== (char*)StubMsg
.BufferStart
+ expected_length
, "not at expected length\n");
2020 buf
= (DWORD
*)StubMsg
.BufferStart
;
2022 ok(*buf
== memsrc
.dim1
, "dim1 should have been %d instead of %08x\n", memsrc
.dim1
, *buf
);
2024 ok(*buf
== memsrc
.dim2
, "dim2 should have been %d instead of %08x\n", memsrc
.dim2
, *buf
);
2026 ok(*buf
!= 0, "pointer id should be non-zero\n");
2028 ok(*buf
== memsrc
.dim1
, "Conformance should have been %d instead of %08x\n", memsrc
.dim1
, *buf
);
2030 for(i
= 0; i
< memsrc
.dim1
; i
++)
2032 ok(*buf
!= 0, "pointer id[%d] should be non-zero\n", i
);
2035 for(i
= 0; i
< memsrc
.dim1
; i
++)
2037 ok(*buf
== memsrc
.dim2
, "Conformance should have been %d instead of %08x\n", memsrc
.dim2
, *buf
);
2039 for(j
= 0; j
< memsrc
.dim2
; j
++)
2041 ok(*buf
== i
* memsrc
.dim2
+ j
, "got %08x\n", *buf
);
2046 ok((void*)buf
== StubMsg
.Buffer
, "not at end of buffer\n");
2049 my_alloc_called
= 0;
2050 StubMsg
.IsClient
= 0;
2052 StubMsg
.Buffer
= StubMsg
.BufferStart
;
2054 ptr
= NdrComplexStructUnmarshall( &StubMsg
, (unsigned char **)&mem
, &fmtstr_complex_array
[32], 0);
2056 ptr
= NdrSimpleStructUnmarshall( &StubMsg
, (unsigned char **)&mem
, &fmtstr_complex_array
[32], 0);
2058 ok(ptr
== NULL
, "ret %p\n", ptr
);
2059 ok(mem
->dim1
== memsrc
.dim1
, "mem->dim1 wasn't unmarshalled correctly (%d)\n", mem
->dim1
);
2060 ok(mem
->dim2
== memsrc
.dim2
, "mem->dim2 wasn't unmarshalled correctly (%d)\n", mem
->dim2
);
2061 ok(mem
->array
[1][0] == memsrc
.dim2
, "mem->array[1][0] wasn't unmarshalled correctly (%d)\n", mem
->array
[1][0]);
2063 StubMsg
.Buffer
= StubMsg
.BufferStart
;
2065 NdrComplexStructFree( &StubMsg
, (unsigned char*)mem
, &fmtstr_complex_array
[32]);
2067 NdrSimpleStructFree( &StubMsg
, (unsigned char*)mem
, &fmtstr_complex_array
[32]);
2070 HeapFree(GetProcessHeap(), 0, StubMsg
.RpcMsg
->Buffer
);
2073 for(i
= 0; i
< memsrc
.dim1
; i
++)
2074 HeapFree(GetProcessHeap(), 0, memsrc
.array
[i
]);
2075 HeapFree(GetProcessHeap(), 0, memsrc
.array
);
2078 static void test_ndr_buffer(void)
2080 static unsigned char ncalrpc
[] = "ncalrpc";
2081 static unsigned char endpoint
[] = "winetest:test_ndr_buffer";
2082 RPC_MESSAGE RpcMessage
;
2083 MIDL_STUB_MESSAGE StubMsg
;
2084 MIDL_STUB_DESC StubDesc
= Object_StubDesc
;
2086 unsigned char *binding
;
2087 RPC_BINDING_HANDLE Handle
;
2089 ULONG prev_buffer_length
;
2090 BOOL old_buffer_valid_location
;
2092 StubDesc
.RpcInterfaceInformation
= (void *)&IFoo___RpcServerInterface
;
2094 status
= RpcServerUseProtseqEp(ncalrpc
, 20, endpoint
, NULL
);
2095 ok(RPC_S_OK
== status
, "RpcServerUseProtseqEp failed with status %u\n", status
);
2096 status
= RpcServerRegisterIf(IFoo_v0_0_s_ifspec
, NULL
, NULL
);
2097 ok(RPC_S_OK
== status
, "RpcServerRegisterIf failed with status %u\n", status
);
2098 status
= RpcServerListen(1, 20, TRUE
);
2099 ok(RPC_S_OK
== status
, "RpcServerListen failed with status %u\n", status
);
2100 if (status
!= RPC_S_OK
)
2102 /* Failed to create a server, running client tests is useless */
2106 status
= RpcStringBindingCompose(NULL
, ncalrpc
, NULL
, endpoint
, NULL
, &binding
);
2107 ok(status
== RPC_S_OK
, "RpcStringBindingCompose failed (%u)\n", status
);
2109 status
= RpcBindingFromStringBinding(binding
, &Handle
);
2110 ok(status
== RPC_S_OK
, "RpcBindingFromStringBinding failed (%u)\n", status
);
2111 RpcStringFree(&binding
);
2113 NdrClientInitializeNew(&RpcMessage
, &StubMsg
, &StubDesc
, 5);
2115 ret
= NdrGetBuffer(&StubMsg
, 10, Handle
);
2116 ok(ret
== StubMsg
.Buffer
, "NdrGetBuffer should have returned the same value as StubMsg.Buffer instead of %p\n", ret
);
2117 ok(RpcMessage
.Handle
!= NULL
, "RpcMessage.Handle should not have been NULL\n");
2118 ok(RpcMessage
.Buffer
!= NULL
, "RpcMessage.Buffer should not have been NULL\n");
2119 ok(RpcMessage
.BufferLength
== 10 ||
2120 broken(RpcMessage
.BufferLength
== 12), /* win2k */
2121 "RpcMessage.BufferLength should have been 10 instead of %d\n", RpcMessage
.BufferLength
);
2122 ok(RpcMessage
.RpcFlags
== 0, "RpcMessage.RpcFlags should have been 0x0 instead of 0x%x\n", RpcMessage
.RpcFlags
);
2123 ok(StubMsg
.Buffer
!= NULL
, "Buffer should not have been NULL\n");
2124 ok(!StubMsg
.BufferStart
, "BufferStart should have been NULL instead of %p\n", StubMsg
.BufferStart
);
2125 ok(!StubMsg
.BufferEnd
, "BufferEnd should have been NULL instead of %p\n", StubMsg
.BufferEnd
);
2127 ok(StubMsg
.BufferLength
== 0, "BufferLength should have left as 0 instead of being set to %d\n", StubMsg
.BufferLength
);
2128 old_buffer_valid_location
= !StubMsg
.fBufferValid
;
2129 if (old_buffer_valid_location
)
2130 ok(broken(StubMsg
.CorrDespIncrement
== TRUE
), "fBufferValid should have been TRUE instead of 0x%x\n", StubMsg
.CorrDespIncrement
);
2132 ok(StubMsg
.fBufferValid
, "fBufferValid should have been non-zero instead of 0x%x\n", StubMsg
.fBufferValid
);
2134 prev_buffer_length
= RpcMessage
.BufferLength
;
2135 StubMsg
.BufferLength
= 1;
2136 NdrFreeBuffer(&StubMsg
);
2137 ok(RpcMessage
.Handle
!= NULL
, "RpcMessage.Handle should not have been NULL\n");
2138 ok(RpcMessage
.Buffer
!= NULL
, "RpcMessage.Buffer should not have been NULL\n");
2139 ok(RpcMessage
.BufferLength
== prev_buffer_length
, "RpcMessage.BufferLength should have been left as %d instead of %d\n", prev_buffer_length
, RpcMessage
.BufferLength
);
2140 ok(StubMsg
.Buffer
!= NULL
, "Buffer should not have been NULL\n");
2141 ok(StubMsg
.BufferLength
== 1, "BufferLength should have left as 1 instead of being set to %d\n", StubMsg
.BufferLength
);
2142 if (old_buffer_valid_location
)
2143 ok(broken(StubMsg
.CorrDespIncrement
== FALSE
), "fBufferValid should have been FALSE instead of 0x%x\n", StubMsg
.CorrDespIncrement
);
2145 ok(!StubMsg
.fBufferValid
, "fBufferValid should have been FALSE instead of %d\n", StubMsg
.fBufferValid
);
2147 /* attempt double-free */
2148 NdrFreeBuffer(&StubMsg
);
2150 RpcBindingFree(&Handle
);
2152 status
= RpcServerUnregisterIf(NULL
, NULL
, FALSE
);
2153 ok(status
== RPC_S_OK
, "RpcServerUnregisterIf failed (%u)\n", status
);
2156 static void test_NdrMapCommAndFaultStatus(void)
2158 RPC_STATUS rpc_status
;
2159 MIDL_STUB_MESSAGE StubMsg
;
2160 RPC_MESSAGE RpcMessage
;
2162 NdrClientInitializeNew(&RpcMessage
, &StubMsg
, &Object_StubDesc
, 5);
2164 for (rpc_status
= 0; rpc_status
< 10000; rpc_status
++)
2167 ULONG comm_status
= 0;
2168 ULONG fault_status
= 0;
2169 ULONG expected_comm_status
= 0;
2170 ULONG expected_fault_status
= 0;
2171 status
= NdrMapCommAndFaultStatus(&StubMsg
, &comm_status
, &fault_status
, rpc_status
);
2172 ok(status
== RPC_S_OK
, "NdrMapCommAndFaultStatus failed with error %d\n", status
);
2175 case ERROR_INVALID_HANDLE
:
2176 case RPC_S_INVALID_BINDING
:
2177 case RPC_S_UNKNOWN_IF
:
2178 case RPC_S_SERVER_UNAVAILABLE
:
2179 case RPC_S_SERVER_TOO_BUSY
:
2180 case RPC_S_CALL_FAILED_DNE
:
2181 case RPC_S_PROTOCOL_ERROR
:
2182 case RPC_S_UNSUPPORTED_TRANS_SYN
:
2183 case RPC_S_UNSUPPORTED_TYPE
:
2184 case RPC_S_PROCNUM_OUT_OF_RANGE
:
2185 case EPT_S_NOT_REGISTERED
:
2186 case RPC_S_COMM_FAILURE
:
2187 expected_comm_status
= rpc_status
;
2190 expected_fault_status
= rpc_status
;
2192 ok(comm_status
== expected_comm_status
, "NdrMapCommAndFaultStatus should have mapped %d to comm status %d instead of %d\n",
2193 rpc_status
, expected_comm_status
, comm_status
);
2194 ok(fault_status
== expected_fault_status
, "NdrMapCommAndFaultStatus should have mapped %d to fault status %d instead of %d\n",
2195 rpc_status
, expected_fault_status
, fault_status
);
2199 static void test_NdrGetUserMarshalInfo(void)
2202 MIDL_STUB_MESSAGE stubmsg
;
2203 USER_MARSHAL_CB umcb
;
2204 NDR_USER_MARSHAL_INFO umi
;
2205 unsigned char buffer
[16];
2206 void *rpc_channel_buffer
= (void *)(ULONG_PTR
)0xcafebabe;
2207 RPC_MESSAGE rpc_msg
;
2208 RPC_STATUS (RPC_ENTRY
*pNdrGetUserMarshalInfo
)(ULONG
*,ULONG
,NDR_USER_MARSHAL_INFO
*);
2210 pNdrGetUserMarshalInfo
= (void *)GetProcAddress(GetModuleHandle("rpcrt4.dll"), "NdrGetUserMarshalInfo");
2211 if (!pNdrGetUserMarshalInfo
)
2213 skip("NdrGetUserMarshalInfo not exported\n");
2219 memset(&rpc_msg
, 0xcc, sizeof(rpc_msg
));
2220 rpc_msg
.Buffer
= buffer
;
2221 rpc_msg
.BufferLength
= 16;
2223 memset(&stubmsg
, 0xcc, sizeof(stubmsg
));
2224 stubmsg
.RpcMsg
= &rpc_msg
;
2225 stubmsg
.dwDestContext
= MSHCTX_INPROC
;
2226 stubmsg
.pvDestContext
= NULL
;
2227 stubmsg
.Buffer
= buffer
+ 15;
2228 stubmsg
.BufferLength
= 0;
2229 stubmsg
.BufferEnd
= NULL
;
2230 stubmsg
.pRpcChannelBuffer
= rpc_channel_buffer
;
2231 stubmsg
.StubDesc
= NULL
;
2232 stubmsg
.pfnAllocate
= my_alloc
;
2233 stubmsg
.pfnFree
= my_free
;
2235 memset(&umcb
, 0xcc, sizeof(umcb
));
2236 umcb
.Flags
= MAKELONG(MSHCTX_INPROC
, NDR_LOCAL_DATA_REPRESENTATION
);
2237 umcb
.pStubMsg
= &stubmsg
;
2238 umcb
.Signature
= USER_MARSHAL_CB_SIGNATURE
;
2239 umcb
.CBType
= USER_MARSHAL_CB_UNMARSHALL
;
2241 memset(&umi
, 0xaa, sizeof(umi
));
2243 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2244 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2245 ok( umi
.InformationLevel
== 1,
2246 "umi.InformationLevel was %u instead of 1\n",
2247 umi
.InformationLevel
);
2248 ok( U1(umi
).Level1
.Buffer
== buffer
+ 15,
2249 "umi.Level1.Buffer was %p instead of %p\n",
2250 U1(umi
).Level1
.Buffer
, buffer
);
2251 ok( U1(umi
).Level1
.BufferSize
== 1,
2252 "umi.Level1.BufferSize was %u instead of 1\n",
2253 U1(umi
).Level1
.BufferSize
);
2254 ok( U1(umi
).Level1
.pfnAllocate
== my_alloc
,
2255 "umi.Level1.pfnAllocate was %p instead of %p\n",
2256 U1(umi
).Level1
.pfnAllocate
, my_alloc
);
2257 ok( U1(umi
).Level1
.pfnFree
== my_free
,
2258 "umi.Level1.pfnFree was %p instead of %p\n",
2259 U1(umi
).Level1
.pfnFree
, my_free
);
2260 ok( U1(umi
).Level1
.pRpcChannelBuffer
== rpc_channel_buffer
,
2261 "umi.Level1.pRpcChannelBuffer was %p instead of %p\n",
2262 U1(umi
).Level1
.pRpcChannelBuffer
, rpc_channel_buffer
);
2266 rpc_msg
.Buffer
= buffer
;
2267 rpc_msg
.BufferLength
= 16;
2269 stubmsg
.Buffer
= buffer
;
2270 stubmsg
.BufferLength
= 16;
2271 stubmsg
.BufferEnd
= NULL
;
2273 umcb
.CBType
= USER_MARSHAL_CB_BUFFER_SIZE
;
2275 memset(&umi
, 0xaa, sizeof(umi
));
2277 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2278 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2279 ok( umi
.InformationLevel
== 1,
2280 "umi.InformationLevel was %u instead of 1\n",
2281 umi
.InformationLevel
);
2282 ok( U1(umi
).Level1
.Buffer
== NULL
,
2283 "umi.Level1.Buffer was %p instead of NULL\n",
2284 U1(umi
).Level1
.Buffer
);
2285 ok( U1(umi
).Level1
.BufferSize
== 0,
2286 "umi.Level1.BufferSize was %u instead of 0\n",
2287 U1(umi
).Level1
.BufferSize
);
2288 ok( U1(umi
).Level1
.pfnAllocate
== my_alloc
,
2289 "umi.Level1.pfnAllocate was %p instead of %p\n",
2290 U1(umi
).Level1
.pfnAllocate
, my_alloc
);
2291 ok( U1(umi
).Level1
.pfnFree
== my_free
,
2292 "umi.Level1.pfnFree was %p instead of %p\n",
2293 U1(umi
).Level1
.pfnFree
, my_free
);
2294 ok( U1(umi
).Level1
.pRpcChannelBuffer
== rpc_channel_buffer
,
2295 "umi.Level1.pRpcChannelBuffer was %p instead of %p\n",
2296 U1(umi
).Level1
.pRpcChannelBuffer
, rpc_channel_buffer
);
2300 rpc_msg
.Buffer
= buffer
;
2301 rpc_msg
.BufferLength
= 16;
2303 stubmsg
.Buffer
= buffer
+ 15;
2304 stubmsg
.BufferLength
= 0;
2305 stubmsg
.BufferEnd
= NULL
;
2307 umcb
.CBType
= USER_MARSHAL_CB_MARSHALL
;
2309 memset(&umi
, 0xaa, sizeof(umi
));
2311 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2312 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2313 ok( umi
.InformationLevel
== 1,
2314 "umi.InformationLevel was %u instead of 1\n",
2315 umi
.InformationLevel
);
2316 ok( U1(umi
).Level1
.Buffer
== buffer
+ 15,
2317 "umi.Level1.Buffer was %p instead of %p\n",
2318 U1(umi
).Level1
.Buffer
, buffer
);
2319 ok( U1(umi
).Level1
.BufferSize
== 1,
2320 "umi.Level1.BufferSize was %u instead of 1\n",
2321 U1(umi
).Level1
.BufferSize
);
2322 ok( U1(umi
).Level1
.pfnAllocate
== my_alloc
,
2323 "umi.Level1.pfnAllocate was %p instead of %p\n",
2324 U1(umi
).Level1
.pfnAllocate
, my_alloc
);
2325 ok( U1(umi
).Level1
.pfnFree
== my_free
,
2326 "umi.Level1.pfnFree was %p instead of %p\n",
2327 U1(umi
).Level1
.pfnFree
, my_free
);
2328 ok( U1(umi
).Level1
.pRpcChannelBuffer
== rpc_channel_buffer
,
2329 "umi.Level1.pRpcChannelBuffer was %p instead of %p\n",
2330 U1(umi
).Level1
.pRpcChannelBuffer
, rpc_channel_buffer
);
2334 rpc_msg
.Buffer
= buffer
;
2335 rpc_msg
.BufferLength
= 16;
2337 stubmsg
.Buffer
= buffer
;
2338 stubmsg
.BufferLength
= 16;
2339 stubmsg
.BufferEnd
= NULL
;
2341 umcb
.CBType
= USER_MARSHAL_CB_FREE
;
2343 memset(&umi
, 0xaa, sizeof(umi
));
2345 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2346 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2347 ok( umi
.InformationLevel
== 1,
2348 "umi.InformationLevel was %u instead of 1\n",
2349 umi
.InformationLevel
);
2350 ok( U1(umi
).Level1
.Buffer
== NULL
,
2351 "umi.Level1.Buffer was %p instead of NULL\n",
2352 U1(umi
).Level1
.Buffer
);
2353 ok( U1(umi
).Level1
.BufferSize
== 0,
2354 "umi.Level1.BufferSize was %u instead of 0\n",
2355 U1(umi
).Level1
.BufferSize
);
2356 ok( U1(umi
).Level1
.pfnAllocate
== my_alloc
,
2357 "umi.Level1.pfnAllocate was %p instead of %p\n",
2358 U1(umi
).Level1
.pfnAllocate
, my_alloc
);
2359 ok( U1(umi
).Level1
.pfnFree
== my_free
,
2360 "umi.Level1.pfnFree was %p instead of %p\n",
2361 U1(umi
).Level1
.pfnFree
, my_free
);
2362 ok( U1(umi
).Level1
.pRpcChannelBuffer
== rpc_channel_buffer
,
2363 "umi.Level1.pRpcChannelBuffer was %p instead of %p\n",
2364 U1(umi
).Level1
.pRpcChannelBuffer
, rpc_channel_buffer
);
2368 rpc_msg
.Buffer
= buffer
;
2369 rpc_msg
.BufferLength
= 15;
2371 stubmsg
.Buffer
= buffer
+ 15;
2372 stubmsg
.BufferLength
= 0;
2373 stubmsg
.BufferEnd
= NULL
;
2375 umcb
.CBType
= USER_MARSHAL_CB_MARSHALL
;
2377 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2378 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2379 ok( U1(umi
).Level1
.BufferSize
== 0,
2380 "umi.Level1.BufferSize was %u instead of 0\n",
2381 U1(umi
).Level1
.BufferSize
);
2383 /* error conditions */
2385 rpc_msg
.BufferLength
= 14;
2386 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2387 ok(status
== ERROR_INVALID_USER_BUFFER
,
2388 "NdrGetUserMarshalInfo should have failed with ERROR_INVALID_USER_BUFFER instead of %d\n", status
);
2390 rpc_msg
.BufferLength
= 15;
2391 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 9999, &umi
);
2392 ok(status
== RPC_S_INVALID_ARG
,
2393 "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status
);
2396 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2397 ok(status
== RPC_S_OK
, "NdrGetUserMarshalInfo failed with error %d\n", status
);
2399 umcb
.CBType
= USER_MARSHAL_CB_MARSHALL
;
2401 status
= pNdrGetUserMarshalInfo(&umcb
.Flags
, 1, &umi
);
2402 ok(status
== RPC_S_INVALID_ARG
,
2403 "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status
);
2406 START_TEST( ndr_marshall
)
2408 determine_pointer_marshalling_style();
2410 test_ndr_simple_type();
2411 test_simple_types();
2412 test_nontrivial_pointer_types();
2413 test_simple_struct();
2414 test_fullpointer_xlat();
2417 test_ndr_allocate();
2418 test_conformant_array();
2419 test_conformant_string();
2420 test_nonconformant_string();
2421 test_conf_complex_struct();
2422 test_conf_complex_array();
2424 test_NdrMapCommAndFaultStatus();
2425 test_NdrGetUserMarshalInfo();