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_w(format));
174 memcpy(pBuffer, format, len * sizeof(WCHAR));
175 pBuffer += len * sizeof(WCHAR);
179 *(DWORD *)pBuffer = WDT_INPROC_CALL;
181 *(DWORD *)pBuffer = *pCF;
188 /******************************************************************************
189 * CLIPFORMAT_UserUnmarshal [OLE32.@]
191 * Unmarshals a clip format from a buffer.
194 * pFlags [I] Flags. See notes.
195 * pBuffer [I] Buffer to marshal the clip format from.
196 * pCF [O] Address that receive the unmarshaled clip format.
199 * The end of the marshaled data in the buffer.
202 * Even though the function is documented to take a pointer to an unsigned
203 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
204 * the first parameter is an unsigned long.
205 * This function is only intended to be called by the RPC runtime.
207 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
211 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
213 fContext = *(DWORD *)pBuffer;
216 if (fContext == WDT_INPROC_CALL)
218 *pCF = *(CLIPFORMAT *)pBuffer;
221 else if (fContext == WDT_REMOTE_CALL)
226 /* pointer ID for registered clip format string */
227 if (*(DWORD *)pBuffer == 0)
228 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
231 len = *(UINT *)pBuffer;
232 pBuffer += sizeof(UINT);
233 if (*(UINT *)pBuffer != 0)
234 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
235 pBuffer += sizeof(UINT);
236 if (*(UINT *)pBuffer != len)
237 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
238 pBuffer += sizeof(UINT);
239 if (((WCHAR *)pBuffer)[len - 1] != '\0')
240 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
241 TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
242 cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
243 pBuffer += len * sizeof(WCHAR);
245 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
249 /* code not really appropriate, but nearest I can find */
250 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
254 /******************************************************************************
255 * CLIPFORMAT_UserFree [OLE32.@]
257 * Frees an unmarshaled clip format.
260 * pFlags [I] Flags. See notes.
261 * pCF [I] Clip format to free.
264 * The end of the marshaled data in the buffer.
267 * Even though the function is documented to take a pointer to an unsigned
268 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
269 * structure, of which the first parameter is an unsigned long.
270 * This function is only intended to be called by the RPC runtime.
272 void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
274 /* there is no inverse of the RegisterClipboardFormat function,
275 * so nothing to do */
278 static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
280 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
282 ERR("can't remote a local handle\n");
283 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
286 return StartingSize + sizeof(RemotableHandle);
289 static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
291 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
292 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
294 ERR("can't remote a local handle\n");
295 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
298 remhandle->fContext = WDT_INPROC_CALL;
299 remhandle->u.hInproc = (LONG_PTR)*handle;
300 return pBuffer + sizeof(RemotableHandle);
303 static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
305 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
306 if (remhandle->fContext != WDT_INPROC_CALL)
307 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
308 *handle = (HANDLE)(LONG_PTR)remhandle->u.hInproc;
309 return pBuffer + sizeof(RemotableHandle);
312 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
317 #define IMPL_WIREM_HANDLE(type) \
318 ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \
320 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \
321 return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
324 unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
326 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \
327 return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
330 unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
332 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \
333 return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
336 void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \
338 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \
339 handle_UserFree(pFlags, (HANDLE *)handle); \
342 IMPL_WIREM_HANDLE(HACCEL)
343 IMPL_WIREM_HANDLE(HMENU)
344 IMPL_WIREM_HANDLE(HWND)
346 /******************************************************************************
347 * HGLOBAL_UserSize [OLE32.@]
349 * Calculates the buffer size required to marshal an HGLOBAL.
352 * pFlags [I] Flags. See notes.
353 * StartingSize [I] Starting size of the buffer. This value is added on to
354 * the buffer size required for the clip format.
355 * phGlobal [I] HGLOBAL to size.
358 * The buffer size required to marshal an HGLOBAL plus the starting size.
361 * Even though the function is documented to take a pointer to a ULONG in
362 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
363 * the first parameter is a ULONG.
364 * This function is only intended to be called by the RPC runtime.
366 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
368 ULONG size = StartingSize;
370 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
372 ALIGN_LENGTH(size, 3);
374 size += sizeof(ULONG);
376 if (LOWORD(*pFlags == MSHCTX_INPROC))
377 size += sizeof(HGLOBAL);
380 size += sizeof(ULONG);
384 size += 3 * sizeof(ULONG);
385 ret = GlobalSize(*phGlobal);
393 /******************************************************************************
394 * HGLOBAL_UserMarshal [OLE32.@]
396 * Marshals an HGLOBAL into a buffer.
399 * pFlags [I] Flags. See notes.
400 * pBuffer [I] Buffer to marshal the clip format into.
401 * phGlobal [I] HGLOBAL to marshal.
404 * The end of the marshaled data in the buffer.
407 * Even though the function is documented to take a pointer to a ULONG in
408 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
409 * the first parameter is a ULONG.
410 * This function is only intended to be called by the RPC runtime.
412 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
414 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
416 ALIGN_POINTER(pBuffer, 3);
418 if (LOWORD(*pFlags == MSHCTX_INPROC))
420 if (sizeof(*phGlobal) == 8)
421 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
423 *(ULONG *)pBuffer = WDT_INPROC_CALL;
424 pBuffer += sizeof(ULONG);
425 *(HGLOBAL *)pBuffer = *phGlobal;
426 pBuffer += sizeof(HGLOBAL);
430 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
431 pBuffer += sizeof(ULONG);
432 *(ULONG *)pBuffer = (ULONG)*phGlobal;
433 pBuffer += sizeof(ULONG);
436 const unsigned char *memory;
437 SIZE_T size = GlobalSize(*phGlobal);
438 *(ULONG *)pBuffer = (ULONG)size;
439 pBuffer += sizeof(ULONG);
440 *(ULONG *)pBuffer = (ULONG)*phGlobal;
441 pBuffer += sizeof(ULONG);
442 *(ULONG *)pBuffer = (ULONG)size;
443 pBuffer += sizeof(ULONG);
445 memory = GlobalLock(*phGlobal);
446 memcpy(pBuffer, memory, size);
448 GlobalUnlock(*phGlobal);
455 /******************************************************************************
456 * HGLOBAL_UserUnmarshal [OLE32.@]
458 * Unmarshals an HGLOBAL from a buffer.
461 * pFlags [I] Flags. See notes.
462 * pBuffer [I] Buffer to marshal the clip format from.
463 * phGlobal [O] Address that receive the unmarshaled HGLOBAL.
466 * The end of the marshaled data in the buffer.
469 * Even though the function is documented to take a pointer to an ULONG in
470 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
471 * the first parameter is an ULONG.
472 * This function is only intended to be called by the RPC runtime.
474 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
478 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
480 ALIGN_POINTER(pBuffer, 3);
482 fContext = *(ULONG *)pBuffer;
483 pBuffer += sizeof(ULONG);
485 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
486 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
488 *phGlobal = *(HGLOBAL *)pBuffer;
489 pBuffer += sizeof(*phGlobal);
491 else if (fContext == WDT_REMOTE_CALL)
495 handle = *(ULONG *)pBuffer;
496 pBuffer += sizeof(ULONG);
503 size = *(ULONG *)pBuffer;
504 pBuffer += sizeof(ULONG);
505 /* redundancy is bad - it means you have to check consistency like
507 if (*(ULONG *)pBuffer != handle)
509 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
512 pBuffer += sizeof(ULONG);
513 /* redundancy is bad - it means you have to check consistency like
515 if (*(ULONG *)pBuffer != size)
517 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
520 pBuffer += sizeof(ULONG);
522 /* FIXME: check size is not too big */
524 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
525 memory = GlobalLock(*phGlobal);
526 memcpy(memory, pBuffer, size);
528 GlobalUnlock(*phGlobal);
534 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
539 /******************************************************************************
540 * HGLOBAL_UserFree [OLE32.@]
542 * Frees an unmarshaled HGLOBAL.
545 * pFlags [I] Flags. See notes.
546 * phGlobal [I] HGLOBAL to free.
549 * The end of the marshaled data in the buffer.
552 * Even though the function is documented to take a pointer to a ULONG in
553 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
554 * which the first parameter is a ULONG.
555 * This function is only intended to be called by the RPC runtime.
557 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
559 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
561 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
562 GlobalFree(*phGlobal);
565 /******************************************************************************
566 * HBITMAP_UserSize [OLE32.@]
568 * Calculates the buffer size required to marshal a bitmap.
571 * pFlags [I] Flags. See notes.
572 * StartingSize [I] Starting size of the buffer. This value is added on to
573 * the buffer size required for the clip format.
574 * phBmp [I] Bitmap to size.
577 * The buffer size required to marshal an bitmap plus the starting size.
580 * Even though the function is documented to take a pointer to a ULONG in
581 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
582 * the first parameter is a ULONG.
583 * This function is only intended to be called by the RPC runtime.
585 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
591 /******************************************************************************
592 * HBITMAP_UserMarshal [OLE32.@]
594 * Marshals a bitmap into a buffer.
597 * pFlags [I] Flags. See notes.
598 * pBuffer [I] Buffer to marshal the clip format into.
599 * phBmp [I] Bitmap to marshal.
602 * The end of the marshaled data in the buffer.
605 * Even though the function is documented to take a pointer to a ULONG in
606 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
607 * the first parameter is a ULONG.
608 * This function is only intended to be called by the RPC runtime.
610 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
616 /******************************************************************************
617 * HBITMAP_UserUnmarshal [OLE32.@]
619 * Unmarshals a bitmap from a buffer.
622 * pFlags [I] Flags. See notes.
623 * pBuffer [I] Buffer to marshal the clip format from.
624 * phBmp [O] Address that receive the unmarshaled bitmap.
627 * The end of the marshaled data in the buffer.
630 * Even though the function is documented to take a pointer to an ULONG in
631 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
632 * the first parameter is an ULONG.
633 * This function is only intended to be called by the RPC runtime.
635 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
641 /******************************************************************************
642 * HBITMAP_UserFree [OLE32.@]
644 * Frees an unmarshaled bitmap.
647 * pFlags [I] Flags. See notes.
648 * phBmp [I] Bitmap to free.
651 * The end of the marshaled data in the buffer.
654 * Even though the function is documented to take a pointer to a ULONG in
655 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
656 * which the first parameter is a ULONG.
657 * This function is only intended to be called by the RPC runtime.
659 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
664 /******************************************************************************
665 * HICON_UserSize [OLE32.@]
667 * Calculates the buffer size required to marshal an icon.
670 * pFlags [I] Flags. See notes.
671 * StartingSize [I] Starting size of the buffer. This value is added on to
672 * the buffer size required for the icon.
673 * phIcon [I] Icon to size.
676 * The buffer size required to marshal an icon plus the starting size.
679 * Even though the function is documented to take a pointer to a ULONG in
680 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
681 * the first parameter is a ULONG.
682 * This function is only intended to be called by the RPC runtime.
684 ULONG __RPC_USER HICON_UserSize(ULONG *pFlags, ULONG StartingSize, HICON *phIcon)
690 /******************************************************************************
691 * HICON_UserMarshal [OLE32.@]
693 * Marshals an icon into a buffer.
696 * pFlags [I] Flags. See notes.
697 * pBuffer [I] Buffer to marshal the icon into.
698 * phIcon [I] Icon to marshal.
701 * The end of the marshaled data in the buffer.
704 * Even though the function is documented to take a pointer to a ULONG in
705 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
706 * the first parameter is a ULONG.
707 * This function is only intended to be called by the RPC runtime.
709 unsigned char * __RPC_USER HICON_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
715 /******************************************************************************
716 * HICON_UserUnmarshal [OLE32.@]
718 * Unmarshals an icon from a buffer.
721 * pFlags [I] Flags. See notes.
722 * pBuffer [I] Buffer to marshal the icon from.
723 * phIcon [O] Address that receive the unmarshaled icon.
726 * The end of the marshaled data in the buffer.
729 * Even though the function is documented to take a pointer to an ULONG in
730 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
731 * the first parameter is an ULONG.
732 * This function is only intended to be called by the RPC runtime.
734 unsigned char * __RPC_USER HICON_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
740 /******************************************************************************
741 * HICON_UserFree [OLE32.@]
743 * Frees an unmarshaled icon.
746 * pFlags [I] Flags. See notes.
747 * phIcon [I] Icon to free.
750 * The end of the marshaled data in the buffer.
753 * Even though the function is documented to take a pointer to a ULONG in
754 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
755 * which the first parameter is a ULONG.
756 * This function is only intended to be called by the RPC runtime.
758 void __RPC_USER HICON_UserFree(ULONG *pFlags, HICON *phIcon)
763 /******************************************************************************
764 * HDC_UserSize [OLE32.@]
766 * Calculates the buffer size required to marshal an HDC.
769 * pFlags [I] Flags. See notes.
770 * StartingSize [I] Starting size of the buffer. This value is added on to
771 * the buffer size required for the clip format.
772 * phGlobal [I] HDC to size.
775 * The buffer size required to marshal an HDC plus the starting size.
778 * Even though the function is documented to take a pointer to a ULONG in
779 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
780 * the first parameter is a ULONG.
781 * This function is only intended to be called by the RPC runtime.
783 ULONG __RPC_USER HDC_UserSize(ULONG *pFlags, ULONG StartingSize, HDC *phdc)
789 /******************************************************************************
790 * HDC_UserMarshal [OLE32.@]
792 * Marshals an HDC into a buffer.
795 * pFlags [I] Flags. See notes.
796 * pBuffer [I] Buffer to marshal the clip format into.
797 * phdc [I] HDC to marshal.
800 * The end of the marshaled data in the buffer.
803 * Even though the function is documented to take a pointer to a ULONG in
804 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
805 * the first parameter is a ULONG.
806 * This function is only intended to be called by the RPC runtime.
808 unsigned char * __RPC_USER HDC_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
814 /******************************************************************************
815 * HDC_UserUnmarshal [OLE32.@]
817 * Unmarshals an HDC from a buffer.
820 * pFlags [I] Flags. See notes.
821 * pBuffer [I] Buffer to marshal the clip format from.
822 * phdc [O] Address that receive the unmarshaled HDC.
825 * The end of the marshaled data in the buffer.
828 * Even though the function is documented to take a pointer to an ULONG in
829 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
830 * the first parameter is an ULONG.
831 * This function is only intended to be called by the RPC runtime.
833 unsigned char * __RPC_USER HDC_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
839 /******************************************************************************
840 * HDC_UserFree [OLE32.@]
842 * Frees an unmarshaled HDC.
845 * pFlags [I] Flags. See notes.
846 * phdc [I] HDC to free.
849 * The end of the marshaled data in the buffer.
852 * Even though the function is documented to take a pointer to a ULONG in
853 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
854 * which the first parameter is a ULONG.
855 * This function is only intended to be called by the RPC runtime.
857 void __RPC_USER HDC_UserFree(ULONG *pFlags, HDC *phdc)
862 /******************************************************************************
863 * HPALETTE_UserSize [OLE32.@]
865 * Calculates the buffer size required to marshal a palette.
868 * pFlags [I] Flags. See notes.
869 * StartingSize [I] Starting size of the buffer. This value is added on to
870 * the buffer size required for the clip format.
871 * phPal [I] Palette to size.
874 * The buffer size required to marshal a palette plus the starting size.
877 * Even though the function is documented to take a pointer to a ULONG in
878 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
879 * the first parameter is a ULONG.
880 * This function is only intended to be called by the RPC runtime.
882 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
888 /******************************************************************************
889 * HPALETTE_UserMarshal [OLE32.@]
891 * Marshals a palette into a buffer.
894 * pFlags [I] Flags. See notes.
895 * pBuffer [I] Buffer to marshal the clip format into.
896 * phPal [I] Palette to marshal.
899 * The end of the marshaled data in the buffer.
902 * Even though the function is documented to take a pointer to a ULONG in
903 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
904 * the first parameter is a ULONG.
905 * This function is only intended to be called by the RPC runtime.
907 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
913 /******************************************************************************
914 * HPALETTE_UserUnmarshal [OLE32.@]
916 * Unmarshals a palette from a buffer.
919 * pFlags [I] Flags. See notes.
920 * pBuffer [I] Buffer to marshal the clip format from.
921 * phPal [O] Address that receive the unmarshaled palette.
924 * The end of the marshaled data in the buffer.
927 * Even though the function is documented to take a pointer to an ULONG in
928 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
929 * the first parameter is an ULONG.
930 * This function is only intended to be called by the RPC runtime.
932 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
938 /******************************************************************************
939 * HPALETTE_UserFree [OLE32.@]
941 * Frees an unmarshaled palette.
944 * pFlags [I] Flags. See notes.
945 * phPal [I] Palette to free.
948 * The end of the marshaled data in the buffer.
951 * Even though the function is documented to take a pointer to a ULONG in
952 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
953 * which the first parameter is a ULONG.
954 * This function is only intended to be called by the RPC runtime.
956 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
962 /******************************************************************************
963 * HMETAFILE_UserSize [OLE32.@]
965 * Calculates the buffer size required to marshal a metafile.
968 * pFlags [I] Flags. See notes.
969 * StartingSize [I] Starting size of the buffer. This value is added on to
970 * the buffer size required for the clip format.
971 * phmf [I] Metafile to size.
974 * The buffer size required to marshal a metafile plus the starting size.
977 * Even though the function is documented to take a pointer to a ULONG in
978 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
979 * the first parameter is a ULONG.
980 * This function is only intended to be called by the RPC runtime.
982 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
984 ULONG size = StartingSize;
986 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
988 ALIGN_LENGTH(size, 3);
990 size += sizeof(ULONG);
991 if (LOWORD(*pFlags) == MSHCTX_INPROC)
992 size += sizeof(ULONG_PTR);
995 size += sizeof(ULONG);
1001 size += 2 * sizeof(ULONG);
1002 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1010 /******************************************************************************
1011 * HMETAFILE_UserMarshal [OLE32.@]
1013 * Marshals a metafile into a buffer.
1016 * pFlags [I] Flags. See notes.
1017 * pBuffer [I] Buffer to marshal the clip format into.
1018 * phEmf [I] Metafile to marshal.
1021 * The end of the marshaled data in the buffer.
1024 * Even though the function is documented to take a pointer to a ULONG in
1025 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1026 * the first parameter is a ULONG.
1027 * This function is only intended to be called by the RPC runtime.
1029 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1031 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
1033 ALIGN_POINTER(pBuffer, 3);
1035 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1037 if (sizeof(*phmf) == 8)
1038 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1040 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1041 pBuffer += sizeof(ULONG);
1042 *(HMETAFILE *)pBuffer = *phmf;
1043 pBuffer += sizeof(HMETAFILE);
1047 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1048 pBuffer += sizeof(ULONG);
1049 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1050 pBuffer += sizeof(ULONG);
1054 UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1056 *(ULONG *)pBuffer = mfsize;
1057 pBuffer += sizeof(ULONG);
1058 *(ULONG *)pBuffer = mfsize;
1059 pBuffer += sizeof(ULONG);
1060 GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
1068 /******************************************************************************
1069 * HMETAFILE_UserUnmarshal [OLE32.@]
1071 * Unmarshals a metafile from a buffer.
1074 * pFlags [I] Flags. See notes.
1075 * pBuffer [I] Buffer to marshal the clip format from.
1076 * phmf [O] Address that receive the unmarshaled metafile.
1079 * The end of the marshaled data in the buffer.
1082 * Even though the function is documented to take a pointer to an ULONG in
1083 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1084 * the first parameter is an ULONG.
1085 * This function is only intended to be called by the RPC runtime.
1087 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1091 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
1093 ALIGN_POINTER(pBuffer, 3);
1095 fContext = *(ULONG *)pBuffer;
1096 pBuffer += sizeof(ULONG);
1098 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
1099 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
1101 *phmf = *(HMETAFILE *)pBuffer;
1102 pBuffer += sizeof(*phmf);
1104 else if (fContext == WDT_REMOTE_CALL)
1108 handle = *(ULONG *)pBuffer;
1109 pBuffer += sizeof(ULONG);
1114 size = *(ULONG *)pBuffer;
1115 pBuffer += sizeof(ULONG);
1116 if (size != *(ULONG *)pBuffer)
1118 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1121 pBuffer += sizeof(ULONG);
1122 *phmf = SetMetaFileBitsEx(size, pBuffer);
1129 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1134 /******************************************************************************
1135 * HMETAFILE_UserFree [OLE32.@]
1137 * Frees an unmarshaled metafile.
1140 * pFlags [I] Flags. See notes.
1141 * phmf [I] Metafile to free.
1144 * The end of the marshaled data in the buffer.
1147 * Even though the function is documented to take a pointer to a ULONG in
1148 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1149 * which the first parameter is a ULONG.
1150 * This function is only intended to be called by the RPC runtime.
1152 void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
1154 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
1156 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1157 DeleteMetaFile(*phmf);
1160 /******************************************************************************
1161 * HENHMETAFILE_UserSize [OLE32.@]
1163 * Calculates the buffer size required to marshal an enhanced metafile.
1166 * pFlags [I] Flags. See notes.
1167 * StartingSize [I] Starting size of the buffer. This value is added on to
1168 * the buffer size required for the clip format.
1169 * phEmf [I] Enhanced metafile to size.
1172 * The buffer size required to marshal an enhanced metafile plus the starting size.
1175 * Even though the function is documented to take a pointer to a ULONG in
1176 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1177 * the first parameter is a ULONG.
1178 * This function is only intended to be called by the RPC runtime.
1180 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
1182 ULONG size = StartingSize;
1184 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
1186 size += sizeof(ULONG);
1187 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1188 size += sizeof(ULONG_PTR);
1191 size += sizeof(ULONG);
1197 size += 2 * sizeof(ULONG);
1198 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1206 /******************************************************************************
1207 * HENHMETAFILE_UserMarshal [OLE32.@]
1209 * Marshals an enhance metafile into a buffer.
1212 * pFlags [I] Flags. See notes.
1213 * pBuffer [I] Buffer to marshal the clip format into.
1214 * phEmf [I] Enhanced metafile to marshal.
1217 * The end of the marshaled data in the buffer.
1220 * Even though the function is documented to take a pointer to a ULONG in
1221 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1222 * the first parameter is a ULONG.
1223 * This function is only intended to be called by the RPC runtime.
1225 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1227 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1229 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1231 if (sizeof(*phEmf) == 8)
1232 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1234 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1235 pBuffer += sizeof(ULONG);
1236 *(HENHMETAFILE *)pBuffer = *phEmf;
1237 pBuffer += sizeof(HENHMETAFILE);
1241 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1242 pBuffer += sizeof(ULONG);
1243 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1244 pBuffer += sizeof(ULONG);
1248 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1250 *(ULONG *)pBuffer = emfsize;
1251 pBuffer += sizeof(ULONG);
1252 *(ULONG *)pBuffer = emfsize;
1253 pBuffer += sizeof(ULONG);
1254 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1262 /******************************************************************************
1263 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1265 * Unmarshals an enhanced metafile from a buffer.
1268 * pFlags [I] Flags. See notes.
1269 * pBuffer [I] Buffer to marshal the clip format from.
1270 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
1273 * The end of the marshaled data in the buffer.
1276 * Even though the function is documented to take a pointer to an ULONG in
1277 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1278 * the first parameter is an ULONG.
1279 * This function is only intended to be called by the RPC runtime.
1281 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1285 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1287 fContext = *(ULONG *)pBuffer;
1288 pBuffer += sizeof(ULONG);
1290 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1291 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1293 *phEmf = *(HENHMETAFILE *)pBuffer;
1294 pBuffer += sizeof(*phEmf);
1296 else if (fContext == WDT_REMOTE_CALL)
1300 handle = *(ULONG *)pBuffer;
1301 pBuffer += sizeof(ULONG);
1306 size = *(ULONG *)pBuffer;
1307 pBuffer += sizeof(ULONG);
1308 if (size != *(ULONG *)pBuffer)
1310 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1313 pBuffer += sizeof(ULONG);
1314 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1321 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1326 /******************************************************************************
1327 * HENHMETAFILE_UserFree [OLE32.@]
1329 * Frees an unmarshaled enhanced metafile.
1332 * pFlags [I] Flags. See notes.
1333 * phEmf [I] Enhanced metafile to free.
1336 * The end of the marshaled data in the buffer.
1339 * Even though the function is documented to take a pointer to a ULONG in
1340 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1341 * which the first parameter is a ULONG.
1342 * This function is only intended to be called by the RPC runtime.
1344 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1346 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1348 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1349 DeleteEnhMetaFile(*phEmf);
1352 /******************************************************************************
1353 * HMETAFILEPICT_UserSize [OLE32.@]
1355 * Calculates the buffer size required to marshal an metafile pict.
1358 * pFlags [I] Flags. See notes.
1359 * StartingSize [I] Starting size of the buffer. This value is added on to
1360 * the buffer size required for the clip format.
1361 * phMfp [I] Metafile pict to size.
1364 * The buffer size required to marshal a metafile pict plus the starting size.
1367 * Even though the function is documented to take a pointer to a ULONG in
1368 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1369 * the first parameter is a ULONG.
1370 * This function is only intended to be called by the RPC runtime.
1372 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1374 ULONG size = StartingSize;
1376 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1378 size += sizeof(ULONG);
1380 if(LOWORD(*pFlags) == MSHCTX_INPROC)
1381 size += sizeof(HMETAFILEPICT);
1384 size += sizeof(ULONG);
1388 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1390 /* FIXME: raise an exception if mfpict is NULL? */
1391 size += 3 * sizeof(ULONG);
1392 size += sizeof(ULONG);
1394 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1396 GlobalUnlock(*phMfp);
1403 /******************************************************************************
1404 * HMETAFILEPICT_UserMarshal [OLE32.@]
1406 * Marshals a metafile pict into a buffer.
1409 * pFlags [I] Flags. See notes.
1410 * pBuffer [I] Buffer to marshal the clip format into.
1411 * phMfp [I] Metafile pict to marshal.
1414 * The end of the marshaled data in the buffer.
1417 * Even though the function is documented to take a pointer to a ULONG in
1418 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1419 * the first parameter is a ULONG.
1420 * This function is only intended to be called by the RPC runtime.
1422 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1424 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1426 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1428 if (sizeof(HMETAFILEPICT) == 8)
1429 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1431 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1432 pBuffer += sizeof(ULONG);
1433 *(HMETAFILEPICT *)pBuffer = *phMfp;
1434 pBuffer += sizeof(HMETAFILEPICT);
1438 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1439 pBuffer += sizeof(ULONG);
1440 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
1441 pBuffer += sizeof(ULONG);
1445 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1446 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1448 /* FIXME: raise an exception if mfpict is NULL? */
1449 remmfpict->mm = mfpict->mm;
1450 remmfpict->xExt = mfpict->xExt;
1451 remmfpict->yExt = mfpict->yExt;
1452 pBuffer += 3 * sizeof(ULONG);
1453 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1454 pBuffer += sizeof(ULONG);
1456 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1458 GlobalUnlock(*phMfp);
1464 /******************************************************************************
1465 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1467 * Unmarshals an metafile pict from a buffer.
1470 * pFlags [I] Flags. See notes.
1471 * pBuffer [I] Buffer to marshal the clip format from.
1472 * phMfp [O] Address that receive the unmarshaled metafile pict.
1475 * The end of the marshaled data in the buffer.
1478 * Even though the function is documented to take a pointer to an ULONG in
1479 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1480 * the first parameter is an ULONG.
1481 * This function is only intended to be called by the RPC runtime.
1483 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1487 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1489 fContext = *(ULONG *)pBuffer;
1490 pBuffer += sizeof(ULONG);
1492 if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
1494 *phMfp = *(HMETAFILEPICT *)pBuffer;
1495 pBuffer += sizeof(HMETAFILEPICT);
1499 ULONG handle = *(ULONG *)pBuffer;
1500 pBuffer += sizeof(ULONG);
1505 METAFILEPICT *mfpict;
1506 const remoteMETAFILEPICT *remmfpict;
1507 ULONG user_marshal_prefix;
1509 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1511 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1513 RpcRaiseException(E_OUTOFMEMORY);
1515 mfpict = GlobalLock(*phMfp);
1516 mfpict->mm = remmfpict->mm;
1517 mfpict->xExt = remmfpict->xExt;
1518 mfpict->yExt = remmfpict->yExt;
1519 pBuffer += 3 * sizeof(ULONG);
1520 user_marshal_prefix = *(ULONG *)pBuffer;
1521 pBuffer += sizeof(ULONG);
1523 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1524 RpcRaiseException(RPC_X_INVALID_TAG);
1526 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1528 GlobalUnlock(*phMfp);
1534 /******************************************************************************
1535 * HMETAFILEPICT_UserFree [OLE32.@]
1537 * Frees an unmarshaled metafile pict.
1540 * pFlags [I] Flags. See notes.
1541 * phMfp [I] Metafile pict to free.
1544 * The end of the marshaled data in the buffer.
1547 * Even though the function is documented to take a pointer to a ULONG in
1548 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1549 * which the first parameter is a ULONG.
1550 * This function is only intended to be called by the RPC runtime.
1552 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1554 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1556 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1558 METAFILEPICT *mfpict;
1560 mfpict = GlobalLock(*phMfp);
1561 /* FIXME: raise an exception if mfpict is NULL? */
1562 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1563 GlobalUnlock(*phMfp);
1569 /******************************************************************************
1570 * WdtpInterfacePointer_UserSize [OLE32.@]
1572 * Calculates the buffer size required to marshal an interface pointer.
1575 * pFlags [I] Flags. See notes.
1576 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1577 * punk [I] Interface pointer to size.
1578 * StartingSize [I] Starting size of the buffer. This value is added on to
1579 * the buffer size required for the clip format.
1580 * riid [I] ID of interface to size.
1583 * The buffer size required to marshal an interface pointer plus the starting size.
1586 * Even though the function is documented to take a pointer to a ULONG in
1587 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1588 * the first parameter is a ULONG.
1590 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1592 DWORD marshal_size = 0;
1595 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1597 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1598 if(FAILED(hr)) return StartingSize;
1600 ALIGN_LENGTH(StartingSize, 3);
1601 StartingSize += 2 * sizeof(DWORD);
1602 return StartingSize + marshal_size;
1605 /******************************************************************************
1606 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1608 * Marshals an interface pointer into a buffer.
1611 * pFlags [I] Flags. See notes.
1612 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1613 * pBuffer [I] Buffer to marshal the clip format into.
1614 * punk [I] Interface pointer to marshal.
1615 * riid [I] ID of interface to marshal.
1618 * The end of the marshaled data in the buffer.
1621 * Even though the function is documented to take a pointer to a ULONG in
1622 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1623 * the first parameter is a ULONG.
1625 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1627 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1632 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1635 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1641 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1643 IStream_Release(stm);
1647 ALIGN_POINTER(pBuffer, 3);
1648 size = GlobalSize(h);
1650 *(DWORD *)pBuffer = size;
1651 pBuffer += sizeof(DWORD);
1652 *(DWORD *)pBuffer = size;
1653 pBuffer += sizeof(DWORD);
1655 ptr = GlobalLock(h);
1656 memcpy(pBuffer, ptr, size);
1659 IStream_Release(stm);
1660 return pBuffer + size;
1663 /******************************************************************************
1664 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1666 * Unmarshals an interface pointer from a buffer.
1669 * pFlags [I] Flags. See notes.
1670 * pBuffer [I] Buffer to marshal the clip format from.
1671 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1672 * riid [I] ID of interface to unmarshal.
1675 * The end of the marshaled data in the buffer.
1678 * Even though the function is documented to take a pointer to an ULONG in
1679 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1680 * the first parameter is an ULONG.
1682 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1690 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1692 ALIGN_POINTER(pBuffer, 3);
1694 size = *(DWORD *)pBuffer;
1695 pBuffer += sizeof(DWORD);
1696 if(size != *(DWORD *)pBuffer)
1697 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1699 pBuffer += sizeof(DWORD);
1701 /* FIXME: sanity check on size */
1703 h = GlobalAlloc(GMEM_MOVEABLE, size);
1704 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1706 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1709 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1712 ptr = GlobalLock(h);
1713 memcpy(ptr, pBuffer, size);
1716 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1717 IStream_Release(stm);
1719 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1721 return pBuffer + size;
1724 /******************************************************************************
1725 * WdtpInterfacePointer_UserFree [OLE32.@]
1727 * Releases an unmarshaled interface pointer.
1730 * punk [I] Interface pointer to release.
1735 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1737 TRACE("(%p)\n", punk);
1738 if(punk) IUnknown_Release(punk);
1741 /******************************************************************************
1742 * STGMEDIUM_UserSize [OLE32.@]
1744 * Calculates the buffer size required to marshal an STGMEDIUM.
1747 * pFlags [I] Flags. See notes.
1748 * StartingSize [I] Starting size of the buffer. This value is added on to
1749 * the buffer size required for the clip format.
1750 * pStgMedium [I] STGMEDIUM to size.
1753 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1756 * Even though the function is documented to take a pointer to a ULONG in
1757 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1758 * the first parameter is a ULONG.
1759 * This function is only intended to be called by the RPC runtime.
1761 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1763 ULONG size = StartingSize;
1765 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1767 ALIGN_LENGTH(size, 3);
1769 size += 2 * sizeof(DWORD);
1770 if (pStgMedium->tymed != TYMED_NULL)
1771 size += sizeof(DWORD);
1773 switch (pStgMedium->tymed)
1776 TRACE("TYMED_NULL\n");
1779 TRACE("TYMED_HGLOBAL\n");
1780 if (pStgMedium->u.hGlobal)
1781 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1784 TRACE("TYMED_FILE\n");
1785 if (pStgMedium->u.lpszFileName)
1787 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1788 size += 3 * sizeof(DWORD) +
1789 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1793 TRACE("TYMED_ISTREAM\n");
1794 if (pStgMedium->u.pstm)
1797 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1798 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1799 IUnknown_Release(unk);
1802 case TYMED_ISTORAGE:
1803 TRACE("TYMED_ISTORAGE\n");
1804 if (pStgMedium->u.pstg)
1807 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1808 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1809 IUnknown_Release(unk);
1813 TRACE("TYMED_GDI\n");
1814 if (pStgMedium->u.hBitmap)
1816 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1820 TRACE("TYMED_MFPICT\n");
1821 if (pStgMedium->u.hMetaFilePict)
1822 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1825 TRACE("TYMED_ENHMF\n");
1826 if (pStgMedium->u.hEnhMetaFile)
1827 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1830 RaiseException(DV_E_TYMED, 0, 0, NULL);
1833 if (pStgMedium->pUnkForRelease)
1834 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1839 /******************************************************************************
1840 * STGMEDIUM_UserMarshal [OLE32.@]
1842 * Marshals a STGMEDIUM into a buffer.
1845 * pFlags [I] Flags. See notes.
1846 * pBuffer [I] Buffer to marshal the clip format into.
1847 * pCF [I] STGMEDIUM to marshal.
1850 * The end of the marshaled data in the buffer.
1853 * Even though the function is documented to take a pointer to a ULONG in
1854 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1855 * the first parameter is a ULONG.
1856 * This function is only intended to be called by the RPC runtime.
1858 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1860 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1862 ALIGN_POINTER(pBuffer, 3);
1864 *(DWORD *)pBuffer = pStgMedium->tymed;
1865 pBuffer += sizeof(DWORD);
1866 if (pStgMedium->tymed != TYMED_NULL)
1868 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1869 pBuffer += sizeof(DWORD);
1871 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1872 pBuffer += sizeof(DWORD);
1874 switch (pStgMedium->tymed)
1877 TRACE("TYMED_NULL\n");
1880 TRACE("TYMED_HGLOBAL\n");
1881 if (pStgMedium->u.hGlobal)
1882 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1885 TRACE("TYMED_FILE\n");
1886 if (pStgMedium->u.lpszFileName)
1889 len = strlenW(pStgMedium->u.lpszFileName);
1891 *(DWORD *)pBuffer = len + 1;
1892 pBuffer += sizeof(DWORD);
1894 *(DWORD *)pBuffer = 0;
1895 pBuffer += sizeof(DWORD);
1897 *(DWORD *)pBuffer = len + 1;
1898 pBuffer += sizeof(DWORD);
1900 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1901 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1905 TRACE("TYMED_ISTREAM\n");
1906 if (pStgMedium->u.pstm)
1909 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1910 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1911 IUnknown_Release(unk);
1914 case TYMED_ISTORAGE:
1915 TRACE("TYMED_ISTORAGE\n");
1916 if (pStgMedium->u.pstg)
1919 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1920 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1921 IUnknown_Release(unk);
1925 TRACE("TYMED_GDI\n");
1926 if (pStgMedium->u.hBitmap)
1928 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1932 TRACE("TYMED_MFPICT\n");
1933 if (pStgMedium->u.hMetaFilePict)
1934 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1937 TRACE("TYMED_ENHMF\n");
1938 if (pStgMedium->u.hEnhMetaFile)
1939 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1942 RaiseException(DV_E_TYMED, 0, 0, NULL);
1945 if (pStgMedium->pUnkForRelease)
1946 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1951 /******************************************************************************
1952 * STGMEDIUM_UserUnmarshal [OLE32.@]
1954 * Unmarshals a STGMEDIUM from a buffer.
1957 * pFlags [I] Flags. See notes.
1958 * pBuffer [I] Buffer to marshal the clip format from.
1959 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1962 * The end of the marshaled data in the buffer.
1965 * Even though the function is documented to take a pointer to an ULONG in
1966 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1967 * the first parameter is an ULONG.
1968 * This function is only intended to be called by the RPC runtime.
1970 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1975 ALIGN_POINTER(pBuffer, 3);
1977 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1979 pStgMedium->tymed = *(DWORD *)pBuffer;
1980 pBuffer += sizeof(DWORD);
1981 if (pStgMedium->tymed != TYMED_NULL)
1983 content = *(DWORD *)pBuffer;
1984 pBuffer += sizeof(DWORD);
1986 releaseunk = *(DWORD *)pBuffer;
1987 pBuffer += sizeof(DWORD);
1989 switch (pStgMedium->tymed)
1992 TRACE("TYMED_NULL\n");
1995 TRACE("TYMED_HGLOBAL\n");
1997 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
2000 TRACE("TYMED_FILE\n");
2005 conformance = *(DWORD *)pBuffer;
2006 pBuffer += sizeof(DWORD);
2007 if (*(DWORD *)pBuffer != 0)
2009 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
2010 RpcRaiseException(RPC_S_INVALID_BOUND);
2013 pBuffer += sizeof(DWORD);
2014 variance = *(DWORD *)pBuffer;
2015 pBuffer += sizeof(DWORD);
2016 if (conformance != variance)
2018 ERR("conformance (%d) and variance (%d) should be equal\n",
2019 conformance, variance);
2020 RpcRaiseException(RPC_S_INVALID_BOUND);
2023 if (conformance > 0x7fffffff)
2025 ERR("conformance 0x%x too large\n", conformance);
2026 RpcRaiseException(RPC_S_INVALID_BOUND);
2029 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2030 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2031 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2032 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2033 pBuffer += variance * sizeof(WCHAR);
2036 pStgMedium->u.lpszFileName = NULL;
2039 TRACE("TYMED_ISTREAM\n");
2042 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
2045 pStgMedium->u.pstm = NULL;
2047 case TYMED_ISTORAGE:
2048 TRACE("TYMED_ISTORAGE\n");
2051 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
2054 pStgMedium->u.pstg = NULL;
2057 TRACE("TYMED_GDI\n");
2060 FIXME("not implemented for GDI object\n");
2063 pStgMedium->u.hBitmap = NULL;
2066 TRACE("TYMED_MFPICT\n");
2068 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2070 pStgMedium->u.hMetaFilePict = NULL;
2073 TRACE("TYMED_ENHMF\n");
2075 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2077 pStgMedium->u.hEnhMetaFile = NULL;
2080 RaiseException(DV_E_TYMED, 0, 0, NULL);
2083 pStgMedium->pUnkForRelease = NULL;
2085 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2090 /******************************************************************************
2091 * STGMEDIUM_UserFree [OLE32.@]
2093 * Frees an unmarshaled STGMEDIUM.
2096 * pFlags [I] Flags. See notes.
2097 * pStgmedium [I] STGMEDIUM to free.
2100 * The end of the marshaled data in the buffer.
2103 * Even though the function is documented to take a pointer to a ULONG in
2104 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2105 * which the first parameter is a ULONG.
2106 * This function is only intended to be called by the RPC runtime.
2108 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2110 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2112 ReleaseStgMedium(pStgMedium);
2115 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2118 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2121 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2124 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2127 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2130 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2133 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2136 STGMEDIUM_UserFree(pFlags, pStgMedium);
2139 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2142 return StartingSize;
2145 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2151 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2157 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2162 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2165 return StartingSize;
2168 unsigned char * __RPC_USER SNB_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2174 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2180 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2185 /* call_as/local stubs for unknwn.idl */
2187 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2188 IClassFactory* This,
2189 IUnknown *pUnkOuter,
2193 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2197 ERR("aggregation is not allowed on remote objects\n");
2198 return CLASS_E_NOAGGREGATION;
2200 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2201 (IUnknown **) ppvObject);
2204 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2205 IClassFactory* This,
2207 IUnknown **ppvObject)
2209 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2210 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2213 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2214 IClassFactory* This,
2221 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2222 IClassFactory* This,
2229 /* call_as/local stubs for objidl.idl */
2231 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2235 ULONG *pceltFetched)
2238 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2239 if (!pceltFetched) pceltFetched = &fetched;
2240 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2243 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2247 ULONG *pceltFetched)
2250 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2252 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2253 if (hr == S_OK) *pceltFetched = celt;
2257 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2259 BIND_OPTS *pbindopts)
2265 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2267 BIND_OPTS2 *pbindopts)
2273 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2275 BIND_OPTS *pbindopts)
2281 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2283 BIND_OPTS2 *pbindopts)
2289 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2293 ULONG *pceltFetched)
2296 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2297 if (!pceltFetched) pceltFetched = &fetched;
2298 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2301 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2305 ULONG *pceltFetched)
2308 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2310 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2311 if (hr == S_OK) *pceltFetched = celt;
2315 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2316 IRunnableObject* This)
2320 memset(&rv, 0, sizeof rv);
2324 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2325 IRunnableObject* This)
2331 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2334 IMoniker *pmkToLeft,
2342 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2345 IMoniker *pmkToLeft,
2347 IUnknown **ppvResult)
2353 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2356 IMoniker *pmkToLeft,
2364 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2367 IMoniker *pmkToLeft,
2375 HRESULT CALLBACK IEnumString_Next_Proxy(
2379 ULONG *pceltFetched)
2382 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2383 if (!pceltFetched) pceltFetched = &fetched;
2384 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2387 HRESULT __RPC_STUB IEnumString_Next_Stub(
2391 ULONG *pceltFetched)
2394 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2396 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2397 if (hr == S_OK) *pceltFetched = celt;
2401 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2402 ISequentialStream* This,
2410 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2412 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2413 if(pcbRead) *pcbRead = read;
2418 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2419 ISequentialStream* This,
2424 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2425 return ISequentialStream_Read(This, pv, cb, pcbRead);
2428 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2429 ISequentialStream* This,
2437 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2439 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2440 if(pcbWritten) *pcbWritten = written;
2445 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2446 ISequentialStream* This,
2451 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2452 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2455 HRESULT CALLBACK IStream_Seek_Proxy(
2457 LARGE_INTEGER dlibMove,
2459 ULARGE_INTEGER *plibNewPosition)
2461 ULARGE_INTEGER newpos;
2464 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2466 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2467 if(plibNewPosition) *plibNewPosition = newpos;
2472 HRESULT __RPC_STUB IStream_Seek_Stub(
2474 LARGE_INTEGER dlibMove,
2476 ULARGE_INTEGER *plibNewPosition)
2478 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2479 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2482 HRESULT CALLBACK IStream_CopyTo_Proxy(
2486 ULARGE_INTEGER *pcbRead,
2487 ULARGE_INTEGER *pcbWritten)
2489 ULARGE_INTEGER read, written;
2492 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2494 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2495 if(pcbRead) *pcbRead = read;
2496 if(pcbWritten) *pcbWritten = written;
2501 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2505 ULARGE_INTEGER *pcbRead,
2506 ULARGE_INTEGER *pcbWritten)
2508 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2510 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2513 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2517 ULONG *pceltFetched)
2520 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2521 if (!pceltFetched) pceltFetched = &fetched;
2522 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2525 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2529 ULONG *pceltFetched)
2532 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2534 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2535 if (hr == S_OK) *pceltFetched = celt;
2539 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2547 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2548 if(reserved1) WARN("reserved1 %p\n", reserved1);
2550 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2553 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2562 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2563 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2565 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2568 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2573 IEnumSTATSTG **ppenum)
2575 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2576 if(reserved2) WARN("reserved2 %p\n", reserved2);
2578 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2581 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2587 IEnumSTATSTG **ppenum)
2589 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2590 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2592 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2595 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2597 ULARGE_INTEGER ulOffset,
2605 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2607 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2608 if(pcbRead) *pcbRead = read;
2613 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2615 ULARGE_INTEGER ulOffset,
2620 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2621 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2624 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2626 ULARGE_INTEGER ulOffset,
2634 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2636 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2637 if(pcbWritten) *pcbWritten = written;
2642 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2644 ULARGE_INTEGER ulOffset,
2649 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2650 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2653 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2654 IFillLockBytes* This,
2662 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2664 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2665 if(pcbWritten) *pcbWritten = written;
2670 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2671 IFillLockBytes* This,
2676 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2677 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2680 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2681 IFillLockBytes* This,
2682 ULARGE_INTEGER ulOffset,
2690 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2692 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2693 if(pcbWritten) *pcbWritten = written;
2698 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2699 IFillLockBytes* This,
2700 ULARGE_INTEGER ulOffset,
2705 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2706 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2709 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2710 IEnumFORMATETC* This,
2713 ULONG *pceltFetched)
2716 if (!pceltFetched) pceltFetched = &fetched;
2717 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2720 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2721 IEnumFORMATETC* This,
2724 ULONG *pceltFetched)
2728 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2729 if (hr == S_OK) *pceltFetched = celt;
2733 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2734 IEnumSTATDATA* This,
2737 ULONG *pceltFetched)
2740 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2741 if (!pceltFetched) pceltFetched = &fetched;
2742 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2745 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2746 IEnumSTATDATA* This,
2749 ULONG *pceltFetched)
2752 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2754 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2755 if (hr == S_OK) *pceltFetched = celt;
2759 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2761 FORMATETC *pFormatetc,
2767 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2769 FORMATETC *pFormatetc,
2770 ASYNC_STGMEDIUM *pStgmed)
2776 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2784 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2793 void CALLBACK IAdviseSink_OnRename_Proxy(
2800 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2808 void CALLBACK IAdviseSink_OnSave_Proxy(
2814 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2821 void CALLBACK IAdviseSink_OnClose_Proxy(
2827 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2834 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2841 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2849 HRESULT CALLBACK IDataObject_GetData_Proxy(
2851 FORMATETC *pformatetcIn,
2854 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2855 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2858 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2860 FORMATETC *pformatetcIn,
2861 STGMEDIUM *pRemoteMedium)
2863 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2864 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2867 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2869 FORMATETC *pformatetc,
2872 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2873 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2876 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2878 FORMATETC *pformatetc,
2879 STGMEDIUM *pRemoteMedium)
2881 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2882 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2885 HRESULT CALLBACK IDataObject_SetData_Proxy(
2887 FORMATETC *pformatetc,
2895 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2897 FORMATETC *pformatetc,
2898 FLAG_STGMEDIUM *pmedium,
2905 /* call_as/local stubs for oleidl.idl */
2907 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2908 IOleInPlaceActiveObject* This,
2915 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2916 IOleInPlaceActiveObject* This)
2922 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2923 IOleInPlaceActiveObject* This,
2925 IOleInPlaceUIWindow *pUIWindow,
2932 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2933 IOleInPlaceActiveObject* This,
2936 IOleInPlaceUIWindow *pUIWindow,
2943 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2945 LPDATAOBJECT pDataObject,
2953 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2955 LPDATAOBJECT pDataObject,
2963 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2967 ULONG *pceltFetched)
2970 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2971 if (!pceltFetched) pceltFetched = &fetched;
2972 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2975 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2979 ULONG *pceltFetched)
2982 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2984 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2985 if (hr == S_OK) *pceltFetched = celt;
2989 HRESULT CALLBACK IViewObject_Draw_Proxy(
2994 DVTARGETDEVICE *ptd,
2997 LPCRECTL lprcBounds,
2998 LPCRECTL lprcWBounds,
2999 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
3000 ULONG_PTR dwContinue)
3006 HRESULT __RPC_STUB IViewObject_Draw_Stub(
3011 DVTARGETDEVICE *ptd,
3012 ULONG_PTR hdcTargetDev,
3014 LPCRECTL lprcBounds,
3015 LPCRECTL lprcWBounds,
3016 IContinue *pContinue)
3022 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3027 DVTARGETDEVICE *ptd,
3029 LOGPALETTE **ppColorSet)
3035 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3040 DVTARGETDEVICE *ptd,
3041 ULONG_PTR hicTargetDev,
3042 LOGPALETTE **ppColorSet)
3048 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3059 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3070 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3074 IAdviseSink **ppAdvSink)
3080 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3084 IAdviseSink **ppAdvSink)