msvcirt: Add implementation of streambuf::sputbackc.
[wine.git] / dlls / ole32 / usrmarshal.c
blobfe8ff4febbf9c3e73d6800aa6d4fab87b42235b4
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;
1494 TRACE("(%s, %p, %p, %s)\n", debugstr_user_flags(pFlags), pBuffer, ppunk, debugstr_guid(riid));
1496 ALIGN_POINTER(pBuffer, 3);
1498 size = *(DWORD *)pBuffer;
1499 pBuffer += sizeof(DWORD);
1500 if(size != *(DWORD *)pBuffer)
1501 RaiseException(RPC_X_BAD_STUB_DATA, 0, 0, NULL);
1503 pBuffer += sizeof(DWORD);
1505 /* FIXME: sanity check on size */
1507 h = GlobalAlloc(GMEM_MOVEABLE, size);
1508 if(!h) RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1510 if(CreateStreamOnHGlobal(h, TRUE, &stm) != S_OK)
1512 GlobalFree(h);
1513 RaiseException(RPC_X_NO_MEMORY, 0, 0, NULL);
1516 ptr = GlobalLock(h);
1517 memcpy(ptr, pBuffer, size);
1518 GlobalUnlock(h);
1520 hr = CoUnmarshalInterface(stm, riid, (void**)ppunk);
1521 IStream_Release(stm);
1523 if(hr != S_OK) RaiseException(hr, 0, 0, NULL);
1525 return pBuffer + size;
1528 /******************************************************************************
1529 * WdtpInterfacePointer_UserFree [OLE32.@]
1531 * Releases an unmarshaled interface pointer.
1533 * PARAMS
1534 * punk [I] Interface pointer to release.
1536 * RETURNS
1537 * Nothing.
1539 void WINAPI WdtpInterfacePointer_UserFree(IUnknown *punk)
1541 TRACE("(%p)\n", punk);
1542 if(punk) IUnknown_Release(punk);
1545 /******************************************************************************
1546 * STGMEDIUM_UserSize [OLE32.@]
1548 * Calculates the buffer size required to marshal an STGMEDIUM.
1550 * PARAMS
1551 * pFlags [I] Flags. See notes.
1552 * StartingSize [I] Starting size of the buffer. This value is added on to
1553 * the buffer size required for the clip format.
1554 * pStgMedium [I] STGMEDIUM to size.
1556 * RETURNS
1557 * The buffer size required to marshal an STGMEDIUM plus the starting size.
1559 * NOTES
1560 * Even though the function is documented to take a pointer to a ULONG in
1561 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1562 * the first parameter is a ULONG.
1563 * This function is only intended to be called by the RPC runtime.
1565 ULONG __RPC_USER STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, STGMEDIUM *pStgMedium)
1567 ULONG size = StartingSize;
1569 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pStgMedium);
1571 ALIGN_LENGTH(size, 3);
1573 size += 2 * sizeof(DWORD);
1574 if (pStgMedium->tymed != TYMED_NULL)
1575 size += sizeof(DWORD);
1577 switch (pStgMedium->tymed)
1579 case TYMED_NULL:
1580 TRACE("TYMED_NULL\n");
1581 break;
1582 case TYMED_HGLOBAL:
1583 TRACE("TYMED_HGLOBAL\n");
1584 if (pStgMedium->u.hGlobal)
1585 size = HGLOBAL_UserSize(pFlags, size, &pStgMedium->u.hGlobal);
1586 break;
1587 case TYMED_FILE:
1588 TRACE("TYMED_FILE\n");
1589 if (pStgMedium->u.lpszFileName)
1591 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1592 size += 3 * sizeof(DWORD) +
1593 (strlenW(pStgMedium->u.lpszFileName) + 1) * sizeof(WCHAR);
1595 break;
1596 case TYMED_ISTREAM:
1597 TRACE("TYMED_ISTREAM\n");
1598 if (pStgMedium->u.pstm)
1600 IUnknown *unk;
1601 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1602 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStream);
1603 IUnknown_Release(unk);
1605 break;
1606 case TYMED_ISTORAGE:
1607 TRACE("TYMED_ISTORAGE\n");
1608 if (pStgMedium->u.pstg)
1610 IUnknown *unk;
1611 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1612 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, unk, &IID_IStorage);
1613 IUnknown_Release(unk);
1615 break;
1616 case TYMED_GDI:
1617 TRACE("TYMED_GDI\n");
1618 if (pStgMedium->u.hBitmap)
1620 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1622 break;
1623 case TYMED_MFPICT:
1624 TRACE("TYMED_MFPICT\n");
1625 if (pStgMedium->u.hMetaFilePict)
1626 size = HMETAFILEPICT_UserSize(pFlags, size, &pStgMedium->u.hMetaFilePict);
1627 break;
1628 case TYMED_ENHMF:
1629 TRACE("TYMED_ENHMF\n");
1630 if (pStgMedium->u.hEnhMetaFile)
1631 size = HENHMETAFILE_UserSize(pFlags, size, &pStgMedium->u.hEnhMetaFile);
1632 break;
1633 default:
1634 RaiseException(DV_E_TYMED, 0, 0, NULL);
1637 if (pStgMedium->pUnkForRelease)
1638 size = WdtpInterfacePointer_UserSize(pFlags, LOWORD(*pFlags), size, pStgMedium->pUnkForRelease, &IID_IUnknown);
1640 return size;
1643 /******************************************************************************
1644 * STGMEDIUM_UserMarshal [OLE32.@]
1646 * Marshals a STGMEDIUM into a buffer.
1648 * PARAMS
1649 * pFlags [I] Flags. See notes.
1650 * pBuffer [I] Buffer to marshal the clip format into.
1651 * pCF [I] STGMEDIUM to marshal.
1653 * RETURNS
1654 * The end of the marshaled data in the buffer.
1656 * NOTES
1657 * Even though the function is documented to take a pointer to a ULONG in
1658 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1659 * the first parameter is a ULONG.
1660 * This function is only intended to be called by the RPC runtime.
1662 unsigned char * __RPC_USER STGMEDIUM_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1664 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1666 ALIGN_POINTER(pBuffer, 3);
1668 *(DWORD *)pBuffer = pStgMedium->tymed;
1669 pBuffer += sizeof(DWORD);
1670 if (pStgMedium->tymed != TYMED_NULL)
1672 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->u.pstg;
1673 pBuffer += sizeof(DWORD);
1675 *(DWORD *)pBuffer = (DWORD)(DWORD_PTR)pStgMedium->pUnkForRelease;
1676 pBuffer += sizeof(DWORD);
1678 switch (pStgMedium->tymed)
1680 case TYMED_NULL:
1681 TRACE("TYMED_NULL\n");
1682 break;
1683 case TYMED_HGLOBAL:
1684 TRACE("TYMED_HGLOBAL\n");
1685 if (pStgMedium->u.hGlobal)
1686 pBuffer = HGLOBAL_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1687 break;
1688 case TYMED_FILE:
1689 TRACE("TYMED_FILE\n");
1690 if (pStgMedium->u.lpszFileName)
1692 DWORD len;
1693 len = strlenW(pStgMedium->u.lpszFileName);
1694 /* conformance */
1695 *(DWORD *)pBuffer = len + 1;
1696 pBuffer += sizeof(DWORD);
1697 /* offset */
1698 *(DWORD *)pBuffer = 0;
1699 pBuffer += sizeof(DWORD);
1700 /* variance */
1701 *(DWORD *)pBuffer = len + 1;
1702 pBuffer += sizeof(DWORD);
1704 TRACE("file name is %s\n", debugstr_w(pStgMedium->u.lpszFileName));
1705 memcpy(pBuffer, pStgMedium->u.lpszFileName, (len + 1) * sizeof(WCHAR));
1707 break;
1708 case TYMED_ISTREAM:
1709 TRACE("TYMED_ISTREAM\n");
1710 if (pStgMedium->u.pstm)
1712 IUnknown *unk;
1713 IStream_QueryInterface(pStgMedium->u.pstm, &IID_IUnknown, (void**)&unk);
1714 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStream);
1715 IUnknown_Release(unk);
1717 break;
1718 case TYMED_ISTORAGE:
1719 TRACE("TYMED_ISTORAGE\n");
1720 if (pStgMedium->u.pstg)
1722 IUnknown *unk;
1723 IStorage_QueryInterface(pStgMedium->u.pstg, &IID_IUnknown, (void**)&unk);
1724 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, unk, &IID_IStorage);
1725 IUnknown_Release(unk);
1727 break;
1728 case TYMED_GDI:
1729 TRACE("TYMED_GDI\n");
1730 if (pStgMedium->u.hBitmap)
1732 FIXME("not implemented for GDI object %p\n", pStgMedium->u.hBitmap);
1734 break;
1735 case TYMED_MFPICT:
1736 TRACE("TYMED_MFPICT\n");
1737 if (pStgMedium->u.hMetaFilePict)
1738 pBuffer = HMETAFILEPICT_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1739 break;
1740 case TYMED_ENHMF:
1741 TRACE("TYMED_ENHMF\n");
1742 if (pStgMedium->u.hEnhMetaFile)
1743 pBuffer = HENHMETAFILE_UserMarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1744 break;
1745 default:
1746 RaiseException(DV_E_TYMED, 0, 0, NULL);
1749 if (pStgMedium->pUnkForRelease)
1750 pBuffer = WdtpInterfacePointer_UserMarshal(pFlags, LOWORD(*pFlags), pBuffer, pStgMedium->pUnkForRelease, &IID_IUnknown);
1752 return pBuffer;
1755 /******************************************************************************
1756 * STGMEDIUM_UserUnmarshal [OLE32.@]
1758 * Unmarshals a STGMEDIUM from a buffer.
1760 * PARAMS
1761 * pFlags [I] Flags. See notes.
1762 * pBuffer [I] Buffer to marshal the clip format from.
1763 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
1765 * RETURNS
1766 * The end of the marshaled data in the buffer.
1768 * NOTES
1769 * Even though the function is documented to take a pointer to an ULONG in
1770 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
1771 * the first parameter is an ULONG.
1772 * This function is only intended to be called by the RPC runtime.
1774 unsigned char * __RPC_USER STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, STGMEDIUM *pStgMedium)
1776 DWORD content = 0;
1777 DWORD releaseunk;
1779 ALIGN_POINTER(pBuffer, 3);
1781 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags), pBuffer, pStgMedium);
1783 pStgMedium->tymed = *(DWORD *)pBuffer;
1784 pBuffer += sizeof(DWORD);
1785 if (pStgMedium->tymed != TYMED_NULL)
1787 content = *(DWORD *)pBuffer;
1788 pBuffer += sizeof(DWORD);
1790 releaseunk = *(DWORD *)pBuffer;
1791 pBuffer += sizeof(DWORD);
1793 switch (pStgMedium->tymed)
1795 case TYMED_NULL:
1796 TRACE("TYMED_NULL\n");
1797 break;
1798 case TYMED_HGLOBAL:
1799 TRACE("TYMED_HGLOBAL\n");
1800 if (content)
1801 pBuffer = HGLOBAL_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hGlobal);
1802 break;
1803 case TYMED_FILE:
1804 TRACE("TYMED_FILE\n");
1805 if (content)
1807 DWORD conformance;
1808 DWORD variance;
1809 conformance = *(DWORD *)pBuffer;
1810 pBuffer += sizeof(DWORD);
1811 if (*(DWORD *)pBuffer != 0)
1813 ERR("invalid offset %d\n", *(DWORD *)pBuffer);
1814 RpcRaiseException(RPC_S_INVALID_BOUND);
1815 return NULL;
1817 pBuffer += sizeof(DWORD);
1818 variance = *(DWORD *)pBuffer;
1819 pBuffer += sizeof(DWORD);
1820 if (conformance != variance)
1822 ERR("conformance (%d) and variance (%d) should be equal\n",
1823 conformance, variance);
1824 RpcRaiseException(RPC_S_INVALID_BOUND);
1825 return NULL;
1827 if (conformance > 0x7fffffff)
1829 ERR("conformance 0x%x too large\n", conformance);
1830 RpcRaiseException(RPC_S_INVALID_BOUND);
1831 return NULL;
1833 pStgMedium->u.lpszFileName = CoTaskMemAlloc(conformance * sizeof(WCHAR));
1834 if (!pStgMedium->u.lpszFileName) RpcRaiseException(ERROR_OUTOFMEMORY);
1835 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR *)pBuffer, variance));
1836 memcpy(pStgMedium->u.lpszFileName, pBuffer, variance * sizeof(WCHAR));
1837 pBuffer += variance * sizeof(WCHAR);
1839 else
1840 pStgMedium->u.lpszFileName = NULL;
1841 break;
1842 case TYMED_ISTREAM:
1843 TRACE("TYMED_ISTREAM\n");
1844 if (content)
1846 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstm, &IID_IStream);
1848 else
1849 pStgMedium->u.pstm = NULL;
1850 break;
1851 case TYMED_ISTORAGE:
1852 TRACE("TYMED_ISTORAGE\n");
1853 if (content)
1855 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, (IUnknown**)&pStgMedium->u.pstg, &IID_IStorage);
1857 else
1858 pStgMedium->u.pstg = NULL;
1859 break;
1860 case TYMED_GDI:
1861 TRACE("TYMED_GDI\n");
1862 if (content)
1864 FIXME("not implemented for GDI object\n");
1866 else
1867 pStgMedium->u.hBitmap = NULL;
1868 break;
1869 case TYMED_MFPICT:
1870 TRACE("TYMED_MFPICT\n");
1871 if (content)
1872 pBuffer = HMETAFILEPICT_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hMetaFilePict);
1873 else
1874 pStgMedium->u.hMetaFilePict = NULL;
1875 break;
1876 case TYMED_ENHMF:
1877 TRACE("TYMED_ENHMF\n");
1878 if (content)
1879 pBuffer = HENHMETAFILE_UserUnmarshal(pFlags, pBuffer, &pStgMedium->u.hEnhMetaFile);
1880 else
1881 pStgMedium->u.hEnhMetaFile = NULL;
1882 break;
1883 default:
1884 RaiseException(DV_E_TYMED, 0, 0, NULL);
1887 pStgMedium->pUnkForRelease = NULL;
1888 if (releaseunk)
1889 pBuffer = WdtpInterfacePointer_UserUnmarshal(pFlags, pBuffer, &pStgMedium->pUnkForRelease, &IID_IUnknown);
1891 return pBuffer;
1894 /******************************************************************************
1895 * STGMEDIUM_UserFree [OLE32.@]
1897 * Frees an unmarshaled STGMEDIUM.
1899 * PARAMS
1900 * pFlags [I] Flags. See notes.
1901 * pStgmedium [I] STGMEDIUM to free.
1903 * RETURNS
1904 * The end of the marshaled data in the buffer.
1906 * NOTES
1907 * Even though the function is documented to take a pointer to a ULONG in
1908 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1909 * which the first parameter is a ULONG.
1910 * This function is only intended to be called by the RPC runtime.
1912 void __RPC_USER STGMEDIUM_UserFree(ULONG *pFlags, STGMEDIUM *pStgMedium)
1914 TRACE("(%s, %p\n", debugstr_user_flags(pFlags), pStgMedium);
1916 ReleaseStgMedium(pStgMedium);
1919 ULONG __RPC_USER ASYNC_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, ASYNC_STGMEDIUM *pStgMedium)
1921 TRACE("\n");
1922 return STGMEDIUM_UserSize(pFlags, StartingSize, pStgMedium);
1925 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
1927 TRACE("\n");
1928 return STGMEDIUM_UserMarshal(pFlags, pBuffer, pStgMedium);
1931 unsigned char * __RPC_USER ASYNC_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, ASYNC_STGMEDIUM *pStgMedium)
1933 TRACE("\n");
1934 return STGMEDIUM_UserUnmarshal(pFlags, pBuffer, pStgMedium);
1937 void __RPC_USER ASYNC_STGMEDIUM_UserFree(ULONG *pFlags, ASYNC_STGMEDIUM *pStgMedium)
1939 TRACE("\n");
1940 STGMEDIUM_UserFree(pFlags, pStgMedium);
1943 ULONG __RPC_USER FLAG_STGMEDIUM_UserSize(ULONG *pFlags, ULONG StartingSize, FLAG_STGMEDIUM *pStgMedium)
1945 FIXME(":stub\n");
1946 return StartingSize;
1949 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserMarshal( ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
1951 FIXME(":stub\n");
1952 return pBuffer;
1955 unsigned char * __RPC_USER FLAG_STGMEDIUM_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, FLAG_STGMEDIUM *pStgMedium)
1957 FIXME(":stub\n");
1958 return pBuffer;
1961 void __RPC_USER FLAG_STGMEDIUM_UserFree(ULONG *pFlags, FLAG_STGMEDIUM *pStgMedium)
1963 FIXME(":stub\n");
1966 ULONG __RPC_USER SNB_UserSize(ULONG *pFlags, ULONG StartingSize, SNB *pSnb)
1968 ULONG size = StartingSize;
1970 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags), StartingSize, pSnb);
1972 ALIGN_LENGTH(size, 3);
1974 /* two counters from RemSNB header, plus one more ULONG */
1975 size += 3*sizeof(ULONG);
1977 /* now actual data length */
1978 if (*pSnb)
1980 WCHAR **ptrW = *pSnb;
1982 while (*ptrW)
1984 size += (strlenW(*ptrW) + 1)*sizeof(WCHAR);
1985 ptrW++;
1989 return size;
1992 struct SNB_wire {
1993 ULONG charcnt;
1994 ULONG strcnt;
1995 ULONG datalen;
1996 WCHAR data[1];
1999 unsigned char * __RPC_USER SNB_UserMarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2001 struct SNB_wire *wire;
2002 ULONG size;
2004 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2006 ALIGN_POINTER(pBuffer, 3);
2008 wire = (struct SNB_wire*)pBuffer;
2009 wire->charcnt = wire->strcnt = 0;
2010 size = 3*sizeof(ULONG);
2012 if (*pSnb)
2014 WCHAR **ptrW = *pSnb;
2015 WCHAR *dataW = wire->data;
2017 while (*ptrW)
2019 ULONG len = strlenW(*ptrW) + 1;
2021 wire->strcnt++;
2022 wire->charcnt += len;
2023 memcpy(dataW, *ptrW, len*sizeof(WCHAR));
2024 dataW += len;
2026 size += len*sizeof(WCHAR);
2027 ptrW++;
2031 wire->datalen = wire->charcnt;
2032 return pBuffer + size;
2035 unsigned char * __RPC_USER SNB_UserUnmarshal(ULONG *pFlags, unsigned char *pBuffer, SNB *pSnb)
2037 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2038 struct SNB_wire *wire;
2040 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags), pBuffer, pSnb);
2042 wire = (struct SNB_wire*)pBuffer;
2044 if (*pSnb)
2045 umcb->pStubMsg->pfnFree(*pSnb);
2047 if (wire->datalen == 0)
2048 *pSnb = NULL;
2049 else
2051 WCHAR *src = wire->data, *dest;
2052 WCHAR **ptrW;
2053 ULONG i;
2055 ptrW = *pSnb = umcb->pStubMsg->pfnAllocate((wire->strcnt+1)*sizeof(WCHAR*) + wire->datalen*sizeof(WCHAR));
2056 dest = (WCHAR*)(*pSnb + wire->strcnt + 1);
2058 for (i = 0; i < wire->strcnt; i++)
2060 ULONG len = strlenW(src);
2061 memcpy(dest, src, (len + 1)*sizeof(WCHAR));
2062 *ptrW = dest;
2063 src += len + 1;
2064 dest += len + 1;
2065 ptrW++;
2067 *ptrW = NULL;
2070 return pBuffer + 3*sizeof(ULONG) + wire->datalen*sizeof(WCHAR);
2073 void __RPC_USER SNB_UserFree(ULONG *pFlags, SNB *pSnb)
2075 USER_MARSHAL_CB *umcb = (USER_MARSHAL_CB*)pFlags;
2076 TRACE("(%p)\n", pSnb);
2077 if (*pSnb)
2078 umcb->pStubMsg->pfnFree(*pSnb);
2081 /* call_as/local stubs for unknwn.idl */
2083 HRESULT CALLBACK IClassFactory_CreateInstance_Proxy(
2084 IClassFactory* This,
2085 IUnknown *pUnkOuter,
2086 REFIID riid,
2087 void **ppvObject)
2089 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
2090 *ppvObject = NULL;
2091 if (pUnkOuter)
2093 ERR("aggregation is not allowed on remote objects\n");
2094 return CLASS_E_NOAGGREGATION;
2096 return IClassFactory_RemoteCreateInstance_Proxy(This, riid,
2097 (IUnknown **) ppvObject);
2100 HRESULT __RPC_STUB IClassFactory_CreateInstance_Stub(
2101 IClassFactory* This,
2102 REFIID riid,
2103 IUnknown **ppvObject)
2105 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObject);
2106 return IClassFactory_CreateInstance(This, NULL, riid, (void **) ppvObject);
2109 HRESULT CALLBACK IClassFactory_LockServer_Proxy(
2110 IClassFactory* This,
2111 BOOL fLock)
2113 FIXME(":stub\n");
2114 return E_NOTIMPL;
2117 HRESULT __RPC_STUB IClassFactory_LockServer_Stub(
2118 IClassFactory* This,
2119 BOOL fLock)
2121 FIXME(":stub\n");
2122 return E_NOTIMPL;
2125 /* call_as/local stubs for objidl.idl */
2127 HRESULT CALLBACK IEnumUnknown_Next_Proxy(
2128 IEnumUnknown* This,
2129 ULONG celt,
2130 IUnknown **rgelt,
2131 ULONG *pceltFetched)
2133 ULONG fetched;
2134 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2135 if (!pceltFetched) pceltFetched = &fetched;
2136 return IEnumUnknown_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2139 HRESULT __RPC_STUB IEnumUnknown_Next_Stub(
2140 IEnumUnknown* This,
2141 ULONG celt,
2142 IUnknown **rgelt,
2143 ULONG *pceltFetched)
2145 HRESULT hr;
2146 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2147 *pceltFetched = 0;
2148 hr = IEnumUnknown_Next(This, celt, rgelt, pceltFetched);
2149 if (hr == S_OK) *pceltFetched = celt;
2150 return hr;
2153 HRESULT CALLBACK IBindCtx_SetBindOptions_Proxy(
2154 IBindCtx* This,
2155 BIND_OPTS *pbindopts)
2157 FIXME(":stub\n");
2158 return E_NOTIMPL;
2161 HRESULT __RPC_STUB IBindCtx_SetBindOptions_Stub(
2162 IBindCtx* This,
2163 BIND_OPTS2 *pbindopts)
2165 FIXME(":stub\n");
2166 return E_NOTIMPL;
2169 HRESULT CALLBACK IBindCtx_GetBindOptions_Proxy(
2170 IBindCtx* This,
2171 BIND_OPTS *pbindopts)
2173 FIXME(":stub\n");
2174 return E_NOTIMPL;
2177 HRESULT __RPC_STUB IBindCtx_GetBindOptions_Stub(
2178 IBindCtx* This,
2179 BIND_OPTS2 *pbindopts)
2181 FIXME(":stub\n");
2182 return E_NOTIMPL;
2185 HRESULT CALLBACK IEnumMoniker_Next_Proxy(
2186 IEnumMoniker* This,
2187 ULONG celt,
2188 IMoniker **rgelt,
2189 ULONG *pceltFetched)
2191 ULONG fetched;
2192 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2193 if (!pceltFetched) pceltFetched = &fetched;
2194 return IEnumMoniker_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2197 HRESULT __RPC_STUB IEnumMoniker_Next_Stub(
2198 IEnumMoniker* This,
2199 ULONG celt,
2200 IMoniker **rgelt,
2201 ULONG *pceltFetched)
2203 HRESULT hr;
2204 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2205 *pceltFetched = 0;
2206 hr = IEnumMoniker_Next(This, celt, rgelt, pceltFetched);
2207 if (hr == S_OK) *pceltFetched = celt;
2208 return hr;
2211 BOOL CALLBACK IRunnableObject_IsRunning_Proxy(
2212 IRunnableObject* This)
2214 BOOL rv;
2215 FIXME(":stub\n");
2216 memset(&rv, 0, sizeof rv);
2217 return rv;
2220 HRESULT __RPC_STUB IRunnableObject_IsRunning_Stub(
2221 IRunnableObject* This)
2223 FIXME(":stub\n");
2224 return E_NOTIMPL;
2227 HRESULT CALLBACK IMoniker_BindToObject_Proxy(
2228 IMoniker* This,
2229 IBindCtx *pbc,
2230 IMoniker *pmkToLeft,
2231 REFIID riidResult,
2232 void **ppvResult)
2234 FIXME(":stub\n");
2235 return E_NOTIMPL;
2238 HRESULT __RPC_STUB IMoniker_BindToObject_Stub(
2239 IMoniker* This,
2240 IBindCtx *pbc,
2241 IMoniker *pmkToLeft,
2242 REFIID riidResult,
2243 IUnknown **ppvResult)
2245 FIXME(":stub\n");
2246 return E_NOTIMPL;
2249 HRESULT CALLBACK IMoniker_BindToStorage_Proxy(
2250 IMoniker* This,
2251 IBindCtx *pbc,
2252 IMoniker *pmkToLeft,
2253 REFIID riid,
2254 void **ppvObj)
2256 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2257 return IMoniker_RemoteBindToStorage_Proxy(This, pbc, pmkToLeft, riid, (IUnknown**)ppvObj);
2260 HRESULT __RPC_STUB IMoniker_BindToStorage_Stub(
2261 IMoniker* This,
2262 IBindCtx *pbc,
2263 IMoniker *pmkToLeft,
2264 REFIID riid,
2265 IUnknown **ppvObj)
2267 TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
2268 return IMoniker_BindToStorage(This, pbc, pmkToLeft, riid, (void**)ppvObj);
2271 HRESULT CALLBACK IEnumString_Next_Proxy(
2272 IEnumString* This,
2273 ULONG celt,
2274 LPOLESTR *rgelt,
2275 ULONG *pceltFetched)
2277 ULONG fetched;
2278 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2279 if (!pceltFetched) pceltFetched = &fetched;
2280 return IEnumString_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2283 HRESULT __RPC_STUB IEnumString_Next_Stub(
2284 IEnumString* This,
2285 ULONG celt,
2286 LPOLESTR *rgelt,
2287 ULONG *pceltFetched)
2289 HRESULT hr;
2290 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2291 *pceltFetched = 0;
2292 hr = IEnumString_Next(This, celt, rgelt, pceltFetched);
2293 if (hr == S_OK) *pceltFetched = celt;
2294 return hr;
2297 HRESULT CALLBACK ISequentialStream_Read_Proxy(
2298 ISequentialStream* This,
2299 void *pv,
2300 ULONG cb,
2301 ULONG *pcbRead)
2303 ULONG read;
2304 HRESULT hr;
2306 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2308 hr = ISequentialStream_RemoteRead_Proxy(This, pv, cb, &read);
2309 if(pcbRead) *pcbRead = read;
2311 return hr;
2314 HRESULT __RPC_STUB ISequentialStream_Read_Stub(
2315 ISequentialStream* This,
2316 byte *pv,
2317 ULONG cb,
2318 ULONG *pcbRead)
2320 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbRead);
2321 return ISequentialStream_Read(This, pv, cb, pcbRead);
2324 HRESULT CALLBACK ISequentialStream_Write_Proxy(
2325 ISequentialStream* This,
2326 const void *pv,
2327 ULONG cb,
2328 ULONG *pcbWritten)
2330 ULONG written;
2331 HRESULT hr;
2333 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2335 hr = ISequentialStream_RemoteWrite_Proxy(This, pv, cb, &written);
2336 if(pcbWritten) *pcbWritten = written;
2338 return hr;
2341 HRESULT __RPC_STUB ISequentialStream_Write_Stub(
2342 ISequentialStream* This,
2343 const byte *pv,
2344 ULONG cb,
2345 ULONG *pcbWritten)
2347 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2348 return ISequentialStream_Write(This, pv, cb, pcbWritten);
2351 HRESULT CALLBACK IStream_Seek_Proxy(
2352 IStream* This,
2353 LARGE_INTEGER dlibMove,
2354 DWORD dwOrigin,
2355 ULARGE_INTEGER *plibNewPosition)
2357 ULARGE_INTEGER newpos;
2358 HRESULT hr;
2360 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2362 hr = IStream_RemoteSeek_Proxy(This, dlibMove, dwOrigin, &newpos);
2363 if(plibNewPosition) *plibNewPosition = newpos;
2365 return hr;
2368 HRESULT __RPC_STUB IStream_Seek_Stub(
2369 IStream* This,
2370 LARGE_INTEGER dlibMove,
2371 DWORD dwOrigin,
2372 ULARGE_INTEGER *plibNewPosition)
2374 TRACE("(%p)->(%s, %d, %p)\n", This, wine_dbgstr_longlong(dlibMove.QuadPart), dwOrigin, plibNewPosition);
2375 return IStream_Seek(This, dlibMove, dwOrigin, plibNewPosition);
2378 HRESULT CALLBACK IStream_CopyTo_Proxy(
2379 IStream* This,
2380 IStream *pstm,
2381 ULARGE_INTEGER cb,
2382 ULARGE_INTEGER *pcbRead,
2383 ULARGE_INTEGER *pcbWritten)
2385 ULARGE_INTEGER read, written;
2386 HRESULT hr;
2388 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2390 hr = IStream_RemoteCopyTo_Proxy(This, pstm, cb, &read, &written);
2391 if(pcbRead) *pcbRead = read;
2392 if(pcbWritten) *pcbWritten = written;
2394 return hr;
2397 HRESULT __RPC_STUB IStream_CopyTo_Stub(
2398 IStream* This,
2399 IStream *pstm,
2400 ULARGE_INTEGER cb,
2401 ULARGE_INTEGER *pcbRead,
2402 ULARGE_INTEGER *pcbWritten)
2404 TRACE("(%p)->(%p, %s, %p, %p)\n", This, pstm, wine_dbgstr_longlong(cb.QuadPart), pcbRead, pcbWritten);
2406 return IStream_CopyTo(This, pstm, cb, pcbRead, pcbWritten);
2409 HRESULT CALLBACK IEnumSTATSTG_Next_Proxy(
2410 IEnumSTATSTG* This,
2411 ULONG celt,
2412 STATSTG *rgelt,
2413 ULONG *pceltFetched)
2415 ULONG fetched;
2416 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2417 if (!pceltFetched) pceltFetched = &fetched;
2418 return IEnumSTATSTG_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2421 HRESULT __RPC_STUB IEnumSTATSTG_Next_Stub(
2422 IEnumSTATSTG* This,
2423 ULONG celt,
2424 STATSTG *rgelt,
2425 ULONG *pceltFetched)
2427 HRESULT hr;
2428 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2429 *pceltFetched = 0;
2430 hr = IEnumSTATSTG_Next(This, celt, rgelt, pceltFetched);
2431 if (hr == S_OK) *pceltFetched = celt;
2432 return hr;
2435 HRESULT CALLBACK IStorage_OpenStream_Proxy(
2436 IStorage* This,
2437 LPCOLESTR pwcsName,
2438 void *reserved1,
2439 DWORD grfMode,
2440 DWORD reserved2,
2441 IStream **ppstm)
2443 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
2444 if(reserved1) WARN("reserved1 %p\n", reserved1);
2446 return IStorage_RemoteOpenStream_Proxy(This, pwcsName, 0, NULL, grfMode, reserved2, ppstm);
2449 HRESULT __RPC_STUB IStorage_OpenStream_Stub(
2450 IStorage* This,
2451 LPCOLESTR pwcsName,
2452 ULONG cbReserved1,
2453 byte *reserved1,
2454 DWORD grfMode,
2455 DWORD reserved2,
2456 IStream **ppstm)
2458 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This, debugstr_w(pwcsName), cbReserved1, reserved1, grfMode, reserved2, ppstm);
2459 if(cbReserved1 || reserved1) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1, reserved1);
2461 return IStorage_OpenStream(This, pwcsName, NULL, grfMode, reserved2, ppstm);
2464 HRESULT CALLBACK IStorage_EnumElements_Proxy(
2465 IStorage* This,
2466 DWORD reserved1,
2467 void *reserved2,
2468 DWORD reserved3,
2469 IEnumSTATSTG **ppenum)
2471 TRACE("(%p)->(%d, %p, %d, %p)\n", This, reserved1, reserved2, reserved3, ppenum);
2472 if(reserved2) WARN("reserved2 %p\n", reserved2);
2474 return IStorage_RemoteEnumElements_Proxy(This, reserved1, 0, NULL, reserved3, ppenum);
2477 HRESULT __RPC_STUB IStorage_EnumElements_Stub(
2478 IStorage* This,
2479 DWORD reserved1,
2480 ULONG cbReserved2,
2481 byte *reserved2,
2482 DWORD reserved3,
2483 IEnumSTATSTG **ppenum)
2485 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This, reserved1, cbReserved2, reserved2, reserved3, ppenum);
2486 if(cbReserved2 || reserved2) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2, reserved2);
2488 return IStorage_EnumElements(This, reserved1, NULL, reserved3, ppenum);
2491 HRESULT CALLBACK ILockBytes_ReadAt_Proxy(
2492 ILockBytes* This,
2493 ULARGE_INTEGER ulOffset,
2494 void *pv,
2495 ULONG cb,
2496 ULONG *pcbRead)
2498 ULONG read;
2499 HRESULT hr;
2501 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2503 hr = ILockBytes_RemoteReadAt_Proxy(This, ulOffset, pv, cb, &read);
2504 if(pcbRead) *pcbRead = read;
2506 return hr;
2509 HRESULT __RPC_STUB ILockBytes_ReadAt_Stub(
2510 ILockBytes* This,
2511 ULARGE_INTEGER ulOffset,
2512 byte *pv,
2513 ULONG cb,
2514 ULONG *pcbRead)
2516 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbRead);
2517 return ILockBytes_ReadAt(This, ulOffset, pv, cb, pcbRead);
2520 HRESULT CALLBACK ILockBytes_WriteAt_Proxy(
2521 ILockBytes* This,
2522 ULARGE_INTEGER ulOffset,
2523 const void *pv,
2524 ULONG cb,
2525 ULONG *pcbWritten)
2527 ULONG written;
2528 HRESULT hr;
2530 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2532 hr = ILockBytes_RemoteWriteAt_Proxy(This, ulOffset, pv, cb, &written);
2533 if(pcbWritten) *pcbWritten = written;
2535 return hr;
2538 HRESULT __RPC_STUB ILockBytes_WriteAt_Stub(
2539 ILockBytes* This,
2540 ULARGE_INTEGER ulOffset,
2541 const byte *pv,
2542 ULONG cb,
2543 ULONG *pcbWritten)
2545 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2546 return ILockBytes_WriteAt(This, ulOffset, pv, cb, pcbWritten);
2549 HRESULT CALLBACK IFillLockBytes_FillAppend_Proxy(
2550 IFillLockBytes* This,
2551 const void *pv,
2552 ULONG cb,
2553 ULONG *pcbWritten)
2555 ULONG written;
2556 HRESULT hr;
2558 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2560 hr = IFillLockBytes_RemoteFillAppend_Proxy(This, pv, cb, &written);
2561 if(pcbWritten) *pcbWritten = written;
2563 return hr;
2566 HRESULT __RPC_STUB IFillLockBytes_FillAppend_Stub(
2567 IFillLockBytes* This,
2568 const byte *pv,
2569 ULONG cb,
2570 ULONG *pcbWritten)
2572 TRACE("(%p)->(%p, %d, %p)\n", This, pv, cb, pcbWritten);
2573 return IFillLockBytes_FillAppend(This, pv, cb, pcbWritten);
2576 HRESULT CALLBACK IFillLockBytes_FillAt_Proxy(
2577 IFillLockBytes* This,
2578 ULARGE_INTEGER ulOffset,
2579 const void *pv,
2580 ULONG cb,
2581 ULONG *pcbWritten)
2583 ULONG written;
2584 HRESULT hr;
2586 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2588 hr = IFillLockBytes_RemoteFillAt_Proxy(This, ulOffset, pv, cb, &written);
2589 if(pcbWritten) *pcbWritten = written;
2591 return hr;
2594 HRESULT __RPC_STUB IFillLockBytes_FillAt_Stub(
2595 IFillLockBytes* This,
2596 ULARGE_INTEGER ulOffset,
2597 const byte *pv,
2598 ULONG cb,
2599 ULONG *pcbWritten)
2601 TRACE("(%p)->(%s, %p, %d, %p)\n", This, wine_dbgstr_longlong(ulOffset.QuadPart), pv, cb, pcbWritten);
2602 return IFillLockBytes_FillAt(This, ulOffset, pv, cb, pcbWritten);
2605 HRESULT CALLBACK IEnumFORMATETC_Next_Proxy(
2606 IEnumFORMATETC* This,
2607 ULONG celt,
2608 FORMATETC *rgelt,
2609 ULONG *pceltFetched)
2611 ULONG fetched;
2612 if (!pceltFetched) pceltFetched = &fetched;
2613 return IEnumFORMATETC_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2616 HRESULT __RPC_STUB IEnumFORMATETC_Next_Stub(
2617 IEnumFORMATETC* This,
2618 ULONG celt,
2619 FORMATETC *rgelt,
2620 ULONG *pceltFetched)
2622 HRESULT hr;
2623 *pceltFetched = 0;
2624 hr = IEnumFORMATETC_Next(This, celt, rgelt, pceltFetched);
2625 if (hr == S_OK) *pceltFetched = celt;
2626 return hr;
2629 HRESULT CALLBACK IEnumSTATDATA_Next_Proxy(
2630 IEnumSTATDATA* This,
2631 ULONG celt,
2632 STATDATA *rgelt,
2633 ULONG *pceltFetched)
2635 ULONG fetched;
2636 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2637 if (!pceltFetched) pceltFetched = &fetched;
2638 return IEnumSTATDATA_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2641 HRESULT __RPC_STUB IEnumSTATDATA_Next_Stub(
2642 IEnumSTATDATA* This,
2643 ULONG celt,
2644 STATDATA *rgelt,
2645 ULONG *pceltFetched)
2647 HRESULT hr;
2648 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2649 *pceltFetched = 0;
2650 hr = IEnumSTATDATA_Next(This, celt, rgelt, pceltFetched);
2651 if (hr == S_OK) *pceltFetched = celt;
2652 return hr;
2655 void CALLBACK IAdviseSink_OnDataChange_Proxy(
2656 IAdviseSink* This,
2657 FORMATETC *pFormatetc,
2658 STGMEDIUM *pStgmed)
2660 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2661 IAdviseSink_RemoteOnDataChange_Proxy(This, pFormatetc, pStgmed);
2664 HRESULT __RPC_STUB IAdviseSink_OnDataChange_Stub(
2665 IAdviseSink* This,
2666 FORMATETC *pFormatetc,
2667 ASYNC_STGMEDIUM *pStgmed)
2669 TRACE("(%p)->(%p, %p)\n", This, pFormatetc, pStgmed);
2670 IAdviseSink_OnDataChange(This, pFormatetc, pStgmed);
2671 return S_OK;
2674 void CALLBACK IAdviseSink_OnViewChange_Proxy(
2675 IAdviseSink* This,
2676 DWORD dwAspect,
2677 LONG lindex)
2679 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2680 IAdviseSink_RemoteOnViewChange_Proxy(This, dwAspect, lindex);
2683 HRESULT __RPC_STUB IAdviseSink_OnViewChange_Stub(
2684 IAdviseSink* This,
2685 DWORD dwAspect,
2686 LONG lindex)
2688 TRACE("(%p)->(%d, %d)\n", This, dwAspect, lindex);
2689 IAdviseSink_OnViewChange(This, dwAspect, lindex);
2690 return S_OK;
2693 void CALLBACK IAdviseSink_OnRename_Proxy(
2694 IAdviseSink* This,
2695 IMoniker *pmk)
2697 TRACE("(%p)->(%p)\n", This, pmk);
2698 IAdviseSink_RemoteOnRename_Proxy(This, pmk);
2701 HRESULT __RPC_STUB IAdviseSink_OnRename_Stub(
2702 IAdviseSink* This,
2703 IMoniker *pmk)
2705 TRACE("(%p)->(%p)\n", This, pmk);
2706 IAdviseSink_OnRename(This, pmk);
2707 return S_OK;
2710 void CALLBACK IAdviseSink_OnSave_Proxy(
2711 IAdviseSink* This)
2713 TRACE("(%p)\n", This);
2714 IAdviseSink_RemoteOnSave_Proxy(This);
2717 HRESULT __RPC_STUB IAdviseSink_OnSave_Stub(
2718 IAdviseSink* This)
2720 TRACE("(%p)\n", This);
2721 IAdviseSink_OnSave(This);
2722 return S_OK;
2725 void CALLBACK IAdviseSink_OnClose_Proxy(
2726 IAdviseSink* This)
2728 TRACE("(%p)\n", This);
2729 IAdviseSink_RemoteOnClose_Proxy(This);
2732 HRESULT __RPC_STUB IAdviseSink_OnClose_Stub(
2733 IAdviseSink* This)
2735 TRACE("(%p)\n", This);
2736 IAdviseSink_OnClose(This);
2737 return S_OK;
2740 void CALLBACK IAdviseSink2_OnLinkSrcChange_Proxy(
2741 IAdviseSink2* This,
2742 IMoniker *pmk)
2744 TRACE("(%p)->(%p)\n", This, pmk);
2745 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This, pmk);
2748 HRESULT __RPC_STUB IAdviseSink2_OnLinkSrcChange_Stub(
2749 IAdviseSink2* This,
2750 IMoniker *pmk)
2752 TRACE("(%p)->(%p)\n", This, pmk);
2753 IAdviseSink2_OnLinkSrcChange(This, pmk);
2754 return S_OK;
2757 HRESULT CALLBACK IDataObject_GetData_Proxy(
2758 IDataObject* This,
2759 FORMATETC *pformatetcIn,
2760 STGMEDIUM *pmedium)
2762 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pmedium);
2763 return IDataObject_RemoteGetData_Proxy(This, pformatetcIn, pmedium);
2766 HRESULT __RPC_STUB IDataObject_GetData_Stub(
2767 IDataObject* This,
2768 FORMATETC *pformatetcIn,
2769 STGMEDIUM *pRemoteMedium)
2771 TRACE("(%p)->(%p, %p)\n", This, pformatetcIn, pRemoteMedium);
2772 return IDataObject_GetData(This, pformatetcIn, pRemoteMedium);
2775 HRESULT CALLBACK IDataObject_GetDataHere_Proxy(
2776 IDataObject* This,
2777 FORMATETC *pformatetc,
2778 STGMEDIUM *pmedium)
2780 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pmedium);
2781 return IDataObject_RemoteGetDataHere_Proxy(This, pformatetc, pmedium);
2784 HRESULT __RPC_STUB IDataObject_GetDataHere_Stub(
2785 IDataObject* This,
2786 FORMATETC *pformatetc,
2787 STGMEDIUM *pRemoteMedium)
2789 TRACE("(%p)->(%p, %p)\n", This, pformatetc, pRemoteMedium);
2790 return IDataObject_GetDataHere(This, pformatetc, pRemoteMedium);
2793 HRESULT CALLBACK IDataObject_SetData_Proxy(
2794 IDataObject* This,
2795 FORMATETC *pformatetc,
2796 STGMEDIUM *pmedium,
2797 BOOL fRelease)
2799 FIXME(":stub\n");
2800 return E_NOTIMPL;
2803 HRESULT __RPC_STUB IDataObject_SetData_Stub(
2804 IDataObject* This,
2805 FORMATETC *pformatetc,
2806 FLAG_STGMEDIUM *pmedium,
2807 BOOL fRelease)
2809 FIXME(":stub\n");
2810 return E_NOTIMPL;
2813 /* call_as/local stubs for oleidl.idl */
2815 HRESULT CALLBACK IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2816 IOleInPlaceActiveObject* This,
2817 LPMSG lpmsg)
2819 TRACE("(%p %p)\n", This, lpmsg);
2820 return IOleInPlaceActiveObject_RemoteTranslateAccelerator_Proxy(This);
2823 HRESULT __RPC_STUB IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2824 IOleInPlaceActiveObject* This)
2826 TRACE("(%p)\n", This);
2827 return S_FALSE;
2830 HRESULT CALLBACK IOleInPlaceActiveObject_ResizeBorder_Proxy(
2831 IOleInPlaceActiveObject* This,
2832 LPCRECT prcBorder,
2833 IOleInPlaceUIWindow *pUIWindow,
2834 BOOL fFrameWindow)
2836 FIXME(":stub\n");
2837 return E_NOTIMPL;
2840 HRESULT __RPC_STUB IOleInPlaceActiveObject_ResizeBorder_Stub(
2841 IOleInPlaceActiveObject* This,
2842 LPCRECT prcBorder,
2843 REFIID riid,
2844 IOleInPlaceUIWindow *pUIWindow,
2845 BOOL fFrameWindow)
2847 FIXME(":stub\n");
2848 return E_NOTIMPL;
2851 HRESULT CALLBACK IOleCache2_UpdateCache_Proxy(
2852 IOleCache2* This,
2853 LPDATAOBJECT pDataObject,
2854 DWORD grfUpdf,
2855 LPVOID pReserved)
2857 TRACE("(%p, %p, 0x%08x, %p)\n", This, pDataObject, grfUpdf, pReserved);
2858 return IOleCache2_RemoteUpdateCache_Proxy(This, pDataObject, grfUpdf, (LONG_PTR)pReserved);
2861 HRESULT __RPC_STUB IOleCache2_UpdateCache_Stub(
2862 IOleCache2* This,
2863 LPDATAOBJECT pDataObject,
2864 DWORD grfUpdf,
2865 LONG_PTR pReserved)
2867 TRACE("(%p, %p, 0x%08x, %li)\n", This, pDataObject, grfUpdf, pReserved);
2868 return IOleCache2_UpdateCache(This, pDataObject, grfUpdf, (void*)pReserved);
2871 HRESULT CALLBACK IEnumOLEVERB_Next_Proxy(
2872 IEnumOLEVERB* This,
2873 ULONG celt,
2874 LPOLEVERB rgelt,
2875 ULONG *pceltFetched)
2877 ULONG fetched;
2878 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2879 if (!pceltFetched) pceltFetched = &fetched;
2880 return IEnumOLEVERB_RemoteNext_Proxy(This, celt, rgelt, pceltFetched);
2883 HRESULT __RPC_STUB IEnumOLEVERB_Next_Stub(
2884 IEnumOLEVERB* This,
2885 ULONG celt,
2886 LPOLEVERB rgelt,
2887 ULONG *pceltFetched)
2889 HRESULT hr;
2890 TRACE("(%p)->(%d, %p, %p)\n", This, celt, rgelt, pceltFetched);
2891 *pceltFetched = 0;
2892 hr = IEnumOLEVERB_Next(This, celt, rgelt, pceltFetched);
2893 if (hr == S_OK) *pceltFetched = celt;
2894 return hr;
2897 HRESULT CALLBACK IViewObject_Draw_Proxy(
2898 IViewObject* This,
2899 DWORD dwDrawAspect,
2900 LONG lindex,
2901 void *pvAspect,
2902 DVTARGETDEVICE *ptd,
2903 HDC hdcTargetDev,
2904 HDC hdcDraw,
2905 LPCRECTL lprcBounds,
2906 LPCRECTL lprcWBounds,
2907 BOOL (STDMETHODCALLTYPE *pfnContinue)(ULONG_PTR dwContinue),
2908 ULONG_PTR dwContinue)
2910 FIXME(":stub\n");
2911 return E_NOTIMPL;
2914 HRESULT __RPC_STUB IViewObject_Draw_Stub(
2915 IViewObject* This,
2916 DWORD dwDrawAspect,
2917 LONG lindex,
2918 ULONG_PTR pvAspect,
2919 DVTARGETDEVICE *ptd,
2920 ULONG_PTR hdcTargetDev,
2921 ULONG_PTR hdcDraw,
2922 LPCRECTL lprcBounds,
2923 LPCRECTL lprcWBounds,
2924 IContinue *pContinue)
2926 FIXME(":stub\n");
2927 return E_NOTIMPL;
2930 HRESULT CALLBACK IViewObject_GetColorSet_Proxy(
2931 IViewObject* This,
2932 DWORD dwDrawAspect,
2933 LONG lindex,
2934 void *pvAspect,
2935 DVTARGETDEVICE *ptd,
2936 HDC hicTargetDev,
2937 LOGPALETTE **ppColorSet)
2939 FIXME(":stub\n");
2940 return E_NOTIMPL;
2943 HRESULT __RPC_STUB IViewObject_GetColorSet_Stub(
2944 IViewObject* This,
2945 DWORD dwDrawAspect,
2946 LONG lindex,
2947 ULONG_PTR pvAspect,
2948 DVTARGETDEVICE *ptd,
2949 ULONG_PTR hicTargetDev,
2950 LOGPALETTE **ppColorSet)
2952 FIXME(":stub\n");
2953 return E_NOTIMPL;
2956 HRESULT CALLBACK IViewObject_Freeze_Proxy(
2957 IViewObject* This,
2958 DWORD dwDrawAspect,
2959 LONG lindex,
2960 void *pvAspect,
2961 DWORD *pdwFreeze)
2963 FIXME(":stub\n");
2964 return E_NOTIMPL;
2967 HRESULT __RPC_STUB IViewObject_Freeze_Stub(
2968 IViewObject* This,
2969 DWORD dwDrawAspect,
2970 LONG lindex,
2971 ULONG_PTR pvAspect,
2972 DWORD *pdwFreeze)
2974 FIXME(":stub\n");
2975 return E_NOTIMPL;
2978 HRESULT CALLBACK IViewObject_GetAdvise_Proxy(
2979 IViewObject* This,
2980 DWORD *pAspects,
2981 DWORD *pAdvf,
2982 IAdviseSink **ppAdvSink)
2984 FIXME(":stub\n");
2985 return E_NOTIMPL;
2988 HRESULT __RPC_STUB IViewObject_GetAdvise_Stub(
2989 IViewObject* This,
2990 DWORD *pAspects,
2991 DWORD *pAdvf,
2992 IAdviseSink **ppAdvSink)
2994 FIXME(":stub\n");
2995 return E_NOTIMPL;