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
26 #define NONAMELESSUNION
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
42 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
43 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
44 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
45 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
47 #define USER_MARSHAL_PTR_PREFIX \
48 ( (DWORD)'U' | ( (DWORD)'s' << 8 ) | \
49 ( (DWORD)'e' << 16 ) | ( (DWORD)'r' << 24 ) )
51 ULONG __RPC_USER
WdtpInterfacePointer_UserSize(ULONG
*pFlags
, ULONG RealFlags
, ULONG StartingSize
, IUnknown
*punk
, REFIID riid
);
52 unsigned char * WINAPI
WdtpInterfacePointer_UserMarshal(ULONG
*pFlags
, ULONG RealFlags
, unsigned char *pBuffer
,
53 IUnknown
*punk
, REFIID riid
);
54 unsigned char * WINAPI
WdtpInterfacePointer_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, IUnknown
**ppunk
, REFIID riid
);
56 static const char* debugstr_user_flags(ULONG
*pFlags
)
60 switch (LOWORD(*pFlags
))
63 loword
="MSHCTX_LOCAL";
65 case MSHCTX_NOSHAREDMEM
:
66 loword
="MSHCTX_NOSHAREDMEM";
68 case MSHCTX_DIFFERENTMACHINE
:
69 loword
="MSHCTX_DIFFERENTMACHINE";
72 loword
="MSHCTX_INPROC";
75 sprintf(buf
, "%d", LOWORD(*pFlags
));
79 if (HIWORD(*pFlags
) == NDR_LOCAL_DATA_REPRESENTATION
)
80 return wine_dbg_sprintf("MAKELONG(%s, NDR_LOCAL_DATA_REPRESENTATION)", loword
);
82 return wine_dbg_sprintf("MAKELONG(%s, 0x%04x)", loword
, HIWORD(*pFlags
));
85 /******************************************************************************
86 * HMETAFILE_UserSize [OLE32.@]
88 * Calculates the buffer size required to marshal a metafile.
91 * pFlags [I] Flags. See notes.
92 * StartingSize [I] Starting size of the buffer. This value is added on to
93 * the buffer size required for the clip format.
94 * phmf [I] Metafile to size.
97 * The buffer size required to marshal a metafile plus the starting size.
100 * Even though the function is documented to take a pointer to a ULONG in
101 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
102 * the first parameter is a ULONG.
103 * This function is only intended to be called by the RPC runtime.
105 ULONG __RPC_USER
HMETAFILE_UserSize(ULONG
*pFlags
, ULONG StartingSize
, HMETAFILE
*phmf
)
107 ULONG size
= StartingSize
;
109 TRACE("(%s, %d, &%p\n", debugstr_user_flags(pFlags
), StartingSize
, *phmf
);
111 ALIGN_LENGTH(size
, 3);
113 size
+= sizeof(ULONG
);
114 if (LOWORD(*pFlags
) == MSHCTX_INPROC
)
115 size
+= sizeof(ULONG_PTR
);
118 size
+= sizeof(ULONG
);
124 size
+= 2 * sizeof(ULONG
);
125 mfsize
= GetMetaFileBitsEx(*phmf
, 0, NULL
);
133 /******************************************************************************
134 * HMETAFILE_UserMarshal [OLE32.@]
136 * Marshals a metafile into a buffer.
139 * pFlags [I] Flags. See notes.
140 * pBuffer [I] Buffer to marshal the clip format into.
141 * phEmf [I] Metafile to marshal.
144 * The end of the marshaled data in the buffer.
147 * Even though the function is documented to take a pointer to a ULONG in
148 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
149 * the first parameter is a ULONG.
150 * This function is only intended to be called by the RPC runtime.
152 unsigned char * __RPC_USER
HMETAFILE_UserMarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HMETAFILE
*phmf
)
154 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags
), pBuffer
, *phmf
);
156 ALIGN_POINTER(pBuffer
, 3);
158 if (LOWORD(*pFlags
) == MSHCTX_INPROC
)
160 if (sizeof(*phmf
) == 8)
161 *(ULONG
*)pBuffer
= WDT_INPROC64_CALL
;
163 *(ULONG
*)pBuffer
= WDT_INPROC_CALL
;
164 pBuffer
+= sizeof(ULONG
);
165 *(HMETAFILE
*)pBuffer
= *phmf
;
166 pBuffer
+= sizeof(HMETAFILE
);
170 *(ULONG
*)pBuffer
= WDT_REMOTE_CALL
;
171 pBuffer
+= sizeof(ULONG
);
172 *(ULONG
*)pBuffer
= (ULONG
)(ULONG_PTR
)*phmf
;
173 pBuffer
+= sizeof(ULONG
);
177 UINT mfsize
= GetMetaFileBitsEx(*phmf
, 0, NULL
);
179 *(ULONG
*)pBuffer
= mfsize
;
180 pBuffer
+= sizeof(ULONG
);
181 *(ULONG
*)pBuffer
= mfsize
;
182 pBuffer
+= sizeof(ULONG
);
183 GetMetaFileBitsEx(*phmf
, mfsize
, pBuffer
);
191 /******************************************************************************
192 * HMETAFILE_UserUnmarshal [OLE32.@]
194 * Unmarshals a metafile from a buffer.
197 * pFlags [I] Flags. See notes.
198 * pBuffer [I] Buffer to marshal the clip format from.
199 * phmf [O] Address that receive the unmarshaled metafile.
202 * The end of the marshaled data in the buffer.
205 * Even though the function is documented to take a pointer to an ULONG in
206 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
207 * the first parameter is an ULONG.
208 * This function is only intended to be called by the RPC runtime.
210 unsigned char * __RPC_USER
HMETAFILE_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HMETAFILE
*phmf
)
214 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags
), pBuffer
, phmf
);
216 ALIGN_POINTER(pBuffer
, 3);
218 fContext
= *(ULONG
*)pBuffer
;
219 pBuffer
+= sizeof(ULONG
);
221 if (((fContext
== WDT_INPROC_CALL
) && (sizeof(*phmf
) < 8)) ||
222 ((fContext
== WDT_INPROC64_CALL
) && (sizeof(*phmf
) == 8)))
224 *phmf
= *(HMETAFILE
*)pBuffer
;
225 pBuffer
+= sizeof(*phmf
);
227 else if (fContext
== WDT_REMOTE_CALL
)
231 handle
= *(ULONG
*)pBuffer
;
232 pBuffer
+= sizeof(ULONG
);
237 size
= *(ULONG
*)pBuffer
;
238 pBuffer
+= sizeof(ULONG
);
239 if (size
!= *(ULONG
*)pBuffer
)
241 RaiseException(RPC_X_BAD_STUB_DATA
, 0, 0, NULL
);
244 pBuffer
+= sizeof(ULONG
);
245 *phmf
= SetMetaFileBitsEx(size
, pBuffer
);
252 RaiseException(RPC_S_INVALID_TAG
, 0, 0, NULL
);
257 /******************************************************************************
258 * HMETAFILE_UserFree [OLE32.@]
260 * Frees an unmarshaled metafile.
263 * pFlags [I] Flags. See notes.
264 * phmf [I] Metafile to free.
267 * The end of the marshaled data in the buffer.
270 * Even though the function is documented to take a pointer to a ULONG in
271 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
272 * which the first parameter is a ULONG.
273 * This function is only intended to be called by the RPC runtime.
275 void __RPC_USER
HMETAFILE_UserFree(ULONG
*pFlags
, HMETAFILE
*phmf
)
277 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags
), *phmf
);
279 if (LOWORD(*pFlags
) != MSHCTX_INPROC
)
280 DeleteMetaFile(*phmf
);
283 /******************************************************************************
284 * HENHMETAFILE_UserSize [OLE32.@]
286 * Calculates the buffer size required to marshal an enhanced metafile.
289 * pFlags [I] Flags. See notes.
290 * StartingSize [I] Starting size of the buffer. This value is added on to
291 * the buffer size required for the clip format.
292 * phEmf [I] Enhanced metafile to size.
295 * The buffer size required to marshal an enhanced metafile plus the starting size.
298 * Even though the function is documented to take a pointer to a ULONG in
299 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
300 * the first parameter is a ULONG.
301 * This function is only intended to be called by the RPC runtime.
303 ULONG __RPC_USER
HENHMETAFILE_UserSize(ULONG
*pFlags
, ULONG size
, HENHMETAFILE
*phEmf
)
305 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags
), size
, *phEmf
);
307 ALIGN_LENGTH(size
, 3);
309 size
+= sizeof(ULONG
);
310 if (LOWORD(*pFlags
) == MSHCTX_INPROC
)
311 size
+= sizeof(ULONG_PTR
);
314 size
+= sizeof(ULONG
);
320 size
+= 2 * sizeof(ULONG
);
321 emfsize
= GetEnhMetaFileBits(*phEmf
, 0, NULL
);
329 /******************************************************************************
330 * HENHMETAFILE_UserMarshal [OLE32.@]
332 * Marshals an enhance metafile into a buffer.
335 * pFlags [I] Flags. See notes.
336 * pBuffer [I] Buffer to marshal the clip format into.
337 * phEmf [I] Enhanced metafile to marshal.
340 * The end of the marshaled data in the buffer.
343 * Even though the function is documented to take a pointer to a ULONG in
344 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
345 * the first parameter is a ULONG.
346 * This function is only intended to be called by the RPC runtime.
348 unsigned char * __RPC_USER
HENHMETAFILE_UserMarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HENHMETAFILE
*phEmf
)
350 TRACE("(%s, %p, &%p\n", debugstr_user_flags(pFlags
), pBuffer
, *phEmf
);
352 ALIGN_POINTER(pBuffer
, 3);
354 if (LOWORD(*pFlags
) == MSHCTX_INPROC
)
356 if (sizeof(*phEmf
) == 8)
357 *(ULONG
*)pBuffer
= WDT_INPROC64_CALL
;
359 *(ULONG
*)pBuffer
= WDT_INPROC_CALL
;
360 pBuffer
+= sizeof(ULONG
);
361 *(HENHMETAFILE
*)pBuffer
= *phEmf
;
362 pBuffer
+= sizeof(HENHMETAFILE
);
366 *(ULONG
*)pBuffer
= WDT_REMOTE_CALL
;
367 pBuffer
+= sizeof(ULONG
);
368 *(ULONG
*)pBuffer
= (ULONG
)(ULONG_PTR
)*phEmf
;
369 pBuffer
+= sizeof(ULONG
);
373 UINT emfsize
= GetEnhMetaFileBits(*phEmf
, 0, NULL
);
375 *(ULONG
*)pBuffer
= emfsize
;
376 pBuffer
+= sizeof(ULONG
);
377 *(ULONG
*)pBuffer
= emfsize
;
378 pBuffer
+= sizeof(ULONG
);
379 GetEnhMetaFileBits(*phEmf
, emfsize
, pBuffer
);
387 /******************************************************************************
388 * HENHMETAFILE_UserUnmarshal [OLE32.@]
390 * Unmarshals an enhanced metafile from a buffer.
393 * pFlags [I] Flags. See notes.
394 * pBuffer [I] Buffer to marshal the clip format from.
395 * phEmf [O] Address that receive the unmarshaled enhanced metafile.
398 * The end of the marshaled data in the buffer.
401 * Even though the function is documented to take a pointer to an ULONG in
402 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
403 * the first parameter is an ULONG.
404 * This function is only intended to be called by the RPC runtime.
406 unsigned char * __RPC_USER
HENHMETAFILE_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HENHMETAFILE
*phEmf
)
410 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags
), pBuffer
, phEmf
);
412 ALIGN_POINTER(pBuffer
, 3);
414 fContext
= *(ULONG
*)pBuffer
;
415 pBuffer
+= sizeof(ULONG
);
417 if (((fContext
== WDT_INPROC_CALL
) && (sizeof(*phEmf
) < 8)) ||
418 ((fContext
== WDT_INPROC64_CALL
) && (sizeof(*phEmf
) == 8)))
420 *phEmf
= *(HENHMETAFILE
*)pBuffer
;
421 pBuffer
+= sizeof(*phEmf
);
423 else if (fContext
== WDT_REMOTE_CALL
)
427 handle
= *(ULONG
*)pBuffer
;
428 pBuffer
+= sizeof(ULONG
);
433 size
= *(ULONG
*)pBuffer
;
434 pBuffer
+= sizeof(ULONG
);
435 if (size
!= *(ULONG
*)pBuffer
)
437 RaiseException(RPC_X_BAD_STUB_DATA
, 0, 0, NULL
);
440 pBuffer
+= sizeof(ULONG
);
441 *phEmf
= SetEnhMetaFileBits(size
, pBuffer
);
448 RaiseException(RPC_S_INVALID_TAG
, 0, 0, NULL
);
453 /******************************************************************************
454 * HENHMETAFILE_UserFree [OLE32.@]
456 * Frees an unmarshaled enhanced metafile.
459 * pFlags [I] Flags. See notes.
460 * phEmf [I] Enhanced metafile to free.
463 * The end of the marshaled data in the buffer.
466 * Even though the function is documented to take a pointer to a ULONG in
467 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
468 * which the first parameter is a ULONG.
469 * This function is only intended to be called by the RPC runtime.
471 void __RPC_USER
HENHMETAFILE_UserFree(ULONG
*pFlags
, HENHMETAFILE
*phEmf
)
473 TRACE("(%s, &%p\n", debugstr_user_flags(pFlags
), *phEmf
);
475 if (LOWORD(*pFlags
) != MSHCTX_INPROC
)
476 DeleteEnhMetaFile(*phEmf
);
479 /******************************************************************************
480 * HMETAFILEPICT_UserSize [OLE32.@]
482 * Calculates the buffer size required to marshal an metafile pict.
485 * pFlags [I] Flags. See notes.
486 * StartingSize [I] Starting size of the buffer. This value is added on to
487 * the buffer size required for the clip format.
488 * phMfp [I] Metafile pict to size.
491 * The buffer size required to marshal a metafile pict plus the starting size.
494 * Even though the function is documented to take a pointer to a ULONG in
495 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
496 * the first parameter is a ULONG.
497 * This function is only intended to be called by the RPC runtime.
499 ULONG __RPC_USER
HMETAFILEPICT_UserSize(ULONG
*pFlags
, ULONG size
, HMETAFILEPICT
*phMfp
)
501 TRACE("(%s, %d, &%p)\n", debugstr_user_flags(pFlags
), size
, *phMfp
);
503 ALIGN_LENGTH(size
, 3);
505 size
+= sizeof(ULONG
);
507 if(LOWORD(*pFlags
) == MSHCTX_INPROC
)
508 size
+= sizeof(HMETAFILEPICT
);
511 size
+= sizeof(ULONG
);
515 METAFILEPICT
*mfpict
= GlobalLock(*phMfp
);
517 /* FIXME: raise an exception if mfpict is NULL? */
518 size
+= 3 * sizeof(ULONG
);
519 size
+= sizeof(ULONG
);
521 size
= HMETAFILE_UserSize(pFlags
, size
, &mfpict
->hMF
);
523 GlobalUnlock(*phMfp
);
530 /******************************************************************************
531 * HMETAFILEPICT_UserMarshal [OLE32.@]
533 * Marshals a metafile pict into a buffer.
536 * pFlags [I] Flags. See notes.
537 * pBuffer [I] Buffer to marshal the clip format into.
538 * phMfp [I] Metafile pict to marshal.
541 * The end of the marshaled data in the buffer.
544 * Even though the function is documented to take a pointer to a ULONG in
545 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
546 * the first parameter is a ULONG.
547 * This function is only intended to be called by the RPC runtime.
549 unsigned char * __RPC_USER
HMETAFILEPICT_UserMarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HMETAFILEPICT
*phMfp
)
551 TRACE("(%s, %p, &%p)\n", debugstr_user_flags(pFlags
), pBuffer
, *phMfp
);
553 ALIGN_POINTER(pBuffer
, 3);
555 if (LOWORD(*pFlags
) == MSHCTX_INPROC
)
557 if (sizeof(HMETAFILEPICT
) == 8)
558 *(ULONG
*)pBuffer
= WDT_INPROC64_CALL
;
560 *(ULONG
*)pBuffer
= WDT_INPROC_CALL
;
561 pBuffer
+= sizeof(ULONG
);
562 *(HMETAFILEPICT
*)pBuffer
= *phMfp
;
563 pBuffer
+= sizeof(HMETAFILEPICT
);
567 *(ULONG
*)pBuffer
= WDT_REMOTE_CALL
;
568 pBuffer
+= sizeof(ULONG
);
569 *(ULONG
*)pBuffer
= (ULONG
)(ULONG_PTR
)*phMfp
;
570 pBuffer
+= sizeof(ULONG
);
574 METAFILEPICT
*mfpict
= GlobalLock(*phMfp
);
575 remoteMETAFILEPICT
* remmfpict
= (remoteMETAFILEPICT
*)pBuffer
;
577 /* FIXME: raise an exception if mfpict is NULL? */
578 remmfpict
->mm
= mfpict
->mm
;
579 remmfpict
->xExt
= mfpict
->xExt
;
580 remmfpict
->yExt
= mfpict
->yExt
;
581 pBuffer
+= 3 * sizeof(ULONG
);
582 *(ULONG
*)pBuffer
= USER_MARSHAL_PTR_PREFIX
;
583 pBuffer
+= sizeof(ULONG
);
585 pBuffer
= HMETAFILE_UserMarshal(pFlags
, pBuffer
, &mfpict
->hMF
);
587 GlobalUnlock(*phMfp
);
593 /******************************************************************************
594 * HMETAFILEPICT_UserUnmarshal [OLE32.@]
596 * Unmarshals an metafile pict from a buffer.
599 * pFlags [I] Flags. See notes.
600 * pBuffer [I] Buffer to marshal the clip format from.
601 * phMfp [O] Address that receive the unmarshaled metafile pict.
604 * The end of the marshaled data in the buffer.
607 * Even though the function is documented to take a pointer to an ULONG in
608 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
609 * the first parameter is an ULONG.
610 * This function is only intended to be called by the RPC runtime.
612 unsigned char * __RPC_USER
HMETAFILEPICT_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, HMETAFILEPICT
*phMfp
)
616 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags
), pBuffer
, phMfp
);
618 ALIGN_POINTER(pBuffer
, 3);
620 fContext
= *(ULONG
*)pBuffer
;
621 pBuffer
+= sizeof(ULONG
);
623 if ((fContext
== WDT_INPROC_CALL
) || fContext
== WDT_INPROC64_CALL
)
625 *phMfp
= *(HMETAFILEPICT
*)pBuffer
;
626 pBuffer
+= sizeof(HMETAFILEPICT
);
630 ULONG handle
= *(ULONG
*)pBuffer
;
631 pBuffer
+= sizeof(ULONG
);
636 METAFILEPICT
*mfpict
;
637 const remoteMETAFILEPICT
*remmfpict
;
638 ULONG user_marshal_prefix
;
640 remmfpict
= (const remoteMETAFILEPICT
*)pBuffer
;
642 *phMfp
= GlobalAlloc(GMEM_MOVEABLE
, sizeof(METAFILEPICT
));
644 RpcRaiseException(E_OUTOFMEMORY
);
646 mfpict
= GlobalLock(*phMfp
);
647 mfpict
->mm
= remmfpict
->mm
;
648 mfpict
->xExt
= remmfpict
->xExt
;
649 mfpict
->yExt
= remmfpict
->yExt
;
650 pBuffer
+= 3 * sizeof(ULONG
);
651 user_marshal_prefix
= *(ULONG
*)pBuffer
;
652 pBuffer
+= sizeof(ULONG
);
654 if (user_marshal_prefix
!= USER_MARSHAL_PTR_PREFIX
)
655 RpcRaiseException(RPC_X_INVALID_TAG
);
657 pBuffer
= HMETAFILE_UserUnmarshal(pFlags
, pBuffer
, &mfpict
->hMF
);
659 GlobalUnlock(*phMfp
);
665 /******************************************************************************
666 * HMETAFILEPICT_UserFree [OLE32.@]
668 * Frees an unmarshaled metafile pict.
671 * pFlags [I] Flags. See notes.
672 * phMfp [I] Metafile pict to free.
675 * The end of the marshaled data in the buffer.
678 * Even though the function is documented to take a pointer to a ULONG in
679 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
680 * which the first parameter is a ULONG.
681 * This function is only intended to be called by the RPC runtime.
683 void __RPC_USER
HMETAFILEPICT_UserFree(ULONG
*pFlags
, HMETAFILEPICT
*phMfp
)
685 TRACE("(%s, &%p)\n", debugstr_user_flags(pFlags
), *phMfp
);
687 if ((LOWORD(*pFlags
) != MSHCTX_INPROC
) && *phMfp
)
689 METAFILEPICT
*mfpict
;
691 mfpict
= GlobalLock(*phMfp
);
692 /* FIXME: raise an exception if mfpict is NULL? */
693 HMETAFILE_UserFree(pFlags
, &mfpict
->hMF
);
694 GlobalUnlock(*phMfp
);
700 /******************************************************************************
701 * STGMEDIUM_UserSize [OLE32.@]
703 * Calculates the buffer size required to marshal an STGMEDIUM.
706 * pFlags [I] Flags. See notes.
707 * StartingSize [I] Starting size of the buffer. This value is added on to
708 * the buffer size required for the clip format.
709 * pStgMedium [I] STGMEDIUM to size.
712 * The buffer size required to marshal an STGMEDIUM plus the starting size.
715 * Even though the function is documented to take a pointer to a ULONG in
716 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
717 * the first parameter is a ULONG.
718 * This function is only intended to be called by the RPC runtime.
720 ULONG __RPC_USER
STGMEDIUM_UserSize(ULONG
*pFlags
, ULONG StartingSize
, STGMEDIUM
*pStgMedium
)
722 ULONG size
= StartingSize
;
724 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags
), StartingSize
, pStgMedium
);
726 ALIGN_LENGTH(size
, 3);
728 size
+= 2 * sizeof(DWORD
);
729 if (pStgMedium
->tymed
!= TYMED_NULL
)
730 size
+= sizeof(DWORD
);
732 switch (pStgMedium
->tymed
)
735 TRACE("TYMED_NULL\n");
738 TRACE("TYMED_HGLOBAL\n");
739 if (pStgMedium
->u
.hGlobal
)
740 size
= HGLOBAL_UserSize(pFlags
, size
, &pStgMedium
->u
.hGlobal
);
743 TRACE("TYMED_FILE\n");
744 if (pStgMedium
->u
.lpszFileName
)
746 TRACE("file name is %s\n", debugstr_w(pStgMedium
->u
.lpszFileName
));
747 size
+= 3 * sizeof(DWORD
) +
748 (lstrlenW(pStgMedium
->u
.lpszFileName
) + 1) * sizeof(WCHAR
);
752 TRACE("TYMED_ISTREAM\n");
753 if (pStgMedium
->u
.pstm
)
756 IStream_QueryInterface(pStgMedium
->u
.pstm
, &IID_IUnknown
, (void**)&unk
);
757 size
= WdtpInterfacePointer_UserSize(pFlags
, LOWORD(*pFlags
), size
, unk
, &IID_IStream
);
758 IUnknown_Release(unk
);
762 TRACE("TYMED_ISTORAGE\n");
763 if (pStgMedium
->u
.pstg
)
766 IStorage_QueryInterface(pStgMedium
->u
.pstg
, &IID_IUnknown
, (void**)&unk
);
767 size
= WdtpInterfacePointer_UserSize(pFlags
, LOWORD(*pFlags
), size
, unk
, &IID_IStorage
);
768 IUnknown_Release(unk
);
772 TRACE("TYMED_GDI\n");
773 if (pStgMedium
->u
.hBitmap
)
774 size
= HBITMAP_UserSize(pFlags
, size
, &pStgMedium
->u
.hBitmap
);
777 TRACE("TYMED_MFPICT\n");
778 if (pStgMedium
->u
.hMetaFilePict
)
779 size
= HMETAFILEPICT_UserSize(pFlags
, size
, &pStgMedium
->u
.hMetaFilePict
);
782 TRACE("TYMED_ENHMF\n");
783 if (pStgMedium
->u
.hEnhMetaFile
)
784 size
= HENHMETAFILE_UserSize(pFlags
, size
, &pStgMedium
->u
.hEnhMetaFile
);
787 RaiseException(DV_E_TYMED
, 0, 0, NULL
);
790 if (pStgMedium
->pUnkForRelease
)
791 size
= WdtpInterfacePointer_UserSize(pFlags
, LOWORD(*pFlags
), size
, pStgMedium
->pUnkForRelease
, &IID_IUnknown
);
796 /******************************************************************************
797 * STGMEDIUM_UserMarshal [OLE32.@]
799 * Marshals a STGMEDIUM into a buffer.
802 * pFlags [I] Flags. See notes.
803 * pBuffer [I] Buffer to marshal the clip format into.
804 * pCF [I] STGMEDIUM to marshal.
807 * The end of the marshaled data in the buffer.
810 * Even though the function is documented to take a pointer to a ULONG in
811 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
812 * the first parameter is a ULONG.
813 * This function is only intended to be called by the RPC runtime.
815 unsigned char * __RPC_USER
STGMEDIUM_UserMarshal(ULONG
*pFlags
, unsigned char *pBuffer
, STGMEDIUM
*pStgMedium
)
817 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags
), pBuffer
, pStgMedium
);
819 ALIGN_POINTER(pBuffer
, 3);
821 *(DWORD
*)pBuffer
= pStgMedium
->tymed
;
822 pBuffer
+= sizeof(DWORD
);
823 if (pStgMedium
->tymed
!= TYMED_NULL
)
825 *(DWORD
*)pBuffer
= (DWORD
)(DWORD_PTR
)pStgMedium
->u
.pstg
;
826 pBuffer
+= sizeof(DWORD
);
828 *(DWORD
*)pBuffer
= (DWORD
)(DWORD_PTR
)pStgMedium
->pUnkForRelease
;
829 pBuffer
+= sizeof(DWORD
);
831 switch (pStgMedium
->tymed
)
834 TRACE("TYMED_NULL\n");
837 TRACE("TYMED_HGLOBAL\n");
838 if (pStgMedium
->u
.hGlobal
)
839 pBuffer
= HGLOBAL_UserMarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hGlobal
);
842 TRACE("TYMED_FILE\n");
843 if (pStgMedium
->u
.lpszFileName
)
846 len
= lstrlenW(pStgMedium
->u
.lpszFileName
);
848 *(DWORD
*)pBuffer
= len
+ 1;
849 pBuffer
+= sizeof(DWORD
);
851 *(DWORD
*)pBuffer
= 0;
852 pBuffer
+= sizeof(DWORD
);
854 *(DWORD
*)pBuffer
= len
+ 1;
855 pBuffer
+= sizeof(DWORD
);
857 TRACE("file name is %s\n", debugstr_w(pStgMedium
->u
.lpszFileName
));
858 memcpy(pBuffer
, pStgMedium
->u
.lpszFileName
, (len
+ 1) * sizeof(WCHAR
));
862 TRACE("TYMED_ISTREAM\n");
863 if (pStgMedium
->u
.pstm
)
866 IStream_QueryInterface(pStgMedium
->u
.pstm
, &IID_IUnknown
, (void**)&unk
);
867 pBuffer
= WdtpInterfacePointer_UserMarshal(pFlags
, LOWORD(*pFlags
), pBuffer
, unk
, &IID_IStream
);
868 IUnknown_Release(unk
);
872 TRACE("TYMED_ISTORAGE\n");
873 if (pStgMedium
->u
.pstg
)
876 IStorage_QueryInterface(pStgMedium
->u
.pstg
, &IID_IUnknown
, (void**)&unk
);
877 pBuffer
= WdtpInterfacePointer_UserMarshal(pFlags
, LOWORD(*pFlags
), pBuffer
, unk
, &IID_IStorage
);
878 IUnknown_Release(unk
);
882 TRACE("TYMED_GDI\n");
883 if (pStgMedium
->u
.hBitmap
)
884 pBuffer
= HBITMAP_UserMarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hBitmap
);
887 TRACE("TYMED_MFPICT\n");
888 if (pStgMedium
->u
.hMetaFilePict
)
889 pBuffer
= HMETAFILEPICT_UserMarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hMetaFilePict
);
892 TRACE("TYMED_ENHMF\n");
893 if (pStgMedium
->u
.hEnhMetaFile
)
894 pBuffer
= HENHMETAFILE_UserMarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hEnhMetaFile
);
897 RaiseException(DV_E_TYMED
, 0, 0, NULL
);
900 if (pStgMedium
->pUnkForRelease
)
901 pBuffer
= WdtpInterfacePointer_UserMarshal(pFlags
, LOWORD(*pFlags
), pBuffer
, pStgMedium
->pUnkForRelease
, &IID_IUnknown
);
906 /******************************************************************************
907 * STGMEDIUM_UserUnmarshal [OLE32.@]
909 * Unmarshals a STGMEDIUM from a buffer.
912 * pFlags [I] Flags. See notes.
913 * pBuffer [I] Buffer to marshal the clip format from.
914 * pStgMedium [O] Address that receive the unmarshaled STGMEDIUM.
917 * The end of the marshaled data in the buffer.
920 * Even though the function is documented to take a pointer to an ULONG in
921 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of which
922 * the first parameter is an ULONG.
923 * This function is only intended to be called by the RPC runtime.
925 unsigned char * __RPC_USER
STGMEDIUM_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, STGMEDIUM
*pStgMedium
)
930 ALIGN_POINTER(pBuffer
, 3);
932 TRACE("(%s, %p, %p\n", debugstr_user_flags(pFlags
), pBuffer
, pStgMedium
);
934 pStgMedium
->tymed
= *(DWORD
*)pBuffer
;
935 pBuffer
+= sizeof(DWORD
);
936 if (pStgMedium
->tymed
!= TYMED_NULL
)
938 content
= *(DWORD
*)pBuffer
;
939 pBuffer
+= sizeof(DWORD
);
941 releaseunk
= *(DWORD
*)pBuffer
;
942 pBuffer
+= sizeof(DWORD
);
944 switch (pStgMedium
->tymed
)
947 TRACE("TYMED_NULL\n");
950 TRACE("TYMED_HGLOBAL\n");
952 pBuffer
= HGLOBAL_UserUnmarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hGlobal
);
955 TRACE("TYMED_FILE\n");
960 conformance
= *(DWORD
*)pBuffer
;
961 pBuffer
+= sizeof(DWORD
);
962 if (*(DWORD
*)pBuffer
!= 0)
964 ERR("invalid offset %d\n", *(DWORD
*)pBuffer
);
965 RpcRaiseException(RPC_S_INVALID_BOUND
);
968 pBuffer
+= sizeof(DWORD
);
969 variance
= *(DWORD
*)pBuffer
;
970 pBuffer
+= sizeof(DWORD
);
971 if (conformance
!= variance
)
973 ERR("conformance (%d) and variance (%d) should be equal\n",
974 conformance
, variance
);
975 RpcRaiseException(RPC_S_INVALID_BOUND
);
978 if (conformance
> 0x7fffffff)
980 ERR("conformance 0x%x too large\n", conformance
);
981 RpcRaiseException(RPC_S_INVALID_BOUND
);
984 pStgMedium
->u
.lpszFileName
= CoTaskMemAlloc(conformance
* sizeof(WCHAR
));
985 if (!pStgMedium
->u
.lpszFileName
) RpcRaiseException(ERROR_OUTOFMEMORY
);
986 TRACE("unmarshalled file name is %s\n", debugstr_wn((const WCHAR
*)pBuffer
, variance
));
987 memcpy(pStgMedium
->u
.lpszFileName
, pBuffer
, variance
* sizeof(WCHAR
));
988 pBuffer
+= variance
* sizeof(WCHAR
);
991 pStgMedium
->u
.lpszFileName
= NULL
;
994 TRACE("TYMED_ISTREAM\n");
997 pBuffer
= WdtpInterfacePointer_UserUnmarshal(pFlags
, pBuffer
, (IUnknown
**)&pStgMedium
->u
.pstm
, &IID_IStream
);
1001 if (pStgMedium
->u
.pstm
) IStream_Release( pStgMedium
->u
.pstm
);
1002 pStgMedium
->u
.pstm
= NULL
;
1005 case TYMED_ISTORAGE
:
1006 TRACE("TYMED_ISTORAGE\n");
1009 pBuffer
= WdtpInterfacePointer_UserUnmarshal(pFlags
, pBuffer
, (IUnknown
**)&pStgMedium
->u
.pstg
, &IID_IStorage
);
1013 if (pStgMedium
->u
.pstg
) IStorage_Release( pStgMedium
->u
.pstg
);
1014 pStgMedium
->u
.pstg
= NULL
;
1018 TRACE("TYMED_GDI\n");
1020 pBuffer
= HBITMAP_UserUnmarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hBitmap
);
1022 pStgMedium
->u
.hBitmap
= NULL
;
1025 TRACE("TYMED_MFPICT\n");
1027 pBuffer
= HMETAFILEPICT_UserUnmarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hMetaFilePict
);
1029 pStgMedium
->u
.hMetaFilePict
= NULL
;
1032 TRACE("TYMED_ENHMF\n");
1034 pBuffer
= HENHMETAFILE_UserUnmarshal(pFlags
, pBuffer
, &pStgMedium
->u
.hEnhMetaFile
);
1036 pStgMedium
->u
.hEnhMetaFile
= NULL
;
1039 RaiseException(DV_E_TYMED
, 0, 0, NULL
);
1043 pBuffer
= WdtpInterfacePointer_UserUnmarshal(pFlags
, pBuffer
, &pStgMedium
->pUnkForRelease
, &IID_IUnknown
);
1044 /* Unlike the IStream / IStorage ifaces, the existing pUnkForRelease
1045 is left intact if a NULL ptr is unmarshalled - see the tests. */
1050 /******************************************************************************
1051 * STGMEDIUM_UserFree [OLE32.@]
1053 * Frees an unmarshaled STGMEDIUM.
1056 * pFlags [I] Flags. See notes.
1057 * pStgmedium [I] STGMEDIUM to free.
1060 * The end of the marshaled data in the buffer.
1063 * Even though the function is documented to take a pointer to a ULONG in
1064 * pFlags, it actually takes a pointer to a USER_MARSHAL_CB structure, of
1065 * which the first parameter is a ULONG.
1066 * This function is only intended to be called by the RPC runtime.
1068 void __RPC_USER
STGMEDIUM_UserFree(ULONG
*flags
, STGMEDIUM
*med
)
1070 TRACE("(%s, %p)\n", debugstr_user_flags(flags
), med
);
1077 case TYMED_ISTORAGE
:
1078 ReleaseStgMedium(med
);
1084 if (LOWORD(*flags
) == MSHCTX_INPROC
)
1085 med
->tymed
= TYMED_NULL
;
1086 ReleaseStgMedium(med
);
1089 RaiseException(DV_E_TYMED
, 0, 0, NULL
);
1093 ULONG __RPC_USER
ASYNC_STGMEDIUM_UserSize(ULONG
*pFlags
, ULONG StartingSize
, ASYNC_STGMEDIUM
*pStgMedium
)
1096 return STGMEDIUM_UserSize(pFlags
, StartingSize
, pStgMedium
);
1099 unsigned char * __RPC_USER
ASYNC_STGMEDIUM_UserMarshal( ULONG
*pFlags
, unsigned char *pBuffer
, ASYNC_STGMEDIUM
*pStgMedium
)
1102 return STGMEDIUM_UserMarshal(pFlags
, pBuffer
, pStgMedium
);
1105 unsigned char * __RPC_USER
ASYNC_STGMEDIUM_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, ASYNC_STGMEDIUM
*pStgMedium
)
1108 return STGMEDIUM_UserUnmarshal(pFlags
, pBuffer
, pStgMedium
);
1111 void __RPC_USER
ASYNC_STGMEDIUM_UserFree(ULONG
*pFlags
, ASYNC_STGMEDIUM
*pStgMedium
)
1114 STGMEDIUM_UserFree(pFlags
, pStgMedium
);
1117 ULONG __RPC_USER
FLAG_STGMEDIUM_UserSize(ULONG
*pFlags
, ULONG StartingSize
, FLAG_STGMEDIUM
*pStgMedium
)
1120 return StartingSize
;
1123 unsigned char * __RPC_USER
FLAG_STGMEDIUM_UserMarshal( ULONG
*pFlags
, unsigned char *pBuffer
, FLAG_STGMEDIUM
*pStgMedium
)
1129 unsigned char * __RPC_USER
FLAG_STGMEDIUM_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, FLAG_STGMEDIUM
*pStgMedium
)
1135 void __RPC_USER
FLAG_STGMEDIUM_UserFree(ULONG
*pFlags
, FLAG_STGMEDIUM
*pStgMedium
)
1140 ULONG __RPC_USER
SNB_UserSize(ULONG
*pFlags
, ULONG StartingSize
, SNB
*pSnb
)
1142 ULONG size
= StartingSize
;
1144 TRACE("(%s, %d, %p\n", debugstr_user_flags(pFlags
), StartingSize
, pSnb
);
1146 ALIGN_LENGTH(size
, 3);
1148 /* two counters from RemSNB header, plus one more ULONG */
1149 size
+= 3*sizeof(ULONG
);
1151 /* now actual data length */
1154 WCHAR
**ptrW
= *pSnb
;
1158 size
+= (lstrlenW(*ptrW
) + 1)*sizeof(WCHAR
);
1173 unsigned char * __RPC_USER
SNB_UserMarshal(ULONG
*pFlags
, unsigned char *pBuffer
, SNB
*pSnb
)
1175 struct SNB_wire
*wire
;
1178 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags
), pBuffer
, pSnb
);
1180 ALIGN_POINTER(pBuffer
, 3);
1182 wire
= (struct SNB_wire
*)pBuffer
;
1183 wire
->charcnt
= wire
->strcnt
= 0;
1184 size
= 3*sizeof(ULONG
);
1188 WCHAR
**ptrW
= *pSnb
;
1189 WCHAR
*dataW
= wire
->data
;
1193 ULONG len
= lstrlenW(*ptrW
) + 1;
1196 wire
->charcnt
+= len
;
1197 memcpy(dataW
, *ptrW
, len
*sizeof(WCHAR
));
1200 size
+= len
*sizeof(WCHAR
);
1205 wire
->datalen
= wire
->charcnt
;
1206 return pBuffer
+ size
;
1209 unsigned char * __RPC_USER
SNB_UserUnmarshal(ULONG
*pFlags
, unsigned char *pBuffer
, SNB
*pSnb
)
1211 USER_MARSHAL_CB
*umcb
= (USER_MARSHAL_CB
*)pFlags
;
1212 struct SNB_wire
*wire
;
1214 TRACE("(%s, %p, %p)\n", debugstr_user_flags(pFlags
), pBuffer
, pSnb
);
1216 wire
= (struct SNB_wire
*)pBuffer
;
1219 umcb
->pStubMsg
->pfnFree(*pSnb
);
1221 if (wire
->datalen
== 0)
1225 WCHAR
*src
= wire
->data
, *dest
;
1229 ptrW
= *pSnb
= umcb
->pStubMsg
->pfnAllocate((wire
->strcnt
+1)*sizeof(WCHAR
*) + wire
->datalen
*sizeof(WCHAR
));
1230 dest
= (WCHAR
*)(*pSnb
+ wire
->strcnt
+ 1);
1232 for (i
= 0; i
< wire
->strcnt
; i
++)
1234 ULONG len
= lstrlenW(src
);
1235 memcpy(dest
, src
, (len
+ 1)*sizeof(WCHAR
));
1244 return pBuffer
+ 3*sizeof(ULONG
) + wire
->datalen
*sizeof(WCHAR
);
1247 void __RPC_USER
SNB_UserFree(ULONG
*pFlags
, SNB
*pSnb
)
1249 USER_MARSHAL_CB
*umcb
= (USER_MARSHAL_CB
*)pFlags
;
1250 TRACE("(%p)\n", pSnb
);
1252 umcb
->pStubMsg
->pfnFree(*pSnb
);
1255 /* call_as/local stubs for unknwn.idl */
1257 HRESULT CALLBACK
IClassFactory_CreateInstance_Proxy(
1258 IClassFactory
* This
,
1259 IUnknown
*pUnkOuter
,
1263 TRACE("(%p, %s, %p)\n", pUnkOuter
, debugstr_guid(riid
), ppvObject
);
1267 ERR("aggregation is not allowed on remote objects\n");
1268 return CLASS_E_NOAGGREGATION
;
1270 return IClassFactory_RemoteCreateInstance_Proxy(This
, riid
,
1271 (IUnknown
**) ppvObject
);
1274 HRESULT __RPC_STUB
IClassFactory_CreateInstance_Stub(
1275 IClassFactory
* This
,
1277 IUnknown
**ppvObject
)
1279 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppvObject
);
1280 return IClassFactory_CreateInstance(This
, NULL
, riid
, (void **) ppvObject
);
1283 HRESULT CALLBACK
IClassFactory_LockServer_Proxy(
1284 IClassFactory
* This
,
1291 HRESULT __RPC_STUB
IClassFactory_LockServer_Stub(
1292 IClassFactory
* This
,
1299 /* call_as/local stubs for objidl.idl */
1301 HRESULT CALLBACK
IEnumUnknown_Next_Proxy(
1305 ULONG
*pceltFetched
)
1308 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1309 if (!pceltFetched
) pceltFetched
= &fetched
;
1310 return IEnumUnknown_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1313 HRESULT __RPC_STUB
IEnumUnknown_Next_Stub(
1317 ULONG
*pceltFetched
)
1320 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1322 hr
= IEnumUnknown_Next(This
, celt
, rgelt
, pceltFetched
);
1323 if (hr
== S_OK
) *pceltFetched
= celt
;
1327 HRESULT CALLBACK
IBindCtx_SetBindOptions_Proxy(
1329 BIND_OPTS
*pbindopts
)
1335 HRESULT __RPC_STUB
IBindCtx_SetBindOptions_Stub(
1337 BIND_OPTS2
*pbindopts
)
1343 HRESULT CALLBACK
IBindCtx_GetBindOptions_Proxy(
1345 BIND_OPTS
*pbindopts
)
1351 HRESULT __RPC_STUB
IBindCtx_GetBindOptions_Stub(
1353 BIND_OPTS2
*pbindopts
)
1359 HRESULT CALLBACK
IEnumMoniker_Next_Proxy(
1363 ULONG
*pceltFetched
)
1366 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1367 if (!pceltFetched
) pceltFetched
= &fetched
;
1368 return IEnumMoniker_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1371 HRESULT __RPC_STUB
IEnumMoniker_Next_Stub(
1375 ULONG
*pceltFetched
)
1378 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1380 hr
= IEnumMoniker_Next(This
, celt
, rgelt
, pceltFetched
);
1381 if (hr
== S_OK
) *pceltFetched
= celt
;
1385 BOOL CALLBACK
IRunnableObject_IsRunning_Proxy(
1386 IRunnableObject
* This
)
1390 memset(&rv
, 0, sizeof rv
);
1394 HRESULT __RPC_STUB
IRunnableObject_IsRunning_Stub(
1395 IRunnableObject
* This
)
1401 HRESULT CALLBACK
IMoniker_BindToObject_Proxy(
1404 IMoniker
*pmkToLeft
,
1412 HRESULT __RPC_STUB
IMoniker_BindToObject_Stub(
1415 IMoniker
*pmkToLeft
,
1417 IUnknown
**ppvResult
)
1423 HRESULT CALLBACK
IMoniker_BindToStorage_Proxy(
1426 IMoniker
*pmkToLeft
,
1430 TRACE("(%p)->(%p %p %s %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObj
);
1431 return IMoniker_RemoteBindToStorage_Proxy(This
, pbc
, pmkToLeft
, riid
, (IUnknown
**)ppvObj
);
1434 HRESULT __RPC_STUB
IMoniker_BindToStorage_Stub(
1437 IMoniker
*pmkToLeft
,
1441 TRACE("(%p)->(%p %p %s %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObj
);
1442 return IMoniker_BindToStorage(This
, pbc
, pmkToLeft
, riid
, (void**)ppvObj
);
1445 HRESULT CALLBACK
IEnumString_Next_Proxy(
1449 ULONG
*pceltFetched
)
1452 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1453 if (!pceltFetched
) pceltFetched
= &fetched
;
1454 return IEnumString_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1457 HRESULT __RPC_STUB
IEnumString_Next_Stub(
1461 ULONG
*pceltFetched
)
1464 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1466 hr
= IEnumString_Next(This
, celt
, rgelt
, pceltFetched
);
1467 if (hr
== S_OK
) *pceltFetched
= celt
;
1471 HRESULT CALLBACK
ISequentialStream_Read_Proxy(
1472 ISequentialStream
* This
,
1480 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbRead
);
1482 hr
= ISequentialStream_RemoteRead_Proxy(This
, pv
, cb
, &read
);
1483 if(pcbRead
) *pcbRead
= read
;
1488 HRESULT __RPC_STUB
ISequentialStream_Read_Stub(
1489 ISequentialStream
* This
,
1494 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbRead
);
1495 return ISequentialStream_Read(This
, pv
, cb
, pcbRead
);
1498 HRESULT CALLBACK
ISequentialStream_Write_Proxy(
1499 ISequentialStream
* This
,
1507 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbWritten
);
1509 hr
= ISequentialStream_RemoteWrite_Proxy(This
, pv
, cb
, &written
);
1510 if(pcbWritten
) *pcbWritten
= written
;
1515 HRESULT __RPC_STUB
ISequentialStream_Write_Stub(
1516 ISequentialStream
* This
,
1521 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbWritten
);
1522 return ISequentialStream_Write(This
, pv
, cb
, pcbWritten
);
1525 HRESULT CALLBACK
IStream_Seek_Proxy(
1527 LARGE_INTEGER dlibMove
,
1529 ULARGE_INTEGER
*plibNewPosition
)
1531 ULARGE_INTEGER newpos
;
1534 TRACE("(%p)->(%s, %d, %p)\n", This
, wine_dbgstr_longlong(dlibMove
.QuadPart
), dwOrigin
, plibNewPosition
);
1536 hr
= IStream_RemoteSeek_Proxy(This
, dlibMove
, dwOrigin
, &newpos
);
1537 if(plibNewPosition
) *plibNewPosition
= newpos
;
1542 HRESULT __RPC_STUB
IStream_Seek_Stub(
1544 LARGE_INTEGER dlibMove
,
1546 ULARGE_INTEGER
*plibNewPosition
)
1548 TRACE("(%p)->(%s, %d, %p)\n", This
, wine_dbgstr_longlong(dlibMove
.QuadPart
), dwOrigin
, plibNewPosition
);
1549 return IStream_Seek(This
, dlibMove
, dwOrigin
, plibNewPosition
);
1552 HRESULT CALLBACK
IStream_CopyTo_Proxy(
1556 ULARGE_INTEGER
*pcbRead
,
1557 ULARGE_INTEGER
*pcbWritten
)
1559 ULARGE_INTEGER read
, written
;
1562 TRACE("(%p)->(%p, %s, %p, %p)\n", This
, pstm
, wine_dbgstr_longlong(cb
.QuadPart
), pcbRead
, pcbWritten
);
1564 hr
= IStream_RemoteCopyTo_Proxy(This
, pstm
, cb
, &read
, &written
);
1565 if(pcbRead
) *pcbRead
= read
;
1566 if(pcbWritten
) *pcbWritten
= written
;
1571 HRESULT __RPC_STUB
IStream_CopyTo_Stub(
1575 ULARGE_INTEGER
*pcbRead
,
1576 ULARGE_INTEGER
*pcbWritten
)
1578 TRACE("(%p)->(%p, %s, %p, %p)\n", This
, pstm
, wine_dbgstr_longlong(cb
.QuadPart
), pcbRead
, pcbWritten
);
1580 return IStream_CopyTo(This
, pstm
, cb
, pcbRead
, pcbWritten
);
1583 HRESULT CALLBACK
IEnumSTATSTG_Next_Proxy(
1587 ULONG
*pceltFetched
)
1590 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1591 if (!pceltFetched
) pceltFetched
= &fetched
;
1592 return IEnumSTATSTG_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1595 HRESULT __RPC_STUB
IEnumSTATSTG_Next_Stub(
1599 ULONG
*pceltFetched
)
1602 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1604 hr
= IEnumSTATSTG_Next(This
, celt
, rgelt
, pceltFetched
);
1605 if (hr
== S_OK
) *pceltFetched
= celt
;
1609 HRESULT CALLBACK
IStorage_OpenStream_Proxy(
1617 TRACE("(%p)->(%s, %p, %08x, %d %p)\n", This
, debugstr_w(pwcsName
), reserved1
, grfMode
, reserved2
, ppstm
);
1618 if(reserved1
) WARN("reserved1 %p\n", reserved1
);
1620 return IStorage_RemoteOpenStream_Proxy(This
, pwcsName
, 0, NULL
, grfMode
, reserved2
, ppstm
);
1623 HRESULT __RPC_STUB
IStorage_OpenStream_Stub(
1632 TRACE("(%p)->(%s, %d, %p, %08x, %d %p)\n", This
, debugstr_w(pwcsName
), cbReserved1
, reserved1
, grfMode
, reserved2
, ppstm
);
1633 if(cbReserved1
|| reserved1
) WARN("cbReserved1 %d reserved1 %p\n", cbReserved1
, reserved1
);
1635 return IStorage_OpenStream(This
, pwcsName
, NULL
, grfMode
, reserved2
, ppstm
);
1638 HRESULT CALLBACK
IStorage_EnumElements_Proxy(
1643 IEnumSTATSTG
**ppenum
)
1645 TRACE("(%p)->(%d, %p, %d, %p)\n", This
, reserved1
, reserved2
, reserved3
, ppenum
);
1646 if(reserved2
) WARN("reserved2 %p\n", reserved2
);
1648 return IStorage_RemoteEnumElements_Proxy(This
, reserved1
, 0, NULL
, reserved3
, ppenum
);
1651 HRESULT __RPC_STUB
IStorage_EnumElements_Stub(
1657 IEnumSTATSTG
**ppenum
)
1659 TRACE("(%p)->(%d, %d, %p, %d, %p)\n", This
, reserved1
, cbReserved2
, reserved2
, reserved3
, ppenum
);
1660 if(cbReserved2
|| reserved2
) WARN("cbReserved2 %d reserved2 %p\n", cbReserved2
, reserved2
);
1662 return IStorage_EnumElements(This
, reserved1
, NULL
, reserved3
, ppenum
);
1665 HRESULT CALLBACK
ILockBytes_ReadAt_Proxy(
1667 ULARGE_INTEGER ulOffset
,
1675 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbRead
);
1677 hr
= ILockBytes_RemoteReadAt_Proxy(This
, ulOffset
, pv
, cb
, &read
);
1678 if(pcbRead
) *pcbRead
= read
;
1683 HRESULT __RPC_STUB
ILockBytes_ReadAt_Stub(
1685 ULARGE_INTEGER ulOffset
,
1690 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbRead
);
1691 return ILockBytes_ReadAt(This
, ulOffset
, pv
, cb
, pcbRead
);
1694 HRESULT CALLBACK
ILockBytes_WriteAt_Proxy(
1696 ULARGE_INTEGER ulOffset
,
1704 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbWritten
);
1706 hr
= ILockBytes_RemoteWriteAt_Proxy(This
, ulOffset
, pv
, cb
, &written
);
1707 if(pcbWritten
) *pcbWritten
= written
;
1712 HRESULT __RPC_STUB
ILockBytes_WriteAt_Stub(
1714 ULARGE_INTEGER ulOffset
,
1719 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbWritten
);
1720 return ILockBytes_WriteAt(This
, ulOffset
, pv
, cb
, pcbWritten
);
1723 HRESULT CALLBACK
IFillLockBytes_FillAppend_Proxy(
1724 IFillLockBytes
* This
,
1732 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbWritten
);
1734 hr
= IFillLockBytes_RemoteFillAppend_Proxy(This
, pv
, cb
, &written
);
1735 if(pcbWritten
) *pcbWritten
= written
;
1740 HRESULT __RPC_STUB
IFillLockBytes_FillAppend_Stub(
1741 IFillLockBytes
* This
,
1746 TRACE("(%p)->(%p, %d, %p)\n", This
, pv
, cb
, pcbWritten
);
1747 return IFillLockBytes_FillAppend(This
, pv
, cb
, pcbWritten
);
1750 HRESULT CALLBACK
IFillLockBytes_FillAt_Proxy(
1751 IFillLockBytes
* This
,
1752 ULARGE_INTEGER ulOffset
,
1760 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbWritten
);
1762 hr
= IFillLockBytes_RemoteFillAt_Proxy(This
, ulOffset
, pv
, cb
, &written
);
1763 if(pcbWritten
) *pcbWritten
= written
;
1768 HRESULT __RPC_STUB
IFillLockBytes_FillAt_Stub(
1769 IFillLockBytes
* This
,
1770 ULARGE_INTEGER ulOffset
,
1775 TRACE("(%p)->(%s, %p, %d, %p)\n", This
, wine_dbgstr_longlong(ulOffset
.QuadPart
), pv
, cb
, pcbWritten
);
1776 return IFillLockBytes_FillAt(This
, ulOffset
, pv
, cb
, pcbWritten
);
1779 HRESULT CALLBACK
IEnumFORMATETC_Next_Proxy(
1780 IEnumFORMATETC
* This
,
1783 ULONG
*pceltFetched
)
1786 if (!pceltFetched
) pceltFetched
= &fetched
;
1787 return IEnumFORMATETC_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1790 HRESULT __RPC_STUB
IEnumFORMATETC_Next_Stub(
1791 IEnumFORMATETC
* This
,
1794 ULONG
*pceltFetched
)
1798 hr
= IEnumFORMATETC_Next(This
, celt
, rgelt
, pceltFetched
);
1799 if (hr
== S_OK
) *pceltFetched
= celt
;
1803 HRESULT CALLBACK
IEnumSTATDATA_Next_Proxy(
1804 IEnumSTATDATA
* This
,
1807 ULONG
*pceltFetched
)
1810 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1811 if (!pceltFetched
) pceltFetched
= &fetched
;
1812 return IEnumSTATDATA_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
1815 HRESULT __RPC_STUB
IEnumSTATDATA_Next_Stub(
1816 IEnumSTATDATA
* This
,
1819 ULONG
*pceltFetched
)
1822 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
1824 hr
= IEnumSTATDATA_Next(This
, celt
, rgelt
, pceltFetched
);
1825 if (hr
== S_OK
) *pceltFetched
= celt
;
1829 void CALLBACK
IAdviseSink_OnDataChange_Proxy(
1831 FORMATETC
*pFormatetc
,
1834 TRACE("(%p)->(%p, %p)\n", This
, pFormatetc
, pStgmed
);
1835 IAdviseSink_RemoteOnDataChange_Proxy(This
, pFormatetc
, pStgmed
);
1838 HRESULT __RPC_STUB
IAdviseSink_OnDataChange_Stub(
1840 FORMATETC
*pFormatetc
,
1841 ASYNC_STGMEDIUM
*pStgmed
)
1843 TRACE("(%p)->(%p, %p)\n", This
, pFormatetc
, pStgmed
);
1844 IAdviseSink_OnDataChange(This
, pFormatetc
, pStgmed
);
1848 void CALLBACK
IAdviseSink_OnViewChange_Proxy(
1853 TRACE("(%p)->(%d, %d)\n", This
, dwAspect
, lindex
);
1854 IAdviseSink_RemoteOnViewChange_Proxy(This
, dwAspect
, lindex
);
1857 HRESULT __RPC_STUB
IAdviseSink_OnViewChange_Stub(
1862 TRACE("(%p)->(%d, %d)\n", This
, dwAspect
, lindex
);
1863 IAdviseSink_OnViewChange(This
, dwAspect
, lindex
);
1867 void CALLBACK
IAdviseSink_OnRename_Proxy(
1871 TRACE("(%p)->(%p)\n", This
, pmk
);
1872 IAdviseSink_RemoteOnRename_Proxy(This
, pmk
);
1875 HRESULT __RPC_STUB
IAdviseSink_OnRename_Stub(
1879 TRACE("(%p)->(%p)\n", This
, pmk
);
1880 IAdviseSink_OnRename(This
, pmk
);
1884 void CALLBACK
IAdviseSink_OnSave_Proxy(
1887 TRACE("(%p)\n", This
);
1888 IAdviseSink_RemoteOnSave_Proxy(This
);
1891 HRESULT __RPC_STUB
IAdviseSink_OnSave_Stub(
1894 TRACE("(%p)\n", This
);
1895 IAdviseSink_OnSave(This
);
1899 void CALLBACK
IAdviseSink_OnClose_Proxy(
1902 TRACE("(%p)\n", This
);
1903 IAdviseSink_RemoteOnClose_Proxy(This
);
1906 HRESULT __RPC_STUB
IAdviseSink_OnClose_Stub(
1909 TRACE("(%p)\n", This
);
1910 IAdviseSink_OnClose(This
);
1914 void CALLBACK
IAdviseSink2_OnLinkSrcChange_Proxy(
1918 TRACE("(%p)->(%p)\n", This
, pmk
);
1919 IAdviseSink2_RemoteOnLinkSrcChange_Proxy(This
, pmk
);
1922 HRESULT __RPC_STUB
IAdviseSink2_OnLinkSrcChange_Stub(
1926 TRACE("(%p)->(%p)\n", This
, pmk
);
1927 IAdviseSink2_OnLinkSrcChange(This
, pmk
);
1931 HRESULT CALLBACK
IDataObject_GetData_Proxy(
1933 FORMATETC
*pformatetcIn
,
1936 TRACE("(%p)->(%p, %p)\n", This
, pformatetcIn
, pmedium
);
1937 return IDataObject_RemoteGetData_Proxy(This
, pformatetcIn
, pmedium
);
1940 HRESULT __RPC_STUB
IDataObject_GetData_Stub(
1942 FORMATETC
*pformatetcIn
,
1943 STGMEDIUM
*pRemoteMedium
)
1945 TRACE("(%p)->(%p, %p)\n", This
, pformatetcIn
, pRemoteMedium
);
1946 return IDataObject_GetData(This
, pformatetcIn
, pRemoteMedium
);
1949 HRESULT CALLBACK
IDataObject_GetDataHere_Proxy(IDataObject
*iface
, FORMATETC
*fmt
, STGMEDIUM
*med
)
1952 IStorage
*stg
= NULL
;
1955 TRACE("(%p)->(%p, %p)\n", iface
, fmt
, med
);
1957 if ((med
->tymed
& (TYMED_HGLOBAL
| TYMED_FILE
| TYMED_ISTREAM
| TYMED_ISTORAGE
)) == 0)
1959 if (med
->tymed
!= fmt
->tymed
)
1962 release
= med
->pUnkForRelease
;
1963 med
->pUnkForRelease
= NULL
;
1965 if (med
->tymed
== TYMED_ISTREAM
|| med
->tymed
== TYMED_ISTORAGE
)
1967 stg
= med
->u
.pstg
; /* This may actually be a stream, but that's ok */
1968 if (stg
) IStorage_AddRef( stg
);
1971 hr
= IDataObject_RemoteGetDataHere_Proxy(iface
, fmt
, med
);
1973 med
->pUnkForRelease
= release
;
1977 IStorage_Release( med
->u
.pstg
);
1984 HRESULT __RPC_STUB
IDataObject_GetDataHere_Stub(
1986 FORMATETC
*pformatetc
,
1987 STGMEDIUM
*pRemoteMedium
)
1989 TRACE("(%p)->(%p, %p)\n", This
, pformatetc
, pRemoteMedium
);
1990 return IDataObject_GetDataHere(This
, pformatetc
, pRemoteMedium
);
1993 HRESULT CALLBACK
IDataObject_SetData_Proxy(
1995 FORMATETC
*pformatetc
,
2003 HRESULT __RPC_STUB
IDataObject_SetData_Stub(
2005 FORMATETC
*pformatetc
,
2006 FLAG_STGMEDIUM
*pmedium
,
2013 /* call_as/local stubs for oleidl.idl */
2015 HRESULT CALLBACK
IOleInPlaceActiveObject_TranslateAccelerator_Proxy(
2016 IOleInPlaceActiveObject
* This
,
2019 TRACE("(%p %p)\n", This
, lpmsg
);
2020 return IOleInPlaceActiveObject_RemoteTranslateAccelerator_Proxy(This
);
2023 HRESULT __RPC_STUB
IOleInPlaceActiveObject_TranslateAccelerator_Stub(
2024 IOleInPlaceActiveObject
* This
)
2026 TRACE("(%p)\n", This
);
2030 HRESULT CALLBACK
IOleInPlaceActiveObject_ResizeBorder_Proxy(
2031 IOleInPlaceActiveObject
* This
,
2033 IOleInPlaceUIWindow
*pUIWindow
,
2040 HRESULT __RPC_STUB
IOleInPlaceActiveObject_ResizeBorder_Stub(
2041 IOleInPlaceActiveObject
* This
,
2044 IOleInPlaceUIWindow
*pUIWindow
,
2051 HRESULT CALLBACK
IOleCache2_UpdateCache_Proxy(
2053 LPDATAOBJECT pDataObject
,
2057 TRACE("(%p, %p, 0x%08x, %p)\n", This
, pDataObject
, grfUpdf
, pReserved
);
2058 return IOleCache2_RemoteUpdateCache_Proxy(This
, pDataObject
, grfUpdf
, (LONG_PTR
)pReserved
);
2061 HRESULT __RPC_STUB
IOleCache2_UpdateCache_Stub(
2063 LPDATAOBJECT pDataObject
,
2067 TRACE("(%p, %p, 0x%08x, %li)\n", This
, pDataObject
, grfUpdf
, pReserved
);
2068 return IOleCache2_UpdateCache(This
, pDataObject
, grfUpdf
, (void*)pReserved
);
2071 HRESULT CALLBACK
IEnumOLEVERB_Next_Proxy(
2075 ULONG
*pceltFetched
)
2078 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
2079 if (!pceltFetched
) pceltFetched
= &fetched
;
2080 return IEnumOLEVERB_RemoteNext_Proxy(This
, celt
, rgelt
, pceltFetched
);
2083 HRESULT __RPC_STUB
IEnumOLEVERB_Next_Stub(
2087 ULONG
*pceltFetched
)
2090 TRACE("(%p)->(%d, %p, %p)\n", This
, celt
, rgelt
, pceltFetched
);
2092 hr
= IEnumOLEVERB_Next(This
, celt
, rgelt
, pceltFetched
);
2093 if (hr
== S_OK
) *pceltFetched
= celt
;
2097 HRESULT CALLBACK
IViewObject_Draw_Proxy(
2102 DVTARGETDEVICE
*ptd
,
2105 LPCRECTL lprcBounds
,
2106 LPCRECTL lprcWBounds
,
2107 BOOL (STDMETHODCALLTYPE
*pfnContinue
)(ULONG_PTR dwContinue
),
2108 ULONG_PTR dwContinue
)
2114 HRESULT __RPC_STUB
IViewObject_Draw_Stub(
2119 DVTARGETDEVICE
*ptd
,
2120 ULONG_PTR hdcTargetDev
,
2122 LPCRECTL lprcBounds
,
2123 LPCRECTL lprcWBounds
,
2124 IContinue
*pContinue
)
2130 HRESULT CALLBACK
IViewObject_GetColorSet_Proxy(
2135 DVTARGETDEVICE
*ptd
,
2137 LOGPALETTE
**ppColorSet
)
2143 HRESULT __RPC_STUB
IViewObject_GetColorSet_Stub(
2148 DVTARGETDEVICE
*ptd
,
2149 ULONG_PTR hicTargetDev
,
2150 LOGPALETTE
**ppColorSet
)
2156 HRESULT CALLBACK
IViewObject_Freeze_Proxy(
2167 HRESULT __RPC_STUB
IViewObject_Freeze_Stub(
2178 HRESULT CALLBACK
IViewObject_GetAdvise_Proxy(
2182 IAdviseSink
**ppAdvSink
)
2188 HRESULT __RPC_STUB
IViewObject_GetAdvise_Stub(
2192 IAdviseSink
**ppAdvSink
)