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