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