wineandroid: Create the top-level view on desktop window creation.
[wine.git] / dlls / ole32 / usrmarshal.c
blob89d0675f484844b0bf59494d017d2020bbe66b15
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 *handle)
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)
344 IMPL_WIREM_HANDLE(HDC)
345 IMPL_WIREM_HANDLE(HICON)
346 IMPL_WIREM_HANDLE(HBRUSH)
348 /******************************************************************************
349 * HGLOBAL_UserSize [OLE32.@]
351 * Calculates the buffer size required to marshal an HGLOBAL.
353 * PARAMS
354 * pFlags [I] Flags. See notes.
355 * StartingSize [I] Starting size of the buffer. This value is added on to
356 * the buffer size required for the clip format.
357 * phGlobal [I] HGLOBAL to size.
359 * RETURNS
360 * The buffer size required to marshal an HGLOBAL plus the starting size.
362 * NOTES
363 * Even though the function is documented to take a pointer to a ULONG in
364 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
365 * the first parameter is a ULONG.
366 * This function is only intended to be called by the RPC runtime.
368 ULONG __RPC_USER HGLOBAL_UserSize(ULONG *pFlags, ULONG StartingSize, HGLOBAL *phGlobal)
370 ULONG size = StartingSize;
372 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, phGlobal);
374 ALIGN_LENGTH(size, 3);
376 size += sizeof(ULONG);
378 if (LOWORD(*pFlags == MSHCTX_INPROC))
379 size += sizeof(HGLOBAL);
380 else
382 size += sizeof(ULONG);
383 if (*phGlobal)
385 SIZE_T ret;
386 size += 3 * sizeof(ULONG);
387 ret = GlobalSize(*phGlobal);
388 size += (ULONG)ret;
392 return size;
395 /******************************************************************************
396 * HGLOBAL_UserMarshal [OLE32.@]
398 * Marshals an HGLOBAL into a buffer.
400 * PARAMS
401 * pFlags [I] Flags. See notes.
402 * pBuffer [I] Buffer to marshal the clip format into.
403 * phGlobal [I] HGLOBAL to marshal.
405 * RETURNS
406 * The end of the marshaled data in the buffer.
408 * NOTES
409 * Even though the function is documented to take a pointer to a ULONG in
410 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
411 * the first parameter is a ULONG.
412 * This function is only intended to be called by the RPC runtime.
414 unsigned char * __RPC_USER HGLOBAL_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
416 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
418 ALIGN_POINTER(pBuffer, 3);
420 if (LOWORD(*pFlags == MSHCTX_INPROC))
422 if (sizeof(*phGlobal) == 8)
423 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
424 else
425 *(ULONG *)pBuffer = WDT_INPROC_CALL;
426 pBuffer += sizeof(ULONG);
427 *(HGLOBAL *)pBuffer = *phGlobal;
428 pBuffer += sizeof(HGLOBAL);
430 else
432 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
433 pBuffer += sizeof(ULONG);
434 *(ULONG *)pBuffer = HandleToULong(*phGlobal);
435 pBuffer += sizeof(ULONG);
436 if (*phGlobal)
438 const unsigned char *memory;
439 SIZE_T size = GlobalSize(*phGlobal);
440 *(ULONG *)pBuffer = (ULONG)size;
441 pBuffer += sizeof(ULONG);
442 *(ULONG *)pBuffer = HandleToULong(*phGlobal);
443 pBuffer += sizeof(ULONG);
444 *(ULONG *)pBuffer = (ULONG)size;
445 pBuffer += sizeof(ULONG);
447 memory = GlobalLock(*phGlobal);
448 memcpy(pBuffer, memory, size);
449 pBuffer += size;
450 GlobalUnlock(*phGlobal);
454 return pBuffer;
457 /******************************************************************************
458 * HGLOBAL_UserUnmarshal [OLE32.@]
460 * Unmarshals an HGLOBAL from a buffer.
462 * PARAMS
463 * pFlags [I] Flags. See notes.
464 * pBuffer [I] Buffer to marshal the clip format from.
465 * phGlobal [O] Address that receive the unmarshaled HGLOBAL.
467 * RETURNS
468 * The end of the marshaled data in the buffer.
470 * NOTES
471 * Even though the function is documented to take a pointer to an ULONG in
472 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
473 * the first parameter is an ULONG.
474 * This function is only intended to be called by the RPC runtime.
476 unsigned char * __RPC_USER HGLOBAL_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HGLOBAL *phGlobal)
478 ULONG fContext;
480 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phGlobal);
482 ALIGN_POINTER(pBuffer, 3);
484 fContext = *(ULONG *)pBuffer;
485 pBuffer += sizeof(ULONG);
487 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phGlobal) < 8)) ||
488 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phGlobal) == 8)))
490 *phGlobal = *(HGLOBAL *)pBuffer;
491 pBuffer += sizeof(*phGlobal);
493 else if (fContext == WDT_REMOTE_CALL)
495 ULONG handle;
497 handle = *(ULONG *)pBuffer;
498 pBuffer += sizeof(ULONG);
500 if (handle)
502 ULONG size;
503 void *memory;
505 size = *(ULONG *)pBuffer;
506 pBuffer += sizeof(ULONG);
507 /* redundancy is bad - it means you have to check consistency like
508 * this: */
509 if (*(ULONG *)pBuffer != handle)
511 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
512 return pBuffer;
514 pBuffer += sizeof(ULONG);
515 /* redundancy is bad - it means you have to check consistency like
516 * this: */
517 if (*(ULONG *)pBuffer != size)
519 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
520 return pBuffer;
522 pBuffer += sizeof(ULONG);
524 /* FIXME: check size is not too big */
526 *phGlobal = GlobalAlloc(GMEM_MOVEABLE, size);
527 memory = GlobalLock(*phGlobal);
528 memcpy(memory, pBuffer, size);
529 pBuffer += size;
530 GlobalUnlock(*phGlobal);
532 else
533 *phGlobal = NULL;
535 else
536 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
538 return pBuffer;
541 /******************************************************************************
542 * HGLOBAL_UserFree [OLE32.@]
544 * Frees an unmarshaled HGLOBAL.
546 * PARAMS
547 * pFlags [I] Flags. See notes.
548 * phGlobal [I] HGLOBAL to free.
550 * RETURNS
551 * The end of the marshaled data in the buffer.
553 * NOTES
554 * Even though the function is documented to take a pointer to a ULONG in
555 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
556 * which the first parameter is a ULONG.
557 * This function is only intended to be called by the RPC runtime.
559 void __RPC_USER HGLOBAL_UserFree(ULONG *pFlags, HGLOBAL *phGlobal)
561 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phGlobal);
563 if (LOWORD(*pFlags != MSHCTX_INPROC) && *phGlobal)
564 GlobalFree(*phGlobal);
567 /******************************************************************************
568 * HBITMAP_UserSize [OLE32.@]
570 * Calculates the buffer size required to marshal a bitmap.
572 * PARAMS
573 * pFlags [I] Flags. See notes.
574 * StartingSize [I] Starting size of the buffer. This value is added on to
575 * the buffer size required for the clip format.
576 * phBmp [I] Bitmap to size.
578 * RETURNS
579 * The buffer size required to marshal an bitmap plus the starting size.
581 * NOTES
582 * Even though the function is documented to take a pointer to a ULONG in
583 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
584 * the first parameter is a ULONG.
585 * This function is only intended to be called by the RPC runtime.
587 ULONG __RPC_USER HBITMAP_UserSize(ULONG *pFlags, ULONG StartingSize, HBITMAP *phBmp)
589 FIXME(":stub\n");
590 return StartingSize;
593 /******************************************************************************
594 * HBITMAP_UserMarshal [OLE32.@]
596 * Marshals a bitmap into a buffer.
598 * PARAMS
599 * pFlags [I] Flags. See notes.
600 * pBuffer [I] Buffer to marshal the clip format into.
601 * phBmp [I] Bitmap to marshal.
603 * RETURNS
604 * The end of the marshaled data in the buffer.
606 * NOTES
607 * Even though the function is documented to take a pointer to a ULONG in
608 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
609 * the first parameter is a ULONG.
610 * This function is only intended to be called by the RPC runtime.
612 unsigned char * __RPC_USER HBITMAP_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
614 FIXME(":stub\n");
615 return pBuffer;
618 /******************************************************************************
619 * HBITMAP_UserUnmarshal [OLE32.@]
621 * Unmarshals a bitmap from a buffer.
623 * PARAMS
624 * pFlags [I] Flags. See notes.
625 * pBuffer [I] Buffer to marshal the clip format from.
626 * phBmp [O] Address that receive the unmarshaled bitmap.
628 * RETURNS
629 * The end of the marshaled data in the buffer.
631 * NOTES
632 * Even though the function is documented to take a pointer to an ULONG in
633 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
634 * the first parameter is an ULONG.
635 * This function is only intended to be called by the RPC runtime.
637 unsigned char * __RPC_USER HBITMAP_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HBITMAP *phBmp)
639 FIXME(":stub\n");
640 return pBuffer;
643 /******************************************************************************
644 * HBITMAP_UserFree [OLE32.@]
646 * Frees an unmarshaled bitmap.
648 * PARAMS
649 * pFlags [I] Flags. See notes.
650 * phBmp [I] Bitmap to free.
652 * RETURNS
653 * The end of the marshaled data in the buffer.
655 * NOTES
656 * Even though the function is documented to take a pointer to a ULONG in
657 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
658 * which the first parameter is a ULONG.
659 * This function is only intended to be called by the RPC runtime.
661 void __RPC_USER HBITMAP_UserFree(ULONG *pFlags, HBITMAP *phBmp)
663 FIXME(":stub\n");
666 /******************************************************************************
667 * HPALETTE_UserSize [OLE32.@]
669 * Calculates the buffer size required to marshal a palette.
671 * PARAMS
672 * pFlags [I] Flags. See notes.
673 * StartingSize [I] Starting size of the buffer. This value is added on to
674 * the buffer size required for the clip format.
675 * phPal [I] Palette to size.
677 * RETURNS
678 * The buffer size required to marshal a palette plus the starting size.
680 * NOTES
681 * Even though the function is documented to take a pointer to a ULONG in
682 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
683 * the first parameter is a ULONG.
684 * This function is only intended to be called by the RPC runtime.
686 ULONG __RPC_USER HPALETTE_UserSize(ULONG *pFlags, ULONG StartingSize, HPALETTE *phPal)
688 FIXME(":stub\n");
689 return StartingSize;
692 /******************************************************************************
693 * HPALETTE_UserMarshal [OLE32.@]
695 * Marshals a palette into a buffer.
697 * PARAMS
698 * pFlags [I] Flags. See notes.
699 * pBuffer [I] Buffer to marshal the clip format into.
700 * phPal [I] Palette to marshal.
702 * RETURNS
703 * The end of the marshaled data in the buffer.
705 * NOTES
706 * Even though the function is documented to take a pointer to a ULONG in
707 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
708 * the first parameter is a ULONG.
709 * This function is only intended to be called by the RPC runtime.
711 unsigned char * __RPC_USER HPALETTE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
713 FIXME(":stub\n");
714 return pBuffer;
717 /******************************************************************************
718 * HPALETTE_UserUnmarshal [OLE32.@]
720 * Unmarshals a palette from a buffer.
722 * PARAMS
723 * pFlags [I] Flags. See notes.
724 * pBuffer [I] Buffer to marshal the clip format from.
725 * phPal [O] Address that receive the unmarshaled palette.
727 * RETURNS
728 * The end of the marshaled data in the buffer.
730 * NOTES
731 * Even though the function is documented to take a pointer to an ULONG in
732 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
733 * the first parameter is an ULONG.
734 * This function is only intended to be called by the RPC runtime.
736 unsigned char * __RPC_USER HPALETTE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HPALETTE *phPal)
738 FIXME(":stub\n");
739 return pBuffer;
742 /******************************************************************************
743 * HPALETTE_UserFree [OLE32.@]
745 * Frees an unmarshaled palette.
747 * PARAMS
748 * pFlags [I] Flags. See notes.
749 * phPal [I] Palette to free.
751 * RETURNS
752 * The end of the marshaled data in the buffer.
754 * NOTES
755 * Even though the function is documented to take a pointer to a ULONG in
756 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
757 * which the first parameter is a ULONG.
758 * This function is only intended to be called by the RPC runtime.
760 void __RPC_USER HPALETTE_UserFree(ULONG *pFlags, HPALETTE *phPal)
762 FIXME(":stub\n");
766 /******************************************************************************
767 * HMETAFILE_UserSize [OLE32.@]
769 * Calculates the buffer size required to marshal a metafile.
771 * PARAMS
772 * pFlags [I] Flags. See notes.
773 * StartingSize [I] Starting size of the buffer. This value is added on to
774 * the buffer size required for the clip format.
775 * phmf [I] Metafile to size.
777 * RETURNS
778 * The buffer size required to marshal a metafile plus the starting size.
780 * NOTES
781 * Even though the function is documented to take a pointer to a ULONG in
782 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
783 * the first parameter is a ULONG.
784 * This function is only intended to be called by the RPC runtime.
786 ULONG __RPC_USER HMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILE *phmf)
788 ULONG size = StartingSize;
790 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags), StartingSize, *phmf);
792 ALIGN_LENGTH(size, 3);
794 size += sizeof(ULONG);
795 if (LOWORD(*pFlags) == MSHCTX_INPROC)
796 size += sizeof(ULONG_PTR);
797 else
799 size += sizeof(ULONG);
801 if (*phmf)
803 UINT mfsize;
805 size += 2 * sizeof(ULONG);
806 mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
807 size += mfsize;
811 return size;
814 /******************************************************************************
815 * HMETAFILE_UserMarshal [OLE32.@]
817 * Marshals a metafile into a buffer.
819 * PARAMS
820 * pFlags [I] Flags. See notes.
821 * pBuffer [I] Buffer to marshal the clip format into.
822 * phEmf [I] Metafile to marshal.
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 a ULONG in
829 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
830 * the first parameter is a ULONG.
831 * This function is only intended to be called by the RPC runtime.
833 unsigned char * __RPC_USER HMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
835 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phmf);
837 ALIGN_POINTER(pBuffer, 3);
839 if (LOWORD(*pFlags) == MSHCTX_INPROC)
841 if (sizeof(*phmf) == 8)
842 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
843 else
844 *(ULONG *)pBuffer = WDT_INPROC_CALL;
845 pBuffer += sizeof(ULONG);
846 *(HMETAFILE *)pBuffer = *phmf;
847 pBuffer += sizeof(HMETAFILE);
849 else
851 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
852 pBuffer += sizeof(ULONG);
853 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phmf;
854 pBuffer += sizeof(ULONG);
856 if (*phmf)
858 UINT mfsize = GetMetaFileBitsEx(*phmf, 0, NULL);
860 *(ULONG *)pBuffer = mfsize;
861 pBuffer += sizeof(ULONG);
862 *(ULONG *)pBuffer = mfsize;
863 pBuffer += sizeof(ULONG);
864 GetMetaFileBitsEx(*phmf, mfsize, pBuffer);
865 pBuffer += mfsize;
869 return pBuffer;
872 /******************************************************************************
873 * HMETAFILE_UserUnmarshal [OLE32.@]
875 * Unmarshals a metafile from a buffer.
877 * PARAMS
878 * pFlags [I] Flags. See notes.
879 * pBuffer [I] Buffer to marshal the clip format from.
880 * phmf [O] Address that receive the unmarshaled metafile.
882 * RETURNS
883 * The end of the marshaled data in the buffer.
885 * NOTES
886 * Even though the function is documented to take a pointer to an ULONG in
887 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
888 * the first parameter is an ULONG.
889 * This function is only intended to be called by the RPC runtime.
891 unsigned char * __RPC_USER HMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILE *phmf)
893 ULONG fContext;
895 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phmf);
897 ALIGN_POINTER(pBuffer, 3);
899 fContext = *(ULONG *)pBuffer;
900 pBuffer += sizeof(ULONG);
902 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phmf) < 8)) ||
903 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phmf) == 8)))
905 *phmf = *(HMETAFILE *)pBuffer;
906 pBuffer += sizeof(*phmf);
908 else if (fContext == WDT_REMOTE_CALL)
910 ULONG handle;
912 handle = *(ULONG *)pBuffer;
913 pBuffer += sizeof(ULONG);
915 if (handle)
917 ULONG size;
918 size = *(ULONG *)pBuffer;
919 pBuffer += sizeof(ULONG);
920 if (size != *(ULONG *)pBuffer)
922 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
923 return pBuffer;
925 pBuffer += sizeof(ULONG);
926 *phmf = SetMetaFileBitsEx(size, pBuffer);
927 pBuffer += size;
929 else
930 *phmf = NULL;
932 else
933 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
935 return pBuffer;
938 /******************************************************************************
939 * HMETAFILE_UserFree [OLE32.@]
941 * Frees an unmarshaled metafile.
943 * PARAMS
944 * pFlags [I] Flags. See notes.
945 * phmf [I] Metafile 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 HMETAFILE_UserFree(ULONG *pFlags, HMETAFILE *phmf)
958 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phmf);
960 if (LOWORD(*pFlags) != MSHCTX_INPROC)
961 DeleteMetaFile(*phmf);
964 /******************************************************************************
965 * HENHMETAFILE_UserSize [OLE32.@]
967 * Calculates the buffer size required to marshal an enhanced metafile.
969 * PARAMS
970 * pFlags [I] Flags. See notes.
971 * StartingSize [I] Starting size of the buffer. This value is added on to
972 * the buffer size required for the clip format.
973 * phEmf [I] Enhanced metafile to size.
975 * RETURNS
976 * The buffer size required to marshal an enhanced metafile plus the starting size.
978 * NOTES
979 * Even though the function is documented to take a pointer to a ULONG in
980 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
981 * the first parameter is a ULONG.
982 * This function is only intended to be called by the RPC runtime.
984 ULONG __RPC_USER HENHMETAFILE_UserSize(ULONG *pFlags, ULONG StartingSize, HENHMETAFILE *phEmf)
986 ULONG size = StartingSize;
988 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, *phEmf);
990 size += sizeof(ULONG);
991 if (LOWORD(*pFlags) == MSHCTX_INPROC)
992 size += sizeof(ULONG_PTR);
993 else
995 size += sizeof(ULONG);
997 if (*phEmf)
999 UINT emfsize;
1001 size += 2 * sizeof(ULONG);
1002 emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1003 size += emfsize;
1007 return size;
1010 /******************************************************************************
1011 * HENHMETAFILE_UserMarshal [OLE32.@]
1013 * Marshals an enhance 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] Enhanced 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 HENHMETAFILE_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1031 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags), pBuffer, *phEmf);
1033 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1035 if (sizeof(*phEmf) == 8)
1036 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1037 else
1038 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1039 pBuffer += sizeof(ULONG);
1040 *(HENHMETAFILE *)pBuffer = *phEmf;
1041 pBuffer += sizeof(HENHMETAFILE);
1043 else
1045 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1046 pBuffer += sizeof(ULONG);
1047 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phEmf;
1048 pBuffer += sizeof(ULONG);
1050 if (*phEmf)
1052 UINT emfsize = GetEnhMetaFileBits(*phEmf, 0, NULL);
1054 *(ULONG *)pBuffer = emfsize;
1055 pBuffer += sizeof(ULONG);
1056 *(ULONG *)pBuffer = emfsize;
1057 pBuffer += sizeof(ULONG);
1058 GetEnhMetaFileBits(*phEmf, emfsize, pBuffer);
1059 pBuffer += emfsize;
1063 return pBuffer;
1066 /******************************************************************************
1067 * HENHMETAFILE_UserUnmarshal [OLE32.@]
1069 * Unmarshals an enhanced metafile from a buffer.
1071 * PARAMS
1072 * pFlags [I] Flags. See notes.
1073 * pBuffer [I] Buffer to marshal the clip format from.
1074 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
1076 * RETURNS
1077 * The end of the marshaled data in the buffer.
1079 * NOTES
1080 * Even though the function is documented to take a pointer to an ULONG in
1081 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1082 * the first parameter is an ULONG.
1083 * This function is only intended to be called by the RPC runtime.
1085 unsigned char * __RPC_USER HENHMETAFILE_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HENHMETAFILE *phEmf)
1087 ULONG fContext;
1089 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, phEmf);
1091 fContext = *(ULONG *)pBuffer;
1092 pBuffer += sizeof(ULONG);
1094 if (((fContext == WDT_INPROC_CALL) && (sizeof(*phEmf) < 8)) ||
1095 ((fContext == WDT_INPROC64_CALL) && (sizeof(*phEmf) == 8)))
1097 *phEmf = *(HENHMETAFILE *)pBuffer;
1098 pBuffer += sizeof(*phEmf);
1100 else if (fContext == WDT_REMOTE_CALL)
1102 ULONG handle;
1104 handle = *(ULONG *)pBuffer;
1105 pBuffer += sizeof(ULONG);
1107 if (handle)
1109 ULONG size;
1110 size = *(ULONG *)pBuffer;
1111 pBuffer += sizeof(ULONG);
1112 if (size != *(ULONG *)pBuffer)
1114 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1115 return pBuffer;
1117 pBuffer += sizeof(ULONG);
1118 *phEmf = SetEnhMetaFileBits(size, pBuffer);
1119 pBuffer += size;
1121 else
1122 *phEmf = NULL;
1124 else
1125 RaiseException(RPC_S_INVALID_TAG, 0, 0, NULL);
1127 return pBuffer;
1130 /******************************************************************************
1131 * HENHMETAFILE_UserFree [OLE32.@]
1133 * Frees an unmarshaled enhanced metafile.
1135 * PARAMS
1136 * pFlags [I] Flags. See notes.
1137 * phEmf [I] Enhanced metafile to free.
1139 * RETURNS
1140 * The end of the marshaled data in the buffer.
1142 * NOTES
1143 * Even though the function is documented to take a pointer to a ULONG in
1144 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1145 * which the first parameter is a ULONG.
1146 * This function is only intended to be called by the RPC runtime.
1148 void __RPC_USER HENHMETAFILE_UserFree(ULONG *pFlags, HENHMETAFILE *phEmf)
1150 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags), *phEmf);
1152 if (LOWORD(*pFlags) != MSHCTX_INPROC)
1153 DeleteEnhMetaFile(*phEmf);
1156 /******************************************************************************
1157 * HMETAFILEPICT_UserSize [OLE32.@]
1159 * Calculates the buffer size required to marshal an metafile pict.
1161 * PARAMS
1162 * pFlags [I] Flags. See notes.
1163 * StartingSize [I] Starting size of the buffer. This value is added on to
1164 * the buffer size required for the clip format.
1165 * phMfp [I] Metafile pict to size.
1167 * RETURNS
1168 * The buffer size required to marshal a metafile pict plus the starting size.
1170 * NOTES
1171 * Even though the function is documented to take a pointer to a ULONG in
1172 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1173 * the first parameter is a ULONG.
1174 * This function is only intended to be called by the RPC runtime.
1176 ULONG __RPC_USER HMETAFILEPICT_UserSize(ULONG *pFlags, ULONG StartingSize, HMETAFILEPICT *phMfp)
1178 ULONG size = StartingSize;
1180 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags), StartingSize, *phMfp);
1182 size += sizeof(ULONG);
1184 if(LOWORD(*pFlags) == MSHCTX_INPROC)
1185 size += sizeof(HMETAFILEPICT);
1186 else
1188 size += sizeof(ULONG);
1190 if (*phMfp)
1192 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1194 /* FIXME: raise an exception if mfpict is NULL? */
1195 size += 3 * sizeof(ULONG);
1196 size += sizeof(ULONG);
1198 size = HMETAFILE_UserSize(pFlags, size, &mfpict->hMF);
1200 GlobalUnlock(*phMfp);
1204 return size;
1207 /******************************************************************************
1208 * HMETAFILEPICT_UserMarshal [OLE32.@]
1210 * Marshals a metafile pict into a buffer.
1212 * PARAMS
1213 * pFlags [I] Flags. See notes.
1214 * pBuffer [I] Buffer to marshal the clip format into.
1215 * phMfp [I] Metafile pict to marshal.
1217 * RETURNS
1218 * The end of the marshaled data in the buffer.
1220 * NOTES
1221 * Even though the function is documented to take a pointer to a ULONG in
1222 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1223 * the first parameter is a ULONG.
1224 * This function is only intended to be called by the RPC runtime.
1226 unsigned char * __RPC_USER HMETAFILEPICT_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1228 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags), pBuffer, *phMfp);
1230 if (LOWORD(*pFlags) == MSHCTX_INPROC)
1232 if (sizeof(HMETAFILEPICT) == 8)
1233 *(ULONG *)pBuffer = WDT_INPROC64_CALL;
1234 else
1235 *(ULONG *)pBuffer = WDT_INPROC_CALL;
1236 pBuffer += sizeof(ULONG);
1237 *(HMETAFILEPICT *)pBuffer = *phMfp;
1238 pBuffer += sizeof(HMETAFILEPICT);
1240 else
1242 *(ULONG *)pBuffer = WDT_REMOTE_CALL;
1243 pBuffer += sizeof(ULONG);
1244 *(ULONG *)pBuffer = (ULONG)(ULONG_PTR)*phMfp;
1245 pBuffer += sizeof(ULONG);
1247 if (*phMfp)
1249 METAFILEPICT *mfpict = GlobalLock(*phMfp);
1250 remoteMETAFILEPICT * remmfpict = (remoteMETAFILEPICT *)pBuffer;
1252 /* FIXME: raise an exception if mfpict is NULL? */
1253 remmfpict->mm = mfpict->mm;
1254 remmfpict->xExt = mfpict->xExt;
1255 remmfpict->yExt = mfpict->yExt;
1256 pBuffer += 3 * sizeof(ULONG);
1257 *(ULONG *)pBuffer = USER_MARSHAL_PTR_PREFIX;
1258 pBuffer += sizeof(ULONG);
1260 pBuffer = HMETAFILE_UserMarshal(pFlags, pBuffer, &mfpict->hMF);
1262 GlobalUnlock(*phMfp);
1265 return pBuffer;
1268 /******************************************************************************
1269 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
1271 * Unmarshals an metafile pict from a buffer.
1273 * PARAMS
1274 * pFlags [I] Flags. See notes.
1275 * pBuffer [I] Buffer to marshal the clip format from.
1276 * phMfp [O] Address that receive the unmarshaled metafile pict.
1278 * RETURNS
1279 * The end of the marshaled data in the buffer.
1281 * NOTES
1282 * Even though the function is documented to take a pointer to an ULONG in
1283 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1284 * the first parameter is an ULONG.
1285 * This function is only intended to be called by the RPC runtime.
1287 unsigned char * __RPC_USER HMETAFILEPICT_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, HMETAFILEPICT *phMfp)
1289 ULONG fContext;
1291 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, phMfp);
1293 fContext = *(ULONG *)pBuffer;
1294 pBuffer += sizeof(ULONG);
1296 if ((fContext == WDT_INPROC_CALL) || fContext == WDT_INPROC64_CALL)
1298 *phMfp = *(HMETAFILEPICT *)pBuffer;
1299 pBuffer += sizeof(HMETAFILEPICT);
1301 else
1303 ULONG handle = *(ULONG *)pBuffer;
1304 pBuffer += sizeof(ULONG);
1305 *phMfp = NULL;
1307 if(handle)
1309 METAFILEPICT *mfpict;
1310 const remoteMETAFILEPICT *remmfpict;
1311 ULONG user_marshal_prefix;
1313 remmfpict = (const remoteMETAFILEPICT *)pBuffer;
1315 *phMfp = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILEPICT));
1316 if (!*phMfp)
1317 RpcRaiseException(E_OUTOFMEMORY);
1319 mfpict = GlobalLock(*phMfp);
1320 mfpict->mm = remmfpict->mm;
1321 mfpict->xExt = remmfpict->xExt;
1322 mfpict->yExt = remmfpict->yExt;
1323 pBuffer += 3 * sizeof(ULONG);
1324 user_marshal_prefix = *(ULONG *)pBuffer;
1325 pBuffer += sizeof(ULONG);
1327 if (user_marshal_prefix != USER_MARSHAL_PTR_PREFIX)
1328 RpcRaiseException(RPC_X_INVALID_TAG);
1330 pBuffer = HMETAFILE_UserUnmarshal(pFlags, pBuffer, &mfpict->hMF);
1332 GlobalUnlock(*phMfp);
1335 return pBuffer;
1338 /******************************************************************************
1339 * HMETAFILEPICT_UserFree [OLE32.@]
1341 * Frees an unmarshaled metafile pict.
1343 * PARAMS
1344 * pFlags [I] Flags. See notes.
1345 * phMfp [I] Metafile pict to free.
1347 * RETURNS
1348 * The end of the marshaled data in the buffer.
1350 * NOTES
1351 * Even though the function is documented to take a pointer to a ULONG in
1352 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1353 * which the first parameter is a ULONG.
1354 * This function is only intended to be called by the RPC runtime.
1356 void __RPC_USER HMETAFILEPICT_UserFree(ULONG *pFlags, HMETAFILEPICT *phMfp)
1358 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags), *phMfp);
1360 if ((LOWORD(*pFlags) != MSHCTX_INPROC) && *phMfp)
1362 METAFILEPICT *mfpict;
1364 mfpict = GlobalLock(*phMfp);
1365 /* FIXME: raise an exception if mfpict is NULL? */
1366 HMETAFILE_UserFree(pFlags, &mfpict->hMF);
1367 GlobalUnlock(*phMfp);
1369 GlobalFree(*phMfp);
1373 /******************************************************************************
1374 * WdtpInterfacePointer_UserSize [OLE32.@]
1376 * Calculates the buffer size required to marshal an interface pointer.
1378 * PARAMS
1379 * pFlags [I] Flags. See notes.
1380 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1381 * punk [I] Interface pointer to size.
1382 * StartingSize [I] Starting size of the buffer. This value is added on to
1383 * the buffer size required for the clip format.
1384 * riid [I] ID of interface to size.
1386 * RETURNS
1387 * The buffer size required to marshal an interface pointer plus the starting size.
1389 * NOTES
1390 * Even though the function is documented to take a pointer to a ULONG in
1391 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1392 * the first parameter is a ULONG.
1394 ULONG __RPC_USER WdtpInterfacePointer_UserSize(ULONG *pFlags, ULONG RealFlags, ULONG StartingSize, IUnknown *punk, REFIID riid)
1396 DWORD marshal_size = 0;
1397 HRESULT hr;
1399 TRACE("(%s, 0%x, %d, %p, %s)\n", debugstr_user_flags(pFlags), RealFlags, StartingSize, punk, debugstr_guid(riid));
1401 hr = CoGetMarshalSizeMax(&marshal_size, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL);
1402 if(FAILED(hr)) return StartingSize;
1404 ALIGN_LENGTH(StartingSize, 3);
1405 StartingSize += 2 * sizeof(DWORD);
1406 return StartingSize + marshal_size;
1409 /******************************************************************************
1410 * WdtpInterfacePointer_UserMarshal [OLE32.@]
1412 * Marshals an interface pointer into a buffer.
1414 * PARAMS
1415 * pFlags [I] Flags. See notes.
1416 * RealFlags [I] The MSHCTX to use when marshaling the interface.
1417 * pBuffer [I] Buffer to marshal the clip format into.
1418 * punk [I] Interface pointer to marshal.
1419 * riid [I] ID of interface to marshal.
1421 * RETURNS
1422 * The end of the marshaled data in the buffer.
1424 * NOTES
1425 * Even though the function is documented to take a pointer to a ULONG in
1426 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1427 * the first parameter is a ULONG.
1429 unsigned char * WINAPI WdtpInterfacePointer_UserMarshal(ULONG *pFlags, ULONG RealFlags, unsigned char *pBuffer, IUnknown *punk, REFIID riid)
1431 HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, 0);
1432 IStream *stm;
1433 DWORD size;
1434 void *ptr;
1436 TRACE("(%s, 0x%x, %p, &%p, %s)\n", debugstr_user_flags(pFlags), RealFlags, pBuffer, punk, debugstr_guid(riid));
1438 if(!h) return NULL;
1439 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1441 GlobalFree(h);
1442 return NULL;
1445 if(CoMarshalInterface(stm, riid, punk, LOWORD(RealFlags), NULL, MSHLFLAGS_NORMAL) != S_OK)
1447 IStream_Release(stm);
1448 return pBuffer;
1451 ALIGN_POINTER(pBuffer, 3);
1452 size = GlobalSize(h);
1454 *(DWORD *)pBuffer = size;
1455 pBuffer += sizeof(DWORD);
1456 *(DWORD *)pBuffer = size;
1457 pBuffer += sizeof(DWORD);
1459 ptr = GlobalLock(h);
1460 memcpy(pBuffer, ptr, size);
1461 GlobalUnlock(h);
1463 IStream_Release(stm);
1464 return pBuffer + size;
1467 /******************************************************************************
1468 * WdtpInterfacePointer_UserUnmarshal [OLE32.@]
1470 * Unmarshals an interface pointer from a buffer.
1472 * PARAMS
1473 * pFlags [I] Flags. See notes.
1474 * pBuffer [I] Buffer to marshal the clip format from.
1475 * ppunk [I/O] Address that receives the unmarshaled interface pointer.
1476 * riid [I] ID of interface to unmarshal.
1478 * RETURNS
1479 * The end of the marshaled data in the buffer.
1481 * NOTES
1482 * Even though the function is documented to take a pointer to an ULONG in
1483 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1484 * the first parameter is an ULONG.
1486 unsigned char * WINAPI WdtpInterfacePointer_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, IUnknown **ppunk, REFIID riid)
1488 HRESULT hr;
1489 HGLOBAL h;
1490 IStream *stm;
1491 DWORD size;
1492 void *ptr;
1493 IUnknown *orig;
1495 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1497 ALIGN_POINTER(pBuffer, 3);
1499 size = *(DWORD *)pBuffer;
1500 pBuffer += sizeof(DWORD);
1501 if(size != *(DWORD *)pBuffer)
1502 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1504 pBuffer += sizeof(DWORD);
1506 /* FIXME: sanity check on size */
1508 h = GlobalAlloc(GMEM_MOVEABLE, size);
1509 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1511 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1513 GlobalFree(h);
1514 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1517 ptr = GlobalLock(h);
1518 memcpy(ptr, pBuffer, size);
1519 GlobalUnlock(h);
1521 orig = *ppunk;
1522 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1523 IStream_Release(stm);
1525 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1527 if(orig) IUnknown_Release(orig);
1529 return pBuffer + size;
1532 /******************************************************************************
1533 * WdtpInterfacePointer_UserFree [OLE32.@]
1535 * Releases an unmarshaled interface pointer.
1537 * PARAMS
1538 * punk [I] Interface pointer to release.
1540 * RETURNS
1541 * Nothing.
1543 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1545 TRACE("(%p)\n", punk);
1546 if(punk) IUnknown_Release(punk);
1549 /******************************************************************************
1550 * STGMEDIUM_UserSize [OLE32.@]
1552 * Calculates the buffer size required to marshal an STGMEDIUM.
1554 * PARAMS
1555 * pFlags [I] Flags. See notes.
1556 * StartingSize [I] Starting size of the buffer. This value is added on to
1557 * the buffer size required for the clip format.
1558 * pStgMedium [I] STGMEDIUM to size.
1560 * RETURNS
1561 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1563 * NOTES
1564 * Even though the function is documented to take a pointer to a ULONG in
1565 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1566 * the first parameter is a ULONG.
1567 * This function is only intended to be called by the RPC runtime.
1569 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1571 ULONG size = StartingSize;
1573 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1575 ALIGN_LENGTH(size, 3);
1577 size += 2 * sizeof(DWORD);
1578 if (pStgMedium->tymed != TYMED_NULL)
1579 size += sizeof(DWORD);
1581 switch (pStgMedium->tymed)
1583 case TYMED_NULL:
1584 TRACE("TYMED_NULL\n");
1585 break;
1586 case TYMED_HGLOBAL:
1587 TRACE("TYMED_HGLOBAL\n");
1588 if (pStgMedium->u.hGlobal)
1589 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1590 break;
1591 case TYMED_FILE:
1592 TRACE("TYMED_FILE\n");
1593 if (pStgMedium->u.lpszFileName)
1595 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1596 size += 3 * sizeof(DWORD) +
1597 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1599 break;
1600 case TYMED_ISTREAM:
1601 TRACE("TYMED_ISTREAM\n");
1602 if (pStgMedium->u.pstm)
1604 IUnknown *unk;
1605 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1606 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1607 IUnknown_Release(unk);
1609 break;
1610 case TYMED_ISTORAGE:
1611 TRACE("TYMED_ISTORAGE\n");
1612 if (pStgMedium->u.pstg)
1614 IUnknown *unk;
1615 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1616 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1617 IUnknown_Release(unk);
1619 break;
1620 case TYMED_GDI:
1621 TRACE("TYMED_GDI\n");
1622 if (pStgMedium->u.hBitmap)
1624 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1626 break;
1627 case TYMED_MFPICT:
1628 TRACE("TYMED_MFPICT\n");
1629 if (pStgMedium->u.hMetaFilePict)
1630 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1631 break;
1632 case TYMED_ENHMF:
1633 TRACE("TYMED_ENHMF\n");
1634 if (pStgMedium->u.hEnhMetaFile)
1635 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1636 break;
1637 default:
1638 RaiseException(DV_E_TYMED, 0, 0, NULL);
1641 if (pStgMedium->pUnkForRelease)
1642 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1644 return size;
1647 /******************************************************************************
1648 * STGMEDIUM_UserMarshal [OLE32.@]
1650 * Marshals a STGMEDIUM into a buffer.
1652 * PARAMS
1653 * pFlags [I] Flags. See notes.
1654 * pBuffer [I] Buffer to marshal the clip format into.
1655 * pCF [I] STGMEDIUM to marshal.
1657 * RETURNS
1658 * The end of the marshaled data in the buffer.
1660 * NOTES
1661 * Even though the function is documented to take a pointer to a ULONG in
1662 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1663 * the first parameter is a ULONG.
1664 * This function is only intended to be called by the RPC runtime.
1666 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1668 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1670 ALIGN_POINTER(pBuffer, 3);
1672 *(DWORD *)pBuffer = pStgMedium->tymed;
1673 pBuffer += sizeof(DWORD);
1674 if (pStgMedium->tymed != TYMED_NULL)
1676 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1677 pBuffer += sizeof(DWORD);
1679 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1680 pBuffer += sizeof(DWORD);
1682 switch (pStgMedium->tymed)
1684 case TYMED_NULL:
1685 TRACE("TYMED_NULL\n");
1686 break;
1687 case TYMED_HGLOBAL:
1688 TRACE("TYMED_HGLOBAL\n");
1689 if (pStgMedium->u.hGlobal)
1690 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1691 break;
1692 case TYMED_FILE:
1693 TRACE("TYMED_FILE\n");
1694 if (pStgMedium->u.lpszFileName)
1696 DWORD len;
1697 len = strlenW(pStgMedium->u.lpszFileName);
1698 /* conformance */
1699 *(DWORD *)pBuffer = len + 1;
1700 pBuffer += sizeof(DWORD);
1701 /* offset */
1702 *(DWORD *)pBuffer = 0;
1703 pBuffer += sizeof(DWORD);
1704 /* variance */
1705 *(DWORD *)pBuffer = len + 1;
1706 pBuffer += sizeof(DWORD);
1708 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1709 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1711 break;
1712 case TYMED_ISTREAM:
1713 TRACE("TYMED_ISTREAM\n");
1714 if (pStgMedium->u.pstm)
1716 IUnknown *unk;
1717 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1718 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1719 IUnknown_Release(unk);
1721 break;
1722 case TYMED_ISTORAGE:
1723 TRACE("TYMED_ISTORAGE\n");
1724 if (pStgMedium->u.pstg)
1726 IUnknown *unk;
1727 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1728 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1729 IUnknown_Release(unk);
1731 break;
1732 case TYMED_GDI:
1733 TRACE("TYMED_GDI\n");
1734 if (pStgMedium->u.hBitmap)
1736 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1738 break;
1739 case TYMED_MFPICT:
1740 TRACE("TYMED_MFPICT\n");
1741 if (pStgMedium->u.hMetaFilePict)
1742 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1743 break;
1744 case TYMED_ENHMF:
1745 TRACE("TYMED_ENHMF\n");
1746 if (pStgMedium->u.hEnhMetaFile)
1747 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1748 break;
1749 default:
1750 RaiseException(DV_E_TYMED, 0, 0, NULL);
1753 if (pStgMedium->pUnkForRelease)
1754 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1756 return pBuffer;
1759 /******************************************************************************
1760 * STGMEDIUM_UserUnmarshal [OLE32.@]
1762 * Unmarshals a STGMEDIUM from a buffer.
1764 * PARAMS
1765 * pFlags [I] Flags. See notes.
1766 * pBuffer [I] Buffer to marshal the clip format from.
1767 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1769 * RETURNS
1770 * The end of the marshaled data in the buffer.
1772 * NOTES
1773 * Even though the function is documented to take a pointer to an ULONG in
1774 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1775 * the first parameter is an ULONG.
1776 * This function is only intended to be called by the RPC runtime.
1778 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1780 DWORD content = 0;
1781 DWORD releaseunk;
1783 ALIGN_POINTER(pBuffer, 3);
1785 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1787 pStgMedium->tymed = *(DWORD *)pBuffer;
1788 pBuffer += sizeof(DWORD);
1789 if (pStgMedium->tymed != TYMED_NULL)
1791 content = *(DWORD *)pBuffer;
1792 pBuffer += sizeof(DWORD);
1794 releaseunk = *(DWORD *)pBuffer;
1795 pBuffer += sizeof(DWORD);
1797 switch (pStgMedium->tymed)
1799 case TYMED_NULL:
1800 TRACE("TYMED_NULL\n");
1801 break;
1802 case TYMED_HGLOBAL:
1803 TRACE("TYMED_HGLOBAL\n");
1804 if (content)
1805 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1806 break;
1807 case TYMED_FILE:
1808 TRACE("TYMED_FILE\n");
1809 if (content)
1811 DWORD conformance;
1812 DWORD variance;
1813 conformance = *(DWORD *)pBuffer;
1814 pBuffer += sizeof(DWORD);
1815 if (*(DWORD *)pBuffer != 0)
1817 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
1818 RpcRaiseException(RPC_S_INVALID_BOUND);
1819 return NULL;
1821 pBuffer += sizeof(DWORD);
1822 variance = *(DWORD *)pBuffer;
1823 pBuffer += sizeof(DWORD);
1824 if (conformance != variance)
1826 ERR("conformance (%d) and variance (%d) should be equal\n",
1827 conformance, variance);
1828 RpcRaiseException(RPC_S_INVALID_BOUND);
1829 return NULL;
1831 if (conformance > 0x7fffffff)
1833 ERR("conformance 0x%x too large\n", conformance);
1834 RpcRaiseException(RPC_S_INVALID_BOUND);
1835 return NULL;
1837 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
1838 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
1839 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
1840 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
1841 pBuffer += variance * sizeof(WCHAR);
1843 else
1844 pStgMedium->u.lpszFileName = NULL;
1845 break;
1846 case TYMED_ISTREAM:
1847 TRACE("TYMED_ISTREAM\n");
1848 if (content)
1850 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
1852 else
1854 if (pStgMedium->u.pstm) IStream_Release( pStgMedium->u.pstm );
1855 pStgMedium->u.pstm = NULL;
1857 break;
1858 case TYMED_ISTORAGE:
1859 TRACE("TYMED_ISTORAGE\n");
1860 if (content)
1862 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
1864 else
1866 if (pStgMedium->u.pstg) IStorage_Release( pStgMedium->u.pstg );
1867 pStgMedium->u.pstg = NULL;
1869 break;
1870 case TYMED_GDI:
1871 TRACE("TYMED_GDI\n");
1872 if (content)
1874 FIXME("not implemented for GDI object\n");
1876 else
1877 pStgMedium->u.hBitmap = NULL;
1878 break;
1879 case TYMED_MFPICT:
1880 TRACE("TYMED_MFPICT\n");
1881 if (content)
1882 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1883 else
1884 pStgMedium->u.hMetaFilePict = NULL;
1885 break;
1886 case TYMED_ENHMF:
1887 TRACE("TYMED_ENHMF\n");
1888 if (content)
1889 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1890 else
1891 pStgMedium->u.hEnhMetaFile = NULL;
1892 break;
1893 default:
1894 RaiseException(DV_E_TYMED, 0, 0, NULL);
1897 if (releaseunk)
1898 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
1899 /* Unlike the IStream / IStorage ifaces, the existing pUnkForRelease
1900 is left intact if a NULL ptr is unmarshalled - see the tests. */
1902 return pBuffer;
1905 /******************************************************************************
1906 * STGMEDIUM_UserFree [OLE32.@]
1908 * Frees an unmarshaled STGMEDIUM.
1910 * PARAMS
1911 * pFlags [I] Flags. See notes.
1912 * pStgmedium [I] STGMEDIUM to free.
1914 * RETURNS
1915 * The end of the marshaled data in the buffer.
1917 * NOTES
1918 * Even though the function is documented to take a pointer to a ULONG in
1919 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1920 * which the first parameter is a ULONG.
1921 * This function is only intended to be called by the RPC runtime.
1923 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
1925 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
1927 ReleaseStgMedium(pStgMedium);
1930 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
1932 TRACE("\n");
1933 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
1936 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
1938 TRACE("\n");
1939 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
1942 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
1944 TRACE("\n");
1945 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
1948 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
1950 TRACE("\n");
1951 STGMEDIUM_UserFree(pFlags, pStgMedium);
1954 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
1956 FIXME(":stub\n");
1957 return StartingSize;
1960 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
1962 FIXME(":stub\n");
1963 return pBuffer;
1966 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
1968 FIXME(":stub\n");
1969 return pBuffer;
1972 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
1974 FIXME(":stub\n");
1977 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
1979 ULONG size = StartingSize;
1981 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pSnb);
1983 ALIGN_LENGTH(size, 3);
1985 /* two counters from RemSNB header, plus one more ULONG */
1986 size += 3*sizeof(ULONG);
1988 /* now actual data length */
1989 if (*pSnb)
1991 WCHAR **ptrW = *pSnb;
1993 while (*ptrW)
1995 size += (strlenW(*ptrW) + 1)*sizeof(WCHAR);
1996 ptrW++;
2000 return size;
2003 struct SNB_wire {
2004 ULONG charcnt;
2005 ULONG strcnt;
2006 ULONG datalen;
2007 WCHAR data[1];
2010 unsigned char * __RPC_USER SNB_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2012 struct SNB_wire *wire;
2013 ULONG size;
2015 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2017 ALIGN_POINTER(pBuffer, 3);
2019 wire = (struct SNB_wire*)pBuffer;
2020 wire->charcnt = wire->strcnt = 0;
2021 size = 3*sizeof(ULONG);
2023 if (*pSnb)
2025 WCHAR **ptrW = *pSnb;
2026 WCHAR *dataW = wire->data;
2028 while (*ptrW)
2030 ULONG len = strlenW(*ptrW) + 1;
2032 wire->strcnt++;
2033 wire->charcnt += len;
2034 memcpy(dataW, *ptrW, len*sizeof(WCHAR));
2035 dataW += len;
2037 size += len*sizeof(WCHAR);
2038 ptrW++;
2042 wire->datalen = wire->charcnt;
2043 return pBuffer + size;
2046 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2048 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2049 struct SNB_wire *wire;
2051 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2053 wire = (struct SNB_wire*)pBuffer;
2055 if (*pSnb)
2056 umcb->pStubMsg->pfnFree(*pSnb);
2058 if (wire->datalen == 0)
2059 *pSnb = NULL;
2060 else
2062 WCHAR *src = wire->data, *dest;
2063 WCHAR **ptrW;
2064 ULONG i;
2066 ptrW = *pSnb = umcb->pStubMsg->pfnAllocate((wire->strcnt+1)*sizeof(WCHAR*) + wire->datalen*sizeof(WCHAR));
2067 dest = (WCHAR*)(*pSnb + wire->strcnt + 1);
2069 for (i = 0; i < wire->strcnt; i++)
2071 ULONG len = strlenW(src);
2072 memcpy(dest, src, (len + 1)*sizeof(WCHAR));
2073 *ptrW = dest;
2074 src += len + 1;
2075 dest += len + 1;
2076 ptrW++;
2078 *ptrW = NULL;
2081 return pBuffer + 3*sizeof(ULONG) + wire->datalen*sizeof(WCHAR);
2084 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2086 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2087 TRACE("(%p)\n", pSnb);
2088 if (*pSnb)
2089 umcb->pStubMsg->pfnFree(*pSnb);
2092 /* call_as/local stubs for unknwn.idl */
2094 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2095 IClassFactory* This,
2096 IUnknown *pUnkOuter,
2097 REFIID riid,
2098 void **ppvObject)
2100 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2101 *ppvObject = NULL;
2102 if (pUnkOuter)
2104 ERR("aggregation is not allowed on remote objects\n");
2105 return CLASS_E_NOAGGREGATION;
2107 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2108 (IUnknown **) ppvObject);
2111 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2112 IClassFactory* This,
2113 REFIID riid,
2114 IUnknown **ppvObject)
2116 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2117 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2120 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2121 IClassFactory* This,
2122 BOOL fLock)
2124 FIXME(":stub\n");
2125 return E_NOTIMPL;
2128 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2129 IClassFactory* This,
2130 BOOL fLock)
2132 FIXME(":stub\n");
2133 return E_NOTIMPL;
2136 /* call_as/local stubs for objidl.idl */
2138 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2139 IEnumUnknown* This,
2140 ULONG celt,
2141 IUnknown **rgelt,
2142 ULONG *pceltFetched)
2144 ULONG fetched;
2145 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2146 if (!pceltFetched) pceltFetched = &fetched;
2147 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2150 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2151 IEnumUnknown* This,
2152 ULONG celt,
2153 IUnknown **rgelt,
2154 ULONG *pceltFetched)
2156 HRESULT hr;
2157 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2158 *pceltFetched = 0;
2159 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2160 if (hr == S_OK) *pceltFetched = celt;
2161 return hr;
2164 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2165 IBindCtx* This,
2166 BIND_OPTS *pbindopts)
2168 FIXME(":stub\n");
2169 return E_NOTIMPL;
2172 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2173 IBindCtx* This,
2174 BIND_OPTS2 *pbindopts)
2176 FIXME(":stub\n");
2177 return E_NOTIMPL;
2180 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2181 IBindCtx* This,
2182 BIND_OPTS *pbindopts)
2184 FIXME(":stub\n");
2185 return E_NOTIMPL;
2188 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2189 IBindCtx* This,
2190 BIND_OPTS2 *pbindopts)
2192 FIXME(":stub\n");
2193 return E_NOTIMPL;
2196 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2197 IEnumMoniker* This,
2198 ULONG celt,
2199 IMoniker **rgelt,
2200 ULONG *pceltFetched)
2202 ULONG fetched;
2203 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2204 if (!pceltFetched) pceltFetched = &fetched;
2205 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2208 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2209 IEnumMoniker* This,
2210 ULONG celt,
2211 IMoniker **rgelt,
2212 ULONG *pceltFetched)
2214 HRESULT hr;
2215 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2216 *pceltFetched = 0;
2217 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2218 if (hr == S_OK) *pceltFetched = celt;
2219 return hr;
2222 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2223 IRunnableObject* This)
2225 BOOL rv;
2226 FIXME(":stub\n");
2227 memset(&rv, 0, sizeof rv);
2228 return rv;
2231 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2232 IRunnableObject* This)
2234 FIXME(":stub\n");
2235 return E_NOTIMPL;
2238 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2239 IMoniker* This,
2240 IBindCtx *pbc,
2241 IMoniker *pmkToLeft,
2242 REFIID riidResult,
2243 void **ppvResult)
2245 FIXME(":stub\n");
2246 return E_NOTIMPL;
2249 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2250 IMoniker* This,
2251 IBindCtx *pbc,
2252 IMoniker *pmkToLeft,
2253 REFIID riidResult,
2254 IUnknown **ppvResult)
2256 FIXME(":stub\n");
2257 return E_NOTIMPL;
2260 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2261 IMoniker* This,
2262 IBindCtx *pbc,
2263 IMoniker *pmkToLeft,
2264 REFIID riid,
2265 void **ppvObj)
2267 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2268 return IMoniker_RemoteBindToStorage_Proxy(This, pbc, pmkToLeft, riid, (IUnknown**)ppvObj);
2271 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2272 IMoniker* This,
2273 IBindCtx *pbc,
2274 IMoniker *pmkToLeft,
2275 REFIID riid,
2276 IUnknown **ppvObj)
2278 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2279 return IMoniker_BindToStorage(This, pbc, pmkToLeft, riid, (void**)ppvObj);
2282 HRESULT CALLBACK IEnumString_Next_Proxy(
2283 IEnumString* This,
2284 ULONG celt,
2285 LPOLESTR *rgelt,
2286 ULONG *pceltFetched)
2288 ULONG fetched;
2289 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2290 if (!pceltFetched) pceltFetched = &fetched;
2291 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2294 HRESULT __RPC_STUB IEnumString_Next_Stub(
2295 IEnumString* This,
2296 ULONG celt,
2297 LPOLESTR *rgelt,
2298 ULONG *pceltFetched)
2300 HRESULT hr;
2301 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2302 *pceltFetched = 0;
2303 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2304 if (hr == S_OK) *pceltFetched = celt;
2305 return hr;
2308 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2309 ISequentialStream* This,
2310 void *pv,
2311 ULONG cb,
2312 ULONG *pcbRead)
2314 ULONG read;
2315 HRESULT hr;
2317 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2319 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2320 if(pcbRead) *pcbRead = read;
2322 return hr;
2325 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2326 ISequentialStream* This,
2327 byte *pv,
2328 ULONG cb,
2329 ULONG *pcbRead)
2331 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2332 return ISequentialStream_Read(This, pv, cb, pcbRead);
2335 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2336 ISequentialStream* This,
2337 const void *pv,
2338 ULONG cb,
2339 ULONG *pcbWritten)
2341 ULONG written;
2342 HRESULT hr;
2344 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2346 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2347 if(pcbWritten) *pcbWritten = written;
2349 return hr;
2352 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2353 ISequentialStream* This,
2354 const byte *pv,
2355 ULONG cb,
2356 ULONG *pcbWritten)
2358 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2359 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2362 HRESULT CALLBACK IStream_Seek_Proxy(
2363 IStream* This,
2364 LARGE_INTEGER dlibMove,
2365 DWORD dwOrigin,
2366 ULARGE_INTEGER *plibNewPosition)
2368 ULARGE_INTEGER newpos;
2369 HRESULT hr;
2371 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2373 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2374 if(plibNewPosition) *plibNewPosition = newpos;
2376 return hr;
2379 HRESULT __RPC_STUB IStream_Seek_Stub(
2380 IStream* This,
2381 LARGE_INTEGER dlibMove,
2382 DWORD dwOrigin,
2383 ULARGE_INTEGER *plibNewPosition)
2385 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2386 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2389 HRESULT CALLBACK IStream_CopyTo_Proxy(
2390 IStream* This,
2391 IStream *pstm,
2392 ULARGE_INTEGER cb,
2393 ULARGE_INTEGER *pcbRead,
2394 ULARGE_INTEGER *pcbWritten)
2396 ULARGE_INTEGER read, written;
2397 HRESULT hr;
2399 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2401 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2402 if(pcbRead) *pcbRead = read;
2403 if(pcbWritten) *pcbWritten = written;
2405 return hr;
2408 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2409 IStream* This,
2410 IStream *pstm,
2411 ULARGE_INTEGER cb,
2412 ULARGE_INTEGER *pcbRead,
2413 ULARGE_INTEGER *pcbWritten)
2415 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2417 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2420 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2421 IEnumSTATSTG* This,
2422 ULONG celt,
2423 STATSTG *rgelt,
2424 ULONG *pceltFetched)
2426 ULONG fetched;
2427 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2428 if (!pceltFetched) pceltFetched = &fetched;
2429 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2432 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2433 IEnumSTATSTG* This,
2434 ULONG celt,
2435 STATSTG *rgelt,
2436 ULONG *pceltFetched)
2438 HRESULT hr;
2439 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2440 *pceltFetched = 0;
2441 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2442 if (hr == S_OK) *pceltFetched = celt;
2443 return hr;
2446 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2447 IStorage* This,
2448 LPCOLESTR pwcsName,
2449 void *reserved1,
2450 DWORD grfMode,
2451 DWORD reserved2,
2452 IStream **ppstm)
2454 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2455 if(reserved1) WARN("reserved1 %p\n", reserved1);
2457 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2460 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2461 IStorage* This,
2462 LPCOLESTR pwcsName,
2463 ULONG cbReserved1,
2464 byte *reserved1,
2465 DWORD grfMode,
2466 DWORD reserved2,
2467 IStream **ppstm)
2469 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2470 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2472 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2475 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2476 IStorage* This,
2477 DWORD reserved1,
2478 void *reserved2,
2479 DWORD reserved3,
2480 IEnumSTATSTG **ppenum)
2482 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2483 if(reserved2) WARN("reserved2 %p\n", reserved2);
2485 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2488 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2489 IStorage* This,
2490 DWORD reserved1,
2491 ULONG cbReserved2,
2492 byte *reserved2,
2493 DWORD reserved3,
2494 IEnumSTATSTG **ppenum)
2496 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2497 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2499 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2502 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2503 ILockBytes* This,
2504 ULARGE_INTEGER ulOffset,
2505 void *pv,
2506 ULONG cb,
2507 ULONG *pcbRead)
2509 ULONG read;
2510 HRESULT hr;
2512 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2514 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2515 if(pcbRead) *pcbRead = read;
2517 return hr;
2520 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2521 ILockBytes* This,
2522 ULARGE_INTEGER ulOffset,
2523 byte *pv,
2524 ULONG cb,
2525 ULONG *pcbRead)
2527 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2528 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2531 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2532 ILockBytes* This,
2533 ULARGE_INTEGER ulOffset,
2534 const void *pv,
2535 ULONG cb,
2536 ULONG *pcbWritten)
2538 ULONG written;
2539 HRESULT hr;
2541 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2543 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2544 if(pcbWritten) *pcbWritten = written;
2546 return hr;
2549 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2550 ILockBytes* This,
2551 ULARGE_INTEGER ulOffset,
2552 const byte *pv,
2553 ULONG cb,
2554 ULONG *pcbWritten)
2556 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2557 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2560 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2561 IFillLockBytes* This,
2562 const void *pv,
2563 ULONG cb,
2564 ULONG *pcbWritten)
2566 ULONG written;
2567 HRESULT hr;
2569 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2571 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2572 if(pcbWritten) *pcbWritten = written;
2574 return hr;
2577 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2578 IFillLockBytes* This,
2579 const byte *pv,
2580 ULONG cb,
2581 ULONG *pcbWritten)
2583 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2584 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2587 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2588 IFillLockBytes* This,
2589 ULARGE_INTEGER ulOffset,
2590 const void *pv,
2591 ULONG cb,
2592 ULONG *pcbWritten)
2594 ULONG written;
2595 HRESULT hr;
2597 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2599 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2600 if(pcbWritten) *pcbWritten = written;
2602 return hr;
2605 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2606 IFillLockBytes* This,
2607 ULARGE_INTEGER ulOffset,
2608 const byte *pv,
2609 ULONG cb,
2610 ULONG *pcbWritten)
2612 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2613 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2616 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2617 IEnumFORMATETC* This,
2618 ULONG celt,
2619 FORMATETC *rgelt,
2620 ULONG *pceltFetched)
2622 ULONG fetched;
2623 if (!pceltFetched) pceltFetched = &fetched;
2624 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2627 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2628 IEnumFORMATETC* This,
2629 ULONG celt,
2630 FORMATETC *rgelt,
2631 ULONG *pceltFetched)
2633 HRESULT hr;
2634 *pceltFetched = 0;
2635 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2636 if (hr == S_OK) *pceltFetched = celt;
2637 return hr;
2640 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2641 IEnumSTATDATA* This,
2642 ULONG celt,
2643 STATDATA *rgelt,
2644 ULONG *pceltFetched)
2646 ULONG fetched;
2647 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2648 if (!pceltFetched) pceltFetched = &fetched;
2649 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2652 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2653 IEnumSTATDATA* This,
2654 ULONG celt,
2655 STATDATA *rgelt,
2656 ULONG *pceltFetched)
2658 HRESULT hr;
2659 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2660 *pceltFetched = 0;
2661 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2662 if (hr == S_OK) *pceltFetched = celt;
2663 return hr;
2666 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2667 IAdviseSink* This,
2668 FORMATETC *pFormatetc,
2669 STGMEDIUM *pStgmed)
2671 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2672 IAdviseSink_RemoteOnDataChange_Proxy(This, pFormatetc, pStgmed);
2675 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2676 IAdviseSink* This,
2677 FORMATETC *pFormatetc,
2678 ASYNC_STGMEDIUM *pStgmed)
2680 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2681 IAdviseSink_OnDataChange(This, pFormatetc, pStgmed);
2682 return S_OK;
2685 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2686 IAdviseSink* This,
2687 DWORD dwAspect,
2688 LONG lindex)
2690 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2691 IAdviseSink_RemoteOnViewChange_Proxy(This, dwAspect, lindex);
2694 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2695 IAdviseSink* This,
2696 DWORD dwAspect,
2697 LONG lindex)
2699 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2700 IAdviseSink_OnViewChange(This, dwAspect, lindex);
2701 return S_OK;
2704 void CALLBACK IAdviseSink_OnRename_Proxy(
2705 IAdviseSink* This,
2706 IMoniker *pmk)
2708 TRACE("(%p)->(%p)\n", This, pmk);
2709 IAdviseSink_RemoteOnRename_Proxy(This, pmk);
2712 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2713 IAdviseSink* This,
2714 IMoniker *pmk)
2716 TRACE("(%p)->(%p)\n", This, pmk);
2717 IAdviseSink_OnRename(This, pmk);
2718 return S_OK;
2721 void CALLBACK IAdviseSink_OnSave_Proxy(
2722 IAdviseSink* This)
2724 TRACE("(%p)\n", This);
2725 IAdviseSink_RemoteOnSave_Proxy(This);
2728 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2729 IAdviseSink* This)
2731 TRACE("(%p)\n", This);
2732 IAdviseSink_OnSave(This);
2733 return S_OK;
2736 void CALLBACK IAdviseSink_OnClose_Proxy(
2737 IAdviseSink* This)
2739 TRACE("(%p)\n", This);
2740 IAdviseSink_RemoteOnClose_Proxy(This);
2743 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2744 IAdviseSink* This)
2746 TRACE("(%p)\n", This);
2747 IAdviseSink_OnClose(This);
2748 return S_OK;
2751 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2752 IAdviseSink2* This,
2753 IMoniker *pmk)
2755 TRACE("(%p)->(%p)\n", This, pmk);
2756 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This, pmk);
2759 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2760 IAdviseSink2* This,
2761 IMoniker *pmk)
2763 TRACE("(%p)->(%p)\n", This, pmk);
2764 IAdviseSink2_OnLinkSrcChange(This, pmk);
2765 return S_OK;
2768 HRESULT CALLBACK IDataObject_GetData_Proxy(
2769 IDataObject* This,
2770 FORMATETC *pformatetcIn,
2771 STGMEDIUM *pmedium)
2773 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2774 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2777 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2778 IDataObject* This,
2779 FORMATETC *pformatetcIn,
2780 STGMEDIUM *pRemoteMedium)
2782 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2783 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2786 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(IDataObject *iface, FORMATETC *fmt, STGMEDIUM *med)
2788 IUnknown *release;
2789 IStorage *stg = NULL;
2790 HRESULT hr;
2792 TRACE("(%p)->(%p, %p)\n", iface, fmt, med);
2794 if ((med->tymed & (TYMED_HGLOBAL | TYMED_FILE | TYMED_ISTREAM | TYMED_ISTORAGE)) == 0)
2795 return DV_E_TYMED;
2796 if (med->tymed != fmt->tymed)
2797 return DV_E_TYMED;
2799 release = med->pUnkForRelease;
2800 med->pUnkForRelease = NULL;
2802 if (med->tymed == TYMED_ISTREAM || med->tymed == TYMED_ISTORAGE)
2804 stg = med->u.pstg; /* This may actually be a stream, but that's ok */
2805 if (stg) IStorage_AddRef( stg );
2808 hr = IDataObject_RemoteGetDataHere_Proxy(iface, fmt, med);
2810 med->pUnkForRelease = release;
2811 if (stg)
2813 if (med->u.pstg)
2814 IStorage_Release( med->u.pstg );
2815 med->u.pstg = stg;
2818 return hr;
2821 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2822 IDataObject* This,
2823 FORMATETC *pformatetc,
2824 STGMEDIUM *pRemoteMedium)
2826 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2827 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2830 HRESULT CALLBACK IDataObject_SetData_Proxy(
2831 IDataObject* This,
2832 FORMATETC *pformatetc,
2833 STGMEDIUM *pmedium,
2834 BOOL fRelease)
2836 FIXME(":stub\n");
2837 return E_NOTIMPL;
2840 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2841 IDataObject* This,
2842 FORMATETC *pformatetc,
2843 FLAG_STGMEDIUM *pmedium,
2844 BOOL fRelease)
2846 FIXME(":stub\n");
2847 return E_NOTIMPL;
2850 /* call_as/local stubs for oleidl.idl */
2852 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2853 IOleInPlaceActiveObject* This,
2854 LPMSG lpmsg)
2856 TRACE("(%p %p)\n", This, lpmsg);
2857 return IOleInPlaceActiveObject_RemoteTranslateAccelerator_Proxy(This);
2860 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2861 IOleInPlaceActiveObject* This)
2863 TRACE("(%p)\n", This);
2864 return S_FALSE;
2867 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2868 IOleInPlaceActiveObject* This,
2869 LPCRECT prcBorder,
2870 IOleInPlaceUIWindow *pUIWindow,
2871 BOOL fFrameWindow)
2873 FIXME(":stub\n");
2874 return E_NOTIMPL;
2877 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2878 IOleInPlaceActiveObject* This,
2879 LPCRECT prcBorder,
2880 REFIID riid,
2881 IOleInPlaceUIWindow *pUIWindow,
2882 BOOL fFrameWindow)
2884 FIXME(":stub\n");
2885 return E_NOTIMPL;
2888 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2889 IOleCache2* This,
2890 LPDATAOBJECT pDataObject,
2891 DWORD grfUpdf,
2892 LPVOID pReserved)
2894 TRACE("(%p, %p, 0x%08x, %p)\n", This, pDataObject, grfUpdf, pReserved);
2895 return IOleCache2_RemoteUpdateCache_Proxy(This, pDataObject, grfUpdf, (LONG_PTR)pReserved);
2898 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2899 IOleCache2* This,
2900 LPDATAOBJECT pDataObject,
2901 DWORD grfUpdf,
2902 LONG_PTR pReserved)
2904 TRACE("(%p, %p, 0x%08x, %li)\n", This, pDataObject, grfUpdf, pReserved);
2905 return IOleCache2_UpdateCache(This, pDataObject, grfUpdf, (void*)pReserved);
2908 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2909 IEnumOLEVERB* This,
2910 ULONG celt,
2911 LPOLEVERB rgelt,
2912 ULONG *pceltFetched)
2914 ULONG fetched;
2915 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2916 if (!pceltFetched) pceltFetched = &fetched;
2917 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2920 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2921 IEnumOLEVERB* This,
2922 ULONG celt,
2923 LPOLEVERB rgelt,
2924 ULONG *pceltFetched)
2926 HRESULT hr;
2927 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2928 *pceltFetched = 0;
2929 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2930 if (hr == S_OK) *pceltFetched = celt;
2931 return hr;
2934 HRESULT CALLBACK IViewObject_Draw_Proxy(
2935 IViewObject* This,
2936 DWORD dwDrawAspect,
2937 LONG lindex,
2938 void *pvAspect,
2939 DVTARGETDEVICE *ptd,
2940 HDC hdcTargetDev,
2941 HDC hdcDraw,
2942 LPCRECTL lprcBounds,
2943 LPCRECTL lprcWBounds,
2944 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
2945 ULONG_PTR dwContinue)
2947 FIXME(":stub\n");
2948 return E_NOTIMPL;
2951 HRESULT __RPC_STUB IViewObject_Draw_Stub(
2952 IViewObject* This,
2953 DWORD dwDrawAspect,
2954 LONG lindex,
2955 ULONG_PTR pvAspect,
2956 DVTARGETDEVICE *ptd,
2957 ULONG_PTR hdcTargetDev,
2958 ULONG_PTR hdcDraw,
2959 LPCRECTL lprcBounds,
2960 LPCRECTL lprcWBounds,
2961 IContinue *pContinue)
2963 FIXME(":stub\n");
2964 return E_NOTIMPL;
2967 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
2968 IViewObject* This,
2969 DWORD dwDrawAspect,
2970 LONG lindex,
2971 void *pvAspect,
2972 DVTARGETDEVICE *ptd,
2973 HDC hicTargetDev,
2974 LOGPALETTE **ppColorSet)
2976 FIXME(":stub\n");
2977 return E_NOTIMPL;
2980 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
2981 IViewObject* This,
2982 DWORD dwDrawAspect,
2983 LONG lindex,
2984 ULONG_PTR pvAspect,
2985 DVTARGETDEVICE *ptd,
2986 ULONG_PTR hicTargetDev,
2987 LOGPALETTE **ppColorSet)
2989 FIXME(":stub\n");
2990 return E_NOTIMPL;
2993 HRESULT CALLBACK IViewObject_Freeze_Proxy(
2994 IViewObject* This,
2995 DWORD dwDrawAspect,
2996 LONG lindex,
2997 void *pvAspect,
2998 DWORD *pdwFreeze)
3000 FIXME(":stub\n");
3001 return E_NOTIMPL;
3004 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
3005 IViewObject* This,
3006 DWORD dwDrawAspect,
3007 LONG lindex,
3008 ULONG_PTR pvAspect,
3009 DWORD *pdwFreeze)
3011 FIXME(":stub\n");
3012 return E_NOTIMPL;
3015 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
3016 IViewObject* This,
3017 DWORD *pAspects,
3018 DWORD *pAdvf,
3019 IAdviseSink **ppAdvSink)
3021 FIXME(":stub\n");
3022 return E_NOTIMPL;
3025 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
3026 IViewObject* This,
3027 DWORD *pAspects,
3028 DWORD *pAdvf,
3029 IAdviseSink **ppAdvSink)
3031 FIXME(":stub\n");
3032 return E_NOTIMPL;