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
);
901 SAFEARRAYBOUND
*bound
;
906 sftype
= SAFEARRAY_GetUnionType(psa
);
908 *(ULONG
*)Buffer
= psa
->cDims
;
909 Buffer
+= sizeof(ULONG
);
910 *(USHORT
*)Buffer
= psa
->cDims
;
911 Buffer
+= sizeof(USHORT
);
912 *(USHORT
*)Buffer
= psa
->fFeatures
;
913 Buffer
+= sizeof(USHORT
);
914 *(ULONG
*)Buffer
= elem_wire_size(psa
, sftype
);
915 Buffer
+= sizeof(ULONG
);
917 hr
= SafeArrayGetVartype(psa
, &vt
);
918 if (FAILED(hr
)) vt
= 0;
920 *(ULONG
*)Buffer
= (USHORT
)psa
->cLocks
| (vt
<< 16);
921 Buffer
+= sizeof(ULONG
);
923 *(ULONG
*)Buffer
= sftype
;
924 Buffer
+= sizeof(ULONG
);
926 *(ULONG
*)Buffer
= ulCellCount
;
927 Buffer
+= sizeof(ULONG
);
928 *(ULONG
*)Buffer
= psa
->pvData
? 0x2 : 0x0;
929 Buffer
+= sizeof(ULONG
);
930 if (sftype
== SF_HAVEIID
)
932 SafeArrayGetIID(psa
, &guid
);
933 memcpy(Buffer
, &guid
, sizeof(guid
));
934 Buffer
+= sizeof(guid
);
937 /* bounds are marshaled in opposite order comparing to storage layout */
938 bound
= (SAFEARRAYBOUND
*)Buffer
;
939 for (i
= 0; i
< psa
->cDims
; i
++)
941 memcpy(bound
++, &psa
->rgsabound
[psa
->cDims
-i
-1], sizeof(psa
->rgsabound
[0]));
943 Buffer
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
945 *(ULONG
*)Buffer
= ulCellCount
;
946 Buffer
+= sizeof(ULONG
);
956 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
957 Buffer
= BSTR_UserMarshal(pFlags
, Buffer
, lpBstr
);
964 FIXME("marshal interfaces\n");
970 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
971 Buffer
= VARIANT_UserMarshal(pFlags
, Buffer
, lpVariant
);
977 IRecordInfo
* pRecInfo
= NULL
;
979 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
981 RpcRaiseException(hr
);
985 FIXME("write record info %p\n", pRecInfo
);
987 IRecordInfo_Release(pRecInfo
);
993 ALIGN_POINTER(Buffer
, 7);
998 /* Just copy the data over */
999 memcpy(Buffer
, psa
->pvData
, ulCellCount
* psa
->cbElements
);
1000 Buffer
+= ulCellCount
* psa
->cbElements
;
1011 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
1012 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
1013 FADF_VARIANT | FADF_CREATEVECTOR)
1015 unsigned char * WINAPI
LPSAFEARRAY_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
1018 wireSAFEARRAY wiresa
;
1025 SAFEARRAYBOUND
*wiresab
;
1027 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, %p\n", Buffer
, ppsa
);
1029 ALIGN_POINTER(Buffer
, 3);
1030 ptr
= *(ULONG
*)Buffer
;
1031 Buffer
+= sizeof(ULONG
);
1037 TRACE("NULL safe array unmarshaled\n");
1042 cDims
= *(ULONG
*)Buffer
;
1043 Buffer
+= sizeof(ULONG
);
1045 wiresa
= (wireSAFEARRAY
)Buffer
;
1046 Buffer
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
1048 if (cDims
!= wiresa
->cDims
)
1049 RpcRaiseException(RPC_S_INVALID_BOUND
);
1051 /* FIXME: there should be a limit on how large cDims can be */
1053 vt
= HIWORD(wiresa
->cLocks
);
1055 sftype
= *(ULONG
*)Buffer
;
1056 Buffer
+= sizeof(ULONG
);
1058 cell_count
= *(ULONG
*)Buffer
;
1059 Buffer
+= sizeof(ULONG
);
1060 ptr
= *(ULONG
*)Buffer
;
1061 Buffer
+= sizeof(ULONG
);
1062 if (sftype
== SF_HAVEIID
)
1064 memcpy(&guid
, Buffer
, sizeof(guid
));
1065 Buffer
+= sizeof(guid
);
1068 wiresab
= (SAFEARRAYBOUND
*)Buffer
;
1069 Buffer
+= sizeof(wiresab
[0]) * wiresa
->cDims
;
1072 *ppsa
= SafeArrayCreateEx(vt
, wiresa
->cDims
, wiresab
, NULL
);
1075 SafeArrayAllocDescriptor(wiresa
->cDims
, ppsa
);
1077 memcpy((*ppsa
)->rgsabound
, wiresab
, sizeof(SAFEARRAYBOUND
) * wiresa
->cDims
);
1080 RpcRaiseException(E_OUTOFMEMORY
);
1082 /* be careful about which flags we set since they could be a security
1084 (*ppsa
)->fFeatures
&= FADF_AUTOSETFLAGS
;
1085 (*ppsa
)->fFeatures
|= (wiresa
->fFeatures
& ~(FADF_AUTOSETFLAGS
));
1086 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1087 (*ppsa
)->cbElements
= elem_mem_size(wiresa
, sftype
);
1088 (*ppsa
)->cLocks
= LOWORD(wiresa
->cLocks
);
1090 /* SafeArrayCreateEx allocates the data for us, but
1091 * SafeArrayAllocDescriptor doesn't */
1094 hr
= SafeArrayAllocData(*ppsa
);
1096 RpcRaiseException(hr
);
1099 if ((*(ULONG
*)Buffer
!= cell_count
) || (SAFEARRAY_GetCellCount(*ppsa
) != cell_count
))
1100 RpcRaiseException(RPC_S_INVALID_BOUND
);
1101 Buffer
+= sizeof(ULONG
);
1111 for (lpBstr
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpBstr
++)
1112 Buffer
= BSTR_UserUnmarshal(pFlags
, Buffer
, lpBstr
);
1119 FIXME("marshal interfaces\n");
1125 for (lpVariant
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpVariant
++)
1126 Buffer
= VARIANT_UserUnmarshal(pFlags
, Buffer
, lpVariant
);
1132 FIXME("set record info\n");
1138 ALIGN_POINTER(Buffer
, 7);
1143 /* Just copy the data over */
1144 memcpy((*ppsa
)->pvData
, Buffer
, cell_count
* (*ppsa
)->cbElements
);
1145 Buffer
+= cell_count
* (*ppsa
)->cbElements
;
1152 TRACE("safe array unmarshaled: %p\n", *ppsa
);
1157 void WINAPI
LPSAFEARRAY_UserFree(ULONG
*pFlags
, LPSAFEARRAY
*ppsa
)
1159 TRACE("("); dump_user_flags(pFlags
); TRACE(", &%p\n", *ppsa
);
1161 SafeArrayDestroy(*ppsa
);
1165 ULONG WINAPI
HFONT_UserSize(ULONG
*pFlags
, ULONG Start
, HFONT
*phfont
)
1171 unsigned char * WINAPI
HFONT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1177 unsigned char * WINAPI
HFONT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1183 void WINAPI
HFONT_UserFree(ULONG
*pFlags
, HFONT
*phfont
)
1191 /* exactly how Invoke is marshalled is not very clear to me yet,
1192 * but the way I've done it seems to work for me */
1194 HRESULT CALLBACK
IDispatch_Invoke_Proxy(
1196 DISPID dispIdMember
,
1200 DISPPARAMS
* pDispParams
,
1201 VARIANT
* pVarResult
,
1202 EXCEPINFO
* pExcepInfo
,
1207 UINT
* rgVarRefIdx
= NULL
;
1208 VARIANTARG
* rgVarRef
= NULL
;
1211 EXCEPINFO ExcepInfo
;
1213 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This
,
1214 dispIdMember
, debugstr_guid(riid
),
1215 lcid
, wFlags
, pDispParams
, pVarResult
,
1216 pExcepInfo
, puArgErr
);
1218 /* [out] args can't be null, use dummy vars if needed */
1219 if (!pVarResult
) pVarResult
= &VarResult
;
1220 if (!puArgErr
) puArgErr
= &uArgErr
;
1221 if (!pExcepInfo
) pExcepInfo
= &ExcepInfo
;
1223 /* count by-ref args */
1224 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1225 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1226 if (V_ISBYREF(arg
)) {
1231 rgVarRefIdx
= CoTaskMemAlloc(sizeof(UINT
)*cVarRef
);
1232 rgVarRef
= CoTaskMemAlloc(sizeof(VARIANTARG
)*cVarRef
);
1233 /* make list of by-ref args */
1234 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1235 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1236 if (V_ISBYREF(arg
)) {
1237 rgVarRefIdx
[cVarRef
] = u
;
1238 VariantInit(&rgVarRef
[cVarRef
]);
1239 VariantCopy(&rgVarRef
[cVarRef
], arg
);
1245 /* [out] args still can't be null,
1246 * but we can point these anywhere in this case,
1247 * since they won't be written to when cVarRef is 0 */
1248 rgVarRefIdx
= puArgErr
;
1249 rgVarRef
= pVarResult
;
1251 TRACE("passed by ref: %d args\n", cVarRef
);
1252 hr
= IDispatch_RemoteInvoke_Proxy(This
,
1265 for (u
=0; u
<cVarRef
; u
++) {
1266 unsigned i
= rgVarRefIdx
[u
];
1267 VariantCopy(&pDispParams
->rgvarg
[i
],
1269 VariantClear(&rgVarRef
[u
]);
1271 CoTaskMemFree(rgVarRef
);
1272 CoTaskMemFree(rgVarRefIdx
);
1275 if(pExcepInfo
== &ExcepInfo
)
1277 SysFreeString(pExcepInfo
->bstrSource
);
1278 SysFreeString(pExcepInfo
->bstrDescription
);
1279 SysFreeString(pExcepInfo
->bstrHelpFile
);
1284 HRESULT __RPC_STUB
IDispatch_Invoke_Stub(
1286 DISPID dispIdMember
,
1290 DISPPARAMS
* pDispParams
,
1291 VARIANT
* pVarResult
,
1292 EXCEPINFO
* pExcepInfo
,
1296 VARIANTARG
* rgVarRef
)
1299 VARIANTARG
*rgvarg
, *arg
;
1302 /* initialize out parameters, so that they can be marshalled
1303 * in case the real Invoke doesn't initialize them */
1304 VariantInit(pVarResult
);
1305 memset(pExcepInfo
, 0, sizeof(*pExcepInfo
));
1308 /* let the real Invoke operate on a copy of the in parameters,
1309 * so we don't risk losing pointers to allocated memory */
1310 rgvarg
= pDispParams
->rgvarg
;
1311 arg
= CoTaskMemAlloc(sizeof(VARIANTARG
)*pDispParams
->cArgs
);
1312 if (!arg
) return E_OUTOFMEMORY
;
1314 /* init all args so we can call VariantClear on all the args if the copy
1316 for (u
= 0; u
< pDispParams
->cArgs
; u
++)
1317 VariantInit(&arg
[u
]);
1319 for (u
= 0; u
< pDispParams
->cArgs
; u
++) {
1320 hr
= VariantCopy(&arg
[u
], &rgvarg
[u
]);
1325 if (SUCCEEDED(hr
)) {
1326 /* copy ref args to arg array */
1327 for (u
=0; u
<cVarRef
; u
++) {
1328 unsigned i
= rgVarRefIdx
[u
];
1329 VariantCopy(&arg
[i
], &rgVarRef
[u
]);
1332 pDispParams
->rgvarg
= arg
;
1334 hr
= IDispatch_Invoke(This
,
1344 /* copy ref args from arg array */
1345 for (u
=0; u
<cVarRef
; u
++) {
1346 unsigned i
= rgVarRefIdx
[u
];
1347 VariantCopy(&rgVarRef
[u
], &arg
[i
]);
1351 /* clear the duplicate argument list */
1352 for (u
=0; u
<pDispParams
->cArgs
; u
++)
1353 VariantClear(&arg
[u
]);
1355 pDispParams
->rgvarg
= rgvarg
;
1363 HRESULT CALLBACK
IEnumVARIANT_Next_Proxy(
1367 ULONG
* pCeltFetched
)
1371 pCeltFetched
= &fetched
;
1372 return IEnumVARIANT_RemoteNext_Proxy(This
,
1378 HRESULT __RPC_STUB
IEnumVARIANT_Next_Stub(
1382 ULONG
* pCeltFetched
)
1386 hr
= IEnumVARIANT_Next(This
,
1390 if (hr
== S_OK
) *pCeltFetched
= celt
;
1394 /* TypeInfo related freers */
1396 static void free_embedded_typedesc(TYPEDESC
*tdesc
);
1397 static void free_embedded_arraydesc(ARRAYDESC
*adesc
)
1399 switch(adesc
->tdescElem
.vt
)
1403 free_embedded_typedesc(adesc
->tdescElem
.u
.lptdesc
);
1404 CoTaskMemFree(adesc
->tdescElem
.u
.lptdesc
);
1407 free_embedded_arraydesc(adesc
->tdescElem
.u
.lpadesc
);
1408 CoTaskMemFree(adesc
->tdescElem
.u
.lpadesc
);
1413 static void free_embedded_typedesc(TYPEDESC
*tdesc
)
1419 free_embedded_typedesc(tdesc
->u
.lptdesc
);
1420 CoTaskMemFree(tdesc
->u
.lptdesc
);
1423 free_embedded_arraydesc(tdesc
->u
.lpadesc
);
1424 CoTaskMemFree(tdesc
->u
.lpadesc
);
1429 static void free_embedded_elemdesc(ELEMDESC
*edesc
)
1431 free_embedded_typedesc(&edesc
->tdesc
);
1432 if(edesc
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
1433 CoTaskMemFree(edesc
->u
.paramdesc
.pparamdescex
);
1438 HRESULT CALLBACK
ITypeComp_Bind_Proxy(
1443 ITypeInfo
** ppTInfo
,
1444 DESCKIND
* pDescKind
,
1447 FIXME("not implemented\n");
1451 HRESULT __RPC_STUB
ITypeComp_Bind_Stub(
1456 ITypeInfo
** ppTInfo
,
1457 DESCKIND
* pDescKind
,
1458 LPFUNCDESC
* ppFuncDesc
,
1459 LPVARDESC
* ppVarDesc
,
1460 ITypeComp
** ppTypeComp
,
1461 CLEANLOCALSTORAGE
* pDummy
)
1463 FIXME("not implemented\n");
1467 HRESULT CALLBACK
ITypeComp_BindType_Proxy(
1471 ITypeInfo
** ppTInfo
,
1472 ITypeComp
** ppTComp
)
1474 FIXME("not implemented\n");
1478 HRESULT __RPC_STUB
ITypeComp_BindType_Stub(
1482 ITypeInfo
** ppTInfo
)
1484 FIXME("not implemented\n");
1490 HRESULT CALLBACK
ITypeInfo_GetTypeAttr_Proxy(
1492 TYPEATTR
** ppTypeAttr
)
1495 CLEANLOCALSTORAGE stg
;
1496 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1499 stg
.pStorage
= NULL
;
1500 stg
.pInterface
= NULL
;
1502 return ITypeInfo_RemoteGetTypeAttr_Proxy(This
, ppTypeAttr
, &stg
);
1505 HRESULT __RPC_STUB
ITypeInfo_GetTypeAttr_Stub(
1507 LPTYPEATTR
* ppTypeAttr
,
1508 CLEANLOCALSTORAGE
* pDummy
)
1511 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1513 hr
= ITypeInfo_GetTypeAttr(This
, ppTypeAttr
);
1517 pDummy
->flags
= CLS_TYPEATTR
;
1518 ITypeInfo_AddRef(This
);
1519 pDummy
->pInterface
= (IUnknown
*)This
;
1520 pDummy
->pStorage
= ppTypeAttr
;
1524 HRESULT CALLBACK
ITypeInfo_GetFuncDesc_Proxy(
1527 FUNCDESC
** ppFuncDesc
)
1529 CLEANLOCALSTORAGE stg
;
1530 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1533 stg
.pStorage
= NULL
;
1534 stg
.pInterface
= NULL
;
1536 return ITypeInfo_RemoteGetFuncDesc_Proxy(This
, index
, ppFuncDesc
, &stg
);
1539 HRESULT __RPC_STUB
ITypeInfo_GetFuncDesc_Stub(
1542 LPFUNCDESC
* ppFuncDesc
,
1543 CLEANLOCALSTORAGE
* pDummy
)
1546 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1548 hr
= ITypeInfo_GetFuncDesc(This
, index
, ppFuncDesc
);
1552 pDummy
->flags
= CLS_FUNCDESC
;
1553 ITypeInfo_AddRef(This
);
1554 pDummy
->pInterface
= (IUnknown
*)This
;
1555 pDummy
->pStorage
= ppFuncDesc
;
1559 HRESULT CALLBACK
ITypeInfo_GetVarDesc_Proxy(
1562 VARDESC
** ppVarDesc
)
1564 CLEANLOCALSTORAGE stg
;
1565 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1568 stg
.pStorage
= NULL
;
1569 stg
.pInterface
= NULL
;
1571 return ITypeInfo_RemoteGetVarDesc_Proxy(This
, index
, ppVarDesc
, &stg
);
1574 HRESULT __RPC_STUB
ITypeInfo_GetVarDesc_Stub(
1577 LPVARDESC
* ppVarDesc
,
1578 CLEANLOCALSTORAGE
* pDummy
)
1581 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1583 hr
= ITypeInfo_GetVarDesc(This
, index
, ppVarDesc
);
1587 pDummy
->flags
= CLS_VARDESC
;
1588 ITypeInfo_AddRef(This
);
1589 pDummy
->pInterface
= (IUnknown
*)This
;
1590 pDummy
->pStorage
= ppVarDesc
;
1594 HRESULT CALLBACK
ITypeInfo_GetNames_Proxy(
1601 FIXME("not implemented\n");
1605 HRESULT __RPC_STUB
ITypeInfo_GetNames_Stub(
1612 FIXME("not implemented\n");
1616 HRESULT CALLBACK
ITypeInfo_GetIDsOfNames_Proxy(
1618 LPOLESTR
* rgszNames
,
1622 FIXME("not implemented\n");
1626 HRESULT __RPC_STUB
ITypeInfo_GetIDsOfNames_Stub(
1629 FIXME("not implemented\n");
1633 HRESULT CALLBACK
ITypeInfo_Invoke_Proxy(
1638 DISPPARAMS
* pDispParams
,
1639 VARIANT
* pVarResult
,
1640 EXCEPINFO
* pExcepInfo
,
1643 FIXME("not implemented\n");
1647 HRESULT __RPC_STUB
ITypeInfo_Invoke_Stub(
1650 FIXME("not implemented\n");
1654 HRESULT CALLBACK
ITypeInfo_GetDocumentation_Proxy(
1658 BSTR
* pBstrDocString
,
1659 DWORD
* pdwHelpContext
,
1660 BSTR
* pBstrHelpFile
)
1663 BSTR name
, doc_string
, help_file
;
1665 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1667 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1668 hr
= ITypeInfo_RemoteGetDocumentation_Proxy(This
, memid
, 0, &name
, &doc_string
, &help_context
, &help_file
);
1671 if(pBstrName
) *pBstrName
= name
;
1672 else SysFreeString(name
);
1674 if(pBstrDocString
) *pBstrDocString
= doc_string
;
1675 else SysFreeString(doc_string
);
1677 if(pBstrHelpFile
) *pBstrHelpFile
= help_file
;
1678 else SysFreeString(help_file
);
1680 if(pdwHelpContext
) *pdwHelpContext
= help_context
;
1685 HRESULT __RPC_STUB
ITypeInfo_GetDocumentation_Stub(
1690 BSTR
* pBstrDocString
,
1691 DWORD
* pdwHelpContext
,
1692 BSTR
* pBstrHelpFile
)
1694 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This
, memid
, refPtrFlags
, pBstrName
, pBstrDocString
,
1695 pdwHelpContext
, pBstrHelpFile
);
1696 return ITypeInfo_GetDocumentation(This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1699 HRESULT CALLBACK
ITypeInfo_GetDllEntry_Proxy(
1707 FIXME("not implemented\n");
1711 HRESULT __RPC_STUB
ITypeInfo_GetDllEntry_Stub(
1720 FIXME("not implemented\n");
1724 HRESULT CALLBACK
ITypeInfo_AddressOfMember_Proxy(
1730 FIXME("not implemented\n");
1734 HRESULT __RPC_STUB
ITypeInfo_AddressOfMember_Stub(
1737 FIXME("not implemented\n");
1741 HRESULT CALLBACK
ITypeInfo_CreateInstance_Proxy(
1743 IUnknown
* pUnkOuter
,
1747 FIXME("not implemented\n");
1751 HRESULT __RPC_STUB
ITypeInfo_CreateInstance_Stub(
1756 FIXME("not implemented\n");
1760 HRESULT CALLBACK
ITypeInfo_GetContainingTypeLib_Proxy(
1769 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1771 hr
= ITypeInfo_RemoteGetContainingTypeLib_Proxy(This
, &pTL
, &index
);
1780 ITypeLib_Release(pTL
);
1785 HRESULT __RPC_STUB
ITypeInfo_GetContainingTypeLib_Stub(
1790 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1791 return ITypeInfo_GetContainingTypeLib(This
, ppTLib
, pIndex
);
1794 void CALLBACK
ITypeInfo_ReleaseTypeAttr_Proxy(
1796 TYPEATTR
* pTypeAttr
)
1798 TRACE("(%p, %p)\n", This
, pTypeAttr
);
1799 free_embedded_typedesc(&pTypeAttr
->tdescAlias
);
1800 CoTaskMemFree(pTypeAttr
);
1803 HRESULT __RPC_STUB
ITypeInfo_ReleaseTypeAttr_Stub(
1806 TRACE("nothing to do\n");
1810 void CALLBACK
ITypeInfo_ReleaseFuncDesc_Proxy(
1812 FUNCDESC
* pFuncDesc
)
1815 TRACE("(%p, %p)\n", This
, pFuncDesc
);
1817 for(param
= 0; param
< pFuncDesc
->cParams
; param
++)
1818 free_embedded_elemdesc(pFuncDesc
->lprgelemdescParam
+ param
);
1820 CoTaskMemFree(pFuncDesc
->lprgelemdescParam
);
1822 free_embedded_elemdesc(&pFuncDesc
->elemdescFunc
);
1824 if(pFuncDesc
->cScodes
!= 0 && pFuncDesc
->cScodes
!= -1)
1825 CoTaskMemFree(pFuncDesc
->lprgscode
);
1827 CoTaskMemFree(pFuncDesc
);
1830 HRESULT __RPC_STUB
ITypeInfo_ReleaseFuncDesc_Stub(
1833 TRACE("nothing to do\n");
1837 void CALLBACK
ITypeInfo_ReleaseVarDesc_Proxy(
1841 TRACE("(%p, %p)\n", This
, pVarDesc
);
1843 CoTaskMemFree(pVarDesc
->lpstrSchema
);
1845 if(pVarDesc
->varkind
== VAR_CONST
)
1846 CoTaskMemFree(pVarDesc
->u
.lpvarValue
);
1848 free_embedded_elemdesc(&pVarDesc
->elemdescVar
);
1849 CoTaskMemFree(pVarDesc
);
1852 HRESULT __RPC_STUB
ITypeInfo_ReleaseVarDesc_Stub(
1855 TRACE("nothing to do\n");
1862 HRESULT CALLBACK
ITypeInfo2_GetDocumentation2_Proxy(
1866 BSTR
* pbstrHelpString
,
1867 DWORD
* pdwHelpStringContext
,
1868 BSTR
* pbstrHelpStringDll
)
1870 FIXME("not implemented\n");
1874 HRESULT __RPC_STUB
ITypeInfo2_GetDocumentation2_Stub(
1879 BSTR
* pbstrHelpString
,
1880 DWORD
* pdwHelpStringContext
,
1881 BSTR
* pbstrHelpStringDll
)
1883 FIXME("not implemented\n");
1889 UINT CALLBACK
ITypeLib_GetTypeInfoCount_Proxy(
1893 TRACE("(%p)\n", This
);
1895 ITypeLib_RemoteGetTypeInfoCount_Proxy(This
, &count
);
1900 HRESULT __RPC_STUB
ITypeLib_GetTypeInfoCount_Stub(
1904 TRACE("(%p, %p)\n", This
, pcTInfo
);
1905 *pcTInfo
= ITypeLib_GetTypeInfoCount(This
);
1909 HRESULT CALLBACK
ITypeLib_GetLibAttr_Proxy(
1911 TLIBATTR
** ppTLibAttr
)
1913 CLEANLOCALSTORAGE stg
;
1914 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1917 stg
.pStorage
= NULL
;
1918 stg
.pInterface
= NULL
;
1920 return ITypeLib_RemoteGetLibAttr_Proxy(This
, ppTLibAttr
, &stg
);
1923 HRESULT __RPC_STUB
ITypeLib_GetLibAttr_Stub(
1925 LPTLIBATTR
* ppTLibAttr
,
1926 CLEANLOCALSTORAGE
* pDummy
)
1929 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1931 hr
= ITypeLib_GetLibAttr(This
, ppTLibAttr
);
1935 pDummy
->flags
= CLS_LIBATTR
;
1936 ITypeLib_AddRef(This
);
1937 pDummy
->pInterface
= (IUnknown
*)This
;
1938 pDummy
->pStorage
= ppTLibAttr
;
1942 HRESULT CALLBACK
ITypeLib_GetDocumentation_Proxy(
1946 BSTR
* pBstrDocString
,
1947 DWORD
* pdwHelpContext
,
1948 BSTR
* pBstrHelpFile
)
1950 FIXME("not implemented\n");
1954 HRESULT __RPC_STUB
ITypeLib_GetDocumentation_Stub(
1959 BSTR
* pBstrDocString
,
1960 DWORD
* pdwHelpContext
,
1961 BSTR
* pBstrHelpFile
)
1963 FIXME("not implemented\n");
1967 HRESULT CALLBACK
ITypeLib_IsName_Proxy(
1973 FIXME("not implemented\n");
1977 HRESULT __RPC_STUB
ITypeLib_IsName_Stub(
1984 FIXME("not implemented\n");
1988 HRESULT CALLBACK
ITypeLib_FindName_Proxy(
1992 ITypeInfo
** ppTInfo
,
1996 FIXME("not implemented\n");
2000 HRESULT __RPC_STUB
ITypeLib_FindName_Stub(
2004 ITypeInfo
** ppTInfo
,
2009 FIXME("not implemented\n");
2013 void CALLBACK
ITypeLib_ReleaseTLibAttr_Proxy(
2015 TLIBATTR
* pTLibAttr
)
2017 TRACE("(%p, %p)\n", This
, pTLibAttr
);
2018 CoTaskMemFree(pTLibAttr
);
2021 HRESULT __RPC_STUB
ITypeLib_ReleaseTLibAttr_Stub(
2024 TRACE("nothing to do\n");
2031 HRESULT CALLBACK
ITypeLib2_GetLibStatistics_Proxy(
2033 ULONG
* pcUniqueNames
,
2034 ULONG
* pcchUniqueNames
)
2036 FIXME("not implemented\n");
2040 HRESULT __RPC_STUB
ITypeLib2_GetLibStatistics_Stub(
2042 ULONG
* pcUniqueNames
,
2043 ULONG
* pcchUniqueNames
)
2045 FIXME("not implemented\n");
2049 HRESULT CALLBACK
ITypeLib2_GetDocumentation2_Proxy(
2053 BSTR
* pbstrHelpString
,
2054 DWORD
* pdwHelpStringContext
,
2055 BSTR
* pbstrHelpStringDll
)
2057 FIXME("not implemented\n");
2061 HRESULT __RPC_STUB
ITypeLib2_GetDocumentation2_Stub(
2066 BSTR
* pbstrHelpString
,
2067 DWORD
* pdwHelpStringContext
,
2068 BSTR
* pbstrHelpStringDll
)
2070 FIXME("not implemented\n");
2074 HRESULT CALLBACK
IPropertyBag_Read_Proxy(
2076 LPCOLESTR pszPropName
,
2078 IErrorLog
*pErrorLog
)
2080 IUnknown
*pUnk
= NULL
;
2081 TRACE("(%p, %s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
2086 if(V_VT(pVar
) & (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2088 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2095 pUnk
= (IUnknown
*)V_DISPATCH(pVar
);
2098 pUnk
= V_UNKNOWN(pVar
);
2101 FIXME("Safearray support not yet implemented.\n");
2104 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar
));
2108 return IPropertyBag_RemoteRead_Proxy(This
, pszPropName
, pVar
, pErrorLog
,
2112 HRESULT __RPC_STUB
IPropertyBag_Read_Stub(
2114 LPCOLESTR pszPropName
,
2116 IErrorLog
*pErrorLog
,
2120 static const WCHAR emptyWstr
[1] = {0};
2123 TRACE("(%p, %s, %p, %p, %x, %p)\n", This
, debugstr_w(pszPropName
), pVar
,
2124 pErrorLog
, varType
, pUnkObj
);
2126 if(varType
& (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2128 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2132 V_VT(pVar
) = varType
;
2136 hr
= IUnknown_QueryInterface(pUnkObj
, &IID_IDispatch
, (LPVOID
*)&disp
);
2139 IUnknown_Release(pUnkObj
);
2140 V_DISPATCH(pVar
) = disp
;
2143 V_UNKNOWN(pVar
) = pUnkObj
;
2146 V_BSTR(pVar
) = SysAllocString(emptyWstr
);
2149 FIXME("Safearray support not yet implemented.\n");
2154 hr
= IPropertyBag_Read(This
, pszPropName
, pVar
, pErrorLog
);
2161 /* call_as/local stubs for ocidl.idl */
2163 HRESULT CALLBACK
IClassFactory2_CreateInstanceLic_Proxy(
2164 IClassFactory2
* This
,
2165 IUnknown
*pUnkOuter
,
2166 IUnknown
*pUnkReserved
,
2171 FIXME("not implemented\n");
2175 HRESULT __RPC_STUB
IClassFactory2_CreateInstanceLic_Stub(
2176 IClassFactory2
* This
,
2181 FIXME("not implemented\n");
2185 HRESULT CALLBACK
IEnumConnections_Next_Proxy(
2186 IEnumConnections
* This
,
2191 FIXME("not implemented\n");
2195 HRESULT __RPC_STUB
IEnumConnections_Next_Stub(
2196 IEnumConnections
* This
,
2201 FIXME("not implemented\n");
2205 HRESULT CALLBACK
IEnumConnectionPoints_Next_Proxy(
2206 IEnumConnectionPoints
* This
,
2208 LPCONNECTIONPOINT
*ppCP
,
2211 FIXME("not implemented\n");
2215 HRESULT __RPC_STUB
IEnumConnectionPoints_Next_Stub(
2216 IEnumConnectionPoints
* This
,
2218 LPCONNECTIONPOINT
*ppCP
,
2221 FIXME("not implemented\n");
2225 HRESULT CALLBACK
IPersistMemory_Load_Proxy(
2226 IPersistMemory
* This
,
2230 FIXME("not implemented\n");
2234 HRESULT __RPC_STUB
IPersistMemory_Load_Stub(
2235 IPersistMemory
* This
,
2239 FIXME("not implemented\n");
2243 HRESULT CALLBACK
IPersistMemory_Save_Proxy(
2244 IPersistMemory
* This
,
2249 FIXME("not implemented\n");
2253 HRESULT __RPC_STUB
IPersistMemory_Save_Stub(
2254 IPersistMemory
* This
,
2259 FIXME("not implemented\n");
2263 void CALLBACK
IAdviseSinkEx_OnViewStatusChange_Proxy(
2264 IAdviseSinkEx
* This
,
2267 FIXME("not implemented\n");
2270 HRESULT __RPC_STUB
IAdviseSinkEx_OnViewStatusChange_Stub(
2271 IAdviseSinkEx
* This
,
2274 FIXME("not implemented\n");
2278 HRESULT CALLBACK
IEnumOleUndoUnits_Next_Proxy(
2279 IEnumOleUndoUnits
* This
,
2281 IOleUndoUnit
**rgElt
,
2282 ULONG
*pcEltFetched
)
2284 FIXME("not implemented\n");
2288 HRESULT __RPC_STUB
IEnumOleUndoUnits_Next_Stub(
2289 IEnumOleUndoUnits
* This
,
2291 IOleUndoUnit
**rgElt
,
2292 ULONG
*pcEltFetched
)
2294 FIXME("not implemented\n");
2298 HRESULT CALLBACK
IQuickActivate_QuickActivate_Proxy(
2299 IQuickActivate
* This
,
2300 QACONTAINER
*pQaContainer
,
2301 QACONTROL
*pQaControl
)
2303 FIXME("not implemented\n");
2307 HRESULT __RPC_STUB
IQuickActivate_QuickActivate_Stub(
2308 IQuickActivate
* This
,
2309 QACONTAINER
*pQaContainer
,
2310 QACONTROL
*pQaControl
)
2312 FIXME("not implemented\n");