msctf: Use FAILED instead of !SUCCEDED.
[wine] / dlls / ole32 / usrmarshal.c
1 /*
2  * Miscellaneous Marshaling Routines
3  *
4  * Copyright 2005 Robert Shearman
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <string.h>
24
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winerror.h"
34
35 #include "ole2.h"
36 #include "oleauto.h"
37 #include "rpcproxy.h"
38
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
43
44 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
45 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
46 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
47 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
48
49 #define USER_MARSHAL_PTR_PREFIX \
50   ( (DWORD)'U'         | ( (DWORD)'s' << 8 ) | \
51   ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
52
53 static const char* debugstr_user_flags(ULONG *pFlags)
54 {
55     char buf[12];
56     const char* loword;
57     switch (LOWORD(*pFlags))
58     {
59     case MSHCTX_LOCAL:
60         loword="MSHCTX_LOCAL";
61         break;
62     case MSHCTX_NOSHAREDMEM:
63         loword="MSHCTX_NOSHAREDMEM";
64         break;
65     case MSHCTX_DIFFERENTMACHINE:
66         loword="MSHCTX_DIFFERENTMACHINE";
67         break;
68     case MSHCTX_INPROC:
69         loword="MSHCTX_INPROC";
70         break;
71     default:
72         sprintf(buf, "%d", LOWORD(*pFlags));
73         loword=buf;
74     }
75
76     if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
77         return wine_dbg_sprintf("MAKELONG(NDR_LOCAL_REPRESENTATION, %s)", loword);
78     else
79         return wine_dbg_sprintf("MAKELONG(0x%04x, %s)", HIWORD(*pFlags), loword);
80 }
81
82 /******************************************************************************
83  *           CLIPFORMAT_UserSize [OLE32.@]
84  *
85  * Calculates the buffer size required to marshal a clip format.
86  *
87  * PARAMS
88  *  pFlags       [I] Flags. See notes.
89  *  StartingSize [I] Starting size of the buffer. This value is added on to
90  *                   the buffer size required for the clip format.
91  *  pCF          [I] Clip format to size.
92  *
93  * RETURNS
94  *  The buffer size required to marshal a clip format plus the starting size.
95  *
96  * NOTES
97  *  Even though the function is documented to take a pointer to an unsigned
98  *  long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
99  *  the first parameter is an unsigned long.
100  *  This function is only intended to be called by the RPC runtime.
101  */
102 ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORMAT *pCF)
103 {
104     ULONG size = StartingSize;
105
106     TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF);
107
108     size += 8;
109
110     /* only need to marshal the name if it is not a pre-defined type and
111      * we are going remote */
112     if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
113     {
114         WCHAR format[255];
115         INT ret;
116         size += 3 * sizeof(UINT);
117         /* urg! this function is badly designed because it won't tell us how
118          * much space is needed without doing a dummy run of storing the
119          * name into a buffer */
120         ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
121         if (!ret)
122             RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
123         size += (ret + 1) * sizeof(WCHAR);
124     }
125     return size;
126 }
127
128 /******************************************************************************
129  *           CLIPFORMAT_UserMarshal [OLE32.@]
130  *
131  * Marshals a clip format into a buffer.
132  *
133  * PARAMS
134  *  pFlags  [I] Flags. See notes.
135  *  pBuffer [I] Buffer to marshal the clip format into.
136  *  pCF     [I] Clip format to marshal.
137  *
138  * RETURNS
139  *  The end of the marshaled data in the buffer.
140  *
141  * NOTES
142  *  Even though the function is documented to take a pointer to an unsigned
143  *  long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
144  *  the first parameter is an unsigned long.
145  *  This function is only intended to be called by the RPC runtime.
146  */
147 unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
148 {
149     TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
150
151     /* only need to marshal the name if it is not a pre-defined type and
152      * we are going remote */
153     if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
154     {
155         WCHAR format[255];
156         UINT len;
157
158         *(DWORD *)pBuffer = WDT_REMOTE_CALL;
159         pBuffer += 4;
160         *(DWORD *)pBuffer = *pCF;
161         pBuffer += 4;
162
163         len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
164         if (!len)
165             RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
166         len += 1;
167         *(UINT *)pBuffer = len;
168         pBuffer += sizeof(UINT);
169         *(UINT *)pBuffer = 0;
170         pBuffer += sizeof(UINT);
171         *(UINT *)pBuffer = len;
172         pBuffer += sizeof(UINT);
173         TRACE("marshaling format name %s\n", debugstr_wn(format, len-1));
174         lstrcpynW((LPWSTR)pBuffer, format, len);
175         pBuffer += len * sizeof(WCHAR);
176         *(WCHAR *)pBuffer = '\0';
177         pBuffer += sizeof(WCHAR);
178     }
179     else
180     {
181         *(DWORD *)pBuffer = WDT_INPROC_CALL;
182         pBuffer += 4;
183         *(DWORD *)pBuffer = *pCF;
184         pBuffer += 4;
185     }
186
187     return pBuffer;
188 }
189
190 /******************************************************************************
191  *           CLIPFORMAT_UserUnmarshal [OLE32.@]
192  *
193  * Unmarshals a clip format from a buffer.
194  *
195  * PARAMS
196  *  pFlags  [I] Flags. See notes.
197  *  pBuffer [I] Buffer to marshal the clip format from.
198  *  pCF     [O] Address that receive the unmarshaled clip format.
199  *
200  * RETURNS
201  *  The end of the marshaled data in the buffer.
202  *
203  * NOTES
204  *  Even though the function is documented to take a pointer to an unsigned
205  *  long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
206  *  the first parameter is an unsigned long.
207  *  This function is only intended to be called by the RPC runtime.
208  */
209 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
210 {
211     LONG fContext;
212
213     TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
214
215     fContext = *(DWORD *)pBuffer;
216     pBuffer += 4;
217
218     if (fContext == WDT_INPROC_CALL)
219     {
220         *pCF = *(CLIPFORMAT *)pBuffer;
221         pBuffer += 4;
222     }
223     else if (fContext == WDT_REMOTE_CALL)
224     {
225         CLIPFORMAT cf;
226         UINT len;
227
228         /* pointer ID for registered clip format string */
229         if (*(DWORD *)pBuffer == 0)
230             RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
231         pBuffer += 4;
232
233         len = *(UINT *)pBuffer;
234         pBuffer += sizeof(UINT);
235         if (*(UINT *)pBuffer != 0)
236             RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
237         pBuffer += sizeof(UINT);
238         if (*(UINT *)pBuffer != len)
239             RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
240         pBuffer += sizeof(UINT);
241         if (((WCHAR *)pBuffer)[len] != '\0')
242             RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
243         TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
244         cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
245         pBuffer += (len + 1) * sizeof(WCHAR);
246         if (!cf)
247             RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
248         *pCF = cf;
249     }
250     else
251         /* code not really appropriate, but nearest I can find */
252         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
253     return pBuffer;
254 }
255
256 /******************************************************************************
257  *           CLIPFORMAT_UserFree [OLE32.@]
258  *
259  * Frees an unmarshaled clip format.
260  *
261  * PARAMS
262  *  pFlags  [I] Flags. See notes.
263  *  pCF     [I] Clip format to free.
264  *
265  * RETURNS
266  *  The end of the marshaled data in the buffer.
267  *
268  * NOTES
269  *  Even though the function is documented to take a pointer to an unsigned
270  *  long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
271  *  structure, of which the first parameter is an unsigned long.
272  *  This function is only intended to be called by the RPC runtime.
273  */
274 void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
275 {
276     /* there is no inverse of the RegisterClipboardFormat function,
277      * so nothing to do */
278 }
279
280 static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
281 {
282     if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
283     {
284         ERR("can't remote a local handle\n");
285         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
286         return StartingSize;
287     }
288     return StartingSize + sizeof(RemotableHandle);
289 }
290
291 static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
292 {
293     RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
294     if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
295     {
296         ERR("can't remote a local handle\n");
297         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
298         return pBuffer;
299     }
300     remhandle->fContext = WDT_INPROC_CALL;
301     remhandle->u.hInproc = (LONG_PTR)*handle;
302     return pBuffer + sizeof(RemotableHandle);
303 }
304
305 static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
306 {
307     RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
308     if (remhandle->fContext != WDT_INPROC_CALL)
309         RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
310     *handle = (HANDLE)remhandle->u.hInproc;
311     return pBuffer + sizeof(RemotableHandle);
312 }
313
314 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
315 {
316     /* nothing to do */
317 }
318
319 #define IMPL_WIREM_HANDLE(type) \
320     ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \
321     { \
322         TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \
323         return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
324     } \
325     \
326     unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
327     { \
328         TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \
329         return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
330     } \
331     \
332     unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
333     { \
334         TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \
335         return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
336     } \
337     \
338     void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \
339     { \
340         TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \
341         handle_UserFree(pFlags, (HANDLE *)handle); \
342     }
343
344 IMPL_WIREM_HANDLE(HACCEL)
345 IMPL_WIREM_HANDLE(HMENU)
346 IMPL_WIREM_HANDLE(HWND)
347
348 /******************************************************************************
349  *           HGLOBAL_UserSize [OLE32.@]
350  *
351  * Calculates the buffer size required to marshal an HGLOBAL.
352  *
353  * PARAMS
354  *  pFlags       [I] Flags. See notes.
355  *  StartingSize [I] Starting size of the buffer. This value is added on to
356  *                   the buffer size required for the clip format.
357  *  phGlobal     [I] HGLOBAL to size.
358  *
359  * RETURNS
360  *  The buffer size required to marshal an HGLOBAL plus the starting size.
361  *
362  * NOTES
363  *  Even though the function is documented to take a pointer to a ULONG in
364  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
365  *  the first parameter is a ULONG.
366  *  This function is only intended to be called by the RPC runtime.
367  */
368 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
369 {
370     ULONG size = StartingSize;
371
372     TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
373
374     ALIGN_LENGTH(size, 3);
375
376     size += sizeof(ULONG);
377
378     if (LOWORD(*pFlags == MSHCTX_INPROC))
379         size += sizeof(HGLOBAL);
380     else
381     {
382         size += sizeof(ULONG);
383         if (*phGlobal)
384         {
385             SIZE_T ret;
386             size += 3 * sizeof(ULONG);
387             ret = GlobalSize(*phGlobal);
388             size += (ULONG)ret;
389         }
390     }
391     
392     return size;
393 }
394
395 /******************************************************************************
396  *           HGLOBAL_UserMarshal [OLE32.@]
397  *
398  * Marshals an HGLOBAL into a buffer.
399  *
400  * PARAMS
401  *  pFlags   [I] Flags. See notes.
402  *  pBuffer  [I] Buffer to marshal the clip format into.
403  *  phGlobal [I] HGLOBAL to marshal.
404  *
405  * RETURNS
406  *  The end of the marshaled data in the buffer.
407  *
408  * NOTES
409  *  Even though the function is documented to take a pointer to a ULONG in
410  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
411  *  the first parameter is a ULONG.
412  *  This function is only intended to be called by the RPC runtime.
413  */
414 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
415 {
416     TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
417
418     ALIGN_POINTER(pBuffer, 3);
419
420     if (LOWORD(*pFlags == MSHCTX_INPROC))
421     {
422         if (sizeof(*phGlobal) == 8)
423             *(ULONG *)pBuffer = WDT_INPROC64_CALL;
424         else
425             *(ULONG *)pBuffer = WDT_INPROC_CALL;
426         pBuffer += sizeof(ULONG);
427         *(HGLOBAL *)pBuffer = *phGlobal;
428         pBuffer += sizeof(HGLOBAL);
429     }
430     else
431     {
432         *(ULONG *)pBuffer = WDT_REMOTE_CALL;
433         pBuffer += sizeof(ULONG);
434         *(ULONG *)pBuffer = (ULONG)*phGlobal;
435         pBuffer += sizeof(ULONG);
436         if (*phGlobal)
437         {
438             const unsigned char *memory;
439             SIZE_T size = GlobalSize(*phGlobal);
440             *(ULONG *)pBuffer = (ULONG)size;
441             pBuffer += sizeof(ULONG);
442             *(ULONG *)pBuffer = (ULONG)*phGlobal;
443             pBuffer += sizeof(ULONG);
444             *(ULONG *)pBuffer = (ULONG)size;
445             pBuffer += sizeof(ULONG);
446
447             memory = GlobalLock(*phGlobal);
448             memcpy(pBuffer, memory, size);
449             pBuffer += size;
450             GlobalUnlock(*phGlobal);
451         }
452     }
453
454     return pBuffer;
455 }
456
457 /******************************************************************************
458  *           HGLOBAL_UserUnmarshal [OLE32.@]
459  *
460  * Unmarshals an HGLOBAL from a buffer.
461  *
462  * PARAMS
463  *  pFlags   [I] Flags. See notes.
464  *  pBuffer  [I] Buffer to marshal the clip format from.
465  *  phGlobal [O] Address that receive the unmarshaled HGLOBAL.
466  *
467  * RETURNS
468  *  The end of the marshaled data in the buffer.
469  *
470  * NOTES
471  *  Even though the function is documented to take a pointer to an ULONG in
472  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
473  *  the first parameter is an ULONG.
474  *  This function is only intended to be called by the RPC runtime.
475  */
476 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
477 {
478     ULONG fContext;
479
480     TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
481
482     ALIGN_POINTER(pBuffer, 3);
483
484     fContext = *(ULONG *)pBuffer;
485     pBuffer += sizeof(ULONG);
486
487     if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
488         ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
489     {
490         *phGlobal = *(HGLOBAL *)pBuffer;
491         pBuffer += sizeof(*phGlobal);
492     }
493     else if (fContext == WDT_REMOTE_CALL)
494     {
495         ULONG handle;
496
497         handle = *(ULONG *)pBuffer;
498         pBuffer += sizeof(ULONG);
499
500         if (handle)
501         {
502             ULONG size;
503             void *memory;
504
505             size = *(ULONG *)pBuffer;
506             pBuffer += sizeof(ULONG);
507             /* redundancy is bad - it means you have to check consistency like
508              * this: */
509             if (*(ULONG *)pBuffer != handle)
510             {
511                 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
512                 return pBuffer;
513             }
514             pBuffer += sizeof(ULONG);
515             /* redundancy is bad - it means you have to check consistency like
516              * this: */
517             if (*(ULONG *)pBuffer != size)
518             {
519                 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
520                 return pBuffer;
521             }
522             pBuffer += sizeof(ULONG);
523
524             /* FIXME: check size is not too big */
525
526             *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
527             memory = GlobalLock(*phGlobal);
528             memcpy(memory, pBuffer, size);
529             pBuffer += size;
530             GlobalUnlock(*phGlobal);
531         }
532         else
533             *phGlobal = NULL;
534     }
535     else
536         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
537
538     return pBuffer;
539 }
540
541 /******************************************************************************
542  *           HGLOBAL_UserFree [OLE32.@]
543  *
544  * Frees an unmarshaled HGLOBAL.
545  *
546  * PARAMS
547  *  pFlags   [I] Flags. See notes.
548  *  phGlobal [I] HGLOBAL to free.
549  *
550  * RETURNS
551  *  The end of the marshaled data in the buffer.
552  *
553  * NOTES
554  *  Even though the function is documented to take a pointer to a ULONG in
555  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
556  *  which the first parameter is a ULONG.
557  *  This function is only intended to be called by the RPC runtime.
558  */
559 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
560 {
561     TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
562
563     if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
564         GlobalFree(*phGlobal);
565 }
566
567 /******************************************************************************
568  *           HBITMAP_UserSize [OLE32.@]
569  *
570  * Calculates the buffer size required to marshal a bitmap.
571  *
572  * PARAMS
573  *  pFlags       [I] Flags. See notes.
574  *  StartingSize [I] Starting size of the buffer. This value is added on to
575  *                   the buffer size required for the clip format.
576  *  phBmp        [I] Bitmap to size.
577  *
578  * RETURNS
579  *  The buffer size required to marshal an bitmap plus the starting size.
580  *
581  * NOTES
582  *  Even though the function is documented to take a pointer to a ULONG in
583  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
584  *  the first parameter is a ULONG.
585  *  This function is only intended to be called by the RPC runtime.
586  */
587 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
588 {
589     FIXME(":stub\n");
590     return StartingSize;
591 }
592
593 /******************************************************************************
594 *           HBITMAP_UserMarshal [OLE32.@]
595 *
596 * Marshals a bitmap into a buffer.
597 *
598 * PARAMS
599 *  pFlags  [I] Flags. See notes.
600 *  pBuffer [I] Buffer to marshal the clip format into.
601 *  phBmp   [I] Bitmap to marshal.
602 *
603 * RETURNS
604 *  The end of the marshaled data in the buffer.
605 *
606 * NOTES
607 *  Even though the function is documented to take a pointer to a ULONG in
608 *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
609 *  the first parameter is a ULONG.
610 *  This function is only intended to be called by the RPC runtime.
611 */
612 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
613 {
614     FIXME(":stub\n");
615     return pBuffer;
616 }
617
618 /******************************************************************************
619  *           HBITMAP_UserUnmarshal [OLE32.@]
620  *
621  * Unmarshals a bitmap from a buffer.
622  *
623  * PARAMS
624  *  pFlags   [I] Flags. See notes.
625  *  pBuffer  [I] Buffer to marshal the clip format from.
626  *  phBmp    [O] Address that receive the unmarshaled bitmap.
627  *
628  * RETURNS
629  *  The end of the marshaled data in the buffer.
630  *
631  * NOTES
632  *  Even though the function is documented to take a pointer to an ULONG in
633  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
634  *  the first parameter is an ULONG.
635  *  This function is only intended to be called by the RPC runtime.
636  */
637 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
638 {
639     FIXME(":stub\n");
640     return pBuffer;
641 }
642
643 /******************************************************************************
644  *           HBITMAP_UserFree [OLE32.@]
645  *
646  * Frees an unmarshaled bitmap.
647  *
648  * PARAMS
649  *  pFlags   [I] Flags. See notes.
650  *  phBmp    [I] Bitmap to free.
651  *
652  * RETURNS
653  *  The end of the marshaled data in the buffer.
654  *
655  * NOTES
656  *  Even though the function is documented to take a pointer to a ULONG in
657  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
658  *  which the first parameter is a ULONG.
659  *  This function is only intended to be called by the RPC runtime.
660  */
661 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
662 {
663     FIXME(":stub\n");
664 }
665
666 /******************************************************************************
667  *           HICON_UserSize [OLE32.@]
668  *
669  * Calculates the buffer size required to marshal an icon.
670  *
671  * PARAMS
672  *  pFlags       [I] Flags. See notes.
673  *  StartingSize [I] Starting size of the buffer. This value is added on to
674  *                   the buffer size required for the icon.
675  *  phIcon       [I] Icon to size.
676  *
677  * RETURNS
678  *  The buffer size required to marshal an icon plus the starting size.
679  *
680  * NOTES
681  *  Even though the function is documented to take a pointer to a ULONG in
682  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
683  *  the first parameter is a ULONG.
684  *  This function is only intended to be called by the RPC runtime.
685  */
686 ULONG __RPC_USER HICON_UserSize(ULONG *pFlags, ULONG StartingSize, HICON *phIcon)
687 {
688     FIXME(":stub\n");
689     return StartingSize;
690 }
691
692 /******************************************************************************
693 *           HICON_UserMarshal [OLE32.@]
694 *
695 * Marshals an icon into a buffer.
696 *
697 * PARAMS
698 *  pFlags  [I] Flags. See notes.
699 *  pBuffer [I] Buffer to marshal the icon into.
700 *  phIcon  [I] Icon to marshal.
701 *
702 * RETURNS
703 *  The end of the marshaled data in the buffer.
704 *
705 * NOTES
706 *  Even though the function is documented to take a pointer to a ULONG in
707 *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
708 *  the first parameter is a ULONG.
709 *  This function is only intended to be called by the RPC runtime.
710 */
711 unsigned char * __RPC_USER HICON_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
712 {
713     FIXME(":stub\n");
714     return pBuffer;
715 }
716
717 /******************************************************************************
718  *           HICON_UserUnmarshal [OLE32.@]
719  *
720  * Unmarshals an icon from a buffer.
721  *
722  * PARAMS
723  *  pFlags   [I] Flags. See notes.
724  *  pBuffer  [I] Buffer to marshal the icon from.
725  *  phIcon   [O] Address that receive the unmarshaled icon.
726  *
727  * RETURNS
728  *  The end of the marshaled data in the buffer.
729  *
730  * NOTES
731  *  Even though the function is documented to take a pointer to an ULONG in
732  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
733  *  the first parameter is an ULONG.
734  *  This function is only intended to be called by the RPC runtime.
735  */
736 unsigned char * __RPC_USER HICON_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
737 {
738     FIXME(":stub\n");
739     return pBuffer;
740 }
741
742 /******************************************************************************
743  *           HICON_UserFree [OLE32.@]
744  *
745  * Frees an unmarshaled icon.
746  *
747  * PARAMS
748  *  pFlags   [I] Flags. See notes.
749  *  phIcon   [I] Icon to free.
750  *
751  * RETURNS
752  *  The end of the marshaled data in the buffer.
753  *
754  * NOTES
755  *  Even though the function is documented to take a pointer to a ULONG in
756  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
757  *  which the first parameter is a ULONG.
758  *  This function is only intended to be called by the RPC runtime.
759  */
760 void __RPC_USER HICON_UserFree(ULONG *pFlags, HICON *phIcon)
761 {
762     FIXME(":stub\n");
763 }
764
765 /******************************************************************************
766  *           HDC_UserSize [OLE32.@]
767  *
768  * Calculates the buffer size required to marshal an HDC.
769  *
770  * PARAMS
771  *  pFlags       [I] Flags. See notes.
772  *  StartingSize [I] Starting size of the buffer. This value is added on to
773  *                   the buffer size required for the clip format.
774  *  phGlobal     [I] HDC to size.
775  *
776  * RETURNS
777  *  The buffer size required to marshal an HDC plus the starting size.
778  *
779  * NOTES
780  *  Even though the function is documented to take a pointer to a ULONG in
781  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
782  *  the first parameter is a ULONG.
783  *  This function is only intended to be called by the RPC runtime.
784  */
785 ULONG __RPC_USER HDC_UserSize(ULONG *pFlags, ULONG StartingSize, HDC *phdc)
786 {
787     FIXME(":stub\n");
788     return StartingSize;
789 }
790
791 /******************************************************************************
792  *           HDC_UserMarshal [OLE32.@]
793  *
794  * Marshals an HDC into a buffer.
795  *
796  * PARAMS
797  *  pFlags  [I] Flags. See notes.
798  *  pBuffer [I] Buffer to marshal the clip format into.
799  *  phdc    [I] HDC to marshal.
800  *
801  * RETURNS
802  *  The end of the marshaled data in the buffer.
803  *
804  * NOTES
805  *  Even though the function is documented to take a pointer to a ULONG in
806  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
807  *  the first parameter is a ULONG.
808  *  This function is only intended to be called by the RPC runtime.
809  */
810 unsigned char * __RPC_USER HDC_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
811 {
812     FIXME(":stub\n");
813     return pBuffer;
814 }
815
816 /******************************************************************************
817  *           HDC_UserUnmarshal [OLE32.@]
818  *
819  * Unmarshals an HDC from a buffer.
820  *
821  * PARAMS
822  *  pFlags   [I] Flags. See notes.
823  *  pBuffer  [I] Buffer to marshal the clip format from.
824  *  phdc     [O] Address that receive the unmarshaled HDC.
825  *
826  * RETURNS
827  *  The end of the marshaled data in the buffer.
828  *
829  * NOTES
830  *  Even though the function is documented to take a pointer to an ULONG in
831  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
832  *  the first parameter is an ULONG.
833  *  This function is only intended to be called by the RPC runtime.
834  */
835 unsigned char * __RPC_USER HDC_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
836 {
837     FIXME(":stub\n");
838     return pBuffer;
839 }
840
841 /******************************************************************************
842  *           HDC_UserFree [OLE32.@]
843  *
844  * Frees an unmarshaled HDC.
845  *
846  * PARAMS
847  *  pFlags   [I] Flags. See notes.
848  *  phdc     [I] HDC to free.
849  *
850  * RETURNS
851  *  The end of the marshaled data in the buffer.
852  *
853  * NOTES
854  *  Even though the function is documented to take a pointer to a ULONG in
855  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
856  *  which the first parameter is a ULONG.
857  *  This function is only intended to be called by the RPC runtime.
858  */
859 void __RPC_USER HDC_UserFree(ULONG *pFlags, HDC *phdc)
860 {
861     FIXME(":stub\n");
862 }
863
864 /******************************************************************************
865  *           HPALETTE_UserSize [OLE32.@]
866  *
867  * Calculates the buffer size required to marshal a palette.
868  *
869  * PARAMS
870  *  pFlags       [I] Flags. See notes.
871  *  StartingSize [I] Starting size of the buffer. This value is added on to
872  *                   the buffer size required for the clip format.
873  *  phPal        [I] Palette to size.
874  *
875  * RETURNS
876  *  The buffer size required to marshal a palette plus the starting size.
877  *
878  * NOTES
879  *  Even though the function is documented to take a pointer to a ULONG in
880  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
881  *  the first parameter is a ULONG.
882  *  This function is only intended to be called by the RPC runtime.
883  */
884 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
885 {
886     FIXME(":stub\n");
887     return StartingSize;
888 }
889
890 /******************************************************************************
891  *           HPALETTE_UserMarshal [OLE32.@]
892  *
893  * Marshals a palette into a buffer.
894  *
895  * PARAMS
896  *  pFlags  [I] Flags. See notes.
897  *  pBuffer [I] Buffer to marshal the clip format into.
898  *  phPal   [I] Palette to marshal.
899  *
900  * RETURNS
901  *  The end of the marshaled data in the buffer.
902  *
903  * NOTES
904  *  Even though the function is documented to take a pointer to a ULONG in
905  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
906  *  the first parameter is a ULONG.
907  *  This function is only intended to be called by the RPC runtime.
908  */
909 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
910 {
911     FIXME(":stub\n");
912     return pBuffer;
913 }
914
915 /******************************************************************************
916  *           HPALETTE_UserUnmarshal [OLE32.@]
917  *
918  * Unmarshals a palette from a buffer.
919  *
920  * PARAMS
921  *  pFlags   [I] Flags. See notes.
922  *  pBuffer  [I] Buffer to marshal the clip format from.
923  *  phPal    [O] Address that receive the unmarshaled palette.
924  *
925  * RETURNS
926  *  The end of the marshaled data in the buffer.
927  *
928  * NOTES
929  *  Even though the function is documented to take a pointer to an ULONG in
930  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
931  *  the first parameter is an ULONG.
932  *  This function is only intended to be called by the RPC runtime.
933  */
934 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
935 {
936     FIXME(":stub\n");
937     return pBuffer;
938 }
939
940 /******************************************************************************
941  *           HPALETTE_UserFree [OLE32.@]
942  *
943  * Frees an unmarshaled palette.
944  *
945  * PARAMS
946  *  pFlags   [I] Flags. See notes.
947  *  phPal    [I] Palette to free.
948  *
949  * RETURNS
950  *  The end of the marshaled data in the buffer.
951  *
952  * NOTES
953  *  Even though the function is documented to take a pointer to a ULONG in
954  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
955  *  which the first parameter is a ULONG.
956  *  This function is only intended to be called by the RPC runtime.
957  */
958 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
959 {
960     FIXME(":stub\n");
961 }
962
963
964 /******************************************************************************
965  *           HMETAFILE_UserSize [OLE32.@]
966  *
967  * Calculates the buffer size required to marshal a metafile.
968  *
969  * PARAMS
970  *  pFlags       [I] Flags. See notes.
971  *  StartingSize [I] Starting size of the buffer. This value is added on to
972  *                   the buffer size required for the clip format.
973  *  phmf         [I] Metafile to size.
974  *
975  * RETURNS
976  *  The buffer size required to marshal a metafile plus the starting size.
977  *
978  * NOTES
979  *  Even though the function is documented to take a pointer to a ULONG in
980  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
981  *  the first parameter is a ULONG.
982  *  This function is only intended to be called by the RPC runtime.
983  */
984 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
985 {
986     ULONG size = StartingSize;
987
988     TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
989
990     ALIGN_LENGTH(size, 3);
991
992     size += sizeof(ULONG);
993     if (LOWORD(*pFlags) == MSHCTX_INPROC)
994         size += sizeof(ULONG_PTR);
995     else
996     {
997         size += sizeof(ULONG);
998
999         if (*phmf)
1000         {
1001             UINT mfsize;
1002
1003             size += 2 * sizeof(ULONG);
1004             mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1005             size += mfsize;
1006         }
1007     }
1008
1009     return size;
1010 }
1011
1012 /******************************************************************************
1013  *           HMETAFILE_UserMarshal [OLE32.@]
1014  *
1015  * Marshals a metafile into a buffer.
1016  *
1017  * PARAMS
1018  *  pFlags  [I] Flags. See notes.
1019  *  pBuffer [I] Buffer to marshal the clip format into.
1020  *  phEmf   [I] Metafile to marshal.
1021  *
1022  * RETURNS
1023  *  The end of the marshaled data in the buffer.
1024  *
1025  * NOTES
1026  *  Even though the function is documented to take a pointer to a ULONG in
1027  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1028  *  the first parameter is a ULONG.
1029  *  This function is only intended to be called by the RPC runtime.
1030  */
1031 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1032 {
1033     TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
1034
1035     ALIGN_POINTER(pBuffer, 3);
1036
1037     if (LOWORD(*pFlags) == MSHCTX_INPROC)
1038     {
1039         if (sizeof(*phmf) == 8)
1040             *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1041         else
1042             *(ULONG *)pBuffer = WDT_INPROC_CALL;
1043         pBuffer += sizeof(ULONG);
1044         *(HMETAFILE *)pBuffer = *phmf;
1045         pBuffer += sizeof(HMETAFILE);
1046     }
1047     else
1048     {
1049         *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1050         pBuffer += sizeof(ULONG);
1051         *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1052         pBuffer += sizeof(ULONG);
1053
1054         if (*phmf)
1055         {
1056             UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1057
1058             *(ULONG *)pBuffer = mfsize;
1059             pBuffer += sizeof(ULONG);
1060             *(ULONG *)pBuffer = mfsize;
1061             pBuffer += sizeof(ULONG);
1062             GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
1063             pBuffer += mfsize;
1064         }
1065     }
1066
1067     return pBuffer;
1068 }
1069
1070 /******************************************************************************
1071  *           HMETAFILE_UserUnmarshal [OLE32.@]
1072  *
1073  * Unmarshals a metafile from a buffer.
1074  *
1075  * PARAMS
1076  *  pFlags   [I] Flags. See notes.
1077  *  pBuffer  [I] Buffer to marshal the clip format from.
1078  *  phmf     [O] Address that receive the unmarshaled metafile.
1079  *
1080  * RETURNS
1081  *  The end of the marshaled data in the buffer.
1082  *
1083  * NOTES
1084  *  Even though the function is documented to take a pointer to an ULONG in
1085  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1086  *  the first parameter is an ULONG.
1087  *  This function is only intended to be called by the RPC runtime.
1088  */
1089 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1090 {
1091     ULONG fContext;
1092
1093     TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
1094
1095     ALIGN_POINTER(pBuffer, 3);
1096
1097     fContext = *(ULONG *)pBuffer;
1098     pBuffer += sizeof(ULONG);
1099
1100     if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
1101         ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
1102     {
1103         *phmf = *(HMETAFILE *)pBuffer;
1104         pBuffer += sizeof(*phmf);
1105     }
1106     else if (fContext == WDT_REMOTE_CALL)
1107     {
1108         ULONG handle;
1109
1110         handle = *(ULONG *)pBuffer;
1111         pBuffer += sizeof(ULONG);
1112
1113         if (handle)
1114         {
1115             ULONG size;
1116             size = *(ULONG *)pBuffer;
1117             pBuffer += sizeof(ULONG);
1118             if (size != *(ULONG *)pBuffer)
1119             {
1120                 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1121                 return pBuffer;
1122             }
1123             pBuffer += sizeof(ULONG);
1124             *phmf = SetMetaFileBitsEx(size, pBuffer);
1125             pBuffer += size;
1126         }
1127         else
1128             *phmf = NULL;
1129     }
1130     else
1131         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1132
1133     return pBuffer;
1134 }
1135
1136 /******************************************************************************
1137  *           HMETAFILE_UserFree [OLE32.@]
1138  *
1139  * Frees an unmarshaled metafile.
1140  *
1141  * PARAMS
1142  *  pFlags   [I] Flags. See notes.
1143  *  phmf     [I] Metafile to free.
1144  *
1145  * RETURNS
1146  *  The end of the marshaled data in the buffer.
1147  *
1148  * NOTES
1149  *  Even though the function is documented to take a pointer to a ULONG in
1150  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1151  *  which the first parameter is a ULONG.
1152  *  This function is only intended to be called by the RPC runtime.
1153  */
1154 void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
1155 {
1156     TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
1157
1158     if (LOWORD(*pFlags) != MSHCTX_INPROC)
1159         DeleteMetaFile(*phmf);
1160 }
1161
1162 /******************************************************************************
1163 *           HENHMETAFILE_UserSize [OLE32.@]
1164 *
1165 * Calculates the buffer size required to marshal an enhanced metafile.
1166 *
1167 * PARAMS
1168 *  pFlags       [I] Flags. See notes.
1169 *  StartingSize [I] Starting size of the buffer. This value is added on to
1170 *                   the buffer size required for the clip format.
1171 *  phEmf        [I] Enhanced metafile to size.
1172 *
1173 * RETURNS
1174 *  The buffer size required to marshal an enhanced metafile plus the starting size.
1175 *
1176 * NOTES
1177 *  Even though the function is documented to take a pointer to a ULONG in
1178 *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1179 *  the first parameter is a ULONG.
1180 *  This function is only intended to be called by the RPC runtime.
1181 */
1182 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
1183 {
1184     ULONG size = StartingSize;
1185
1186     TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
1187
1188     size += sizeof(ULONG);
1189     if (LOWORD(*pFlags) == MSHCTX_INPROC)
1190         size += sizeof(ULONG_PTR);
1191     else
1192     {
1193         size += sizeof(ULONG);
1194
1195         if (*phEmf)
1196         {
1197             UINT emfsize;
1198     
1199             size += 2 * sizeof(ULONG);
1200             emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1201             size += emfsize;
1202         }
1203     }
1204
1205     return size;
1206 }
1207
1208 /******************************************************************************
1209  *           HENHMETAFILE_UserMarshal [OLE32.@]
1210  *
1211  * Marshals an enhance metafile into a buffer.
1212  *
1213  * PARAMS
1214  *  pFlags  [I] Flags. See notes.
1215  *  pBuffer [I] Buffer to marshal the clip format into.
1216  *  phEmf   [I] Enhanced metafile to marshal.
1217  *
1218  * RETURNS
1219  *  The end of the marshaled data in the buffer.
1220  *
1221  * NOTES
1222  *  Even though the function is documented to take a pointer to a ULONG in
1223  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1224  *  the first parameter is a ULONG.
1225  *  This function is only intended to be called by the RPC runtime.
1226  */
1227 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1228 {
1229     TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1230
1231     if (LOWORD(*pFlags) == MSHCTX_INPROC)
1232     {
1233         if (sizeof(*phEmf) == 8)
1234             *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1235         else
1236             *(ULONG *)pBuffer = WDT_INPROC_CALL;
1237         pBuffer += sizeof(ULONG);
1238         *(HENHMETAFILE *)pBuffer = *phEmf;
1239         pBuffer += sizeof(HENHMETAFILE);
1240     }
1241     else
1242     {
1243         *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1244         pBuffer += sizeof(ULONG);
1245         *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1246         pBuffer += sizeof(ULONG);
1247     
1248         if (*phEmf)
1249         {
1250             UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1251     
1252             *(ULONG *)pBuffer = emfsize;
1253             pBuffer += sizeof(ULONG);
1254             *(ULONG *)pBuffer = emfsize;
1255             pBuffer += sizeof(ULONG);
1256             GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1257             pBuffer += emfsize;
1258         }
1259     }
1260
1261     return pBuffer;
1262 }
1263
1264 /******************************************************************************
1265  *           HENHMETAFILE_UserUnmarshal [OLE32.@]
1266  *
1267  * Unmarshals an enhanced metafile from a buffer.
1268  *
1269  * PARAMS
1270  *  pFlags   [I] Flags. See notes.
1271  *  pBuffer  [I] Buffer to marshal the clip format from.
1272  *  phEmf    [O] Address that receive the unmarshaled enhanced metafile.
1273  *
1274  * RETURNS
1275  *  The end of the marshaled data in the buffer.
1276  *
1277  * NOTES
1278  *  Even though the function is documented to take a pointer to an ULONG in
1279  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1280  *  the first parameter is an ULONG.
1281  *  This function is only intended to be called by the RPC runtime.
1282  */
1283 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1284 {
1285     ULONG fContext;
1286
1287     TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1288
1289     fContext = *(ULONG *)pBuffer;
1290     pBuffer += sizeof(ULONG);
1291
1292     if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1293         ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1294     {
1295         *phEmf = *(HENHMETAFILE *)pBuffer;
1296         pBuffer += sizeof(*phEmf);
1297     }
1298     else if (fContext == WDT_REMOTE_CALL)
1299     {
1300         ULONG handle;
1301
1302         handle = *(ULONG *)pBuffer;
1303         pBuffer += sizeof(ULONG);
1304
1305         if (handle)
1306         {
1307             ULONG size;
1308             size = *(ULONG *)pBuffer;
1309             pBuffer += sizeof(ULONG);
1310             if (size != *(ULONG *)pBuffer)
1311             {
1312                 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1313                 return pBuffer;
1314             }
1315             pBuffer += sizeof(ULONG);
1316             *phEmf = SetEnhMetaFileBits(size, pBuffer);
1317             pBuffer += size;
1318         }
1319         else 
1320             *phEmf = NULL;
1321     }
1322     else
1323         RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1324
1325     return pBuffer;
1326 }
1327
1328 /******************************************************************************
1329  *           HENHMETAFILE_UserFree [OLE32.@]
1330  *
1331  * Frees an unmarshaled enhanced metafile.
1332  *
1333  * PARAMS
1334  *  pFlags   [I] Flags. See notes.
1335  *  phEmf    [I] Enhanced metafile to free.
1336  *
1337  * RETURNS
1338  *  The end of the marshaled data in the buffer.
1339  *
1340  * NOTES
1341  *  Even though the function is documented to take a pointer to a ULONG in
1342  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1343  *  which the first parameter is a ULONG.
1344  *  This function is only intended to be called by the RPC runtime.
1345  */
1346 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1347 {
1348     TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1349
1350     if (LOWORD(*pFlags) != MSHCTX_INPROC)
1351         DeleteEnhMetaFile(*phEmf);
1352 }
1353
1354 /******************************************************************************
1355  *           HMETAFILEPICT_UserSize [OLE32.@]
1356  *
1357  * Calculates the buffer size required to marshal an metafile pict.
1358  *
1359  * PARAMS
1360  *  pFlags       [I] Flags. See notes.
1361  *  StartingSize [I] Starting size of the buffer. This value is added on to
1362  *                   the buffer size required for the clip format.
1363  *  phMfp        [I] Metafile pict to size.
1364  *
1365  * RETURNS
1366  *  The buffer size required to marshal a metafile pict plus the starting size.
1367  *
1368  * NOTES
1369  *  Even though the function is documented to take a pointer to a ULONG in
1370  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1371  *  the first parameter is a ULONG.
1372  *  This function is only intended to be called by the RPC runtime.
1373  */
1374 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1375 {
1376     ULONG size = StartingSize;
1377
1378     TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1379
1380     size += sizeof(ULONG);
1381     size += sizeof(HMETAFILEPICT);
1382
1383     if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1384     {
1385         METAFILEPICT *mfpict = GlobalLock(*phMfp);
1386
1387         /* FIXME: raise an exception if mfpict is NULL? */
1388         size += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1389         size += sizeof(ULONG);
1390
1391         size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1392
1393         GlobalUnlock(*phMfp);
1394     }
1395
1396     return size;
1397 }
1398
1399 /******************************************************************************
1400  *           HMETAFILEPICT_UserMarshal [OLE32.@]
1401  *
1402  * Marshals a metafile pict into a buffer.
1403  *
1404  * PARAMS
1405  *  pFlags  [I] Flags. See notes.
1406  *  pBuffer [I] Buffer to marshal the clip format into.
1407  *  phMfp   [I] Metafile pict to marshal.
1408  *
1409  * RETURNS
1410  *  The end of the marshaled data in the buffer.
1411  *
1412  * NOTES
1413  *  Even though the function is documented to take a pointer to a ULONG in
1414  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1415  *  the first parameter is a ULONG.
1416  *  This function is only intended to be called by the RPC runtime.
1417  */
1418 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1419 {
1420     TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1421
1422     if (LOWORD(*pFlags) == MSHCTX_INPROC)
1423         *(ULONG *)pBuffer = WDT_INPROC_CALL;
1424     else
1425         *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1426     pBuffer += sizeof(ULONG);
1427
1428     *(HMETAFILEPICT *)pBuffer = *phMfp;
1429     pBuffer += sizeof(HMETAFILEPICT);
1430
1431     if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1432     {
1433         METAFILEPICT *mfpict = GlobalLock(*phMfp);
1434         remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1435
1436         /* FIXME: raise an exception if mfpict is NULL? */
1437         remmfpict->mm = mfpict->mm;
1438         remmfpict->xExt = mfpict->xExt;
1439         remmfpict->yExt = mfpict->yExt;
1440         pBuffer += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1441         *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1442         pBuffer += sizeof(ULONG);
1443
1444         pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1445
1446         GlobalUnlock(*phMfp);
1447     }
1448
1449     return pBuffer;
1450 }
1451
1452 /******************************************************************************
1453  *           HMETAFILEPICT_UserUnmarshal [OLE32.@]
1454  *
1455  * Unmarshals an metafile pict from a buffer.
1456  *
1457  * PARAMS
1458  *  pFlags   [I] Flags. See notes.
1459  *  pBuffer  [I] Buffer to marshal the clip format from.
1460  *  phMfp    [O] Address that receive the unmarshaled metafile pict.
1461  *
1462  * RETURNS
1463  *  The end of the marshaled data in the buffer.
1464  *
1465  * NOTES
1466  *  Even though the function is documented to take a pointer to an ULONG in
1467  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1468  *  the first parameter is an ULONG.
1469  *  This function is only intended to be called by the RPC runtime.
1470  */
1471 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1472 {
1473     ULONG fContext;
1474
1475     TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1476
1477     fContext = *(ULONG *)pBuffer;
1478     pBuffer += sizeof(ULONG);
1479
1480     if ((fContext == WDT_INPROC_CALL) || !*(HMETAFILEPICT *)pBuffer)
1481     {
1482         *phMfp = *(HMETAFILEPICT *)pBuffer;
1483         pBuffer += sizeof(HMETAFILEPICT);
1484     }
1485     else
1486     {
1487         METAFILEPICT *mfpict;
1488         const remoteMETAFILEPICT *remmfpict;
1489         ULONG user_marshal_prefix;
1490
1491         pBuffer += sizeof(HMETAFILEPICT);
1492         remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1493
1494         *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1495         if (!*phMfp)
1496             RpcRaiseException(E_OUTOFMEMORY);
1497
1498         mfpict = GlobalLock(*phMfp);
1499         mfpict->mm = remmfpict->mm;
1500         mfpict->xExt = remmfpict->xExt;
1501         mfpict->yExt = remmfpict->yExt;
1502         pBuffer += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1503         user_marshal_prefix = *(ULONG *)pBuffer;
1504         pBuffer += sizeof(ULONG);
1505
1506         if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1507             RpcRaiseException(RPC_X_INVALID_TAG);
1508
1509         pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1510
1511         GlobalUnlock(*phMfp);
1512     }
1513
1514     return pBuffer;
1515 }
1516
1517 /******************************************************************************
1518  *           HMETAFILEPICT_UserFree [OLE32.@]
1519  *
1520  * Frees an unmarshaled metafile pict.
1521  *
1522  * PARAMS
1523  *  pFlags   [I] Flags. See notes.
1524  *  phMfp    [I] Metafile pict to free.
1525  *
1526  * RETURNS
1527  *  The end of the marshaled data in the buffer.
1528  *
1529  * NOTES
1530  *  Even though the function is documented to take a pointer to a ULONG in
1531  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1532  *  which the first parameter is a ULONG.
1533  *  This function is only intended to be called by the RPC runtime.
1534  */
1535 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1536 {
1537     TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1538
1539     if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1540     {
1541         METAFILEPICT *mfpict;
1542
1543         mfpict = GlobalLock(*phMfp);
1544         /* FIXME: raise an exception if mfpict is NULL? */
1545         HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1546         GlobalUnlock(*phMfp);
1547
1548         GlobalFree(*phMfp);
1549     }
1550 }
1551
1552 /******************************************************************************
1553  *           WdtpInterfacePointer_UserSize [OLE32.@]
1554  *
1555  * Calculates the buffer size required to marshal an interface pointer.
1556  *
1557  * PARAMS
1558  *  pFlags       [I] Flags. See notes.
1559  *  RealFlags    [I] The MSHCTX to use when marshaling the interface.
1560  *  punk         [I] Interface pointer to size.
1561  *  StartingSize [I] Starting size of the buffer. This value is added on to
1562  *                   the buffer size required for the clip format.
1563  *  riid         [I] ID of interface to size.
1564  *
1565  * RETURNS
1566  *  The buffer size required to marshal an interface pointer plus the starting size.
1567  *
1568  * NOTES
1569  *  Even though the function is documented to take a pointer to a ULONG in
1570  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1571  *  the first parameter is a ULONG.
1572  */
1573 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1574 {
1575     DWORD marshal_size = 0;
1576     HRESULT hr;
1577
1578     TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1579
1580     hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1581     if(FAILED(hr)) return StartingSize;
1582
1583     ALIGN_LENGTH(StartingSize, 3);
1584     StartingSize += 2 * sizeof(DWORD);
1585     return StartingSize + marshal_size;
1586 }
1587
1588 /******************************************************************************
1589  *           WdtpInterfacePointer_UserMarshal [OLE32.@]
1590  *
1591  * Marshals an interface pointer into a buffer.
1592  *
1593  * PARAMS
1594  *  pFlags    [I] Flags. See notes.
1595  *  RealFlags [I] The MSHCTX to use when marshaling the interface.
1596  *  pBuffer   [I] Buffer to marshal the clip format into.
1597  *  punk      [I] Interface pointer to marshal.
1598  *  riid      [I] ID of interface to marshal.
1599  *
1600  * RETURNS
1601  *  The end of the marshaled data in the buffer.
1602  *
1603  * NOTES
1604  *  Even though the function is documented to take a pointer to a ULONG in
1605  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1606  *  the first parameter is a ULONG.
1607  */
1608 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1609 {
1610     HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1611     IStream *stm;
1612     DWORD size;
1613     void *ptr;
1614
1615     TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1616
1617     if(!h) return NULL;
1618     if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1619     {
1620         GlobalFree(h);
1621         return NULL;
1622     }
1623
1624     if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1625     {
1626         IStream_Release(stm);
1627         return NULL;
1628     }
1629
1630     ALIGN_POINTER(pBuffer, 3);
1631     size = GlobalSize(h);
1632
1633     *(DWORD *)pBuffer = size;
1634     pBuffer += sizeof(DWORD);
1635     *(DWORD *)pBuffer = size;
1636     pBuffer += sizeof(DWORD);
1637
1638     ptr = GlobalLock(h);
1639     memcpy(pBuffer, ptr, size);
1640     GlobalUnlock(h);
1641
1642     IStream_Release(stm);
1643     return pBuffer + size;
1644 }
1645
1646 /******************************************************************************
1647  *           WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1648  *
1649  * Unmarshals an interface pointer from a buffer.
1650  *
1651  * PARAMS
1652  *  pFlags   [I] Flags. See notes.
1653  *  pBuffer  [I] Buffer to marshal the clip format from.
1654  *  ppunk    [I/O] Address that receives the unmarshaled interface pointer.
1655  *  riid     [I] ID of interface to unmarshal.
1656  *
1657  * RETURNS
1658  *  The end of the marshaled data in the buffer.
1659  *
1660  * NOTES
1661  *  Even though the function is documented to take a pointer to an ULONG in
1662  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1663  *  the first parameter is an ULONG.
1664  */
1665 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1666 {
1667     HRESULT hr;
1668     HGLOBAL h;
1669     IStream *stm;
1670     DWORD size;
1671     void *ptr;
1672
1673     TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1674
1675     ALIGN_POINTER(pBuffer, 3);
1676
1677     size = *(DWORD *)pBuffer;
1678     pBuffer += sizeof(DWORD);
1679     if(size != *(DWORD *)pBuffer)
1680         RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1681
1682     pBuffer += sizeof(DWORD);
1683
1684     /* FIXME: sanity check on size */
1685
1686     h = GlobalAlloc(GMEM_MOVEABLE, size);
1687     if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1688
1689     if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1690     {
1691         GlobalFree(h);
1692         RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1693     }
1694
1695     ptr = GlobalLock(h);
1696     memcpy(ptr, pBuffer, size);
1697     GlobalUnlock(h);
1698
1699     hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1700     IStream_Release(stm);
1701
1702     if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1703
1704     return pBuffer + size;
1705 }
1706
1707 /******************************************************************************
1708  *           WdtpInterfacePointer_UserFree [OLE32.@]
1709  *
1710  * Releases an unmarshaled interface pointer.
1711  *
1712  * PARAMS
1713  *  punk    [I] Interface pointer to release.
1714  *
1715  * RETURNS
1716  *  Nothing.
1717  */
1718 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1719 {
1720     TRACE("(%p)\n", punk);
1721     if(punk) IUnknown_Release(punk);
1722 }
1723
1724 /******************************************************************************
1725 *           STGMEDIUM_UserSize [OLE32.@]
1726 *
1727 * Calculates the buffer size required to marshal an STGMEDIUM.
1728 *
1729 * PARAMS
1730 *  pFlags       [I] Flags. See notes.
1731 *  StartingSize [I] Starting size of the buffer. This value is added on to
1732 *                   the buffer size required for the clip format.
1733 *  pStgMedium   [I] STGMEDIUM to size.
1734 *
1735 * RETURNS
1736 *  The buffer size required to marshal an STGMEDIUM plus the starting size.
1737 *
1738 * NOTES
1739 *  Even though the function is documented to take a pointer to a ULONG in
1740 *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1741 *  the first parameter is a ULONG.
1742 *  This function is only intended to be called by the RPC runtime.
1743 */
1744 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1745 {
1746     ULONG size = StartingSize;
1747
1748     TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1749
1750     ALIGN_LENGTH(size, 3);
1751
1752     size += 2 * sizeof(DWORD);
1753     if (pStgMedium->tymed != TYMED_NULL)
1754         size += sizeof(DWORD);
1755
1756     switch (pStgMedium->tymed)
1757     {
1758     case TYMED_NULL:
1759         TRACE("TYMED_NULL\n");
1760         break;
1761     case TYMED_HGLOBAL:
1762         TRACE("TYMED_HGLOBAL\n");
1763         if (pStgMedium->u.hGlobal)
1764             size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1765         break;
1766     case TYMED_FILE:
1767         TRACE("TYMED_FILE\n");
1768         if (pStgMedium->u.lpszFileName)
1769         {
1770             TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1771             size += 3 * sizeof(DWORD) +
1772                 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1773         }
1774         break;
1775     case TYMED_ISTREAM:
1776         TRACE("TYMED_ISTREAM\n");
1777         if (pStgMedium->u.pstm)
1778         {
1779             IUnknown *unk;
1780             IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1781             size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1782             IUnknown_Release(unk);
1783         }
1784         break;
1785     case TYMED_ISTORAGE:
1786         TRACE("TYMED_ISTORAGE\n");
1787         if (pStgMedium->u.pstg)
1788         {
1789             IUnknown *unk;
1790             IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1791             size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1792             IUnknown_Release(unk);
1793         }
1794         break;
1795     case TYMED_GDI:
1796         TRACE("TYMED_GDI\n");
1797         if (pStgMedium->u.hBitmap)
1798         {
1799             FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1800         }
1801         break;
1802     case TYMED_MFPICT:
1803         TRACE("TYMED_MFPICT\n");
1804         if (pStgMedium->u.hMetaFilePict)
1805             size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1806         break;
1807     case TYMED_ENHMF:
1808         TRACE("TYMED_ENHMF\n");
1809         if (pStgMedium->u.hEnhMetaFile)
1810             size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1811         break;
1812     default:
1813         RaiseException(DV_E_TYMED, 0, 0, NULL);
1814     }
1815
1816     if (pStgMedium->pUnkForRelease)
1817         size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1818
1819     return size;
1820 }
1821
1822 /******************************************************************************
1823  *           STGMEDIUM_UserMarshal [OLE32.@]
1824  *
1825  * Marshals a STGMEDIUM into a buffer.
1826  *
1827  * PARAMS
1828  *  pFlags  [I] Flags. See notes.
1829  *  pBuffer [I] Buffer to marshal the clip format into.
1830  *  pCF     [I] STGMEDIUM to marshal.
1831  *
1832  * RETURNS
1833  *  The end of the marshaled data in the buffer.
1834  *
1835  * NOTES
1836  *  Even though the function is documented to take a pointer to a ULONG in
1837  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1838  *  the first parameter is a ULONG.
1839  *  This function is only intended to be called by the RPC runtime.
1840  */
1841 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1842 {
1843     TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1844
1845     ALIGN_POINTER(pBuffer, 3);
1846
1847     *(DWORD *)pBuffer = pStgMedium->tymed;
1848     pBuffer += sizeof(DWORD);
1849     if (pStgMedium->tymed != TYMED_NULL)
1850     {
1851         *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1852         pBuffer += sizeof(DWORD);
1853     }
1854     *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1855     pBuffer += sizeof(DWORD);
1856
1857     switch (pStgMedium->tymed)
1858     {
1859     case TYMED_NULL:
1860         TRACE("TYMED_NULL\n");
1861         break;
1862     case TYMED_HGLOBAL:
1863         TRACE("TYMED_HGLOBAL\n");
1864         if (pStgMedium->u.hGlobal)
1865             pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1866         break;
1867     case TYMED_FILE:
1868         TRACE("TYMED_FILE\n");
1869         if (pStgMedium->u.lpszFileName)
1870         {
1871             DWORD len;
1872             len = strlenW(pStgMedium->u.lpszFileName);
1873             /* conformance */
1874             *(DWORD *)pBuffer = len + 1;
1875             pBuffer += sizeof(DWORD);
1876             /* offset */
1877             *(DWORD *)pBuffer = 0;
1878             pBuffer += sizeof(DWORD);
1879             /* variance */
1880             *(DWORD *)pBuffer = len + 1;
1881             pBuffer += sizeof(DWORD);
1882
1883             TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1884             memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1885         }
1886         break;
1887     case TYMED_ISTREAM:
1888         TRACE("TYMED_ISTREAM\n");
1889         if (pStgMedium->u.pstm)
1890         {
1891             IUnknown *unk;
1892             IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1893             pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1894             IUnknown_Release(unk);
1895         }
1896         break;
1897     case TYMED_ISTORAGE:
1898         TRACE("TYMED_ISTORAGE\n");
1899         if (pStgMedium->u.pstg)
1900         {
1901             IUnknown *unk;
1902             IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1903             pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1904             IUnknown_Release(unk);
1905         }
1906         break;
1907     case TYMED_GDI:
1908         TRACE("TYMED_GDI\n");
1909         if (pStgMedium->u.hBitmap)
1910         {
1911             FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1912         }
1913         break;
1914     case TYMED_MFPICT:
1915         TRACE("TYMED_MFPICT\n");
1916         if (pStgMedium->u.hMetaFilePict)
1917             pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1918         break;
1919     case TYMED_ENHMF:
1920         TRACE("TYMED_ENHMF\n");
1921         if (pStgMedium->u.hEnhMetaFile)
1922             pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1923         break;
1924     default:
1925         RaiseException(DV_E_TYMED, 0, 0, NULL);
1926     }
1927
1928     if (pStgMedium->pUnkForRelease)
1929         pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1930
1931     return pBuffer;
1932 }
1933
1934 /******************************************************************************
1935  *           STGMEDIUM_UserUnmarshal [OLE32.@]
1936  *
1937  * Unmarshals a STGMEDIUM from a buffer.
1938  *
1939  * PARAMS
1940  *  pFlags     [I] Flags. See notes.
1941  *  pBuffer    [I] Buffer to marshal the clip format from.
1942  *  pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1943  *
1944  * RETURNS
1945  *  The end of the marshaled data in the buffer.
1946  *
1947  * NOTES
1948  *  Even though the function is documented to take a pointer to an ULONG in
1949  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1950  *  the first parameter is an ULONG.
1951  *  This function is only intended to be called by the RPC runtime.
1952  */
1953 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1954 {
1955     DWORD content = 0;
1956     DWORD releaseunk;
1957
1958     ALIGN_POINTER(pBuffer, 3);
1959
1960     TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1961
1962     pStgMedium->tymed = *(DWORD *)pBuffer;
1963     pBuffer += sizeof(DWORD);
1964     if (pStgMedium->tymed != TYMED_NULL)
1965     {
1966         content = *(DWORD *)pBuffer;
1967         pBuffer += sizeof(DWORD);
1968     }
1969     releaseunk = *(DWORD *)pBuffer;
1970     pBuffer += sizeof(DWORD);
1971
1972     switch (pStgMedium->tymed)
1973     {
1974     case TYMED_NULL:
1975         TRACE("TYMED_NULL\n");
1976         break;
1977     case TYMED_HGLOBAL:
1978         TRACE("TYMED_HGLOBAL\n");
1979         if (content)
1980             pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1981         break;
1982     case TYMED_FILE:
1983         TRACE("TYMED_FILE\n");
1984         if (content)
1985         {
1986             DWORD conformance;
1987             DWORD variance;
1988             conformance = *(DWORD *)pBuffer;
1989             pBuffer += sizeof(DWORD);
1990             if (*(DWORD *)pBuffer != 0)
1991             {
1992                 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
1993                 RpcRaiseException(RPC_S_INVALID_BOUND);
1994                 return NULL;
1995             }
1996             pBuffer += sizeof(DWORD);
1997             variance = *(DWORD *)pBuffer;
1998             pBuffer += sizeof(DWORD);
1999             if (conformance != variance)
2000             {
2001                 ERR("conformance (%d) and variance (%d) should be equal\n",
2002                     conformance, variance);
2003                 RpcRaiseException(RPC_S_INVALID_BOUND);
2004                 return NULL;
2005             }
2006             if (conformance > 0x7fffffff)
2007             {
2008                 ERR("conformance 0x%x too large\n", conformance);
2009                 RpcRaiseException(RPC_S_INVALID_BOUND);
2010                 return NULL;
2011             }
2012             pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2013             if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2014             TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2015             memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2016             pBuffer += variance * sizeof(WCHAR);
2017         }
2018         else
2019             pStgMedium->u.lpszFileName = NULL;
2020         break;
2021     case TYMED_ISTREAM:
2022         TRACE("TYMED_ISTREAM\n");
2023         if (content)
2024         {
2025             pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
2026         }
2027         else
2028             pStgMedium->u.pstm = NULL;
2029         break;
2030     case TYMED_ISTORAGE:
2031         TRACE("TYMED_ISTORAGE\n");
2032         if (content)
2033         {
2034             pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
2035         }
2036         else
2037             pStgMedium->u.pstg = NULL;
2038         break;
2039     case TYMED_GDI:
2040         TRACE("TYMED_GDI\n");
2041         if (content)
2042         {
2043             FIXME("not implemented for GDI object\n");
2044         }
2045         else
2046             pStgMedium->u.hBitmap = NULL;
2047         break;
2048     case TYMED_MFPICT:
2049         TRACE("TYMED_MFPICT\n");
2050         if (content)
2051             pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2052         else
2053             pStgMedium->u.hMetaFilePict = NULL;
2054         break;
2055     case TYMED_ENHMF:
2056         TRACE("TYMED_ENHMF\n");
2057         if (content)
2058             pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2059         else
2060             pStgMedium->u.hEnhMetaFile = NULL;
2061         break;
2062     default:
2063         RaiseException(DV_E_TYMED, 0, 0, NULL);
2064     }
2065
2066     pStgMedium->pUnkForRelease = NULL;
2067     if (releaseunk)
2068         pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2069
2070     return pBuffer;
2071 }
2072
2073 /******************************************************************************
2074  *           STGMEDIUM_UserFree [OLE32.@]
2075  *
2076  * Frees an unmarshaled STGMEDIUM.
2077  *
2078  * PARAMS
2079  *  pFlags     [I] Flags. See notes.
2080  *  pStgmedium [I] STGMEDIUM to free.
2081  *
2082  * RETURNS
2083  *  The end of the marshaled data in the buffer.
2084  *
2085  * NOTES
2086  *  Even though the function is documented to take a pointer to a ULONG in
2087  *  pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2088  *  which the first parameter is a ULONG.
2089  *  This function is only intended to be called by the RPC runtime.
2090  */
2091 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2092 {
2093     TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2094
2095     ReleaseStgMedium(pStgMedium);
2096 }
2097
2098 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2099 {
2100     TRACE("\n");
2101     return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2102 }
2103
2104 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal(  ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2105 {
2106     TRACE("\n");
2107     return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2108 }
2109
2110 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2111 {
2112     TRACE("\n");
2113     return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2114 }
2115
2116 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2117 {
2118     TRACE("\n");
2119     STGMEDIUM_UserFree(pFlags, pStgMedium);
2120 }
2121
2122 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2123 {
2124     FIXME(":stub\n");
2125     return StartingSize;
2126 }
2127
2128 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal(  ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2129 {
2130     FIXME(":stub\n");
2131     return pBuffer;
2132 }
2133
2134 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2135 {
2136     FIXME(":stub\n");
2137     return pBuffer;
2138 }
2139
2140 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2141 {
2142     FIXME(":stub\n");
2143 }
2144
2145 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2146 {
2147     FIXME(":stub\n");
2148     return StartingSize;
2149 }
2150
2151 unsigned char * __RPC_USER SNB_UserMarshal(  ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2152 {
2153     FIXME(":stub\n");
2154     return pBuffer;
2155 }
2156
2157 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2158 {
2159     FIXME(":stub\n");
2160     return pBuffer;
2161 }
2162
2163 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2164 {
2165     FIXME(":stub\n");
2166 }
2167
2168 /* call_as/local stubs for unknwn.idl */
2169
2170 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2171     IClassFactory* This,
2172     IUnknown *pUnkOuter,
2173     REFIID riid,
2174     void **ppvObject)
2175 {
2176     TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2177     *ppvObject = NULL;
2178     if (pUnkOuter)
2179     {
2180         ERR("aggregation is not allowed on remote objects\n");
2181         return CLASS_E_NOAGGREGATION;
2182     }
2183     return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2184                                                     (IUnknown **) ppvObject);
2185 }
2186
2187 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2188     IClassFactory* This,
2189     REFIID riid,
2190     IUnknown **ppvObject)
2191 {
2192     TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2193     return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2194 }
2195
2196 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2197     IClassFactory* This,
2198     BOOL fLock)
2199 {
2200     FIXME(":stub\n");
2201     return E_NOTIMPL;
2202 }
2203
2204 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2205     IClassFactory* This,
2206     BOOL fLock)
2207 {
2208     FIXME(":stub\n");
2209     return E_NOTIMPL;
2210 }
2211
2212 /* call_as/local stubs for objidl.idl */
2213
2214 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2215     IEnumUnknown* This,
2216     ULONG celt,
2217     IUnknown **rgelt,
2218     ULONG *pceltFetched)
2219 {
2220     ULONG fetched;
2221     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2222     if (!pceltFetched) pceltFetched = &fetched;
2223     return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2224 }
2225
2226 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2227     IEnumUnknown* This,
2228     ULONG celt,
2229     IUnknown **rgelt,
2230     ULONG *pceltFetched)
2231 {
2232     HRESULT hr;
2233     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2234     *pceltFetched = 0;
2235     hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2236     if (hr == S_OK) *pceltFetched = celt;
2237     return hr;
2238 }
2239
2240 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2241     IBindCtx* This,
2242     BIND_OPTS *pbindopts)
2243 {
2244     FIXME(":stub\n");
2245     return E_NOTIMPL;
2246 }
2247
2248 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2249     IBindCtx* This,
2250     BIND_OPTS2 *pbindopts)
2251 {
2252     FIXME(":stub\n");
2253     return E_NOTIMPL;
2254 }
2255
2256 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2257     IBindCtx* This,
2258     BIND_OPTS *pbindopts)
2259 {
2260     FIXME(":stub\n");
2261     return E_NOTIMPL;
2262 }
2263
2264 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2265     IBindCtx* This,
2266     BIND_OPTS2 *pbindopts)
2267 {
2268     FIXME(":stub\n");
2269     return E_NOTIMPL;
2270 }
2271
2272 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2273     IEnumMoniker* This,
2274     ULONG celt,
2275     IMoniker **rgelt,
2276     ULONG *pceltFetched)
2277 {
2278     ULONG fetched;
2279     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2280     if (!pceltFetched) pceltFetched = &fetched;
2281     return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2282 }
2283
2284 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2285     IEnumMoniker* This,
2286     ULONG celt,
2287     IMoniker **rgelt,
2288     ULONG *pceltFetched)
2289 {
2290     HRESULT hr;
2291     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2292     *pceltFetched = 0;
2293     hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2294     if (hr == S_OK) *pceltFetched = celt;
2295     return hr;
2296 }
2297
2298 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2299     IRunnableObject* This)
2300 {
2301     BOOL rv;
2302     FIXME(":stub\n");
2303     memset(&rv, 0, sizeof rv);
2304     return rv;
2305 }
2306
2307 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2308     IRunnableObject* This)
2309 {
2310     FIXME(":stub\n");
2311     return E_NOTIMPL;
2312 }
2313
2314 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2315     IMoniker* This,
2316     IBindCtx *pbc,
2317     IMoniker *pmkToLeft,
2318     REFIID riidResult,
2319     void **ppvResult)
2320 {
2321     FIXME(":stub\n");
2322     return E_NOTIMPL;
2323 }
2324
2325 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2326     IMoniker* This,
2327     IBindCtx *pbc,
2328     IMoniker *pmkToLeft,
2329     REFIID riidResult,
2330     IUnknown **ppvResult)
2331 {
2332     FIXME(":stub\n");
2333     return E_NOTIMPL;
2334 }
2335
2336 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2337     IMoniker* This,
2338     IBindCtx *pbc,
2339     IMoniker *pmkToLeft,
2340     REFIID riid,
2341     void **ppvObj)
2342 {
2343     FIXME(":stub\n");
2344     return E_NOTIMPL;
2345 }
2346
2347 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2348     IMoniker* This,
2349     IBindCtx *pbc,
2350     IMoniker *pmkToLeft,
2351     REFIID riid,
2352     IUnknown **ppvObj)
2353 {
2354     FIXME(":stub\n");
2355     return E_NOTIMPL;
2356 }
2357
2358 HRESULT CALLBACK IEnumString_Next_Proxy(
2359     IEnumString* This,
2360     ULONG celt,
2361     LPOLESTR *rgelt,
2362     ULONG *pceltFetched)
2363 {
2364     ULONG fetched;
2365     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2366     if (!pceltFetched) pceltFetched = &fetched;
2367     return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2368 }
2369
2370 HRESULT __RPC_STUB IEnumString_Next_Stub(
2371     IEnumString* This,
2372     ULONG celt,
2373     LPOLESTR *rgelt,
2374     ULONG *pceltFetched)
2375 {
2376     HRESULT hr;
2377     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2378     *pceltFetched = 0;
2379     hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2380     if (hr == S_OK) *pceltFetched = celt;
2381     return hr;
2382 }
2383
2384 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2385     ISequentialStream* This,
2386     void *pv,
2387     ULONG cb,
2388     ULONG *pcbRead)
2389 {
2390     ULONG read;
2391     HRESULT hr;
2392
2393     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2394
2395     hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2396     if(pcbRead) *pcbRead = read;
2397
2398     return hr;
2399 }
2400
2401 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2402     ISequentialStream* This,
2403     byte *pv,
2404     ULONG cb,
2405     ULONG *pcbRead)
2406 {
2407     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2408     return ISequentialStream_Read(This, pv, cb, pcbRead);
2409 }
2410
2411 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2412     ISequentialStream* This,
2413     const void *pv,
2414     ULONG cb,
2415     ULONG *pcbWritten)
2416 {
2417     ULONG written;
2418     HRESULT hr;
2419
2420     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2421
2422     hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2423     if(pcbWritten) *pcbWritten = written;
2424
2425     return hr;
2426 }
2427
2428 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2429     ISequentialStream* This,
2430     const byte *pv,
2431     ULONG cb,
2432     ULONG *pcbWritten)
2433 {
2434     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2435     return ISequentialStream_Write(This, pv, cb, pcbWritten);
2436 }
2437
2438 HRESULT CALLBACK IStream_Seek_Proxy(
2439     IStream* This,
2440     LARGE_INTEGER dlibMove,
2441     DWORD dwOrigin,
2442     ULARGE_INTEGER *plibNewPosition)
2443 {
2444     ULARGE_INTEGER newpos;
2445     HRESULT hr;
2446
2447     TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2448
2449     hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2450     if(plibNewPosition) *plibNewPosition = newpos;
2451
2452     return hr;
2453 }
2454
2455 HRESULT __RPC_STUB IStream_Seek_Stub(
2456     IStream* This,
2457     LARGE_INTEGER dlibMove,
2458     DWORD dwOrigin,
2459     ULARGE_INTEGER *plibNewPosition)
2460 {
2461     TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2462     return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2463 }
2464
2465 HRESULT CALLBACK IStream_CopyTo_Proxy(
2466     IStream* This,
2467     IStream *pstm,
2468     ULARGE_INTEGER cb,
2469     ULARGE_INTEGER *pcbRead,
2470     ULARGE_INTEGER *pcbWritten)
2471 {
2472     ULARGE_INTEGER read, written;
2473     HRESULT hr;
2474
2475     TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2476
2477     hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2478     if(pcbRead) *pcbRead = read;
2479     if(pcbWritten) *pcbWritten = written;
2480
2481     return hr;
2482 }
2483
2484 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2485     IStream* This,
2486     IStream *pstm,
2487     ULARGE_INTEGER cb,
2488     ULARGE_INTEGER *pcbRead,
2489     ULARGE_INTEGER *pcbWritten)
2490 {
2491     TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2492
2493     return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2494 }
2495
2496 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2497     IEnumSTATSTG* This,
2498     ULONG celt,
2499     STATSTG *rgelt,
2500     ULONG *pceltFetched)
2501 {
2502     ULONG fetched;
2503     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2504     if (!pceltFetched) pceltFetched = &fetched;
2505     return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2506 }
2507
2508 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2509     IEnumSTATSTG* This,
2510     ULONG celt,
2511     STATSTG *rgelt,
2512     ULONG *pceltFetched)
2513 {
2514     HRESULT hr;
2515     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2516     *pceltFetched = 0;
2517     hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2518     if (hr == S_OK) *pceltFetched = celt;
2519     return hr;
2520 }
2521
2522 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2523     IStorage* This,
2524     LPCOLESTR pwcsName,
2525     void *reserved1,
2526     DWORD grfMode,
2527     DWORD reserved2,
2528     IStream **ppstm)
2529 {
2530     TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2531     if(reserved1) WARN("reserved1 %p\n", reserved1);
2532
2533     return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2534 }
2535
2536 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2537     IStorage* This,
2538     LPCOLESTR pwcsName,
2539     ULONG cbReserved1,
2540     byte *reserved1,
2541     DWORD grfMode,
2542     DWORD reserved2,
2543     IStream **ppstm)
2544 {
2545     TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2546     if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2547
2548     return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2549 }
2550
2551 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2552     IStorage* This,
2553     DWORD reserved1,
2554     void *reserved2,
2555     DWORD reserved3,
2556     IEnumSTATSTG **ppenum)
2557 {
2558     TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2559     if(reserved2) WARN("reserved2 %p\n", reserved2);
2560
2561     return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2562 }
2563
2564 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2565     IStorage* This,
2566     DWORD reserved1,
2567     ULONG cbReserved2,
2568     byte *reserved2,
2569     DWORD reserved3,
2570     IEnumSTATSTG **ppenum)
2571 {
2572     TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2573     if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2574
2575     return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2576 }
2577
2578 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2579     ILockBytes* This,
2580     ULARGE_INTEGER ulOffset,
2581     void *pv,
2582     ULONG cb,
2583     ULONG *pcbRead)
2584 {
2585     ULONG read;
2586     HRESULT hr;
2587
2588     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2589
2590     hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2591     if(pcbRead) *pcbRead = read;
2592
2593     return hr;
2594 }
2595
2596 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2597     ILockBytes* This,
2598     ULARGE_INTEGER ulOffset,
2599     byte *pv,
2600     ULONG cb,
2601     ULONG *pcbRead)
2602 {
2603     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2604     return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2605 }
2606
2607 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2608     ILockBytes* This,
2609     ULARGE_INTEGER ulOffset,
2610     const void *pv,
2611     ULONG cb,
2612     ULONG *pcbWritten)
2613 {
2614     ULONG written;
2615     HRESULT hr;
2616
2617     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2618
2619     hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2620     if(pcbWritten) *pcbWritten = written;
2621
2622     return hr;
2623 }
2624
2625 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2626     ILockBytes* This,
2627     ULARGE_INTEGER ulOffset,
2628     const byte *pv,
2629     ULONG cb,
2630     ULONG *pcbWritten)
2631 {
2632     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2633     return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2634 }
2635
2636 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2637     IFillLockBytes* This,
2638     const void *pv,
2639     ULONG cb,
2640     ULONG *pcbWritten)
2641 {
2642     ULONG written;
2643     HRESULT hr;
2644
2645     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2646
2647     hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2648     if(pcbWritten) *pcbWritten = written;
2649
2650     return hr;
2651 }
2652
2653 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2654     IFillLockBytes* This,
2655     const byte *pv,
2656     ULONG cb,
2657     ULONG *pcbWritten)
2658 {
2659     TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2660     return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2661 }
2662
2663 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2664     IFillLockBytes* This,
2665     ULARGE_INTEGER ulOffset,
2666     const void *pv,
2667     ULONG cb,
2668     ULONG *pcbWritten)
2669 {
2670     ULONG written;
2671     HRESULT hr;
2672
2673     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2674
2675     hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2676     if(pcbWritten) *pcbWritten = written;
2677
2678     return hr;
2679 }
2680
2681 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2682     IFillLockBytes* This,
2683     ULARGE_INTEGER ulOffset,
2684     const byte *pv,
2685     ULONG cb,
2686     ULONG *pcbWritten)
2687 {
2688     TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2689     return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2690 }
2691
2692 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2693     IEnumFORMATETC* This,
2694     ULONG celt,
2695     FORMATETC *rgelt,
2696     ULONG *pceltFetched)
2697 {
2698     ULONG fetched;
2699     if (!pceltFetched) pceltFetched = &fetched;
2700     return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2701 }
2702
2703 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2704     IEnumFORMATETC* This,
2705     ULONG celt,
2706     FORMATETC *rgelt,
2707     ULONG *pceltFetched)
2708 {
2709     HRESULT hr;
2710     *pceltFetched = 0;
2711     hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2712     if (hr == S_OK) *pceltFetched = celt;
2713     return hr;
2714 }
2715
2716 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2717     IEnumSTATDATA* This,
2718     ULONG celt,
2719     STATDATA *rgelt,
2720     ULONG *pceltFetched)
2721 {
2722     ULONG fetched;
2723     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2724     if (!pceltFetched) pceltFetched = &fetched;
2725     return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2726 }
2727
2728 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2729     IEnumSTATDATA* This,
2730     ULONG celt,
2731     STATDATA *rgelt,
2732     ULONG *pceltFetched)
2733 {
2734     HRESULT hr;
2735     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2736     *pceltFetched = 0;
2737     hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2738     if (hr == S_OK) *pceltFetched = celt;
2739     return hr;
2740 }
2741
2742 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2743     IAdviseSink* This,
2744     FORMATETC *pFormatetc,
2745     STGMEDIUM *pStgmed)
2746 {
2747     FIXME(":stub\n");
2748 }
2749
2750 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2751     IAdviseSink* This,
2752     FORMATETC *pFormatetc,
2753     ASYNC_STGMEDIUM *pStgmed)
2754 {
2755     FIXME(":stub\n");
2756     return E_NOTIMPL;
2757 }
2758
2759 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2760     IAdviseSink* This,
2761     DWORD dwAspect,
2762     LONG lindex)
2763 {
2764     FIXME(":stub\n");
2765 }
2766
2767 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2768     IAdviseSink* This,
2769     DWORD dwAspect,
2770     LONG lindex)
2771 {
2772     FIXME(":stub\n");
2773     return E_NOTIMPL;
2774 }
2775
2776 void CALLBACK IAdviseSink_OnRename_Proxy(
2777     IAdviseSink* This,
2778     IMoniker *pmk)
2779 {
2780     FIXME(":stub\n");
2781 }
2782
2783 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2784     IAdviseSink* This,
2785     IMoniker *pmk)
2786 {
2787     FIXME(":stub\n");
2788     return E_NOTIMPL;
2789 }
2790
2791 void CALLBACK IAdviseSink_OnSave_Proxy(
2792     IAdviseSink* This)
2793 {
2794     FIXME(":stub\n");
2795 }
2796
2797 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2798     IAdviseSink* This)
2799 {
2800     FIXME(":stub\n");
2801     return E_NOTIMPL;
2802 }
2803
2804 void CALLBACK IAdviseSink_OnClose_Proxy(
2805     IAdviseSink* This)
2806 {
2807     FIXME(":stub\n");
2808 }
2809
2810 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2811     IAdviseSink* This)
2812 {
2813     FIXME(":stub\n");
2814     return E_NOTIMPL;
2815 }
2816
2817 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2818     IAdviseSink2* This,
2819     IMoniker *pmk)
2820 {
2821     FIXME(":stub\n");
2822 }
2823
2824 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2825     IAdviseSink2* This,
2826     IMoniker *pmk)
2827 {
2828     FIXME(":stub\n");
2829     return E_NOTIMPL;
2830 }
2831
2832 HRESULT CALLBACK IDataObject_GetData_Proxy(
2833     IDataObject* This,
2834     FORMATETC *pformatetcIn,
2835     STGMEDIUM *pmedium)
2836 {
2837     TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2838     return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2839 }
2840
2841 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2842     IDataObject* This,
2843     FORMATETC *pformatetcIn,
2844     STGMEDIUM *pRemoteMedium)
2845 {
2846     TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2847     return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2848 }
2849
2850 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2851     IDataObject* This,
2852     FORMATETC *pformatetc,
2853     STGMEDIUM *pmedium)
2854 {
2855     TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2856     return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2857 }
2858
2859 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2860     IDataObject* This,
2861     FORMATETC *pformatetc,
2862     STGMEDIUM *pRemoteMedium)
2863 {
2864     TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2865     return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2866 }
2867
2868 HRESULT CALLBACK IDataObject_SetData_Proxy(
2869     IDataObject* This,
2870     FORMATETC *pformatetc,
2871     STGMEDIUM *pmedium,
2872     BOOL fRelease)
2873 {
2874     FIXME(":stub\n");
2875     return E_NOTIMPL;
2876 }
2877
2878 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2879     IDataObject* This,
2880     FORMATETC *pformatetc,
2881     FLAG_STGMEDIUM *pmedium,
2882     BOOL fRelease)
2883 {
2884     FIXME(":stub\n");
2885     return E_NOTIMPL;
2886 }
2887
2888 /* call_as/local stubs for oleidl.idl */
2889
2890 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2891     IOleInPlaceActiveObject* This,
2892     LPMSG lpmsg)
2893 {
2894     FIXME(":stub\n");
2895     return E_NOTIMPL;
2896 }
2897
2898 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2899     IOleInPlaceActiveObject* This)
2900 {
2901     FIXME(":stub\n");
2902     return E_NOTIMPL;
2903 }
2904
2905 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2906     IOleInPlaceActiveObject* This,
2907     LPCRECT prcBorder,
2908     IOleInPlaceUIWindow *pUIWindow,
2909     BOOL fFrameWindow)
2910 {
2911     FIXME(":stub\n");
2912     return E_NOTIMPL;
2913 }
2914
2915 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2916     IOleInPlaceActiveObject* This,
2917     LPCRECT prcBorder,
2918     REFIID riid,
2919     IOleInPlaceUIWindow *pUIWindow,
2920     BOOL fFrameWindow)
2921 {
2922     FIXME(":stub\n");
2923     return E_NOTIMPL;
2924 }
2925
2926 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2927     IOleCache2* This,
2928     LPDATAOBJECT pDataObject,
2929     DWORD grfUpdf,
2930     LPVOID pReserved)
2931 {
2932     FIXME(":stub\n");
2933     return E_NOTIMPL;
2934 }
2935
2936 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2937     IOleCache2* This,
2938     LPDATAOBJECT pDataObject,
2939     DWORD grfUpdf,
2940     LONG_PTR pReserved)
2941 {
2942     FIXME(":stub\n");
2943     return E_NOTIMPL;
2944 }
2945
2946 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2947     IEnumOLEVERB* This,
2948     ULONG celt,
2949     LPOLEVERB rgelt,
2950     ULONG *pceltFetched)
2951 {
2952     ULONG fetched;
2953     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2954     if (!pceltFetched) pceltFetched = &fetched;
2955     return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2956 }
2957
2958 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2959     IEnumOLEVERB* This,
2960     ULONG celt,
2961     LPOLEVERB rgelt,
2962     ULONG *pceltFetched)
2963 {
2964     HRESULT hr;
2965     TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2966     *pceltFetched = 0;
2967     hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2968     if (hr == S_OK) *pceltFetched = celt;
2969     return hr;
2970 }
2971
2972 HRESULT CALLBACK IViewObject_Draw_Proxy(
2973     IViewObject* This,
2974     DWORD dwDrawAspect,
2975     LONG lindex,
2976     void *pvAspect,
2977     DVTARGETDEVICE *ptd,
2978     HDC hdcTargetDev,
2979     HDC hdcDraw,
2980     LPCRECTL lprcBounds,
2981     LPCRECTL lprcWBounds,
2982     BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
2983     ULONG_PTR dwContinue)
2984 {
2985     FIXME(":stub\n");
2986     return E_NOTIMPL;
2987 }
2988
2989 HRESULT __RPC_STUB IViewObject_Draw_Stub(
2990     IViewObject* This,
2991     DWORD dwDrawAspect,
2992     LONG lindex,
2993     ULONG_PTR pvAspect,
2994     DVTARGETDEVICE *ptd,
2995     ULONG_PTR hdcTargetDev,
2996     ULONG_PTR hdcDraw,
2997     LPCRECTL lprcBounds,
2998     LPCRECTL lprcWBounds,
2999     IContinue *pContinue)
3000 {
3001     FIXME(":stub\n");
3002     return E_NOTIMPL;
3003 }
3004
3005 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3006     IViewObject* This,
3007     DWORD dwDrawAspect,
3008     LONG lindex,
3009     void *pvAspect,
3010     DVTARGETDEVICE *ptd,
3011     HDC hicTargetDev,
3012     LOGPALETTE **ppColorSet)
3013 {
3014     FIXME(":stub\n");
3015     return E_NOTIMPL;
3016 }
3017
3018 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3019     IViewObject* This,
3020     DWORD dwDrawAspect,
3021     LONG lindex,
3022     ULONG_PTR pvAspect,
3023     DVTARGETDEVICE *ptd,
3024     ULONG_PTR hicTargetDev,
3025     LOGPALETTE **ppColorSet)
3026 {
3027     FIXME(":stub\n");
3028     return E_NOTIMPL;
3029 }
3030
3031 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3032     IViewObject* This,
3033     DWORD dwDrawAspect,
3034     LONG lindex,
3035     void *pvAspect,
3036     DWORD *pdwFreeze)
3037 {
3038     FIXME(":stub\n");
3039     return E_NOTIMPL;
3040 }
3041
3042 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3043     IViewObject* This,
3044     DWORD dwDrawAspect,
3045     LONG lindex,
3046     ULONG_PTR pvAspect,
3047     DWORD *pdwFreeze)
3048 {
3049     FIXME(":stub\n");
3050     return E_NOTIMPL;
3051 }
3052
3053 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3054     IViewObject* This,
3055     DWORD *pAspects,
3056     DWORD *pAdvf,
3057     IAdviseSink **ppAdvSink)
3058 {
3059     FIXME(":stub\n");
3060     return E_NOTIMPL;
3061 }
3062
3063 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3064     IViewObject* This,
3065     DWORD *pAspects,
3066     DWORD *pAdvf,
3067     IAdviseSink **ppAdvSink)
3068 {
3069     FIXME(":stub\n");
3070     return E_NOTIMPL;
3071 }