configure: Changes from running autconf after previous patch.
[wine/hacks.git] / dlls / ole32 / usrmarshal.c
blob2d238e6ccc3cd14c73a1c7020ca1009907d16da8
1 /*
2 * Miscellaneous Marshaling Routines
4 * Copyright 2005 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winerror.h"
35 #include "ole2.h"
36 #include "oleauto.h"
37 #include "rpcproxy.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
45 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
46 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
47 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
49 #define USER_MARSHAL_PTR_PREFIX \
50 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
51 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
53 static const char* debugstr_user_flags(ULONG *pFlags)
55 char buf[12];
56 const char* loword;
57 switch (LOWORD(*pFlags))
59 case MSHCTX_LOCAL:
60 loword="MSHCTX_LOCAL";
61 break;
62 case MSHCTX_NOSHAREDMEM:
63 loword="MSHCTX_NOSHAREDMEM";
64 break;
65 case MSHCTX_DIFFERENTMACHINE:
66 loword="MSHCTX_DIFFERENTMACHINE";
67 break;
68 case MSHCTX_INPROC:
69 loword="MSHCTX_INPROC";
70 break;
71 default:
72 sprintf(buf, "%d", LOWORD(*pFlags));
73 loword=buf;
76 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
77 return wine_dbg_sprintf("MAKELONG(NDR_LOCAL_REPRESENTATION, %s)", loword);
78 else
79 return wine_dbg_sprintf("MAKELONG(0x%04x, %s)", HIWORD(*pFlags), loword);
82 /******************************************************************************
83 * CLIPFORMAT_UserSize [OLE32.@]
85 * Calculates the buffer size required to marshal a clip format.
87 * PARAMS
88 * pFlags [I] Flags. See notes.
89 * StartingSize [I] Starting size of the buffer. This value is added on to
90 * the buffer size required for the clip format.
91 * pCF [I] Clip format to size.
93 * RETURNS
94 * The buffer size required to marshal a clip format plus the starting size.
96 * NOTES
97 * Even though the function is documented to take a pointer to an unsigned
98 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
99 * the first parameter is an unsigned long.
100 * This function is only intended to be called by the RPC runtime.
102 ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG StartingSize, CLIPFORMAT *pCF)
104 ULONG size = StartingSize;
106 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pCF);
108 size += 8;
110 /* only need to marshal the name if it is not a pre-defined type and
111 * we are going remote */
112 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
114 WCHAR format[255];
115 INT ret;
116 size += 3 * sizeof(UINT);
117 /* urg! this function is badly designed because it won't tell us how
118 * much space is needed without doing a dummy run of storing the
119 * name into a buffer */
120 ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
121 if (!ret)
122 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
123 size += (ret + 1) * sizeof(WCHAR);
125 return size;
128 /******************************************************************************
129 * CLIPFORMAT_UserMarshal [OLE32.@]
131 * Marshals a clip format into a buffer.
133 * PARAMS
134 * pFlags [I] Flags. See notes.
135 * pBuffer [I] Buffer to marshal the clip format into.
136 * pCF [I] Clip format to marshal.
138 * RETURNS
139 * The end of the marshaled data in the buffer.
141 * NOTES
142 * Even though the function is documented to take a pointer to an unsigned
143 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
144 * the first parameter is an unsigned long.
145 * This function is only intended to be called by the RPC runtime.
147 unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
149 TRACE("(%s, %p, &0x%04x\n", debugstr_user_flags(pFlags), pBuffer, *pCF);
151 /* only need to marshal the name if it is not a pre-defined type and
152 * we are going remote */
153 if ((*pCF >= 0xc000) && (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE))
155 WCHAR format[255];
156 UINT len;
158 *(DWORD *)pBuffer = WDT_REMOTE_CALL;
159 pBuffer += 4;
160 *(DWORD *)pBuffer = *pCF;
161 pBuffer += 4;
163 len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
164 if (!len)
165 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
166 len += 1;
167 *(UINT *)pBuffer = len;
168 pBuffer += sizeof(UINT);
169 *(UINT *)pBuffer = 0;
170 pBuffer += sizeof(UINT);
171 *(UINT *)pBuffer = len;
172 pBuffer += sizeof(UINT);
173 TRACE("marshaling format name %s\n", debugstr_w(format));
174 memcpy(pBuffer, format, len * sizeof(WCHAR));
175 pBuffer += len * sizeof(WCHAR);
177 else
179 *(DWORD *)pBuffer = WDT_INPROC_CALL;
180 pBuffer += 4;
181 *(DWORD *)pBuffer = *pCF;
182 pBuffer += 4;
185 return pBuffer;
188 /******************************************************************************
189 * CLIPFORMAT_UserUnmarshal [OLE32.@]
191 * Unmarshals a clip format from a buffer.
193 * PARAMS
194 * pFlags [I] Flags. See notes.
195 * pBuffer [I] Buffer to marshal the clip format from.
196 * pCF [O] Address that receive the unmarshaled clip format.
198 * RETURNS
199 * The end of the marshaled data in the buffer.
201 * NOTES
202 * Even though the function is documented to take a pointer to an unsigned
203 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
204 * the first parameter is an unsigned long.
205 * This function is only intended to be called by the RPC runtime.
207 unsigned char * __RPC_USER CLIPFORMAT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, CLIPFORMAT *pCF)
209 LONG fContext;
211 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pCF);
213 fContext = *(DWORD *)pBuffer;
214 pBuffer += 4;
216 if (fContext == WDT_INPROC_CALL)
218 *pCF = *(CLIPFORMAT *)pBuffer;
219 pBuffer += 4;
221 else if (fContext == WDT_REMOTE_CALL)
223 CLIPFORMAT cf;
224 UINT len;
226 /* pointer ID for registered clip format string */
227 if (*(DWORD *)pBuffer == 0)
228 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
229 pBuffer += 4;
231 len = *(UINT *)pBuffer;
232 pBuffer += sizeof(UINT);
233 if (*(UINT *)pBuffer != 0)
234 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
235 pBuffer += sizeof(UINT);
236 if (*(UINT *)pBuffer != len)
237 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
238 pBuffer += sizeof(UINT);
239 if (((WCHAR *)pBuffer)[len - 1] != '\0')
240 RaiseException(RPC_S_INVALID_BOUND, 0, 0, NULL);
241 TRACE("unmarshaling clip format %s\n", debugstr_w((LPCWSTR)pBuffer));
242 cf = RegisterClipboardFormatW((LPCWSTR)pBuffer);
243 pBuffer += len * sizeof(WCHAR);
244 if (!cf)
245 RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
246 *pCF = cf;
248 else
249 /* code not really appropriate, but nearest I can find */
250 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
251 return pBuffer;
254 /******************************************************************************
255 * CLIPFORMAT_UserFree [OLE32.@]
257 * Frees an unmarshaled clip format.
259 * PARAMS
260 * pFlags [I] Flags. See notes.
261 * pCF [I] Clip format to free.
263 * RETURNS
264 * The end of the marshaled data in the buffer.
266 * NOTES
267 * Even though the function is documented to take a pointer to an unsigned
268 * long in pFlags, it actually takes a pointer to a USER_MARSHAL_CB
269 * structure, of which the first parameter is an unsigned long.
270 * This function is only intended to be called by the RPC runtime.
272 void __RPC_USER CLIPFORMAT_UserFree(ULONG *pFlags, CLIPFORMAT *pCF)
274 /* there is no inverse of the RegisterClipboardFormat function,
275 * so nothing to do */
278 static ULONG handle_UserSize(ULONG *pFlags, ULONG StartingSize, HANDLE *handle)
280 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
282 ERR("can't remote a local handle\n");
283 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
284 return StartingSize;
286 return StartingSize + sizeof(RemotableHandle);
289 static unsigned char * handle_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
291 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
292 if (LOWORD(*pFlags) == MSHCTX_DIFFERENTMACHINE)
294 ERR("can't remote a local handle\n");
295 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
296 return pBuffer;
298 remhandle->fContext = WDT_INPROC_CALL;
299 remhandle->u.hInproc = (LONG_PTR)*handle;
300 return pBuffer + sizeof(RemotableHandle);
303 static unsigned char * handle_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HANDLE *handle)
305 RemotableHandle *remhandle = (RemotableHandle *)pBuffer;
306 if (remhandle->fContext != WDT_INPROC_CALL)
307 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
308 *handle = (HANDLE)(LONG_PTR)remhandle->u.hInproc;
309 return pBuffer + sizeof(RemotableHandle);
312 static void handle_UserFree(ULONG *pFlags, HANDLE *phMenu)
314 /* nothing to do */
317 #define IMPL_WIREM_HANDLE(type) \
318 ULONG __RPC_USER type##_UserSize(ULONG *pFlags, ULONG StartingSize, type *handle) \
320 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, handle); \
321 return handle_UserSize(pFlags, StartingSize, (HANDLE *)handle); \
324 unsigned char * __RPC_USER type##_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
326 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *handle); \
327 return handle_UserMarshal(pFlags, pBuffer, (HANDLE *)handle); \
330 unsigned char * __RPC_USER type##_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, type *handle) \
332 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, handle); \
333 return handle_UserUnmarshal(pFlags, pBuffer, (HANDLE *)handle); \
336 void __RPC_USER type##_UserFree(ULONG *pFlags, type *handle) \
338 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *handle); \
339 handle_UserFree(pFlags, (HANDLE *)handle); \
342 IMPL_WIREM_HANDLE(HACCEL)
343 IMPL_WIREM_HANDLE(HMENU)
344 IMPL_WIREM_HANDLE(HWND)
346 /******************************************************************************
347 * HGLOBAL_UserSize [OLE32.@]
349 * Calculates the buffer size required to marshal an HGLOBAL.
351 * PARAMS
352 * pFlags [I] Flags. See notes.
353 * StartingSize [I] Starting size of the buffer. This value is added on to
354 * the buffer size required for the clip format.
355 * phGlobal [I] HGLOBAL to size.
357 * RETURNS
358 * The buffer size required to marshal an HGLOBAL plus the starting size.
360 * NOTES
361 * Even though the function is documented to take a pointer to a ULONG in
362 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
363 * the first parameter is a ULONG.
364 * This function is only intended to be called by the RPC runtime.
366 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
368 ULONG size = StartingSize;
370 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
372 ALIGN_LENGTH(size, 3);
374 size += sizeof(ULONG);
376 if (LOWORD(*pFlags == MSHCTX_INPROC))
377 size += sizeof(HGLOBAL);
378 else
380 size += sizeof(ULONG);
381 if (*phGlobal)
383 SIZE_T ret;
384 size += 3 * sizeof(ULONG);
385 ret = GlobalSize(*phGlobal);
386 size += (ULONG)ret;
390 return size;
393 /******************************************************************************
394 * HGLOBAL_UserMarshal [OLE32.@]
396 * Marshals an HGLOBAL into a buffer.
398 * PARAMS
399 * pFlags [I] Flags. See notes.
400 * pBuffer [I] Buffer to marshal the clip format into.
401 * phGlobal [I] HGLOBAL to marshal.
403 * RETURNS
404 * The end of the marshaled data in the buffer.
406 * NOTES
407 * Even though the function is documented to take a pointer to a ULONG in
408 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
409 * the first parameter is a ULONG.
410 * This function is only intended to be called by the RPC runtime.
412 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
414 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
416 ALIGN_POINTER(pBuffer, 3);
418 if (LOWORD(*pFlags == MSHCTX_INPROC))
420 if (sizeof(*phGlobal) == 8)
421 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
422 else
423 *(ULONG *)pBuffer = WDT_INPROC_CALL;
424 pBuffer += sizeof(ULONG);
425 *(HGLOBAL *)pBuffer = *phGlobal;
426 pBuffer += sizeof(HGLOBAL);
428 else
430 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
431 pBuffer += sizeof(ULONG);
432 *(ULONG *)pBuffer = (ULONG)*phGlobal;
433 pBuffer += sizeof(ULONG);
434 if (*phGlobal)
436 const unsigned char *memory;
437 SIZE_T size = GlobalSize(*phGlobal);
438 *(ULONG *)pBuffer = (ULONG)size;
439 pBuffer += sizeof(ULONG);
440 *(ULONG *)pBuffer = (ULONG)*phGlobal;
441 pBuffer += sizeof(ULONG);
442 *(ULONG *)pBuffer = (ULONG)size;
443 pBuffer += sizeof(ULONG);
445 memory = GlobalLock(*phGlobal);
446 memcpy(pBuffer, memory, size);
447 pBuffer += size;
448 GlobalUnlock(*phGlobal);
452 return pBuffer;
455 /******************************************************************************
456 * HGLOBAL_UserUnmarshal [OLE32.@]
458 * Unmarshals an HGLOBAL from a buffer.
460 * PARAMS
461 * pFlags [I] Flags. See notes.
462 * pBuffer [I] Buffer to marshal the clip format from.
463 * phGlobal [O] Address that receive the unmarshaled HGLOBAL.
465 * RETURNS
466 * The end of the marshaled data in the buffer.
468 * NOTES
469 * Even though the function is documented to take a pointer to an ULONG in
470 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
471 * the first parameter is an ULONG.
472 * This function is only intended to be called by the RPC runtime.
474 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
476 ULONG fContext;
478 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
480 ALIGN_POINTER(pBuffer, 3);
482 fContext = *(ULONG *)pBuffer;
483 pBuffer += sizeof(ULONG);
485 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
486 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
488 *phGlobal = *(HGLOBAL *)pBuffer;
489 pBuffer += sizeof(*phGlobal);
491 else if (fContext == WDT_REMOTE_CALL)
493 ULONG handle;
495 handle = *(ULONG *)pBuffer;
496 pBuffer += sizeof(ULONG);
498 if (handle)
500 ULONG size;
501 void *memory;
503 size = *(ULONG *)pBuffer;
504 pBuffer += sizeof(ULONG);
505 /* redundancy is bad - it means you have to check consistency like
506 * this: */
507 if (*(ULONG *)pBuffer != handle)
509 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
510 return pBuffer;
512 pBuffer += sizeof(ULONG);
513 /* redundancy is bad - it means you have to check consistency like
514 * this: */
515 if (*(ULONG *)pBuffer != size)
517 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
518 return pBuffer;
520 pBuffer += sizeof(ULONG);
522 /* FIXME: check size is not too big */
524 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
525 memory = GlobalLock(*phGlobal);
526 memcpy(memory, pBuffer, size);
527 pBuffer += size;
528 GlobalUnlock(*phGlobal);
530 else
531 *phGlobal = NULL;
533 else
534 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
536 return pBuffer;
539 /******************************************************************************
540 * HGLOBAL_UserFree [OLE32.@]
542 * Frees an unmarshaled HGLOBAL.
544 * PARAMS
545 * pFlags [I] Flags. See notes.
546 * phGlobal [I] HGLOBAL to free.
548 * RETURNS
549 * The end of the marshaled data in the buffer.
551 * NOTES
552 * Even though the function is documented to take a pointer to a ULONG in
553 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
554 * which the first parameter is a ULONG.
555 * This function is only intended to be called by the RPC runtime.
557 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
559 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
561 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
562 GlobalFree(*phGlobal);
565 /******************************************************************************
566 * HBITMAP_UserSize [OLE32.@]
568 * Calculates the buffer size required to marshal a bitmap.
570 * PARAMS
571 * pFlags [I] Flags. See notes.
572 * StartingSize [I] Starting size of the buffer. This value is added on to
573 * the buffer size required for the clip format.
574 * phBmp [I] Bitmap to size.
576 * RETURNS
577 * The buffer size required to marshal an bitmap plus the starting size.
579 * NOTES
580 * Even though the function is documented to take a pointer to a ULONG in
581 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
582 * the first parameter is a ULONG.
583 * This function is only intended to be called by the RPC runtime.
585 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
587 FIXME(":stub\n");
588 return StartingSize;
591 /******************************************************************************
592 * HBITMAP_UserMarshal [OLE32.@]
594 * Marshals a bitmap into a buffer.
596 * PARAMS
597 * pFlags [I] Flags. See notes.
598 * pBuffer [I] Buffer to marshal the clip format into.
599 * phBmp [I] Bitmap to marshal.
601 * RETURNS
602 * The end of the marshaled data in the buffer.
604 * NOTES
605 * Even though the function is documented to take a pointer to a ULONG in
606 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
607 * the first parameter is a ULONG.
608 * This function is only intended to be called by the RPC runtime.
610 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
612 FIXME(":stub\n");
613 return pBuffer;
616 /******************************************************************************
617 * HBITMAP_UserUnmarshal [OLE32.@]
619 * Unmarshals a bitmap from a buffer.
621 * PARAMS
622 * pFlags [I] Flags. See notes.
623 * pBuffer [I] Buffer to marshal the clip format from.
624 * phBmp [O] Address that receive the unmarshaled bitmap.
626 * RETURNS
627 * The end of the marshaled data in the buffer.
629 * NOTES
630 * Even though the function is documented to take a pointer to an ULONG in
631 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
632 * the first parameter is an ULONG.
633 * This function is only intended to be called by the RPC runtime.
635 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
637 FIXME(":stub\n");
638 return pBuffer;
641 /******************************************************************************
642 * HBITMAP_UserFree [OLE32.@]
644 * Frees an unmarshaled bitmap.
646 * PARAMS
647 * pFlags [I] Flags. See notes.
648 * phBmp [I] Bitmap to free.
650 * RETURNS
651 * The end of the marshaled data in the buffer.
653 * NOTES
654 * Even though the function is documented to take a pointer to a ULONG in
655 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
656 * which the first parameter is a ULONG.
657 * This function is only intended to be called by the RPC runtime.
659 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
661 FIXME(":stub\n");
664 /******************************************************************************
665 * HICON_UserSize [OLE32.@]
667 * Calculates the buffer size required to marshal an icon.
669 * PARAMS
670 * pFlags [I] Flags. See notes.
671 * StartingSize [I] Starting size of the buffer. This value is added on to
672 * the buffer size required for the icon.
673 * phIcon [I] Icon to size.
675 * RETURNS
676 * The buffer size required to marshal an icon plus the starting size.
678 * NOTES
679 * Even though the function is documented to take a pointer to a ULONG in
680 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
681 * the first parameter is a ULONG.
682 * This function is only intended to be called by the RPC runtime.
684 ULONG __RPC_USER HICON_UserSize(ULONG *pFlags, ULONG StartingSize, HICON *phIcon)
686 FIXME(":stub\n");
687 return StartingSize;
690 /******************************************************************************
691 * HICON_UserMarshal [OLE32.@]
693 * Marshals an icon into a buffer.
695 * PARAMS
696 * pFlags [I] Flags. See notes.
697 * pBuffer [I] Buffer to marshal the icon into.
698 * phIcon [I] Icon to marshal.
700 * RETURNS
701 * The end of the marshaled data in the buffer.
703 * NOTES
704 * Even though the function is documented to take a pointer to a ULONG in
705 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
706 * the first parameter is a ULONG.
707 * This function is only intended to be called by the RPC runtime.
709 unsigned char * __RPC_USER HICON_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
711 FIXME(":stub\n");
712 return pBuffer;
715 /******************************************************************************
716 * HICON_UserUnmarshal [OLE32.@]
718 * Unmarshals an icon from a buffer.
720 * PARAMS
721 * pFlags [I] Flags. See notes.
722 * pBuffer [I] Buffer to marshal the icon from.
723 * phIcon [O] Address that receive the unmarshaled icon.
725 * RETURNS
726 * The end of the marshaled data in the buffer.
728 * NOTES
729 * Even though the function is documented to take a pointer to an ULONG in
730 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
731 * the first parameter is an ULONG.
732 * This function is only intended to be called by the RPC runtime.
734 unsigned char * __RPC_USER HICON_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HICON *phIcon)
736 FIXME(":stub\n");
737 return pBuffer;
740 /******************************************************************************
741 * HICON_UserFree [OLE32.@]
743 * Frees an unmarshaled icon.
745 * PARAMS
746 * pFlags [I] Flags. See notes.
747 * phIcon [I] Icon to free.
749 * RETURNS
750 * The end of the marshaled data in the buffer.
752 * NOTES
753 * Even though the function is documented to take a pointer to a ULONG in
754 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
755 * which the first parameter is a ULONG.
756 * This function is only intended to be called by the RPC runtime.
758 void __RPC_USER HICON_UserFree(ULONG *pFlags, HICON *phIcon)
760 FIXME(":stub\n");
763 /******************************************************************************
764 * HDC_UserSize [OLE32.@]
766 * Calculates the buffer size required to marshal an HDC.
768 * PARAMS
769 * pFlags [I] Flags. See notes.
770 * StartingSize [I] Starting size of the buffer. This value is added on to
771 * the buffer size required for the clip format.
772 * phGlobal [I] HDC to size.
774 * RETURNS
775 * The buffer size required to marshal an HDC plus the starting size.
777 * NOTES
778 * Even though the function is documented to take a pointer to a ULONG in
779 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
780 * the first parameter is a ULONG.
781 * This function is only intended to be called by the RPC runtime.
783 ULONG __RPC_USER HDC_UserSize(ULONG *pFlags, ULONG StartingSize, HDC *phdc)
785 FIXME(":stub\n");
786 return StartingSize;
789 /******************************************************************************
790 * HDC_UserMarshal [OLE32.@]
792 * Marshals an HDC into a buffer.
794 * PARAMS
795 * pFlags [I] Flags. See notes.
796 * pBuffer [I] Buffer to marshal the clip format into.
797 * phdc [I] HDC to marshal.
799 * RETURNS
800 * The end of the marshaled data in the buffer.
802 * NOTES
803 * Even though the function is documented to take a pointer to a ULONG in
804 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
805 * the first parameter is a ULONG.
806 * This function is only intended to be called by the RPC runtime.
808 unsigned char * __RPC_USER HDC_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
810 FIXME(":stub\n");
811 return pBuffer;
814 /******************************************************************************
815 * HDC_UserUnmarshal [OLE32.@]
817 * Unmarshals an HDC from a buffer.
819 * PARAMS
820 * pFlags [I] Flags. See notes.
821 * pBuffer [I] Buffer to marshal the clip format from.
822 * phdc [O] Address that receive the unmarshaled HDC.
824 * RETURNS
825 * The end of the marshaled data in the buffer.
827 * NOTES
828 * Even though the function is documented to take a pointer to an ULONG in
829 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
830 * the first parameter is an ULONG.
831 * This function is only intended to be called by the RPC runtime.
833 unsigned char * __RPC_USER HDC_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HDC *phdc)
835 FIXME(":stub\n");
836 return pBuffer;
839 /******************************************************************************
840 * HDC_UserFree [OLE32.@]
842 * Frees an unmarshaled HDC.
844 * PARAMS
845 * pFlags [I] Flags. See notes.
846 * phdc [I] HDC to free.
848 * RETURNS
849 * The end of the marshaled data in the buffer.
851 * NOTES
852 * Even though the function is documented to take a pointer to a ULONG in
853 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
854 * which the first parameter is a ULONG.
855 * This function is only intended to be called by the RPC runtime.
857 void __RPC_USER HDC_UserFree(ULONG *pFlags, HDC *phdc)
859 FIXME(":stub\n");
862 /******************************************************************************
863 * HPALETTE_UserSize [OLE32.@]
865 * Calculates the buffer size required to marshal a palette.
867 * PARAMS
868 * pFlags [I] Flags. See notes.
869 * StartingSize [I] Starting size of the buffer. This value is added on to
870 * the buffer size required for the clip format.
871 * phPal [I] Palette to size.
873 * RETURNS
874 * The buffer size required to marshal a palette plus the starting size.
876 * NOTES
877 * Even though the function is documented to take a pointer to a ULONG in
878 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
879 * the first parameter is a ULONG.
880 * This function is only intended to be called by the RPC runtime.
882 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
884 FIXME(":stub\n");
885 return StartingSize;
888 /******************************************************************************
889 * HPALETTE_UserMarshal [OLE32.@]
891 * Marshals a palette into a buffer.
893 * PARAMS
894 * pFlags [I] Flags. See notes.
895 * pBuffer [I] Buffer to marshal the clip format into.
896 * phPal [I] Palette to marshal.
898 * RETURNS
899 * The end of the marshaled data in the buffer.
901 * NOTES
902 * Even though the function is documented to take a pointer to a ULONG in
903 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
904 * the first parameter is a ULONG.
905 * This function is only intended to be called by the RPC runtime.
907 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
909 FIXME(":stub\n");
910 return pBuffer;
913 /******************************************************************************
914 * HPALETTE_UserUnmarshal [OLE32.@]
916 * Unmarshals a palette from a buffer.
918 * PARAMS
919 * pFlags [I] Flags. See notes.
920 * pBuffer [I] Buffer to marshal the clip format from.
921 * phPal [O] Address that receive the unmarshaled palette.
923 * RETURNS
924 * The end of the marshaled data in the buffer.
926 * NOTES
927 * Even though the function is documented to take a pointer to an ULONG in
928 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
929 * the first parameter is an ULONG.
930 * This function is only intended to be called by the RPC runtime.
932 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
934 FIXME(":stub\n");
935 return pBuffer;
938 /******************************************************************************
939 * HPALETTE_UserFree [OLE32.@]
941 * Frees an unmarshaled palette.
943 * PARAMS
944 * pFlags [I] Flags. See notes.
945 * phPal [I] Palette to free.
947 * RETURNS
948 * The end of the marshaled data in the buffer.
950 * NOTES
951 * Even though the function is documented to take a pointer to a ULONG in
952 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
953 * which the first parameter is a ULONG.
954 * This function is only intended to be called by the RPC runtime.
956 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
958 FIXME(":stub\n");
962 /******************************************************************************
963 * HMETAFILE_UserSize [OLE32.@]
965 * Calculates the buffer size required to marshal a metafile.
967 * PARAMS
968 * pFlags [I] Flags. See notes.
969 * StartingSize [I] Starting size of the buffer. This value is added on to
970 * the buffer size required for the clip format.
971 * phmf [I] Metafile to size.
973 * RETURNS
974 * The buffer size required to marshal a metafile plus the starting size.
976 * NOTES
977 * Even though the function is documented to take a pointer to a ULONG in
978 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
979 * the first parameter is a ULONG.
980 * This function is only intended to be called by the RPC runtime.
982 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
984 ULONG size = StartingSize;
986 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
988 ALIGN_LENGTH(size, 3);
990 size += sizeof(ULONG);
991 if (LOWORD(*pFlags) == MSHCTX_INPROC)
992 size += sizeof(ULONG_PTR);
993 else
995 size += sizeof(ULONG);
997 if (*phmf)
999 UINT mfsize;
1001 size += 2 * sizeof(ULONG);
1002 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1003 size += mfsize;
1007 return size;
1010 /******************************************************************************
1011 * HMETAFILE_UserMarshal [OLE32.@]
1013 * Marshals a metafile into a buffer.
1015 * PARAMS
1016 * pFlags [I] Flags. See notes.
1017 * pBuffer [I] Buffer to marshal the clip format into.
1018 * phEmf [I] Metafile to marshal.
1020 * RETURNS
1021 * The end of the marshaled data in the buffer.
1023 * NOTES
1024 * Even though the function is documented to take a pointer to a ULONG in
1025 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1026 * the first parameter is a ULONG.
1027 * This function is only intended to be called by the RPC runtime.
1029 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1031 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
1033 ALIGN_POINTER(pBuffer, 3);
1035 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1037 if (sizeof(*phmf) == 8)
1038 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1039 else
1040 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1041 pBuffer += sizeof(ULONG);
1042 *(HMETAFILE *)pBuffer = *phmf;
1043 pBuffer += sizeof(HMETAFILE);
1045 else
1047 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1048 pBuffer += sizeof(ULONG);
1049 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
1050 pBuffer += sizeof(ULONG);
1052 if (*phmf)
1054 UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
1056 *(ULONG *)pBuffer = mfsize;
1057 pBuffer += sizeof(ULONG);
1058 *(ULONG *)pBuffer = mfsize;
1059 pBuffer += sizeof(ULONG);
1060 GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
1061 pBuffer += mfsize;
1065 return pBuffer;
1068 /******************************************************************************
1069 * HMETAFILE_UserUnmarshal [OLE32.@]
1071 * Unmarshals a metafile from a buffer.
1073 * PARAMS
1074 * pFlags [I] Flags. See notes.
1075 * pBuffer [I] Buffer to marshal the clip format from.
1076 * phmf [O] Address that receive the unmarshaled metafile.
1078 * RETURNS
1079 * The end of the marshaled data in the buffer.
1081 * NOTES
1082 * Even though the function is documented to take a pointer to an ULONG in
1083 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1084 * the first parameter is an ULONG.
1085 * This function is only intended to be called by the RPC runtime.
1087 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
1089 ULONG fContext;
1091 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
1093 ALIGN_POINTER(pBuffer, 3);
1095 fContext = *(ULONG *)pBuffer;
1096 pBuffer += sizeof(ULONG);
1098 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
1099 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
1101 *phmf = *(HMETAFILE *)pBuffer;
1102 pBuffer += sizeof(*phmf);
1104 else if (fContext == WDT_REMOTE_CALL)
1106 ULONG handle;
1108 handle = *(ULONG *)pBuffer;
1109 pBuffer += sizeof(ULONG);
1111 if (handle)
1113 ULONG size;
1114 size = *(ULONG *)pBuffer;
1115 pBuffer += sizeof(ULONG);
1116 if (size != *(ULONG *)pBuffer)
1118 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1119 return pBuffer;
1121 pBuffer += sizeof(ULONG);
1122 *phmf = SetMetaFileBitsEx(size, pBuffer);
1123 pBuffer += size;
1125 else
1126 *phmf = NULL;
1128 else
1129 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1131 return pBuffer;
1134 /******************************************************************************
1135 * HMETAFILE_UserFree [OLE32.@]
1137 * Frees an unmarshaled metafile.
1139 * PARAMS
1140 * pFlags [I] Flags. See notes.
1141 * phmf [I] Metafile to free.
1143 * RETURNS
1144 * The end of the marshaled data in the buffer.
1146 * NOTES
1147 * Even though the function is documented to take a pointer to a ULONG in
1148 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1149 * which the first parameter is a ULONG.
1150 * This function is only intended to be called by the RPC runtime.
1152 void __RPC_USER HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
1154 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
1156 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1157 DeleteMetaFile(*phmf);
1160 /******************************************************************************
1161 * HENHMETAFILE_UserSize [OLE32.@]
1163 * Calculates the buffer size required to marshal an enhanced metafile.
1165 * PARAMS
1166 * pFlags [I] Flags. See notes.
1167 * StartingSize [I] Starting size of the buffer. This value is added on to
1168 * the buffer size required for the clip format.
1169 * phEmf [I] Enhanced metafile to size.
1171 * RETURNS
1172 * The buffer size required to marshal an enhanced metafile plus the starting size.
1174 * NOTES
1175 * Even though the function is documented to take a pointer to a ULONG in
1176 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1177 * the first parameter is a ULONG.
1178 * This function is only intended to be called by the RPC runtime.
1180 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
1182 ULONG size = StartingSize;
1184 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
1186 size += sizeof(ULONG);
1187 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1188 size += sizeof(ULONG_PTR);
1189 else
1191 size += sizeof(ULONG);
1193 if (*phEmf)
1195 UINT emfsize;
1197 size += 2 * sizeof(ULONG);
1198 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1199 size += emfsize;
1203 return size;
1206 /******************************************************************************
1207 * HENHMETAFILE_UserMarshal [OLE32.@]
1209 * Marshals an enhance metafile into a buffer.
1211 * PARAMS
1212 * pFlags [I] Flags. See notes.
1213 * pBuffer [I] Buffer to marshal the clip format into.
1214 * phEmf [I] Enhanced metafile to marshal.
1216 * RETURNS
1217 * The end of the marshaled data in the buffer.
1219 * NOTES
1220 * Even though the function is documented to take a pointer to a ULONG in
1221 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1222 * the first parameter is a ULONG.
1223 * This function is only intended to be called by the RPC runtime.
1225 unsigned char * __RPC_USER HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1227 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1229 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1231 if (sizeof(*phEmf) == 8)
1232 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1233 else
1234 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1235 pBuffer += sizeof(ULONG);
1236 *(HENHMETAFILE *)pBuffer = *phEmf;
1237 pBuffer += sizeof(HENHMETAFILE);
1239 else
1241 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1242 pBuffer += sizeof(ULONG);
1243 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1244 pBuffer += sizeof(ULONG);
1246 if (*phEmf)
1248 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1250 *(ULONG *)pBuffer = emfsize;
1251 pBuffer += sizeof(ULONG);
1252 *(ULONG *)pBuffer = emfsize;
1253 pBuffer += sizeof(ULONG);
1254 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1255 pBuffer += emfsize;
1259 return pBuffer;
1262 /******************************************************************************
1263 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1265 * Unmarshals an enhanced metafile from a buffer.
1267 * PARAMS
1268 * pFlags [I] Flags. See notes.
1269 * pBuffer [I] Buffer to marshal the clip format from.
1270 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
1272 * RETURNS
1273 * The end of the marshaled data in the buffer.
1275 * NOTES
1276 * Even though the function is documented to take a pointer to an ULONG in
1277 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1278 * the first parameter is an ULONG.
1279 * This function is only intended to be called by the RPC runtime.
1281 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1283 ULONG fContext;
1285 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1287 fContext = *(ULONG *)pBuffer;
1288 pBuffer += sizeof(ULONG);
1290 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1291 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1293 *phEmf = *(HENHMETAFILE *)pBuffer;
1294 pBuffer += sizeof(*phEmf);
1296 else if (fContext == WDT_REMOTE_CALL)
1298 ULONG handle;
1300 handle = *(ULONG *)pBuffer;
1301 pBuffer += sizeof(ULONG);
1303 if (handle)
1305 ULONG size;
1306 size = *(ULONG *)pBuffer;
1307 pBuffer += sizeof(ULONG);
1308 if (size != *(ULONG *)pBuffer)
1310 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1311 return pBuffer;
1313 pBuffer += sizeof(ULONG);
1314 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1315 pBuffer += size;
1317 else
1318 *phEmf = NULL;
1320 else
1321 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1323 return pBuffer;
1326 /******************************************************************************
1327 * HENHMETAFILE_UserFree [OLE32.@]
1329 * Frees an unmarshaled enhanced metafile.
1331 * PARAMS
1332 * pFlags [I] Flags. See notes.
1333 * phEmf [I] Enhanced metafile to free.
1335 * RETURNS
1336 * The end of the marshaled data in the buffer.
1338 * NOTES
1339 * Even though the function is documented to take a pointer to a ULONG in
1340 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1341 * which the first parameter is a ULONG.
1342 * This function is only intended to be called by the RPC runtime.
1344 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1346 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1348 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1349 DeleteEnhMetaFile(*phEmf);
1352 /******************************************************************************
1353 * HMETAFILEPICT_UserSize [OLE32.@]
1355 * Calculates the buffer size required to marshal an metafile pict.
1357 * PARAMS
1358 * pFlags [I] Flags. See notes.
1359 * StartingSize [I] Starting size of the buffer. This value is added on to
1360 * the buffer size required for the clip format.
1361 * phMfp [I] Metafile pict to size.
1363 * RETURNS
1364 * The buffer size required to marshal a metafile pict plus the starting size.
1366 * NOTES
1367 * Even though the function is documented to take a pointer to a ULONG in
1368 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1369 * the first parameter is a ULONG.
1370 * This function is only intended to be called by the RPC runtime.
1372 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1374 ULONG size = StartingSize;
1376 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1378 size += sizeof(ULONG);
1380 if(LOWORD(*pFlags) == MSHCTX_INPROC)
1381 size += sizeof(HMETAFILEPICT);
1382 else
1384 size += sizeof(ULONG);
1386 if (*phMfp)
1388 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1390 /* FIXME: raise an exception if mfpict is NULL? */
1391 size += 3 * sizeof(ULONG);
1392 size += sizeof(ULONG);
1394 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1396 GlobalUnlock(*phMfp);
1400 return size;
1403 /******************************************************************************
1404 * HMETAFILEPICT_UserMarshal [OLE32.@]
1406 * Marshals a metafile pict into a buffer.
1408 * PARAMS
1409 * pFlags [I] Flags. See notes.
1410 * pBuffer [I] Buffer to marshal the clip format into.
1411 * phMfp [I] Metafile pict to marshal.
1413 * RETURNS
1414 * The end of the marshaled data in the buffer.
1416 * NOTES
1417 * Even though the function is documented to take a pointer to a ULONG in
1418 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1419 * the first parameter is a ULONG.
1420 * This function is only intended to be called by the RPC runtime.
1422 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1424 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1426 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1428 if (sizeof(HMETAFILEPICT) == 8)
1429 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1430 else
1431 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1432 pBuffer += sizeof(ULONG);
1433 *(HMETAFILEPICT *)pBuffer = *phMfp;
1434 pBuffer += sizeof(HMETAFILEPICT);
1436 else
1438 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1439 pBuffer += sizeof(ULONG);
1440 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
1441 pBuffer += sizeof(ULONG);
1443 if (*phMfp)
1445 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1446 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1448 /* FIXME: raise an exception if mfpict is NULL? */
1449 remmfpict->mm = mfpict->mm;
1450 remmfpict->xExt = mfpict->xExt;
1451 remmfpict->yExt = mfpict->yExt;
1452 pBuffer += 3 * sizeof(ULONG);
1453 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1454 pBuffer += sizeof(ULONG);
1456 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1458 GlobalUnlock(*phMfp);
1461 return pBuffer;
1464 /******************************************************************************
1465 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1467 * Unmarshals an metafile pict from a buffer.
1469 * PARAMS
1470 * pFlags [I] Flags. See notes.
1471 * pBuffer [I] Buffer to marshal the clip format from.
1472 * phMfp [O] Address that receive the unmarshaled metafile pict.
1474 * RETURNS
1475 * The end of the marshaled data in the buffer.
1477 * NOTES
1478 * Even though the function is documented to take a pointer to an ULONG in
1479 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1480 * the first parameter is an ULONG.
1481 * This function is only intended to be called by the RPC runtime.
1483 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1485 ULONG fContext;
1487 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1489 fContext = *(ULONG *)pBuffer;
1490 pBuffer += sizeof(ULONG);
1492 if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
1494 *phMfp = *(HMETAFILEPICT *)pBuffer;
1495 pBuffer += sizeof(HMETAFILEPICT);
1497 else
1499 ULONG handle = *(ULONG *)pBuffer;
1500 pBuffer += sizeof(ULONG);
1501 *phMfp = NULL;
1503 if(handle)
1505 METAFILEPICT *mfpict;
1506 const remoteMETAFILEPICT *remmfpict;
1507 ULONG user_marshal_prefix;
1509 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1511 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1512 if (!*phMfp)
1513 RpcRaiseException(E_OUTOFMEMORY);
1515 mfpict = GlobalLock(*phMfp);
1516 mfpict->mm = remmfpict->mm;
1517 mfpict->xExt = remmfpict->xExt;
1518 mfpict->yExt = remmfpict->yExt;
1519 pBuffer += 3 * sizeof(ULONG);
1520 user_marshal_prefix = *(ULONG *)pBuffer;
1521 pBuffer += sizeof(ULONG);
1523 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1524 RpcRaiseException(RPC_X_INVALID_TAG);
1526 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1528 GlobalUnlock(*phMfp);
1531 return pBuffer;
1534 /******************************************************************************
1535 * HMETAFILEPICT_UserFree [OLE32.@]
1537 * Frees an unmarshaled metafile pict.
1539 * PARAMS
1540 * pFlags [I] Flags. See notes.
1541 * phMfp [I] Metafile pict to free.
1543 * RETURNS
1544 * The end of the marshaled data in the buffer.
1546 * NOTES
1547 * Even though the function is documented to take a pointer to a ULONG in
1548 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1549 * which the first parameter is a ULONG.
1550 * This function is only intended to be called by the RPC runtime.
1552 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1554 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1556 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1558 METAFILEPICT *mfpict;
1560 mfpict = GlobalLock(*phMfp);
1561 /* FIXME: raise an exception if mfpict is NULL? */
1562 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1563 GlobalUnlock(*phMfp);
1565 GlobalFree(*phMfp);
1569 /******************************************************************************
1570 * WdtpInterfacePointer_UserSize [OLE32.@]
1572 * Calculates the buffer size required to marshal an interface pointer.
1574 * PARAMS
1575 * pFlags [I] Flags. See notes.
1576 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1577 * punk [I] Interface pointer to size.
1578 * StartingSize [I] Starting size of the buffer. This value is added on to
1579 * the buffer size required for the clip format.
1580 * riid [I] ID of interface to size.
1582 * RETURNS
1583 * The buffer size required to marshal an interface pointer plus the starting size.
1585 * NOTES
1586 * Even though the function is documented to take a pointer to a ULONG in
1587 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1588 * the first parameter is a ULONG.
1590 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1592 DWORD marshal_size = 0;
1593 HRESULT hr;
1595 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1597 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1598 if(FAILED(hr)) return StartingSize;
1600 ALIGN_LENGTH(StartingSize, 3);
1601 StartingSize += 2 * sizeof(DWORD);
1602 return StartingSize + marshal_size;
1605 /******************************************************************************
1606 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1608 * Marshals an interface pointer into a buffer.
1610 * PARAMS
1611 * pFlags [I] Flags. See notes.
1612 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1613 * pBuffer [I] Buffer to marshal the clip format into.
1614 * punk [I] Interface pointer to marshal.
1615 * riid [I] ID of interface to marshal.
1617 * RETURNS
1618 * The end of the marshaled data in the buffer.
1620 * NOTES
1621 * Even though the function is documented to take a pointer to a ULONG in
1622 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1623 * the first parameter is a ULONG.
1625 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1627 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1628 IStream *stm;
1629 DWORD size;
1630 void *ptr;
1632 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1634 if(!h) return NULL;
1635 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1637 GlobalFree(h);
1638 return NULL;
1641 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1643 IStream_Release(stm);
1644 return NULL;
1647 ALIGN_POINTER(pBuffer, 3);
1648 size = GlobalSize(h);
1650 *(DWORD *)pBuffer = size;
1651 pBuffer += sizeof(DWORD);
1652 *(DWORD *)pBuffer = size;
1653 pBuffer += sizeof(DWORD);
1655 ptr = GlobalLock(h);
1656 memcpy(pBuffer, ptr, size);
1657 GlobalUnlock(h);
1659 IStream_Release(stm);
1660 return pBuffer + size;
1663 /******************************************************************************
1664 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1666 * Unmarshals an interface pointer from a buffer.
1668 * PARAMS
1669 * pFlags [I] Flags. See notes.
1670 * pBuffer [I] Buffer to marshal the clip format from.
1671 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1672 * riid [I] ID of interface to unmarshal.
1674 * RETURNS
1675 * The end of the marshaled data in the buffer.
1677 * NOTES
1678 * Even though the function is documented to take a pointer to an ULONG in
1679 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1680 * the first parameter is an ULONG.
1682 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1684 HRESULT hr;
1685 HGLOBAL h;
1686 IStream *stm;
1687 DWORD size;
1688 void *ptr;
1690 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1692 ALIGN_POINTER(pBuffer, 3);
1694 size = *(DWORD *)pBuffer;
1695 pBuffer += sizeof(DWORD);
1696 if(size != *(DWORD *)pBuffer)
1697 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1699 pBuffer += sizeof(DWORD);
1701 /* FIXME: sanity check on size */
1703 h = GlobalAlloc(GMEM_MOVEABLE, size);
1704 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1706 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1708 GlobalFree(h);
1709 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1712 ptr = GlobalLock(h);
1713 memcpy(ptr, pBuffer, size);
1714 GlobalUnlock(h);
1716 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1717 IStream_Release(stm);
1719 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1721 return pBuffer + size;
1724 /******************************************************************************
1725 * WdtpInterfacePointer_UserFree [OLE32.@]
1727 * Releases an unmarshaled interface pointer.
1729 * PARAMS
1730 * punk [I] Interface pointer to release.
1732 * RETURNS
1733 * Nothing.
1735 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1737 TRACE("(%p)\n", punk);
1738 if(punk) IUnknown_Release(punk);
1741 /******************************************************************************
1742 * STGMEDIUM_UserSize [OLE32.@]
1744 * Calculates the buffer size required to marshal an STGMEDIUM.
1746 * PARAMS
1747 * pFlags [I] Flags. See notes.
1748 * StartingSize [I] Starting size of the buffer. This value is added on to
1749 * the buffer size required for the clip format.
1750 * pStgMedium [I] STGMEDIUM to size.
1752 * RETURNS
1753 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1755 * NOTES
1756 * Even though the function is documented to take a pointer to a ULONG in
1757 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1758 * the first parameter is a ULONG.
1759 * This function is only intended to be called by the RPC runtime.
1761 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1763 ULONG size = StartingSize;
1765 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1767 ALIGN_LENGTH(size, 3);
1769 size += 2 * sizeof(DWORD);
1770 if (pStgMedium->tymed != TYMED_NULL)
1771 size += sizeof(DWORD);
1773 switch (pStgMedium->tymed)
1775 case TYMED_NULL:
1776 TRACE("TYMED_NULL\n");
1777 break;
1778 case TYMED_HGLOBAL:
1779 TRACE("TYMED_HGLOBAL\n");
1780 if (pStgMedium->u.hGlobal)
1781 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1782 break;
1783 case TYMED_FILE:
1784 TRACE("TYMED_FILE\n");
1785 if (pStgMedium->u.lpszFileName)
1787 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1788 size += 3 * sizeof(DWORD) +
1789 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1791 break;
1792 case TYMED_ISTREAM:
1793 TRACE("TYMED_ISTREAM\n");
1794 if (pStgMedium->u.pstm)
1796 IUnknown *unk;
1797 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1798 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1799 IUnknown_Release(unk);
1801 break;
1802 case TYMED_ISTORAGE:
1803 TRACE("TYMED_ISTORAGE\n");
1804 if (pStgMedium->u.pstg)
1806 IUnknown *unk;
1807 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1808 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1809 IUnknown_Release(unk);
1811 break;
1812 case TYMED_GDI:
1813 TRACE("TYMED_GDI\n");
1814 if (pStgMedium->u.hBitmap)
1816 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1818 break;
1819 case TYMED_MFPICT:
1820 TRACE("TYMED_MFPICT\n");
1821 if (pStgMedium->u.hMetaFilePict)
1822 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1823 break;
1824 case TYMED_ENHMF:
1825 TRACE("TYMED_ENHMF\n");
1826 if (pStgMedium->u.hEnhMetaFile)
1827 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1828 break;
1829 default:
1830 RaiseException(DV_E_TYMED, 0, 0, NULL);
1833 if (pStgMedium->pUnkForRelease)
1834 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1836 return size;
1839 /******************************************************************************
1840 * STGMEDIUM_UserMarshal [OLE32.@]
1842 * Marshals a STGMEDIUM into a buffer.
1844 * PARAMS
1845 * pFlags [I] Flags. See notes.
1846 * pBuffer [I] Buffer to marshal the clip format into.
1847 * pCF [I] STGMEDIUM to marshal.
1849 * RETURNS
1850 * The end of the marshaled data in the buffer.
1852 * NOTES
1853 * Even though the function is documented to take a pointer to a ULONG in
1854 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1855 * the first parameter is a ULONG.
1856 * This function is only intended to be called by the RPC runtime.
1858 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1860 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1862 ALIGN_POINTER(pBuffer, 3);
1864 *(DWORD *)pBuffer = pStgMedium->tymed;
1865 pBuffer += sizeof(DWORD);
1866 if (pStgMedium->tymed != TYMED_NULL)
1868 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1869 pBuffer += sizeof(DWORD);
1871 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1872 pBuffer += sizeof(DWORD);
1874 switch (pStgMedium->tymed)
1876 case TYMED_NULL:
1877 TRACE("TYMED_NULL\n");
1878 break;
1879 case TYMED_HGLOBAL:
1880 TRACE("TYMED_HGLOBAL\n");
1881 if (pStgMedium->u.hGlobal)
1882 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1883 break;
1884 case TYMED_FILE:
1885 TRACE("TYMED_FILE\n");
1886 if (pStgMedium->u.lpszFileName)
1888 DWORD len;
1889 len = strlenW(pStgMedium->u.lpszFileName);
1890 /* conformance */
1891 *(DWORD *)pBuffer = len + 1;
1892 pBuffer += sizeof(DWORD);
1893 /* offset */
1894 *(DWORD *)pBuffer = 0;
1895 pBuffer += sizeof(DWORD);
1896 /* variance */
1897 *(DWORD *)pBuffer = len + 1;
1898 pBuffer += sizeof(DWORD);
1900 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1901 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1903 break;
1904 case TYMED_ISTREAM:
1905 TRACE("TYMED_ISTREAM\n");
1906 if (pStgMedium->u.pstm)
1908 IUnknown *unk;
1909 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1910 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1911 IUnknown_Release(unk);
1913 break;
1914 case TYMED_ISTORAGE:
1915 TRACE("TYMED_ISTORAGE\n");
1916 if (pStgMedium->u.pstg)
1918 IUnknown *unk;
1919 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1920 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1921 IUnknown_Release(unk);
1923 break;
1924 case TYMED_GDI:
1925 TRACE("TYMED_GDI\n");
1926 if (pStgMedium->u.hBitmap)
1928 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1930 break;
1931 case TYMED_MFPICT:
1932 TRACE("TYMED_MFPICT\n");
1933 if (pStgMedium->u.hMetaFilePict)
1934 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1935 break;
1936 case TYMED_ENHMF:
1937 TRACE("TYMED_ENHMF\n");
1938 if (pStgMedium->u.hEnhMetaFile)
1939 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1940 break;
1941 default:
1942 RaiseException(DV_E_TYMED, 0, 0, NULL);
1945 if (pStgMedium->pUnkForRelease)
1946 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1948 return pBuffer;
1951 /******************************************************************************
1952 * STGMEDIUM_UserUnmarshal [OLE32.@]
1954 * Unmarshals a STGMEDIUM from a buffer.
1956 * PARAMS
1957 * pFlags [I] Flags. See notes.
1958 * pBuffer [I] Buffer to marshal the clip format from.
1959 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1961 * RETURNS
1962 * The end of the marshaled data in the buffer.
1964 * NOTES
1965 * Even though the function is documented to take a pointer to an ULONG in
1966 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1967 * the first parameter is an ULONG.
1968 * This function is only intended to be called by the RPC runtime.
1970 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1972 DWORD content = 0;
1973 DWORD releaseunk;
1975 ALIGN_POINTER(pBuffer, 3);
1977 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1979 pStgMedium->tymed = *(DWORD *)pBuffer;
1980 pBuffer += sizeof(DWORD);
1981 if (pStgMedium->tymed != TYMED_NULL)
1983 content = *(DWORD *)pBuffer;
1984 pBuffer += sizeof(DWORD);
1986 releaseunk = *(DWORD *)pBuffer;
1987 pBuffer += sizeof(DWORD);
1989 switch (pStgMedium->tymed)
1991 case TYMED_NULL:
1992 TRACE("TYMED_NULL\n");
1993 break;
1994 case TYMED_HGLOBAL:
1995 TRACE("TYMED_HGLOBAL\n");
1996 if (content)
1997 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1998 break;
1999 case TYMED_FILE:
2000 TRACE("TYMED_FILE\n");
2001 if (content)
2003 DWORD conformance;
2004 DWORD variance;
2005 conformance = *(DWORD *)pBuffer;
2006 pBuffer += sizeof(DWORD);
2007 if (*(DWORD *)pBuffer != 0)
2009 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
2010 RpcRaiseException(RPC_S_INVALID_BOUND);
2011 return NULL;
2013 pBuffer += sizeof(DWORD);
2014 variance = *(DWORD *)pBuffer;
2015 pBuffer += sizeof(DWORD);
2016 if (conformance != variance)
2018 ERR("conformance (%d) and variance (%d) should be equal\n",
2019 conformance, variance);
2020 RpcRaiseException(RPC_S_INVALID_BOUND);
2021 return NULL;
2023 if (conformance > 0x7fffffff)
2025 ERR("conformance 0x%x too large\n", conformance);
2026 RpcRaiseException(RPC_S_INVALID_BOUND);
2027 return NULL;
2029 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
2030 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
2031 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
2032 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
2033 pBuffer += variance * sizeof(WCHAR);
2035 else
2036 pStgMedium->u.lpszFileName = NULL;
2037 break;
2038 case TYMED_ISTREAM:
2039 TRACE("TYMED_ISTREAM\n");
2040 if (content)
2042 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
2044 else
2045 pStgMedium->u.pstm = NULL;
2046 break;
2047 case TYMED_ISTORAGE:
2048 TRACE("TYMED_ISTORAGE\n");
2049 if (content)
2051 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
2053 else
2054 pStgMedium->u.pstg = NULL;
2055 break;
2056 case TYMED_GDI:
2057 TRACE("TYMED_GDI\n");
2058 if (content)
2060 FIXME("not implemented for GDI object\n");
2062 else
2063 pStgMedium->u.hBitmap = NULL;
2064 break;
2065 case TYMED_MFPICT:
2066 TRACE("TYMED_MFPICT\n");
2067 if (content)
2068 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
2069 else
2070 pStgMedium->u.hMetaFilePict = NULL;
2071 break;
2072 case TYMED_ENHMF:
2073 TRACE("TYMED_ENHMF\n");
2074 if (content)
2075 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
2076 else
2077 pStgMedium->u.hEnhMetaFile = NULL;
2078 break;
2079 default:
2080 RaiseException(DV_E_TYMED, 0, 0, NULL);
2083 pStgMedium->pUnkForRelease = NULL;
2084 if (releaseunk)
2085 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
2087 return pBuffer;
2090 /******************************************************************************
2091 * STGMEDIUM_UserFree [OLE32.@]
2093 * Frees an unmarshaled STGMEDIUM.
2095 * PARAMS
2096 * pFlags [I] Flags. See notes.
2097 * pStgmedium [I] STGMEDIUM to free.
2099 * RETURNS
2100 * The end of the marshaled data in the buffer.
2102 * NOTES
2103 * Even though the function is documented to take a pointer to a ULONG in
2104 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
2105 * which the first parameter is a ULONG.
2106 * This function is only intended to be called by the RPC runtime.
2108 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
2110 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
2112 ReleaseStgMedium(pStgMedium);
2115 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
2117 TRACE("\n");
2118 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
2121 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2123 TRACE("\n");
2124 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
2127 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
2129 TRACE("\n");
2130 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
2133 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
2135 TRACE("\n");
2136 STGMEDIUM_UserFree(pFlags, pStgMedium);
2139 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
2141 FIXME(":stub\n");
2142 return StartingSize;
2145 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2147 FIXME(":stub\n");
2148 return pBuffer;
2151 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
2153 FIXME(":stub\n");
2154 return pBuffer;
2157 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
2159 FIXME(":stub\n");
2162 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
2164 FIXME(":stub\n");
2165 return StartingSize;
2168 unsigned char * __RPC_USER SNB_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2170 FIXME(":stub\n");
2171 return pBuffer;
2174 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2176 FIXME(":stub\n");
2177 return pBuffer;
2180 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2182 FIXME(":stub\n");
2185 /* call_as/local stubs for unknwn.idl */
2187 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2188 IClassFactory* This,
2189 IUnknown *pUnkOuter,
2190 REFIID riid,
2191 void **ppvObject)
2193 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2194 *ppvObject = NULL;
2195 if (pUnkOuter)
2197 ERR("aggregation is not allowed on remote objects\n");
2198 return CLASS_E_NOAGGREGATION;
2200 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2201 (IUnknown **) ppvObject);
2204 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2205 IClassFactory* This,
2206 REFIID riid,
2207 IUnknown **ppvObject)
2209 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2210 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2213 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2214 IClassFactory* This,
2215 BOOL fLock)
2217 FIXME(":stub\n");
2218 return E_NOTIMPL;
2221 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2222 IClassFactory* This,
2223 BOOL fLock)
2225 FIXME(":stub\n");
2226 return E_NOTIMPL;
2229 /* call_as/local stubs for objidl.idl */
2231 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2232 IEnumUnknown* This,
2233 ULONG celt,
2234 IUnknown **rgelt,
2235 ULONG *pceltFetched)
2237 ULONG fetched;
2238 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2239 if (!pceltFetched) pceltFetched = &fetched;
2240 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2243 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2244 IEnumUnknown* This,
2245 ULONG celt,
2246 IUnknown **rgelt,
2247 ULONG *pceltFetched)
2249 HRESULT hr;
2250 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2251 *pceltFetched = 0;
2252 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2253 if (hr == S_OK) *pceltFetched = celt;
2254 return hr;
2257 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2258 IBindCtx* This,
2259 BIND_OPTS *pbindopts)
2261 FIXME(":stub\n");
2262 return E_NOTIMPL;
2265 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2266 IBindCtx* This,
2267 BIND_OPTS2 *pbindopts)
2269 FIXME(":stub\n");
2270 return E_NOTIMPL;
2273 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2274 IBindCtx* This,
2275 BIND_OPTS *pbindopts)
2277 FIXME(":stub\n");
2278 return E_NOTIMPL;
2281 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2282 IBindCtx* This,
2283 BIND_OPTS2 *pbindopts)
2285 FIXME(":stub\n");
2286 return E_NOTIMPL;
2289 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2290 IEnumMoniker* This,
2291 ULONG celt,
2292 IMoniker **rgelt,
2293 ULONG *pceltFetched)
2295 ULONG fetched;
2296 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2297 if (!pceltFetched) pceltFetched = &fetched;
2298 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2301 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2302 IEnumMoniker* This,
2303 ULONG celt,
2304 IMoniker **rgelt,
2305 ULONG *pceltFetched)
2307 HRESULT hr;
2308 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2309 *pceltFetched = 0;
2310 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2311 if (hr == S_OK) *pceltFetched = celt;
2312 return hr;
2315 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2316 IRunnableObject* This)
2318 BOOL rv;
2319 FIXME(":stub\n");
2320 memset(&rv, 0, sizeof rv);
2321 return rv;
2324 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2325 IRunnableObject* This)
2327 FIXME(":stub\n");
2328 return E_NOTIMPL;
2331 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2332 IMoniker* This,
2333 IBindCtx *pbc,
2334 IMoniker *pmkToLeft,
2335 REFIID riidResult,
2336 void **ppvResult)
2338 FIXME(":stub\n");
2339 return E_NOTIMPL;
2342 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2343 IMoniker* This,
2344 IBindCtx *pbc,
2345 IMoniker *pmkToLeft,
2346 REFIID riidResult,
2347 IUnknown **ppvResult)
2349 FIXME(":stub\n");
2350 return E_NOTIMPL;
2353 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2354 IMoniker* This,
2355 IBindCtx *pbc,
2356 IMoniker *pmkToLeft,
2357 REFIID riid,
2358 void **ppvObj)
2360 FIXME(":stub\n");
2361 return E_NOTIMPL;
2364 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2365 IMoniker* This,
2366 IBindCtx *pbc,
2367 IMoniker *pmkToLeft,
2368 REFIID riid,
2369 IUnknown **ppvObj)
2371 FIXME(":stub\n");
2372 return E_NOTIMPL;
2375 HRESULT CALLBACK IEnumString_Next_Proxy(
2376 IEnumString* This,
2377 ULONG celt,
2378 LPOLESTR *rgelt,
2379 ULONG *pceltFetched)
2381 ULONG fetched;
2382 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2383 if (!pceltFetched) pceltFetched = &fetched;
2384 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2387 HRESULT __RPC_STUB IEnumString_Next_Stub(
2388 IEnumString* This,
2389 ULONG celt,
2390 LPOLESTR *rgelt,
2391 ULONG *pceltFetched)
2393 HRESULT hr;
2394 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2395 *pceltFetched = 0;
2396 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2397 if (hr == S_OK) *pceltFetched = celt;
2398 return hr;
2401 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2402 ISequentialStream* This,
2403 void *pv,
2404 ULONG cb,
2405 ULONG *pcbRead)
2407 ULONG read;
2408 HRESULT hr;
2410 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2412 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2413 if(pcbRead) *pcbRead = read;
2415 return hr;
2418 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2419 ISequentialStream* This,
2420 byte *pv,
2421 ULONG cb,
2422 ULONG *pcbRead)
2424 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2425 return ISequentialStream_Read(This, pv, cb, pcbRead);
2428 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2429 ISequentialStream* This,
2430 const void *pv,
2431 ULONG cb,
2432 ULONG *pcbWritten)
2434 ULONG written;
2435 HRESULT hr;
2437 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2439 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2440 if(pcbWritten) *pcbWritten = written;
2442 return hr;
2445 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2446 ISequentialStream* This,
2447 const byte *pv,
2448 ULONG cb,
2449 ULONG *pcbWritten)
2451 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2452 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2455 HRESULT CALLBACK IStream_Seek_Proxy(
2456 IStream* This,
2457 LARGE_INTEGER dlibMove,
2458 DWORD dwOrigin,
2459 ULARGE_INTEGER *plibNewPosition)
2461 ULARGE_INTEGER newpos;
2462 HRESULT hr;
2464 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2466 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2467 if(plibNewPosition) *plibNewPosition = newpos;
2469 return hr;
2472 HRESULT __RPC_STUB IStream_Seek_Stub(
2473 IStream* This,
2474 LARGE_INTEGER dlibMove,
2475 DWORD dwOrigin,
2476 ULARGE_INTEGER *plibNewPosition)
2478 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2479 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2482 HRESULT CALLBACK IStream_CopyTo_Proxy(
2483 IStream* This,
2484 IStream *pstm,
2485 ULARGE_INTEGER cb,
2486 ULARGE_INTEGER *pcbRead,
2487 ULARGE_INTEGER *pcbWritten)
2489 ULARGE_INTEGER read, written;
2490 HRESULT hr;
2492 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2494 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2495 if(pcbRead) *pcbRead = read;
2496 if(pcbWritten) *pcbWritten = written;
2498 return hr;
2501 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2502 IStream* This,
2503 IStream *pstm,
2504 ULARGE_INTEGER cb,
2505 ULARGE_INTEGER *pcbRead,
2506 ULARGE_INTEGER *pcbWritten)
2508 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2510 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2513 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2514 IEnumSTATSTG* This,
2515 ULONG celt,
2516 STATSTG *rgelt,
2517 ULONG *pceltFetched)
2519 ULONG fetched;
2520 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2521 if (!pceltFetched) pceltFetched = &fetched;
2522 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2525 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2526 IEnumSTATSTG* This,
2527 ULONG celt,
2528 STATSTG *rgelt,
2529 ULONG *pceltFetched)
2531 HRESULT hr;
2532 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2533 *pceltFetched = 0;
2534 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2535 if (hr == S_OK) *pceltFetched = celt;
2536 return hr;
2539 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2540 IStorage* This,
2541 LPCOLESTR pwcsName,
2542 void *reserved1,
2543 DWORD grfMode,
2544 DWORD reserved2,
2545 IStream **ppstm)
2547 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2548 if(reserved1) WARN("reserved1 %p\n", reserved1);
2550 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2553 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2554 IStorage* This,
2555 LPCOLESTR pwcsName,
2556 ULONG cbReserved1,
2557 byte *reserved1,
2558 DWORD grfMode,
2559 DWORD reserved2,
2560 IStream **ppstm)
2562 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2563 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2565 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2568 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2569 IStorage* This,
2570 DWORD reserved1,
2571 void *reserved2,
2572 DWORD reserved3,
2573 IEnumSTATSTG **ppenum)
2575 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2576 if(reserved2) WARN("reserved2 %p\n", reserved2);
2578 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2581 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2582 IStorage* This,
2583 DWORD reserved1,
2584 ULONG cbReserved2,
2585 byte *reserved2,
2586 DWORD reserved3,
2587 IEnumSTATSTG **ppenum)
2589 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2590 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2592 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2595 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2596 ILockBytes* This,
2597 ULARGE_INTEGER ulOffset,
2598 void *pv,
2599 ULONG cb,
2600 ULONG *pcbRead)
2602 ULONG read;
2603 HRESULT hr;
2605 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2607 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2608 if(pcbRead) *pcbRead = read;
2610 return hr;
2613 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2614 ILockBytes* This,
2615 ULARGE_INTEGER ulOffset,
2616 byte *pv,
2617 ULONG cb,
2618 ULONG *pcbRead)
2620 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2621 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2624 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2625 ILockBytes* This,
2626 ULARGE_INTEGER ulOffset,
2627 const void *pv,
2628 ULONG cb,
2629 ULONG *pcbWritten)
2631 ULONG written;
2632 HRESULT hr;
2634 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2636 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2637 if(pcbWritten) *pcbWritten = written;
2639 return hr;
2642 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2643 ILockBytes* This,
2644 ULARGE_INTEGER ulOffset,
2645 const byte *pv,
2646 ULONG cb,
2647 ULONG *pcbWritten)
2649 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2650 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2653 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2654 IFillLockBytes* This,
2655 const void *pv,
2656 ULONG cb,
2657 ULONG *pcbWritten)
2659 ULONG written;
2660 HRESULT hr;
2662 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2664 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2665 if(pcbWritten) *pcbWritten = written;
2667 return hr;
2670 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2671 IFillLockBytes* This,
2672 const byte *pv,
2673 ULONG cb,
2674 ULONG *pcbWritten)
2676 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2677 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2680 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2681 IFillLockBytes* This,
2682 ULARGE_INTEGER ulOffset,
2683 const void *pv,
2684 ULONG cb,
2685 ULONG *pcbWritten)
2687 ULONG written;
2688 HRESULT hr;
2690 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2692 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2693 if(pcbWritten) *pcbWritten = written;
2695 return hr;
2698 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2699 IFillLockBytes* This,
2700 ULARGE_INTEGER ulOffset,
2701 const byte *pv,
2702 ULONG cb,
2703 ULONG *pcbWritten)
2705 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2706 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2709 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2710 IEnumFORMATETC* This,
2711 ULONG celt,
2712 FORMATETC *rgelt,
2713 ULONG *pceltFetched)
2715 ULONG fetched;
2716 if (!pceltFetched) pceltFetched = &fetched;
2717 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2720 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2721 IEnumFORMATETC* This,
2722 ULONG celt,
2723 FORMATETC *rgelt,
2724 ULONG *pceltFetched)
2726 HRESULT hr;
2727 *pceltFetched = 0;
2728 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2729 if (hr == S_OK) *pceltFetched = celt;
2730 return hr;
2733 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2734 IEnumSTATDATA* This,
2735 ULONG celt,
2736 STATDATA *rgelt,
2737 ULONG *pceltFetched)
2739 ULONG fetched;
2740 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2741 if (!pceltFetched) pceltFetched = &fetched;
2742 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2745 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2746 IEnumSTATDATA* This,
2747 ULONG celt,
2748 STATDATA *rgelt,
2749 ULONG *pceltFetched)
2751 HRESULT hr;
2752 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2753 *pceltFetched = 0;
2754 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2755 if (hr == S_OK) *pceltFetched = celt;
2756 return hr;
2759 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2760 IAdviseSink* This,
2761 FORMATETC *pFormatetc,
2762 STGMEDIUM *pStgmed)
2764 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2765 IAdviseSink_RemoteOnDataChange_Proxy(This, pFormatetc, pStgmed);
2768 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2769 IAdviseSink* This,
2770 FORMATETC *pFormatetc,
2771 ASYNC_STGMEDIUM *pStgmed)
2773 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2774 IAdviseSink_OnDataChange(This, pFormatetc, pStgmed);
2775 return S_OK;
2778 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2779 IAdviseSink* This,
2780 DWORD dwAspect,
2781 LONG lindex)
2783 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2784 IAdviseSink_RemoteOnViewChange_Proxy(This, dwAspect, lindex);
2787 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2788 IAdviseSink* This,
2789 DWORD dwAspect,
2790 LONG lindex)
2792 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2793 IAdviseSink_OnViewChange(This, dwAspect, lindex);
2794 return S_OK;
2797 void CALLBACK IAdviseSink_OnRename_Proxy(
2798 IAdviseSink* This,
2799 IMoniker *pmk)
2801 TRACE("(%p)->(%p)\n", This, pmk);
2802 IAdviseSink_RemoteOnRename_Proxy(This, pmk);
2805 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2806 IAdviseSink* This,
2807 IMoniker *pmk)
2809 TRACE("(%p)->(%p)\n", This, pmk);
2810 IAdviseSink_OnRename(This, pmk);
2811 return S_OK;
2814 void CALLBACK IAdviseSink_OnSave_Proxy(
2815 IAdviseSink* This)
2817 TRACE("(%p)\n", This);
2818 IAdviseSink_RemoteOnSave_Proxy(This);
2821 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2822 IAdviseSink* This)
2824 TRACE("(%p)\n", This);
2825 IAdviseSink_OnSave(This);
2826 return S_OK;
2829 void CALLBACK IAdviseSink_OnClose_Proxy(
2830 IAdviseSink* This)
2832 TRACE("(%p)\n", This);
2833 IAdviseSink_RemoteOnClose_Proxy(This);
2836 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2837 IAdviseSink* This)
2839 TRACE("(%p)\n", This);
2840 IAdviseSink_OnClose(This);
2841 return S_OK;
2844 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2845 IAdviseSink2* This,
2846 IMoniker *pmk)
2848 TRACE("(%p)->(%p)\n", This, pmk);
2849 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This, pmk);
2852 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2853 IAdviseSink2* This,
2854 IMoniker *pmk)
2856 TRACE("(%p)->(%p)\n", This, pmk);
2857 IAdviseSink2_OnLinkSrcChange(This, pmk);
2858 return S_OK;
2861 HRESULT CALLBACK IDataObject_GetData_Proxy(
2862 IDataObject* This,
2863 FORMATETC *pformatetcIn,
2864 STGMEDIUM *pmedium)
2866 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2867 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2870 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2871 IDataObject* This,
2872 FORMATETC *pformatetcIn,
2873 STGMEDIUM *pRemoteMedium)
2875 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2876 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2879 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2880 IDataObject* This,
2881 FORMATETC *pformatetc,
2882 STGMEDIUM *pmedium)
2884 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2885 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2888 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2889 IDataObject* This,
2890 FORMATETC *pformatetc,
2891 STGMEDIUM *pRemoteMedium)
2893 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2894 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2897 HRESULT CALLBACK IDataObject_SetData_Proxy(
2898 IDataObject* This,
2899 FORMATETC *pformatetc,
2900 STGMEDIUM *pmedium,
2901 BOOL fRelease)
2903 FIXME(":stub\n");
2904 return E_NOTIMPL;
2907 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2908 IDataObject* This,
2909 FORMATETC *pformatetc,
2910 FLAG_STGMEDIUM *pmedium,
2911 BOOL fRelease)
2913 FIXME(":stub\n");
2914 return E_NOTIMPL;
2917 /* call_as/local stubs for oleidl.idl */
2919 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2920 IOleInPlaceActiveObject* This,
2921 LPMSG lpmsg)
2923 FIXME(":stub\n");
2924 return E_NOTIMPL;
2927 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2928 IOleInPlaceActiveObject* This)
2930 FIXME(":stub\n");
2931 return E_NOTIMPL;
2934 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2935 IOleInPlaceActiveObject* This,
2936 LPCRECT prcBorder,
2937 IOleInPlaceUIWindow *pUIWindow,
2938 BOOL fFrameWindow)
2940 FIXME(":stub\n");
2941 return E_NOTIMPL;
2944 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2945 IOleInPlaceActiveObject* This,
2946 LPCRECT prcBorder,
2947 REFIID riid,
2948 IOleInPlaceUIWindow *pUIWindow,
2949 BOOL fFrameWindow)
2951 FIXME(":stub\n");
2952 return E_NOTIMPL;
2955 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2956 IOleCache2* This,
2957 LPDATAOBJECT pDataObject,
2958 DWORD grfUpdf,
2959 LPVOID pReserved)
2961 FIXME(":stub\n");
2962 return E_NOTIMPL;
2965 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2966 IOleCache2* This,
2967 LPDATAOBJECT pDataObject,
2968 DWORD grfUpdf,
2969 LONG_PTR pReserved)
2971 FIXME(":stub\n");
2972 return E_NOTIMPL;
2975 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2976 IEnumOLEVERB* This,
2977 ULONG celt,
2978 LPOLEVERB rgelt,
2979 ULONG *pceltFetched)
2981 ULONG fetched;
2982 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2983 if (!pceltFetched) pceltFetched = &fetched;
2984 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2987 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2988 IEnumOLEVERB* This,
2989 ULONG celt,
2990 LPOLEVERB rgelt,
2991 ULONG *pceltFetched)
2993 HRESULT hr;
2994 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2995 *pceltFetched = 0;
2996 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2997 if (hr == S_OK) *pceltFetched = celt;
2998 return hr;
3001 HRESULT CALLBACK IViewObject_Draw_Proxy(
3002 IViewObject* This,
3003 DWORD dwDrawAspect,
3004 LONG lindex,
3005 void *pvAspect,
3006 DVTARGETDEVICE *ptd,
3007 HDC hdcTargetDev,
3008 HDC hdcDraw,
3009 LPCRECTL lprcBounds,
3010 LPCRECTL lprcWBounds,
3011 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
3012 ULONG_PTR dwContinue)
3014 FIXME(":stub\n");
3015 return E_NOTIMPL;
3018 HRESULT __RPC_STUB IViewObject_Draw_Stub(
3019 IViewObject* This,
3020 DWORD dwDrawAspect,
3021 LONG lindex,
3022 ULONG_PTR pvAspect,
3023 DVTARGETDEVICE *ptd,
3024 ULONG_PTR hdcTargetDev,
3025 ULONG_PTR hdcDraw,
3026 LPCRECTL lprcBounds,
3027 LPCRECTL lprcWBounds,
3028 IContinue *pContinue)
3030 FIXME(":stub\n");
3031 return E_NOTIMPL;
3034 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
3035 IViewObject* This,
3036 DWORD dwDrawAspect,
3037 LONG lindex,
3038 void *pvAspect,
3039 DVTARGETDEVICE *ptd,
3040 HDC hicTargetDev,
3041 LOGPALETTE **ppColorSet)
3043 FIXME(":stub\n");
3044 return E_NOTIMPL;
3047 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
3048 IViewObject* This,
3049 DWORD dwDrawAspect,
3050 LONG lindex,
3051 ULONG_PTR pvAspect,
3052 DVTARGETDEVICE *ptd,
3053 ULONG_PTR hicTargetDev,
3054 LOGPALETTE **ppColorSet)
3056 FIXME(":stub\n");
3057 return E_NOTIMPL;
3060 HRESULT CALLBACK IViewObject_Freeze_Proxy(
3061 IViewObject* This,
3062 DWORD dwDrawAspect,
3063 LONG lindex,
3064 void *pvAspect,
3065 DWORD *pdwFreeze)
3067 FIXME(":stub\n");
3068 return E_NOTIMPL;
3071 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3072 IViewObject* This,
3073 DWORD dwDrawAspect,
3074 LONG lindex,
3075 ULONG_PTR pvAspect,
3076 DWORD *pdwFreeze)
3078 FIXME(":stub\n");
3079 return E_NOTIMPL;
3082 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3083 IViewObject* This,
3084 DWORD *pAspects,
3085 DWORD *pAdvf,
3086 IAdviseSink **ppAdvSink)
3088 FIXME(":stub\n");
3089 return E_NOTIMPL;
3092 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3093 IViewObject* This,
3094 DWORD *pAspects,
3095 DWORD *pAdvf,
3096 IAdviseSink **ppAdvSink)
3098 FIXME(":stub\n");
3099 return E_NOTIMPL;