push 0a0aa53cd365a71ca6121b6df157ca635450378f
[wine/hacks.git] / dlls / ole32 / usrmarshal.c
blobf180f42f8ca24da61e3d40f7ffc6665b46a86cb5
1 /*
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
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winerror.h"
35 #include "ole2.h"
36 #include "oleauto.h"
37 #include "rpcproxy.h"
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)
55 char buf[12];
56 const char* loword;
57 switch (LOWORD(*pFlags))
59 case MSHCTX_LOCAL:
60 loword="MSHCTX_LOCAL";
61 break;
62 case MSHCTX_NOSHAREDMEM:
63 loword="MSHCTX_NOSHAREDMEM";
64 break;
65 case MSHCTX_DIFFERENTMACHINE:
66 loword="MSHCTX_DIFFERENTMACHINE";
67 break;
68 case MSHCTX_INPROC:
69 loword="MSHCTX_INPROC";
70 break;
71 default:
72 sprintf(buf, "%d", LOWORD(*pFlags));
73 loword=buf;
76 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
77 return wine_dbg_sprintf("MAKELONG(NDR_LOCAL_REPRESENTATION, %s)", loword);
78 else
79 return wine_dbg_sprintf("MAKELONG(0x%04x, %s)", HIWORD(*pFlags), loword);
82 /******************************************************************************
83 * CLIPFORMAT_UserSize [OLE32.@]
85 * Calculates the buffer size required to marshal a clip format.
87 * PARAMS
88 * pFlags [I] Flags. See notes.
89 * StartingSize [I] Starting size of the buffer. This value is added on to
90 * the buffer size required for the clip format.
91 * pCF [I] Clip format to size.
93 * RETURNS
94 * The buffer size required to marshal a clip format plus the starting size.
96 * NOTES
97 * Even though the function is documented to take a pointer to an unsigned
98 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
99 * the first parameter is an unsigned long.
100 * This function is only intended to be called by the RPC runtime.
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);
108 size += 8;
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))
114 WCHAR format[255];
115 INT ret;
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);
121 if (!ret)
122 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
123 size += (ret + 1) * sizeof(WCHAR);
125 return size;
128 /******************************************************************************
129 * CLIPFORMAT_UserMarshal [OLE32.@]
131 * Marshals a clip format into a buffer.
133 * PARAMS
134 * pFlags [I] Flags. See notes.
135 * pBuffer [I] Buffer to marshal the clip format into.
136 * pCF [I] Clip format to marshal.
138 * RETURNS
139 * The end of the marshaled data in the buffer.
141 * NOTES
142 * Even though the function is documented to take a pointer to an unsigned
143 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
144 * the first parameter is an unsigned long.
145 * This function is only intended to be called by the RPC runtime.
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))
155 WCHAR format[255];
156 UINT len;
158 *(DWORD *)pBuffer = WDT_REMOTE_CALL;
159 pBuffer += 4;
160 *(DWORD *)pBuffer = *pCF;
161 pBuffer += 4;
163 len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
164 if (!len)
165 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
166 len += 1;
167 *(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);
179 else
181 *(DWORD *)pBuffer = WDT_INPROC_CALL;
182 pBuffer += 4;
183 *(DWORD *)pBuffer = *pCF;
184 pBuffer += 4;
187 return pBuffer;
190 /******************************************************************************
191 * CLIPFORMAT_UserUnmarshal [OLE32.@]
193 * Unmarshals a clip format from a buffer.
195 * PARAMS
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.
200 * RETURNS
201 * The end of the marshaled data in the buffer.
203 * NOTES
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)
211 LONG fContext;
213 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
215 fContext = *(DWORD *)pBuffer;
216 pBuffer += 4;
218 if (fContext == WDT_INPROC_CALL)
220 *pCF = *(CLIPFORMAT *)pBuffer;
221 pBuffer += 4;
223 else if (fContext == WDT_REMOTE_CALL)
225 CLIPFORMAT cf;
226 UINT len;
228 /* pointer ID for registered clip format string */
229 if (*(DWORD *)pBuffer == 0)
230 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
231 pBuffer += 4;
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);
246 if (!cf)
247 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
248 *pCF = cf;
250 else
251 /* code not really appropriate, but nearest I can find */
252 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
253 return pBuffer;
256 /******************************************************************************
257 * CLIPFORMAT_UserFree [OLE32.@]
259 * Frees an unmarshaled clip format.
261 * PARAMS
262 * pFlags [I] Flags. See notes.
263 * pCF [I] Clip format to free.
265 * RETURNS
266 * The end of the marshaled data in the buffer.
268 * NOTES
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);
286 return StartingSize;
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);
298 return pBuffer;
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)(LONG_PTR)remhandle->u.hInproc;
311 return pBuffer + sizeof(RemotableHandle);
314 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
316 /* nothing to do */
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.
353 * PARAMS
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.
359 * RETURNS
360 * The buffer size required to marshal an HGLOBAL plus the starting size.
362 * NOTES
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);
380 else
382 size += sizeof(ULONG);
383 if (*phGlobal)
385 SIZE_T ret;
386 size += 3 * sizeof(ULONG);
387 ret = GlobalSize(*phGlobal);
388 size += (ULONG)ret;
392 return size;
395 /******************************************************************************
396 * HGLOBAL_UserMarshal [OLE32.@]
398 * Marshals an HGLOBAL into a buffer.
400 * PARAMS
401 * pFlags [I] Flags. See notes.
402 * pBuffer [I] Buffer to marshal the clip format into.
403 * phGlobal [I] HGLOBAL to marshal.
405 * RETURNS
406 * The end of the marshaled data in the buffer.
408 * NOTES
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;
424 else
425 *(ULONG *)pBuffer = WDT_INPROC_CALL;
426 pBuffer += sizeof(ULONG);
427 *(HGLOBAL *)pBuffer = *phGlobal;
428 pBuffer += sizeof(HGLOBAL);
430 else
432 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
433 pBuffer += sizeof(ULONG);
434 *(ULONG *)pBuffer = (ULONG)*phGlobal;
435 pBuffer += sizeof(ULONG);
436 if (*phGlobal)
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);
449 pBuffer += size;
450 GlobalUnlock(*phGlobal);
454 return pBuffer;
457 /******************************************************************************
458 * HGLOBAL_UserUnmarshal [OLE32.@]
460 * Unmarshals an HGLOBAL from a buffer.
462 * PARAMS
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.
467 * RETURNS
468 * The end of the marshaled data in the buffer.
470 * NOTES
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)
478 ULONG fContext;
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)
495 ULONG handle;
497 handle = *(ULONG *)pBuffer;
498 pBuffer += sizeof(ULONG);
500 if (handle)
502 ULONG size;
503 void *memory;
505 size = *(ULONG *)pBuffer;
506 pBuffer += sizeof(ULONG);
507 /* redundancy is bad - it means you have to check consistency like
508 * this: */
509 if (*(ULONG *)pBuffer != handle)
511 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
512 return pBuffer;
514 pBuffer += sizeof(ULONG);
515 /* redundancy is bad - it means you have to check consistency like
516 * this: */
517 if (*(ULONG *)pBuffer != size)
519 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
520 return pBuffer;
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);
529 pBuffer += size;
530 GlobalUnlock(*phGlobal);
532 else
533 *phGlobal = NULL;
535 else
536 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
538 return pBuffer;
541 /******************************************************************************
542 * HGLOBAL_UserFree [OLE32.@]
544 * Frees an unmarshaled HGLOBAL.
546 * PARAMS
547 * pFlags [I] Flags. See notes.
548 * phGlobal [I] HGLOBAL to free.
550 * RETURNS
551 * The end of the marshaled data in the buffer.
553 * NOTES
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.
572 * PARAMS
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.
578 * RETURNS
579 * The buffer size required to marshal an bitmap plus the starting size.
581 * NOTES
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)
589 FIXME(":stub\n");
590 return StartingSize;
593 /******************************************************************************
594 * HBITMAP_UserMarshal [OLE32.@]
596 * Marshals a bitmap into a buffer.
598 * PARAMS
599 * pFlags [I] Flags. See notes.
600 * pBuffer [I] Buffer to marshal the clip format into.
601 * phBmp [I] Bitmap to marshal.
603 * RETURNS
604 * The end of the marshaled data in the buffer.
606 * NOTES
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)
614 FIXME(":stub\n");
615 return pBuffer;
618 /******************************************************************************
619 * HBITMAP_UserUnmarshal [OLE32.@]
621 * Unmarshals a bitmap from a buffer.
623 * PARAMS
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.
628 * RETURNS
629 * The end of the marshaled data in the buffer.
631 * NOTES
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)
639 FIXME(":stub\n");
640 return pBuffer;
643 /******************************************************************************
644 * HBITMAP_UserFree [OLE32.@]
646 * Frees an unmarshaled bitmap.
648 * PARAMS
649 * pFlags [I] Flags. See notes.
650 * phBmp [I] Bitmap to free.
652 * RETURNS
653 * The end of the marshaled data in the buffer.
655 * NOTES
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)
663 FIXME(":stub\n");
666 /******************************************************************************
667 * HICON_UserSize [OLE32.@]
669 * Calculates the buffer size required to marshal an icon.
671 * PARAMS
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.
677 * RETURNS
678 * The buffer size required to marshal an icon plus the starting size.
680 * NOTES
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)
688 FIXME(":stub\n");
689 return StartingSize;
692 /******************************************************************************
693 * HICON_UserMarshal [OLE32.@]
695 * Marshals an icon into a buffer.
697 * PARAMS
698 * pFlags [I] Flags. See notes.
699 * pBuffer [I] Buffer to marshal the icon into.
700 * phIcon [I] Icon to marshal.
702 * RETURNS
703 * The end of the marshaled data in the buffer.
705 * NOTES
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)
713 FIXME(":stub\n");
714 return pBuffer;
717 /******************************************************************************
718 * HICON_UserUnmarshal [OLE32.@]
720 * Unmarshals an icon from a buffer.
722 * PARAMS
723 * pFlags [I] Flags. See notes.
724 * pBuffer [I] Buffer to marshal the icon from.
725 * phIcon [O] Address that receive the unmarshaled icon.
727 * RETURNS
728 * The end of the marshaled data in the buffer.
730 * NOTES
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)
738 FIXME(":stub\n");
739 return pBuffer;
742 /******************************************************************************
743 * HICON_UserFree [OLE32.@]
745 * Frees an unmarshaled icon.
747 * PARAMS
748 * pFlags [I] Flags. See notes.
749 * phIcon [I] Icon to free.
751 * RETURNS
752 * The end of the marshaled data in the buffer.
754 * NOTES
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)
762 FIXME(":stub\n");
765 /******************************************************************************
766 * HDC_UserSize [OLE32.@]
768 * Calculates the buffer size required to marshal an HDC.
770 * PARAMS
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.
776 * RETURNS
777 * The buffer size required to marshal an HDC plus the starting size.
779 * NOTES
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)
787 FIXME(":stub\n");
788 return StartingSize;
791 /******************************************************************************
792 * HDC_UserMarshal [OLE32.@]
794 * Marshals an HDC into a buffer.
796 * PARAMS
797 * pFlags [I] Flags. See notes.
798 * pBuffer [I] Buffer to marshal the clip format into.
799 * phdc [I] HDC to marshal.
801 * RETURNS
802 * The end of the marshaled data in the buffer.
804 * NOTES
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)
812 FIXME(":stub\n");
813 return pBuffer;
816 /******************************************************************************
817 * HDC_UserUnmarshal [OLE32.@]
819 * Unmarshals an HDC from a buffer.
821 * PARAMS
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.
826 * RETURNS
827 * The end of the marshaled data in the buffer.
829 * NOTES
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)
837 FIXME(":stub\n");
838 return pBuffer;
841 /******************************************************************************
842 * HDC_UserFree [OLE32.@]
844 * Frees an unmarshaled HDC.
846 * PARAMS
847 * pFlags [I] Flags. See notes.
848 * phdc [I] HDC to free.
850 * RETURNS
851 * The end of the marshaled data in the buffer.
853 * NOTES
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)
861 FIXME(":stub\n");
864 /******************************************************************************
865 * HPALETTE_UserSize [OLE32.@]
867 * Calculates the buffer size required to marshal a palette.
869 * PARAMS
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.
875 * RETURNS
876 * The buffer size required to marshal a palette plus the starting size.
878 * NOTES
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)
886 FIXME(":stub\n");
887 return StartingSize;
890 /******************************************************************************
891 * HPALETTE_UserMarshal [OLE32.@]
893 * Marshals a palette into a buffer.
895 * PARAMS
896 * pFlags [I] Flags. See notes.
897 * pBuffer [I] Buffer to marshal the clip format into.
898 * phPal [I] Palette to marshal.
900 * RETURNS
901 * The end of the marshaled data in the buffer.
903 * NOTES
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)
911 FIXME(":stub\n");
912 return pBuffer;
915 /******************************************************************************
916 * HPALETTE_UserUnmarshal [OLE32.@]
918 * Unmarshals a palette from a buffer.
920 * PARAMS
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.
925 * RETURNS
926 * The end of the marshaled data in the buffer.
928 * NOTES
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)
936 FIXME(":stub\n");
937 return pBuffer;
940 /******************************************************************************
941 * HPALETTE_UserFree [OLE32.@]
943 * Frees an unmarshaled palette.
945 * PARAMS
946 * pFlags [I] Flags. See notes.
947 * phPal [I] Palette to free.
949 * RETURNS
950 * The end of the marshaled data in the buffer.
952 * NOTES
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)
960 FIXME(":stub\n");
964 /******************************************************************************
965 * HMETAFILE_UserSize [OLE32.@]
967 * Calculates the buffer size required to marshal a metafile.
969 * PARAMS
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.
975 * RETURNS
976 * The buffer size required to marshal a metafile plus the starting size.
978 * NOTES
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);
995 else
997 size += sizeof(ULONG);
999 if (*phmf)
1001 UINT mfsize;
1003 size += 2 * sizeof(ULONG);
1004 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1005 size += mfsize;
1009 return size;
1012 /******************************************************************************
1013 * HMETAFILE_UserMarshal [OLE32.@]
1015 * Marshals a metafile into a buffer.
1017 * PARAMS
1018 * pFlags [I] Flags. See notes.
1019 * pBuffer [I] Buffer to marshal the clip format into.
1020 * phEmf [I] Metafile to marshal.
1022 * RETURNS
1023 * The end of the marshaled data in the buffer.
1025 * NOTES
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;
1041 else
1042 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1043 pBuffer += sizeof(ULONG);
1044 *(HMETAFILE *)pBuffer = *phmf;
1045 pBuffer += sizeof(HMETAFILE);
1047 else
1049 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1050 pBuffer += sizeof(ULONG);
1051 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1052 pBuffer += sizeof(ULONG);
1054 if (*phmf)
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);
1063 pBuffer += mfsize;
1067 return pBuffer;
1070 /******************************************************************************
1071 * HMETAFILE_UserUnmarshal [OLE32.@]
1073 * Unmarshals a metafile from a buffer.
1075 * PARAMS
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.
1080 * RETURNS
1081 * The end of the marshaled data in the buffer.
1083 * NOTES
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)
1091 ULONG fContext;
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)
1108 ULONG handle;
1110 handle = *(ULONG *)pBuffer;
1111 pBuffer += sizeof(ULONG);
1113 if (handle)
1115 ULONG size;
1116 size = *(ULONG *)pBuffer;
1117 pBuffer += sizeof(ULONG);
1118 if (size != *(ULONG *)pBuffer)
1120 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1121 return pBuffer;
1123 pBuffer += sizeof(ULONG);
1124 *phmf = SetMetaFileBitsEx(size, pBuffer);
1125 pBuffer += size;
1127 else
1128 *phmf = NULL;
1130 else
1131 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1133 return pBuffer;
1136 /******************************************************************************
1137 * HMETAFILE_UserFree [OLE32.@]
1139 * Frees an unmarshaled metafile.
1141 * PARAMS
1142 * pFlags [I] Flags. See notes.
1143 * phmf [I] Metafile to free.
1145 * RETURNS
1146 * The end of the marshaled data in the buffer.
1148 * NOTES
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.
1167 * PARAMS
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.
1173 * RETURNS
1174 * The buffer size required to marshal an enhanced metafile plus the starting size.
1176 * NOTES
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);
1191 else
1193 size += sizeof(ULONG);
1195 if (*phEmf)
1197 UINT emfsize;
1199 size += 2 * sizeof(ULONG);
1200 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1201 size += emfsize;
1205 return size;
1208 /******************************************************************************
1209 * HENHMETAFILE_UserMarshal [OLE32.@]
1211 * Marshals an enhance metafile into a buffer.
1213 * PARAMS
1214 * pFlags [I] Flags. See notes.
1215 * pBuffer [I] Buffer to marshal the clip format into.
1216 * phEmf [I] Enhanced metafile to marshal.
1218 * RETURNS
1219 * The end of the marshaled data in the buffer.
1221 * NOTES
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;
1235 else
1236 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1237 pBuffer += sizeof(ULONG);
1238 *(HENHMETAFILE *)pBuffer = *phEmf;
1239 pBuffer += sizeof(HENHMETAFILE);
1241 else
1243 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1244 pBuffer += sizeof(ULONG);
1245 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1246 pBuffer += sizeof(ULONG);
1248 if (*phEmf)
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);
1257 pBuffer += emfsize;
1261 return pBuffer;
1264 /******************************************************************************
1265 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1267 * Unmarshals an enhanced metafile from a buffer.
1269 * PARAMS
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.
1274 * RETURNS
1275 * The end of the marshaled data in the buffer.
1277 * NOTES
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)
1285 ULONG fContext;
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)
1300 ULONG handle;
1302 handle = *(ULONG *)pBuffer;
1303 pBuffer += sizeof(ULONG);
1305 if (handle)
1307 ULONG size;
1308 size = *(ULONG *)pBuffer;
1309 pBuffer += sizeof(ULONG);
1310 if (size != *(ULONG *)pBuffer)
1312 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1313 return pBuffer;
1315 pBuffer += sizeof(ULONG);
1316 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1317 pBuffer += size;
1319 else
1320 *phEmf = NULL;
1322 else
1323 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1325 return pBuffer;
1328 /******************************************************************************
1329 * HENHMETAFILE_UserFree [OLE32.@]
1331 * Frees an unmarshaled enhanced metafile.
1333 * PARAMS
1334 * pFlags [I] Flags. See notes.
1335 * phEmf [I] Enhanced metafile to free.
1337 * RETURNS
1338 * The end of the marshaled data in the buffer.
1340 * NOTES
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.
1359 * PARAMS
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.
1365 * RETURNS
1366 * The buffer size required to marshal a metafile pict plus the starting size.
1368 * NOTES
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);
1382 if(LOWORD(*pFlags) == MSHCTX_INPROC)
1383 size += sizeof(HMETAFILEPICT);
1384 else
1386 size += sizeof(ULONG);
1388 if (*phMfp)
1390 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1392 /* FIXME: raise an exception if mfpict is NULL? */
1393 size += 3 * sizeof(ULONG);
1394 size += sizeof(ULONG);
1396 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1398 GlobalUnlock(*phMfp);
1402 return size;
1405 /******************************************************************************
1406 * HMETAFILEPICT_UserMarshal [OLE32.@]
1408 * Marshals a metafile pict into a buffer.
1410 * PARAMS
1411 * pFlags [I] Flags. See notes.
1412 * pBuffer [I] Buffer to marshal the clip format into.
1413 * phMfp [I] Metafile pict to marshal.
1415 * RETURNS
1416 * The end of the marshaled data in the buffer.
1418 * NOTES
1419 * Even though the function is documented to take a pointer to a ULONG in
1420 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1421 * the first parameter is a ULONG.
1422 * This function is only intended to be called by the RPC runtime.
1424 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1426 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1428 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1430 if (sizeof(HMETAFILEPICT) == 8)
1431 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1432 else
1433 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1434 pBuffer += sizeof(ULONG);
1435 *(HMETAFILEPICT *)pBuffer = *phMfp;
1436 pBuffer += sizeof(HMETAFILEPICT);
1438 else
1440 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1441 pBuffer += sizeof(ULONG);
1442 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
1443 pBuffer += sizeof(ULONG);
1445 if (*phMfp)
1447 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1448 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1450 /* FIXME: raise an exception if mfpict is NULL? */
1451 remmfpict->mm = mfpict->mm;
1452 remmfpict->xExt = mfpict->xExt;
1453 remmfpict->yExt = mfpict->yExt;
1454 pBuffer += 3 * sizeof(ULONG);
1455 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1456 pBuffer += sizeof(ULONG);
1458 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1460 GlobalUnlock(*phMfp);
1463 return pBuffer;
1466 /******************************************************************************
1467 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1469 * Unmarshals an metafile pict from a buffer.
1471 * PARAMS
1472 * pFlags [I] Flags. See notes.
1473 * pBuffer [I] Buffer to marshal the clip format from.
1474 * phMfp [O] Address that receive the unmarshaled metafile pict.
1476 * RETURNS
1477 * The end of the marshaled data in the buffer.
1479 * NOTES
1480 * Even though the function is documented to take a pointer to an ULONG in
1481 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1482 * the first parameter is an ULONG.
1483 * This function is only intended to be called by the RPC runtime.
1485 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1487 ULONG fContext;
1489 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1491 fContext = *(ULONG *)pBuffer;
1492 pBuffer += sizeof(ULONG);
1494 if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
1496 *phMfp = *(HMETAFILEPICT *)pBuffer;
1497 pBuffer += sizeof(HMETAFILEPICT);
1499 else
1501 ULONG handle = *(ULONG *)pBuffer;
1502 pBuffer += sizeof(ULONG);
1503 *phMfp = NULL;
1505 if(handle)
1507 METAFILEPICT *mfpict;
1508 const remoteMETAFILEPICT *remmfpict;
1509 ULONG user_marshal_prefix;
1511 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1513 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1514 if (!*phMfp)
1515 RpcRaiseException(E_OUTOFMEMORY);
1517 mfpict = GlobalLock(*phMfp);
1518 mfpict->mm = remmfpict->mm;
1519 mfpict->xExt = remmfpict->xExt;
1520 mfpict->yExt = remmfpict->yExt;
1521 pBuffer += 3 * sizeof(ULONG);
1522 user_marshal_prefix = *(ULONG *)pBuffer;
1523 pBuffer += sizeof(ULONG);
1525 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1526 RpcRaiseException(RPC_X_INVALID_TAG);
1528 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1530 GlobalUnlock(*phMfp);
1533 return pBuffer;
1536 /******************************************************************************
1537 * HMETAFILEPICT_UserFree [OLE32.@]
1539 * Frees an unmarshaled metafile pict.
1541 * PARAMS
1542 * pFlags [I] Flags. See notes.
1543 * phMfp [I] Metafile pict to free.
1545 * RETURNS
1546 * The end of the marshaled data in the buffer.
1548 * NOTES
1549 * Even though the function is documented to take a pointer to a ULONG in
1550 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1551 * which the first parameter is a ULONG.
1552 * This function is only intended to be called by the RPC runtime.
1554 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1556 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1558 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1560 METAFILEPICT *mfpict;
1562 mfpict = GlobalLock(*phMfp);
1563 /* FIXME: raise an exception if mfpict is NULL? */
1564 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1565 GlobalUnlock(*phMfp);
1567 GlobalFree(*phMfp);
1571 /******************************************************************************
1572 * WdtpInterfacePointer_UserSize [OLE32.@]
1574 * Calculates the buffer size required to marshal an interface pointer.
1576 * PARAMS
1577 * pFlags [I] Flags. See notes.
1578 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1579 * punk [I] Interface pointer to size.
1580 * StartingSize [I] Starting size of the buffer. This value is added on to
1581 * the buffer size required for the clip format.
1582 * riid [I] ID of interface to size.
1584 * RETURNS
1585 * The buffer size required to marshal an interface pointer plus the starting size.
1587 * NOTES
1588 * Even though the function is documented to take a pointer to a ULONG in
1589 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1590 * the first parameter is a ULONG.
1592 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1594 DWORD marshal_size = 0;
1595 HRESULT hr;
1597 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1599 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1600 if(FAILED(hr)) return StartingSize;
1602 ALIGN_LENGTH(StartingSize, 3);
1603 StartingSize += 2 * sizeof(DWORD);
1604 return StartingSize + marshal_size;
1607 /******************************************************************************
1608 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1610 * Marshals an interface pointer into a buffer.
1612 * PARAMS
1613 * pFlags [I] Flags. See notes.
1614 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1615 * pBuffer [I] Buffer to marshal the clip format into.
1616 * punk [I] Interface pointer to marshal.
1617 * riid [I] ID of interface to marshal.
1619 * RETURNS
1620 * The end of the marshaled data in the buffer.
1622 * NOTES
1623 * Even though the function is documented to take a pointer to a ULONG in
1624 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1625 * the first parameter is a ULONG.
1627 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1629 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1630 IStream *stm;
1631 DWORD size;
1632 void *ptr;
1634 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1636 if(!h) return NULL;
1637 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1639 GlobalFree(h);
1640 return NULL;
1643 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1645 IStream_Release(stm);
1646 return NULL;
1649 ALIGN_POINTER(pBuffer, 3);
1650 size = GlobalSize(h);
1652 *(DWORD *)pBuffer = size;
1653 pBuffer += sizeof(DWORD);
1654 *(DWORD *)pBuffer = size;
1655 pBuffer += sizeof(DWORD);
1657 ptr = GlobalLock(h);
1658 memcpy(pBuffer, ptr, size);
1659 GlobalUnlock(h);
1661 IStream_Release(stm);
1662 return pBuffer + size;
1665 /******************************************************************************
1666 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1668 * Unmarshals an interface pointer from a buffer.
1670 * PARAMS
1671 * pFlags [I] Flags. See notes.
1672 * pBuffer [I] Buffer to marshal the clip format from.
1673 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1674 * riid [I] ID of interface to unmarshal.
1676 * RETURNS
1677 * The end of the marshaled data in the buffer.
1679 * NOTES
1680 * Even though the function is documented to take a pointer to an ULONG in
1681 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1682 * the first parameter is an ULONG.
1684 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1686 HRESULT hr;
1687 HGLOBAL h;
1688 IStream *stm;
1689 DWORD size;
1690 void *ptr;
1692 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1694 ALIGN_POINTER(pBuffer, 3);
1696 size = *(DWORD *)pBuffer;
1697 pBuffer += sizeof(DWORD);
1698 if(size != *(DWORD *)pBuffer)
1699 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1701 pBuffer += sizeof(DWORD);
1703 /* FIXME: sanity check on size */
1705 h = GlobalAlloc(GMEM_MOVEABLE, size);
1706 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1708 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1710 GlobalFree(h);
1711 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1714 ptr = GlobalLock(h);
1715 memcpy(ptr, pBuffer, size);
1716 GlobalUnlock(h);
1718 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1719 IStream_Release(stm);
1721 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1723 return pBuffer + size;
1726 /******************************************************************************
1727 * WdtpInterfacePointer_UserFree [OLE32.@]
1729 * Releases an unmarshaled interface pointer.
1731 * PARAMS
1732 * punk [I] Interface pointer to release.
1734 * RETURNS
1735 * Nothing.
1737 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1739 TRACE("(%p)\n", punk);
1740 if(punk) IUnknown_Release(punk);
1743 /******************************************************************************
1744 * STGMEDIUM_UserSize [OLE32.@]
1746 * Calculates the buffer size required to marshal an STGMEDIUM.
1748 * PARAMS
1749 * pFlags [I] Flags. See notes.
1750 * StartingSize [I] Starting size of the buffer. This value is added on to
1751 * the buffer size required for the clip format.
1752 * pStgMedium [I] STGMEDIUM to size.
1754 * RETURNS
1755 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1757 * NOTES
1758 * Even though the function is documented to take a pointer to a ULONG in
1759 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1760 * the first parameter is a ULONG.
1761 * This function is only intended to be called by the RPC runtime.
1763 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1765 ULONG size = StartingSize;
1767 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1769 ALIGN_LENGTH(size, 3);
1771 size += 2 * sizeof(DWORD);
1772 if (pStgMedium->tymed != TYMED_NULL)
1773 size += sizeof(DWORD);
1775 switch (pStgMedium->tymed)
1777 case TYMED_NULL:
1778 TRACE("TYMED_NULL\n");
1779 break;
1780 case TYMED_HGLOBAL:
1781 TRACE("TYMED_HGLOBAL\n");
1782 if (pStgMedium->u.hGlobal)
1783 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1784 break;
1785 case TYMED_FILE:
1786 TRACE("TYMED_FILE\n");
1787 if (pStgMedium->u.lpszFileName)
1789 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1790 size += 3 * sizeof(DWORD) +
1791 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1793 break;
1794 case TYMED_ISTREAM:
1795 TRACE("TYMED_ISTREAM\n");
1796 if (pStgMedium->u.pstm)
1798 IUnknown *unk;
1799 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1800 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1801 IUnknown_Release(unk);
1803 break;
1804 case TYMED_ISTORAGE:
1805 TRACE("TYMED_ISTORAGE\n");
1806 if (pStgMedium->u.pstg)
1808 IUnknown *unk;
1809 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1810 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1811 IUnknown_Release(unk);
1813 break;
1814 case TYMED_GDI:
1815 TRACE("TYMED_GDI\n");
1816 if (pStgMedium->u.hBitmap)
1818 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1820 break;
1821 case TYMED_MFPICT:
1822 TRACE("TYMED_MFPICT\n");
1823 if (pStgMedium->u.hMetaFilePict)
1824 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1825 break;
1826 case TYMED_ENHMF:
1827 TRACE("TYMED_ENHMF\n");
1828 if (pStgMedium->u.hEnhMetaFile)
1829 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1830 break;
1831 default:
1832 RaiseException(DV_E_TYMED, 0, 0, NULL);
1835 if (pStgMedium->pUnkForRelease)
1836 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1838 return size;
1841 /******************************************************************************
1842 * STGMEDIUM_UserMarshal [OLE32.@]
1844 * Marshals a STGMEDIUM into a buffer.
1846 * PARAMS
1847 * pFlags [I] Flags. See notes.
1848 * pBuffer [I] Buffer to marshal the clip format into.
1849 * pCF [I] STGMEDIUM to marshal.
1851 * RETURNS
1852 * The end of the marshaled data in the buffer.
1854 * NOTES
1855 * Even though the function is documented to take a pointer to a ULONG in
1856 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1857 * the first parameter is a ULONG.
1858 * This function is only intended to be called by the RPC runtime.
1860 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1862 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1864 ALIGN_POINTER(pBuffer, 3);
1866 *(DWORD *)pBuffer = pStgMedium->tymed;
1867 pBuffer += sizeof(DWORD);
1868 if (pStgMedium->tymed != TYMED_NULL)
1870 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1871 pBuffer += sizeof(DWORD);
1873 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1874 pBuffer += sizeof(DWORD);
1876 switch (pStgMedium->tymed)
1878 case TYMED_NULL:
1879 TRACE("TYMED_NULL\n");
1880 break;
1881 case TYMED_HGLOBAL:
1882 TRACE("TYMED_HGLOBAL\n");
1883 if (pStgMedium->u.hGlobal)
1884 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1885 break;
1886 case TYMED_FILE:
1887 TRACE("TYMED_FILE\n");
1888 if (pStgMedium->u.lpszFileName)
1890 DWORD len;
1891 len = strlenW(pStgMedium->u.lpszFileName);
1892 /* conformance */
1893 *(DWORD *)pBuffer = len + 1;
1894 pBuffer += sizeof(DWORD);
1895 /* offset */
1896 *(DWORD *)pBuffer = 0;
1897 pBuffer += sizeof(DWORD);
1898 /* variance */
1899 *(DWORD *)pBuffer = len + 1;
1900 pBuffer += sizeof(DWORD);
1902 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1903 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1905 break;
1906 case TYMED_ISTREAM:
1907 TRACE("TYMED_ISTREAM\n");
1908 if (pStgMedium->u.pstm)
1910 IUnknown *unk;
1911 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1912 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1913 IUnknown_Release(unk);
1915 break;
1916 case TYMED_ISTORAGE:
1917 TRACE("TYMED_ISTORAGE\n");
1918 if (pStgMedium->u.pstg)
1920 IUnknown *unk;
1921 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1922 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1923 IUnknown_Release(unk);
1925 break;
1926 case TYMED_GDI:
1927 TRACE("TYMED_GDI\n");
1928 if (pStgMedium->u.hBitmap)
1930 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1932 break;
1933 case TYMED_MFPICT:
1934 TRACE("TYMED_MFPICT\n");
1935 if (pStgMedium->u.hMetaFilePict)
1936 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1937 break;
1938 case TYMED_ENHMF:
1939 TRACE("TYMED_ENHMF\n");
1940 if (pStgMedium->u.hEnhMetaFile)
1941 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1942 break;
1943 default:
1944 RaiseException(DV_E_TYMED, 0, 0, NULL);
1947 if (pStgMedium->pUnkForRelease)
1948 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1950 return pBuffer;
1953 /******************************************************************************
1954 * STGMEDIUM_UserUnmarshal [OLE32.@]
1956 * Unmarshals a STGMEDIUM from a buffer.
1958 * PARAMS
1959 * pFlags [I] Flags. See notes.
1960 * pBuffer [I] Buffer to marshal the clip format from.
1961 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1963 * RETURNS
1964 * The end of the marshaled data in the buffer.
1966 * NOTES
1967 * Even though the function is documented to take a pointer to an ULONG in
1968 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1969 * the first parameter is an ULONG.
1970 * This function is only intended to be called by the RPC runtime.
1972 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1974 DWORD content = 0;
1975 DWORD releaseunk;
1977 ALIGN_POINTER(pBuffer, 3);
1979 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1981 pStgMedium->tymed = *(DWORD *)pBuffer;
1982 pBuffer += sizeof(DWORD);
1983 if (pStgMedium->tymed != TYMED_NULL)
1985 content = *(DWORD *)pBuffer;
1986 pBuffer += sizeof(DWORD);
1988 releaseunk = *(DWORD *)pBuffer;
1989 pBuffer += sizeof(DWORD);
1991 switch (pStgMedium->tymed)
1993 case TYMED_NULL:
1994 TRACE("TYMED_NULL\n");
1995 break;
1996 case TYMED_HGLOBAL:
1997 TRACE("TYMED_HGLOBAL\n");
1998 if (content)
1999 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
2000 break;
2001 case TYMED_FILE:
2002 TRACE("TYMED_FILE\n");
2003 if (content)
2005 DWORD conformance;
2006 DWORD variance;
2007 conformance = *(DWORD *)pBuffer;
2008 pBuffer += sizeof(DWORD);
2009 if (*(DWORD *)pBuffer != 0)
2011 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
2012 RpcRaiseException(RPC_S_INVALID_BOUND);
2013 return NULL;
2015 pBuffer += sizeof(DWORD);
2016 variance = *(DWORD *)pBuffer;
2017 pBuffer += sizeof(DWORD);
2018 if (conformance != variance)
2020 ERR("conformance (%d) and variance (%d) should be equal\n",
2021 conformance, variance);
2022 RpcRaiseException(RPC_S_INVALID_BOUND);
2023 return NULL;
2025 if (conformance > 0x7fffffff)
2027 ERR("conformance 0x%x too large\n", conformance);
2028 RpcRaiseException(RPC_S_INVALID_BOUND);
2029 return NULL;
2031 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2032 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2033 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2034 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2035 pBuffer += variance * sizeof(WCHAR);
2037 else
2038 pStgMedium->u.lpszFileName = NULL;
2039 break;
2040 case TYMED_ISTREAM:
2041 TRACE("TYMED_ISTREAM\n");
2042 if (content)
2044 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
2046 else
2047 pStgMedium->u.pstm = NULL;
2048 break;
2049 case TYMED_ISTORAGE:
2050 TRACE("TYMED_ISTORAGE\n");
2051 if (content)
2053 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
2055 else
2056 pStgMedium->u.pstg = NULL;
2057 break;
2058 case TYMED_GDI:
2059 TRACE("TYMED_GDI\n");
2060 if (content)
2062 FIXME("not implemented for GDI object\n");
2064 else
2065 pStgMedium->u.hBitmap = NULL;
2066 break;
2067 case TYMED_MFPICT:
2068 TRACE("TYMED_MFPICT\n");
2069 if (content)
2070 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2071 else
2072 pStgMedium->u.hMetaFilePict = NULL;
2073 break;
2074 case TYMED_ENHMF:
2075 TRACE("TYMED_ENHMF\n");
2076 if (content)
2077 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2078 else
2079 pStgMedium->u.hEnhMetaFile = NULL;
2080 break;
2081 default:
2082 RaiseException(DV_E_TYMED, 0, 0, NULL);
2085 pStgMedium->pUnkForRelease = NULL;
2086 if (releaseunk)
2087 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2089 return pBuffer;
2092 /******************************************************************************
2093 * STGMEDIUM_UserFree [OLE32.@]
2095 * Frees an unmarshaled STGMEDIUM.
2097 * PARAMS
2098 * pFlags [I] Flags. See notes.
2099 * pStgmedium [I] STGMEDIUM to free.
2101 * RETURNS
2102 * The end of the marshaled data in the buffer.
2104 * NOTES
2105 * Even though the function is documented to take a pointer to a ULONG in
2106 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2107 * which the first parameter is a ULONG.
2108 * This function is only intended to be called by the RPC runtime.
2110 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2112 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2114 ReleaseStgMedium(pStgMedium);
2117 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2119 TRACE("\n");
2120 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2123 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2125 TRACE("\n");
2126 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2129 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2131 TRACE("\n");
2132 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2135 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2137 TRACE("\n");
2138 STGMEDIUM_UserFree(pFlags, pStgMedium);
2141 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2143 FIXME(":stub\n");
2144 return StartingSize;
2147 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2149 FIXME(":stub\n");
2150 return pBuffer;
2153 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2155 FIXME(":stub\n");
2156 return pBuffer;
2159 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2161 FIXME(":stub\n");
2164 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2166 FIXME(":stub\n");
2167 return StartingSize;
2170 unsigned char * __RPC_USER SNB_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2172 FIXME(":stub\n");
2173 return pBuffer;
2176 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2178 FIXME(":stub\n");
2179 return pBuffer;
2182 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2184 FIXME(":stub\n");
2187 /* call_as/local stubs for unknwn.idl */
2189 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2190 IClassFactory* This,
2191 IUnknown *pUnkOuter,
2192 REFIID riid,
2193 void **ppvObject)
2195 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2196 *ppvObject = NULL;
2197 if (pUnkOuter)
2199 ERR("aggregation is not allowed on remote objects\n");
2200 return CLASS_E_NOAGGREGATION;
2202 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2203 (IUnknown **) ppvObject);
2206 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2207 IClassFactory* This,
2208 REFIID riid,
2209 IUnknown **ppvObject)
2211 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2212 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2215 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2216 IClassFactory* This,
2217 BOOL fLock)
2219 FIXME(":stub\n");
2220 return E_NOTIMPL;
2223 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2224 IClassFactory* This,
2225 BOOL fLock)
2227 FIXME(":stub\n");
2228 return E_NOTIMPL;
2231 /* call_as/local stubs for objidl.idl */
2233 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2234 IEnumUnknown* This,
2235 ULONG celt,
2236 IUnknown **rgelt,
2237 ULONG *pceltFetched)
2239 ULONG fetched;
2240 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2241 if (!pceltFetched) pceltFetched = &fetched;
2242 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2245 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2246 IEnumUnknown* This,
2247 ULONG celt,
2248 IUnknown **rgelt,
2249 ULONG *pceltFetched)
2251 HRESULT hr;
2252 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2253 *pceltFetched = 0;
2254 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2255 if (hr == S_OK) *pceltFetched = celt;
2256 return hr;
2259 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2260 IBindCtx* This,
2261 BIND_OPTS *pbindopts)
2263 FIXME(":stub\n");
2264 return E_NOTIMPL;
2267 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2268 IBindCtx* This,
2269 BIND_OPTS2 *pbindopts)
2271 FIXME(":stub\n");
2272 return E_NOTIMPL;
2275 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2276 IBindCtx* This,
2277 BIND_OPTS *pbindopts)
2279 FIXME(":stub\n");
2280 return E_NOTIMPL;
2283 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2284 IBindCtx* This,
2285 BIND_OPTS2 *pbindopts)
2287 FIXME(":stub\n");
2288 return E_NOTIMPL;
2291 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2292 IEnumMoniker* This,
2293 ULONG celt,
2294 IMoniker **rgelt,
2295 ULONG *pceltFetched)
2297 ULONG fetched;
2298 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2299 if (!pceltFetched) pceltFetched = &fetched;
2300 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2303 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2304 IEnumMoniker* This,
2305 ULONG celt,
2306 IMoniker **rgelt,
2307 ULONG *pceltFetched)
2309 HRESULT hr;
2310 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2311 *pceltFetched = 0;
2312 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2313 if (hr == S_OK) *pceltFetched = celt;
2314 return hr;
2317 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2318 IRunnableObject* This)
2320 BOOL rv;
2321 FIXME(":stub\n");
2322 memset(&rv, 0, sizeof rv);
2323 return rv;
2326 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2327 IRunnableObject* This)
2329 FIXME(":stub\n");
2330 return E_NOTIMPL;
2333 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2334 IMoniker* This,
2335 IBindCtx *pbc,
2336 IMoniker *pmkToLeft,
2337 REFIID riidResult,
2338 void **ppvResult)
2340 FIXME(":stub\n");
2341 return E_NOTIMPL;
2344 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2345 IMoniker* This,
2346 IBindCtx *pbc,
2347 IMoniker *pmkToLeft,
2348 REFIID riidResult,
2349 IUnknown **ppvResult)
2351 FIXME(":stub\n");
2352 return E_NOTIMPL;
2355 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2356 IMoniker* This,
2357 IBindCtx *pbc,
2358 IMoniker *pmkToLeft,
2359 REFIID riid,
2360 void **ppvObj)
2362 FIXME(":stub\n");
2363 return E_NOTIMPL;
2366 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2367 IMoniker* This,
2368 IBindCtx *pbc,
2369 IMoniker *pmkToLeft,
2370 REFIID riid,
2371 IUnknown **ppvObj)
2373 FIXME(":stub\n");
2374 return E_NOTIMPL;
2377 HRESULT CALLBACK IEnumString_Next_Proxy(
2378 IEnumString* This,
2379 ULONG celt,
2380 LPOLESTR *rgelt,
2381 ULONG *pceltFetched)
2383 ULONG fetched;
2384 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2385 if (!pceltFetched) pceltFetched = &fetched;
2386 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2389 HRESULT __RPC_STUB IEnumString_Next_Stub(
2390 IEnumString* This,
2391 ULONG celt,
2392 LPOLESTR *rgelt,
2393 ULONG *pceltFetched)
2395 HRESULT hr;
2396 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2397 *pceltFetched = 0;
2398 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2399 if (hr == S_OK) *pceltFetched = celt;
2400 return hr;
2403 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2404 ISequentialStream* This,
2405 void *pv,
2406 ULONG cb,
2407 ULONG *pcbRead)
2409 ULONG read;
2410 HRESULT hr;
2412 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2414 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2415 if(pcbRead) *pcbRead = read;
2417 return hr;
2420 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2421 ISequentialStream* This,
2422 byte *pv,
2423 ULONG cb,
2424 ULONG *pcbRead)
2426 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2427 return ISequentialStream_Read(This, pv, cb, pcbRead);
2430 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2431 ISequentialStream* This,
2432 const void *pv,
2433 ULONG cb,
2434 ULONG *pcbWritten)
2436 ULONG written;
2437 HRESULT hr;
2439 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2441 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2442 if(pcbWritten) *pcbWritten = written;
2444 return hr;
2447 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2448 ISequentialStream* This,
2449 const byte *pv,
2450 ULONG cb,
2451 ULONG *pcbWritten)
2453 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2454 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2457 HRESULT CALLBACK IStream_Seek_Proxy(
2458 IStream* This,
2459 LARGE_INTEGER dlibMove,
2460 DWORD dwOrigin,
2461 ULARGE_INTEGER *plibNewPosition)
2463 ULARGE_INTEGER newpos;
2464 HRESULT hr;
2466 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2468 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2469 if(plibNewPosition) *plibNewPosition = newpos;
2471 return hr;
2474 HRESULT __RPC_STUB IStream_Seek_Stub(
2475 IStream* This,
2476 LARGE_INTEGER dlibMove,
2477 DWORD dwOrigin,
2478 ULARGE_INTEGER *plibNewPosition)
2480 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2481 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2484 HRESULT CALLBACK IStream_CopyTo_Proxy(
2485 IStream* This,
2486 IStream *pstm,
2487 ULARGE_INTEGER cb,
2488 ULARGE_INTEGER *pcbRead,
2489 ULARGE_INTEGER *pcbWritten)
2491 ULARGE_INTEGER read, written;
2492 HRESULT hr;
2494 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2496 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2497 if(pcbRead) *pcbRead = read;
2498 if(pcbWritten) *pcbWritten = written;
2500 return hr;
2503 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2504 IStream* This,
2505 IStream *pstm,
2506 ULARGE_INTEGER cb,
2507 ULARGE_INTEGER *pcbRead,
2508 ULARGE_INTEGER *pcbWritten)
2510 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2512 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2515 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2516 IEnumSTATSTG* This,
2517 ULONG celt,
2518 STATSTG *rgelt,
2519 ULONG *pceltFetched)
2521 ULONG fetched;
2522 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2523 if (!pceltFetched) pceltFetched = &fetched;
2524 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2527 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2528 IEnumSTATSTG* This,
2529 ULONG celt,
2530 STATSTG *rgelt,
2531 ULONG *pceltFetched)
2533 HRESULT hr;
2534 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2535 *pceltFetched = 0;
2536 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2537 if (hr == S_OK) *pceltFetched = celt;
2538 return hr;
2541 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2542 IStorage* This,
2543 LPCOLESTR pwcsName,
2544 void *reserved1,
2545 DWORD grfMode,
2546 DWORD reserved2,
2547 IStream **ppstm)
2549 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2550 if(reserved1) WARN("reserved1 %p\n", reserved1);
2552 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2555 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2556 IStorage* This,
2557 LPCOLESTR pwcsName,
2558 ULONG cbReserved1,
2559 byte *reserved1,
2560 DWORD grfMode,
2561 DWORD reserved2,
2562 IStream **ppstm)
2564 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2565 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2567 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2570 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2571 IStorage* This,
2572 DWORD reserved1,
2573 void *reserved2,
2574 DWORD reserved3,
2575 IEnumSTATSTG **ppenum)
2577 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2578 if(reserved2) WARN("reserved2 %p\n", reserved2);
2580 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2583 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2584 IStorage* This,
2585 DWORD reserved1,
2586 ULONG cbReserved2,
2587 byte *reserved2,
2588 DWORD reserved3,
2589 IEnumSTATSTG **ppenum)
2591 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2592 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2594 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2597 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2598 ILockBytes* This,
2599 ULARGE_INTEGER ulOffset,
2600 void *pv,
2601 ULONG cb,
2602 ULONG *pcbRead)
2604 ULONG read;
2605 HRESULT hr;
2607 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2609 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2610 if(pcbRead) *pcbRead = read;
2612 return hr;
2615 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2616 ILockBytes* This,
2617 ULARGE_INTEGER ulOffset,
2618 byte *pv,
2619 ULONG cb,
2620 ULONG *pcbRead)
2622 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2623 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2626 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2627 ILockBytes* This,
2628 ULARGE_INTEGER ulOffset,
2629 const void *pv,
2630 ULONG cb,
2631 ULONG *pcbWritten)
2633 ULONG written;
2634 HRESULT hr;
2636 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2638 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2639 if(pcbWritten) *pcbWritten = written;
2641 return hr;
2644 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2645 ILockBytes* This,
2646 ULARGE_INTEGER ulOffset,
2647 const byte *pv,
2648 ULONG cb,
2649 ULONG *pcbWritten)
2651 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2652 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2655 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2656 IFillLockBytes* This,
2657 const void *pv,
2658 ULONG cb,
2659 ULONG *pcbWritten)
2661 ULONG written;
2662 HRESULT hr;
2664 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2666 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2667 if(pcbWritten) *pcbWritten = written;
2669 return hr;
2672 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2673 IFillLockBytes* This,
2674 const byte *pv,
2675 ULONG cb,
2676 ULONG *pcbWritten)
2678 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2679 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2682 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2683 IFillLockBytes* This,
2684 ULARGE_INTEGER ulOffset,
2685 const void *pv,
2686 ULONG cb,
2687 ULONG *pcbWritten)
2689 ULONG written;
2690 HRESULT hr;
2692 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2694 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2695 if(pcbWritten) *pcbWritten = written;
2697 return hr;
2700 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2701 IFillLockBytes* This,
2702 ULARGE_INTEGER ulOffset,
2703 const byte *pv,
2704 ULONG cb,
2705 ULONG *pcbWritten)
2707 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2708 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2711 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2712 IEnumFORMATETC* This,
2713 ULONG celt,
2714 FORMATETC *rgelt,
2715 ULONG *pceltFetched)
2717 ULONG fetched;
2718 if (!pceltFetched) pceltFetched = &fetched;
2719 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2722 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2723 IEnumFORMATETC* This,
2724 ULONG celt,
2725 FORMATETC *rgelt,
2726 ULONG *pceltFetched)
2728 HRESULT hr;
2729 *pceltFetched = 0;
2730 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2731 if (hr == S_OK) *pceltFetched = celt;
2732 return hr;
2735 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2736 IEnumSTATDATA* This,
2737 ULONG celt,
2738 STATDATA *rgelt,
2739 ULONG *pceltFetched)
2741 ULONG fetched;
2742 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2743 if (!pceltFetched) pceltFetched = &fetched;
2744 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2747 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2748 IEnumSTATDATA* This,
2749 ULONG celt,
2750 STATDATA *rgelt,
2751 ULONG *pceltFetched)
2753 HRESULT hr;
2754 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2755 *pceltFetched = 0;
2756 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2757 if (hr == S_OK) *pceltFetched = celt;
2758 return hr;
2761 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2762 IAdviseSink* This,
2763 FORMATETC *pFormatetc,
2764 STGMEDIUM *pStgmed)
2766 FIXME(":stub\n");
2769 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2770 IAdviseSink* This,
2771 FORMATETC *pFormatetc,
2772 ASYNC_STGMEDIUM *pStgmed)
2774 FIXME(":stub\n");
2775 return E_NOTIMPL;
2778 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2779 IAdviseSink* This,
2780 DWORD dwAspect,
2781 LONG lindex)
2783 FIXME(":stub\n");
2786 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2787 IAdviseSink* This,
2788 DWORD dwAspect,
2789 LONG lindex)
2791 FIXME(":stub\n");
2792 return E_NOTIMPL;
2795 void CALLBACK IAdviseSink_OnRename_Proxy(
2796 IAdviseSink* This,
2797 IMoniker *pmk)
2799 FIXME(":stub\n");
2802 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2803 IAdviseSink* This,
2804 IMoniker *pmk)
2806 FIXME(":stub\n");
2807 return E_NOTIMPL;
2810 void CALLBACK IAdviseSink_OnSave_Proxy(
2811 IAdviseSink* This)
2813 FIXME(":stub\n");
2816 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2817 IAdviseSink* This)
2819 FIXME(":stub\n");
2820 return E_NOTIMPL;
2823 void CALLBACK IAdviseSink_OnClose_Proxy(
2824 IAdviseSink* This)
2826 FIXME(":stub\n");
2829 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2830 IAdviseSink* This)
2832 FIXME(":stub\n");
2833 return E_NOTIMPL;
2836 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2837 IAdviseSink2* This,
2838 IMoniker *pmk)
2840 FIXME(":stub\n");
2843 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2844 IAdviseSink2* This,
2845 IMoniker *pmk)
2847 FIXME(":stub\n");
2848 return E_NOTIMPL;
2851 HRESULT CALLBACK IDataObject_GetData_Proxy(
2852 IDataObject* This,
2853 FORMATETC *pformatetcIn,
2854 STGMEDIUM *pmedium)
2856 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2857 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2860 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2861 IDataObject* This,
2862 FORMATETC *pformatetcIn,
2863 STGMEDIUM *pRemoteMedium)
2865 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2866 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2869 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2870 IDataObject* This,
2871 FORMATETC *pformatetc,
2872 STGMEDIUM *pmedium)
2874 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2875 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2878 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2879 IDataObject* This,
2880 FORMATETC *pformatetc,
2881 STGMEDIUM *pRemoteMedium)
2883 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2884 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2887 HRESULT CALLBACK IDataObject_SetData_Proxy(
2888 IDataObject* This,
2889 FORMATETC *pformatetc,
2890 STGMEDIUM *pmedium,
2891 BOOL fRelease)
2893 FIXME(":stub\n");
2894 return E_NOTIMPL;
2897 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2898 IDataObject* This,
2899 FORMATETC *pformatetc,
2900 FLAG_STGMEDIUM *pmedium,
2901 BOOL fRelease)
2903 FIXME(":stub\n");
2904 return E_NOTIMPL;
2907 /* call_as/local stubs for oleidl.idl */
2909 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2910 IOleInPlaceActiveObject* This,
2911 LPMSG lpmsg)
2913 FIXME(":stub\n");
2914 return E_NOTIMPL;
2917 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2918 IOleInPlaceActiveObject* This)
2920 FIXME(":stub\n");
2921 return E_NOTIMPL;
2924 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2925 IOleInPlaceActiveObject* This,
2926 LPCRECT prcBorder,
2927 IOleInPlaceUIWindow *pUIWindow,
2928 BOOL fFrameWindow)
2930 FIXME(":stub\n");
2931 return E_NOTIMPL;
2934 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2935 IOleInPlaceActiveObject* This,
2936 LPCRECT prcBorder,
2937 REFIID riid,
2938 IOleInPlaceUIWindow *pUIWindow,
2939 BOOL fFrameWindow)
2941 FIXME(":stub\n");
2942 return E_NOTIMPL;
2945 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2946 IOleCache2* This,
2947 LPDATAOBJECT pDataObject,
2948 DWORD grfUpdf,
2949 LPVOID pReserved)
2951 FIXME(":stub\n");
2952 return E_NOTIMPL;
2955 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2956 IOleCache2* This,
2957 LPDATAOBJECT pDataObject,
2958 DWORD grfUpdf,
2959 LONG_PTR pReserved)
2961 FIXME(":stub\n");
2962 return E_NOTIMPL;
2965 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2966 IEnumOLEVERB* This,
2967 ULONG celt,
2968 LPOLEVERB rgelt,
2969 ULONG *pceltFetched)
2971 ULONG fetched;
2972 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2973 if (!pceltFetched) pceltFetched = &fetched;
2974 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2977 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2978 IEnumOLEVERB* This,
2979 ULONG celt,
2980 LPOLEVERB rgelt,
2981 ULONG *pceltFetched)
2983 HRESULT hr;
2984 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2985 *pceltFetched = 0;
2986 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2987 if (hr == S_OK) *pceltFetched = celt;
2988 return hr;
2991 HRESULT CALLBACK IViewObject_Draw_Proxy(
2992 IViewObject* This,
2993 DWORD dwDrawAspect,
2994 LONG lindex,
2995 void *pvAspect,
2996 DVTARGETDEVICE *ptd,
2997 HDC hdcTargetDev,
2998 HDC hdcDraw,
2999 LPCRECTL lprcBounds,
3000 LPCRECTL lprcWBounds,
3001 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
3002 ULONG_PTR dwContinue)
3004 FIXME(":stub\n");
3005 return E_NOTIMPL;
3008 HRESULT __RPC_STUB IViewObject_Draw_Stub(
3009 IViewObject* This,
3010 DWORD dwDrawAspect,
3011 LONG lindex,
3012 ULONG_PTR pvAspect,
3013 DVTARGETDEVICE *ptd,
3014 ULONG_PTR hdcTargetDev,
3015 ULONG_PTR hdcDraw,
3016 LPCRECTL lprcBounds,
3017 LPCRECTL lprcWBounds,
3018 IContinue *pContinue)
3020 FIXME(":stub\n");
3021 return E_NOTIMPL;
3024 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3025 IViewObject* This,
3026 DWORD dwDrawAspect,
3027 LONG lindex,
3028 void *pvAspect,
3029 DVTARGETDEVICE *ptd,
3030 HDC hicTargetDev,
3031 LOGPALETTE **ppColorSet)
3033 FIXME(":stub\n");
3034 return E_NOTIMPL;
3037 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3038 IViewObject* This,
3039 DWORD dwDrawAspect,
3040 LONG lindex,
3041 ULONG_PTR pvAspect,
3042 DVTARGETDEVICE *ptd,
3043 ULONG_PTR hicTargetDev,
3044 LOGPALETTE **ppColorSet)
3046 FIXME(":stub\n");
3047 return E_NOTIMPL;
3050 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3051 IViewObject* This,
3052 DWORD dwDrawAspect,
3053 LONG lindex,
3054 void *pvAspect,
3055 DWORD *pdwFreeze)
3057 FIXME(":stub\n");
3058 return E_NOTIMPL;
3061 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3062 IViewObject* This,
3063 DWORD dwDrawAspect,
3064 LONG lindex,
3065 ULONG_PTR pvAspect,
3066 DWORD *pdwFreeze)
3068 FIXME(":stub\n");
3069 return E_NOTIMPL;
3072 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3073 IViewObject* This,
3074 DWORD *pAspects,
3075 DWORD *pAdvf,
3076 IAdviseSink **ppAdvSink)
3078 FIXME(":stub\n");
3079 return E_NOTIMPL;
3082 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3083 IViewObject* This,
3084 DWORD *pAspects,
3085 DWORD *pAdvf,
3086 IAdviseSink **ppAdvSink)
3088 FIXME(":stub\n");
3089 return E_NOTIMPL;