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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
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)
49 #define USER_MARSHAL_PTR_PREFIX \
50 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
51 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
53 static const char* debugstr_user_flags(ULONG *pFlags)
57 switch (LOWORD(*pFlags))
60 loword="MSHCTX_LOCAL";
62 case MSHCTX_NOSHAREDMEM:
63 loword="MSHCTX_NOSHAREDMEM";
65 case MSHCTX_DIFFERENTMACHINE:
66 loword="MSHCTX_DIFFERENTMACHINE";
69 loword="MSHCTX_INPROC";
72 sprintf(buf, "%d", LOWORD(*pFlags));
76 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
77 return wine_dbg_sprintf("MAKELONG(NDR_LOCAL_REPRESENTATION, %s)", loword);
79 return wine_dbg_sprintf("MAKELONG(0x%04x, %s)", HIWORD(*pFlags), loword);
82 /******************************************************************************
83 * CLIPFORMAT_UserSize [OLE32.@]
85 * Calculates the buffer size required to marshal a clip format.
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.
94 * The buffer size required to marshal a clip format plus the starting size.
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.
102 ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORMAT *pCF)
104 ULONG size = StartingSize;
106 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF);
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))
116 size += 3 * sizeof(UINT);
117 /* urg! this function is badly designed because it won't tell us how
118 * much space is needed without doing a dummy run of storing the
119 * name into a buffer */
120 ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
122 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
123 size += (ret + 1) * sizeof(WCHAR);
128 /******************************************************************************
129 * CLIPFORMAT_UserMarshal [OLE32.@]
131 * Marshals a clip format into a buffer.
134 * pFlags [I] Flags. See notes.
135 * pBuffer [I] Buffer to marshal the clip format into.
136 * pCF [I] Clip format to marshal.
139 * The end of the marshaled data in the buffer.
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.
147 unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
149 TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
151 /* only need to marshal the name if it is not a pre-defined type and
152 * we are going remote */
153 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
158 *(DWORD *)pBuffer = WDT_REMOTE_CALL;
160 *(DWORD *)pBuffer = *pCF;
163 len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
165 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
167 *(UINT *)pBuffer = len;
168 pBuffer += sizeof(UINT);
169 *(UINT *)pBuffer = 0;
170 pBuffer += sizeof(UINT);
171 *(UINT *)pBuffer = len;
172 pBuffer += sizeof(UINT);
173 TRACE("marshaling format name %s\n", debugstr_wn(format, len-1));
174 lstrcpynW((LPWSTR)pBuffer, format, len);
175 pBuffer += len * sizeof(WCHAR);
176 *(WCHAR *)pBuffer = '\0';
177 pBuffer += sizeof(WCHAR);
181 *(DWORD *)pBuffer = WDT_INPROC_CALL;
183 *(DWORD *)pBuffer = *pCF;
190 /******************************************************************************
191 * CLIPFORMAT_UserUnmarshal [OLE32.@]
193 * Unmarshals a clip format from a buffer.
196 * pFlags [I] Flags. See notes.
197 * pBuffer [I] Buffer to marshal the clip format from.
198 * pCF [O] Address that receive the unmarshaled clip format.
201 * The end of the marshaled data in the buffer.
204 * Even though the function is documented to take a pointer to an unsigned
205 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
206 * the first parameter is an unsigned long.
207 * This function is only intended to be called by the RPC runtime.
209 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
213 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
215 fContext = *(DWORD *)pBuffer;
218 if (fContext == WDT_INPROC_CALL)
220 *pCF = *(CLIPFORMAT *)pBuffer;
223 else if (fContext == WDT_REMOTE_CALL)
228 /* pointer ID for registered clip format string */
229 if (*(DWORD *)pBuffer == 0)
230 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
233 len = *(UINT *)pBuffer;
234 pBuffer += sizeof(UINT);
235 if (*(UINT *)pBuffer != 0)
236 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
237 pBuffer += sizeof(UINT);
238 if (*(UINT *)pBuffer != len)
239 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
240 pBuffer += sizeof(UINT);
241 if (((WCHAR *)pBuffer)[len] != '\0')
242 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
243 TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
244 cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
245 pBuffer += (len + 1) * sizeof(WCHAR);
247 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
251 /* code not really appropriate, but nearest I can find */
252 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
256 /******************************************************************************
257 * CLIPFORMAT_UserFree [OLE32.@]
259 * Frees an unmarshaled clip format.
262 * pFlags [I] Flags. See notes.
263 * pCF [I] Clip format to free.
266 * The end of the marshaled data in the buffer.
269 * Even though the function is documented to take a pointer to an unsigned
270 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
271 * structure, of which the first parameter is an unsigned long.
272 * This function is only intended to be called by the RPC runtime.
274 void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
276 /* there is no inverse of the RegisterClipboardFormat function,
277 * so nothing to do */
280 static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
282 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
284 ERR("can't remote a local handle\n");
285 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
288 return StartingSize + sizeof(RemotableHandle);
291 static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
293 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
294 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
296 ERR("can't remote a local handle\n");
297 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
300 remhandle->fContext = WDT_INPROC_CALL;
301 remhandle->u.hInproc = (LONG_PTR)*handle;
302 return pBuffer + sizeof(RemotableHandle);
305 static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
307 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
308 if (remhandle->fContext != WDT_INPROC_CALL)
309 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
310 *handle = (HANDLE)remhandle->u.hInproc;
311 return pBuffer + sizeof(RemotableHandle);
314 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
319 #define IMPL_WIREM_HANDLE(type) \
320 ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \
322 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \
323 return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
326 unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
328 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \
329 return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
332 unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
334 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \
335 return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
338 void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \
340 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \
341 handle_UserFree(pFlags, (HANDLE *)handle); \
344 IMPL_WIREM_HANDLE(HACCEL)
345 IMPL_WIREM_HANDLE(HMENU)
346 IMPL_WIREM_HANDLE(HWND)
348 /******************************************************************************
349 * HGLOBAL_UserSize [OLE32.@]
351 * Calculates the buffer size required to marshal an HGLOBAL.
354 * pFlags [I] Flags. See notes.
355 * StartingSize [I] Starting size of the buffer. This value is added on to
356 * the buffer size required for the clip format.
357 * phGlobal [I] HGLOBAL to size.
360 * The buffer size required to marshal an HGLOBAL plus the starting size.
363 * Even though the function is documented to take a pointer to a ULONG in
364 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
365 * the first parameter is a ULONG.
366 * This function is only intended to be called by the RPC runtime.
368 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
370 ULONG size = StartingSize;
372 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
374 ALIGN_LENGTH(size, 3);
376 size += sizeof(ULONG);
378 if (LOWORD(*pFlags == MSHCTX_INPROC))
379 size += sizeof(HGLOBAL);
382 size += sizeof(ULONG);
386 size += 3 * sizeof(ULONG);
387 ret = GlobalSize(*phGlobal);
395 /******************************************************************************
396 * HGLOBAL_UserMarshal [OLE32.@]
398 * Marshals an HGLOBAL into a buffer.
401 * pFlags [I] Flags. See notes.
402 * pBuffer [I] Buffer to marshal the clip format into.
403 * phGlobal [I] HGLOBAL to marshal.
406 * The end of the marshaled data in the buffer.
409 * Even though the function is documented to take a pointer to a ULONG in
410 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
411 * the first parameter is a ULONG.
412 * This function is only intended to be called by the RPC runtime.
414 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
416 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
418 ALIGN_POINTER(pBuffer, 3);
420 if (LOWORD(*pFlags == MSHCTX_INPROC))
422 if (sizeof(*phGlobal) == 8)
423 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
425 *(ULONG *)pBuffer = WDT_INPROC_CALL;
426 pBuffer += sizeof(ULONG);
427 *(HGLOBAL *)pBuffer = *phGlobal;
428 pBuffer += sizeof(HGLOBAL);
432 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
433 pBuffer += sizeof(ULONG);
434 *(ULONG *)pBuffer = (ULONG)*phGlobal;
435 pBuffer += sizeof(ULONG);
438 const unsigned char *memory;
439 SIZE_T size = GlobalSize(*phGlobal);
440 *(ULONG *)pBuffer = (ULONG)size;
441 pBuffer += sizeof(ULONG);
442 *(ULONG *)pBuffer = (ULONG)*phGlobal;
443 pBuffer += sizeof(ULONG);
444 *(ULONG *)pBuffer = (ULONG)size;
445 pBuffer += sizeof(ULONG);
447 memory = GlobalLock(*phGlobal);
448 memcpy(pBuffer, memory, size);
450 GlobalUnlock(*phGlobal);
457 /******************************************************************************
458 * HGLOBAL_UserUnmarshal [OLE32.@]
460 * Unmarshals an HGLOBAL from a buffer.
463 * pFlags [I] Flags. See notes.
464 * pBuffer [I] Buffer to marshal the clip format from.
465 * phGlobal [O] Address that receive the unmarshaled HGLOBAL.
468 * The end of the marshaled data in the buffer.
471 * Even though the function is documented to take a pointer to an ULONG in
472 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
473 * the first parameter is an ULONG.
474 * This function is only intended to be called by the RPC runtime.
476 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
480 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
482 ALIGN_POINTER(pBuffer, 3);
484 fContext = *(ULONG *)pBuffer;
485 pBuffer += sizeof(ULONG);
487 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
488 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
490 *phGlobal = *(HGLOBAL *)pBuffer;
491 pBuffer += sizeof(*phGlobal);
493 else if (fContext == WDT_REMOTE_CALL)
497 handle = *(ULONG *)pBuffer;
498 pBuffer += sizeof(ULONG);
505 size = *(ULONG *)pBuffer;
506 pBuffer += sizeof(ULONG);
507 /* redundancy is bad - it means you have to check consistency like
509 if (*(ULONG *)pBuffer != handle)
511 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
514 pBuffer += sizeof(ULONG);
515 /* redundancy is bad - it means you have to check consistency like
517 if (*(ULONG *)pBuffer != size)
519 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
522 pBuffer += sizeof(ULONG);
524 /* FIXME: check size is not too big */
526 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
527 memory = GlobalLock(*phGlobal);
528 memcpy(memory, pBuffer, size);
530 GlobalUnlock(*phGlobal);
536 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
541 /******************************************************************************
542 * HGLOBAL_UserFree [OLE32.@]
544 * Frees an unmarshaled HGLOBAL.
547 * pFlags [I] Flags. See notes.
548 * phGlobal [I] HGLOBAL to free.
551 * The end of the marshaled data in the buffer.
554 * Even though the function is documented to take a pointer to a ULONG in
555 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
556 * which the first parameter is a ULONG.
557 * This function is only intended to be called by the RPC runtime.
559 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
561 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
563 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
564 GlobalFree(*phGlobal);
567 /******************************************************************************
568 * HBITMAP_UserSize [OLE32.@]
570 * Calculates the buffer size required to marshal a bitmap.
573 * pFlags [I] Flags. See notes.
574 * StartingSize [I] Starting size of the buffer. This value is added on to
575 * the buffer size required for the clip format.
576 * phBmp [I] Bitmap to size.
579 * The buffer size required to marshal an bitmap plus the starting size.
582 * Even though the function is documented to take a pointer to a ULONG in
583 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
584 * the first parameter is a ULONG.
585 * This function is only intended to be called by the RPC runtime.
587 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
593 /******************************************************************************
594 * HBITMAP_UserMarshal [OLE32.@]
596 * Marshals a bitmap into a buffer.
599 * pFlags [I] Flags. See notes.
600 * pBuffer [I] Buffer to marshal the clip format into.
601 * phBmp [I] Bitmap to marshal.
604 * The end of the marshaled data in the buffer.
607 * Even though the function is documented to take a pointer to a ULONG in
608 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
609 * the first parameter is a ULONG.
610 * This function is only intended to be called by the RPC runtime.
612 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
618 /******************************************************************************
619 * HBITMAP_UserUnmarshal [OLE32.@]
621 * Unmarshals a bitmap from a buffer.
624 * pFlags [I] Flags. See notes.
625 * pBuffer [I] Buffer to marshal the clip format from.
626 * phBmp [O] Address that receive the unmarshaled bitmap.
629 * The end of the marshaled data in the buffer.
632 * Even though the function is documented to take a pointer to an ULONG in
633 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
634 * the first parameter is an ULONG.
635 * This function is only intended to be called by the RPC runtime.
637 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
643 /******************************************************************************
644 * HBITMAP_UserFree [OLE32.@]
646 * Frees an unmarshaled bitmap.
649 * pFlags [I] Flags. See notes.
650 * phBmp [I] Bitmap to free.
653 * The end of the marshaled data in the buffer.
656 * Even though the function is documented to take a pointer to a ULONG in
657 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
658 * which the first parameter is a ULONG.
659 * This function is only intended to be called by the RPC runtime.
661 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
666 /******************************************************************************
667 * HICON_UserSize [OLE32.@]
669 * Calculates the buffer size required to marshal an icon.
672 * pFlags [I] Flags. See notes.
673 * StartingSize [I] Starting size of the buffer. This value is added on to
674 * the buffer size required for the icon.
675 * phIcon [I] Icon to size.
678 * The buffer size required to marshal an icon plus the starting size.
681 * Even though the function is documented to take a pointer to a ULONG in
682 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
683 * the first parameter is a ULONG.
684 * This function is only intended to be called by the RPC runtime.
686 ULONG __RPC_USER HICON_UserSize(ULONG *pFlags, ULONG StartingSize, HICON *phIcon)
692 /******************************************************************************
693 * HICON_UserMarshal [OLE32.@]
695 * Marshals an icon into a buffer.
698 * pFlags [I] Flags. See notes.
699 * pBuffer [I] Buffer to marshal the icon into.
700 * phIcon [I] Icon to marshal.
703 * The end of the marshaled data in the buffer.
706 * Even though the function is documented to take a pointer to a ULONG in
707 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
708 * the first parameter is a ULONG.
709 * This function is only intended to be called by the RPC runtime.
711 unsigned char * __RPC_USER HICON_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
717 /******************************************************************************
718 * HICON_UserUnmarshal [OLE32.@]
720 * Unmarshals an icon from a buffer.
723 * pFlags [I] Flags. See notes.
724 * pBuffer [I] Buffer to marshal the icon from.
725 * phIcon [O] Address that receive the unmarshaled icon.
728 * The end of the marshaled data in the buffer.
731 * Even though the function is documented to take a pointer to an ULONG in
732 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
733 * the first parameter is an ULONG.
734 * This function is only intended to be called by the RPC runtime.
736 unsigned char * __RPC_USER HICON_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
742 /******************************************************************************
743 * HICON_UserFree [OLE32.@]
745 * Frees an unmarshaled icon.
748 * pFlags [I] Flags. See notes.
749 * phIcon [I] Icon to free.
752 * The end of the marshaled data in the buffer.
755 * Even though the function is documented to take a pointer to a ULONG in
756 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
757 * which the first parameter is a ULONG.
758 * This function is only intended to be called by the RPC runtime.
760 void __RPC_USER HICON_UserFree(ULONG *pFlags, HICON *phIcon)
765 /******************************************************************************
766 * HDC_UserSize [OLE32.@]
768 * Calculates the buffer size required to marshal an HDC.
771 * pFlags [I] Flags. See notes.
772 * StartingSize [I] Starting size of the buffer. This value is added on to
773 * the buffer size required for the clip format.
774 * phGlobal [I] HDC to size.
777 * The buffer size required to marshal an HDC plus the starting size.
780 * Even though the function is documented to take a pointer to a ULONG in
781 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
782 * the first parameter is a ULONG.
783 * This function is only intended to be called by the RPC runtime.
785 ULONG __RPC_USER HDC_UserSize(ULONG *pFlags, ULONG StartingSize, HDC *phdc)
791 /******************************************************************************
792 * HDC_UserMarshal [OLE32.@]
794 * Marshals an HDC into a buffer.
797 * pFlags [I] Flags. See notes.
798 * pBuffer [I] Buffer to marshal the clip format into.
799 * phdc [I] HDC to marshal.
802 * The end of the marshaled data in the buffer.
805 * Even though the function is documented to take a pointer to a ULONG in
806 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
807 * the first parameter is a ULONG.
808 * This function is only intended to be called by the RPC runtime.
810 unsigned char * __RPC_USER HDC_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
816 /******************************************************************************
817 * HDC_UserUnmarshal [OLE32.@]
819 * Unmarshals an HDC from a buffer.
822 * pFlags [I] Flags. See notes.
823 * pBuffer [I] Buffer to marshal the clip format from.
824 * phdc [O] Address that receive the unmarshaled HDC.
827 * The end of the marshaled data in the buffer.
830 * Even though the function is documented to take a pointer to an ULONG in
831 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
832 * the first parameter is an ULONG.
833 * This function is only intended to be called by the RPC runtime.
835 unsigned char * __RPC_USER HDC_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
841 /******************************************************************************
842 * HDC_UserFree [OLE32.@]
844 * Frees an unmarshaled HDC.
847 * pFlags [I] Flags. See notes.
848 * phdc [I] HDC to free.
851 * The end of the marshaled data in the buffer.
854 * Even though the function is documented to take a pointer to a ULONG in
855 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
856 * which the first parameter is a ULONG.
857 * This function is only intended to be called by the RPC runtime.
859 void __RPC_USER HDC_UserFree(ULONG *pFlags, HDC *phdc)
864 /******************************************************************************
865 * HPALETTE_UserSize [OLE32.@]
867 * Calculates the buffer size required to marshal a palette.
870 * pFlags [I] Flags. See notes.
871 * StartingSize [I] Starting size of the buffer. This value is added on to
872 * the buffer size required for the clip format.
873 * phPal [I] Palette to size.
876 * The buffer size required to marshal a palette plus the starting size.
879 * Even though the function is documented to take a pointer to a ULONG in
880 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
881 * the first parameter is a ULONG.
882 * This function is only intended to be called by the RPC runtime.
884 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
890 /******************************************************************************
891 * HPALETTE_UserMarshal [OLE32.@]
893 * Marshals a palette into a buffer.
896 * pFlags [I] Flags. See notes.
897 * pBuffer [I] Buffer to marshal the clip format into.
898 * phPal [I] Palette to marshal.
901 * The end of the marshaled data in the buffer.
904 * Even though the function is documented to take a pointer to a ULONG in
905 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
906 * the first parameter is a ULONG.
907 * This function is only intended to be called by the RPC runtime.
909 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
915 /******************************************************************************
916 * HPALETTE_UserUnmarshal [OLE32.@]
918 * Unmarshals a palette from a buffer.
921 * pFlags [I] Flags. See notes.
922 * pBuffer [I] Buffer to marshal the clip format from.
923 * phPal [O] Address that receive the unmarshaled palette.
926 * The end of the marshaled data in the buffer.
929 * Even though the function is documented to take a pointer to an ULONG in
930 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
931 * the first parameter is an ULONG.
932 * This function is only intended to be called by the RPC runtime.
934 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
940 /******************************************************************************
941 * HPALETTE_UserFree [OLE32.@]
943 * Frees an unmarshaled palette.
946 * pFlags [I] Flags. See notes.
947 * phPal [I] Palette to free.
950 * The end of the marshaled data in the buffer.
953 * Even though the function is documented to take a pointer to a ULONG in
954 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
955 * which the first parameter is a ULONG.
956 * This function is only intended to be called by the RPC runtime.
958 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
964 /******************************************************************************
965 * HMETAFILE_UserSize [OLE32.@]
967 * Calculates the buffer size required to marshal a metafile.
970 * pFlags [I] Flags. See notes.
971 * StartingSize [I] Starting size of the buffer. This value is added on to
972 * the buffer size required for the clip format.
973 * phmf [I] Metafile to size.
976 * The buffer size required to marshal a metafile plus the starting size.
979 * Even though the function is documented to take a pointer to a ULONG in
980 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
981 * the first parameter is a ULONG.
982 * This function is only intended to be called by the RPC runtime.
984 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
986 ULONG size = StartingSize;
988 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
990 ALIGN_LENGTH(size, 3);
992 size += sizeof(ULONG);
993 if (LOWORD(*pFlags) == MSHCTX_INPROC)
994 size += sizeof(ULONG_PTR);
997 size += sizeof(ULONG);
1003 size += 2 * sizeof(ULONG);
1004 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1012 /******************************************************************************
1013 * HMETAFILE_UserMarshal [OLE32.@]
1015 * Marshals a metafile into a buffer.
1018 * pFlags [I] Flags. See notes.
1019 * pBuffer [I] Buffer to marshal the clip format into.
1020 * phEmf [I] Metafile to marshal.
1023 * The end of the marshaled data in the buffer.
1026 * Even though the function is documented to take a pointer to a ULONG in
1027 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1028 * the first parameter is a ULONG.
1029 * This function is only intended to be called by the RPC runtime.
1031 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1033 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
1035 ALIGN_POINTER(pBuffer, 3);
1037 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1039 if (sizeof(*phmf) == 8)
1040 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1042 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1043 pBuffer += sizeof(ULONG);
1044 *(HMETAFILE *)pBuffer = *phmf;
1045 pBuffer += sizeof(HMETAFILE);
1049 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1050 pBuffer += sizeof(ULONG);
1051 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1052 pBuffer += sizeof(ULONG);
1056 UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1058 *(ULONG *)pBuffer = mfsize;
1059 pBuffer += sizeof(ULONG);
1060 *(ULONG *)pBuffer = mfsize;
1061 pBuffer += sizeof(ULONG);
1062 GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
1070 /******************************************************************************
1071 * HMETAFILE_UserUnmarshal [OLE32.@]
1073 * Unmarshals a metafile from a buffer.
1076 * pFlags [I] Flags. See notes.
1077 * pBuffer [I] Buffer to marshal the clip format from.
1078 * phmf [O] Address that receive the unmarshaled metafile.
1081 * The end of the marshaled data in the buffer.
1084 * Even though the function is documented to take a pointer to an ULONG in
1085 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1086 * the first parameter is an ULONG.
1087 * This function is only intended to be called by the RPC runtime.
1089 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1093 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
1095 ALIGN_POINTER(pBuffer, 3);
1097 fContext = *(ULONG *)pBuffer;
1098 pBuffer += sizeof(ULONG);
1100 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
1101 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
1103 *phmf = *(HMETAFILE *)pBuffer;
1104 pBuffer += sizeof(*phmf);
1106 else if (fContext == WDT_REMOTE_CALL)
1110 handle = *(ULONG *)pBuffer;
1111 pBuffer += sizeof(ULONG);
1116 size = *(ULONG *)pBuffer;
1117 pBuffer += sizeof(ULONG);
1118 if (size != *(ULONG *)pBuffer)
1120 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1123 pBuffer += sizeof(ULONG);
1124 *phmf = SetMetaFileBitsEx(size, pBuffer);
1131 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1136 /******************************************************************************
1137 * HMETAFILE_UserFree [OLE32.@]
1139 * Frees an unmarshaled metafile.
1142 * pFlags [I] Flags. See notes.
1143 * phmf [I] Metafile to free.
1146 * The end of the marshaled data in the buffer.
1149 * Even though the function is documented to take a pointer to a ULONG in
1150 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1151 * which the first parameter is a ULONG.
1152 * This function is only intended to be called by the RPC runtime.
1154 void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
1156 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
1158 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1159 DeleteMetaFile(*phmf);
1162 /******************************************************************************
1163 * HENHMETAFILE_UserSize [OLE32.@]
1165 * Calculates the buffer size required to marshal an enhanced metafile.
1168 * pFlags [I] Flags. See notes.
1169 * StartingSize [I] Starting size of the buffer. This value is added on to
1170 * the buffer size required for the clip format.
1171 * phEmf [I] Enhanced metafile to size.
1174 * The buffer size required to marshal an enhanced metafile plus the starting size.
1177 * Even though the function is documented to take a pointer to a ULONG in
1178 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1179 * the first parameter is a ULONG.
1180 * This function is only intended to be called by the RPC runtime.
1182 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
1184 ULONG size = StartingSize;
1186 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
1188 size += sizeof(ULONG);
1189 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1190 size += sizeof(ULONG_PTR);
1193 size += sizeof(ULONG);
1199 size += 2 * sizeof(ULONG);
1200 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1208 /******************************************************************************
1209 * HENHMETAFILE_UserMarshal [OLE32.@]
1211 * Marshals an enhance metafile into a buffer.
1214 * pFlags [I] Flags. See notes.
1215 * pBuffer [I] Buffer to marshal the clip format into.
1216 * phEmf [I] Enhanced metafile to marshal.
1219 * The end of the marshaled data in the buffer.
1222 * Even though the function is documented to take a pointer to a ULONG in
1223 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1224 * the first parameter is a ULONG.
1225 * This function is only intended to be called by the RPC runtime.
1227 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1229 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1231 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1233 if (sizeof(*phEmf) == 8)
1234 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1236 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1237 pBuffer += sizeof(ULONG);
1238 *(HENHMETAFILE *)pBuffer = *phEmf;
1239 pBuffer += sizeof(HENHMETAFILE);
1243 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1244 pBuffer += sizeof(ULONG);
1245 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1246 pBuffer += sizeof(ULONG);
1250 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1252 *(ULONG *)pBuffer = emfsize;
1253 pBuffer += sizeof(ULONG);
1254 *(ULONG *)pBuffer = emfsize;
1255 pBuffer += sizeof(ULONG);
1256 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1264 /******************************************************************************
1265 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1267 * Unmarshals an enhanced metafile from a buffer.
1270 * pFlags [I] Flags. See notes.
1271 * pBuffer [I] Buffer to marshal the clip format from.
1272 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
1275 * The end of the marshaled data in the buffer.
1278 * Even though the function is documented to take a pointer to an ULONG in
1279 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1280 * the first parameter is an ULONG.
1281 * This function is only intended to be called by the RPC runtime.
1283 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1287 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1289 fContext = *(ULONG *)pBuffer;
1290 pBuffer += sizeof(ULONG);
1292 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1293 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1295 *phEmf = *(HENHMETAFILE *)pBuffer;
1296 pBuffer += sizeof(*phEmf);
1298 else if (fContext == WDT_REMOTE_CALL)
1302 handle = *(ULONG *)pBuffer;
1303 pBuffer += sizeof(ULONG);
1308 size = *(ULONG *)pBuffer;
1309 pBuffer += sizeof(ULONG);
1310 if (size != *(ULONG *)pBuffer)
1312 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1315 pBuffer += sizeof(ULONG);
1316 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1323 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1328 /******************************************************************************
1329 * HENHMETAFILE_UserFree [OLE32.@]
1331 * Frees an unmarshaled enhanced metafile.
1334 * pFlags [I] Flags. See notes.
1335 * phEmf [I] Enhanced metafile to free.
1338 * The end of the marshaled data in the buffer.
1341 * Even though the function is documented to take a pointer to a ULONG in
1342 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1343 * which the first parameter is a ULONG.
1344 * This function is only intended to be called by the RPC runtime.
1346 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1348 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1350 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1351 DeleteEnhMetaFile(*phEmf);
1354 /******************************************************************************
1355 * HMETAFILEPICT_UserSize [OLE32.@]
1357 * Calculates the buffer size required to marshal an metafile pict.
1360 * pFlags [I] Flags. See notes.
1361 * StartingSize [I] Starting size of the buffer. This value is added on to
1362 * the buffer size required for the clip format.
1363 * phMfp [I] Metafile pict to size.
1366 * The buffer size required to marshal a metafile pict plus the starting size.
1369 * Even though the function is documented to take a pointer to a ULONG in
1370 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1371 * the first parameter is a ULONG.
1372 * This function is only intended to be called by the RPC runtime.
1374 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1376 ULONG size = StartingSize;
1378 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1380 size += sizeof(ULONG);
1381 size += sizeof(HMETAFILEPICT);
1383 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1385 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1387 /* FIXME: raise an exception if mfpict is NULL? */
1388 size += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1389 size += sizeof(ULONG);
1391 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1393 GlobalUnlock(*phMfp);
1399 /******************************************************************************
1400 * HMETAFILEPICT_UserMarshal [OLE32.@]
1402 * Marshals a metafile pict into a buffer.
1405 * pFlags [I] Flags. See notes.
1406 * pBuffer [I] Buffer to marshal the clip format into.
1407 * phMfp [I] Metafile pict to marshal.
1410 * The end of the marshaled data in the buffer.
1413 * Even though the function is documented to take a pointer to a ULONG in
1414 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1415 * the first parameter is a ULONG.
1416 * This function is only intended to be called by the RPC runtime.
1418 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1420 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1422 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1423 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1425 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1426 pBuffer += sizeof(ULONG);
1428 *(HMETAFILEPICT *)pBuffer = *phMfp;
1429 pBuffer += sizeof(HMETAFILEPICT);
1431 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1433 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1434 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1436 /* FIXME: raise an exception if mfpict is NULL? */
1437 remmfpict->mm = mfpict->mm;
1438 remmfpict->xExt = mfpict->xExt;
1439 remmfpict->yExt = mfpict->yExt;
1440 pBuffer += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1441 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1442 pBuffer += sizeof(ULONG);
1444 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1446 GlobalUnlock(*phMfp);
1452 /******************************************************************************
1453 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1455 * Unmarshals an metafile pict from a buffer.
1458 * pFlags [I] Flags. See notes.
1459 * pBuffer [I] Buffer to marshal the clip format from.
1460 * phMfp [O] Address that receive the unmarshaled metafile pict.
1463 * The end of the marshaled data in the buffer.
1466 * Even though the function is documented to take a pointer to an ULONG in
1467 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1468 * the first parameter is an ULONG.
1469 * This function is only intended to be called by the RPC runtime.
1471 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1475 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1477 fContext = *(ULONG *)pBuffer;
1478 pBuffer += sizeof(ULONG);
1480 if ((fContext == WDT_INPROC_CALL) || !*(HMETAFILEPICT *)pBuffer)
1482 *phMfp = *(HMETAFILEPICT *)pBuffer;
1483 pBuffer += sizeof(HMETAFILEPICT);
1487 METAFILEPICT *mfpict;
1488 const remoteMETAFILEPICT *remmfpict;
1489 ULONG user_marshal_prefix;
1491 pBuffer += sizeof(HMETAFILEPICT);
1492 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1494 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1496 RpcRaiseException(E_OUTOFMEMORY);
1498 mfpict = GlobalLock(*phMfp);
1499 mfpict->mm = remmfpict->mm;
1500 mfpict->xExt = remmfpict->xExt;
1501 mfpict->yExt = remmfpict->yExt;
1502 pBuffer += FIELD_OFFSET(remoteMETAFILEPICT, hMF);
1503 user_marshal_prefix = *(ULONG *)pBuffer;
1504 pBuffer += sizeof(ULONG);
1506 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1507 RpcRaiseException(RPC_X_INVALID_TAG);
1509 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1511 GlobalUnlock(*phMfp);
1517 /******************************************************************************
1518 * HMETAFILEPICT_UserFree [OLE32.@]
1520 * Frees an unmarshaled metafile pict.
1523 * pFlags [I] Flags. See notes.
1524 * phMfp [I] Metafile pict to free.
1527 * The end of the marshaled data in the buffer.
1530 * Even though the function is documented to take a pointer to a ULONG in
1531 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1532 * which the first parameter is a ULONG.
1533 * This function is only intended to be called by the RPC runtime.
1535 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1537 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1539 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1541 METAFILEPICT *mfpict;
1543 mfpict = GlobalLock(*phMfp);
1544 /* FIXME: raise an exception if mfpict is NULL? */
1545 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1546 GlobalUnlock(*phMfp);
1552 /******************************************************************************
1553 * WdtpInterfacePointer_UserSize [OLE32.@]
1555 * Calculates the buffer size required to marshal an interface pointer.
1558 * pFlags [I] Flags. See notes.
1559 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1560 * punk [I] Interface pointer to size.
1561 * StartingSize [I] Starting size of the buffer. This value is added on to
1562 * the buffer size required for the clip format.
1563 * riid [I] ID of interface to size.
1566 * The buffer size required to marshal an interface pointer plus the starting size.
1569 * Even though the function is documented to take a pointer to a ULONG in
1570 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1571 * the first parameter is a ULONG.
1573 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1575 DWORD marshal_size = 0;
1578 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1580 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1581 if(FAILED(hr)) return StartingSize;
1583 ALIGN_LENGTH(StartingSize, 3);
1584 StartingSize += 2 * sizeof(DWORD);
1585 return StartingSize + marshal_size;
1588 /******************************************************************************
1589 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1591 * Marshals an interface pointer into a buffer.
1594 * pFlags [I] Flags. See notes.
1595 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1596 * pBuffer [I] Buffer to marshal the clip format into.
1597 * punk [I] Interface pointer to marshal.
1598 * riid [I] ID of interface to marshal.
1601 * The end of the marshaled data in the buffer.
1604 * Even though the function is documented to take a pointer to a ULONG in
1605 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1606 * the first parameter is a ULONG.
1608 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1610 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1615 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1618 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1624 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1626 IStream_Release(stm);
1630 ALIGN_POINTER(pBuffer, 3);
1631 size = GlobalSize(h);
1633 *(DWORD *)pBuffer = size;
1634 pBuffer += sizeof(DWORD);
1635 *(DWORD *)pBuffer = size;
1636 pBuffer += sizeof(DWORD);
1638 ptr = GlobalLock(h);
1639 memcpy(pBuffer, ptr, size);
1642 IStream_Release(stm);
1643 return pBuffer + size;
1646 /******************************************************************************
1647 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1649 * Unmarshals an interface pointer from a buffer.
1652 * pFlags [I] Flags. See notes.
1653 * pBuffer [I] Buffer to marshal the clip format from.
1654 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1655 * riid [I] ID of interface to unmarshal.
1658 * The end of the marshaled data in the buffer.
1661 * Even though the function is documented to take a pointer to an ULONG in
1662 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1663 * the first parameter is an ULONG.
1665 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1673 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1675 ALIGN_POINTER(pBuffer, 3);
1677 size = *(DWORD *)pBuffer;
1678 pBuffer += sizeof(DWORD);
1679 if(size != *(DWORD *)pBuffer)
1680 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1682 pBuffer += sizeof(DWORD);
1684 /* FIXME: sanity check on size */
1686 h = GlobalAlloc(GMEM_MOVEABLE, size);
1687 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1689 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1692 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1695 ptr = GlobalLock(h);
1696 memcpy(ptr, pBuffer, size);
1699 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1700 IStream_Release(stm);
1702 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1704 return pBuffer + size;
1707 /******************************************************************************
1708 * WdtpInterfacePointer_UserFree [OLE32.@]
1710 * Releases an unmarshaled interface pointer.
1713 * punk [I] Interface pointer to release.
1718 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1720 TRACE("(%p)\n", punk);
1721 if(punk) IUnknown_Release(punk);
1724 /******************************************************************************
1725 * STGMEDIUM_UserSize [OLE32.@]
1727 * Calculates the buffer size required to marshal an STGMEDIUM.
1730 * pFlags [I] Flags. See notes.
1731 * StartingSize [I] Starting size of the buffer. This value is added on to
1732 * the buffer size required for the clip format.
1733 * pStgMedium [I] STGMEDIUM to size.
1736 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1739 * Even though the function is documented to take a pointer to a ULONG in
1740 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1741 * the first parameter is a ULONG.
1742 * This function is only intended to be called by the RPC runtime.
1744 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1746 ULONG size = StartingSize;
1748 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1750 ALIGN_LENGTH(size, 3);
1752 size += 2 * sizeof(DWORD);
1753 if (pStgMedium->tymed != TYMED_NULL)
1754 size += sizeof(DWORD);
1756 switch (pStgMedium->tymed)
1759 TRACE("TYMED_NULL\n");
1762 TRACE("TYMED_HGLOBAL\n");
1763 if (pStgMedium->u.hGlobal)
1764 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1767 TRACE("TYMED_FILE\n");
1768 if (pStgMedium->u.lpszFileName)
1770 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1771 size += 3 * sizeof(DWORD) +
1772 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1776 TRACE("TYMED_ISTREAM\n");
1777 if (pStgMedium->u.pstm)
1779 FIXME("not implemented for IStream %p\n", pStgMedium->u.pstm);
1782 case TYMED_ISTORAGE:
1783 TRACE("TYMED_ISTORAGE\n");
1784 if (pStgMedium->u.pstg)
1786 FIXME("not implemented for IStorage %p\n", pStgMedium->u.pstg);
1790 TRACE("TYMED_GDI\n");
1791 if (pStgMedium->u.hBitmap)
1793 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1797 TRACE("TYMED_MFPICT\n");
1798 if (pStgMedium->u.hMetaFilePict)
1799 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1802 TRACE("TYMED_ENHMF\n");
1803 if (pStgMedium->u.hEnhMetaFile)
1804 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1807 RaiseException(DV_E_TYMED, 0, 0, NULL);
1810 if (pStgMedium->pUnkForRelease)
1811 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1816 /******************************************************************************
1817 * STGMEDIUM_UserMarshal [OLE32.@]
1819 * Marshals a STGMEDIUM into a buffer.
1822 * pFlags [I] Flags. See notes.
1823 * pBuffer [I] Buffer to marshal the clip format into.
1824 * pCF [I] STGMEDIUM to marshal.
1827 * The end of the marshaled data in the buffer.
1830 * Even though the function is documented to take a pointer to a ULONG in
1831 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1832 * the first parameter is a ULONG.
1833 * This function is only intended to be called by the RPC runtime.
1835 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1837 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1839 ALIGN_POINTER(pBuffer, 3);
1841 *(DWORD *)pBuffer = pStgMedium->tymed;
1842 pBuffer += sizeof(DWORD);
1843 if (pStgMedium->tymed != TYMED_NULL)
1845 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1846 pBuffer += sizeof(DWORD);
1848 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1849 pBuffer += sizeof(DWORD);
1851 switch (pStgMedium->tymed)
1854 TRACE("TYMED_NULL\n");
1857 TRACE("TYMED_HGLOBAL\n");
1858 if (pStgMedium->u.hGlobal)
1859 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1862 TRACE("TYMED_FILE\n");
1863 if (pStgMedium->u.lpszFileName)
1866 len = strlenW(pStgMedium->u.lpszFileName);
1868 *(DWORD *)pBuffer = len + 1;
1869 pBuffer += sizeof(DWORD);
1871 *(DWORD *)pBuffer = 0;
1872 pBuffer += sizeof(DWORD);
1874 *(DWORD *)pBuffer = len + 1;
1875 pBuffer += sizeof(DWORD);
1877 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1878 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1882 TRACE("TYMED_ISTREAM\n");
1883 if (pStgMedium->u.pstm)
1885 FIXME("not implemented for IStream %p\n", pStgMedium->u.pstm);
1888 case TYMED_ISTORAGE:
1889 TRACE("TYMED_ISTORAGE\n");
1890 if (pStgMedium->u.pstg)
1892 FIXME("not implemented for IStorage %p\n", pStgMedium->u.pstg);
1896 TRACE("TYMED_GDI\n");
1897 if (pStgMedium->u.hBitmap)
1899 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1903 TRACE("TYMED_MFPICT\n");
1904 if (pStgMedium->u.hMetaFilePict)
1905 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1908 TRACE("TYMED_ENHMF\n");
1909 if (pStgMedium->u.hEnhMetaFile)
1910 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1913 RaiseException(DV_E_TYMED, 0, 0, NULL);
1916 if (pStgMedium->pUnkForRelease)
1917 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1922 /******************************************************************************
1923 * STGMEDIUM_UserUnmarshal [OLE32.@]
1925 * Unmarshals a STGMEDIUM from a buffer.
1928 * pFlags [I] Flags. See notes.
1929 * pBuffer [I] Buffer to marshal the clip format from.
1930 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1933 * The end of the marshaled data in the buffer.
1936 * Even though the function is documented to take a pointer to an ULONG in
1937 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1938 * the first parameter is an ULONG.
1939 * This function is only intended to be called by the RPC runtime.
1941 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1946 ALIGN_POINTER(pBuffer, 3);
1948 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1950 pStgMedium->tymed = *(DWORD *)pBuffer;
1951 pBuffer += sizeof(DWORD);
1952 if (pStgMedium->tymed != TYMED_NULL)
1954 content = *(DWORD *)pBuffer;
1955 pBuffer += sizeof(DWORD);
1957 releaseunk = *(DWORD *)pBuffer;
1958 pBuffer += sizeof(DWORD);
1960 switch (pStgMedium->tymed)
1963 TRACE("TYMED_NULL\n");
1966 TRACE("TYMED_HGLOBAL\n");
1968 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1971 TRACE("TYMED_FILE\n");
1976 conformance = *(DWORD *)pBuffer;
1977 pBuffer += sizeof(DWORD);
1978 if (*(DWORD *)pBuffer != 0)
1980 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
1981 RpcRaiseException(RPC_S_INVALID_BOUND);
1984 pBuffer += sizeof(DWORD);
1985 variance = *(DWORD *)pBuffer;
1986 pBuffer += sizeof(DWORD);
1987 if (conformance != variance)
1989 ERR("conformance (%d) and variance (%d) should be equal\n",
1990 conformance, variance);
1991 RpcRaiseException(RPC_S_INVALID_BOUND);
1994 if (conformance > 0x7fffffff)
1996 ERR("conformance 0x%x too large\n", conformance);
1997 RpcRaiseException(RPC_S_INVALID_BOUND);
2000 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2001 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2002 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2003 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2004 pBuffer += variance * sizeof(WCHAR);
2007 pStgMedium->u.lpszFileName = NULL;
2010 TRACE("TYMED_ISTREAM\n");
2013 FIXME("not implemented for IStream\n");
2016 pStgMedium->u.pstm = NULL;
2018 case TYMED_ISTORAGE:
2019 TRACE("TYMED_ISTORAGE\n");
2022 FIXME("not implemented for IStorage\n");
2025 pStgMedium->u.pstg = NULL;
2028 TRACE("TYMED_GDI\n");
2031 FIXME("not implemented for GDI object\n");
2034 pStgMedium->u.hBitmap = NULL;
2037 TRACE("TYMED_MFPICT\n");
2039 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2041 pStgMedium->u.hMetaFilePict = NULL;
2044 TRACE("TYMED_ENHMF\n");
2046 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2048 pStgMedium->u.hEnhMetaFile = NULL;
2051 RaiseException(DV_E_TYMED, 0, 0, NULL);
2054 pStgMedium->pUnkForRelease = NULL;
2056 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2061 /******************************************************************************
2062 * STGMEDIUM_UserFree [OLE32.@]
2064 * Frees an unmarshaled STGMEDIUM.
2067 * pFlags [I] Flags. See notes.
2068 * pStgmedium [I] STGMEDIUM to free.
2071 * The end of the marshaled data in the buffer.
2074 * Even though the function is documented to take a pointer to a ULONG in
2075 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2076 * which the first parameter is a ULONG.
2077 * This function is only intended to be called by the RPC runtime.
2079 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2081 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2083 ReleaseStgMedium(pStgMedium);
2086 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2089 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2092 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2095 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2098 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2101 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2104 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2107 STGMEDIUM_UserFree(pFlags, pStgMedium);
2110 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2113 return StartingSize;
2116 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2122 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2128 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2133 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2136 return StartingSize;
2139 unsigned char * __RPC_USER SNB_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2145 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2151 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2156 /* call_as/local stubs for unknwn.idl */
2158 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2159 IClassFactory* This,
2160 IUnknown *pUnkOuter,
2164 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2168 ERR("aggregation is not allowed on remote objects\n");
2169 return CLASS_E_NOAGGREGATION;
2171 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2172 (IUnknown **) ppvObject);
2175 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2176 IClassFactory* This,
2178 IUnknown **ppvObject)
2180 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2181 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2184 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2185 IClassFactory* This,
2192 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2193 IClassFactory* This,
2200 /* call_as/local stubs for objidl.idl */
2202 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2206 ULONG *pceltFetched)
2209 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2210 if (!pceltFetched) pceltFetched = &fetched;
2211 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2214 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2218 ULONG *pceltFetched)
2221 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2223 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2224 if (hr == S_OK) *pceltFetched = celt;
2228 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2230 BIND_OPTS *pbindopts)
2236 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2238 BIND_OPTS2 *pbindopts)
2244 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2246 BIND_OPTS *pbindopts)
2252 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2254 BIND_OPTS2 *pbindopts)
2260 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2264 ULONG *pceltFetched)
2267 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2268 if (!pceltFetched) pceltFetched = &fetched;
2269 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2272 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2276 ULONG *pceltFetched)
2279 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2281 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2282 if (hr == S_OK) *pceltFetched = celt;
2286 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2287 IRunnableObject* This)
2291 memset(&rv, 0, sizeof rv);
2295 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2296 IRunnableObject* This)
2302 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2305 IMoniker *pmkToLeft,
2313 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2316 IMoniker *pmkToLeft,
2318 IUnknown **ppvResult)
2324 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2327 IMoniker *pmkToLeft,
2335 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2338 IMoniker *pmkToLeft,
2346 HRESULT CALLBACK IEnumString_Next_Proxy(
2350 ULONG *pceltFetched)
2353 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2354 if (!pceltFetched) pceltFetched = &fetched;
2355 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2358 HRESULT __RPC_STUB IEnumString_Next_Stub(
2362 ULONG *pceltFetched)
2365 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2367 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2368 if (hr == S_OK) *pceltFetched = celt;
2372 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2373 ISequentialStream* This,
2381 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2383 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2384 if(pcbRead) *pcbRead = read;
2389 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2390 ISequentialStream* This,
2395 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2396 return ISequentialStream_Read(This, pv, cb, pcbRead);
2399 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2400 ISequentialStream* This,
2408 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2410 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2411 if(pcbWritten) *pcbWritten = written;
2416 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2417 ISequentialStream* This,
2422 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2423 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2426 HRESULT CALLBACK IStream_Seek_Proxy(
2428 LARGE_INTEGER dlibMove,
2430 ULARGE_INTEGER *plibNewPosition)
2432 ULARGE_INTEGER newpos;
2435 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2437 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2438 if(plibNewPosition) *plibNewPosition = newpos;
2443 HRESULT __RPC_STUB IStream_Seek_Stub(
2445 LARGE_INTEGER dlibMove,
2447 ULARGE_INTEGER *plibNewPosition)
2449 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2450 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2453 HRESULT CALLBACK IStream_CopyTo_Proxy(
2457 ULARGE_INTEGER *pcbRead,
2458 ULARGE_INTEGER *pcbWritten)
2460 ULARGE_INTEGER read, written;
2463 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2465 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2466 if(pcbRead) *pcbRead = read;
2467 if(pcbWritten) *pcbWritten = written;
2472 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2476 ULARGE_INTEGER *pcbRead,
2477 ULARGE_INTEGER *pcbWritten)
2479 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2481 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2484 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2488 ULONG *pceltFetched)
2491 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2492 if (!pceltFetched) pceltFetched = &fetched;
2493 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2496 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2500 ULONG *pceltFetched)
2503 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2505 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2506 if (hr == S_OK) *pceltFetched = celt;
2510 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2518 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2519 if(reserved1) WARN("reserved1 %p\n", reserved1);
2521 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2524 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2533 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2534 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2536 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2539 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2544 IEnumSTATSTG **ppenum)
2546 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2547 if(reserved2) WARN("reserved2 %p\n", reserved2);
2549 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2552 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2558 IEnumSTATSTG **ppenum)
2560 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2561 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2563 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2566 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2568 ULARGE_INTEGER ulOffset,
2576 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2578 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2579 if(pcbRead) *pcbRead = read;
2584 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2586 ULARGE_INTEGER ulOffset,
2591 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2592 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2595 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2597 ULARGE_INTEGER ulOffset,
2605 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2607 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2608 if(pcbWritten) *pcbWritten = written;
2613 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2615 ULARGE_INTEGER ulOffset,
2620 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2621 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2624 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2625 IFillLockBytes* This,
2633 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2635 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2636 if(pcbWritten) *pcbWritten = written;
2641 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2642 IFillLockBytes* This,
2647 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2648 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2651 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2652 IFillLockBytes* This,
2653 ULARGE_INTEGER ulOffset,
2661 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2663 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2664 if(pcbWritten) *pcbWritten = written;
2669 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2670 IFillLockBytes* This,
2671 ULARGE_INTEGER ulOffset,
2676 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2677 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2680 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2681 IEnumFORMATETC* This,
2684 ULONG *pceltFetched)
2687 if (!pceltFetched) pceltFetched = &fetched;
2688 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2691 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2692 IEnumFORMATETC* This,
2695 ULONG *pceltFetched)
2699 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2700 if (hr == S_OK) *pceltFetched = celt;
2704 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2705 IEnumSTATDATA* This,
2708 ULONG *pceltFetched)
2711 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2712 if (!pceltFetched) pceltFetched = &fetched;
2713 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2716 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2717 IEnumSTATDATA* This,
2720 ULONG *pceltFetched)
2723 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2725 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2726 if (hr == S_OK) *pceltFetched = celt;
2730 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2732 FORMATETC *pFormatetc,
2738 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2740 FORMATETC *pFormatetc,
2741 ASYNC_STGMEDIUM *pStgmed)
2747 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2755 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2764 void CALLBACK IAdviseSink_OnRename_Proxy(
2771 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2779 void CALLBACK IAdviseSink_OnSave_Proxy(
2785 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2792 void CALLBACK IAdviseSink_OnClose_Proxy(
2798 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2805 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2812 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2820 HRESULT CALLBACK IDataObject_GetData_Proxy(
2822 FORMATETC *pformatetcIn,
2825 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2826 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2829 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2831 FORMATETC *pformatetcIn,
2832 STGMEDIUM *pRemoteMedium)
2834 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2835 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2838 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2840 FORMATETC *pformatetc,
2843 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2844 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2847 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2849 FORMATETC *pformatetc,
2850 STGMEDIUM *pRemoteMedium)
2852 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2853 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2856 HRESULT CALLBACK IDataObject_SetData_Proxy(
2858 FORMATETC *pformatetc,
2866 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2868 FORMATETC *pformatetc,
2869 FLAG_STGMEDIUM *pmedium,
2876 /* call_as/local stubs for oleidl.idl */
2878 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2879 IOleInPlaceActiveObject* This,
2886 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2887 IOleInPlaceActiveObject* This)
2893 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2894 IOleInPlaceActiveObject* This,
2896 IOleInPlaceUIWindow *pUIWindow,
2903 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2904 IOleInPlaceActiveObject* This,
2907 IOleInPlaceUIWindow *pUIWindow,
2914 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2916 LPDATAOBJECT pDataObject,
2924 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2926 LPDATAOBJECT pDataObject,
2934 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2938 ULONG *pceltFetched)
2941 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2942 if (!pceltFetched) pceltFetched = &fetched;
2943 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2946 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2950 ULONG *pceltFetched)
2953 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2955 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2956 if (hr == S_OK) *pceltFetched = celt;
2960 HRESULT CALLBACK IViewObject_Draw_Proxy(
2965 DVTARGETDEVICE *ptd,
2968 LPCRECTL lprcBounds,
2969 LPCRECTL lprcWBounds,
2970 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
2971 ULONG_PTR dwContinue)
2977 HRESULT __RPC_STUB IViewObject_Draw_Stub(
2982 DVTARGETDEVICE *ptd,
2983 ULONG_PTR hdcTargetDev,
2985 LPCRECTL lprcBounds,
2986 LPCRECTL lprcWBounds,
2987 IContinue *pContinue)
2993 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
2998 DVTARGETDEVICE *ptd,
3000 LOGPALETTE **ppColorSet)
3006 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3011 DVTARGETDEVICE *ptd,
3012 ULONG_PTR hicTargetDev,
3013 LOGPALETTE **ppColorSet)
3019 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3030 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3041 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3045 IAdviseSink **ppAdvSink)
3051 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3055 IAdviseSink **ppAdvSink)