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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 unsigned long __RPC_USER HGLOBAL_UserSize(unsigned long *pFlags, unsigned long StartingSize, HGLOBAL *phGlobal)
313 unsigned long size = StartingSize;
315 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, phGlobal);
317 ALIGN_LENGTH(size, 3);
319 size += sizeof(ULONG);
321 if (LOWORD(*pFlags == MSHCTX_INPROC))
322 size += sizeof(HGLOBAL);
325 size += sizeof(ULONG);
329 size += 3 * sizeof(ULONG);
330 ret = GlobalSize(*phGlobal);
331 size += (unsigned long)ret;
338 unsigned char * __RPC_USER HGLOBAL_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
340 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phGlobal);
342 ALIGN_POINTER(pBuffer, 3);
344 if (LOWORD(*pFlags == MSHCTX_INPROC))
346 if (sizeof(*phGlobal) == 8)
347 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
349 *(ULONG *)pBuffer = WDT_INPROC_CALL;
350 pBuffer += sizeof(ULONG);
351 *(HGLOBAL *)pBuffer = *phGlobal;
352 pBuffer += sizeof(HGLOBAL);
356 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
357 pBuffer += sizeof(ULONG);
358 *(ULONG *)pBuffer = (ULONG)*phGlobal;
359 pBuffer += sizeof(ULONG);
362 const unsigned char *memory;
363 SIZE_T size = GlobalSize(*phGlobal);
364 *(ULONG *)pBuffer = (ULONG)size;
365 pBuffer += sizeof(ULONG);
366 *(ULONG *)pBuffer = (ULONG)*phGlobal;
367 pBuffer += sizeof(ULONG);
368 *(ULONG *)pBuffer = (ULONG)size;
369 pBuffer += sizeof(ULONG);
371 memory = GlobalLock(*phGlobal);
372 memcpy(pBuffer, memory, size);
374 GlobalUnlock(*phGlobal);
381 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
385 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phGlobal);
387 ALIGN_POINTER(pBuffer, 3);
389 fContext = *(ULONG *)pBuffer;
390 pBuffer += sizeof(ULONG);
392 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
393 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
395 *phGlobal = *(HGLOBAL *)pBuffer;
396 pBuffer += sizeof(*phGlobal);
398 else if (fContext == WDT_REMOTE_CALL)
402 handle = *(ULONG *)pBuffer;
403 pBuffer += sizeof(ULONG);
410 size = *(ULONG *)pBuffer;
411 pBuffer += sizeof(ULONG);
412 /* redundancy is bad - it means you have to check consistency like
414 if (*(ULONG *)pBuffer != handle)
416 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
419 pBuffer += sizeof(ULONG);
420 /* redundancy is bad - it means you have to check consistency like
422 if (*(ULONG *)pBuffer != size)
424 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
427 pBuffer += sizeof(ULONG);
429 /* FIXME: check size is not too big */
431 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
432 memory = GlobalLock(*phGlobal);
433 memcpy(memory, pBuffer, size);
435 GlobalUnlock(*phGlobal);
441 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
446 void __RPC_USER HGLOBAL_UserFree(unsigned long *pFlags, HGLOBAL *phGlobal)
448 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *phGlobal);
450 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
451 GlobalFree(*phGlobal);
454 unsigned long __RPC_USER HBITMAP_UserSize(unsigned long *pFlags, unsigned long StartingSize, HBITMAP *phBmp)
460 unsigned char * __RPC_USER HBITMAP_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
466 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
472 void __RPC_USER HBITMAP_UserFree(unsigned long *pFlags, HBITMAP *phBmp)
477 unsigned long __RPC_USER HDC_UserSize(unsigned long *pFlags, unsigned long StartingSize, HDC *phdc)
483 unsigned char * __RPC_USER HDC_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HDC *phdc)
489 unsigned char * __RPC_USER HDC_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HDC *phdc)
495 void __RPC_USER HDC_UserFree(unsigned long *pFlags, HDC *phdc)
500 unsigned long __RPC_USER HPALETTE_UserSize(unsigned long *pFlags, unsigned long StartingSize, HPALETTE *phPal)
506 unsigned char * __RPC_USER HPALETTE_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
512 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
518 void __RPC_USER HPALETTE_UserFree(unsigned long *pFlags, HPALETTE *phPal)
524 unsigned long __RPC_USER HENHMETAFILE_UserSize(unsigned long *pFlags, unsigned long StartingSize, HENHMETAFILE *phEmf)
526 unsigned long size = StartingSize;
528 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, *phEmf);
530 size += sizeof(ULONG);
531 if (LOWORD(*pFlags) == MSHCTX_INPROC)
532 size += sizeof(ULONG_PTR);
535 size += sizeof(ULONG);
541 size += 2 * sizeof(ULONG);
542 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
550 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
552 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", pBuffer, *phEmf);
554 if (LOWORD(*pFlags) == MSHCTX_INPROC)
556 if (sizeof(*phEmf) == 8)
557 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
559 *(ULONG *)pBuffer = WDT_INPROC_CALL;
560 pBuffer += sizeof(ULONG);
561 *(HENHMETAFILE *)pBuffer = *phEmf;
562 pBuffer += sizeof(HENHMETAFILE);
566 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
567 pBuffer += sizeof(ULONG);
568 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
569 pBuffer += sizeof(ULONG);
573 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
575 *(ULONG *)pBuffer = emfsize;
576 pBuffer += sizeof(ULONG);
577 *(ULONG *)pBuffer = emfsize;
578 pBuffer += sizeof(ULONG);
579 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
587 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
591 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, phEmf);
593 fContext = *(ULONG *)pBuffer;
594 pBuffer += sizeof(ULONG);
596 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
597 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
599 *phEmf = *(HENHMETAFILE *)pBuffer;
600 pBuffer += sizeof(*phEmf);
602 else if (fContext == WDT_REMOTE_CALL)
606 handle = *(ULONG *)pBuffer;
607 pBuffer += sizeof(ULONG);
612 size = *(ULONG *)pBuffer;
613 pBuffer += sizeof(ULONG);
614 if (size != *(ULONG *)pBuffer)
616 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
619 pBuffer += sizeof(ULONG);
620 *phEmf = SetEnhMetaFileBits(size, pBuffer);
627 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
632 void __RPC_USER HENHMETAFILE_UserFree(unsigned long *pFlags, HENHMETAFILE *phEmf)
634 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *phEmf);
636 if (LOWORD(*pFlags) != MSHCTX_INPROC)
637 DeleteEnhMetaFile(*phEmf);
640 unsigned long __RPC_USER STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, STGMEDIUM *pStgMedium)
642 unsigned long size = StartingSize;
644 TRACE("("); dump_user_flags(pFlags); TRACE(", %ld, %p\n", StartingSize, pStgMedium);
646 ALIGN_LENGTH(size, 3);
648 size += 2 * sizeof(DWORD);
649 if (pStgMedium->tymed != TYMED_NULL)
650 size += sizeof(DWORD);
652 switch (pStgMedium->tymed)
655 TRACE("TYMED_NULL\n");
658 TRACE("TYMED_HGLOBAL\n");
659 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
662 FIXME("TYMED_FILE\n");
665 FIXME("TYMED_ISTREAM\n");
668 FIXME("TYMED_ISTORAGE\n");
671 FIXME("TYMED_GDI\n");
674 FIXME("TYMED_MFPICT\n");
677 TRACE("TYMED_ENHMF\n");
678 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
681 RaiseException(DV_E_TYMED, 0, 0, NULL);
684 if (pStgMedium->pUnkForRelease)
685 FIXME("buffer size pUnkForRelease\n");
690 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(unsigned long *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
692 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, pStgMedium);
694 ALIGN_POINTER(pBuffer, 3);
696 *(DWORD *)pBuffer = pStgMedium->tymed;
697 pBuffer += sizeof(DWORD);
698 if (pStgMedium->tymed != TYMED_NULL)
700 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
701 pBuffer += sizeof(DWORD);
703 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
704 pBuffer += sizeof(DWORD);
706 switch (pStgMedium->tymed)
709 TRACE("TYMED_NULL\n");
712 TRACE("TYMED_HGLOBAL\n");
713 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
716 FIXME("TYMED_FILE\n");
719 FIXME("TYMED_ISTREAM\n");
722 FIXME("TYMED_ISTORAGE\n");
725 FIXME("TYMED_GDI\n");
728 FIXME("TYMED_MFPICT\n");
731 TRACE("TYMED_ENHMF\n");
732 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
735 RaiseException(DV_E_TYMED, 0, 0, NULL);
738 if (pStgMedium->pUnkForRelease)
739 FIXME("marshal pUnkForRelease\n");
744 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
749 ALIGN_POINTER(pBuffer, 3);
751 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", pBuffer, pStgMedium);
753 pStgMedium->tymed = *(DWORD *)pBuffer;
754 pBuffer += sizeof(DWORD);
755 if (pStgMedium->tymed != TYMED_NULL)
757 content = *(DWORD *)pBuffer;
758 pBuffer += sizeof(DWORD);
760 releaseunk = *(DWORD *)pBuffer;
761 pBuffer += sizeof(DWORD);
763 switch (pStgMedium->tymed)
766 TRACE("TYMED_NULL\n");
769 TRACE("TYMED_HGLOBAL\n");
770 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
773 FIXME("TYMED_FILE\n");
776 FIXME("TYMED_ISTREAM\n");
779 FIXME("TYMED_ISTORAGE\n");
782 FIXME("TYMED_GDI\n");
785 FIXME("TYMED_MFPICT\n");
788 TRACE("TYMED_ENHMF\n");
789 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
792 RaiseException(DV_E_TYMED, 0, 0, NULL);
795 pStgMedium->pUnkForRelease = NULL;
797 FIXME("unmarshal pUnkForRelease\n");
802 void __RPC_USER STGMEDIUM_UserFree(unsigned long *pFlags, STGMEDIUM *pStgMedium)
804 TRACE("("); dump_user_flags(pFlags); TRACE(", %p\n", pStgMedium);
806 ReleaseStgMedium(pStgMedium);
809 unsigned long __RPC_USER ASYNC_STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, ASYNC_STGMEDIUM *pStgMedium)
815 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
821 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
827 void __RPC_USER ASYNC_STGMEDIUM_UserFree(unsigned long *pFlags, ASYNC_STGMEDIUM *pStgMedium)
832 unsigned long __RPC_USER FLAG_STGMEDIUM_UserSize(unsigned long *pFlags, unsigned long StartingSize, FLAG_STGMEDIUM *pStgMedium)
838 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
844 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
850 void __RPC_USER FLAG_STGMEDIUM_UserFree(unsigned long *pFlags, FLAG_STGMEDIUM *pStgMedium)
855 unsigned long __RPC_USER SNB_UserSize(unsigned long *pFlags, unsigned long StartingSize, SNB *pSnb)
861 unsigned char * __RPC_USER SNB_UserMarshal( unsigned long *pFlags, unsigned char *pBuffer, SNB *pSnb)
867 unsigned char * __RPC_USER SNB_UserUnmarshal(unsigned long *pFlags, unsigned char *pBuffer, SNB *pSnb)
873 void __RPC_USER SNB_UserFree(unsigned long *pFlags, SNB *pSnb)