2 * Misc marshalling routines
4 * Copyright 2002 Ove Kaaven
5 * Copyright 2003 Mike Hearn
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
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 static void dump_user_flags(const ULONG
*pFlags
)
50 if (HIWORD(*pFlags
) == NDR_LOCAL_DATA_REPRESENTATION
)
51 TRACE("MAKELONG(NDR_LOCAL_REPRESENTATION, ");
53 TRACE("MAKELONG(0x%04x, ", HIWORD(*pFlags
));
54 switch (LOWORD(*pFlags
))
56 case MSHCTX_LOCAL
: TRACE("MSHCTX_LOCAL)"); break;
57 case MSHCTX_NOSHAREDMEM
: TRACE("MSHCTX_NOSHAREDMEM)"); break;
58 case MSHCTX_DIFFERENTMACHINE
: TRACE("MSHCTX_DIFFERENTMACHINE)"); break;
59 case MSHCTX_INPROC
: TRACE("MSHCTX_INPROC)"); break;
60 default: TRACE("%d)", LOWORD(*pFlags
));
64 /* CLEANLOCALSTORAGE */
66 #define CLS_FUNCDESC 'f'
67 #define CLS_LIBATTR 'l'
68 #define CLS_TYPEATTR 't'
69 #define CLS_VARDESC 'v'
71 ULONG WINAPI
CLEANLOCALSTORAGE_UserSize(ULONG
*pFlags
, ULONG Start
, CLEANLOCALSTORAGE
*pstg
)
73 ALIGN_LENGTH(Start
, 3);
74 return Start
+ sizeof(DWORD
);
77 unsigned char * WINAPI
CLEANLOCALSTORAGE_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, CLEANLOCALSTORAGE
*pstg
)
79 ALIGN_POINTER(Buffer
, 3);
80 *(DWORD
*)Buffer
= pstg
->flags
;
84 ITypeLib_ReleaseTLibAttr((ITypeLib
*)pstg
->pInterface
, *(TLIBATTR
**)pstg
->pStorage
);
87 ITypeInfo_ReleaseTypeAttr((ITypeInfo
*)pstg
->pInterface
, *(TYPEATTR
**)pstg
->pStorage
);
90 ITypeInfo_ReleaseFuncDesc((ITypeInfo
*)pstg
->pInterface
, *(FUNCDESC
**)pstg
->pStorage
);
93 ITypeInfo_ReleaseVarDesc((ITypeInfo
*)pstg
->pInterface
, *(VARDESC
**)pstg
->pStorage
);
97 ERR("Unknown type %x\n", pstg
->flags
);
100 *(VOID
**)pstg
->pStorage
= NULL
;
101 IUnknown_Release(pstg
->pInterface
);
102 pstg
->pInterface
= NULL
;
104 return Buffer
+ sizeof(DWORD
);
107 unsigned char * WINAPI
CLEANLOCALSTORAGE_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, CLEANLOCALSTORAGE
*pstr
)
109 ALIGN_POINTER(Buffer
, 3);
110 pstr
->flags
= *(DWORD
*)Buffer
;
111 return Buffer
+ sizeof(DWORD
);
114 void WINAPI
CLEANLOCALSTORAGE_UserFree(ULONG
*pFlags
, CLEANLOCALSTORAGE
*pstr
)
123 DWORD len
; /* No. of chars not including trailing '\0' */
124 DWORD byte_len
; /* len * 2 or 0xffffffff if len == 0 */
125 DWORD len2
; /* == len */
128 ULONG WINAPI
BSTR_UserSize(ULONG
*pFlags
, ULONG Start
, BSTR
*pstr
)
130 TRACE("(%x,%d,%p) => %p\n", *pFlags
, Start
, pstr
, *pstr
);
131 if (*pstr
) TRACE("string=%s\n", debugstr_w(*pstr
));
132 ALIGN_LENGTH(Start
, 3);
133 Start
+= sizeof(bstr_wire_t
) + ((SysStringByteLen(*pstr
) + 1) & ~1);
134 TRACE("returning %d\n", Start
);
138 unsigned char * WINAPI
BSTR_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, BSTR
*pstr
)
141 DWORD len
= SysStringByteLen(*pstr
);
143 TRACE("(%x,%p,%p) => %p\n", *pFlags
, Buffer
, pstr
, *pstr
);
144 if (*pstr
) TRACE("string=%s\n", debugstr_w(*pstr
));
146 ALIGN_POINTER(Buffer
, 3);
147 header
= (bstr_wire_t
*)Buffer
;
148 header
->len
= header
->len2
= (len
+ 1) / 2;
151 header
->byte_len
= len
;
152 memcpy(header
+ 1, *pstr
, header
->len
* 2);
155 header
->byte_len
= 0xffffffff; /* special case for a null bstr */
157 return Buffer
+ sizeof(*header
) + sizeof(OLECHAR
) * header
->len
;
160 unsigned char * WINAPI
BSTR_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, BSTR
*pstr
)
163 TRACE("(%x,%p,%p) => %p\n", *pFlags
, Buffer
, pstr
, *pstr
);
165 ALIGN_POINTER(Buffer
, 3);
166 header
= (bstr_wire_t
*)Buffer
;
167 if(header
->len
!= header
->len2
)
168 FIXME("len %08x != len2 %08x\n", header
->len
, header
->len2
);
170 if (header
->byte_len
== 0xffffffff)
172 SysFreeString(*pstr
);
175 else SysReAllocStringLen( pstr
, (OLECHAR
*)(header
+ 1), header
->len
);
177 if (*pstr
) TRACE("string=%s\n", debugstr_w(*pstr
));
178 return Buffer
+ sizeof(*header
) + sizeof(OLECHAR
) * header
->len
;
181 void WINAPI
BSTR_UserFree(ULONG
*pFlags
, BSTR
*pstr
)
183 TRACE("(%x,%p) => %p\n", *pFlags
, pstr
, *pstr
);
184 SysFreeString(*pstr
);
201 static unsigned int get_type_size(ULONG
*pFlags
, VARTYPE vt
)
203 if (vt
& VT_ARRAY
) return 4;
205 switch (vt
& ~VT_BYREF
) {
214 return sizeof(SHORT
);
222 return sizeof(FLOAT
);
224 return sizeof(DOUBLE
);
226 return sizeof(VARIANT_BOOL
);
228 return sizeof(SCODE
);
234 return sizeof(DECIMAL
);
236 return sizeof(ULONG
);
238 return sizeof(VARIANT
);
244 FIXME("unhandled VT %d\n", vt
);
249 static unsigned int get_type_alignment(ULONG
*pFlags
, VARTYPE vt
)
251 unsigned int size
= get_type_size(pFlags
, vt
);
252 if(vt
& VT_BYREF
) return 3;
253 if(size
== 0) return 0;
254 if(size
<= 4) return size
- 1;
258 static unsigned interface_variant_size(const ULONG
*pFlags
, REFIID riid
, IUnknown
*punk
)
265 hr
= CoGetMarshalSizeMax(&size
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
268 ERR("interface variant buffer size calculation failed, HRESULT=0x%x\n", hr
);
272 size
+= sizeof(ULONG
); /* we have to store the buffersize in the stream */
273 TRACE("wire-size extra of interface variant is %d\n", size
);
277 static ULONG
wire_extra_user_size(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
282 return LPSAFEARRAY_UserSize(pFlags
, Start
, V_ARRAYREF(pvar
));
284 return LPSAFEARRAY_UserSize(pFlags
, Start
, &V_ARRAY(pvar
));
287 switch (V_VT(pvar
)) {
289 return BSTR_UserSize(pFlags
, Start
, &V_BSTR(pvar
));
290 case VT_BSTR
| VT_BYREF
:
291 return BSTR_UserSize(pFlags
, Start
, V_BSTRREF(pvar
));
292 case VT_VARIANT
| VT_BYREF
:
293 return VARIANT_UserSize(pFlags
, Start
, V_VARIANTREF(pvar
));
295 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, V_UNKNOWN(pvar
));
296 case VT_UNKNOWN
| VT_BYREF
:
297 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
299 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
300 case VT_DISPATCH
| VT_BYREF
:
301 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
303 FIXME("wire-size record\n");
306 case VT_SAFEARRAY
| VT_BYREF
:
307 FIXME("wire-size safearray: shouldn't be marshaling this\n");
314 /* helper: called for VT_DISPATCH variants to marshal the IDispatch* into the buffer. returns Buffer on failure, new position otherwise */
315 static unsigned char* interface_variant_marshal(const ULONG
*pFlags
, unsigned char *Buffer
,
316 REFIID riid
, IUnknown
*punk
)
320 void *working_memlocked
;
321 unsigned char *oldpos
;
325 TRACE("pFlags=%d, Buffer=%p, pUnk=%p\n", *pFlags
, Buffer
, punk
);
329 memset(Buffer
, 0, sizeof(ULONG
));
330 return Buffer
+ sizeof(ULONG
);
335 /* CoMarshalInterface needs a stream, whereas at this level we are operating in terms of buffers.
336 * We create a stream on an HGLOBAL, so we can simply do a memcpy to move it to the buffer.
337 * in rpcrt4/ndr_ole.c, a simple IStream implementation is wrapped around the buffer object,
338 * but that would be overkill here, hence this implementation. We save the size because the unmarshal
339 * code has no way to know how long the marshalled buffer is. */
341 size
= interface_variant_size(pFlags
, riid
, punk
);
343 working_mem
= GlobalAlloc(0, size
);
344 if (!working_mem
) return oldpos
;
346 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
348 GlobalFree(working_mem
);
352 hr
= CoMarshalInterface(working
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
354 IStream_Release(working
); /* this also releases the hglobal */
358 working_memlocked
= GlobalLock(working_mem
);
359 memcpy(Buffer
, &size
, sizeof(ULONG
)); /* copy the buffersize */
360 memcpy(Buffer
+ sizeof(ULONG
), working_memlocked
, size
- sizeof(ULONG
));
361 GlobalUnlock(working_mem
);
363 IStream_Release(working
);
365 /* size includes the ULONG for the size written above */
366 TRACE("done, size=%d\n", size
);
367 return Buffer
+ size
;
370 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
371 static unsigned char *interface_variant_unmarshal(const ULONG
*pFlags
, unsigned char *Buffer
,
372 REFIID riid
, IUnknown
**ppunk
)
376 void *working_memlocked
;
377 unsigned char *oldpos
;
381 TRACE("pFlags=%d, Buffer=%p, ppUnk=%p\n", *pFlags
, Buffer
, ppunk
);
385 /* get the buffersize */
386 memcpy(&size
, Buffer
, sizeof(ULONG
));
387 TRACE("buffersize=%d\n", size
);
392 return Buffer
+ sizeof(ULONG
);
395 working_mem
= GlobalAlloc(0, size
);
396 if (!working_mem
) return oldpos
;
398 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
400 GlobalFree(working_mem
);
404 working_memlocked
= GlobalLock(working_mem
);
406 /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
407 memcpy(working_memlocked
, Buffer
+ sizeof(ULONG
), size
);
408 GlobalUnlock(working_mem
);
410 hr
= CoUnmarshalInterface(working
, riid
, (void**)ppunk
);
412 IStream_Release(working
);
416 IStream_Release(working
); /* this also frees the underlying hglobal */
418 /* size includes the ULONG for the size written above */
419 TRACE("done, processed=%d bytes\n", size
);
420 return Buffer
+ size
;
424 ULONG WINAPI
VARIANT_UserSize(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
427 TRACE("(%x,%d,%p)\n", *pFlags
, Start
, pvar
);
428 TRACE("vt=%04x\n", V_VT(pvar
));
430 ALIGN_LENGTH(Start
, 7);
431 Start
+= sizeof(variant_wire_t
);
432 if(V_VT(pvar
) & VT_BYREF
)
435 align
= get_type_alignment(pFlags
, V_VT(pvar
));
436 ALIGN_LENGTH(Start
, align
);
437 if(V_VT(pvar
) == (VT_VARIANT
| VT_BYREF
))
440 Start
+= get_type_size(pFlags
, V_VT(pvar
));
441 Start
= wire_extra_user_size(pFlags
, Start
, pvar
);
443 TRACE("returning %d\n", Start
);
447 unsigned char * WINAPI
VARIANT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
449 variant_wire_t
*header
;
454 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
455 TRACE("vt=%04x\n", V_VT(pvar
));
457 ALIGN_POINTER(Buffer
, 7);
459 header
= (variant_wire_t
*)Buffer
;
461 header
->clSize
= 0; /* fixed up at the end */
462 header
->rpcReserved
= 0;
463 header
->vt
= pvar
->n1
.n2
.vt
;
464 header
->wReserved1
= pvar
->n1
.n2
.wReserved1
;
465 header
->wReserved2
= pvar
->n1
.n2
.wReserved2
;
466 header
->wReserved3
= pvar
->n1
.n2
.wReserved3
;
467 header
->switch_is
= pvar
->n1
.n2
.vt
;
468 if(header
->switch_is
& VT_ARRAY
)
469 header
->switch_is
&= ~VT_TYPEMASK
;
471 Pos
= (unsigned char*)(header
+ 1);
472 type_size
= get_type_size(pFlags
, V_VT(pvar
));
473 align
= get_type_alignment(pFlags
, V_VT(pvar
));
474 ALIGN_POINTER(Pos
, align
);
476 if(header
->vt
& VT_BYREF
)
478 *(DWORD
*)Pos
= max(type_size
, 4);
480 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
482 memcpy(Pos
, pvar
->n1
.n2
.n3
.byref
, type_size
);
487 *(DWORD
*)Pos
= 'U' | 's' << 8 | 'e' << 16 | 'r' << 24;
493 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
494 memcpy(Pos
, pvar
, type_size
);
496 memcpy(Pos
, &pvar
->n1
.n2
.n3
, type_size
);
500 if(header
->vt
& VT_ARRAY
)
502 if(header
->vt
& VT_BYREF
)
503 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
505 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
512 Pos
= BSTR_UserMarshal(pFlags
, Pos
, &V_BSTR(pvar
));
514 case VT_BSTR
| VT_BYREF
:
515 Pos
= BSTR_UserMarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
517 case VT_VARIANT
| VT_BYREF
:
518 Pos
= VARIANT_UserMarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
521 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
522 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWN(pvar
));
524 case VT_UNKNOWN
| VT_BYREF
:
525 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
526 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
529 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
530 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
532 case VT_DISPATCH
| VT_BYREF
:
533 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
534 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
537 FIXME("handle BRECORD by val\n");
539 case VT_RECORD
| VT_BYREF
:
540 FIXME("handle BRECORD by ref\n");
544 header
->clSize
= ((Pos
- Buffer
) + 7) >> 3;
545 TRACE("marshalled size=%d\n", header
->clSize
);
549 unsigned char * WINAPI
VARIANT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
551 variant_wire_t
*header
;
556 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
558 ALIGN_POINTER(Buffer
, 7);
560 header
= (variant_wire_t
*)Buffer
;
562 Pos
= (unsigned char*)(header
+ 1);
563 type_size
= get_type_size(pFlags
, header
->vt
);
564 align
= get_type_alignment(pFlags
, header
->vt
);
565 ALIGN_POINTER(Pos
, align
);
567 if(header
->vt
& VT_BYREF
)
572 switch (header
->vt
& ~VT_BYREF
)
574 /* these types have a different memory size compared to wire size */
578 mem_size
= sizeof(void *);
581 mem_size
= type_size
;
585 if (V_VT(pvar
) != header
->vt
)
588 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
590 else if (!V_BYREF(pvar
))
591 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
592 memcpy(V_BYREF(pvar
), Pos
, type_size
);
593 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
601 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
602 memcpy(pvar
, Pos
, type_size
);
604 memcpy(&pvar
->n1
.n2
.n3
, Pos
, type_size
);
608 pvar
->n1
.n2
.vt
= header
->vt
;
609 pvar
->n1
.n2
.wReserved1
= header
->wReserved1
;
610 pvar
->n1
.n2
.wReserved2
= header
->wReserved2
;
611 pvar
->n1
.n2
.wReserved3
= header
->wReserved3
;
613 if(header
->vt
& VT_ARRAY
)
615 if(header
->vt
& VT_BYREF
)
616 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
618 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
626 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, &V_BSTR(pvar
));
628 case VT_BSTR
| VT_BYREF
:
629 *V_BSTRREF(pvar
) = NULL
;
630 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
632 case VT_VARIANT
| VT_BYREF
:
633 Pos
= VARIANT_UserUnmarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
636 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
637 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, &V_UNKNOWN(pvar
));
639 case VT_UNKNOWN
| VT_BYREF
:
640 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
641 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWNREF(pvar
));
644 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
645 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)&V_DISPATCH(pvar
));
647 case VT_DISPATCH
| VT_BYREF
:
648 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
649 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)V_DISPATCHREF(pvar
));
652 FIXME("handle BRECORD by val\n");
654 case VT_RECORD
| VT_BYREF
:
655 FIXME("handle BRECORD by ref\n");
662 void WINAPI
VARIANT_UserFree(ULONG
*pFlags
, VARIANT
*pvar
)
664 VARTYPE vt
= V_VT(pvar
);
667 TRACE("(%x,%p)\n", *pFlags
, pvar
);
668 TRACE("vt=%04x\n", V_VT(pvar
));
670 if (vt
& VT_BYREF
) ref
= pvar
->n1
.n2
.n3
.byref
;
678 LPSAFEARRAY_UserFree(pFlags
, V_ARRAYREF(pvar
));
680 LPSAFEARRAY_UserFree(pFlags
, &V_ARRAY(pvar
));
686 case VT_BSTR
| VT_BYREF
:
687 BSTR_UserFree(pFlags
, V_BSTRREF(pvar
));
689 case VT_VARIANT
| VT_BYREF
:
690 VARIANT_UserFree(pFlags
, V_VARIANTREF(pvar
));
692 case VT_RECORD
| VT_BYREF
:
693 FIXME("handle BRECORD by ref\n");
695 case VT_UNKNOWN
| VT_BYREF
:
696 case VT_DISPATCH
| VT_BYREF
:
697 IUnknown_Release(*V_UNKNOWNREF(pvar
));
707 /* Get the number of cells in a SafeArray */
708 static ULONG
SAFEARRAY_GetCellCount(const SAFEARRAY
*psa
)
710 const SAFEARRAYBOUND
* psab
= psa
->rgsabound
;
711 USHORT cCount
= psa
->cDims
;
712 ULONG ulNumCells
= 1;
716 /* This is a valid bordercase. See testcases. -Marcus */
717 if (!psab
->cElements
)
719 ulNumCells
*= psab
->cElements
;
725 static inline SF_TYPE
SAFEARRAY_GetUnionType(SAFEARRAY
*psa
)
730 hr
= SafeArrayGetVartype(psa
, &vt
);
733 if(psa
->fFeatures
& FADF_VARIANT
) return SF_VARIANT
;
735 switch(psa
->cbElements
)
737 case 1: vt
= VT_I1
; break;
738 case 2: vt
= VT_I2
; break;
739 case 4: vt
= VT_I4
; break;
740 case 8: vt
= VT_I8
; break;
742 RpcRaiseException(hr
);
746 if (psa
->fFeatures
& FADF_HAVEIID
)
752 case VT_UI1
: return SF_I1
;
755 case VT_UI2
: return SF_I2
;
760 case VT_R4
: return SF_I4
;
765 case VT_UI8
: return SF_I8
;
767 case VT_UINT_PTR
: return (sizeof(UINT_PTR
) == 4 ? SF_I4
: SF_I8
);
768 case VT_BSTR
: return SF_BSTR
;
769 case VT_DISPATCH
: return SF_DISPATCH
;
770 case VT_VARIANT
: return SF_VARIANT
;
771 case VT_UNKNOWN
: return SF_UNKNOWN
;
772 /* Note: Return a non-zero size to indicate vt is valid. The actual size
773 * of a UDT is taken from the result of IRecordInfo_GetSize().
775 case VT_RECORD
: return SF_RECORD
;
776 default: return SF_ERROR
;
780 static DWORD
elem_wire_size(LPSAFEARRAY lpsa
, SF_TYPE sftype
)
782 if (sftype
== SF_BSTR
)
783 return sizeof(DWORD
);
784 else if (sftype
== SF_VARIANT
)
785 return sizeof(variant_wire_t
) - sizeof(DWORD
);
787 return lpsa
->cbElements
;
790 static DWORD
elem_mem_size(wireSAFEARRAY wiresa
, SF_TYPE sftype
)
792 if (sftype
== SF_BSTR
)
794 else if (sftype
== SF_VARIANT
)
795 return sizeof(VARIANT
);
797 return wiresa
->cbElements
;
800 ULONG WINAPI
LPSAFEARRAY_UserSize(ULONG
*pFlags
, ULONG StartingSize
, LPSAFEARRAY
*ppsa
)
802 ULONG size
= StartingSize
;
804 TRACE("("); dump_user_flags(pFlags
); TRACE(", %d, %p\n", StartingSize
, *ppsa
);
806 ALIGN_LENGTH(size
, 3);
807 size
+= sizeof(ULONG
);
810 SAFEARRAY
*psa
= *ppsa
;
811 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
815 size
+= sizeof(ULONG
);
816 size
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
818 sftype
= SAFEARRAY_GetUnionType(psa
);
819 size
+= sizeof(ULONG
);
821 size
+= sizeof(ULONG
);
822 size
+= sizeof(ULONG
);
823 if (sftype
== SF_HAVEIID
)
826 size
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
828 size
+= sizeof(ULONG
);
836 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
837 size
= BSTR_UserSize(pFlags
, size
, lpBstr
);
844 FIXME("size interfaces\n");
850 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
851 size
= VARIANT_UserSize(pFlags
, size
, lpVariant
);
857 IRecordInfo
* pRecInfo
= NULL
;
859 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
861 RpcRaiseException(hr
);
865 FIXME("size record info %p\n", pRecInfo
);
867 IRecordInfo_Release(pRecInfo
);
872 ALIGN_LENGTH(size
, 7);
877 size
+= ulCellCount
* psa
->cbElements
;
888 unsigned char * WINAPI
LPSAFEARRAY_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
892 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, &%p\n", Buffer
, *ppsa
);
894 ALIGN_POINTER(Buffer
, 3);
895 *(ULONG
*)Buffer
= *ppsa
? 0x1 : 0x0;
896 Buffer
+= sizeof(ULONG
);
900 SAFEARRAY
*psa
= *ppsa
;
901 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
902 SAFEARRAYBOUND
*bound
;
907 sftype
= SAFEARRAY_GetUnionType(psa
);
909 *(ULONG
*)Buffer
= psa
->cDims
;
910 Buffer
+= sizeof(ULONG
);
911 *(USHORT
*)Buffer
= psa
->cDims
;
912 Buffer
+= sizeof(USHORT
);
913 *(USHORT
*)Buffer
= psa
->fFeatures
;
914 Buffer
+= sizeof(USHORT
);
915 *(ULONG
*)Buffer
= elem_wire_size(psa
, sftype
);
916 Buffer
+= sizeof(ULONG
);
918 hr
= SafeArrayGetVartype(psa
, &vt
);
919 if (FAILED(hr
)) vt
= 0;
921 *(ULONG
*)Buffer
= (USHORT
)psa
->cLocks
| (vt
<< 16);
922 Buffer
+= sizeof(ULONG
);
924 *(ULONG
*)Buffer
= sftype
;
925 Buffer
+= sizeof(ULONG
);
927 *(ULONG
*)Buffer
= ulCellCount
;
928 Buffer
+= sizeof(ULONG
);
929 *(ULONG
*)Buffer
= psa
->pvData
? 0x2 : 0x0;
930 Buffer
+= sizeof(ULONG
);
931 if (sftype
== SF_HAVEIID
)
933 SafeArrayGetIID(psa
, &guid
);
934 memcpy(Buffer
, &guid
, sizeof(guid
));
935 Buffer
+= sizeof(guid
);
938 /* bounds are marshaled in opposite order comparing to storage layout */
939 bound
= (SAFEARRAYBOUND
*)Buffer
;
940 for (i
= 0; i
< psa
->cDims
; i
++)
942 memcpy(bound
++, &psa
->rgsabound
[psa
->cDims
-i
-1], sizeof(psa
->rgsabound
[0]));
944 Buffer
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
946 *(ULONG
*)Buffer
= ulCellCount
;
947 Buffer
+= sizeof(ULONG
);
957 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
958 Buffer
= BSTR_UserMarshal(pFlags
, Buffer
, lpBstr
);
965 FIXME("marshal interfaces\n");
971 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
972 Buffer
= VARIANT_UserMarshal(pFlags
, Buffer
, lpVariant
);
978 IRecordInfo
* pRecInfo
= NULL
;
980 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
982 RpcRaiseException(hr
);
986 FIXME("write record info %p\n", pRecInfo
);
988 IRecordInfo_Release(pRecInfo
);
994 ALIGN_POINTER(Buffer
, 7);
999 /* Just copy the data over */
1000 memcpy(Buffer
, psa
->pvData
, ulCellCount
* psa
->cbElements
);
1001 Buffer
+= ulCellCount
* psa
->cbElements
;
1012 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
1013 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
1014 FADF_VARIANT | FADF_CREATEVECTOR)
1016 unsigned char * WINAPI
LPSAFEARRAY_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
1019 wireSAFEARRAY wiresa
;
1026 SAFEARRAYBOUND
*wiresab
;
1028 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, %p\n", Buffer
, ppsa
);
1030 ALIGN_POINTER(Buffer
, 3);
1031 ptr
= *(ULONG
*)Buffer
;
1032 Buffer
+= sizeof(ULONG
);
1038 TRACE("NULL safe array unmarshaled\n");
1043 cDims
= *(ULONG
*)Buffer
;
1044 Buffer
+= sizeof(ULONG
);
1046 wiresa
= (wireSAFEARRAY
)Buffer
;
1047 Buffer
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
1049 if (cDims
!= wiresa
->cDims
)
1050 RpcRaiseException(RPC_S_INVALID_BOUND
);
1052 /* FIXME: there should be a limit on how large cDims can be */
1054 vt
= HIWORD(wiresa
->cLocks
);
1056 sftype
= *(ULONG
*)Buffer
;
1057 Buffer
+= sizeof(ULONG
);
1059 cell_count
= *(ULONG
*)Buffer
;
1060 Buffer
+= sizeof(ULONG
);
1061 ptr
= *(ULONG
*)Buffer
;
1062 Buffer
+= sizeof(ULONG
);
1063 if (sftype
== SF_HAVEIID
)
1065 memcpy(&guid
, Buffer
, sizeof(guid
));
1066 Buffer
+= sizeof(guid
);
1069 wiresab
= (SAFEARRAYBOUND
*)Buffer
;
1070 Buffer
+= sizeof(wiresab
[0]) * wiresa
->cDims
;
1074 *ppsa
= SafeArrayCreateEx(vt
, wiresa
->cDims
, wiresab
, NULL
);
1075 if (!*ppsa
) RpcRaiseException(E_OUTOFMEMORY
);
1079 if (FAILED(SafeArrayAllocDescriptor(wiresa
->cDims
, ppsa
)))
1080 RpcRaiseException(E_OUTOFMEMORY
);
1081 memcpy((*ppsa
)->rgsabound
, wiresab
, sizeof(SAFEARRAYBOUND
) * wiresa
->cDims
);
1084 /* be careful about which flags we set since they could be a security
1086 (*ppsa
)->fFeatures
&= FADF_AUTOSETFLAGS
;
1087 (*ppsa
)->fFeatures
|= (wiresa
->fFeatures
& ~(FADF_AUTOSETFLAGS
));
1088 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1089 (*ppsa
)->cbElements
= elem_mem_size(wiresa
, sftype
);
1090 (*ppsa
)->cLocks
= 0;
1092 /* SafeArrayCreateEx allocates the data for us, but
1093 * SafeArrayAllocDescriptor doesn't */
1096 hr
= SafeArrayAllocData(*ppsa
);
1098 RpcRaiseException(hr
);
1101 if ((*(ULONG
*)Buffer
!= cell_count
) || (SAFEARRAY_GetCellCount(*ppsa
) != cell_count
))
1102 RpcRaiseException(RPC_S_INVALID_BOUND
);
1103 Buffer
+= sizeof(ULONG
);
1113 for (lpBstr
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpBstr
++)
1114 Buffer
= BSTR_UserUnmarshal(pFlags
, Buffer
, lpBstr
);
1121 FIXME("marshal interfaces\n");
1127 for (lpVariant
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpVariant
++)
1128 Buffer
= VARIANT_UserUnmarshal(pFlags
, Buffer
, lpVariant
);
1134 FIXME("set record info\n");
1140 ALIGN_POINTER(Buffer
, 7);
1145 /* Just copy the data over */
1146 memcpy((*ppsa
)->pvData
, Buffer
, cell_count
* (*ppsa
)->cbElements
);
1147 Buffer
+= cell_count
* (*ppsa
)->cbElements
;
1154 TRACE("safe array unmarshaled: %p\n", *ppsa
);
1159 void WINAPI
LPSAFEARRAY_UserFree(ULONG
*pFlags
, LPSAFEARRAY
*ppsa
)
1161 TRACE("("); dump_user_flags(pFlags
); TRACE(", &%p\n", *ppsa
);
1163 SafeArrayDestroy(*ppsa
);
1167 ULONG WINAPI
HFONT_UserSize(ULONG
*pFlags
, ULONG Start
, HFONT
*phfont
)
1173 unsigned char * WINAPI
HFONT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1179 unsigned char * WINAPI
HFONT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1185 void WINAPI
HFONT_UserFree(ULONG
*pFlags
, HFONT
*phfont
)
1193 /* exactly how Invoke is marshalled is not very clear to me yet,
1194 * but the way I've done it seems to work for me */
1196 HRESULT CALLBACK
IDispatch_Invoke_Proxy(
1198 DISPID dispIdMember
,
1202 DISPPARAMS
* pDispParams
,
1203 VARIANT
* pVarResult
,
1204 EXCEPINFO
* pExcepInfo
,
1209 UINT
* rgVarRefIdx
= NULL
;
1210 VARIANTARG
* rgVarRef
= NULL
;
1213 EXCEPINFO ExcepInfo
;
1215 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This
,
1216 dispIdMember
, debugstr_guid(riid
),
1217 lcid
, wFlags
, pDispParams
, pVarResult
,
1218 pExcepInfo
, puArgErr
);
1220 /* [out] args can't be null, use dummy vars if needed */
1221 if (!pVarResult
) pVarResult
= &VarResult
;
1222 if (!puArgErr
) puArgErr
= &uArgErr
;
1223 if (!pExcepInfo
) pExcepInfo
= &ExcepInfo
;
1225 /* count by-ref args */
1226 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1227 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1228 if (V_ISBYREF(arg
)) {
1233 rgVarRefIdx
= CoTaskMemAlloc(sizeof(UINT
)*cVarRef
);
1234 rgVarRef
= CoTaskMemAlloc(sizeof(VARIANTARG
)*cVarRef
);
1235 /* make list of by-ref args */
1236 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1237 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1238 if (V_ISBYREF(arg
)) {
1239 rgVarRefIdx
[cVarRef
] = u
;
1240 VariantInit(&rgVarRef
[cVarRef
]);
1241 VariantCopy(&rgVarRef
[cVarRef
], arg
);
1247 /* [out] args still can't be null,
1248 * but we can point these anywhere in this case,
1249 * since they won't be written to when cVarRef is 0 */
1250 rgVarRefIdx
= puArgErr
;
1251 rgVarRef
= pVarResult
;
1253 TRACE("passed by ref: %d args\n", cVarRef
);
1254 hr
= IDispatch_RemoteInvoke_Proxy(This
,
1267 for (u
=0; u
<cVarRef
; u
++) {
1268 unsigned i
= rgVarRefIdx
[u
];
1269 VariantCopy(&pDispParams
->rgvarg
[i
],
1271 VariantClear(&rgVarRef
[u
]);
1273 CoTaskMemFree(rgVarRef
);
1274 CoTaskMemFree(rgVarRefIdx
);
1277 if(pExcepInfo
== &ExcepInfo
)
1279 SysFreeString(pExcepInfo
->bstrSource
);
1280 SysFreeString(pExcepInfo
->bstrDescription
);
1281 SysFreeString(pExcepInfo
->bstrHelpFile
);
1286 HRESULT __RPC_STUB
IDispatch_Invoke_Stub(
1288 DISPID dispIdMember
,
1292 DISPPARAMS
* pDispParams
,
1293 VARIANT
* pVarResult
,
1294 EXCEPINFO
* pExcepInfo
,
1298 VARIANTARG
* rgVarRef
)
1301 VARIANTARG
*rgvarg
, *arg
;
1304 /* initialize out parameters, so that they can be marshalled
1305 * in case the real Invoke doesn't initialize them */
1306 VariantInit(pVarResult
);
1307 memset(pExcepInfo
, 0, sizeof(*pExcepInfo
));
1310 /* let the real Invoke operate on a copy of the in parameters,
1311 * so we don't risk losing pointers to allocated memory */
1312 rgvarg
= pDispParams
->rgvarg
;
1313 arg
= CoTaskMemAlloc(sizeof(VARIANTARG
)*pDispParams
->cArgs
);
1314 if (!arg
) return E_OUTOFMEMORY
;
1316 /* init all args so we can call VariantClear on all the args if the copy
1318 for (u
= 0; u
< pDispParams
->cArgs
; u
++)
1319 VariantInit(&arg
[u
]);
1321 for (u
= 0; u
< pDispParams
->cArgs
; u
++) {
1322 hr
= VariantCopy(&arg
[u
], &rgvarg
[u
]);
1327 if (SUCCEEDED(hr
)) {
1328 /* copy ref args to arg array */
1329 for (u
=0; u
<cVarRef
; u
++) {
1330 unsigned i
= rgVarRefIdx
[u
];
1331 VariantCopy(&arg
[i
], &rgVarRef
[u
]);
1334 pDispParams
->rgvarg
= arg
;
1336 hr
= IDispatch_Invoke(This
,
1346 /* copy ref args from arg array */
1347 for (u
=0; u
<cVarRef
; u
++) {
1348 unsigned i
= rgVarRefIdx
[u
];
1349 VariantCopy(&rgVarRef
[u
], &arg
[i
]);
1353 /* clear the duplicate argument list */
1354 for (u
=0; u
<pDispParams
->cArgs
; u
++)
1355 VariantClear(&arg
[u
]);
1357 pDispParams
->rgvarg
= rgvarg
;
1365 HRESULT CALLBACK
IEnumVARIANT_Next_Proxy(
1369 ULONG
* pCeltFetched
)
1373 pCeltFetched
= &fetched
;
1374 return IEnumVARIANT_RemoteNext_Proxy(This
,
1380 HRESULT __RPC_STUB
IEnumVARIANT_Next_Stub(
1384 ULONG
* pCeltFetched
)
1388 hr
= IEnumVARIANT_Next(This
,
1392 if (hr
== S_OK
) *pCeltFetched
= celt
;
1396 /* TypeInfo related freers */
1398 static void free_embedded_typedesc(TYPEDESC
*tdesc
);
1399 static void free_embedded_arraydesc(ARRAYDESC
*adesc
)
1401 switch(adesc
->tdescElem
.vt
)
1405 free_embedded_typedesc(adesc
->tdescElem
.u
.lptdesc
);
1406 CoTaskMemFree(adesc
->tdescElem
.u
.lptdesc
);
1409 free_embedded_arraydesc(adesc
->tdescElem
.u
.lpadesc
);
1410 CoTaskMemFree(adesc
->tdescElem
.u
.lpadesc
);
1415 static void free_embedded_typedesc(TYPEDESC
*tdesc
)
1421 free_embedded_typedesc(tdesc
->u
.lptdesc
);
1422 CoTaskMemFree(tdesc
->u
.lptdesc
);
1425 free_embedded_arraydesc(tdesc
->u
.lpadesc
);
1426 CoTaskMemFree(tdesc
->u
.lpadesc
);
1431 static void free_embedded_elemdesc(ELEMDESC
*edesc
)
1433 free_embedded_typedesc(&edesc
->tdesc
);
1434 if(edesc
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
1435 CoTaskMemFree(edesc
->u
.paramdesc
.pparamdescex
);
1440 HRESULT CALLBACK
ITypeComp_Bind_Proxy(
1445 ITypeInfo
** ppTInfo
,
1446 DESCKIND
* pDescKind
,
1449 FIXME("not implemented\n");
1453 HRESULT __RPC_STUB
ITypeComp_Bind_Stub(
1458 ITypeInfo
** ppTInfo
,
1459 DESCKIND
* pDescKind
,
1460 LPFUNCDESC
* ppFuncDesc
,
1461 LPVARDESC
* ppVarDesc
,
1462 ITypeComp
** ppTypeComp
,
1463 CLEANLOCALSTORAGE
* pDummy
)
1465 FIXME("not implemented\n");
1469 HRESULT CALLBACK
ITypeComp_BindType_Proxy(
1473 ITypeInfo
** ppTInfo
,
1474 ITypeComp
** ppTComp
)
1476 FIXME("not implemented\n");
1480 HRESULT __RPC_STUB
ITypeComp_BindType_Stub(
1484 ITypeInfo
** ppTInfo
)
1486 FIXME("not implemented\n");
1492 HRESULT CALLBACK
ITypeInfo_GetTypeAttr_Proxy(
1494 TYPEATTR
** ppTypeAttr
)
1497 CLEANLOCALSTORAGE stg
;
1498 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1501 stg
.pStorage
= NULL
;
1502 stg
.pInterface
= NULL
;
1504 return ITypeInfo_RemoteGetTypeAttr_Proxy(This
, ppTypeAttr
, &stg
);
1507 HRESULT __RPC_STUB
ITypeInfo_GetTypeAttr_Stub(
1509 LPTYPEATTR
* ppTypeAttr
,
1510 CLEANLOCALSTORAGE
* pDummy
)
1513 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1515 hr
= ITypeInfo_GetTypeAttr(This
, ppTypeAttr
);
1519 pDummy
->flags
= CLS_TYPEATTR
;
1520 ITypeInfo_AddRef(This
);
1521 pDummy
->pInterface
= (IUnknown
*)This
;
1522 pDummy
->pStorage
= ppTypeAttr
;
1526 HRESULT CALLBACK
ITypeInfo_GetFuncDesc_Proxy(
1529 FUNCDESC
** ppFuncDesc
)
1531 CLEANLOCALSTORAGE stg
;
1532 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1535 stg
.pStorage
= NULL
;
1536 stg
.pInterface
= NULL
;
1538 return ITypeInfo_RemoteGetFuncDesc_Proxy(This
, index
, ppFuncDesc
, &stg
);
1541 HRESULT __RPC_STUB
ITypeInfo_GetFuncDesc_Stub(
1544 LPFUNCDESC
* ppFuncDesc
,
1545 CLEANLOCALSTORAGE
* pDummy
)
1548 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1550 hr
= ITypeInfo_GetFuncDesc(This
, index
, ppFuncDesc
);
1554 pDummy
->flags
= CLS_FUNCDESC
;
1555 ITypeInfo_AddRef(This
);
1556 pDummy
->pInterface
= (IUnknown
*)This
;
1557 pDummy
->pStorage
= ppFuncDesc
;
1561 HRESULT CALLBACK
ITypeInfo_GetVarDesc_Proxy(
1564 VARDESC
** ppVarDesc
)
1566 CLEANLOCALSTORAGE stg
;
1567 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1570 stg
.pStorage
= NULL
;
1571 stg
.pInterface
= NULL
;
1573 return ITypeInfo_RemoteGetVarDesc_Proxy(This
, index
, ppVarDesc
, &stg
);
1576 HRESULT __RPC_STUB
ITypeInfo_GetVarDesc_Stub(
1579 LPVARDESC
* ppVarDesc
,
1580 CLEANLOCALSTORAGE
* pDummy
)
1583 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1585 hr
= ITypeInfo_GetVarDesc(This
, index
, ppVarDesc
);
1589 pDummy
->flags
= CLS_VARDESC
;
1590 ITypeInfo_AddRef(This
);
1591 pDummy
->pInterface
= (IUnknown
*)This
;
1592 pDummy
->pStorage
= ppVarDesc
;
1596 HRESULT CALLBACK
ITypeInfo_GetNames_Proxy(
1603 TRACE("(%p, %08x, %p, %d, %p)\n", This
, memid
, rgBstrNames
, cMaxNames
, pcNames
);
1605 return ITypeInfo_RemoteGetNames_Proxy(This
, memid
, rgBstrNames
, cMaxNames
, pcNames
);
1608 HRESULT __RPC_STUB
ITypeInfo_GetNames_Stub(
1615 TRACE("(%p, %08x, %p, %d, %p)\n", This
, memid
, rgBstrNames
, cMaxNames
, pcNames
);
1617 return ITypeInfo_GetNames(This
, memid
, rgBstrNames
, cMaxNames
, pcNames
);
1620 HRESULT CALLBACK
ITypeInfo_GetIDsOfNames_Proxy(
1622 LPOLESTR
* rgszNames
,
1626 FIXME("not implemented\n");
1630 HRESULT __RPC_STUB
ITypeInfo_GetIDsOfNames_Stub(
1633 FIXME("not implemented\n");
1637 HRESULT CALLBACK
ITypeInfo_Invoke_Proxy(
1642 DISPPARAMS
* pDispParams
,
1643 VARIANT
* pVarResult
,
1644 EXCEPINFO
* pExcepInfo
,
1647 FIXME("not implemented\n");
1651 HRESULT __RPC_STUB
ITypeInfo_Invoke_Stub(
1654 FIXME("not implemented\n");
1658 HRESULT CALLBACK
ITypeInfo_GetDocumentation_Proxy(ITypeInfo
*This
, MEMBERID memid
,
1659 BSTR
*name
, BSTR
*doc_string
,
1660 DWORD
*help_context
, BSTR
*help_file
)
1662 DWORD dummy_help_context
, flags
= 0;
1663 BSTR dummy_name
, dummy_doc_string
, dummy_help_file
;
1665 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This
, memid
, name
, doc_string
, help_context
, help_file
);
1667 if(!name
) name
= &dummy_name
;
1670 if(!doc_string
) doc_string
= &dummy_doc_string
;
1673 if(!help_context
) help_context
= &dummy_help_context
;
1676 if(!help_file
) help_file
= &dummy_help_file
;
1679 hr
= ITypeInfo_RemoteGetDocumentation_Proxy(This
, memid
, flags
, name
, doc_string
, help_context
, help_file
);
1681 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1686 HRESULT __RPC_STUB
ITypeInfo_GetDocumentation_Stub(ITypeInfo
*This
, MEMBERID memid
,
1687 DWORD flags
, BSTR
*name
, BSTR
*doc_string
,
1688 DWORD
*help_context
, BSTR
*help_file
)
1690 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This
, memid
, flags
, name
, doc_string
, help_context
, help_file
);
1692 *name
= *doc_string
= *help_file
= NULL
;
1695 if(!(flags
& 1)) name
= NULL
;
1696 if(!(flags
& 2)) doc_string
= NULL
;
1697 if(!(flags
& 4)) help_context
= NULL
;
1698 if(!(flags
& 8)) help_file
= NULL
;
1700 return ITypeInfo_GetDocumentation(This
, memid
, name
, doc_string
, help_context
, help_file
);
1703 HRESULT CALLBACK
ITypeInfo_GetDllEntry_Proxy(ITypeInfo
*This
, MEMBERID memid
,
1704 INVOKEKIND invkind
, BSTR
*dll_name
,
1705 BSTR
* name
, WORD
*ordinal
)
1708 BSTR dummy_dll_name
, dummy_name
;
1711 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This
, memid
, invkind
, dll_name
, name
, ordinal
);
1713 if(!dll_name
) dll_name
= &dummy_dll_name
;
1716 if(!name
) name
= &dummy_name
;
1719 if(!ordinal
) ordinal
= &dummy_ordinal
;
1722 hr
= ITypeInfo_RemoteGetDllEntry_Proxy(This
, memid
, invkind
, flags
, dll_name
, name
, ordinal
);
1724 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1729 HRESULT __RPC_STUB
ITypeInfo_GetDllEntry_Stub(ITypeInfo
*This
, MEMBERID memid
,
1730 INVOKEKIND invkind
, DWORD flags
,
1731 BSTR
*dll_name
, BSTR
*name
,
1734 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This
, memid
, invkind
, dll_name
, name
, ordinal
);
1736 *dll_name
= *name
= NULL
;
1739 if(!(flags
& 1)) dll_name
= NULL
;
1740 if(!(flags
& 2)) name
= NULL
;
1741 if(!(flags
& 4)) ordinal
= NULL
;
1743 return ITypeInfo_GetDllEntry(This
, memid
, invkind
, dll_name
, name
, ordinal
);
1746 HRESULT CALLBACK
ITypeInfo_AddressOfMember_Proxy(
1752 FIXME("not implemented\n");
1756 HRESULT __RPC_STUB
ITypeInfo_AddressOfMember_Stub(
1759 FIXME("not implemented\n");
1763 HRESULT CALLBACK
ITypeInfo_CreateInstance_Proxy(
1765 IUnknown
* pUnkOuter
,
1769 FIXME("not implemented\n");
1773 HRESULT __RPC_STUB
ITypeInfo_CreateInstance_Stub(
1778 FIXME("not implemented\n");
1782 HRESULT CALLBACK
ITypeInfo_GetContainingTypeLib_Proxy(
1791 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1793 hr
= ITypeInfo_RemoteGetContainingTypeLib_Proxy(This
, &pTL
, &index
);
1802 ITypeLib_Release(pTL
);
1807 HRESULT __RPC_STUB
ITypeInfo_GetContainingTypeLib_Stub(
1812 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1813 return ITypeInfo_GetContainingTypeLib(This
, ppTLib
, pIndex
);
1816 void CALLBACK
ITypeInfo_ReleaseTypeAttr_Proxy(
1818 TYPEATTR
* pTypeAttr
)
1820 TRACE("(%p, %p)\n", This
, pTypeAttr
);
1821 free_embedded_typedesc(&pTypeAttr
->tdescAlias
);
1822 CoTaskMemFree(pTypeAttr
);
1825 HRESULT __RPC_STUB
ITypeInfo_ReleaseTypeAttr_Stub(
1828 TRACE("nothing to do\n");
1832 void CALLBACK
ITypeInfo_ReleaseFuncDesc_Proxy(
1834 FUNCDESC
* pFuncDesc
)
1837 TRACE("(%p, %p)\n", This
, pFuncDesc
);
1839 for(param
= 0; param
< pFuncDesc
->cParams
; param
++)
1840 free_embedded_elemdesc(pFuncDesc
->lprgelemdescParam
+ param
);
1842 CoTaskMemFree(pFuncDesc
->lprgelemdescParam
);
1844 free_embedded_elemdesc(&pFuncDesc
->elemdescFunc
);
1846 if(pFuncDesc
->cScodes
!= 0 && pFuncDesc
->cScodes
!= -1)
1847 CoTaskMemFree(pFuncDesc
->lprgscode
);
1849 CoTaskMemFree(pFuncDesc
);
1852 HRESULT __RPC_STUB
ITypeInfo_ReleaseFuncDesc_Stub(
1855 TRACE("nothing to do\n");
1859 void CALLBACK
ITypeInfo_ReleaseVarDesc_Proxy(
1863 TRACE("(%p, %p)\n", This
, pVarDesc
);
1865 CoTaskMemFree(pVarDesc
->lpstrSchema
);
1867 if(pVarDesc
->varkind
== VAR_CONST
)
1868 CoTaskMemFree(pVarDesc
->u
.lpvarValue
);
1870 free_embedded_elemdesc(&pVarDesc
->elemdescVar
);
1871 CoTaskMemFree(pVarDesc
);
1874 HRESULT __RPC_STUB
ITypeInfo_ReleaseVarDesc_Stub(
1877 TRACE("nothing to do\n");
1884 HRESULT CALLBACK
ITypeInfo2_GetDocumentation2_Proxy(ITypeInfo2
*This
, MEMBERID memid
,
1885 LCID lcid
, BSTR
*help_string
,
1886 DWORD
*help_context
, BSTR
*help_dll
)
1888 DWORD dummy_help_context
, flags
= 0;
1889 BSTR dummy_help_string
, dummy_help_dll
;
1891 TRACE("(%p, %08x, %08x, %p, %p, %p)\n", This
, memid
, lcid
, help_string
, help_context
, help_dll
);
1893 if(!help_string
) help_string
= &dummy_help_string
;
1896 if(!help_context
) help_context
= &dummy_help_context
;
1899 if(!help_dll
) help_dll
= &dummy_help_dll
;
1902 hr
= ITypeInfo2_RemoteGetDocumentation2_Proxy(This
, memid
, lcid
, flags
, help_string
, help_context
, help_dll
);
1904 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1909 HRESULT __RPC_STUB
ITypeInfo2_GetDocumentation2_Stub(ITypeInfo2
*This
, MEMBERID memid
,
1910 LCID lcid
, DWORD flags
,
1911 BSTR
*help_string
, DWORD
*help_context
,
1914 TRACE("(%p, %08x, %08x, %08x, %p, %p, %p)\n", This
, memid
, lcid
, flags
, help_string
, help_context
, help_dll
);
1916 *help_string
= *help_dll
= NULL
;
1919 if(!(flags
& 1)) help_string
= NULL
;
1920 if(!(flags
& 2)) help_context
= NULL
;
1921 if(!(flags
& 4)) help_dll
= NULL
;
1923 return ITypeInfo2_GetDocumentation2(This
, memid
, lcid
, help_string
, help_context
, help_dll
);
1928 UINT CALLBACK
ITypeLib_GetTypeInfoCount_Proxy(
1932 TRACE("(%p)\n", This
);
1934 ITypeLib_RemoteGetTypeInfoCount_Proxy(This
, &count
);
1939 HRESULT __RPC_STUB
ITypeLib_GetTypeInfoCount_Stub(
1943 TRACE("(%p, %p)\n", This
, pcTInfo
);
1944 *pcTInfo
= ITypeLib_GetTypeInfoCount(This
);
1948 HRESULT CALLBACK
ITypeLib_GetLibAttr_Proxy(
1950 TLIBATTR
** ppTLibAttr
)
1952 CLEANLOCALSTORAGE stg
;
1953 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1956 stg
.pStorage
= NULL
;
1957 stg
.pInterface
= NULL
;
1959 return ITypeLib_RemoteGetLibAttr_Proxy(This
, ppTLibAttr
, &stg
);
1962 HRESULT __RPC_STUB
ITypeLib_GetLibAttr_Stub(
1964 LPTLIBATTR
* ppTLibAttr
,
1965 CLEANLOCALSTORAGE
* pDummy
)
1968 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1970 hr
= ITypeLib_GetLibAttr(This
, ppTLibAttr
);
1974 pDummy
->flags
= CLS_LIBATTR
;
1975 ITypeLib_AddRef(This
);
1976 pDummy
->pInterface
= (IUnknown
*)This
;
1977 pDummy
->pStorage
= ppTLibAttr
;
1981 HRESULT CALLBACK
ITypeLib_GetDocumentation_Proxy(ITypeLib
*This
, INT index
, BSTR
*name
,
1982 BSTR
*doc_string
, DWORD
*help_context
,
1985 DWORD dummy_help_context
, flags
= 0;
1986 BSTR dummy_name
, dummy_doc_string
, dummy_help_file
;
1988 TRACE("(%p, %d, %p, %p, %p, %p)\n", This
, index
, name
, doc_string
, help_context
, help_file
);
1990 if(!name
) name
= &dummy_name
;
1993 if(!doc_string
) doc_string
= &dummy_doc_string
;
1996 if(!help_context
) help_context
= &dummy_help_context
;
1999 if(!help_file
) help_file
= &dummy_help_file
;
2002 hr
= ITypeLib_RemoteGetDocumentation_Proxy(This
, index
, flags
, name
, doc_string
, help_context
, help_file
);
2004 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2009 HRESULT __RPC_STUB
ITypeLib_GetDocumentation_Stub(ITypeLib
*This
, INT index
, DWORD flags
,
2010 BSTR
*name
, BSTR
*doc_string
,
2011 DWORD
*help_context
, BSTR
*help_file
)
2013 TRACE("(%p, %d, %08x, %p, %p, %p, %p)\n", This
, index
, flags
, name
, doc_string
, help_context
, help_file
);
2015 *name
= *doc_string
= *help_file
= NULL
;
2018 if(!(flags
& 1)) name
= NULL
;
2019 if(!(flags
& 2)) doc_string
= NULL
;
2020 if(!(flags
& 4)) help_context
= NULL
;
2021 if(!(flags
& 8)) help_file
= NULL
;
2023 return ITypeLib_GetDocumentation(This
, index
, name
, doc_string
, help_context
, help_file
);
2026 HRESULT CALLBACK
ITypeLib_IsName_Proxy(
2032 FIXME("not implemented\n");
2036 HRESULT __RPC_STUB
ITypeLib_IsName_Stub(
2043 FIXME("not implemented\n");
2047 HRESULT CALLBACK
ITypeLib_FindName_Proxy(
2051 ITypeInfo
** ppTInfo
,
2055 FIXME("not implemented\n");
2059 HRESULT __RPC_STUB
ITypeLib_FindName_Stub(
2063 ITypeInfo
** ppTInfo
,
2068 FIXME("not implemented\n");
2072 void CALLBACK
ITypeLib_ReleaseTLibAttr_Proxy(
2074 TLIBATTR
* pTLibAttr
)
2076 TRACE("(%p, %p)\n", This
, pTLibAttr
);
2077 CoTaskMemFree(pTLibAttr
);
2080 HRESULT __RPC_STUB
ITypeLib_ReleaseTLibAttr_Stub(
2083 TRACE("nothing to do\n");
2090 HRESULT CALLBACK
ITypeLib2_GetLibStatistics_Proxy(
2092 ULONG
* pcUniqueNames
,
2093 ULONG
* pcchUniqueNames
)
2095 FIXME("not implemented\n");
2099 HRESULT __RPC_STUB
ITypeLib2_GetLibStatistics_Stub(
2101 ULONG
* pcUniqueNames
,
2102 ULONG
* pcchUniqueNames
)
2104 FIXME("not implemented\n");
2108 HRESULT CALLBACK
ITypeLib2_GetDocumentation2_Proxy(ITypeLib2
*This
, INT index
,
2109 LCID lcid
, BSTR
*help_string
,
2110 DWORD
*help_context
, BSTR
*help_dll
)
2112 DWORD dummy_help_context
, flags
= 0;
2113 BSTR dummy_help_string
, dummy_help_dll
;
2115 TRACE("(%p, %d, %08x, %p, %p, %p)\n", This
, index
, lcid
, help_string
, help_context
, help_dll
);
2117 if(!help_string
) help_string
= &dummy_help_string
;
2120 if(!help_context
) help_context
= &dummy_help_context
;
2123 if(!help_dll
) help_dll
= &dummy_help_dll
;
2126 hr
= ITypeLib2_RemoteGetDocumentation2_Proxy(This
, index
, lcid
, flags
, help_string
, help_context
, help_dll
);
2128 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2133 HRESULT __RPC_STUB
ITypeLib2_GetDocumentation2_Stub(ITypeLib2
*This
, INT index
, LCID lcid
,
2134 DWORD flags
, BSTR
*help_string
,
2135 DWORD
*help_context
, BSTR
*help_dll
)
2137 TRACE("(%p, %d, %08x, %08x, %p, %p, %p)\n", This
, index
, lcid
, flags
, help_string
, help_context
, help_dll
);
2139 *help_string
= *help_dll
= NULL
;
2142 if(!(flags
& 1)) help_string
= NULL
;
2143 if(!(flags
& 2)) help_context
= NULL
;
2144 if(!(flags
& 4)) help_dll
= NULL
;
2146 return ITypeLib2_GetDocumentation2(This
, index
, lcid
, help_string
, help_context
, help_dll
);
2149 HRESULT CALLBACK
IPropertyBag_Read_Proxy(
2151 LPCOLESTR pszPropName
,
2153 IErrorLog
*pErrorLog
)
2155 IUnknown
*pUnk
= NULL
;
2156 TRACE("(%p, %s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
2161 if(V_VT(pVar
) & (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2163 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2170 pUnk
= (IUnknown
*)V_DISPATCH(pVar
);
2173 pUnk
= V_UNKNOWN(pVar
);
2176 FIXME("Safearray support not yet implemented.\n");
2179 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar
));
2183 return IPropertyBag_RemoteRead_Proxy(This
, pszPropName
, pVar
, pErrorLog
,
2187 HRESULT __RPC_STUB
IPropertyBag_Read_Stub(
2189 LPCOLESTR pszPropName
,
2191 IErrorLog
*pErrorLog
,
2195 static const WCHAR emptyWstr
[] = {0};
2198 TRACE("(%p, %s, %p, %p, %x, %p)\n", This
, debugstr_w(pszPropName
), pVar
,
2199 pErrorLog
, varType
, pUnkObj
);
2201 if(varType
& (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2203 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2207 V_VT(pVar
) = varType
;
2211 hr
= IUnknown_QueryInterface(pUnkObj
, &IID_IDispatch
, (LPVOID
*)&disp
);
2214 IUnknown_Release(pUnkObj
);
2215 V_DISPATCH(pVar
) = disp
;
2218 V_UNKNOWN(pVar
) = pUnkObj
;
2221 V_BSTR(pVar
) = SysAllocString(emptyWstr
);
2224 FIXME("Safearray support not yet implemented.\n");
2229 hr
= IPropertyBag_Read(This
, pszPropName
, pVar
, pErrorLog
);
2236 /* call_as/local stubs for ocidl.idl */
2238 HRESULT CALLBACK
IClassFactory2_CreateInstanceLic_Proxy(
2239 IClassFactory2
* This
,
2240 IUnknown
*pUnkOuter
,
2241 IUnknown
*pUnkReserved
,
2246 TRACE("(%p, %s, %p)\n", pUnkOuter
, debugstr_guid(riid
), ppvObj
);
2252 ERR("aggregation is not allowed on remote objects\n");
2253 return CLASS_E_NOAGGREGATION
;
2256 return IClassFactory2_RemoteCreateInstanceLic_Proxy(This
, riid
, bstrKey
, (IUnknown
**)ppvObj
);
2259 HRESULT __RPC_STUB
IClassFactory2_CreateInstanceLic_Stub(
2260 IClassFactory2
* This
,
2265 TRACE("(%s, %p)\n", debugstr_guid(riid
), ppvObj
);
2266 return IClassFactory2_CreateInstanceLic(This
, NULL
, NULL
, riid
, bstrKey
, (void**)ppvObj
);
2269 HRESULT CALLBACK
IEnumConnections_Next_Proxy(
2270 IEnumConnections
* This
,
2275 FIXME("not implemented\n");
2279 HRESULT __RPC_STUB
IEnumConnections_Next_Stub(
2280 IEnumConnections
* This
,
2285 FIXME("not implemented\n");
2289 HRESULT CALLBACK
IEnumConnectionPoints_Next_Proxy(
2290 IEnumConnectionPoints
* This
,
2292 LPCONNECTIONPOINT
*ppCP
,
2295 FIXME("not implemented\n");
2299 HRESULT __RPC_STUB
IEnumConnectionPoints_Next_Stub(
2300 IEnumConnectionPoints
* This
,
2302 LPCONNECTIONPOINT
*ppCP
,
2305 FIXME("not implemented\n");
2309 HRESULT CALLBACK
IPersistMemory_Load_Proxy(
2310 IPersistMemory
* This
,
2314 FIXME("not implemented\n");
2318 HRESULT __RPC_STUB
IPersistMemory_Load_Stub(
2319 IPersistMemory
* This
,
2323 FIXME("not implemented\n");
2327 HRESULT CALLBACK
IPersistMemory_Save_Proxy(
2328 IPersistMemory
* This
,
2333 FIXME("not implemented\n");
2337 HRESULT __RPC_STUB
IPersistMemory_Save_Stub(
2338 IPersistMemory
* This
,
2343 FIXME("not implemented\n");
2347 void CALLBACK
IAdviseSinkEx_OnViewStatusChange_Proxy(
2348 IAdviseSinkEx
* This
,
2351 FIXME("not implemented\n");
2354 HRESULT __RPC_STUB
IAdviseSinkEx_OnViewStatusChange_Stub(
2355 IAdviseSinkEx
* This
,
2358 FIXME("not implemented\n");
2362 HRESULT CALLBACK
IEnumOleUndoUnits_Next_Proxy(
2363 IEnumOleUndoUnits
* This
,
2365 IOleUndoUnit
**rgElt
,
2366 ULONG
*pcEltFetched
)
2368 FIXME("not implemented\n");
2372 HRESULT __RPC_STUB
IEnumOleUndoUnits_Next_Stub(
2373 IEnumOleUndoUnits
* This
,
2375 IOleUndoUnit
**rgElt
,
2376 ULONG
*pcEltFetched
)
2378 FIXME("not implemented\n");
2382 HRESULT CALLBACK
IQuickActivate_QuickActivate_Proxy(
2383 IQuickActivate
* This
,
2384 QACONTAINER
*pQaContainer
,
2385 QACONTROL
*pQaControl
)
2387 FIXME("not implemented\n");
2391 HRESULT __RPC_STUB
IQuickActivate_QuickActivate_Stub(
2392 IQuickActivate
* This
,
2393 QACONTAINER
*pQaContainer
,
2394 QACONTROL
*pQaControl
)
2396 FIXME("not implemented\n");