riched20: Implement IsEqual() for ranges.
[wine.git] / dlls / ole32 / usrmarshal.c
blob7875bef0a106f0c0fbb35a1a1d6236bd2ce3752c
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 ULONG size = StartingSize;
2165 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pSnb);
2167 ALIGN_LENGTH(size, 3);
2169 /* two counters from RemSNB header, plus one more ULONG */
2170 size += 3*sizeof(ULONG);
2172 /* now actual data length */
2173 if (*pSnb)
2175 WCHAR **ptrW = *pSnb;
2177 while (*ptrW)
2179 size += (strlenW(*ptrW) + 1)*sizeof(WCHAR);
2180 ptrW++;
2184 return size;
2187 struct SNB_wire {
2188 ULONG charcnt;
2189 ULONG strcnt;
2190 ULONG datalen;
2191 WCHAR data[1];
2194 unsigned char * __RPC_USER SNB_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2196 struct SNB_wire *wire;
2197 ULONG size;
2199 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2201 ALIGN_POINTER(pBuffer, 3);
2203 wire = (struct SNB_wire*)pBuffer;
2204 wire->charcnt = wire->strcnt = 0;
2205 size = 3*sizeof(ULONG);
2207 if (*pSnb)
2209 WCHAR **ptrW = *pSnb;
2210 WCHAR *dataW = wire->data;
2212 while (*ptrW)
2214 ULONG len = strlenW(*ptrW) + 1;
2216 wire->strcnt++;
2217 wire->charcnt += len;
2218 memcpy(dataW, *ptrW, len*sizeof(WCHAR));
2219 dataW += len;
2221 size += len*sizeof(WCHAR);
2222 ptrW++;
2226 wire->datalen = wire->charcnt;
2227 return pBuffer + size;
2230 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2232 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2233 struct SNB_wire *wire;
2235 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2237 wire = (struct SNB_wire*)pBuffer;
2239 if (*pSnb)
2240 umcb->pStubMsg->pfnFree(*pSnb);
2242 if (wire->datalen == 0)
2243 *pSnb = NULL;
2244 else
2246 WCHAR *src = wire->data, *dest;
2247 WCHAR **ptrW;
2248 ULONG i;
2250 ptrW = *pSnb = umcb->pStubMsg->pfnAllocate((wire->strcnt+1)*sizeof(WCHAR*) + wire->datalen);
2251 dest = (WCHAR*)(*pSnb + wire->strcnt + 1);
2253 for (i = 0; i < wire->strcnt; i++)
2255 ULONG len = strlenW(src);
2256 memcpy(dest, src, (len + 1)*sizeof(WCHAR));
2257 *ptrW = dest;
2258 src += len + 1;
2259 dest += len + 1;
2260 ptrW++;
2262 *ptrW = NULL;
2265 return pBuffer + 3*sizeof(ULONG) + wire->datalen*sizeof(WCHAR);
2268 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2270 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2271 TRACE("(%p)\n", pSnb);
2272 if (*pSnb)
2273 umcb->pStubMsg->pfnFree(*pSnb);
2276 /* call_as/local stubs for unknwn.idl */
2278 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2279 IClassFactory* This,
2280 IUnknown *pUnkOuter,
2281 REFIID riid,
2282 void **ppvObject)
2284 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2285 *ppvObject = NULL;
2286 if (pUnkOuter)
2288 ERR("aggregation is not allowed on remote objects\n");
2289 return CLASS_E_NOAGGREGATION;
2291 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2292 (IUnknown **) ppvObject);
2295 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2296 IClassFactory* This,
2297 REFIID riid,
2298 IUnknown **ppvObject)
2300 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2301 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2304 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2305 IClassFactory* This,
2306 BOOL fLock)
2308 FIXME(":stub\n");
2309 return E_NOTIMPL;
2312 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2313 IClassFactory* This,
2314 BOOL fLock)
2316 FIXME(":stub\n");
2317 return E_NOTIMPL;
2320 /* call_as/local stubs for objidl.idl */
2322 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2323 IEnumUnknown* This,
2324 ULONG celt,
2325 IUnknown **rgelt,
2326 ULONG *pceltFetched)
2328 ULONG fetched;
2329 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2330 if (!pceltFetched) pceltFetched = &fetched;
2331 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2334 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2335 IEnumUnknown* This,
2336 ULONG celt,
2337 IUnknown **rgelt,
2338 ULONG *pceltFetched)
2340 HRESULT hr;
2341 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2342 *pceltFetched = 0;
2343 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2344 if (hr == S_OK) *pceltFetched = celt;
2345 return hr;
2348 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2349 IBindCtx* This,
2350 BIND_OPTS *pbindopts)
2352 FIXME(":stub\n");
2353 return E_NOTIMPL;
2356 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2357 IBindCtx* This,
2358 BIND_OPTS2 *pbindopts)
2360 FIXME(":stub\n");
2361 return E_NOTIMPL;
2364 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2365 IBindCtx* This,
2366 BIND_OPTS *pbindopts)
2368 FIXME(":stub\n");
2369 return E_NOTIMPL;
2372 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2373 IBindCtx* This,
2374 BIND_OPTS2 *pbindopts)
2376 FIXME(":stub\n");
2377 return E_NOTIMPL;
2380 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2381 IEnumMoniker* This,
2382 ULONG celt,
2383 IMoniker **rgelt,
2384 ULONG *pceltFetched)
2386 ULONG fetched;
2387 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2388 if (!pceltFetched) pceltFetched = &fetched;
2389 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2392 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2393 IEnumMoniker* This,
2394 ULONG celt,
2395 IMoniker **rgelt,
2396 ULONG *pceltFetched)
2398 HRESULT hr;
2399 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2400 *pceltFetched = 0;
2401 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2402 if (hr == S_OK) *pceltFetched = celt;
2403 return hr;
2406 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2407 IRunnableObject* This)
2409 BOOL rv;
2410 FIXME(":stub\n");
2411 memset(&rv, 0, sizeof rv);
2412 return rv;
2415 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2416 IRunnableObject* This)
2418 FIXME(":stub\n");
2419 return E_NOTIMPL;
2422 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2423 IMoniker* This,
2424 IBindCtx *pbc,
2425 IMoniker *pmkToLeft,
2426 REFIID riidResult,
2427 void **ppvResult)
2429 FIXME(":stub\n");
2430 return E_NOTIMPL;
2433 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2434 IMoniker* This,
2435 IBindCtx *pbc,
2436 IMoniker *pmkToLeft,
2437 REFIID riidResult,
2438 IUnknown **ppvResult)
2440 FIXME(":stub\n");
2441 return E_NOTIMPL;
2444 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2445 IMoniker* This,
2446 IBindCtx *pbc,
2447 IMoniker *pmkToLeft,
2448 REFIID riid,
2449 void **ppvObj)
2451 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2452 return IMoniker_RemoteBindToStorage_Proxy(This, pbc, pmkToLeft, riid, (IUnknown**)ppvObj);
2455 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2456 IMoniker* This,
2457 IBindCtx *pbc,
2458 IMoniker *pmkToLeft,
2459 REFIID riid,
2460 IUnknown **ppvObj)
2462 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2463 return IMoniker_BindToStorage(This, pbc, pmkToLeft, riid, (void**)ppvObj);
2466 HRESULT CALLBACK IEnumString_Next_Proxy(
2467 IEnumString* This,
2468 ULONG celt,
2469 LPOLESTR *rgelt,
2470 ULONG *pceltFetched)
2472 ULONG fetched;
2473 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2474 if (!pceltFetched) pceltFetched = &fetched;
2475 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2478 HRESULT __RPC_STUB IEnumString_Next_Stub(
2479 IEnumString* This,
2480 ULONG celt,
2481 LPOLESTR *rgelt,
2482 ULONG *pceltFetched)
2484 HRESULT hr;
2485 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2486 *pceltFetched = 0;
2487 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2488 if (hr == S_OK) *pceltFetched = celt;
2489 return hr;
2492 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2493 ISequentialStream* This,
2494 void *pv,
2495 ULONG cb,
2496 ULONG *pcbRead)
2498 ULONG read;
2499 HRESULT hr;
2501 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2503 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2504 if(pcbRead) *pcbRead = read;
2506 return hr;
2509 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2510 ISequentialStream* This,
2511 byte *pv,
2512 ULONG cb,
2513 ULONG *pcbRead)
2515 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2516 return ISequentialStream_Read(This, pv, cb, pcbRead);
2519 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2520 ISequentialStream* This,
2521 const void *pv,
2522 ULONG cb,
2523 ULONG *pcbWritten)
2525 ULONG written;
2526 HRESULT hr;
2528 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2530 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2531 if(pcbWritten) *pcbWritten = written;
2533 return hr;
2536 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2537 ISequentialStream* This,
2538 const byte *pv,
2539 ULONG cb,
2540 ULONG *pcbWritten)
2542 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2543 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2546 HRESULT CALLBACK IStream_Seek_Proxy(
2547 IStream* This,
2548 LARGE_INTEGER dlibMove,
2549 DWORD dwOrigin,
2550 ULARGE_INTEGER *plibNewPosition)
2552 ULARGE_INTEGER newpos;
2553 HRESULT hr;
2555 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2557 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2558 if(plibNewPosition) *plibNewPosition = newpos;
2560 return hr;
2563 HRESULT __RPC_STUB IStream_Seek_Stub(
2564 IStream* This,
2565 LARGE_INTEGER dlibMove,
2566 DWORD dwOrigin,
2567 ULARGE_INTEGER *plibNewPosition)
2569 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2570 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2573 HRESULT CALLBACK IStream_CopyTo_Proxy(
2574 IStream* This,
2575 IStream *pstm,
2576 ULARGE_INTEGER cb,
2577 ULARGE_INTEGER *pcbRead,
2578 ULARGE_INTEGER *pcbWritten)
2580 ULARGE_INTEGER read, written;
2581 HRESULT hr;
2583 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2585 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2586 if(pcbRead) *pcbRead = read;
2587 if(pcbWritten) *pcbWritten = written;
2589 return hr;
2592 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2593 IStream* This,
2594 IStream *pstm,
2595 ULARGE_INTEGER cb,
2596 ULARGE_INTEGER *pcbRead,
2597 ULARGE_INTEGER *pcbWritten)
2599 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2601 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2604 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2605 IEnumSTATSTG* This,
2606 ULONG celt,
2607 STATSTG *rgelt,
2608 ULONG *pceltFetched)
2610 ULONG fetched;
2611 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2612 if (!pceltFetched) pceltFetched = &fetched;
2613 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2616 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2617 IEnumSTATSTG* This,
2618 ULONG celt,
2619 STATSTG *rgelt,
2620 ULONG *pceltFetched)
2622 HRESULT hr;
2623 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2624 *pceltFetched = 0;
2625 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2626 if (hr == S_OK) *pceltFetched = celt;
2627 return hr;
2630 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2631 IStorage* This,
2632 LPCOLESTR pwcsName,
2633 void *reserved1,
2634 DWORD grfMode,
2635 DWORD reserved2,
2636 IStream **ppstm)
2638 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2639 if(reserved1) WARN("reserved1 %p\n", reserved1);
2641 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2644 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2645 IStorage* This,
2646 LPCOLESTR pwcsName,
2647 ULONG cbReserved1,
2648 byte *reserved1,
2649 DWORD grfMode,
2650 DWORD reserved2,
2651 IStream **ppstm)
2653 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2654 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2656 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2659 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2660 IStorage* This,
2661 DWORD reserved1,
2662 void *reserved2,
2663 DWORD reserved3,
2664 IEnumSTATSTG **ppenum)
2666 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2667 if(reserved2) WARN("reserved2 %p\n", reserved2);
2669 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2672 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2673 IStorage* This,
2674 DWORD reserved1,
2675 ULONG cbReserved2,
2676 byte *reserved2,
2677 DWORD reserved3,
2678 IEnumSTATSTG **ppenum)
2680 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2681 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2683 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2686 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2687 ILockBytes* This,
2688 ULARGE_INTEGER ulOffset,
2689 void *pv,
2690 ULONG cb,
2691 ULONG *pcbRead)
2693 ULONG read;
2694 HRESULT hr;
2696 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2698 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2699 if(pcbRead) *pcbRead = read;
2701 return hr;
2704 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2705 ILockBytes* This,
2706 ULARGE_INTEGER ulOffset,
2707 byte *pv,
2708 ULONG cb,
2709 ULONG *pcbRead)
2711 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2712 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2715 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2716 ILockBytes* This,
2717 ULARGE_INTEGER ulOffset,
2718 const void *pv,
2719 ULONG cb,
2720 ULONG *pcbWritten)
2722 ULONG written;
2723 HRESULT hr;
2725 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2727 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2728 if(pcbWritten) *pcbWritten = written;
2730 return hr;
2733 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2734 ILockBytes* This,
2735 ULARGE_INTEGER ulOffset,
2736 const byte *pv,
2737 ULONG cb,
2738 ULONG *pcbWritten)
2740 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2741 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2744 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2745 IFillLockBytes* This,
2746 const void *pv,
2747 ULONG cb,
2748 ULONG *pcbWritten)
2750 ULONG written;
2751 HRESULT hr;
2753 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2755 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2756 if(pcbWritten) *pcbWritten = written;
2758 return hr;
2761 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2762 IFillLockBytes* This,
2763 const byte *pv,
2764 ULONG cb,
2765 ULONG *pcbWritten)
2767 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2768 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2771 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2772 IFillLockBytes* This,
2773 ULARGE_INTEGER ulOffset,
2774 const void *pv,
2775 ULONG cb,
2776 ULONG *pcbWritten)
2778 ULONG written;
2779 HRESULT hr;
2781 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2783 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2784 if(pcbWritten) *pcbWritten = written;
2786 return hr;
2789 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2790 IFillLockBytes* This,
2791 ULARGE_INTEGER ulOffset,
2792 const byte *pv,
2793 ULONG cb,
2794 ULONG *pcbWritten)
2796 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2797 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2800 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2801 IEnumFORMATETC* This,
2802 ULONG celt,
2803 FORMATETC *rgelt,
2804 ULONG *pceltFetched)
2806 ULONG fetched;
2807 if (!pceltFetched) pceltFetched = &fetched;
2808 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2811 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2812 IEnumFORMATETC* This,
2813 ULONG celt,
2814 FORMATETC *rgelt,
2815 ULONG *pceltFetched)
2817 HRESULT hr;
2818 *pceltFetched = 0;
2819 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2820 if (hr == S_OK) *pceltFetched = celt;
2821 return hr;
2824 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2825 IEnumSTATDATA* This,
2826 ULONG celt,
2827 STATDATA *rgelt,
2828 ULONG *pceltFetched)
2830 ULONG fetched;
2831 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2832 if (!pceltFetched) pceltFetched = &fetched;
2833 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2836 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2837 IEnumSTATDATA* This,
2838 ULONG celt,
2839 STATDATA *rgelt,
2840 ULONG *pceltFetched)
2842 HRESULT hr;
2843 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2844 *pceltFetched = 0;
2845 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2846 if (hr == S_OK) *pceltFetched = celt;
2847 return hr;
2850 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2851 IAdviseSink* This,
2852 FORMATETC *pFormatetc,
2853 STGMEDIUM *pStgmed)
2855 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2856 IAdviseSink_RemoteOnDataChange_Proxy(This, pFormatetc, pStgmed);
2859 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2860 IAdviseSink* This,
2861 FORMATETC *pFormatetc,
2862 ASYNC_STGMEDIUM *pStgmed)
2864 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2865 IAdviseSink_OnDataChange(This, pFormatetc, pStgmed);
2866 return S_OK;
2869 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2870 IAdviseSink* This,
2871 DWORD dwAspect,
2872 LONG lindex)
2874 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2875 IAdviseSink_RemoteOnViewChange_Proxy(This, dwAspect, lindex);
2878 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2879 IAdviseSink* This,
2880 DWORD dwAspect,
2881 LONG lindex)
2883 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2884 IAdviseSink_OnViewChange(This, dwAspect, lindex);
2885 return S_OK;
2888 void CALLBACK IAdviseSink_OnRename_Proxy(
2889 IAdviseSink* This,
2890 IMoniker *pmk)
2892 TRACE("(%p)->(%p)\n", This, pmk);
2893 IAdviseSink_RemoteOnRename_Proxy(This, pmk);
2896 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2897 IAdviseSink* This,
2898 IMoniker *pmk)
2900 TRACE("(%p)->(%p)\n", This, pmk);
2901 IAdviseSink_OnRename(This, pmk);
2902 return S_OK;
2905 void CALLBACK IAdviseSink_OnSave_Proxy(
2906 IAdviseSink* This)
2908 TRACE("(%p)\n", This);
2909 IAdviseSink_RemoteOnSave_Proxy(This);
2912 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2913 IAdviseSink* This)
2915 TRACE("(%p)\n", This);
2916 IAdviseSink_OnSave(This);
2917 return S_OK;
2920 void CALLBACK IAdviseSink_OnClose_Proxy(
2921 IAdviseSink* This)
2923 TRACE("(%p)\n", This);
2924 IAdviseSink_RemoteOnClose_Proxy(This);
2927 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2928 IAdviseSink* This)
2930 TRACE("(%p)\n", This);
2931 IAdviseSink_OnClose(This);
2932 return S_OK;
2935 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2936 IAdviseSink2* This,
2937 IMoniker *pmk)
2939 TRACE("(%p)->(%p)\n", This, pmk);
2940 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This, pmk);
2943 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2944 IAdviseSink2* This,
2945 IMoniker *pmk)
2947 TRACE("(%p)->(%p)\n", This, pmk);
2948 IAdviseSink2_OnLinkSrcChange(This, pmk);
2949 return S_OK;
2952 HRESULT CALLBACK IDataObject_GetData_Proxy(
2953 IDataObject* This,
2954 FORMATETC *pformatetcIn,
2955 STGMEDIUM *pmedium)
2957 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2958 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2961 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2962 IDataObject* This,
2963 FORMATETC *pformatetcIn,
2964 STGMEDIUM *pRemoteMedium)
2966 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2967 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2970 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2971 IDataObject* This,
2972 FORMATETC *pformatetc,
2973 STGMEDIUM *pmedium)
2975 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2976 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2979 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2980 IDataObject* This,
2981 FORMATETC *pformatetc,
2982 STGMEDIUM *pRemoteMedium)
2984 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2985 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2988 HRESULT CALLBACK IDataObject_SetData_Proxy(
2989 IDataObject* This,
2990 FORMATETC *pformatetc,
2991 STGMEDIUM *pmedium,
2992 BOOL fRelease)
2994 FIXME(":stub\n");
2995 return E_NOTIMPL;
2998 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2999 IDataObject* This,
3000 FORMATETC *pformatetc,
3001 FLAG_STGMEDIUM *pmedium,
3002 BOOL fRelease)
3004 FIXME(":stub\n");
3005 return E_NOTIMPL;
3008 /* call_as/local stubs for oleidl.idl */
3010 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
3011 IOleInPlaceActiveObject* This,
3012 LPMSG lpmsg)
3014 FIXME(":stub\n");
3015 return E_NOTIMPL;
3018 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
3019 IOleInPlaceActiveObject* This)
3021 FIXME(":stub\n");
3022 return E_NOTIMPL;
3025 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
3026 IOleInPlaceActiveObject* This,
3027 LPCRECT prcBorder,
3028 IOleInPlaceUIWindow *pUIWindow,
3029 BOOL fFrameWindow)
3031 FIXME(":stub\n");
3032 return E_NOTIMPL;
3035 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
3036 IOleInPlaceActiveObject* This,
3037 LPCRECT prcBorder,
3038 REFIID riid,
3039 IOleInPlaceUIWindow *pUIWindow,
3040 BOOL fFrameWindow)
3042 FIXME(":stub\n");
3043 return E_NOTIMPL;
3046 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
3047 IOleCache2* This,
3048 LPDATAOBJECT pDataObject,
3049 DWORD grfUpdf,
3050 LPVOID pReserved)
3052 FIXME(":stub\n");
3053 return E_NOTIMPL;
3056 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
3057 IOleCache2* This,
3058 LPDATAOBJECT pDataObject,
3059 DWORD grfUpdf,
3060 LONG_PTR pReserved)
3062 FIXME(":stub\n");
3063 return E_NOTIMPL;
3066 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
3067 IEnumOLEVERB* This,
3068 ULONG celt,
3069 LPOLEVERB rgelt,
3070 ULONG *pceltFetched)
3072 ULONG fetched;
3073 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
3074 if (!pceltFetched) pceltFetched = &fetched;
3075 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
3078 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
3079 IEnumOLEVERB* This,
3080 ULONG celt,
3081 LPOLEVERB rgelt,
3082 ULONG *pceltFetched)
3084 HRESULT hr;
3085 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
3086 *pceltFetched = 0;
3087 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
3088 if (hr == S_OK) *pceltFetched = celt;
3089 return hr;
3092 HRESULT CALLBACK IViewObject_Draw_Proxy(
3093 IViewObject* This,
3094 DWORD dwDrawAspect,
3095 LONG lindex,
3096 void *pvAspect,
3097 DVTARGETDEVICE *ptd,
3098 HDC hdcTargetDev,
3099 HDC hdcDraw,
3100 LPCRECTL lprcBounds,
3101 LPCRECTL lprcWBounds,
3102 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
3103 ULONG_PTR dwContinue)
3105 FIXME(":stub\n");
3106 return E_NOTIMPL;
3109 HRESULT __RPC_STUB IViewObject_Draw_Stub(
3110 IViewObject* This,
3111 DWORD dwDrawAspect,
3112 LONG lindex,
3113 ULONG_PTR pvAspect,
3114 DVTARGETDEVICE *ptd,
3115 ULONG_PTR hdcTargetDev,
3116 ULONG_PTR hdcDraw,
3117 LPCRECTL lprcBounds,
3118 LPCRECTL lprcWBounds,
3119 IContinue *pContinue)
3121 FIXME(":stub\n");
3122 return E_NOTIMPL;
3125 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3126 IViewObject* This,
3127 DWORD dwDrawAspect,
3128 LONG lindex,
3129 void *pvAspect,
3130 DVTARGETDEVICE *ptd,
3131 HDC hicTargetDev,
3132 LOGPALETTE **ppColorSet)
3134 FIXME(":stub\n");
3135 return E_NOTIMPL;
3138 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3139 IViewObject* This,
3140 DWORD dwDrawAspect,
3141 LONG lindex,
3142 ULONG_PTR pvAspect,
3143 DVTARGETDEVICE *ptd,
3144 ULONG_PTR hicTargetDev,
3145 LOGPALETTE **ppColorSet)
3147 FIXME(":stub\n");
3148 return E_NOTIMPL;
3151 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3152 IViewObject* This,
3153 DWORD dwDrawAspect,
3154 LONG lindex,
3155 void *pvAspect,
3156 DWORD *pdwFreeze)
3158 FIXME(":stub\n");
3159 return E_NOTIMPL;
3162 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3163 IViewObject* This,
3164 DWORD dwDrawAspect,
3165 LONG lindex,
3166 ULONG_PTR pvAspect,
3167 DWORD *pdwFreeze)
3169 FIXME(":stub\n");
3170 return E_NOTIMPL;
3173 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3174 IViewObject* This,
3175 DWORD *pAspects,
3176 DWORD *pAdvf,
3177 IAdviseSink **ppAdvSink)
3179 FIXME(":stub\n");
3180 return E_NOTIMPL;
3183 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3184 IViewObject* This,
3185 DWORD *pAspects,
3186 DWORD *pAdvf,
3187 IAdviseSink **ppAdvSink)
3189 FIXME(":stub\n");
3190 return E_NOTIMPL;