2 * User Marshaling Tests
4 * Copyright 2004-2006 Robert Shearman for CodeWeavers
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
30 #include "wine/test.h"
32 ULONG __RPC_USER
HMETAFILE_UserSize(ULONG
*, unsigned long, HMETAFILE
*);
33 unsigned char * __RPC_USER
HMETAFILE_UserMarshal(ULONG
*, unsigned char *, HMETAFILE
*);
34 unsigned char * __RPC_USER
HMETAFILE_UserUnmarshal(ULONG
*, unsigned char *, HMETAFILE
*);
35 void __RPC_USER
HMETAFILE_UserFree(ULONG
*, HMETAFILE
*);
37 ULONG __RPC_USER
HENHMETAFILE_UserSize(ULONG
*, ULONG
, HENHMETAFILE
*);
38 unsigned char * __RPC_USER
HENHMETAFILE_UserMarshal (ULONG
*, unsigned char *, HENHMETAFILE
*);
39 unsigned char * __RPC_USER
HENHMETAFILE_UserUnmarshal(ULONG
*, unsigned char *, HENHMETAFILE
*);
40 void __RPC_USER
HENHMETAFILE_UserFree(ULONG
*, HENHMETAFILE
*);
42 ULONG __RPC_USER
HMETAFILEPICT_UserSize(ULONG
*, ULONG
, HMETAFILEPICT
*);
43 unsigned char * __RPC_USER
HMETAFILEPICT_UserMarshal (ULONG
*, unsigned char *, HMETAFILEPICT
*);
44 unsigned char * __RPC_USER
HMETAFILEPICT_UserUnmarshal(ULONG
*, unsigned char *, HMETAFILEPICT
*);
45 void __RPC_USER
HMETAFILEPICT_UserFree(ULONG
*, HMETAFILEPICT
*);
48 static const char cf_marshaled
[] =
60 static void test_marshal_CLIPFORMAT(void)
62 unsigned char *buffer
;
64 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
65 wireCLIPFORMAT wirecf
;
66 CLIPFORMAT cf
= RegisterClipboardFormatA("MyFormat");
69 size
= CLIPFORMAT_UserSize(&flags
, 0, &cf
);
70 ok(size
== sizeof(*wirecf
) + sizeof(cf_marshaled
), "Wrong size %d\n", size
);
72 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
73 CLIPFORMAT_UserMarshal(&flags
, buffer
, &cf
);
74 wirecf
= (wireCLIPFORMAT
)buffer
;
75 ok(wirecf
->fContext
== WDT_REMOTE_CALL
, "Context should be WDT_REMOTE_CALL instead of 0x%08lx\n", wirecf
->fContext
);
76 ok(wirecf
->u
.dwValue
== cf
, "Marshaled value should be 0x%04x instead of 0x%04x\n", cf
, wirecf
->u
.dwValue
);
77 ok(!memcmp(wirecf
+1, cf_marshaled
, sizeof(cf_marshaled
)), "Marshaled data differs\n");
79 CLIPFORMAT_UserUnmarshal(&flags
, buffer
, &cf2
);
80 ok(cf
== cf2
, "Didn't unmarshal properly\n");
81 HeapFree(GetProcessHeap(), 0, buffer
);
83 CLIPFORMAT_UserFree(&flags
, &cf2
);
86 static void test_marshal_HWND(void)
88 unsigned char *buffer
;
90 ULONG flags
= MAKELONG(MSHCTX_LOCAL
, NDR_LOCAL_DATA_REPRESENTATION
);
91 HWND hwnd
= GetDesktopWindow();
95 size
= HWND_UserSize(&flags
, 0, &hwnd
);
96 ok(size
== sizeof(*wirehwnd
), "Wrong size %d\n", size
);
98 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
99 HWND_UserMarshal(&flags
, buffer
, &hwnd
);
100 wirehwnd
= (wireHWND
)buffer
;
101 ok(wirehwnd
->fContext
== WDT_INPROC_CALL
, "Context should be WDT_INPROC_CALL instead of 0x%08lx\n", wirehwnd
->fContext
);
102 ok(wirehwnd
->u
.hInproc
== (LONG_PTR
)hwnd
, "Marshaled value should be %p instead of %p\n", hwnd
, (HANDLE
)wirehwnd
->u
.hRemote
);
104 HWND_UserUnmarshal(&flags
, buffer
, &hwnd2
);
105 ok(hwnd
== hwnd2
, "Didn't unmarshal properly\n");
106 HeapFree(GetProcessHeap(), 0, buffer
);
108 HWND_UserFree(&flags
, &hwnd2
);
111 static void test_marshal_HGLOBAL(void)
113 unsigned char *buffer
;
115 ULONG flags
= MAKELONG(MSHCTX_LOCAL
, NDR_LOCAL_DATA_REPRESENTATION
);
118 unsigned char *wirehglobal
;
122 flags
= MAKELONG(MSHCTX_LOCAL
, NDR_LOCAL_DATA_REPRESENTATION
);
123 size
= HGLOBAL_UserSize(&flags
, 0, &hglobal
);
124 /* native is poorly programmed and allocates 4 bytes more than it needs to
125 * here - Wine doesn't have to emulate that */
126 ok((size
== 8) || (size
== 12), "Size should be 12, instead of %d\n", size
);
127 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
128 HGLOBAL_UserMarshal(&flags
, buffer
, &hglobal
);
129 wirehglobal
= buffer
;
130 ok(*(ULONG
*)wirehglobal
== WDT_REMOTE_CALL
, "Context should be WDT_REMOTE_CALL instead of 0x%08x\n", *(ULONG
*)wirehglobal
);
131 wirehglobal
+= sizeof(ULONG
);
132 ok(*(ULONG
*)wirehglobal
== (ULONG
)hglobal
, "buffer+4 should be HGLOBAL\n");
133 HGLOBAL_UserUnmarshal(&flags
, buffer
, &hglobal2
);
134 ok(hglobal2
== hglobal
, "Didn't unmarshal properly\n");
135 HeapFree(GetProcessHeap(), 0, buffer
);
136 HGLOBAL_UserFree(&flags
, &hglobal2
);
138 hglobal
= GlobalAlloc(0, 4);
139 buffer
= GlobalLock(hglobal
);
140 for (i
= 0; i
< 4; i
++)
142 GlobalUnlock(hglobal
);
143 flags
= MAKELONG(MSHCTX_LOCAL
, NDR_LOCAL_DATA_REPRESENTATION
);
144 size
= HGLOBAL_UserSize(&flags
, 0, &hglobal
);
145 /* native is poorly programmed and allocates 4 bytes more than it needs to
146 * here - Wine doesn't have to emulate that */
147 ok((size
== 24) || (size
== 28), "Size should be 24 or 28, instead of %d\n", size
);
148 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
149 HGLOBAL_UserMarshal(&flags
, buffer
, &hglobal
);
150 wirehglobal
= buffer
;
151 ok(*(ULONG
*)wirehglobal
== WDT_REMOTE_CALL
, "Context should be WDT_REMOTE_CALL instead of 0x%08x\n", *(ULONG
*)wirehglobal
);
152 wirehglobal
+= sizeof(ULONG
);
153 ok(*(ULONG
*)wirehglobal
== (ULONG
)hglobal
, "buffer+0x4 should be HGLOBAL\n");
154 wirehglobal
+= sizeof(ULONG
);
155 ok(*(ULONG
*)wirehglobal
== 4, "buffer+0x8 should be size of HGLOBAL\n");
156 wirehglobal
+= sizeof(ULONG
);
157 ok(*(ULONG
*)wirehglobal
== (ULONG
)hglobal
, "buffer+0xc should be HGLOBAL\n");
158 wirehglobal
+= sizeof(ULONG
);
159 ok(*(ULONG
*)wirehglobal
== 4, "buffer+0x10 should be size of HGLOBAL\n");
160 wirehglobal
+= sizeof(ULONG
);
161 for (i
= 0; i
< 4; i
++)
162 ok(wirehglobal
[i
] == i
, "buffer+0x%x should be %d\n", 0x10 + i
, i
);
163 HGLOBAL_UserUnmarshal(&flags
, buffer
, &hglobal2
);
164 ok(hglobal2
!= NULL
, "Didn't unmarshal properly\n");
165 HeapFree(GetProcessHeap(), 0, buffer
);
166 HGLOBAL_UserFree(&flags
, &hglobal2
);
170 static HENHMETAFILE
create_emf(void)
172 const RECT rect
= {0, 0, 100, 100};
173 HDC hdc
= CreateEnhMetaFile(NULL
, NULL
, &rect
, "HENHMETAFILE Marshaling Test\0Test\0\0");
174 ExtTextOut(hdc
, 0, 0, ETO_OPAQUE
, &rect
, "Test String", strlen("Test String"), NULL
);
175 return CloseEnhMetaFile(hdc
);
178 static void test_marshal_HENHMETAFILE(void)
180 unsigned char *buffer
;
182 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
184 HENHMETAFILE hemf2
= NULL
;
185 unsigned char *wirehemf
;
189 size
= HENHMETAFILE_UserSize(&flags
, 0, &hemf
);
190 ok(size
> 20, "size should be at least 20 bytes, not %d\n", size
);
191 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
192 HENHMETAFILE_UserMarshal(&flags
, buffer
, &hemf
);
194 ok(*(DWORD
*)wirehemf
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehemf
);
195 wirehemf
+= sizeof(DWORD
);
196 ok(*(DWORD
*)wirehemf
== (DWORD
)(DWORD_PTR
)hemf
, "wirestgm + 0x4 should be hemf instead of 0x%08x\n", *(DWORD
*)wirehemf
);
197 wirehemf
+= sizeof(DWORD
);
198 ok(*(DWORD
*)wirehemf
== (size
- 0x10), "wirestgm + 0x8 should be size - 0x10 instead of 0x%08x\n", *(DWORD
*)wirehemf
);
199 wirehemf
+= sizeof(DWORD
);
200 ok(*(DWORD
*)wirehemf
== (size
- 0x10), "wirestgm + 0xc should be size - 0x10 instead of 0x%08x\n", *(DWORD
*)wirehemf
);
201 wirehemf
+= sizeof(DWORD
);
202 ok(*(DWORD
*)wirehemf
== EMR_HEADER
, "wirestgm + 0x10 should be EMR_HEADER instead of %d\n", *(DWORD
*)wirehemf
);
203 wirehemf
+= sizeof(DWORD
);
204 /* ... rest of data not tested - refer to tests for GetEnhMetaFileBits
207 HENHMETAFILE_UserUnmarshal(&flags
, buffer
, &hemf2
);
208 ok(hemf2
!= NULL
, "HENHMETAFILE didn't unmarshal\n");
209 HeapFree(GetProcessHeap(), 0, buffer
);
210 HENHMETAFILE_UserFree(&flags
, &hemf2
);
211 DeleteEnhMetaFile(hemf
);
216 size
= HENHMETAFILE_UserSize(&flags
, 0, &hemf
);
217 ok(size
== 8, "size should be 8 bytes, not %d\n", size
);
218 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
219 HENHMETAFILE_UserMarshal(&flags
, buffer
, &hemf
);
221 ok(*(DWORD
*)wirehemf
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehemf
);
222 wirehemf
+= sizeof(DWORD
);
223 ok(*(DWORD
*)wirehemf
== (DWORD
)(DWORD_PTR
)hemf
, "wirestgm + 0x4 should be hemf instead of 0x%08x\n", *(DWORD
*)wirehemf
);
224 wirehemf
+= sizeof(DWORD
);
226 HENHMETAFILE_UserUnmarshal(&flags
, buffer
, &hemf2
);
227 ok(hemf2
== NULL
, "NULL HENHMETAFILE didn't unmarshal\n");
228 HeapFree(GetProcessHeap(), 0, buffer
);
229 HENHMETAFILE_UserFree(&flags
, &hemf2
);
232 static HMETAFILE
create_mf(void)
234 RECT rect
= {0, 0, 100, 100};
235 HDC hdc
= CreateMetaFile(NULL
);
236 ExtTextOut(hdc
, 0, 0, ETO_OPAQUE
, &rect
, "Test String", strlen("Test String"), NULL
);
237 return CloseMetaFile(hdc
);
240 static void test_marshal_HMETAFILE(void)
242 unsigned char *buffer
;
244 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
246 HMETAFILE hmf2
= NULL
;
247 unsigned char *wirehmf
;
251 size
= HMETAFILE_UserSize(&flags
, 0, &hmf
);
252 ok(size
> 20, "size should be at least 20 bytes, not %d\n", size
);
253 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
254 HMETAFILE_UserMarshal(&flags
, buffer
, &hmf
);
256 ok(*(DWORD
*)wirehmf
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehmf
);
257 wirehmf
+= sizeof(DWORD
);
258 ok(*(DWORD
*)wirehmf
== (DWORD
)(DWORD_PTR
)hmf
, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD
*)wirehmf
);
259 wirehmf
+= sizeof(DWORD
);
260 ok(*(DWORD
*)wirehmf
== (size
- 0x10), "wirestgm + 0x8 should be size - 0x10 instead of 0x%08x\n", *(DWORD
*)wirehmf
);
261 wirehmf
+= sizeof(DWORD
);
262 ok(*(DWORD
*)wirehmf
== (size
- 0x10), "wirestgm + 0xc should be size - 0x10 instead of 0x%08x\n", *(DWORD
*)wirehmf
);
263 wirehmf
+= sizeof(DWORD
);
264 ok(*(WORD
*)wirehmf
== 1, "wirestgm + 0x10 should be 1 instead of 0x%08x\n", *(DWORD
*)wirehmf
);
265 wirehmf
+= sizeof(DWORD
);
266 /* ... rest of data not tested - refer to tests for GetMetaFileBits
269 HMETAFILE_UserUnmarshal(&flags
, buffer
, &hmf2
);
270 ok(hmf2
!= NULL
, "HMETAFILE didn't unmarshal\n");
271 HeapFree(GetProcessHeap(), 0, buffer
);
272 HMETAFILE_UserFree(&flags
, &hmf2
);
278 size
= HMETAFILE_UserSize(&flags
, 0, &hmf
);
279 ok(size
== 8, "size should be 8 bytes, not %d\n", size
);
280 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
281 HMETAFILE_UserMarshal(&flags
, buffer
, &hmf
);
283 ok(*(DWORD
*)wirehmf
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehmf
);
284 wirehmf
+= sizeof(DWORD
);
285 ok(*(DWORD
*)wirehmf
== (DWORD
)(DWORD_PTR
)hmf
, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD
*)wirehmf
);
286 wirehmf
+= sizeof(DWORD
);
288 HMETAFILE_UserUnmarshal(&flags
, buffer
, &hmf2
);
289 ok(hmf2
== NULL
, "NULL HMETAFILE didn't unmarshal\n");
290 HeapFree(GetProcessHeap(), 0, buffer
);
291 HMETAFILE_UserFree(&flags
, &hmf2
);
294 #define USER_MARSHAL_PTR_PREFIX \
295 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
296 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
298 static void test_marshal_HMETAFILEPICT(void)
300 unsigned char *buffer
, *buffer_end
;
302 ULONG flags
= MAKELONG(MSHCTX_DIFFERENTMACHINE
, NDR_LOCAL_DATA_REPRESENTATION
);
304 HMETAFILEPICT hmfp2
= NULL
;
306 unsigned char *wirehmfp
;
308 hmfp
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(*pmfp
));
309 pmfp
= GlobalLock(hmfp
);
310 pmfp
->mm
= MM_ISOTROPIC
;
313 pmfp
->hMF
= create_mf();
316 size
= HMETAFILEPICT_UserSize(&flags
, 0, &hmfp
);
317 ok(size
> 20, "size should be at least 20 bytes, not %d\n", size
);
318 trace("size is %d\n", size
);
319 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
320 buffer_end
= HMETAFILEPICT_UserMarshal(&flags
, buffer
, &hmfp
);
322 ok(*(DWORD
*)wirehmfp
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
323 wirehmfp
+= sizeof(DWORD
);
324 ok(*(DWORD
*)wirehmfp
== (DWORD
)(DWORD_PTR
)hmfp
, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
325 wirehmfp
+= sizeof(DWORD
);
326 ok(*(DWORD
*)wirehmfp
== MM_ISOTROPIC
, "wirestgm + 0x8 should be MM_ISOTROPIC instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
327 wirehmfp
+= sizeof(DWORD
);
328 ok(*(DWORD
*)wirehmfp
== 1, "wirestgm + 0xc should be 1 instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
329 wirehmfp
+= sizeof(DWORD
);
330 ok(*(DWORD
*)wirehmfp
== 2, "wirestgm + 0x10 should be 2 instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
331 wirehmfp
+= sizeof(DWORD
);
332 ok(*(DWORD
*)wirehmfp
== USER_MARSHAL_PTR_PREFIX
, "wirestgm + 0x14 should be \"User\" instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
333 wirehmfp
+= sizeof(DWORD
);
334 ok(*(DWORD
*)wirehmfp
== WDT_REMOTE_CALL
, "wirestgm + 0x18 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
335 wirehmfp
+= sizeof(DWORD
);
336 pmfp
= GlobalLock(hmfp
);
337 ok(*(DWORD
*)wirehmfp
== (DWORD
)(DWORD_PTR
)pmfp
->hMF
, "wirestgm + 0x1c should be pmfp->hMF instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
339 wirehmfp
+= sizeof(DWORD
);
340 /* Note use (buffer_end - buffer) instead of size here, because size is an
341 * overestimate with native */
342 ok(*(DWORD
*)wirehmfp
== (buffer_end
- buffer
- 0x28), "wirestgm + 0x20 should be size - 0x34 instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
343 wirehmfp
+= sizeof(DWORD
);
344 ok(*(DWORD
*)wirehmfp
== (buffer_end
- buffer
- 0x28), "wirestgm + 0x24 should be size - 0x34 instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
345 wirehmfp
+= sizeof(DWORD
);
346 ok(*(WORD
*)wirehmfp
== 1, "wirehmfp + 0x28 should be 1 instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
347 wirehmfp
+= sizeof(DWORD
);
348 /* ... rest of data not tested - refer to tests for GetMetaFileBits
351 HMETAFILEPICT_UserUnmarshal(&flags
, buffer
, &hmfp2
);
352 ok(hmfp2
!= NULL
, "HMETAFILEPICT didn't unmarshal\n");
353 HeapFree(GetProcessHeap(), 0, buffer
);
354 HMETAFILEPICT_UserFree(&flags
, &hmfp2
);
355 pmfp
= GlobalLock(hmfp
);
356 DeleteMetaFile(pmfp
->hMF
);
363 size
= HMETAFILEPICT_UserSize(&flags
, 0, &hmfp
);
364 ok(size
== 8, "size should be 8 bytes, not %d\n", size
);
365 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
366 HMETAFILEPICT_UserMarshal(&flags
, buffer
, &hmfp
);
368 ok(*(DWORD
*)wirehmfp
== WDT_REMOTE_CALL
, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
369 wirehmfp
+= sizeof(DWORD
);
370 ok(*(DWORD
*)wirehmfp
== (DWORD
)(DWORD_PTR
)hmfp
, "wirestgm + 0x4 should be hmf instead of 0x%08x\n", *(DWORD
*)wirehmfp
);
371 wirehmfp
+= sizeof(DWORD
);
374 HMETAFILEPICT_UserUnmarshal(&flags
, buffer
, &hmfp2
);
375 ok(hmfp2
== NULL
, "NULL HMETAFILE didn't unmarshal\n");
376 HeapFree(GetProcessHeap(), 0, buffer
);
377 HMETAFILEPICT_UserFree(&flags
, &hmfp2
);
380 static HRESULT WINAPI
Test_IUnknown_QueryInterface(
385 if (ppvObj
== NULL
) return E_POINTER
;
387 if (IsEqualGUID(riid
, &IID_IUnknown
))
389 *ppvObj
= (LPVOID
)iface
;
390 IUnknown_AddRef(iface
);
395 return E_NOINTERFACE
;
398 static ULONG WINAPI
Test_IUnknown_AddRef(LPUNKNOWN iface
)
400 return 2; /* non-heap-based object */
403 static ULONG WINAPI
Test_IUnknown_Release(LPUNKNOWN iface
)
405 return 1; /* non-heap-based object */
408 static const IUnknownVtbl TestUnknown_Vtbl
=
410 Test_IUnknown_QueryInterface
,
411 Test_IUnknown_AddRef
,
412 Test_IUnknown_Release
,
415 static IUnknown Test_Unknown
= { &TestUnknown_Vtbl
};
417 ULONG __RPC_USER
WdtpInterfacePointer_UserSize(ULONG
*, ULONG
, ULONG
, IUnknown
*, REFIID
);
418 unsigned char * __RPC_USER
WdtpInterfacePointer_UserMarshal(ULONG
*, ULONG
, unsigned char *, IUnknown
*, REFIID
);
419 unsigned char * __RPC_USER
WdtpInterfacePointer_UserUnmarshal(ULONG
*, unsigned char *, IUnknown
**, REFIID
);
420 void __RPC_USER
WdtpInterfacePointer_UserFree(IUnknown
*);
422 static void test_marshal_WdtpInterfacePointer(void)
424 unsigned char *buffer
, *buffer_end
;
426 MIDL_STUB_MESSAGE stubmsg
;
427 USER_MARSHAL_CB umcb
;
430 unsigned char *wireip
;
433 memset(&stubmsg
, 0xcc, sizeof(stubmsg
));
434 stubmsg
.dwDestContext
= MSHCTX_INPROC
;
435 stubmsg
.pvDestContext
= NULL
;
437 memset(&umcb
, 0xcc, sizeof(umcb
));
438 umcb
.Flags
= MAKELONG(MSHCTX_INPROC
, NDR_LOCAL_DATA_REPRESENTATION
);
439 umcb
.pStubMsg
= &stubmsg
;
441 /* shows that the WdtpInterfacePointer functions don't marshal anything for
442 * NULL pointers, so code using these functions must handle that case
445 size
= WdtpInterfacePointer_UserSize(&umcb
.Flags
, umcb
.Flags
, 0, unk
, &IID_IUnknown
);
446 ok(size
== 0, "size should be 0 bytes, not %d\n", size
);
447 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
448 buffer_end
= WdtpInterfacePointer_UserMarshal(&umcb
.Flags
, umcb
.Flags
, buffer
, unk
, &IID_IUnknown
);
450 HeapFree(GetProcessHeap(), 0, buffer
);
453 size
= WdtpInterfacePointer_UserSize(&umcb
.Flags
, umcb
.Flags
, 0, unk
, &IID_IUnknown
);
455 ok(size
> 28, "size should be > 28 bytes, not %d\n", size
);
456 trace("WdtpInterfacePointer_UserSize returned %d\n", size
);
457 buffer
= HeapAlloc(GetProcessHeap(), 0, size
);
458 buffer_end
= WdtpInterfacePointer_UserMarshal(&umcb
.Flags
, umcb
.Flags
, buffer
, unk
, &IID_IUnknown
);
462 ok(*(DWORD
*)wireip
== 0x44, "wireip + 0x0 should be 0x44 instead of 0x%08x\n", *(DWORD
*)wireip
);
463 wireip
+= sizeof(DWORD
);
464 ok(*(DWORD
*)wireip
== 0x44, "wireip + 0x4 should be 0x44 instead of 0x%08x\n", *(DWORD
*)wireip
);
465 wireip
+= sizeof(DWORD
);
466 ok(*(DWORD
*)wireip
== 0x574f454d /* 'MEOW' */, "wireip + 0x8 should be 0x574f454d instead of 0x%08x\n", *(DWORD
*)wireip
);
467 wireip
+= sizeof(DWORD
);
468 ok(*(DWORD
*)wireip
== 0x1, "wireip + 0xc should be 0x1 instead of 0x%08x\n", *(DWORD
*)wireip
);
469 wireip
+= sizeof(DWORD
);
470 iid
= (const IID
*)wireip
;
471 ok(IsEqualIID(iid
, &IID_IUnknown
),
472 "wireip + 0x10 should be IID_IUnknown instead of {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n",
473 iid
->Data1
, iid
->Data2
, iid
->Data3
,
474 iid
->Data4
[0], iid
->Data4
[1], iid
->Data4
[2], iid
->Data4
[3],
475 iid
->Data4
[4], iid
->Data4
[5], iid
->Data4
[6], iid
->Data4
[7]);
476 wireip
+= sizeof(IID
);
477 ok(*(DWORD
*)wireip
== 0, "wireip + 0x1c should be 0 instead of 0x%08x\n", *(DWORD
*)wireip
);
478 wireip
+= sizeof(DWORD
);
479 ok(*(DWORD
*)wireip
== 5, "wireip + 0x20 should be 5 instead of %d\n", *(DWORD
*)wireip
);
480 wireip
+= sizeof(DWORD
);
481 /* the rest is dynamic so can't really be tested */
485 WdtpInterfacePointer_UserUnmarshal(&umcb
.Flags
, buffer
, &unk2
, &IID_IUnknown
);
487 ok(unk2
!= NULL
, "IUnknown object didn't unmarshal properly\n");
488 HeapFree(GetProcessHeap(), 0, buffer
);
489 WdtpInterfacePointer_UserFree(unk2
);
492 START_TEST(usrmarshal
)
496 test_marshal_CLIPFORMAT();
498 test_marshal_HGLOBAL();
499 test_marshal_HENHMETAFILE();
500 test_marshal_HMETAFILE();
501 test_marshal_HMETAFILEPICT();
502 test_marshal_WdtpInterfacePointer();