2 * Miscellaneous Marshaling Routines
4 * Copyright 2005 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(ole);
41 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
42 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
43 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
44 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
46 static void dump_user_flags(unsigned long *pFlags)
48 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
49 TRACE("MAKELONG(NDR_LOCAL_REPRESENTATION, ");
51 TRACE("MAKELONG(0x%04x, ", HIWORD(*pFlags));
52 switch (LOWORD(*pFlags))
54 case MSHCTX_LOCAL: TRACE("MSHCTX_LOCAL)"); break;
55 case MSHCTX_NOSHAREDMEM: TRACE("MSHCTX_NOSHAREDMEM)"); break;
56 case MSHCTX_DIFFERENTMACHINE: TRACE("MSHCTX_DIFFERENTMACHINE)"); break;
57 case MSHCTX_INPROC: TRACE("MSHCTX_INPROC)"); break;
58 default: TRACE("%d)", LOWORD(*pFlags));
62 /******************************************************************************
63 * CLIPFORMAT_UserSize [OLE32.@]
65 * Calculates the buffer size required to marshal a clip format.
68 * pFlags [I] Flags. See notes.
69 * StartingSize [I] Starting size of the buffer. This value is added on to
70 * the buffer size required for the clip format.
71 * pCF [I] Clip format to size.
74 * The buffer size required to marshal a clip format plus the starting size.
77 * Even though the function is documented to take a pointer to an unsigned
78 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
79 * the first parameter is an unsigned long.
80 * This function is only intended to be called by the RPC runtime.
82 unsigned long __RPC_USER CLIPFORMAT_UserSize(unsigned long *pFlags, unsigned long StartingSize, CLIPFORMAT *pCF)
84 unsigned long size = StartingSize;
86 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, pCF);
88 size += sizeof(userCLIPFORMAT);
90 /* only need to marshal the name if it is not a pre-defined type and
91 * we are going remote */
92 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
96 size += 3 * sizeof(INT);
97 /* urg! this function is badly designed because it won't tell us how
98 * much space is needed without doing a dummy run of storing the
99 * name into a buffer */
100 ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
102 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
103 size += (ret + 1) * sizeof(WCHAR);
108 /******************************************************************************
109 * CLIPFORMAT_UserMarshal [OLE32.@]
111 * Marshals a clip format into a buffer.
114 * pFlags [I] Flags. See notes.
115 * pBuffer [I] Buffer to marshal the clip format into.
116 * pCF [I] Clip format to marshal.
119 * The end of the marshaled data in the buffer.
122 * Even though the function is documented to take a pointer to an unsigned
123 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
124 * the first parameter is an unsigned long.
125 * This function is only intended to be called by the RPC runtime.
127 unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
129 wireCLIPFORMAT wirecf = (wireCLIPFORMAT)pBuffer;
131 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &0x%04x\n", pBuffer, *pCF);
133 wirecf->u.dwValue = *pCF;
134 pBuffer += sizeof(*wirecf);
136 /* only need to marshal the name if it is not a pre-defined type and
137 * we are going remote */
138 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
142 wirecf->fContext = WDT_REMOTE_CALL;
143 len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
145 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
147 *(INT *)pBuffer = len;
148 pBuffer += sizeof(INT);
150 pBuffer += sizeof(INT);
151 *(INT *)pBuffer = len;
152 pBuffer += sizeof(INT);
153 TRACE("marshaling format name %s\n", debugstr_wn(format, len-1));
154 lstrcpynW((LPWSTR)pBuffer, format, len);
155 pBuffer += len * sizeof(WCHAR);
156 *(WCHAR *)pBuffer = '\0';
157 pBuffer += sizeof(WCHAR);
160 wirecf->fContext = WDT_INPROC_CALL;
165 /******************************************************************************
166 * CLIPFORMAT_UserUnmarshal [OLE32.@]
168 * Unmarshals a clip format from a buffer.
171 * pFlags [I] Flags. See notes.
172 * pBuffer [I] Buffer to marshal the clip format from.
173 * pCF [O] Address that receive the unmarshaled clip format.
176 * The end of the marshaled data in the buffer.
179 * Even though the function is documented to take a pointer to an unsigned
180 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
181 * the first parameter is an unsigned long.
182 * This function is only intended to be called by the RPC runtime.
184 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
186 wireCLIPFORMAT wirecf = (wireCLIPFORMAT)pBuffer;
188 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, pCF);
190 pBuffer += sizeof(*wirecf);
191 if (wirecf->fContext == WDT_INPROC_CALL)
192 *pCF = (CLIPFORMAT)wirecf->u.dwValue;
193 else if (wirecf->fContext == WDT_REMOTE_CALL)
196 INT len = *(INT *)pBuffer;
197 pBuffer += sizeof(INT);
198 if (*(INT *)pBuffer != 0)
199 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
200 pBuffer += sizeof(INT);
201 if (*(INT *)pBuffer != len)
202 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
203 pBuffer += sizeof(INT);
204 if (((WCHAR *)pBuffer)[len] != '\0')
205 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
206 TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
207 cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
208 pBuffer += (len + 1) * sizeof(WCHAR);
210 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
214 /* code not really appropriate, but nearest I can find */
215 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
219 /******************************************************************************
220 * CLIPFORMAT_UserFree [OLE32.@]
222 * Frees an unmarshaled clip format.
225 * pFlags [I] Flags. See notes.
226 * pCF [I] Clip format to free.
229 * The end of the marshaled data in the buffer.
232 * Even though the function is documented to take a pointer to an unsigned
233 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
234 * structure, of which the first parameter is an unsigned long.
235 * This function is only intended to be called by the RPC runtime.
237 void __RPC_USER CLIPFORMAT_UserFree(unsigned long *pFlags, CLIPFORMAT *pCF)
239 /* there is no inverse of the RegisterClipboardFormat function,
240 * so nothing to do */
243 static unsigned long __RPC_USER handle_UserSize(unsigned long *pFlags, unsigned long StartingSize, HANDLE *handle)
245 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
247 ERR("can't remote a local handle\n");
248 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
251 return StartingSize + sizeof(RemotableHandle);
254 static unsigned char * __RPC_USER handle_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HANDLE *handle)
256 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
257 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
259 ERR("can't remote a local handle\n");
260 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
263 remhandle->fContext = WDT_INPROC_CALL;
264 remhandle->u.hInproc = (LONG_PTR)*handle;
265 return pBuffer + sizeof(RemotableHandle);
268 static unsigned char * __RPC_USER handle_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HANDLE *handle)
270 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
271 if (remhandle->fContext != WDT_INPROC_CALL)
272 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
273 *handle = (HANDLE)remhandle->u.hInproc;
274 return pBuffer + sizeof(RemotableHandle);
277 static void __RPC_USER handle_UserFree(unsigned long *pFlags, HANDLE *phMenu)
282 #define IMPL_WIREM_HANDLE(type) \
283 unsigned long __RPC_USER type##_UserSize(unsigned long *pFlags, unsigned long StartingSize, type *handle) \
285 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, handle); \
286 return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
289 unsigned char * __RPC_USER type##_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, type *handle) \
291 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *handle); \
292 return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
295 unsigned char * __RPC_USER type##_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, type *handle) \
297 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, handle); \
298 return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
301 void __RPC_USER type##_UserFree(unsigned long *pFlags, type *handle) \
303 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *handle); \
304 return handle_UserFree(pFlags, (HANDLE *)handle); \
307 IMPL_WIREM_HANDLE(HACCEL)
308 IMPL_WIREM_HANDLE(HMENU)
309 IMPL_WIREM_HANDLE(HWND)
311 /******************************************************************************
312 * HGLOBAL_UserSize [OLE32.@]
314 unsigned long __RPC_USER HGLOBAL_UserSize(unsigned long *pFlags, unsigned long StartingSize, HGLOBAL *phGlobal)
316 unsigned long size = StartingSize;
318 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, phGlobal);
320 ALIGN_LENGTH(size, 3);
322 size += sizeof(ULONG);
324 if (LOWORD(*pFlags == MSHCTX_INPROC))
325 size += sizeof(HGLOBAL);
328 size += sizeof(ULONG);
332 size += 3 * sizeof(ULONG);
333 ret = GlobalSize(*phGlobal);
334 size += (unsigned long)ret;
341 unsigned char * __RPC_USER HGLOBAL_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
343 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phGlobal);
345 ALIGN_POINTER(pBuffer, 3);
347 if (LOWORD(*pFlags == MSHCTX_INPROC))
349 if (sizeof(*phGlobal) == 8)
350 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
352 *(ULONG *)pBuffer = WDT_INPROC_CALL;
353 pBuffer += sizeof(ULONG);
354 *(HGLOBAL *)pBuffer = *phGlobal;
355 pBuffer += sizeof(HGLOBAL);
359 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
360 pBuffer += sizeof(ULONG);
361 *(ULONG *)pBuffer = (ULONG)*phGlobal;
362 pBuffer += sizeof(ULONG);
365 const unsigned char *memory;
366 SIZE_T size = GlobalSize(*phGlobal);
367 *(ULONG *)pBuffer = (ULONG)size;
368 pBuffer += sizeof(ULONG);
369 *(ULONG *)pBuffer = (ULONG)*phGlobal;
370 pBuffer += sizeof(ULONG);
371 *(ULONG *)pBuffer = (ULONG)size;
372 pBuffer += sizeof(ULONG);
374 memory = GlobalLock(*phGlobal);
375 memcpy(pBuffer, memory, size);
377 GlobalUnlock(*phGlobal);
384 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
388 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phGlobal);
390 ALIGN_POINTER(pBuffer, 3);
392 fContext = *(ULONG *)pBuffer;
393 pBuffer += sizeof(ULONG);
395 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
396 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
398 *phGlobal = *(HGLOBAL *)pBuffer;
399 pBuffer += sizeof(*phGlobal);
401 else if (fContext == WDT_REMOTE_CALL)
405 handle = *(ULONG *)pBuffer;
406 pBuffer += sizeof(ULONG);
413 size = *(ULONG *)pBuffer;
414 pBuffer += sizeof(ULONG);
415 /* redundancy is bad - it means you have to check consistency like
417 if (*(ULONG *)pBuffer != handle)
419 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
422 pBuffer += sizeof(ULONG);
423 /* redundancy is bad - it means you have to check consistency like
425 if (*(ULONG *)pBuffer != size)
427 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
430 pBuffer += sizeof(ULONG);
432 /* FIXME: check size is not too big */
434 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
435 memory = GlobalLock(*phGlobal);
436 memcpy(memory, pBuffer, size);
438 GlobalUnlock(*phGlobal);
444 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
449 /******************************************************************************
450 * HGLOBAL_UserFree [OLE32.@]
452 void __RPC_USER HGLOBAL_UserFree(unsigned long *pFlags, HGLOBAL *phGlobal)
454 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *phGlobal);
456 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
457 GlobalFree(*phGlobal);
460 unsigned long __RPC_USER HBITMAP_UserSize(unsigned long *pFlags, unsigned long StartingSize, HBITMAP *phBmp)
466 unsigned char * __RPC_USER HBITMAP_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
472 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
478 void __RPC_USER HBITMAP_UserFree(unsigned long *pFlags, HBITMAP *phBmp)
483 unsigned long __RPC_USER HDC_UserSize(unsigned long *pFlags, unsigned long StartingSize, HDC *phdc)
489 unsigned char * __RPC_USER HDC_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HDC *phdc)
495 unsigned char * __RPC_USER HDC_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HDC *phdc)
501 void __RPC_USER HDC_UserFree(unsigned long *pFlags, HDC *phdc)
506 unsigned long __RPC_USER HPALETTE_UserSize(unsigned long *pFlags, unsigned long StartingSize, HPALETTE *phPal)
512 unsigned char * __RPC_USER HPALETTE_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
518 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
524 void __RPC_USER HPALETTE_UserFree(unsigned long *pFlags, HPALETTE *phPal)
530 unsigned long __RPC_USER HENHMETAFILE_UserSize(unsigned long *pFlags, unsigned long StartingSize, HENHMETAFILE *phEmf)
532 unsigned long size = StartingSize;
534 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, *phEmf);
536 size += sizeof(ULONG);
537 if (LOWORD(*pFlags) == MSHCTX_INPROC)
538 size += sizeof(ULONG_PTR);
541 size += sizeof(ULONG);
547 size += 2 * sizeof(ULONG);
548 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
556 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
558 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phEmf);
560 if (LOWORD(*pFlags) == MSHCTX_INPROC)
562 if (sizeof(*phEmf) == 8)
563 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
565 *(ULONG *)pBuffer = WDT_INPROC_CALL;
566 pBuffer += sizeof(ULONG);
567 *(HENHMETAFILE *)pBuffer = *phEmf;
568 pBuffer += sizeof(HENHMETAFILE);
572 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
573 pBuffer += sizeof(ULONG);
574 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
575 pBuffer += sizeof(ULONG);
579 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
581 *(ULONG *)pBuffer = emfsize;
582 pBuffer += sizeof(ULONG);
583 *(ULONG *)pBuffer = emfsize;
584 pBuffer += sizeof(ULONG);
585 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
593 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
597 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, phEmf);
599 fContext = *(ULONG *)pBuffer;
600 pBuffer += sizeof(ULONG);
602 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
603 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
605 *phEmf = *(HENHMETAFILE *)pBuffer;
606 pBuffer += sizeof(*phEmf);
608 else if (fContext == WDT_REMOTE_CALL)
612 handle = *(ULONG *)pBuffer;
613 pBuffer += sizeof(ULONG);
618 size = *(ULONG *)pBuffer;
619 pBuffer += sizeof(ULONG);
620 if (size != *(ULONG *)pBuffer)
622 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
625 pBuffer += sizeof(ULONG);
626 *phEmf = SetEnhMetaFileBits(size, pBuffer);
633 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
638 void __RPC_USER HENHMETAFILE_UserFree(unsigned long *pFlags, HENHMETAFILE *phEmf)
640 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *phEmf);
642 if (LOWORD(*pFlags) != MSHCTX_INPROC)
643 DeleteEnhMetaFile(*phEmf);
646 unsigned long __RPC_USER STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, STGMEDIUM *pStgMedium)
648 unsigned long size = StartingSize;
650 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, pStgMedium);
652 ALIGN_LENGTH(size, 3);
654 size += 2 * sizeof(DWORD);
655 if (pStgMedium->tymed != TYMED_NULL)
656 size += sizeof(DWORD);
658 switch (pStgMedium->tymed)
661 TRACE("TYMED_NULL\n");
664 TRACE("TYMED_HGLOBAL\n");
665 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
668 FIXME("TYMED_FILE\n");
671 FIXME("TYMED_ISTREAM\n");
674 FIXME("TYMED_ISTORAGE\n");
677 FIXME("TYMED_GDI\n");
680 FIXME("TYMED_MFPICT\n");
683 TRACE("TYMED_ENHMF\n");
684 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
687 RaiseException(DV_E_TYMED, 0, 0, NULL);
690 if (pStgMedium->pUnkForRelease)
691 FIXME("buffer size pUnkForRelease\n");
696 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
698 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, pStgMedium);
700 ALIGN_POINTER(pBuffer, 3);
702 *(DWORD *)pBuffer = pStgMedium->tymed;
703 pBuffer += sizeof(DWORD);
704 if (pStgMedium->tymed != TYMED_NULL)
706 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
707 pBuffer += sizeof(DWORD);
709 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
710 pBuffer += sizeof(DWORD);
712 switch (pStgMedium->tymed)
715 TRACE("TYMED_NULL\n");
718 TRACE("TYMED_HGLOBAL\n");
719 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
722 FIXME("TYMED_FILE\n");
725 FIXME("TYMED_ISTREAM\n");
728 FIXME("TYMED_ISTORAGE\n");
731 FIXME("TYMED_GDI\n");
734 FIXME("TYMED_MFPICT\n");
737 TRACE("TYMED_ENHMF\n");
738 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
741 RaiseException(DV_E_TYMED, 0, 0, NULL);
744 if (pStgMedium->pUnkForRelease)
745 FIXME("marshal pUnkForRelease\n");
750 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
755 ALIGN_POINTER(pBuffer, 3);
757 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, pStgMedium);
759 pStgMedium->tymed = *(DWORD *)pBuffer;
760 pBuffer += sizeof(DWORD);
761 if (pStgMedium->tymed != TYMED_NULL)
763 content = *(DWORD *)pBuffer;
764 pBuffer += sizeof(DWORD);
766 releaseunk = *(DWORD *)pBuffer;
767 pBuffer += sizeof(DWORD);
769 switch (pStgMedium->tymed)
772 TRACE("TYMED_NULL\n");
775 TRACE("TYMED_HGLOBAL\n");
776 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
779 FIXME("TYMED_FILE\n");
782 FIXME("TYMED_ISTREAM\n");
785 FIXME("TYMED_ISTORAGE\n");
788 FIXME("TYMED_GDI\n");
791 FIXME("TYMED_MFPICT\n");
794 TRACE("TYMED_ENHMF\n");
795 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
798 RaiseException(DV_E_TYMED, 0, 0, NULL);
801 pStgMedium->pUnkForRelease = NULL;
803 FIXME("unmarshal pUnkForRelease\n");
808 void __RPC_USER STGMEDIUM_UserFree(unsigned long *pFlags, STGMEDIUM *pStgMedium)
810 TRACE("("); dump_user_flags(pFlags); TRACE(", %p\n", pStgMedium);
812 ReleaseStgMedium(pStgMedium);
815 unsigned long __RPC_USER ASYNC_STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, ASYNC_STGMEDIUM *pStgMedium)
821 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
827 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
833 void __RPC_USER ASYNC_STGMEDIUM_UserFree(unsigned long *pFlags, ASYNC_STGMEDIUM *pStgMedium)
838 unsigned long __RPC_USER FLAG_STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, FLAG_STGMEDIUM *pStgMedium)
844 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
850 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
856 void __RPC_USER FLAG_STGMEDIUM_UserFree(unsigned long *pFlags, FLAG_STGMEDIUM *pStgMedium)
861 unsigned long __RPC_USER SNB_UserSize(unsigned long *pFlags, unsigned long StartingSize, SNB *pSnb)
867 unsigned char * __RPC_USER SNB_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, SNB *pSnb)
873 unsigned char * __RPC_USER SNB_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, SNB *pSnb)
879 void __RPC_USER SNB_UserFree(unsigned long *pFlags, SNB *pSnb)