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 SysFreeString(*pstr
);
173 if(header
->byte_len
!= 0xffffffff)
174 *pstr
= SysAllocStringByteLen((char*)(header
+ 1), header
->byte_len
);
176 if (*pstr
) TRACE("string=%s\n", debugstr_w(*pstr
));
177 return Buffer
+ sizeof(*header
) + sizeof(OLECHAR
) * header
->len
;
180 void WINAPI
BSTR_UserFree(ULONG
*pFlags
, BSTR
*pstr
)
182 TRACE("(%x,%p) => %p\n", *pFlags
, pstr
, *pstr
);
183 SysFreeString(*pstr
);
200 static unsigned int get_type_size(ULONG
*pFlags
, VARTYPE vt
)
202 if (vt
& VT_ARRAY
) return 4;
204 switch (vt
& ~VT_BYREF
) {
213 return sizeof(SHORT
);
221 return sizeof(FLOAT
);
223 return sizeof(DOUBLE
);
225 return sizeof(VARIANT_BOOL
);
227 return sizeof(SCODE
);
233 return sizeof(DECIMAL
);
235 return sizeof(ULONG
);
237 return sizeof(VARIANT
);
243 FIXME("unhandled VT %d\n", vt
);
248 static unsigned int get_type_alignment(ULONG
*pFlags
, VARTYPE vt
)
250 unsigned int size
= get_type_size(pFlags
, vt
);
251 if(vt
& VT_BYREF
) return 3;
252 if(size
== 0) return 0;
253 if(size
<= 4) return size
- 1;
257 static unsigned interface_variant_size(const ULONG
*pFlags
, REFIID riid
, IUnknown
*punk
)
264 hr
= CoGetMarshalSizeMax(&size
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
267 ERR("interface variant buffer size calculation failed, HRESULT=0x%x\n", hr
);
271 size
+= sizeof(ULONG
); /* we have to store the buffersize in the stream */
272 TRACE("wire-size extra of interface variant is %d\n", size
);
276 static ULONG
wire_extra_user_size(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
281 return LPSAFEARRAY_UserSize(pFlags
, Start
, V_ARRAYREF(pvar
));
283 return LPSAFEARRAY_UserSize(pFlags
, Start
, &V_ARRAY(pvar
));
286 switch (V_VT(pvar
)) {
288 return BSTR_UserSize(pFlags
, Start
, &V_BSTR(pvar
));
289 case VT_BSTR
| VT_BYREF
:
290 return BSTR_UserSize(pFlags
, Start
, V_BSTRREF(pvar
));
291 case VT_VARIANT
| VT_BYREF
:
292 return VARIANT_UserSize(pFlags
, Start
, V_VARIANTREF(pvar
));
294 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, V_UNKNOWN(pvar
));
295 case VT_UNKNOWN
| VT_BYREF
:
296 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
298 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
299 case VT_DISPATCH
| VT_BYREF
:
300 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
302 FIXME("wire-size record\n");
305 case VT_SAFEARRAY
| VT_BYREF
:
306 FIXME("wire-size safearray: shouldn't be marshaling this\n");
313 /* helper: called for VT_DISPATCH variants to marshal the IDispatch* into the buffer. returns Buffer on failure, new position otherwise */
314 static unsigned char* interface_variant_marshal(const ULONG
*pFlags
, unsigned char *Buffer
,
315 REFIID riid
, IUnknown
*punk
)
319 void *working_memlocked
;
320 unsigned char *oldpos
;
324 TRACE("pFlags=%d, Buffer=%p, pUnk=%p\n", *pFlags
, Buffer
, punk
);
328 memset(Buffer
, 0, sizeof(ULONG
));
329 return Buffer
+ sizeof(ULONG
);
334 /* CoMarshalInterface needs a stream, whereas at this level we are operating in terms of buffers.
335 * We create a stream on an HGLOBAL, so we can simply do a memcpy to move it to the buffer.
336 * in rpcrt4/ndr_ole.c, a simple IStream implementation is wrapped around the buffer object,
337 * but that would be overkill here, hence this implementation. We save the size because the unmarshal
338 * code has no way to know how long the marshalled buffer is. */
340 size
= interface_variant_size(pFlags
, riid
, punk
);
342 working_mem
= GlobalAlloc(0, size
);
343 if (!working_mem
) return oldpos
;
345 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
347 GlobalFree(working_mem
);
351 hr
= CoMarshalInterface(working
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
353 IStream_Release(working
); /* this also releases the hglobal */
357 working_memlocked
= GlobalLock(working_mem
);
358 memcpy(Buffer
, &size
, sizeof(ULONG
)); /* copy the buffersize */
359 memcpy(Buffer
+ sizeof(ULONG
), working_memlocked
, size
- sizeof(ULONG
));
360 GlobalUnlock(working_mem
);
362 IStream_Release(working
);
364 /* size includes the ULONG for the size written above */
365 TRACE("done, size=%d\n", size
);
366 return Buffer
+ size
;
369 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
370 static unsigned char *interface_variant_unmarshal(const ULONG
*pFlags
, unsigned char *Buffer
,
371 REFIID riid
, IUnknown
**ppunk
)
375 void *working_memlocked
;
376 unsigned char *oldpos
;
380 TRACE("pFlags=%d, Buffer=%p, ppUnk=%p\n", *pFlags
, Buffer
, ppunk
);
384 /* get the buffersize */
385 memcpy(&size
, Buffer
, sizeof(ULONG
));
386 TRACE("buffersize=%d\n", size
);
391 return Buffer
+ sizeof(ULONG
);
394 working_mem
= GlobalAlloc(0, size
);
395 if (!working_mem
) return oldpos
;
397 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
399 GlobalFree(working_mem
);
403 working_memlocked
= GlobalLock(working_mem
);
405 /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
406 memcpy(working_memlocked
, Buffer
+ sizeof(ULONG
), size
);
407 GlobalUnlock(working_mem
);
409 hr
= CoUnmarshalInterface(working
, riid
, (void**)ppunk
);
411 IStream_Release(working
);
415 IStream_Release(working
); /* this also frees the underlying hglobal */
417 /* size includes the ULONG for the size written above */
418 TRACE("done, processed=%d bytes\n", size
);
419 return Buffer
+ size
;
423 ULONG WINAPI
VARIANT_UserSize(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
426 TRACE("(%x,%d,%p)\n", *pFlags
, Start
, pvar
);
427 TRACE("vt=%04x\n", V_VT(pvar
));
429 ALIGN_LENGTH(Start
, 7);
430 Start
+= sizeof(variant_wire_t
);
431 if(V_VT(pvar
) & VT_BYREF
)
434 align
= get_type_alignment(pFlags
, V_VT(pvar
));
435 ALIGN_LENGTH(Start
, align
);
436 if(V_VT(pvar
) == (VT_VARIANT
| VT_BYREF
))
439 Start
+= get_type_size(pFlags
, V_VT(pvar
));
440 Start
= wire_extra_user_size(pFlags
, Start
, pvar
);
442 TRACE("returning %d\n", Start
);
446 unsigned char * WINAPI
VARIANT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
448 variant_wire_t
*header
;
453 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
454 TRACE("vt=%04x\n", V_VT(pvar
));
456 ALIGN_POINTER(Buffer
, 7);
458 header
= (variant_wire_t
*)Buffer
;
460 header
->clSize
= 0; /* fixed up at the end */
461 header
->rpcReserverd
= 0;
462 header
->vt
= pvar
->n1
.n2
.vt
;
463 header
->wReserved1
= pvar
->n1
.n2
.wReserved1
;
464 header
->wReserved2
= pvar
->n1
.n2
.wReserved2
;
465 header
->wReserved3
= pvar
->n1
.n2
.wReserved3
;
466 header
->switch_is
= pvar
->n1
.n2
.vt
;
467 if(header
->switch_is
& VT_ARRAY
)
468 header
->switch_is
&= ~VT_TYPEMASK
;
470 Pos
= (unsigned char*)(header
+ 1);
471 type_size
= get_type_size(pFlags
, V_VT(pvar
));
472 align
= get_type_alignment(pFlags
, V_VT(pvar
));
473 ALIGN_POINTER(Pos
, align
);
475 if(header
->vt
& VT_BYREF
)
477 *(DWORD
*)Pos
= max(type_size
, 4);
479 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
481 memcpy(Pos
, pvar
->n1
.n2
.n3
.byref
, type_size
);
486 *(DWORD
*)Pos
= 'U' | 's' << 8 | 'e' << 16 | 'r' << 24;
492 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
493 memcpy(Pos
, pvar
, type_size
);
495 memcpy(Pos
, &pvar
->n1
.n2
.n3
, type_size
);
499 if(header
->vt
& VT_ARRAY
)
501 if(header
->vt
& VT_BYREF
)
502 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
504 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
511 Pos
= BSTR_UserMarshal(pFlags
, Pos
, &V_BSTR(pvar
));
513 case VT_BSTR
| VT_BYREF
:
514 Pos
= BSTR_UserMarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
516 case VT_VARIANT
| VT_BYREF
:
517 Pos
= VARIANT_UserMarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
520 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
521 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWN(pvar
));
523 case VT_UNKNOWN
| VT_BYREF
:
524 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
525 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
528 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
529 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
531 case VT_DISPATCH
| VT_BYREF
:
532 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
533 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
536 FIXME("handle BRECORD by val\n");
538 case VT_RECORD
| VT_BYREF
:
539 FIXME("handle BRECORD by ref\n");
543 header
->clSize
= ((Pos
- Buffer
) + 7) >> 3;
544 TRACE("marshalled size=%d\n", header
->clSize
);
548 unsigned char * WINAPI
VARIANT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
550 variant_wire_t
*header
;
555 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
557 ALIGN_POINTER(Buffer
, 7);
559 header
= (variant_wire_t
*)Buffer
;
561 Pos
= (unsigned char*)(header
+ 1);
562 type_size
= get_type_size(pFlags
, header
->vt
);
563 align
= get_type_alignment(pFlags
, header
->vt
);
564 ALIGN_POINTER(Pos
, align
);
566 if(header
->vt
& VT_BYREF
)
571 switch (header
->vt
& ~VT_BYREF
)
573 /* these types have a different memory size compared to wire size */
577 mem_size
= sizeof(void *);
580 mem_size
= type_size
;
584 if (V_VT(pvar
) != header
->vt
)
587 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
589 else if (!V_BYREF(pvar
))
590 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
591 memcpy(V_BYREF(pvar
), Pos
, type_size
);
592 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
600 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
601 memcpy(pvar
, Pos
, type_size
);
603 memcpy(&pvar
->n1
.n2
.n3
, Pos
, type_size
);
607 pvar
->n1
.n2
.vt
= header
->vt
;
608 pvar
->n1
.n2
.wReserved1
= header
->wReserved1
;
609 pvar
->n1
.n2
.wReserved2
= header
->wReserved2
;
610 pvar
->n1
.n2
.wReserved3
= header
->wReserved3
;
612 if(header
->vt
& VT_ARRAY
)
614 if(header
->vt
& VT_BYREF
)
615 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
617 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
625 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, &V_BSTR(pvar
));
627 case VT_BSTR
| VT_BYREF
:
628 *V_BSTRREF(pvar
) = NULL
;
629 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
631 case VT_VARIANT
| VT_BYREF
:
632 Pos
= VARIANT_UserUnmarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
635 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
636 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, &V_UNKNOWN(pvar
));
638 case VT_UNKNOWN
| VT_BYREF
:
639 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
640 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWNREF(pvar
));
643 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
644 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)&V_DISPATCH(pvar
));
646 case VT_DISPATCH
| VT_BYREF
:
647 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
648 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)V_DISPATCHREF(pvar
));
651 FIXME("handle BRECORD by val\n");
653 case VT_RECORD
| VT_BYREF
:
654 FIXME("handle BRECORD by ref\n");
661 void WINAPI
VARIANT_UserFree(ULONG
*pFlags
, VARIANT
*pvar
)
663 VARTYPE vt
= V_VT(pvar
);
666 TRACE("(%x,%p)\n", *pFlags
, pvar
);
667 TRACE("vt=%04x\n", V_VT(pvar
));
669 if (vt
& VT_BYREF
) ref
= pvar
->n1
.n2
.n3
.byref
;
677 LPSAFEARRAY_UserFree(pFlags
, V_ARRAYREF(pvar
));
679 LPSAFEARRAY_UserFree(pFlags
, &V_ARRAY(pvar
));
685 case VT_BSTR
| VT_BYREF
:
686 BSTR_UserFree(pFlags
, V_BSTRREF(pvar
));
688 case VT_VARIANT
| VT_BYREF
:
689 VARIANT_UserFree(pFlags
, V_VARIANTREF(pvar
));
691 case VT_RECORD
| VT_BYREF
:
692 FIXME("handle BRECORD by ref\n");
694 case VT_UNKNOWN
| VT_BYREF
:
695 case VT_DISPATCH
| VT_BYREF
:
696 IUnknown_Release(*V_UNKNOWNREF(pvar
));
706 /* Get the number of cells in a SafeArray */
707 static ULONG
SAFEARRAY_GetCellCount(const SAFEARRAY
*psa
)
709 const SAFEARRAYBOUND
* psab
= psa
->rgsabound
;
710 USHORT cCount
= psa
->cDims
;
711 ULONG ulNumCells
= 1;
715 /* This is a valid bordercase. See testcases. -Marcus */
716 if (!psab
->cElements
)
718 ulNumCells
*= psab
->cElements
;
724 static inline SF_TYPE
SAFEARRAY_GetUnionType(SAFEARRAY
*psa
)
729 hr
= SafeArrayGetVartype(psa
, &vt
);
732 if(psa
->fFeatures
& FADF_VARIANT
) return SF_VARIANT
;
734 switch(psa
->cbElements
)
736 case 1: vt
= VT_I1
; break;
737 case 2: vt
= VT_I2
; break;
738 case 4: vt
= VT_I4
; break;
739 case 8: vt
= VT_I8
; break;
741 RpcRaiseException(hr
);
745 if (psa
->fFeatures
& FADF_HAVEIID
)
751 case VT_UI1
: return SF_I1
;
754 case VT_UI2
: return SF_I2
;
759 case VT_R4
: return SF_I4
;
764 case VT_UI8
: return SF_I8
;
766 case VT_UINT_PTR
: return (sizeof(UINT_PTR
) == 4 ? SF_I4
: SF_I8
);
767 case VT_BSTR
: return SF_BSTR
;
768 case VT_DISPATCH
: return SF_DISPATCH
;
769 case VT_VARIANT
: return SF_VARIANT
;
770 case VT_UNKNOWN
: return SF_UNKNOWN
;
771 /* Note: Return a non-zero size to indicate vt is valid. The actual size
772 * of a UDT is taken from the result of IRecordInfo_GetSize().
774 case VT_RECORD
: return SF_RECORD
;
775 default: return SF_ERROR
;
779 static DWORD
elem_wire_size(LPSAFEARRAY lpsa
, SF_TYPE sftype
)
781 if (sftype
== SF_BSTR
)
782 return sizeof(DWORD
);
783 else if (sftype
== SF_VARIANT
)
784 return sizeof(variant_wire_t
) - sizeof(DWORD
);
786 return lpsa
->cbElements
;
789 static DWORD
elem_mem_size(wireSAFEARRAY wiresa
, SF_TYPE sftype
)
791 if (sftype
== SF_BSTR
)
793 else if (sftype
== SF_VARIANT
)
794 return sizeof(VARIANT
);
796 return wiresa
->cbElements
;
799 ULONG WINAPI
LPSAFEARRAY_UserSize(ULONG
*pFlags
, ULONG StartingSize
, LPSAFEARRAY
*ppsa
)
801 ULONG size
= StartingSize
;
803 TRACE("("); dump_user_flags(pFlags
); TRACE(", %d, %p\n", StartingSize
, *ppsa
);
805 ALIGN_LENGTH(size
, 3);
806 size
+= sizeof(ULONG
);
809 SAFEARRAY
*psa
= *ppsa
;
810 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
814 size
+= sizeof(ULONG
);
815 size
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
817 sftype
= SAFEARRAY_GetUnionType(psa
);
818 size
+= sizeof(ULONG
);
820 size
+= sizeof(ULONG
);
821 size
+= sizeof(ULONG
);
822 if (sftype
== SF_HAVEIID
)
825 size
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
827 size
+= sizeof(ULONG
);
835 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
836 size
= BSTR_UserSize(pFlags
, size
, lpBstr
);
843 FIXME("size interfaces\n");
849 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
850 size
= VARIANT_UserSize(pFlags
, size
, lpVariant
);
856 IRecordInfo
* pRecInfo
= NULL
;
858 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
860 RpcRaiseException(hr
);
864 FIXME("size record info %p\n", pRecInfo
);
866 IRecordInfo_Release(pRecInfo
);
871 ALIGN_LENGTH(size
, 7);
876 size
+= ulCellCount
* psa
->cbElements
;
887 unsigned char * WINAPI
LPSAFEARRAY_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
891 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, &%p\n", Buffer
, *ppsa
);
893 ALIGN_POINTER(Buffer
, 3);
894 *(ULONG
*)Buffer
= *ppsa
? 0x1 : 0x0;
895 Buffer
+= sizeof(ULONG
);
899 SAFEARRAY
*psa
= *ppsa
;
900 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
904 sftype
= SAFEARRAY_GetUnionType(psa
);
906 *(ULONG
*)Buffer
= psa
->cDims
;
907 Buffer
+= sizeof(ULONG
);
908 *(USHORT
*)Buffer
= psa
->cDims
;
909 Buffer
+= sizeof(USHORT
);
910 *(USHORT
*)Buffer
= psa
->fFeatures
;
911 Buffer
+= sizeof(USHORT
);
912 *(ULONG
*)Buffer
= elem_wire_size(psa
, sftype
);
913 Buffer
+= sizeof(ULONG
);
915 hr
= SafeArrayGetVartype(psa
, &vt
);
916 if (FAILED(hr
)) vt
= 0;
918 *(ULONG
*)Buffer
= (USHORT
)psa
->cLocks
| (vt
<< 16);
919 Buffer
+= sizeof(ULONG
);
921 *(ULONG
*)Buffer
= sftype
;
922 Buffer
+= sizeof(ULONG
);
924 *(ULONG
*)Buffer
= ulCellCount
;
925 Buffer
+= sizeof(ULONG
);
926 *(ULONG
*)Buffer
= psa
->pvData
? 0x2 : 0x0;
927 Buffer
+= sizeof(ULONG
);
928 if (sftype
== SF_HAVEIID
)
930 SafeArrayGetIID(psa
, &guid
);
931 memcpy(Buffer
, &guid
, sizeof(guid
));
932 Buffer
+= sizeof(guid
);
935 memcpy(Buffer
, psa
->rgsabound
, sizeof(psa
->rgsabound
[0]) * psa
->cDims
);
936 Buffer
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
938 *(ULONG
*)Buffer
= ulCellCount
;
939 Buffer
+= sizeof(ULONG
);
949 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
950 Buffer
= BSTR_UserMarshal(pFlags
, Buffer
, lpBstr
);
957 FIXME("marshal interfaces\n");
963 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
964 Buffer
= VARIANT_UserMarshal(pFlags
, Buffer
, lpVariant
);
970 IRecordInfo
* pRecInfo
= NULL
;
972 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
974 RpcRaiseException(hr
);
978 FIXME("write record info %p\n", pRecInfo
);
980 IRecordInfo_Release(pRecInfo
);
986 ALIGN_POINTER(Buffer
, 7);
991 /* Just copy the data over */
992 memcpy(Buffer
, psa
->pvData
, ulCellCount
* psa
->cbElements
);
993 Buffer
+= ulCellCount
* psa
->cbElements
;
1004 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
1005 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
1006 FADF_VARIANT | FADF_CREATEVECTOR)
1008 unsigned char * WINAPI
LPSAFEARRAY_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
1011 wireSAFEARRAY wiresa
;
1018 SAFEARRAYBOUND
*wiresab
;
1020 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, %p\n", Buffer
, ppsa
);
1022 ALIGN_POINTER(Buffer
, 3);
1023 ptr
= *(ULONG
*)Buffer
;
1024 Buffer
+= sizeof(ULONG
);
1030 TRACE("NULL safe array unmarshaled\n");
1035 cDims
= *(ULONG
*)Buffer
;
1036 Buffer
+= sizeof(ULONG
);
1038 wiresa
= (wireSAFEARRAY
)Buffer
;
1039 Buffer
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
1041 if (cDims
!= wiresa
->cDims
)
1042 RpcRaiseException(RPC_S_INVALID_BOUND
);
1044 /* FIXME: there should be a limit on how large cDims can be */
1046 vt
= HIWORD(wiresa
->cLocks
);
1048 sftype
= *(ULONG
*)Buffer
;
1049 Buffer
+= sizeof(ULONG
);
1051 cell_count
= *(ULONG
*)Buffer
;
1052 Buffer
+= sizeof(ULONG
);
1053 ptr
= *(ULONG
*)Buffer
;
1054 Buffer
+= sizeof(ULONG
);
1055 if (sftype
== SF_HAVEIID
)
1057 memcpy(&guid
, Buffer
, sizeof(guid
));
1058 Buffer
+= sizeof(guid
);
1061 wiresab
= (SAFEARRAYBOUND
*)Buffer
;
1062 Buffer
+= sizeof(wiresab
[0]) * wiresa
->cDims
;
1065 *ppsa
= SafeArrayCreateEx(vt
, wiresa
->cDims
, wiresab
, NULL
);
1068 SafeArrayAllocDescriptor(wiresa
->cDims
, ppsa
);
1070 memcpy((*ppsa
)->rgsabound
, wiresab
, sizeof(SAFEARRAYBOUND
) * wiresa
->cDims
);
1073 RpcRaiseException(E_OUTOFMEMORY
);
1075 /* be careful about which flags we set since they could be a security
1077 (*ppsa
)->fFeatures
&= FADF_AUTOSETFLAGS
;
1078 (*ppsa
)->fFeatures
|= (wiresa
->fFeatures
& ~(FADF_AUTOSETFLAGS
));
1079 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1080 (*ppsa
)->cbElements
= elem_mem_size(wiresa
, sftype
);
1081 (*ppsa
)->cLocks
= LOWORD(wiresa
->cLocks
);
1083 /* SafeArrayCreateEx allocates the data for us, but
1084 * SafeArrayAllocDescriptor doesn't */
1087 hr
= SafeArrayAllocData(*ppsa
);
1089 RpcRaiseException(hr
);
1092 if ((*(ULONG
*)Buffer
!= cell_count
) || (SAFEARRAY_GetCellCount(*ppsa
) != cell_count
))
1093 RpcRaiseException(RPC_S_INVALID_BOUND
);
1094 Buffer
+= sizeof(ULONG
);
1104 for (lpBstr
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpBstr
++)
1105 Buffer
= BSTR_UserUnmarshal(pFlags
, Buffer
, lpBstr
);
1112 FIXME("marshal interfaces\n");
1118 for (lpVariant
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpVariant
++)
1119 Buffer
= VARIANT_UserUnmarshal(pFlags
, Buffer
, lpVariant
);
1125 FIXME("set record info\n");
1131 ALIGN_POINTER(Buffer
, 7);
1136 /* Just copy the data over */
1137 memcpy((*ppsa
)->pvData
, Buffer
, cell_count
* (*ppsa
)->cbElements
);
1138 Buffer
+= cell_count
* (*ppsa
)->cbElements
;
1145 TRACE("safe array unmarshaled: %p\n", *ppsa
);
1150 void WINAPI
LPSAFEARRAY_UserFree(ULONG
*pFlags
, LPSAFEARRAY
*ppsa
)
1152 TRACE("("); dump_user_flags(pFlags
); TRACE(", &%p\n", *ppsa
);
1154 SafeArrayDestroy(*ppsa
);
1158 ULONG WINAPI
HFONT_UserSize(ULONG
*pFlags
, ULONG Start
, HFONT
*phfont
)
1164 unsigned char * WINAPI
HFONT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1170 unsigned char * WINAPI
HFONT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1176 void WINAPI
HFONT_UserFree(ULONG
*pFlags
, HFONT
*phfont
)
1184 /* exactly how Invoke is marshalled is not very clear to me yet,
1185 * but the way I've done it seems to work for me */
1187 HRESULT CALLBACK
IDispatch_Invoke_Proxy(
1189 DISPID dispIdMember
,
1193 DISPPARAMS
* pDispParams
,
1194 VARIANT
* pVarResult
,
1195 EXCEPINFO
* pExcepInfo
,
1200 UINT
* rgVarRefIdx
= NULL
;
1201 VARIANTARG
* rgVarRef
= NULL
;
1204 EXCEPINFO ExcepInfo
;
1206 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This
,
1207 dispIdMember
, debugstr_guid(riid
),
1208 lcid
, wFlags
, pDispParams
, pVarResult
,
1209 pExcepInfo
, puArgErr
);
1211 /* [out] args can't be null, use dummy vars if needed */
1212 if (!pVarResult
) pVarResult
= &VarResult
;
1213 if (!puArgErr
) puArgErr
= &uArgErr
;
1214 if (!pExcepInfo
) pExcepInfo
= &ExcepInfo
;
1216 /* count by-ref args */
1217 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1218 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1219 if (V_ISBYREF(arg
)) {
1224 rgVarRefIdx
= CoTaskMemAlloc(sizeof(UINT
)*cVarRef
);
1225 rgVarRef
= CoTaskMemAlloc(sizeof(VARIANTARG
)*cVarRef
);
1226 /* make list of by-ref args */
1227 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1228 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1229 if (V_ISBYREF(arg
)) {
1230 rgVarRefIdx
[cVarRef
] = u
;
1231 VariantInit(&rgVarRef
[cVarRef
]);
1232 VariantCopy(&rgVarRef
[cVarRef
], arg
);
1238 /* [out] args still can't be null,
1239 * but we can point these anywhere in this case,
1240 * since they won't be written to when cVarRef is 0 */
1241 rgVarRefIdx
= puArgErr
;
1242 rgVarRef
= pVarResult
;
1244 TRACE("passed by ref: %d args\n", cVarRef
);
1245 hr
= IDispatch_RemoteInvoke_Proxy(This
,
1258 for (u
=0; u
<cVarRef
; u
++) {
1259 unsigned i
= rgVarRefIdx
[u
];
1260 VariantCopy(&pDispParams
->rgvarg
[i
],
1262 VariantClear(&rgVarRef
[u
]);
1264 CoTaskMemFree(rgVarRef
);
1265 CoTaskMemFree(rgVarRefIdx
);
1268 if(pExcepInfo
== &ExcepInfo
)
1270 SysFreeString(pExcepInfo
->bstrSource
);
1271 SysFreeString(pExcepInfo
->bstrDescription
);
1272 SysFreeString(pExcepInfo
->bstrHelpFile
);
1277 HRESULT __RPC_STUB
IDispatch_Invoke_Stub(
1279 DISPID dispIdMember
,
1283 DISPPARAMS
* pDispParams
,
1284 VARIANT
* pVarResult
,
1285 EXCEPINFO
* pExcepInfo
,
1289 VARIANTARG
* rgVarRef
)
1292 VARIANTARG
*rgvarg
, *arg
;
1295 /* initialize out parameters, so that they can be marshalled
1296 * in case the real Invoke doesn't initialize them */
1297 VariantInit(pVarResult
);
1298 memset(pExcepInfo
, 0, sizeof(*pExcepInfo
));
1301 /* let the real Invoke operate on a copy of the in parameters,
1302 * so we don't risk losing pointers to allocated memory */
1303 rgvarg
= pDispParams
->rgvarg
;
1304 arg
= CoTaskMemAlloc(sizeof(VARIANTARG
)*pDispParams
->cArgs
);
1305 if (!arg
) return E_OUTOFMEMORY
;
1307 /* init all args so we can call VariantClear on all the args if the copy
1309 for (u
= 0; u
< pDispParams
->cArgs
; u
++)
1310 VariantInit(&arg
[u
]);
1312 for (u
= 0; u
< pDispParams
->cArgs
; u
++) {
1313 hr
= VariantCopy(&arg
[u
], &rgvarg
[u
]);
1318 if (SUCCEEDED(hr
)) {
1319 /* copy ref args to arg array */
1320 for (u
=0; u
<cVarRef
; u
++) {
1321 unsigned i
= rgVarRefIdx
[u
];
1322 VariantCopy(&arg
[i
], &rgVarRef
[u
]);
1325 pDispParams
->rgvarg
= arg
;
1327 hr
= IDispatch_Invoke(This
,
1337 /* copy ref args from arg array */
1338 for (u
=0; u
<cVarRef
; u
++) {
1339 unsigned i
= rgVarRefIdx
[u
];
1340 VariantCopy(&rgVarRef
[u
], &arg
[i
]);
1344 /* clear the duplicate argument list */
1345 for (u
=0; u
<pDispParams
->cArgs
; u
++)
1346 VariantClear(&arg
[u
]);
1348 pDispParams
->rgvarg
= rgvarg
;
1356 HRESULT CALLBACK
IEnumVARIANT_Next_Proxy(
1360 ULONG
* pCeltFetched
)
1364 pCeltFetched
= &fetched
;
1365 return IEnumVARIANT_RemoteNext_Proxy(This
,
1371 HRESULT __RPC_STUB
IEnumVARIANT_Next_Stub(
1375 ULONG
* pCeltFetched
)
1379 hr
= IEnumVARIANT_Next(This
,
1383 if (hr
== S_OK
) *pCeltFetched
= celt
;
1387 /* TypeInfo related freers */
1389 static void free_embedded_typedesc(TYPEDESC
*tdesc
);
1390 static void free_embedded_arraydesc(ARRAYDESC
*adesc
)
1392 switch(adesc
->tdescElem
.vt
)
1396 free_embedded_typedesc(adesc
->tdescElem
.u
.lptdesc
);
1397 CoTaskMemFree(adesc
->tdescElem
.u
.lptdesc
);
1400 free_embedded_arraydesc(adesc
->tdescElem
.u
.lpadesc
);
1401 CoTaskMemFree(adesc
->tdescElem
.u
.lpadesc
);
1406 static void free_embedded_typedesc(TYPEDESC
*tdesc
)
1412 free_embedded_typedesc(tdesc
->u
.lptdesc
);
1413 CoTaskMemFree(tdesc
->u
.lptdesc
);
1416 free_embedded_arraydesc(tdesc
->u
.lpadesc
);
1417 CoTaskMemFree(tdesc
->u
.lpadesc
);
1422 static void free_embedded_elemdesc(ELEMDESC
*edesc
)
1424 free_embedded_typedesc(&edesc
->tdesc
);
1425 if(edesc
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
1426 CoTaskMemFree(edesc
->u
.paramdesc
.pparamdescex
);
1431 HRESULT CALLBACK
ITypeComp_Bind_Proxy(
1436 ITypeInfo
** ppTInfo
,
1437 DESCKIND
* pDescKind
,
1440 FIXME("not implemented\n");
1444 HRESULT __RPC_STUB
ITypeComp_Bind_Stub(
1449 ITypeInfo
** ppTInfo
,
1450 DESCKIND
* pDescKind
,
1451 LPFUNCDESC
* ppFuncDesc
,
1452 LPVARDESC
* ppVarDesc
,
1453 ITypeComp
** ppTypeComp
,
1454 CLEANLOCALSTORAGE
* pDummy
)
1456 FIXME("not implemented\n");
1460 HRESULT CALLBACK
ITypeComp_BindType_Proxy(
1464 ITypeInfo
** ppTInfo
,
1465 ITypeComp
** ppTComp
)
1467 FIXME("not implemented\n");
1471 HRESULT __RPC_STUB
ITypeComp_BindType_Stub(
1475 ITypeInfo
** ppTInfo
)
1477 FIXME("not implemented\n");
1483 HRESULT CALLBACK
ITypeInfo_GetTypeAttr_Proxy(
1485 TYPEATTR
** ppTypeAttr
)
1488 CLEANLOCALSTORAGE stg
;
1489 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1492 stg
.pStorage
= NULL
;
1493 stg
.pInterface
= NULL
;
1495 return ITypeInfo_RemoteGetTypeAttr_Proxy(This
, ppTypeAttr
, &stg
);
1498 HRESULT __RPC_STUB
ITypeInfo_GetTypeAttr_Stub(
1500 LPTYPEATTR
* ppTypeAttr
,
1501 CLEANLOCALSTORAGE
* pDummy
)
1504 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1506 hr
= ITypeInfo_GetTypeAttr(This
, ppTypeAttr
);
1510 pDummy
->flags
= CLS_TYPEATTR
;
1511 ITypeInfo_AddRef(This
);
1512 pDummy
->pInterface
= (IUnknown
*)This
;
1513 pDummy
->pStorage
= ppTypeAttr
;
1517 HRESULT CALLBACK
ITypeInfo_GetFuncDesc_Proxy(
1520 FUNCDESC
** ppFuncDesc
)
1522 CLEANLOCALSTORAGE stg
;
1523 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1526 stg
.pStorage
= NULL
;
1527 stg
.pInterface
= NULL
;
1529 return ITypeInfo_RemoteGetFuncDesc_Proxy(This
, index
, ppFuncDesc
, &stg
);
1532 HRESULT __RPC_STUB
ITypeInfo_GetFuncDesc_Stub(
1535 LPFUNCDESC
* ppFuncDesc
,
1536 CLEANLOCALSTORAGE
* pDummy
)
1539 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1541 hr
= ITypeInfo_GetFuncDesc(This
, index
, ppFuncDesc
);
1545 pDummy
->flags
= CLS_FUNCDESC
;
1546 ITypeInfo_AddRef(This
);
1547 pDummy
->pInterface
= (IUnknown
*)This
;
1548 pDummy
->pStorage
= ppFuncDesc
;
1552 HRESULT CALLBACK
ITypeInfo_GetVarDesc_Proxy(
1555 VARDESC
** ppVarDesc
)
1557 CLEANLOCALSTORAGE stg
;
1558 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1561 stg
.pStorage
= NULL
;
1562 stg
.pInterface
= NULL
;
1564 return ITypeInfo_RemoteGetVarDesc_Proxy(This
, index
, ppVarDesc
, &stg
);
1567 HRESULT __RPC_STUB
ITypeInfo_GetVarDesc_Stub(
1570 LPVARDESC
* ppVarDesc
,
1571 CLEANLOCALSTORAGE
* pDummy
)
1574 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1576 hr
= ITypeInfo_GetVarDesc(This
, index
, ppVarDesc
);
1580 pDummy
->flags
= CLS_VARDESC
;
1581 ITypeInfo_AddRef(This
);
1582 pDummy
->pInterface
= (IUnknown
*)This
;
1583 pDummy
->pStorage
= ppVarDesc
;
1587 HRESULT CALLBACK
ITypeInfo_GetNames_Proxy(
1594 FIXME("not implemented\n");
1598 HRESULT __RPC_STUB
ITypeInfo_GetNames_Stub(
1605 FIXME("not implemented\n");
1609 HRESULT CALLBACK
ITypeInfo_GetIDsOfNames_Proxy(
1611 LPOLESTR
* rgszNames
,
1615 FIXME("not implemented\n");
1619 HRESULT __RPC_STUB
ITypeInfo_GetIDsOfNames_Stub(
1622 FIXME("not implemented\n");
1626 HRESULT CALLBACK
ITypeInfo_Invoke_Proxy(
1631 DISPPARAMS
* pDispParams
,
1632 VARIANT
* pVarResult
,
1633 EXCEPINFO
* pExcepInfo
,
1636 FIXME("not implemented\n");
1640 HRESULT __RPC_STUB
ITypeInfo_Invoke_Stub(
1643 FIXME("not implemented\n");
1647 HRESULT CALLBACK
ITypeInfo_GetDocumentation_Proxy(
1651 BSTR
* pBstrDocString
,
1652 DWORD
* pdwHelpContext
,
1653 BSTR
* pBstrHelpFile
)
1656 BSTR name
, doc_string
, help_file
;
1658 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1660 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1661 hr
= ITypeInfo_RemoteGetDocumentation_Proxy(This
, memid
, 0, &name
, &doc_string
, &help_context
, &help_file
);
1664 if(pBstrName
) *pBstrName
= name
;
1665 else SysFreeString(name
);
1667 if(pBstrDocString
) *pBstrDocString
= doc_string
;
1668 else SysFreeString(doc_string
);
1670 if(pBstrHelpFile
) *pBstrHelpFile
= help_file
;
1671 else SysFreeString(help_file
);
1673 if(pdwHelpContext
) *pdwHelpContext
= help_context
;
1678 HRESULT __RPC_STUB
ITypeInfo_GetDocumentation_Stub(
1683 BSTR
* pBstrDocString
,
1684 DWORD
* pdwHelpContext
,
1685 BSTR
* pBstrHelpFile
)
1687 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This
, memid
, refPtrFlags
, pBstrName
, pBstrDocString
,
1688 pdwHelpContext
, pBstrHelpFile
);
1689 return ITypeInfo_GetDocumentation(This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1692 HRESULT CALLBACK
ITypeInfo_GetDllEntry_Proxy(
1700 FIXME("not implemented\n");
1704 HRESULT __RPC_STUB
ITypeInfo_GetDllEntry_Stub(
1713 FIXME("not implemented\n");
1717 HRESULT CALLBACK
ITypeInfo_AddressOfMember_Proxy(
1723 FIXME("not implemented\n");
1727 HRESULT __RPC_STUB
ITypeInfo_AddressOfMember_Stub(
1730 FIXME("not implemented\n");
1734 HRESULT CALLBACK
ITypeInfo_CreateInstance_Proxy(
1736 IUnknown
* pUnkOuter
,
1740 FIXME("not implemented\n");
1744 HRESULT __RPC_STUB
ITypeInfo_CreateInstance_Stub(
1749 FIXME("not implemented\n");
1753 HRESULT CALLBACK
ITypeInfo_GetContainingTypeLib_Proxy(
1762 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1764 hr
= ITypeInfo_RemoteGetContainingTypeLib_Proxy(This
, &pTL
, &index
);
1773 ITypeLib_Release(pTL
);
1778 HRESULT __RPC_STUB
ITypeInfo_GetContainingTypeLib_Stub(
1783 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1784 return ITypeInfo_GetContainingTypeLib(This
, ppTLib
, pIndex
);
1787 void CALLBACK
ITypeInfo_ReleaseTypeAttr_Proxy(
1789 TYPEATTR
* pTypeAttr
)
1791 TRACE("(%p, %p)\n", This
, pTypeAttr
);
1792 free_embedded_typedesc(&pTypeAttr
->tdescAlias
);
1793 CoTaskMemFree(pTypeAttr
);
1796 HRESULT __RPC_STUB
ITypeInfo_ReleaseTypeAttr_Stub(
1799 TRACE("nothing to do\n");
1803 void CALLBACK
ITypeInfo_ReleaseFuncDesc_Proxy(
1805 FUNCDESC
* pFuncDesc
)
1808 TRACE("(%p, %p)\n", This
, pFuncDesc
);
1810 for(param
= 0; param
< pFuncDesc
->cParams
; param
++)
1811 free_embedded_elemdesc(pFuncDesc
->lprgelemdescParam
+ param
);
1813 CoTaskMemFree(pFuncDesc
->lprgelemdescParam
);
1815 free_embedded_elemdesc(&pFuncDesc
->elemdescFunc
);
1817 if(pFuncDesc
->cScodes
!= 0 && pFuncDesc
->cScodes
!= -1)
1818 CoTaskMemFree(pFuncDesc
->lprgscode
);
1820 CoTaskMemFree(pFuncDesc
);
1823 HRESULT __RPC_STUB
ITypeInfo_ReleaseFuncDesc_Stub(
1826 TRACE("nothing to do\n");
1830 void CALLBACK
ITypeInfo_ReleaseVarDesc_Proxy(
1834 TRACE("(%p, %p)\n", This
, pVarDesc
);
1836 CoTaskMemFree(pVarDesc
->lpstrSchema
);
1838 if(pVarDesc
->varkind
== VAR_CONST
)
1839 CoTaskMemFree(pVarDesc
->u
.lpvarValue
);
1841 free_embedded_elemdesc(&pVarDesc
->elemdescVar
);
1842 CoTaskMemFree(pVarDesc
);
1845 HRESULT __RPC_STUB
ITypeInfo_ReleaseVarDesc_Stub(
1848 TRACE("nothing to do\n");
1855 HRESULT CALLBACK
ITypeInfo2_GetDocumentation2_Proxy(
1859 BSTR
* pbstrHelpString
,
1860 DWORD
* pdwHelpStringContext
,
1861 BSTR
* pbstrHelpStringDll
)
1863 FIXME("not implemented\n");
1867 HRESULT __RPC_STUB
ITypeInfo2_GetDocumentation2_Stub(
1872 BSTR
* pbstrHelpString
,
1873 DWORD
* pdwHelpStringContext
,
1874 BSTR
* pbstrHelpStringDll
)
1876 FIXME("not implemented\n");
1882 UINT CALLBACK
ITypeLib_GetTypeInfoCount_Proxy(
1886 TRACE("(%p)\n", This
);
1888 ITypeLib_RemoteGetTypeInfoCount_Proxy(This
, &count
);
1893 HRESULT __RPC_STUB
ITypeLib_GetTypeInfoCount_Stub(
1897 TRACE("(%p, %p)\n", This
, pcTInfo
);
1898 *pcTInfo
= ITypeLib_GetTypeInfoCount(This
);
1902 HRESULT CALLBACK
ITypeLib_GetLibAttr_Proxy(
1904 TLIBATTR
** ppTLibAttr
)
1906 CLEANLOCALSTORAGE stg
;
1907 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1910 stg
.pStorage
= NULL
;
1911 stg
.pInterface
= NULL
;
1913 return ITypeLib_RemoteGetLibAttr_Proxy(This
, ppTLibAttr
, &stg
);
1916 HRESULT __RPC_STUB
ITypeLib_GetLibAttr_Stub(
1918 LPTLIBATTR
* ppTLibAttr
,
1919 CLEANLOCALSTORAGE
* pDummy
)
1922 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1924 hr
= ITypeLib_GetLibAttr(This
, ppTLibAttr
);
1928 pDummy
->flags
= CLS_LIBATTR
;
1929 ITypeLib_AddRef(This
);
1930 pDummy
->pInterface
= (IUnknown
*)This
;
1931 pDummy
->pStorage
= ppTLibAttr
;
1935 HRESULT CALLBACK
ITypeLib_GetDocumentation_Proxy(
1939 BSTR
* pBstrDocString
,
1940 DWORD
* pdwHelpContext
,
1941 BSTR
* pBstrHelpFile
)
1943 FIXME("not implemented\n");
1947 HRESULT __RPC_STUB
ITypeLib_GetDocumentation_Stub(
1952 BSTR
* pBstrDocString
,
1953 DWORD
* pdwHelpContext
,
1954 BSTR
* pBstrHelpFile
)
1956 FIXME("not implemented\n");
1960 HRESULT CALLBACK
ITypeLib_IsName_Proxy(
1966 FIXME("not implemented\n");
1970 HRESULT __RPC_STUB
ITypeLib_IsName_Stub(
1977 FIXME("not implemented\n");
1981 HRESULT CALLBACK
ITypeLib_FindName_Proxy(
1985 ITypeInfo
** ppTInfo
,
1989 FIXME("not implemented\n");
1993 HRESULT __RPC_STUB
ITypeLib_FindName_Stub(
1997 ITypeInfo
** ppTInfo
,
2002 FIXME("not implemented\n");
2006 void CALLBACK
ITypeLib_ReleaseTLibAttr_Proxy(
2008 TLIBATTR
* pTLibAttr
)
2010 TRACE("(%p, %p)\n", This
, pTLibAttr
);
2011 CoTaskMemFree(pTLibAttr
);
2014 HRESULT __RPC_STUB
ITypeLib_ReleaseTLibAttr_Stub(
2017 TRACE("nothing to do\n");
2024 HRESULT CALLBACK
ITypeLib2_GetLibStatistics_Proxy(
2026 ULONG
* pcUniqueNames
,
2027 ULONG
* pcchUniqueNames
)
2029 FIXME("not implemented\n");
2033 HRESULT __RPC_STUB
ITypeLib2_GetLibStatistics_Stub(
2035 ULONG
* pcUniqueNames
,
2036 ULONG
* pcchUniqueNames
)
2038 FIXME("not implemented\n");
2042 HRESULT CALLBACK
ITypeLib2_GetDocumentation2_Proxy(
2046 BSTR
* pbstrHelpString
,
2047 DWORD
* pdwHelpStringContext
,
2048 BSTR
* pbstrHelpStringDll
)
2050 FIXME("not implemented\n");
2054 HRESULT __RPC_STUB
ITypeLib2_GetDocumentation2_Stub(
2059 BSTR
* pbstrHelpString
,
2060 DWORD
* pdwHelpStringContext
,
2061 BSTR
* pbstrHelpStringDll
)
2063 FIXME("not implemented\n");
2067 HRESULT CALLBACK
IPropertyBag_Read_Proxy(
2069 LPCOLESTR pszPropName
,
2071 IErrorLog
*pErrorLog
)
2073 IUnknown
*pUnk
= NULL
;
2074 TRACE("(%p, %s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
2079 if(V_VT(pVar
) & (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2081 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2088 pUnk
= (IUnknown
*)V_DISPATCH(pVar
);
2091 pUnk
= V_UNKNOWN(pVar
);
2094 FIXME("Safearray support not yet implemented.\n");
2097 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar
));
2101 return IPropertyBag_RemoteRead_Proxy(This
, pszPropName
, pVar
, pErrorLog
,
2105 HRESULT __RPC_STUB
IPropertyBag_Read_Stub(
2107 LPCOLESTR pszPropName
,
2109 IErrorLog
*pErrorLog
,
2113 static const WCHAR emptyWstr
[1] = {0};
2116 TRACE("(%p, %s, %p, %p, %x, %p)\n", This
, debugstr_w(pszPropName
), pVar
,
2117 pErrorLog
, varType
, pUnkObj
);
2119 if(varType
& (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2121 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2125 V_VT(pVar
) = varType
;
2129 hr
= IUnknown_QueryInterface(pUnkObj
, &IID_IDispatch
, (LPVOID
*)&disp
);
2132 IUnknown_Release(pUnkObj
);
2133 V_DISPATCH(pVar
) = disp
;
2136 V_UNKNOWN(pVar
) = pUnkObj
;
2139 V_BSTR(pVar
) = SysAllocString(emptyWstr
);
2142 FIXME("Safearray support not yet implemented.\n");
2147 hr
= IPropertyBag_Read(This
, pszPropName
, pVar
, pErrorLog
);
2154 /* call_as/local stubs for ocidl.idl */
2156 HRESULT CALLBACK
IClassFactory2_CreateInstanceLic_Proxy(
2157 IClassFactory2
* This
,
2158 IUnknown
*pUnkOuter
,
2159 IUnknown
*pUnkReserved
,
2164 FIXME("not implemented\n");
2168 HRESULT __RPC_STUB
IClassFactory2_CreateInstanceLic_Stub(
2169 IClassFactory2
* This
,
2174 FIXME("not implemented\n");
2178 HRESULT CALLBACK
IEnumConnections_Next_Proxy(
2179 IEnumConnections
* This
,
2184 FIXME("not implemented\n");
2188 HRESULT __RPC_STUB
IEnumConnections_Next_Stub(
2189 IEnumConnections
* This
,
2194 FIXME("not implemented\n");
2198 HRESULT CALLBACK
IEnumConnectionPoints_Next_Proxy(
2199 IEnumConnectionPoints
* This
,
2201 LPCONNECTIONPOINT
*ppCP
,
2204 FIXME("not implemented\n");
2208 HRESULT __RPC_STUB
IEnumConnectionPoints_Next_Stub(
2209 IEnumConnectionPoints
* This
,
2211 LPCONNECTIONPOINT
*ppCP
,
2214 FIXME("not implemented\n");
2218 HRESULT CALLBACK
IPersistMemory_Load_Proxy(
2219 IPersistMemory
* This
,
2223 FIXME("not implemented\n");
2227 HRESULT __RPC_STUB
IPersistMemory_Load_Stub(
2228 IPersistMemory
* This
,
2232 FIXME("not implemented\n");
2236 HRESULT CALLBACK
IPersistMemory_Save_Proxy(
2237 IPersistMemory
* This
,
2242 FIXME("not implemented\n");
2246 HRESULT __RPC_STUB
IPersistMemory_Save_Stub(
2247 IPersistMemory
* This
,
2252 FIXME("not implemented\n");
2256 void CALLBACK
IAdviseSinkEx_OnViewStatusChange_Proxy(
2257 IAdviseSinkEx
* This
,
2260 FIXME("not implemented\n");
2263 HRESULT __RPC_STUB
IAdviseSinkEx_OnViewStatusChange_Stub(
2264 IAdviseSinkEx
* This
,
2267 FIXME("not implemented\n");
2271 HRESULT CALLBACK
IEnumOleUndoUnits_Next_Proxy(
2272 IEnumOleUndoUnits
* This
,
2274 IOleUndoUnit
**rgElt
,
2275 ULONG
*pcEltFetched
)
2277 FIXME("not implemented\n");
2281 HRESULT __RPC_STUB
IEnumOleUndoUnits_Next_Stub(
2282 IEnumOleUndoUnits
* This
,
2284 IOleUndoUnit
**rgElt
,
2285 ULONG
*pcEltFetched
)
2287 FIXME("not implemented\n");
2291 HRESULT CALLBACK
IQuickActivate_QuickActivate_Proxy(
2292 IQuickActivate
* This
,
2293 QACONTAINER
*pQaContainer
,
2294 QACONTROL
*pQaControl
)
2296 FIXME("not implemented\n");
2300 HRESULT __RPC_STUB
IQuickActivate_QuickActivate_Stub(
2301 IQuickActivate
* This
,
2302 QACONTAINER
*pQaContainer
,
2303 QACONTROL
*pQaControl
)
2305 FIXME("not implemented\n");