dwrite: Fix cluster width and length calculation.
[wine/multimedia.git] / dlls / ole32 / usrmarshal.c
blobcd16fb28888a16bcbcdf3002cca3076fea745ec7
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
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winerror.h"
34 #include "ole2.h"
35 #include "oleauto.h"
36 #include "rpcproxy.h"
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(ole);
43 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
44 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
45 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
46 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
48 #define USER_MARSHAL_PTR_PREFIX \
49 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
50 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
52 static const char* debugstr_user_flags(ULONG *pFlags)
54 char buf[12];
55 const char* loword;
56 switch (LOWORD(*pFlags))
58 case MSHCTX_LOCAL:
59 loword="MSHCTX_LOCAL";
60 break;
61 case MSHCTX_NOSHAREDMEM:
62 loword="MSHCTX_NOSHAREDMEM";
63 break;
64 case MSHCTX_DIFFERENTMACHINE:
65 loword="MSHCTX_DIFFERENTMACHINE";
66 break;
67 case MSHCTX_INPROC:
68 loword="MSHCTX_INPROC";
69 break;
70 default:
71 sprintf(buf, "%d", LOWORD(*pFlags));
72 loword=buf;
75 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
76 return wine_dbg_sprintf("MAKELONG(%s, NDR_LOCAL_DATA_REPRESENTATION)", loword);
77 else
78 return wine_dbg_sprintf("MAKELONG(%s, 0x%04x)", loword, HIWORD(*pFlags));
81 /******************************************************************************
82 * CLIPFORMAT_UserSize [OLE32.@]
84 * Calculates the buffer size required to marshal a clip format.
86 * PARAMS
87 * pFlags [I] Flags. See notes.
88 * StartingSize [I] Starting size of the buffer. This value is added on to
89 * the buffer size required for the clip format.
90 * pCF [I] Clip format to size.
92 * RETURNS
93 * The buffer size required to marshal a clip format plus the starting size.
95 * NOTES
96 * Even though the function is documented to take a pointer to an unsigned
97 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
98 * the first parameter is an unsigned long.
99 * This function is only intended to be called by the RPC runtime.
101 ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORMAT *pCF)
103 ULONG size = StartingSize;
105 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF);
107 size += 8;
109 /* only need to marshal the name if it is not a pre-defined type and
110 * we are going remote */
111 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
113 WCHAR format[255];
114 INT ret;
115 size += 3 * sizeof(UINT);
116 /* urg! this function is badly designed because it won't tell us how
117 * much space is needed without doing a dummy run of storing the
118 * name into a buffer */
119 ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
120 if (!ret)
121 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
122 size += (ret + 1) * sizeof(WCHAR);
124 return size;
127 /******************************************************************************
128 * CLIPFORMAT_UserMarshal [OLE32.@]
130 * Marshals a clip format into a buffer.
132 * PARAMS
133 * pFlags [I] Flags. See notes.
134 * pBuffer [I] Buffer to marshal the clip format into.
135 * pCF [I] Clip format to marshal.
137 * RETURNS
138 * The end of the marshaled data in the buffer.
140 * NOTES
141 * Even though the function is documented to take a pointer to an unsigned
142 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
143 * the first parameter is an unsigned long.
144 * This function is only intended to be called by the RPC runtime.
146 unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
148 TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
150 /* only need to marshal the name if it is not a pre-defined type and
151 * we are going remote */
152 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
154 WCHAR format[255];
155 UINT len;
157 *(DWORD *)pBuffer = WDT_REMOTE_CALL;
158 pBuffer += 4;
159 *(DWORD *)pBuffer = *pCF;
160 pBuffer += 4;
162 len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
163 if (!len)
164 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
165 len += 1;
166 *(UINT *)pBuffer = len;
167 pBuffer += sizeof(UINT);
168 *(UINT *)pBuffer = 0;
169 pBuffer += sizeof(UINT);
170 *(UINT *)pBuffer = len;
171 pBuffer += sizeof(UINT);
172 TRACE("marshaling format name %s\n", debugstr_w(format));
173 memcpy(pBuffer, format, len * sizeof(WCHAR));
174 pBuffer += len * sizeof(WCHAR);
176 else
178 *(DWORD *)pBuffer = WDT_INPROC_CALL;
179 pBuffer += 4;
180 *(DWORD *)pBuffer = *pCF;
181 pBuffer += 4;
184 return pBuffer;
187 /******************************************************************************
188 * CLIPFORMAT_UserUnmarshal [OLE32.@]
190 * Unmarshals a clip format from a buffer.
192 * PARAMS
193 * pFlags [I] Flags. See notes.
194 * pBuffer [I] Buffer to marshal the clip format from.
195 * pCF [O] Address that receive the unmarshaled clip format.
197 * RETURNS
198 * The end of the marshaled data in the buffer.
200 * NOTES
201 * Even though the function is documented to take a pointer to an unsigned
202 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
203 * the first parameter is an unsigned long.
204 * This function is only intended to be called by the RPC runtime.
206 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
208 LONG fContext;
210 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
212 fContext = *(DWORD *)pBuffer;
213 pBuffer += 4;
215 if (fContext == WDT_INPROC_CALL)
217 *pCF = *(CLIPFORMAT *)pBuffer;
218 pBuffer += 4;
220 else if (fContext == WDT_REMOTE_CALL)
222 CLIPFORMAT cf;
223 UINT len;
225 /* pointer ID for registered clip format string */
226 if (*(DWORD *)pBuffer == 0)
227 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
228 pBuffer += 4;
230 len = *(UINT *)pBuffer;
231 pBuffer += sizeof(UINT);
232 if (*(UINT *)pBuffer != 0)
233 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
234 pBuffer += sizeof(UINT);
235 if (*(UINT *)pBuffer != len)
236 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
237 pBuffer += sizeof(UINT);
238 if (((WCHAR *)pBuffer)[len - 1] != '\0')
239 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
240 TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
241 cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
242 pBuffer += len * sizeof(WCHAR);
243 if (!cf)
244 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
245 *pCF = cf;
247 else
248 /* code not really appropriate, but nearest I can find */
249 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
250 return pBuffer;
253 /******************************************************************************
254 * CLIPFORMAT_UserFree [OLE32.@]
256 * Frees an unmarshaled clip format.
258 * PARAMS
259 * pFlags [I] Flags. See notes.
260 * pCF [I] Clip format to free.
262 * RETURNS
263 * The end of the marshaled data in the buffer.
265 * NOTES
266 * Even though the function is documented to take a pointer to an unsigned
267 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
268 * structure, of which the first parameter is an unsigned long.
269 * This function is only intended to be called by the RPC runtime.
271 void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
273 /* there is no inverse of the RegisterClipboardFormat function,
274 * so nothing to do */
277 static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
279 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
281 ERR("can't remote a local handle\n");
282 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
283 return StartingSize;
285 return StartingSize + sizeof(RemotableHandle);
288 static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
290 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
291 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
293 ERR("can't remote a local handle\n");
294 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
295 return pBuffer;
297 remhandle->fContext = WDT_INPROC_CALL;
298 remhandle->u.hInproc = (LONG_PTR)*handle;
299 return pBuffer + sizeof(RemotableHandle);
302 static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
304 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
305 if (remhandle->fContext != WDT_INPROC_CALL)
306 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
307 *handle = (HANDLE)(LONG_PTR)remhandle->u.hInproc;
308 return pBuffer + sizeof(RemotableHandle);
311 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
313 /* nothing to do */
316 #define IMPL_WIREM_HANDLE(type) \
317 ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \
319 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \
320 return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
323 unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
325 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \
326 return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
329 unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
331 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \
332 return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
335 void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \
337 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \
338 handle_UserFree(pFlags, (HANDLE *)handle); \
341 IMPL_WIREM_HANDLE(HACCEL)
342 IMPL_WIREM_HANDLE(HMENU)
343 IMPL_WIREM_HANDLE(HWND)
345 /******************************************************************************
346 * HGLOBAL_UserSize [OLE32.@]
348 * Calculates the buffer size required to marshal an HGLOBAL.
350 * PARAMS
351 * pFlags [I] Flags. See notes.
352 * StartingSize [I] Starting size of the buffer. This value is added on to
353 * the buffer size required for the clip format.
354 * phGlobal [I] HGLOBAL to size.
356 * RETURNS
357 * The buffer size required to marshal an HGLOBAL plus the starting size.
359 * NOTES
360 * Even though the function is documented to take a pointer to a ULONG in
361 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
362 * the first parameter is a ULONG.
363 * This function is only intended to be called by the RPC runtime.
365 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
367 ULONG size = StartingSize;
369 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
371 ALIGN_LENGTH(size, 3);
373 size += sizeof(ULONG);
375 if (LOWORD(*pFlags == MSHCTX_INPROC))
376 size += sizeof(HGLOBAL);
377 else
379 size += sizeof(ULONG);
380 if (*phGlobal)
382 SIZE_T ret;
383 size += 3 * sizeof(ULONG);
384 ret = GlobalSize(*phGlobal);
385 size += (ULONG)ret;
389 return size;
392 /******************************************************************************
393 * HGLOBAL_UserMarshal [OLE32.@]
395 * Marshals an HGLOBAL into a buffer.
397 * PARAMS
398 * pFlags [I] Flags. See notes.
399 * pBuffer [I] Buffer to marshal the clip format into.
400 * phGlobal [I] HGLOBAL to marshal.
402 * RETURNS
403 * The end of the marshaled data in the buffer.
405 * NOTES
406 * Even though the function is documented to take a pointer to a ULONG in
407 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
408 * the first parameter is a ULONG.
409 * This function is only intended to be called by the RPC runtime.
411 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
413 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
415 ALIGN_POINTER(pBuffer, 3);
417 if (LOWORD(*pFlags == MSHCTX_INPROC))
419 if (sizeof(*phGlobal) == 8)
420 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
421 else
422 *(ULONG *)pBuffer = WDT_INPROC_CALL;
423 pBuffer += sizeof(ULONG);
424 *(HGLOBAL *)pBuffer = *phGlobal;
425 pBuffer += sizeof(HGLOBAL);
427 else
429 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
430 pBuffer += sizeof(ULONG);
431 *(ULONG *)pBuffer = HandleToULong(*phGlobal);
432 pBuffer += sizeof(ULONG);
433 if (*phGlobal)
435 const unsigned char *memory;
436 SIZE_T size = GlobalSize(*phGlobal);
437 *(ULONG *)pBuffer = (ULONG)size;
438 pBuffer += sizeof(ULONG);
439 *(ULONG *)pBuffer = HandleToULong(*phGlobal);
440 pBuffer += sizeof(ULONG);
441 *(ULONG *)pBuffer = (ULONG)size;
442 pBuffer += sizeof(ULONG);
444 memory = GlobalLock(*phGlobal);
445 memcpy(pBuffer, memory, size);
446 pBuffer += size;
447 GlobalUnlock(*phGlobal);
451 return pBuffer;
454 /******************************************************************************
455 * HGLOBAL_UserUnmarshal [OLE32.@]
457 * Unmarshals an HGLOBAL from a buffer.
459 * PARAMS
460 * pFlags [I] Flags. See notes.
461 * pBuffer [I] Buffer to marshal the clip format from.
462 * phGlobal [O] Address that receive the unmarshaled HGLOBAL.
464 * RETURNS
465 * The end of the marshaled data in the buffer.
467 * NOTES
468 * Even though the function is documented to take a pointer to an ULONG in
469 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
470 * the first parameter is an ULONG.
471 * This function is only intended to be called by the RPC runtime.
473 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
475 ULONG fContext;
477 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
479 ALIGN_POINTER(pBuffer, 3);
481 fContext = *(ULONG *)pBuffer;
482 pBuffer += sizeof(ULONG);
484 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
485 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
487 *phGlobal = *(HGLOBAL *)pBuffer;
488 pBuffer += sizeof(*phGlobal);
490 else if (fContext == WDT_REMOTE_CALL)
492 ULONG handle;
494 handle = *(ULONG *)pBuffer;
495 pBuffer += sizeof(ULONG);
497 if (handle)
499 ULONG size;
500 void *memory;
502 size = *(ULONG *)pBuffer;
503 pBuffer += sizeof(ULONG);
504 /* redundancy is bad - it means you have to check consistency like
505 * this: */
506 if (*(ULONG *)pBuffer != handle)
508 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
509 return pBuffer;
511 pBuffer += sizeof(ULONG);
512 /* redundancy is bad - it means you have to check consistency like
513 * this: */
514 if (*(ULONG *)pBuffer != size)
516 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
517 return pBuffer;
519 pBuffer += sizeof(ULONG);
521 /* FIXME: check size is not too big */
523 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
524 memory = GlobalLock(*phGlobal);
525 memcpy(memory, pBuffer, size);
526 pBuffer += size;
527 GlobalUnlock(*phGlobal);
529 else
530 *phGlobal = NULL;
532 else
533 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
535 return pBuffer;
538 /******************************************************************************
539 * HGLOBAL_UserFree [OLE32.@]
541 * Frees an unmarshaled HGLOBAL.
543 * PARAMS
544 * pFlags [I] Flags. See notes.
545 * phGlobal [I] HGLOBAL to free.
547 * RETURNS
548 * The end of the marshaled data in the buffer.
550 * NOTES
551 * Even though the function is documented to take a pointer to a ULONG in
552 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
553 * which the first parameter is a ULONG.
554 * This function is only intended to be called by the RPC runtime.
556 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
558 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
560 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
561 GlobalFree(*phGlobal);
564 /******************************************************************************
565 * HBITMAP_UserSize [OLE32.@]
567 * Calculates the buffer size required to marshal a bitmap.
569 * PARAMS
570 * pFlags [I] Flags. See notes.
571 * StartingSize [I] Starting size of the buffer. This value is added on to
572 * the buffer size required for the clip format.
573 * phBmp [I] Bitmap to size.
575 * RETURNS
576 * The buffer size required to marshal an bitmap plus the starting size.
578 * NOTES
579 * Even though the function is documented to take a pointer to a ULONG in
580 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
581 * the first parameter is a ULONG.
582 * This function is only intended to be called by the RPC runtime.
584 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
586 FIXME(":stub\n");
587 return StartingSize;
590 /******************************************************************************
591 * HBITMAP_UserMarshal [OLE32.@]
593 * Marshals a bitmap into a buffer.
595 * PARAMS
596 * pFlags [I] Flags. See notes.
597 * pBuffer [I] Buffer to marshal the clip format into.
598 * phBmp [I] Bitmap to marshal.
600 * RETURNS
601 * The end of the marshaled data in the buffer.
603 * NOTES
604 * Even though the function is documented to take a pointer to a ULONG in
605 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
606 * the first parameter is a ULONG.
607 * This function is only intended to be called by the RPC runtime.
609 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
611 FIXME(":stub\n");
612 return pBuffer;
615 /******************************************************************************
616 * HBITMAP_UserUnmarshal [OLE32.@]
618 * Unmarshals a bitmap from a buffer.
620 * PARAMS
621 * pFlags [I] Flags. See notes.
622 * pBuffer [I] Buffer to marshal the clip format from.
623 * phBmp [O] Address that receive the unmarshaled bitmap.
625 * RETURNS
626 * The end of the marshaled data in the buffer.
628 * NOTES
629 * Even though the function is documented to take a pointer to an ULONG in
630 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
631 * the first parameter is an ULONG.
632 * This function is only intended to be called by the RPC runtime.
634 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
636 FIXME(":stub\n");
637 return pBuffer;
640 /******************************************************************************
641 * HBITMAP_UserFree [OLE32.@]
643 * Frees an unmarshaled bitmap.
645 * PARAMS
646 * pFlags [I] Flags. See notes.
647 * phBmp [I] Bitmap to free.
649 * RETURNS
650 * The end of the marshaled data in the buffer.
652 * NOTES
653 * Even though the function is documented to take a pointer to a ULONG in
654 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
655 * which the first parameter is a ULONG.
656 * This function is only intended to be called by the RPC runtime.
658 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
660 FIXME(":stub\n");
663 /******************************************************************************
664 * HICON_UserSize [OLE32.@]
666 * Calculates the buffer size required to marshal an icon.
668 * PARAMS
669 * pFlags [I] Flags. See notes.
670 * StartingSize [I] Starting size of the buffer. This value is added on to
671 * the buffer size required for the icon.
672 * phIcon [I] Icon to size.
674 * RETURNS
675 * The buffer size required to marshal an icon plus the starting size.
677 * NOTES
678 * Even though the function is documented to take a pointer to a ULONG in
679 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
680 * the first parameter is a ULONG.
681 * This function is only intended to be called by the RPC runtime.
683 ULONG __RPC_USER HICON_UserSize(ULONG *pFlags, ULONG StartingSize, HICON *phIcon)
685 FIXME(":stub\n");
686 return StartingSize;
689 /******************************************************************************
690 * HICON_UserMarshal [OLE32.@]
692 * Marshals an icon into a buffer.
694 * PARAMS
695 * pFlags [I] Flags. See notes.
696 * pBuffer [I] Buffer to marshal the icon into.
697 * phIcon [I] Icon to marshal.
699 * RETURNS
700 * The end of the marshaled data in the buffer.
702 * NOTES
703 * Even though the function is documented to take a pointer to a ULONG in
704 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
705 * the first parameter is a ULONG.
706 * This function is only intended to be called by the RPC runtime.
708 unsigned char * __RPC_USER HICON_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
710 FIXME(":stub\n");
711 return pBuffer;
714 /******************************************************************************
715 * HICON_UserUnmarshal [OLE32.@]
717 * Unmarshals an icon from a buffer.
719 * PARAMS
720 * pFlags [I] Flags. See notes.
721 * pBuffer [I] Buffer to marshal the icon from.
722 * phIcon [O] Address that receive the unmarshaled icon.
724 * RETURNS
725 * The end of the marshaled data in the buffer.
727 * NOTES
728 * Even though the function is documented to take a pointer to an ULONG in
729 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
730 * the first parameter is an ULONG.
731 * This function is only intended to be called by the RPC runtime.
733 unsigned char * __RPC_USER HICON_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
735 FIXME(":stub\n");
736 return pBuffer;
739 /******************************************************************************
740 * HICON_UserFree [OLE32.@]
742 * Frees an unmarshaled icon.
744 * PARAMS
745 * pFlags [I] Flags. See notes.
746 * phIcon [I] Icon to free.
748 * RETURNS
749 * The end of the marshaled data in the buffer.
751 * NOTES
752 * Even though the function is documented to take a pointer to a ULONG in
753 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
754 * which the first parameter is a ULONG.
755 * This function is only intended to be called by the RPC runtime.
757 void __RPC_USER HICON_UserFree(ULONG *pFlags, HICON *phIcon)
759 FIXME(":stub\n");
762 /******************************************************************************
763 * HDC_UserSize [OLE32.@]
765 * Calculates the buffer size required to marshal an HDC.
767 * PARAMS
768 * pFlags [I] Flags. See notes.
769 * StartingSize [I] Starting size of the buffer. This value is added on to
770 * the buffer size required for the clip format.
771 * phGlobal [I] HDC to size.
773 * RETURNS
774 * The buffer size required to marshal an HDC plus the starting size.
776 * NOTES
777 * Even though the function is documented to take a pointer to a ULONG in
778 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
779 * the first parameter is a ULONG.
780 * This function is only intended to be called by the RPC runtime.
782 ULONG __RPC_USER HDC_UserSize(ULONG *pFlags, ULONG StartingSize, HDC *phdc)
784 FIXME(":stub\n");
785 return StartingSize;
788 /******************************************************************************
789 * HDC_UserMarshal [OLE32.@]
791 * Marshals an HDC into a buffer.
793 * PARAMS
794 * pFlags [I] Flags. See notes.
795 * pBuffer [I] Buffer to marshal the clip format into.
796 * phdc [I] HDC to marshal.
798 * RETURNS
799 * The end of the marshaled data in the buffer.
801 * NOTES
802 * Even though the function is documented to take a pointer to a ULONG in
803 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
804 * the first parameter is a ULONG.
805 * This function is only intended to be called by the RPC runtime.
807 unsigned char * __RPC_USER HDC_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
809 FIXME(":stub\n");
810 return pBuffer;
813 /******************************************************************************
814 * HDC_UserUnmarshal [OLE32.@]
816 * Unmarshals an HDC from a buffer.
818 * PARAMS
819 * pFlags [I] Flags. See notes.
820 * pBuffer [I] Buffer to marshal the clip format from.
821 * phdc [O] Address that receive the unmarshaled HDC.
823 * RETURNS
824 * The end of the marshaled data in the buffer.
826 * NOTES
827 * Even though the function is documented to take a pointer to an ULONG in
828 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
829 * the first parameter is an ULONG.
830 * This function is only intended to be called by the RPC runtime.
832 unsigned char * __RPC_USER HDC_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
834 FIXME(":stub\n");
835 return pBuffer;
838 /******************************************************************************
839 * HDC_UserFree [OLE32.@]
841 * Frees an unmarshaled HDC.
843 * PARAMS
844 * pFlags [I] Flags. See notes.
845 * phdc [I] HDC to free.
847 * RETURNS
848 * The end of the marshaled data in the buffer.
850 * NOTES
851 * Even though the function is documented to take a pointer to a ULONG in
852 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
853 * which the first parameter is a ULONG.
854 * This function is only intended to be called by the RPC runtime.
856 void __RPC_USER HDC_UserFree(ULONG *pFlags, HDC *phdc)
858 FIXME(":stub\n");
861 /******************************************************************************
862 * HPALETTE_UserSize [OLE32.@]
864 * Calculates the buffer size required to marshal a palette.
866 * PARAMS
867 * pFlags [I] Flags. See notes.
868 * StartingSize [I] Starting size of the buffer. This value is added on to
869 * the buffer size required for the clip format.
870 * phPal [I] Palette to size.
872 * RETURNS
873 * The buffer size required to marshal a palette plus the starting size.
875 * NOTES
876 * Even though the function is documented to take a pointer to a ULONG in
877 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
878 * the first parameter is a ULONG.
879 * This function is only intended to be called by the RPC runtime.
881 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
883 FIXME(":stub\n");
884 return StartingSize;
887 /******************************************************************************
888 * HPALETTE_UserMarshal [OLE32.@]
890 * Marshals a palette into a buffer.
892 * PARAMS
893 * pFlags [I] Flags. See notes.
894 * pBuffer [I] Buffer to marshal the clip format into.
895 * phPal [I] Palette to marshal.
897 * RETURNS
898 * The end of the marshaled data in the buffer.
900 * NOTES
901 * Even though the function is documented to take a pointer to a ULONG in
902 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
903 * the first parameter is a ULONG.
904 * This function is only intended to be called by the RPC runtime.
906 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
908 FIXME(":stub\n");
909 return pBuffer;
912 /******************************************************************************
913 * HPALETTE_UserUnmarshal [OLE32.@]
915 * Unmarshals a palette from a buffer.
917 * PARAMS
918 * pFlags [I] Flags. See notes.
919 * pBuffer [I] Buffer to marshal the clip format from.
920 * phPal [O] Address that receive the unmarshaled palette.
922 * RETURNS
923 * The end of the marshaled data in the buffer.
925 * NOTES
926 * Even though the function is documented to take a pointer to an ULONG in
927 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
928 * the first parameter is an ULONG.
929 * This function is only intended to be called by the RPC runtime.
931 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
933 FIXME(":stub\n");
934 return pBuffer;
937 /******************************************************************************
938 * HPALETTE_UserFree [OLE32.@]
940 * Frees an unmarshaled palette.
942 * PARAMS
943 * pFlags [I] Flags. See notes.
944 * phPal [I] Palette to free.
946 * RETURNS
947 * The end of the marshaled data in the buffer.
949 * NOTES
950 * Even though the function is documented to take a pointer to a ULONG in
951 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
952 * which the first parameter is a ULONG.
953 * This function is only intended to be called by the RPC runtime.
955 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
957 FIXME(":stub\n");
961 /******************************************************************************
962 * HMETAFILE_UserSize [OLE32.@]
964 * Calculates the buffer size required to marshal a metafile.
966 * PARAMS
967 * pFlags [I] Flags. See notes.
968 * StartingSize [I] Starting size of the buffer. This value is added on to
969 * the buffer size required for the clip format.
970 * phmf [I] Metafile to size.
972 * RETURNS
973 * The buffer size required to marshal a metafile plus the starting size.
975 * NOTES
976 * Even though the function is documented to take a pointer to a ULONG in
977 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
978 * the first parameter is a ULONG.
979 * This function is only intended to be called by the RPC runtime.
981 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
983 ULONG size = StartingSize;
985 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
987 ALIGN_LENGTH(size, 3);
989 size += sizeof(ULONG);
990 if (LOWORD(*pFlags) == MSHCTX_INPROC)
991 size += sizeof(ULONG_PTR);
992 else
994 size += sizeof(ULONG);
996 if (*phmf)
998 UINT mfsize;
1000 size += 2 * sizeof(ULONG);
1001 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1002 size += mfsize;
1006 return size;
1009 /******************************************************************************
1010 * HMETAFILE_UserMarshal [OLE32.@]
1012 * Marshals a metafile into a buffer.
1014 * PARAMS
1015 * pFlags [I] Flags. See notes.
1016 * pBuffer [I] Buffer to marshal the clip format into.
1017 * phEmf [I] Metafile to marshal.
1019 * RETURNS
1020 * The end of the marshaled data in the buffer.
1022 * NOTES
1023 * Even though the function is documented to take a pointer to a ULONG in
1024 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1025 * the first parameter is a ULONG.
1026 * This function is only intended to be called by the RPC runtime.
1028 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1030 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
1032 ALIGN_POINTER(pBuffer, 3);
1034 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1036 if (sizeof(*phmf) == 8)
1037 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1038 else
1039 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1040 pBuffer += sizeof(ULONG);
1041 *(HMETAFILE *)pBuffer = *phmf;
1042 pBuffer += sizeof(HMETAFILE);
1044 else
1046 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1047 pBuffer += sizeof(ULONG);
1048 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1049 pBuffer += sizeof(ULONG);
1051 if (*phmf)
1053 UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1055 *(ULONG *)pBuffer = mfsize;
1056 pBuffer += sizeof(ULONG);
1057 *(ULONG *)pBuffer = mfsize;
1058 pBuffer += sizeof(ULONG);
1059 GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
1060 pBuffer += mfsize;
1064 return pBuffer;
1067 /******************************************************************************
1068 * HMETAFILE_UserUnmarshal [OLE32.@]
1070 * Unmarshals a metafile from a buffer.
1072 * PARAMS
1073 * pFlags [I] Flags. See notes.
1074 * pBuffer [I] Buffer to marshal the clip format from.
1075 * phmf [O] Address that receive the unmarshaled metafile.
1077 * RETURNS
1078 * The end of the marshaled data in the buffer.
1080 * NOTES
1081 * Even though the function is documented to take a pointer to an ULONG in
1082 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1083 * the first parameter is an ULONG.
1084 * This function is only intended to be called by the RPC runtime.
1086 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1088 ULONG fContext;
1090 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
1092 ALIGN_POINTER(pBuffer, 3);
1094 fContext = *(ULONG *)pBuffer;
1095 pBuffer += sizeof(ULONG);
1097 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
1098 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
1100 *phmf = *(HMETAFILE *)pBuffer;
1101 pBuffer += sizeof(*phmf);
1103 else if (fContext == WDT_REMOTE_CALL)
1105 ULONG handle;
1107 handle = *(ULONG *)pBuffer;
1108 pBuffer += sizeof(ULONG);
1110 if (handle)
1112 ULONG size;
1113 size = *(ULONG *)pBuffer;
1114 pBuffer += sizeof(ULONG);
1115 if (size != *(ULONG *)pBuffer)
1117 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1118 return pBuffer;
1120 pBuffer += sizeof(ULONG);
1121 *phmf = SetMetaFileBitsEx(size, pBuffer);
1122 pBuffer += size;
1124 else
1125 *phmf = NULL;
1127 else
1128 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1130 return pBuffer;
1133 /******************************************************************************
1134 * HMETAFILE_UserFree [OLE32.@]
1136 * Frees an unmarshaled metafile.
1138 * PARAMS
1139 * pFlags [I] Flags. See notes.
1140 * phmf [I] Metafile to free.
1142 * RETURNS
1143 * The end of the marshaled data in the buffer.
1145 * NOTES
1146 * Even though the function is documented to take a pointer to a ULONG in
1147 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1148 * which the first parameter is a ULONG.
1149 * This function is only intended to be called by the RPC runtime.
1151 void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
1153 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
1155 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1156 DeleteMetaFile(*phmf);
1159 /******************************************************************************
1160 * HENHMETAFILE_UserSize [OLE32.@]
1162 * Calculates the buffer size required to marshal an enhanced metafile.
1164 * PARAMS
1165 * pFlags [I] Flags. See notes.
1166 * StartingSize [I] Starting size of the buffer. This value is added on to
1167 * the buffer size required for the clip format.
1168 * phEmf [I] Enhanced metafile to size.
1170 * RETURNS
1171 * The buffer size required to marshal an enhanced metafile plus the starting size.
1173 * NOTES
1174 * Even though the function is documented to take a pointer to a ULONG in
1175 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1176 * the first parameter is a ULONG.
1177 * This function is only intended to be called by the RPC runtime.
1179 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
1181 ULONG size = StartingSize;
1183 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
1185 size += sizeof(ULONG);
1186 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1187 size += sizeof(ULONG_PTR);
1188 else
1190 size += sizeof(ULONG);
1192 if (*phEmf)
1194 UINT emfsize;
1196 size += 2 * sizeof(ULONG);
1197 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1198 size += emfsize;
1202 return size;
1205 /******************************************************************************
1206 * HENHMETAFILE_UserMarshal [OLE32.@]
1208 * Marshals an enhance metafile into a buffer.
1210 * PARAMS
1211 * pFlags [I] Flags. See notes.
1212 * pBuffer [I] Buffer to marshal the clip format into.
1213 * phEmf [I] Enhanced metafile to marshal.
1215 * RETURNS
1216 * The end of the marshaled data in the buffer.
1218 * NOTES
1219 * Even though the function is documented to take a pointer to a ULONG in
1220 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1221 * the first parameter is a ULONG.
1222 * This function is only intended to be called by the RPC runtime.
1224 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1226 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1228 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1230 if (sizeof(*phEmf) == 8)
1231 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1232 else
1233 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1234 pBuffer += sizeof(ULONG);
1235 *(HENHMETAFILE *)pBuffer = *phEmf;
1236 pBuffer += sizeof(HENHMETAFILE);
1238 else
1240 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1241 pBuffer += sizeof(ULONG);
1242 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1243 pBuffer += sizeof(ULONG);
1245 if (*phEmf)
1247 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1249 *(ULONG *)pBuffer = emfsize;
1250 pBuffer += sizeof(ULONG);
1251 *(ULONG *)pBuffer = emfsize;
1252 pBuffer += sizeof(ULONG);
1253 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1254 pBuffer += emfsize;
1258 return pBuffer;
1261 /******************************************************************************
1262 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1264 * Unmarshals an enhanced metafile from a buffer.
1266 * PARAMS
1267 * pFlags [I] Flags. See notes.
1268 * pBuffer [I] Buffer to marshal the clip format from.
1269 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
1271 * RETURNS
1272 * The end of the marshaled data in the buffer.
1274 * NOTES
1275 * Even though the function is documented to take a pointer to an ULONG in
1276 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1277 * the first parameter is an ULONG.
1278 * This function is only intended to be called by the RPC runtime.
1280 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1282 ULONG fContext;
1284 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1286 fContext = *(ULONG *)pBuffer;
1287 pBuffer += sizeof(ULONG);
1289 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1290 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1292 *phEmf = *(HENHMETAFILE *)pBuffer;
1293 pBuffer += sizeof(*phEmf);
1295 else if (fContext == WDT_REMOTE_CALL)
1297 ULONG handle;
1299 handle = *(ULONG *)pBuffer;
1300 pBuffer += sizeof(ULONG);
1302 if (handle)
1304 ULONG size;
1305 size = *(ULONG *)pBuffer;
1306 pBuffer += sizeof(ULONG);
1307 if (size != *(ULONG *)pBuffer)
1309 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1310 return pBuffer;
1312 pBuffer += sizeof(ULONG);
1313 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1314 pBuffer += size;
1316 else
1317 *phEmf = NULL;
1319 else
1320 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1322 return pBuffer;
1325 /******************************************************************************
1326 * HENHMETAFILE_UserFree [OLE32.@]
1328 * Frees an unmarshaled enhanced metafile.
1330 * PARAMS
1331 * pFlags [I] Flags. See notes.
1332 * phEmf [I] Enhanced metafile to free.
1334 * RETURNS
1335 * The end of the marshaled data in the buffer.
1337 * NOTES
1338 * Even though the function is documented to take a pointer to a ULONG in
1339 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1340 * which the first parameter is a ULONG.
1341 * This function is only intended to be called by the RPC runtime.
1343 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1345 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1347 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1348 DeleteEnhMetaFile(*phEmf);
1351 /******************************************************************************
1352 * HMETAFILEPICT_UserSize [OLE32.@]
1354 * Calculates the buffer size required to marshal an metafile pict.
1356 * PARAMS
1357 * pFlags [I] Flags. See notes.
1358 * StartingSize [I] Starting size of the buffer. This value is added on to
1359 * the buffer size required for the clip format.
1360 * phMfp [I] Metafile pict to size.
1362 * RETURNS
1363 * The buffer size required to marshal a metafile pict plus the starting size.
1365 * NOTES
1366 * Even though the function is documented to take a pointer to a ULONG in
1367 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1368 * the first parameter is a ULONG.
1369 * This function is only intended to be called by the RPC runtime.
1371 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1373 ULONG size = StartingSize;
1375 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1377 size += sizeof(ULONG);
1379 if(LOWORD(*pFlags) == MSHCTX_INPROC)
1380 size += sizeof(HMETAFILEPICT);
1381 else
1383 size += sizeof(ULONG);
1385 if (*phMfp)
1387 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1389 /* FIXME: raise an exception if mfpict is NULL? */
1390 size += 3 * sizeof(ULONG);
1391 size += sizeof(ULONG);
1393 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1395 GlobalUnlock(*phMfp);
1399 return size;
1402 /******************************************************************************
1403 * HMETAFILEPICT_UserMarshal [OLE32.@]
1405 * Marshals a metafile pict into a buffer.
1407 * PARAMS
1408 * pFlags [I] Flags. See notes.
1409 * pBuffer [I] Buffer to marshal the clip format into.
1410 * phMfp [I] Metafile pict to marshal.
1412 * RETURNS
1413 * The end of the marshaled data in the buffer.
1415 * NOTES
1416 * Even though the function is documented to take a pointer to a ULONG in
1417 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1418 * the first parameter is a ULONG.
1419 * This function is only intended to be called by the RPC runtime.
1421 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1423 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1425 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1427 if (sizeof(HMETAFILEPICT) == 8)
1428 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1429 else
1430 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1431 pBuffer += sizeof(ULONG);
1432 *(HMETAFILEPICT *)pBuffer = *phMfp;
1433 pBuffer += sizeof(HMETAFILEPICT);
1435 else
1437 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1438 pBuffer += sizeof(ULONG);
1439 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
1440 pBuffer += sizeof(ULONG);
1442 if (*phMfp)
1444 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1445 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1447 /* FIXME: raise an exception if mfpict is NULL? */
1448 remmfpict->mm = mfpict->mm;
1449 remmfpict->xExt = mfpict->xExt;
1450 remmfpict->yExt = mfpict->yExt;
1451 pBuffer += 3 * sizeof(ULONG);
1452 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1453 pBuffer += sizeof(ULONG);
1455 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1457 GlobalUnlock(*phMfp);
1460 return pBuffer;
1463 /******************************************************************************
1464 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1466 * Unmarshals an metafile pict from a buffer.
1468 * PARAMS
1469 * pFlags [I] Flags. See notes.
1470 * pBuffer [I] Buffer to marshal the clip format from.
1471 * phMfp [O] Address that receive the unmarshaled metafile pict.
1473 * RETURNS
1474 * The end of the marshaled data in the buffer.
1476 * NOTES
1477 * Even though the function is documented to take a pointer to an ULONG in
1478 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1479 * the first parameter is an ULONG.
1480 * This function is only intended to be called by the RPC runtime.
1482 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1484 ULONG fContext;
1486 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1488 fContext = *(ULONG *)pBuffer;
1489 pBuffer += sizeof(ULONG);
1491 if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
1493 *phMfp = *(HMETAFILEPICT *)pBuffer;
1494 pBuffer += sizeof(HMETAFILEPICT);
1496 else
1498 ULONG handle = *(ULONG *)pBuffer;
1499 pBuffer += sizeof(ULONG);
1500 *phMfp = NULL;
1502 if(handle)
1504 METAFILEPICT *mfpict;
1505 const remoteMETAFILEPICT *remmfpict;
1506 ULONG user_marshal_prefix;
1508 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1510 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1511 if (!*phMfp)
1512 RpcRaiseException(E_OUTOFMEMORY);
1514 mfpict = GlobalLock(*phMfp);
1515 mfpict->mm = remmfpict->mm;
1516 mfpict->xExt = remmfpict->xExt;
1517 mfpict->yExt = remmfpict->yExt;
1518 pBuffer += 3 * sizeof(ULONG);
1519 user_marshal_prefix = *(ULONG *)pBuffer;
1520 pBuffer += sizeof(ULONG);
1522 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1523 RpcRaiseException(RPC_X_INVALID_TAG);
1525 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1527 GlobalUnlock(*phMfp);
1530 return pBuffer;
1533 /******************************************************************************
1534 * HMETAFILEPICT_UserFree [OLE32.@]
1536 * Frees an unmarshaled metafile pict.
1538 * PARAMS
1539 * pFlags [I] Flags. See notes.
1540 * phMfp [I] Metafile pict to free.
1542 * RETURNS
1543 * The end of the marshaled data in the buffer.
1545 * NOTES
1546 * Even though the function is documented to take a pointer to a ULONG in
1547 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1548 * which the first parameter is a ULONG.
1549 * This function is only intended to be called by the RPC runtime.
1551 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1553 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1555 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1557 METAFILEPICT *mfpict;
1559 mfpict = GlobalLock(*phMfp);
1560 /* FIXME: raise an exception if mfpict is NULL? */
1561 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1562 GlobalUnlock(*phMfp);
1564 GlobalFree(*phMfp);
1568 /******************************************************************************
1569 * WdtpInterfacePointer_UserSize [OLE32.@]
1571 * Calculates the buffer size required to marshal an interface pointer.
1573 * PARAMS
1574 * pFlags [I] Flags. See notes.
1575 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1576 * punk [I] Interface pointer to size.
1577 * StartingSize [I] Starting size of the buffer. This value is added on to
1578 * the buffer size required for the clip format.
1579 * riid [I] ID of interface to size.
1581 * RETURNS
1582 * The buffer size required to marshal an interface pointer plus the starting size.
1584 * NOTES
1585 * Even though the function is documented to take a pointer to a ULONG in
1586 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1587 * the first parameter is a ULONG.
1589 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1591 DWORD marshal_size = 0;
1592 HRESULT hr;
1594 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1596 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1597 if(FAILED(hr)) return StartingSize;
1599 ALIGN_LENGTH(StartingSize, 3);
1600 StartingSize += 2 * sizeof(DWORD);
1601 return StartingSize + marshal_size;
1604 /******************************************************************************
1605 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1607 * Marshals an interface pointer into a buffer.
1609 * PARAMS
1610 * pFlags [I] Flags. See notes.
1611 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1612 * pBuffer [I] Buffer to marshal the clip format into.
1613 * punk [I] Interface pointer to marshal.
1614 * riid [I] ID of interface to marshal.
1616 * RETURNS
1617 * The end of the marshaled data in the buffer.
1619 * NOTES
1620 * Even though the function is documented to take a pointer to a ULONG in
1621 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1622 * the first parameter is a ULONG.
1624 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1626 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1627 IStream *stm;
1628 DWORD size;
1629 void *ptr;
1631 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1633 if(!h) return NULL;
1634 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1636 GlobalFree(h);
1637 return NULL;
1640 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1642 IStream_Release(stm);
1643 return pBuffer;
1646 ALIGN_POINTER(pBuffer, 3);
1647 size = GlobalSize(h);
1649 *(DWORD *)pBuffer = size;
1650 pBuffer += sizeof(DWORD);
1651 *(DWORD *)pBuffer = size;
1652 pBuffer += sizeof(DWORD);
1654 ptr = GlobalLock(h);
1655 memcpy(pBuffer, ptr, size);
1656 GlobalUnlock(h);
1658 IStream_Release(stm);
1659 return pBuffer + size;
1662 /******************************************************************************
1663 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1665 * Unmarshals an interface pointer from a buffer.
1667 * PARAMS
1668 * pFlags [I] Flags. See notes.
1669 * pBuffer [I] Buffer to marshal the clip format from.
1670 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1671 * riid [I] ID of interface to unmarshal.
1673 * RETURNS
1674 * The end of the marshaled data in the buffer.
1676 * NOTES
1677 * Even though the function is documented to take a pointer to an ULONG in
1678 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1679 * the first parameter is an ULONG.
1681 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1683 HRESULT hr;
1684 HGLOBAL h;
1685 IStream *stm;
1686 DWORD size;
1687 void *ptr;
1689 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1691 ALIGN_POINTER(pBuffer, 3);
1693 size = *(DWORD *)pBuffer;
1694 pBuffer += sizeof(DWORD);
1695 if(size != *(DWORD *)pBuffer)
1696 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1698 pBuffer += sizeof(DWORD);
1700 /* FIXME: sanity check on size */
1702 h = GlobalAlloc(GMEM_MOVEABLE, size);
1703 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1705 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1707 GlobalFree(h);
1708 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1711 ptr = GlobalLock(h);
1712 memcpy(ptr, pBuffer, size);
1713 GlobalUnlock(h);
1715 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1716 IStream_Release(stm);
1718 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1720 return pBuffer + size;
1723 /******************************************************************************
1724 * WdtpInterfacePointer_UserFree [OLE32.@]
1726 * Releases an unmarshaled interface pointer.
1728 * PARAMS
1729 * punk [I] Interface pointer to release.
1731 * RETURNS
1732 * Nothing.
1734 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1736 TRACE("(%p)\n", punk);
1737 if(punk) IUnknown_Release(punk);
1740 /******************************************************************************
1741 * STGMEDIUM_UserSize [OLE32.@]
1743 * Calculates the buffer size required to marshal an STGMEDIUM.
1745 * PARAMS
1746 * pFlags [I] Flags. See notes.
1747 * StartingSize [I] Starting size of the buffer. This value is added on to
1748 * the buffer size required for the clip format.
1749 * pStgMedium [I] STGMEDIUM to size.
1751 * RETURNS
1752 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1754 * NOTES
1755 * Even though the function is documented to take a pointer to a ULONG in
1756 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1757 * the first parameter is a ULONG.
1758 * This function is only intended to be called by the RPC runtime.
1760 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1762 ULONG size = StartingSize;
1764 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1766 ALIGN_LENGTH(size, 3);
1768 size += 2 * sizeof(DWORD);
1769 if (pStgMedium->tymed != TYMED_NULL)
1770 size += sizeof(DWORD);
1772 switch (pStgMedium->tymed)
1774 case TYMED_NULL:
1775 TRACE("TYMED_NULL\n");
1776 break;
1777 case TYMED_HGLOBAL:
1778 TRACE("TYMED_HGLOBAL\n");
1779 if (pStgMedium->u.hGlobal)
1780 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1781 break;
1782 case TYMED_FILE:
1783 TRACE("TYMED_FILE\n");
1784 if (pStgMedium->u.lpszFileName)
1786 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1787 size += 3 * sizeof(DWORD) +
1788 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1790 break;
1791 case TYMED_ISTREAM:
1792 TRACE("TYMED_ISTREAM\n");
1793 if (pStgMedium->u.pstm)
1795 IUnknown *unk;
1796 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1797 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1798 IUnknown_Release(unk);
1800 break;
1801 case TYMED_ISTORAGE:
1802 TRACE("TYMED_ISTORAGE\n");
1803 if (pStgMedium->u.pstg)
1805 IUnknown *unk;
1806 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1807 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1808 IUnknown_Release(unk);
1810 break;
1811 case TYMED_GDI:
1812 TRACE("TYMED_GDI\n");
1813 if (pStgMedium->u.hBitmap)
1815 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1817 break;
1818 case TYMED_MFPICT:
1819 TRACE("TYMED_MFPICT\n");
1820 if (pStgMedium->u.hMetaFilePict)
1821 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1822 break;
1823 case TYMED_ENHMF:
1824 TRACE("TYMED_ENHMF\n");
1825 if (pStgMedium->u.hEnhMetaFile)
1826 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1827 break;
1828 default:
1829 RaiseException(DV_E_TYMED, 0, 0, NULL);
1832 if (pStgMedium->pUnkForRelease)
1833 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1835 return size;
1838 /******************************************************************************
1839 * STGMEDIUM_UserMarshal [OLE32.@]
1841 * Marshals a STGMEDIUM into a buffer.
1843 * PARAMS
1844 * pFlags [I] Flags. See notes.
1845 * pBuffer [I] Buffer to marshal the clip format into.
1846 * pCF [I] STGMEDIUM to marshal.
1848 * RETURNS
1849 * The end of the marshaled data in the buffer.
1851 * NOTES
1852 * Even though the function is documented to take a pointer to a ULONG in
1853 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1854 * the first parameter is a ULONG.
1855 * This function is only intended to be called by the RPC runtime.
1857 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1859 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1861 ALIGN_POINTER(pBuffer, 3);
1863 *(DWORD *)pBuffer = pStgMedium->tymed;
1864 pBuffer += sizeof(DWORD);
1865 if (pStgMedium->tymed != TYMED_NULL)
1867 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1868 pBuffer += sizeof(DWORD);
1870 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1871 pBuffer += sizeof(DWORD);
1873 switch (pStgMedium->tymed)
1875 case TYMED_NULL:
1876 TRACE("TYMED_NULL\n");
1877 break;
1878 case TYMED_HGLOBAL:
1879 TRACE("TYMED_HGLOBAL\n");
1880 if (pStgMedium->u.hGlobal)
1881 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1882 break;
1883 case TYMED_FILE:
1884 TRACE("TYMED_FILE\n");
1885 if (pStgMedium->u.lpszFileName)
1887 DWORD len;
1888 len = strlenW(pStgMedium->u.lpszFileName);
1889 /* conformance */
1890 *(DWORD *)pBuffer = len + 1;
1891 pBuffer += sizeof(DWORD);
1892 /* offset */
1893 *(DWORD *)pBuffer = 0;
1894 pBuffer += sizeof(DWORD);
1895 /* variance */
1896 *(DWORD *)pBuffer = len + 1;
1897 pBuffer += sizeof(DWORD);
1899 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1900 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1902 break;
1903 case TYMED_ISTREAM:
1904 TRACE("TYMED_ISTREAM\n");
1905 if (pStgMedium->u.pstm)
1907 IUnknown *unk;
1908 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1909 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1910 IUnknown_Release(unk);
1912 break;
1913 case TYMED_ISTORAGE:
1914 TRACE("TYMED_ISTORAGE\n");
1915 if (pStgMedium->u.pstg)
1917 IUnknown *unk;
1918 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1919 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1920 IUnknown_Release(unk);
1922 break;
1923 case TYMED_GDI:
1924 TRACE("TYMED_GDI\n");
1925 if (pStgMedium->u.hBitmap)
1927 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1929 break;
1930 case TYMED_MFPICT:
1931 TRACE("TYMED_MFPICT\n");
1932 if (pStgMedium->u.hMetaFilePict)
1933 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1934 break;
1935 case TYMED_ENHMF:
1936 TRACE("TYMED_ENHMF\n");
1937 if (pStgMedium->u.hEnhMetaFile)
1938 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1939 break;
1940 default:
1941 RaiseException(DV_E_TYMED, 0, 0, NULL);
1944 if (pStgMedium->pUnkForRelease)
1945 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1947 return pBuffer;
1950 /******************************************************************************
1951 * STGMEDIUM_UserUnmarshal [OLE32.@]
1953 * Unmarshals a STGMEDIUM from a buffer.
1955 * PARAMS
1956 * pFlags [I] Flags. See notes.
1957 * pBuffer [I] Buffer to marshal the clip format from.
1958 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1960 * RETURNS
1961 * The end of the marshaled data in the buffer.
1963 * NOTES
1964 * Even though the function is documented to take a pointer to an ULONG in
1965 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1966 * the first parameter is an ULONG.
1967 * This function is only intended to be called by the RPC runtime.
1969 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1971 DWORD content = 0;
1972 DWORD releaseunk;
1974 ALIGN_POINTER(pBuffer, 3);
1976 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1978 pStgMedium->tymed = *(DWORD *)pBuffer;
1979 pBuffer += sizeof(DWORD);
1980 if (pStgMedium->tymed != TYMED_NULL)
1982 content = *(DWORD *)pBuffer;
1983 pBuffer += sizeof(DWORD);
1985 releaseunk = *(DWORD *)pBuffer;
1986 pBuffer += sizeof(DWORD);
1988 switch (pStgMedium->tymed)
1990 case TYMED_NULL:
1991 TRACE("TYMED_NULL\n");
1992 break;
1993 case TYMED_HGLOBAL:
1994 TRACE("TYMED_HGLOBAL\n");
1995 if (content)
1996 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1997 break;
1998 case TYMED_FILE:
1999 TRACE("TYMED_FILE\n");
2000 if (content)
2002 DWORD conformance;
2003 DWORD variance;
2004 conformance = *(DWORD *)pBuffer;
2005 pBuffer += sizeof(DWORD);
2006 if (*(DWORD *)pBuffer != 0)
2008 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
2009 RpcRaiseException(RPC_S_INVALID_BOUND);
2010 return NULL;
2012 pBuffer += sizeof(DWORD);
2013 variance = *(DWORD *)pBuffer;
2014 pBuffer += sizeof(DWORD);
2015 if (conformance != variance)
2017 ERR("conformance (%d) and variance (%d) should be equal\n",
2018 conformance, variance);
2019 RpcRaiseException(RPC_S_INVALID_BOUND);
2020 return NULL;
2022 if (conformance > 0x7fffffff)
2024 ERR("conformance 0x%x too large\n", conformance);
2025 RpcRaiseException(RPC_S_INVALID_BOUND);
2026 return NULL;
2028 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2029 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2030 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2031 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2032 pBuffer += variance * sizeof(WCHAR);
2034 else
2035 pStgMedium->u.lpszFileName = NULL;
2036 break;
2037 case TYMED_ISTREAM:
2038 TRACE("TYMED_ISTREAM\n");
2039 if (content)
2041 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
2043 else
2044 pStgMedium->u.pstm = NULL;
2045 break;
2046 case TYMED_ISTORAGE:
2047 TRACE("TYMED_ISTORAGE\n");
2048 if (content)
2050 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
2052 else
2053 pStgMedium->u.pstg = NULL;
2054 break;
2055 case TYMED_GDI:
2056 TRACE("TYMED_GDI\n");
2057 if (content)
2059 FIXME("not implemented for GDI object\n");
2061 else
2062 pStgMedium->u.hBitmap = NULL;
2063 break;
2064 case TYMED_MFPICT:
2065 TRACE("TYMED_MFPICT\n");
2066 if (content)
2067 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2068 else
2069 pStgMedium->u.hMetaFilePict = NULL;
2070 break;
2071 case TYMED_ENHMF:
2072 TRACE("TYMED_ENHMF\n");
2073 if (content)
2074 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2075 else
2076 pStgMedium->u.hEnhMetaFile = NULL;
2077 break;
2078 default:
2079 RaiseException(DV_E_TYMED, 0, 0, NULL);
2082 pStgMedium->pUnkForRelease = NULL;
2083 if (releaseunk)
2084 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2086 return pBuffer;
2089 /******************************************************************************
2090 * STGMEDIUM_UserFree [OLE32.@]
2092 * Frees an unmarshaled STGMEDIUM.
2094 * PARAMS
2095 * pFlags [I] Flags. See notes.
2096 * pStgmedium [I] STGMEDIUM to free.
2098 * RETURNS
2099 * The end of the marshaled data in the buffer.
2101 * NOTES
2102 * Even though the function is documented to take a pointer to a ULONG in
2103 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2104 * which the first parameter is a ULONG.
2105 * This function is only intended to be called by the RPC runtime.
2107 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2109 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2111 ReleaseStgMedium(pStgMedium);
2114 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2116 TRACE("\n");
2117 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2120 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2122 TRACE("\n");
2123 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2126 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2128 TRACE("\n");
2129 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2132 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2134 TRACE("\n");
2135 STGMEDIUM_UserFree(pFlags, pStgMedium);
2138 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2140 FIXME(":stub\n");
2141 return StartingSize;
2144 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2146 FIXME(":stub\n");
2147 return pBuffer;
2150 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2152 FIXME(":stub\n");
2153 return pBuffer;
2156 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2158 FIXME(":stub\n");
2161 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2163 FIXME(":stub\n");
2164 return StartingSize;
2167 unsigned char * __RPC_USER SNB_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2169 FIXME(":stub\n");
2170 return pBuffer;
2173 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2175 FIXME(":stub\n");
2176 return pBuffer;
2179 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2181 FIXME(":stub\n");
2184 /* call_as/local stubs for unknwn.idl */
2186 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2187 IClassFactory* This,
2188 IUnknown *pUnkOuter,
2189 REFIID riid,
2190 void **ppvObject)
2192 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2193 *ppvObject = NULL;
2194 if (pUnkOuter)
2196 ERR("aggregation is not allowed on remote objects\n");
2197 return CLASS_E_NOAGGREGATION;
2199 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2200 (IUnknown **) ppvObject);
2203 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2204 IClassFactory* This,
2205 REFIID riid,
2206 IUnknown **ppvObject)
2208 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2209 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2212 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2213 IClassFactory* This,
2214 BOOL fLock)
2216 FIXME(":stub\n");
2217 return E_NOTIMPL;
2220 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2221 IClassFactory* This,
2222 BOOL fLock)
2224 FIXME(":stub\n");
2225 return E_NOTIMPL;
2228 /* call_as/local stubs for objidl.idl */
2230 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2231 IEnumUnknown* This,
2232 ULONG celt,
2233 IUnknown **rgelt,
2234 ULONG *pceltFetched)
2236 ULONG fetched;
2237 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2238 if (!pceltFetched) pceltFetched = &fetched;
2239 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2242 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2243 IEnumUnknown* This,
2244 ULONG celt,
2245 IUnknown **rgelt,
2246 ULONG *pceltFetched)
2248 HRESULT hr;
2249 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2250 *pceltFetched = 0;
2251 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2252 if (hr == S_OK) *pceltFetched = celt;
2253 return hr;
2256 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2257 IBindCtx* This,
2258 BIND_OPTS *pbindopts)
2260 FIXME(":stub\n");
2261 return E_NOTIMPL;
2264 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2265 IBindCtx* This,
2266 BIND_OPTS2 *pbindopts)
2268 FIXME(":stub\n");
2269 return E_NOTIMPL;
2272 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2273 IBindCtx* This,
2274 BIND_OPTS *pbindopts)
2276 FIXME(":stub\n");
2277 return E_NOTIMPL;
2280 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2281 IBindCtx* This,
2282 BIND_OPTS2 *pbindopts)
2284 FIXME(":stub\n");
2285 return E_NOTIMPL;
2288 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2289 IEnumMoniker* This,
2290 ULONG celt,
2291 IMoniker **rgelt,
2292 ULONG *pceltFetched)
2294 ULONG fetched;
2295 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2296 if (!pceltFetched) pceltFetched = &fetched;
2297 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2300 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2301 IEnumMoniker* This,
2302 ULONG celt,
2303 IMoniker **rgelt,
2304 ULONG *pceltFetched)
2306 HRESULT hr;
2307 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2308 *pceltFetched = 0;
2309 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2310 if (hr == S_OK) *pceltFetched = celt;
2311 return hr;
2314 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2315 IRunnableObject* This)
2317 BOOL rv;
2318 FIXME(":stub\n");
2319 memset(&rv, 0, sizeof rv);
2320 return rv;
2323 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2324 IRunnableObject* This)
2326 FIXME(":stub\n");
2327 return E_NOTIMPL;
2330 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2331 IMoniker* This,
2332 IBindCtx *pbc,
2333 IMoniker *pmkToLeft,
2334 REFIID riidResult,
2335 void **ppvResult)
2337 FIXME(":stub\n");
2338 return E_NOTIMPL;
2341 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2342 IMoniker* This,
2343 IBindCtx *pbc,
2344 IMoniker *pmkToLeft,
2345 REFIID riidResult,
2346 IUnknown **ppvResult)
2348 FIXME(":stub\n");
2349 return E_NOTIMPL;
2352 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2353 IMoniker* This,
2354 IBindCtx *pbc,
2355 IMoniker *pmkToLeft,
2356 REFIID riid,
2357 void **ppvObj)
2359 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2360 return IMoniker_RemoteBindToStorage_Proxy(This, pbc, pmkToLeft, riid, (IUnknown**)ppvObj);
2363 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2364 IMoniker* This,
2365 IBindCtx *pbc,
2366 IMoniker *pmkToLeft,
2367 REFIID riid,
2368 IUnknown **ppvObj)
2370 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2371 return IMoniker_BindToStorage(This, pbc, pmkToLeft, riid, (void**)ppvObj);
2374 HRESULT CALLBACK IEnumString_Next_Proxy(
2375 IEnumString* This,
2376 ULONG celt,
2377 LPOLESTR *rgelt,
2378 ULONG *pceltFetched)
2380 ULONG fetched;
2381 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2382 if (!pceltFetched) pceltFetched = &fetched;
2383 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2386 HRESULT __RPC_STUB IEnumString_Next_Stub(
2387 IEnumString* This,
2388 ULONG celt,
2389 LPOLESTR *rgelt,
2390 ULONG *pceltFetched)
2392 HRESULT hr;
2393 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2394 *pceltFetched = 0;
2395 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2396 if (hr == S_OK) *pceltFetched = celt;
2397 return hr;
2400 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2401 ISequentialStream* This,
2402 void *pv,
2403 ULONG cb,
2404 ULONG *pcbRead)
2406 ULONG read;
2407 HRESULT hr;
2409 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2411 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2412 if(pcbRead) *pcbRead = read;
2414 return hr;
2417 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2418 ISequentialStream* This,
2419 byte *pv,
2420 ULONG cb,
2421 ULONG *pcbRead)
2423 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2424 return ISequentialStream_Read(This, pv, cb, pcbRead);
2427 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2428 ISequentialStream* This,
2429 const void *pv,
2430 ULONG cb,
2431 ULONG *pcbWritten)
2433 ULONG written;
2434 HRESULT hr;
2436 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2438 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2439 if(pcbWritten) *pcbWritten = written;
2441 return hr;
2444 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2445 ISequentialStream* This,
2446 const byte *pv,
2447 ULONG cb,
2448 ULONG *pcbWritten)
2450 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2451 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2454 HRESULT CALLBACK IStream_Seek_Proxy(
2455 IStream* This,
2456 LARGE_INTEGER dlibMove,
2457 DWORD dwOrigin,
2458 ULARGE_INTEGER *plibNewPosition)
2460 ULARGE_INTEGER newpos;
2461 HRESULT hr;
2463 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2465 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2466 if(plibNewPosition) *plibNewPosition = newpos;
2468 return hr;
2471 HRESULT __RPC_STUB IStream_Seek_Stub(
2472 IStream* This,
2473 LARGE_INTEGER dlibMove,
2474 DWORD dwOrigin,
2475 ULARGE_INTEGER *plibNewPosition)
2477 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2478 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2481 HRESULT CALLBACK IStream_CopyTo_Proxy(
2482 IStream* This,
2483 IStream *pstm,
2484 ULARGE_INTEGER cb,
2485 ULARGE_INTEGER *pcbRead,
2486 ULARGE_INTEGER *pcbWritten)
2488 ULARGE_INTEGER read, written;
2489 HRESULT hr;
2491 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2493 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2494 if(pcbRead) *pcbRead = read;
2495 if(pcbWritten) *pcbWritten = written;
2497 return hr;
2500 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2501 IStream* This,
2502 IStream *pstm,
2503 ULARGE_INTEGER cb,
2504 ULARGE_INTEGER *pcbRead,
2505 ULARGE_INTEGER *pcbWritten)
2507 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2509 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2512 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2513 IEnumSTATSTG* This,
2514 ULONG celt,
2515 STATSTG *rgelt,
2516 ULONG *pceltFetched)
2518 ULONG fetched;
2519 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2520 if (!pceltFetched) pceltFetched = &fetched;
2521 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2524 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2525 IEnumSTATSTG* This,
2526 ULONG celt,
2527 STATSTG *rgelt,
2528 ULONG *pceltFetched)
2530 HRESULT hr;
2531 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2532 *pceltFetched = 0;
2533 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2534 if (hr == S_OK) *pceltFetched = celt;
2535 return hr;
2538 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2539 IStorage* This,
2540 LPCOLESTR pwcsName,
2541 void *reserved1,
2542 DWORD grfMode,
2543 DWORD reserved2,
2544 IStream **ppstm)
2546 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2547 if(reserved1) WARN("reserved1 %p\n", reserved1);
2549 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2552 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2553 IStorage* This,
2554 LPCOLESTR pwcsName,
2555 ULONG cbReserved1,
2556 byte *reserved1,
2557 DWORD grfMode,
2558 DWORD reserved2,
2559 IStream **ppstm)
2561 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2562 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2564 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2567 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2568 IStorage* This,
2569 DWORD reserved1,
2570 void *reserved2,
2571 DWORD reserved3,
2572 IEnumSTATSTG **ppenum)
2574 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2575 if(reserved2) WARN("reserved2 %p\n", reserved2);
2577 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2580 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2581 IStorage* This,
2582 DWORD reserved1,
2583 ULONG cbReserved2,
2584 byte *reserved2,
2585 DWORD reserved3,
2586 IEnumSTATSTG **ppenum)
2588 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2589 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2591 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2594 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2595 ILockBytes* This,
2596 ULARGE_INTEGER ulOffset,
2597 void *pv,
2598 ULONG cb,
2599 ULONG *pcbRead)
2601 ULONG read;
2602 HRESULT hr;
2604 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2606 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2607 if(pcbRead) *pcbRead = read;
2609 return hr;
2612 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2613 ILockBytes* This,
2614 ULARGE_INTEGER ulOffset,
2615 byte *pv,
2616 ULONG cb,
2617 ULONG *pcbRead)
2619 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2620 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2623 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2624 ILockBytes* This,
2625 ULARGE_INTEGER ulOffset,
2626 const void *pv,
2627 ULONG cb,
2628 ULONG *pcbWritten)
2630 ULONG written;
2631 HRESULT hr;
2633 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2635 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2636 if(pcbWritten) *pcbWritten = written;
2638 return hr;
2641 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2642 ILockBytes* This,
2643 ULARGE_INTEGER ulOffset,
2644 const byte *pv,
2645 ULONG cb,
2646 ULONG *pcbWritten)
2648 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2649 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2652 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2653 IFillLockBytes* This,
2654 const void *pv,
2655 ULONG cb,
2656 ULONG *pcbWritten)
2658 ULONG written;
2659 HRESULT hr;
2661 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2663 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2664 if(pcbWritten) *pcbWritten = written;
2666 return hr;
2669 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2670 IFillLockBytes* This,
2671 const byte *pv,
2672 ULONG cb,
2673 ULONG *pcbWritten)
2675 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2676 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2679 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2680 IFillLockBytes* This,
2681 ULARGE_INTEGER ulOffset,
2682 const void *pv,
2683 ULONG cb,
2684 ULONG *pcbWritten)
2686 ULONG written;
2687 HRESULT hr;
2689 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2691 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2692 if(pcbWritten) *pcbWritten = written;
2694 return hr;
2697 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2698 IFillLockBytes* This,
2699 ULARGE_INTEGER ulOffset,
2700 const byte *pv,
2701 ULONG cb,
2702 ULONG *pcbWritten)
2704 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2705 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2708 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2709 IEnumFORMATETC* This,
2710 ULONG celt,
2711 FORMATETC *rgelt,
2712 ULONG *pceltFetched)
2714 ULONG fetched;
2715 if (!pceltFetched) pceltFetched = &fetched;
2716 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2719 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2720 IEnumFORMATETC* This,
2721 ULONG celt,
2722 FORMATETC *rgelt,
2723 ULONG *pceltFetched)
2725 HRESULT hr;
2726 *pceltFetched = 0;
2727 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2728 if (hr == S_OK) *pceltFetched = celt;
2729 return hr;
2732 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2733 IEnumSTATDATA* This,
2734 ULONG celt,
2735 STATDATA *rgelt,
2736 ULONG *pceltFetched)
2738 ULONG fetched;
2739 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2740 if (!pceltFetched) pceltFetched = &fetched;
2741 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2744 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2745 IEnumSTATDATA* This,
2746 ULONG celt,
2747 STATDATA *rgelt,
2748 ULONG *pceltFetched)
2750 HRESULT hr;
2751 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2752 *pceltFetched = 0;
2753 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2754 if (hr == S_OK) *pceltFetched = celt;
2755 return hr;
2758 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2759 IAdviseSink* This,
2760 FORMATETC *pFormatetc,
2761 STGMEDIUM *pStgmed)
2763 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2764 IAdviseSink_RemoteOnDataChange_Proxy(This, pFormatetc, pStgmed);
2767 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2768 IAdviseSink* This,
2769 FORMATETC *pFormatetc,
2770 ASYNC_STGMEDIUM *pStgmed)
2772 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2773 IAdviseSink_OnDataChange(This, pFormatetc, pStgmed);
2774 return S_OK;
2777 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2778 IAdviseSink* This,
2779 DWORD dwAspect,
2780 LONG lindex)
2782 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2783 IAdviseSink_RemoteOnViewChange_Proxy(This, dwAspect, lindex);
2786 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2787 IAdviseSink* This,
2788 DWORD dwAspect,
2789 LONG lindex)
2791 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2792 IAdviseSink_OnViewChange(This, dwAspect, lindex);
2793 return S_OK;
2796 void CALLBACK IAdviseSink_OnRename_Proxy(
2797 IAdviseSink* This,
2798 IMoniker *pmk)
2800 TRACE("(%p)->(%p)\n", This, pmk);
2801 IAdviseSink_RemoteOnRename_Proxy(This, pmk);
2804 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2805 IAdviseSink* This,
2806 IMoniker *pmk)
2808 TRACE("(%p)->(%p)\n", This, pmk);
2809 IAdviseSink_OnRename(This, pmk);
2810 return S_OK;
2813 void CALLBACK IAdviseSink_OnSave_Proxy(
2814 IAdviseSink* This)
2816 TRACE("(%p)\n", This);
2817 IAdviseSink_RemoteOnSave_Proxy(This);
2820 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2821 IAdviseSink* This)
2823 TRACE("(%p)\n", This);
2824 IAdviseSink_OnSave(This);
2825 return S_OK;
2828 void CALLBACK IAdviseSink_OnClose_Proxy(
2829 IAdviseSink* This)
2831 TRACE("(%p)\n", This);
2832 IAdviseSink_RemoteOnClose_Proxy(This);
2835 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2836 IAdviseSink* This)
2838 TRACE("(%p)\n", This);
2839 IAdviseSink_OnClose(This);
2840 return S_OK;
2843 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2844 IAdviseSink2* This,
2845 IMoniker *pmk)
2847 TRACE("(%p)->(%p)\n", This, pmk);
2848 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This, pmk);
2851 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2852 IAdviseSink2* This,
2853 IMoniker *pmk)
2855 TRACE("(%p)->(%p)\n", This, pmk);
2856 IAdviseSink2_OnLinkSrcChange(This, pmk);
2857 return S_OK;
2860 HRESULT CALLBACK IDataObject_GetData_Proxy(
2861 IDataObject* This,
2862 FORMATETC *pformatetcIn,
2863 STGMEDIUM *pmedium)
2865 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2866 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2869 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2870 IDataObject* This,
2871 FORMATETC *pformatetcIn,
2872 STGMEDIUM *pRemoteMedium)
2874 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2875 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2878 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2879 IDataObject* This,
2880 FORMATETC *pformatetc,
2881 STGMEDIUM *pmedium)
2883 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2884 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2887 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2888 IDataObject* This,
2889 FORMATETC *pformatetc,
2890 STGMEDIUM *pRemoteMedium)
2892 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2893 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2896 HRESULT CALLBACK IDataObject_SetData_Proxy(
2897 IDataObject* This,
2898 FORMATETC *pformatetc,
2899 STGMEDIUM *pmedium,
2900 BOOL fRelease)
2902 FIXME(":stub\n");
2903 return E_NOTIMPL;
2906 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2907 IDataObject* This,
2908 FORMATETC *pformatetc,
2909 FLAG_STGMEDIUM *pmedium,
2910 BOOL fRelease)
2912 FIXME(":stub\n");
2913 return E_NOTIMPL;
2916 /* call_as/local stubs for oleidl.idl */
2918 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2919 IOleInPlaceActiveObject* This,
2920 LPMSG lpmsg)
2922 FIXME(":stub\n");
2923 return E_NOTIMPL;
2926 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2927 IOleInPlaceActiveObject* This)
2929 FIXME(":stub\n");
2930 return E_NOTIMPL;
2933 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2934 IOleInPlaceActiveObject* This,
2935 LPCRECT prcBorder,
2936 IOleInPlaceUIWindow *pUIWindow,
2937 BOOL fFrameWindow)
2939 FIXME(":stub\n");
2940 return E_NOTIMPL;
2943 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2944 IOleInPlaceActiveObject* This,
2945 LPCRECT prcBorder,
2946 REFIID riid,
2947 IOleInPlaceUIWindow *pUIWindow,
2948 BOOL fFrameWindow)
2950 FIXME(":stub\n");
2951 return E_NOTIMPL;
2954 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2955 IOleCache2* This,
2956 LPDATAOBJECT pDataObject,
2957 DWORD grfUpdf,
2958 LPVOID pReserved)
2960 FIXME(":stub\n");
2961 return E_NOTIMPL;
2964 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2965 IOleCache2* This,
2966 LPDATAOBJECT pDataObject,
2967 DWORD grfUpdf,
2968 LONG_PTR pReserved)
2970 FIXME(":stub\n");
2971 return E_NOTIMPL;
2974 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2975 IEnumOLEVERB* This,
2976 ULONG celt,
2977 LPOLEVERB rgelt,
2978 ULONG *pceltFetched)
2980 ULONG fetched;
2981 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2982 if (!pceltFetched) pceltFetched = &fetched;
2983 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2986 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2987 IEnumOLEVERB* This,
2988 ULONG celt,
2989 LPOLEVERB rgelt,
2990 ULONG *pceltFetched)
2992 HRESULT hr;
2993 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2994 *pceltFetched = 0;
2995 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2996 if (hr == S_OK) *pceltFetched = celt;
2997 return hr;
3000 HRESULT CALLBACK IViewObject_Draw_Proxy(
3001 IViewObject* This,
3002 DWORD dwDrawAspect,
3003 LONG lindex,
3004 void *pvAspect,
3005 DVTARGETDEVICE *ptd,
3006 HDC hdcTargetDev,
3007 HDC hdcDraw,
3008 LPCRECTL lprcBounds,
3009 LPCRECTL lprcWBounds,
3010 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
3011 ULONG_PTR dwContinue)
3013 FIXME(":stub\n");
3014 return E_NOTIMPL;
3017 HRESULT __RPC_STUB IViewObject_Draw_Stub(
3018 IViewObject* This,
3019 DWORD dwDrawAspect,
3020 LONG lindex,
3021 ULONG_PTR pvAspect,
3022 DVTARGETDEVICE *ptd,
3023 ULONG_PTR hdcTargetDev,
3024 ULONG_PTR hdcDraw,
3025 LPCRECTL lprcBounds,
3026 LPCRECTL lprcWBounds,
3027 IContinue *pContinue)
3029 FIXME(":stub\n");
3030 return E_NOTIMPL;
3033 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3034 IViewObject* This,
3035 DWORD dwDrawAspect,
3036 LONG lindex,
3037 void *pvAspect,
3038 DVTARGETDEVICE *ptd,
3039 HDC hicTargetDev,
3040 LOGPALETTE **ppColorSet)
3042 FIXME(":stub\n");
3043 return E_NOTIMPL;
3046 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3047 IViewObject* This,
3048 DWORD dwDrawAspect,
3049 LONG lindex,
3050 ULONG_PTR pvAspect,
3051 DVTARGETDEVICE *ptd,
3052 ULONG_PTR hicTargetDev,
3053 LOGPALETTE **ppColorSet)
3055 FIXME(":stub\n");
3056 return E_NOTIMPL;
3059 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3060 IViewObject* This,
3061 DWORD dwDrawAspect,
3062 LONG lindex,
3063 void *pvAspect,
3064 DWORD *pdwFreeze)
3066 FIXME(":stub\n");
3067 return E_NOTIMPL;
3070 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3071 IViewObject* This,
3072 DWORD dwDrawAspect,
3073 LONG lindex,
3074 ULONG_PTR pvAspect,
3075 DWORD *pdwFreeze)
3077 FIXME(":stub\n");
3078 return E_NOTIMPL;
3081 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3082 IViewObject* This,
3083 DWORD *pAspects,
3084 DWORD *pAdvf,
3085 IAdviseSink **ppAdvSink)
3087 FIXME(":stub\n");
3088 return E_NOTIMPL;
3091 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3092 IViewObject* This,
3093 DWORD *pAspects,
3094 DWORD *pAdvf,
3095 IAdviseSink **ppAdvSink)
3097 FIXME(":stub\n");
3098 return E_NOTIMPL;