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
)
261 /* find the buffer size of the marshalled dispatch interface */
262 hr
= CoGetMarshalSizeMax(&size
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
265 WARN("NULL dispatch pointer\n");
267 ERR("Dispatch variant buffer size calculation failed, HRESULT=0x%x\n", hr
);
270 size
+= sizeof(ULONG
); /* we have to store the buffersize in the stream */
271 TRACE("wire-size extra of dispatch variant is %d\n", size
);
275 static ULONG
wire_extra_user_size(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
280 return LPSAFEARRAY_UserSize(pFlags
, Start
, V_ARRAYREF(pvar
));
282 return LPSAFEARRAY_UserSize(pFlags
, Start
, &V_ARRAY(pvar
));
285 switch (V_VT(pvar
)) {
287 return BSTR_UserSize(pFlags
, Start
, &V_BSTR(pvar
));
288 case VT_BSTR
| VT_BYREF
:
289 return BSTR_UserSize(pFlags
, Start
, V_BSTRREF(pvar
));
290 case VT_VARIANT
| VT_BYREF
:
291 return VARIANT_UserSize(pFlags
, Start
, V_VARIANTREF(pvar
));
293 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, V_UNKNOWN(pvar
));
294 case VT_UNKNOWN
| VT_BYREF
:
295 return Start
+ interface_variant_size(pFlags
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
297 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
298 case VT_DISPATCH
| VT_BYREF
:
299 return Start
+ interface_variant_size(pFlags
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
301 FIXME("wire-size record\n");
304 case VT_SAFEARRAY
| VT_BYREF
:
305 FIXME("wire-size safearray: shouldn't be marshaling this\n");
312 /* helper: called for VT_DISPATCH variants to marshal the IDispatch* into the buffer. returns Buffer on failure, new position otherwise */
313 static unsigned char* interface_variant_marshal(const ULONG
*pFlags
, unsigned char *Buffer
,
314 REFIID riid
, IUnknown
*punk
)
318 void *working_memlocked
;
319 unsigned char *oldpos
;
323 TRACE("pFlags=%d, Buffer=%p, pUnk=%p\n", *pFlags
, Buffer
, punk
);
327 /* CoMarshalInterface needs a stream, whereas at this level we are operating in terms of buffers.
328 * We create a stream on an HGLOBAL, so we can simply do a memcpy to move it to the buffer.
329 * in rpcrt4/ndr_ole.c, a simple IStream implementation is wrapped around the buffer object,
330 * but that would be overkill here, hence this implementation. We save the size because the unmarshal
331 * code has no way to know how long the marshalled buffer is. */
333 size
= interface_variant_size(pFlags
, riid
, punk
);
335 working_mem
= GlobalAlloc(0, size
);
336 if (!working_mem
) return oldpos
;
338 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
340 GlobalFree(working_mem
);
344 hr
= CoMarshalInterface(working
, riid
, punk
, LOWORD(*pFlags
), NULL
, MSHLFLAGS_NORMAL
);
346 IStream_Release(working
); /* this also releases the hglobal */
350 working_memlocked
= GlobalLock(working_mem
);
351 memcpy(Buffer
, &size
, sizeof(ULONG
)); /* copy the buffersize */
352 memcpy(Buffer
+ sizeof(ULONG
), working_memlocked
, size
- sizeof(ULONG
));
353 GlobalUnlock(working_mem
);
355 IStream_Release(working
);
357 /* size includes the ULONG for the size written above */
358 TRACE("done, size=%d\n", size
);
359 return Buffer
+ size
;
362 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
363 static unsigned char *interface_variant_unmarshal(const ULONG
*pFlags
, unsigned char *Buffer
,
364 REFIID riid
, IUnknown
**ppunk
)
368 void *working_memlocked
;
369 unsigned char *oldpos
;
373 TRACE("pFlags=%d, Buffer=%p, ppUnk=%p\n", *pFlags
, Buffer
, ppunk
);
377 /* get the buffersize */
378 memcpy(&size
, Buffer
, sizeof(ULONG
));
379 TRACE("buffersize=%d\n", size
);
381 working_mem
= GlobalAlloc(0, size
);
382 if (!working_mem
) return oldpos
;
384 hr
= CreateStreamOnHGlobal(working_mem
, TRUE
, &working
);
386 GlobalFree(working_mem
);
390 working_memlocked
= GlobalLock(working_mem
);
392 /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
393 memcpy(working_memlocked
, Buffer
+ sizeof(ULONG
), size
);
394 GlobalUnlock(working_mem
);
396 hr
= CoUnmarshalInterface(working
, riid
, (void**)ppunk
);
398 IStream_Release(working
);
402 IStream_Release(working
); /* this also frees the underlying hglobal */
404 /* size includes the ULONG for the size written above */
405 TRACE("done, processed=%d bytes\n", size
);
406 return Buffer
+ size
;
410 ULONG WINAPI
VARIANT_UserSize(ULONG
*pFlags
, ULONG Start
, VARIANT
*pvar
)
413 TRACE("(%x,%d,%p)\n", *pFlags
, Start
, pvar
);
414 TRACE("vt=%04x\n", V_VT(pvar
));
416 ALIGN_LENGTH(Start
, 7);
417 Start
+= sizeof(variant_wire_t
);
418 if(V_VT(pvar
) & VT_BYREF
)
421 align
= get_type_alignment(pFlags
, V_VT(pvar
));
422 ALIGN_LENGTH(Start
, align
);
423 if(V_VT(pvar
) == (VT_VARIANT
| VT_BYREF
))
426 Start
+= get_type_size(pFlags
, V_VT(pvar
));
427 Start
= wire_extra_user_size(pFlags
, Start
, pvar
);
429 TRACE("returning %d\n", Start
);
433 unsigned char * WINAPI
VARIANT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
435 variant_wire_t
*header
;
440 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
441 TRACE("vt=%04x\n", V_VT(pvar
));
443 ALIGN_POINTER(Buffer
, 7);
445 header
= (variant_wire_t
*)Buffer
;
447 header
->clSize
= 0; /* fixed up at the end */
448 header
->rpcReserverd
= 0;
449 header
->vt
= pvar
->n1
.n2
.vt
;
450 header
->wReserved1
= pvar
->n1
.n2
.wReserved1
;
451 header
->wReserved2
= pvar
->n1
.n2
.wReserved2
;
452 header
->wReserved3
= pvar
->n1
.n2
.wReserved3
;
453 header
->switch_is
= pvar
->n1
.n2
.vt
;
454 if(header
->switch_is
& VT_ARRAY
)
455 header
->switch_is
&= ~VT_TYPEMASK
;
457 Pos
= (unsigned char*)(header
+ 1);
458 type_size
= get_type_size(pFlags
, V_VT(pvar
));
459 align
= get_type_alignment(pFlags
, V_VT(pvar
));
460 ALIGN_POINTER(Pos
, align
);
462 if(header
->vt
& VT_BYREF
)
464 *(DWORD
*)Pos
= max(type_size
, 4);
466 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
468 memcpy(Pos
, pvar
->n1
.n2
.n3
.byref
, type_size
);
473 *(DWORD
*)Pos
= 'U' | 's' << 8 | 'e' << 16 | 'r' << 24;
479 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
480 memcpy(Pos
, pvar
, type_size
);
482 memcpy(Pos
, &pvar
->n1
.n2
.n3
, type_size
);
486 if(header
->vt
& VT_ARRAY
)
488 if(header
->vt
& VT_BYREF
)
489 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
491 Pos
= LPSAFEARRAY_UserMarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
498 Pos
= BSTR_UserMarshal(pFlags
, Pos
, &V_BSTR(pvar
));
500 case VT_BSTR
| VT_BYREF
:
501 Pos
= BSTR_UserMarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
503 case VT_VARIANT
| VT_BYREF
:
504 Pos
= VARIANT_UserMarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
507 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
508 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWN(pvar
));
510 case VT_UNKNOWN
| VT_BYREF
:
511 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
512 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IUnknown
, *V_UNKNOWNREF(pvar
));
515 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
516 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)V_DISPATCH(pvar
));
518 case VT_DISPATCH
| VT_BYREF
:
519 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
520 Pos
= interface_variant_marshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
*)*V_DISPATCHREF(pvar
));
523 FIXME("handle BRECORD by val\n");
525 case VT_RECORD
| VT_BYREF
:
526 FIXME("handle BRECORD by ref\n");
530 header
->clSize
= ((Pos
- Buffer
) + 7) >> 3;
531 TRACE("marshalled size=%d\n", header
->clSize
);
535 unsigned char * WINAPI
VARIANT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, VARIANT
*pvar
)
537 variant_wire_t
*header
;
542 TRACE("(%x,%p,%p)\n", *pFlags
, Buffer
, pvar
);
544 ALIGN_POINTER(Buffer
, 7);
546 header
= (variant_wire_t
*)Buffer
;
548 Pos
= (unsigned char*)(header
+ 1);
549 type_size
= get_type_size(pFlags
, header
->vt
);
550 align
= get_type_alignment(pFlags
, header
->vt
);
551 ALIGN_POINTER(Pos
, align
);
553 if(header
->vt
& VT_BYREF
)
558 switch (header
->vt
& ~VT_BYREF
)
560 /* these types have a different memory size compared to wire size */
564 mem_size
= sizeof(void *);
567 mem_size
= type_size
;
571 if (V_VT(pvar
) != header
->vt
)
574 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
576 else if (!V_BYREF(pvar
))
577 V_BYREF(pvar
) = CoTaskMemAlloc(mem_size
);
578 memcpy(V_BYREF(pvar
), Pos
, type_size
);
579 if((header
->vt
& VT_TYPEMASK
) != VT_VARIANT
)
587 if((header
->vt
& VT_TYPEMASK
) == VT_DECIMAL
)
588 memcpy(pvar
, Pos
, type_size
);
590 memcpy(&pvar
->n1
.n2
.n3
, Pos
, type_size
);
594 pvar
->n1
.n2
.vt
= header
->vt
;
595 pvar
->n1
.n2
.wReserved1
= header
->wReserved1
;
596 pvar
->n1
.n2
.wReserved2
= header
->wReserved2
;
597 pvar
->n1
.n2
.wReserved3
= header
->wReserved3
;
599 if(header
->vt
& VT_ARRAY
)
601 if(header
->vt
& VT_BYREF
)
602 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, V_ARRAYREF(pvar
));
604 Pos
= LPSAFEARRAY_UserUnmarshal(pFlags
, Pos
, &V_ARRAY(pvar
));
612 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, &V_BSTR(pvar
));
614 case VT_BSTR
| VT_BYREF
:
615 *V_BSTRREF(pvar
) = NULL
;
616 Pos
= BSTR_UserUnmarshal(pFlags
, Pos
, V_BSTRREF(pvar
));
618 case VT_VARIANT
| VT_BYREF
:
619 Pos
= VARIANT_UserUnmarshal(pFlags
, Pos
, V_VARIANTREF(pvar
));
622 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
623 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, &V_UNKNOWN(pvar
));
625 case VT_UNKNOWN
| VT_BYREF
:
626 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
627 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IUnknown
, V_UNKNOWNREF(pvar
));
630 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
631 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)&V_DISPATCH(pvar
));
633 case VT_DISPATCH
| VT_BYREF
:
634 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
635 Pos
= interface_variant_unmarshal(pFlags
, Pos
, &IID_IDispatch
, (IUnknown
**)V_DISPATCHREF(pvar
));
638 FIXME("handle BRECORD by val\n");
640 case VT_RECORD
| VT_BYREF
:
641 FIXME("handle BRECORD by ref\n");
648 void WINAPI
VARIANT_UserFree(ULONG
*pFlags
, VARIANT
*pvar
)
650 VARTYPE vt
= V_VT(pvar
);
653 TRACE("(%x,%p)\n", *pFlags
, pvar
);
654 TRACE("vt=%04x\n", V_VT(pvar
));
656 if (vt
& VT_BYREF
) ref
= pvar
->n1
.n2
.n3
.byref
;
664 LPSAFEARRAY_UserFree(pFlags
, V_ARRAYREF(pvar
));
666 LPSAFEARRAY_UserFree(pFlags
, &V_ARRAY(pvar
));
672 case VT_BSTR
| VT_BYREF
:
673 BSTR_UserFree(pFlags
, V_BSTRREF(pvar
));
675 case VT_VARIANT
| VT_BYREF
:
676 VARIANT_UserFree(pFlags
, V_VARIANTREF(pvar
));
678 case VT_RECORD
| VT_BYREF
:
679 FIXME("handle BRECORD by ref\n");
681 case VT_UNKNOWN
| VT_BYREF
:
682 case VT_DISPATCH
| VT_BYREF
:
683 IUnknown_Release(*V_UNKNOWNREF(pvar
));
693 /* Get the number of cells in a SafeArray */
694 static ULONG
SAFEARRAY_GetCellCount(const SAFEARRAY
*psa
)
696 const SAFEARRAYBOUND
* psab
= psa
->rgsabound
;
697 USHORT cCount
= psa
->cDims
;
698 ULONG ulNumCells
= 1;
702 /* This is a valid bordercase. See testcases. -Marcus */
703 if (!psab
->cElements
)
705 ulNumCells
*= psab
->cElements
;
711 static inline SF_TYPE
SAFEARRAY_GetUnionType(SAFEARRAY
*psa
)
716 hr
= SafeArrayGetVartype(psa
, &vt
);
719 if(psa
->fFeatures
& FADF_VARIANT
) return SF_VARIANT
;
721 switch(psa
->cbElements
)
723 case 1: vt
= VT_I1
; break;
724 case 2: vt
= VT_I2
; break;
725 case 4: vt
= VT_I4
; break;
726 case 8: vt
= VT_I8
; break;
728 RpcRaiseException(hr
);
732 if (psa
->fFeatures
& FADF_HAVEIID
)
738 case VT_UI1
: return SF_I1
;
741 case VT_UI2
: return SF_I2
;
746 case VT_R4
: return SF_I4
;
751 case VT_UI8
: return SF_I8
;
753 case VT_UINT_PTR
: return (sizeof(UINT_PTR
) == 4 ? SF_I4
: SF_I8
);
754 case VT_BSTR
: return SF_BSTR
;
755 case VT_DISPATCH
: return SF_DISPATCH
;
756 case VT_VARIANT
: return SF_VARIANT
;
757 case VT_UNKNOWN
: return SF_UNKNOWN
;
758 /* Note: Return a non-zero size to indicate vt is valid. The actual size
759 * of a UDT is taken from the result of IRecordInfo_GetSize().
761 case VT_RECORD
: return SF_RECORD
;
762 default: return SF_ERROR
;
766 static DWORD
elem_wire_size(LPSAFEARRAY lpsa
, SF_TYPE sftype
)
768 if (sftype
== SF_BSTR
)
769 return sizeof(DWORD
);
770 else if (sftype
== SF_VARIANT
)
771 return sizeof(variant_wire_t
) - sizeof(DWORD
);
773 return lpsa
->cbElements
;
776 static DWORD
elem_mem_size(wireSAFEARRAY wiresa
, SF_TYPE sftype
)
778 if (sftype
== SF_BSTR
)
780 else if (sftype
== SF_VARIANT
)
781 return sizeof(VARIANT
);
783 return wiresa
->cbElements
;
786 ULONG WINAPI
LPSAFEARRAY_UserSize(ULONG
*pFlags
, ULONG StartingSize
, LPSAFEARRAY
*ppsa
)
788 ULONG size
= StartingSize
;
790 TRACE("("); dump_user_flags(pFlags
); TRACE(", %d, %p\n", StartingSize
, *ppsa
);
792 ALIGN_LENGTH(size
, 3);
793 size
+= sizeof(ULONG
);
796 SAFEARRAY
*psa
= *ppsa
;
797 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
801 size
+= sizeof(ULONG
);
802 size
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
804 sftype
= SAFEARRAY_GetUnionType(psa
);
805 size
+= sizeof(ULONG
);
807 size
+= sizeof(ULONG
);
808 size
+= sizeof(ULONG
);
809 if (sftype
== SF_HAVEIID
)
812 size
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
814 size
+= sizeof(ULONG
);
822 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
823 size
= BSTR_UserSize(pFlags
, size
, lpBstr
);
830 FIXME("size interfaces\n");
836 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
837 size
= VARIANT_UserSize(pFlags
, size
, lpVariant
);
843 IRecordInfo
* pRecInfo
= NULL
;
845 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
847 RpcRaiseException(hr
);
851 FIXME("size record info %p\n", pRecInfo
);
853 IRecordInfo_Release(pRecInfo
);
858 ALIGN_LENGTH(size
, 7);
863 size
+= ulCellCount
* psa
->cbElements
;
874 unsigned char * WINAPI
LPSAFEARRAY_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
878 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, &%p\n", Buffer
, *ppsa
);
880 ALIGN_POINTER(Buffer
, 3);
881 *(ULONG
*)Buffer
= *ppsa
? 0x1 : 0x0;
882 Buffer
+= sizeof(ULONG
);
886 SAFEARRAY
*psa
= *ppsa
;
887 ULONG ulCellCount
= SAFEARRAY_GetCellCount(psa
);
891 sftype
= SAFEARRAY_GetUnionType(psa
);
893 *(ULONG
*)Buffer
= psa
->cDims
;
894 Buffer
+= sizeof(ULONG
);
895 *(USHORT
*)Buffer
= psa
->cDims
;
896 Buffer
+= sizeof(USHORT
);
897 *(USHORT
*)Buffer
= psa
->fFeatures
;
898 Buffer
+= sizeof(USHORT
);
899 *(ULONG
*)Buffer
= elem_wire_size(psa
, sftype
);
900 Buffer
+= sizeof(ULONG
);
902 hr
= SafeArrayGetVartype(psa
, &vt
);
903 if (FAILED(hr
)) vt
= 0;
905 *(ULONG
*)Buffer
= (USHORT
)psa
->cLocks
| (vt
<< 16);
906 Buffer
+= sizeof(ULONG
);
908 *(ULONG
*)Buffer
= sftype
;
909 Buffer
+= sizeof(ULONG
);
911 *(ULONG
*)Buffer
= ulCellCount
;
912 Buffer
+= sizeof(ULONG
);
913 *(ULONG
*)Buffer
= psa
->pvData
? 0x2 : 0x0;
914 Buffer
+= sizeof(ULONG
);
915 if (sftype
== SF_HAVEIID
)
917 SafeArrayGetIID(psa
, &guid
);
918 memcpy(Buffer
, &guid
, sizeof(guid
));
919 Buffer
+= sizeof(guid
);
922 memcpy(Buffer
, psa
->rgsabound
, sizeof(psa
->rgsabound
[0]) * psa
->cDims
);
923 Buffer
+= sizeof(psa
->rgsabound
[0]) * psa
->cDims
;
925 *(ULONG
*)Buffer
= ulCellCount
;
926 Buffer
+= sizeof(ULONG
);
936 for (lpBstr
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpBstr
++)
937 Buffer
= BSTR_UserMarshal(pFlags
, Buffer
, lpBstr
);
944 FIXME("marshal interfaces\n");
950 for (lpVariant
= psa
->pvData
; ulCellCount
; ulCellCount
--, lpVariant
++)
951 Buffer
= VARIANT_UserMarshal(pFlags
, Buffer
, lpVariant
);
957 IRecordInfo
* pRecInfo
= NULL
;
959 hr
= SafeArrayGetRecordInfo(psa
, &pRecInfo
);
961 RpcRaiseException(hr
);
965 FIXME("write record info %p\n", pRecInfo
);
967 IRecordInfo_Release(pRecInfo
);
973 ALIGN_POINTER(Buffer
, 7);
978 /* Just copy the data over */
979 memcpy(Buffer
, psa
->pvData
, ulCellCount
* psa
->cbElements
);
980 Buffer
+= ulCellCount
* psa
->cbElements
;
991 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
992 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
993 FADF_VARIANT | FADF_CREATEVECTOR)
995 unsigned char * WINAPI
LPSAFEARRAY_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, LPSAFEARRAY
*ppsa
)
998 wireSAFEARRAY wiresa
;
1005 SAFEARRAYBOUND
*wiresab
;
1007 TRACE("("); dump_user_flags(pFlags
); TRACE(", %p, %p\n", Buffer
, ppsa
);
1009 ALIGN_POINTER(Buffer
, 3);
1010 ptr
= *(ULONG
*)Buffer
;
1011 Buffer
+= sizeof(ULONG
);
1017 TRACE("NULL safe array unmarshaled\n");
1022 cDims
= *(ULONG
*)Buffer
;
1023 Buffer
+= sizeof(ULONG
);
1025 wiresa
= (wireSAFEARRAY
)Buffer
;
1026 Buffer
+= 2 * sizeof(USHORT
) + 2 * sizeof(ULONG
);
1028 if (cDims
!= wiresa
->cDims
)
1029 RpcRaiseException(RPC_S_INVALID_BOUND
);
1031 /* FIXME: there should be a limit on how large cDims can be */
1033 vt
= HIWORD(wiresa
->cLocks
);
1035 sftype
= *(ULONG
*)Buffer
;
1036 Buffer
+= sizeof(ULONG
);
1038 cell_count
= *(ULONG
*)Buffer
;
1039 Buffer
+= sizeof(ULONG
);
1040 ptr
= *(ULONG
*)Buffer
;
1041 Buffer
+= sizeof(ULONG
);
1042 if (sftype
== SF_HAVEIID
)
1044 memcpy(&guid
, Buffer
, sizeof(guid
));
1045 Buffer
+= sizeof(guid
);
1048 wiresab
= (SAFEARRAYBOUND
*)Buffer
;
1049 Buffer
+= sizeof(wiresab
[0]) * wiresa
->cDims
;
1052 *ppsa
= SafeArrayCreateEx(vt
, wiresa
->cDims
, wiresab
, NULL
);
1055 SafeArrayAllocDescriptor(wiresa
->cDims
, ppsa
);
1057 memcpy((*ppsa
)->rgsabound
, wiresab
, sizeof(SAFEARRAYBOUND
) * wiresa
->cDims
);
1060 RpcRaiseException(E_OUTOFMEMORY
);
1062 /* be careful about which flags we set since they could be a security
1064 (*ppsa
)->fFeatures
&= FADF_AUTOSETFLAGS
;
1065 (*ppsa
)->fFeatures
|= (wiresa
->fFeatures
& ~(FADF_AUTOSETFLAGS
));
1066 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1067 (*ppsa
)->cbElements
= elem_mem_size(wiresa
, sftype
);
1068 (*ppsa
)->cLocks
= LOWORD(wiresa
->cLocks
);
1070 /* SafeArrayCreateEx allocates the data for us, but
1071 * SafeArrayAllocDescriptor doesn't */
1074 hr
= SafeArrayAllocData(*ppsa
);
1076 RpcRaiseException(hr
);
1079 if ((*(ULONG
*)Buffer
!= cell_count
) || (SAFEARRAY_GetCellCount(*ppsa
) != cell_count
))
1080 RpcRaiseException(RPC_S_INVALID_BOUND
);
1081 Buffer
+= sizeof(ULONG
);
1091 for (lpBstr
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpBstr
++)
1092 Buffer
= BSTR_UserUnmarshal(pFlags
, Buffer
, lpBstr
);
1099 FIXME("marshal interfaces\n");
1105 for (lpVariant
= (*ppsa
)->pvData
; cell_count
; cell_count
--, lpVariant
++)
1106 Buffer
= VARIANT_UserUnmarshal(pFlags
, Buffer
, lpVariant
);
1112 FIXME("set record info\n");
1118 ALIGN_POINTER(Buffer
, 7);
1123 /* Just copy the data over */
1124 memcpy((*ppsa
)->pvData
, Buffer
, cell_count
* (*ppsa
)->cbElements
);
1125 Buffer
+= cell_count
* (*ppsa
)->cbElements
;
1132 TRACE("safe array unmarshaled: %p\n", *ppsa
);
1137 void WINAPI
LPSAFEARRAY_UserFree(ULONG
*pFlags
, LPSAFEARRAY
*ppsa
)
1139 TRACE("("); dump_user_flags(pFlags
); TRACE(", &%p\n", *ppsa
);
1141 SafeArrayDestroy(*ppsa
);
1145 ULONG WINAPI
HFONT_UserSize(ULONG
*pFlags
, ULONG Start
, HFONT
*phfont
)
1151 unsigned char * WINAPI
HFONT_UserMarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1157 unsigned char * WINAPI
HFONT_UserUnmarshal(ULONG
*pFlags
, unsigned char *Buffer
, HFONT
*phfont
)
1163 void WINAPI
HFONT_UserFree(ULONG
*pFlags
, HFONT
*phfont
)
1171 /* exactly how Invoke is marshalled is not very clear to me yet,
1172 * but the way I've done it seems to work for me */
1174 HRESULT CALLBACK
IDispatch_Invoke_Proxy(
1176 DISPID dispIdMember
,
1180 DISPPARAMS
* pDispParams
,
1181 VARIANT
* pVarResult
,
1182 EXCEPINFO
* pExcepInfo
,
1187 UINT
* rgVarRefIdx
= NULL
;
1188 VARIANTARG
* rgVarRef
= NULL
;
1191 EXCEPINFO ExcepInfo
;
1193 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This
,
1194 dispIdMember
, debugstr_guid(riid
),
1195 lcid
, wFlags
, pDispParams
, pVarResult
,
1196 pExcepInfo
, puArgErr
);
1198 /* [out] args can't be null, use dummy vars if needed */
1199 if (!pVarResult
) pVarResult
= &VarResult
;
1200 if (!puArgErr
) puArgErr
= &uArgErr
;
1201 if (!pExcepInfo
) pExcepInfo
= &ExcepInfo
;
1203 /* count by-ref args */
1204 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1205 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1206 if (V_ISBYREF(arg
)) {
1211 rgVarRefIdx
= CoTaskMemAlloc(sizeof(UINT
)*cVarRef
);
1212 rgVarRef
= CoTaskMemAlloc(sizeof(VARIANTARG
)*cVarRef
);
1213 /* make list of by-ref args */
1214 for (cVarRef
=0,u
=0; u
<pDispParams
->cArgs
; u
++) {
1215 VARIANTARG
* arg
= &pDispParams
->rgvarg
[u
];
1216 if (V_ISBYREF(arg
)) {
1217 rgVarRefIdx
[cVarRef
] = u
;
1218 VariantInit(&rgVarRef
[cVarRef
]);
1219 VariantCopy(&rgVarRef
[cVarRef
], arg
);
1225 /* [out] args still can't be null,
1226 * but we can point these anywhere in this case,
1227 * since they won't be written to when cVarRef is 0 */
1228 rgVarRefIdx
= puArgErr
;
1229 rgVarRef
= pVarResult
;
1231 TRACE("passed by ref: %d args\n", cVarRef
);
1232 hr
= IDispatch_RemoteInvoke_Proxy(This
,
1245 for (u
=0; u
<cVarRef
; u
++) {
1246 unsigned i
= rgVarRefIdx
[u
];
1247 VariantCopy(&pDispParams
->rgvarg
[i
],
1249 VariantClear(&rgVarRef
[u
]);
1251 CoTaskMemFree(rgVarRef
);
1252 CoTaskMemFree(rgVarRefIdx
);
1255 if(pExcepInfo
== &ExcepInfo
)
1257 SysFreeString(pExcepInfo
->bstrSource
);
1258 SysFreeString(pExcepInfo
->bstrDescription
);
1259 SysFreeString(pExcepInfo
->bstrHelpFile
);
1264 HRESULT __RPC_STUB
IDispatch_Invoke_Stub(
1266 DISPID dispIdMember
,
1270 DISPPARAMS
* pDispParams
,
1271 VARIANT
* pVarResult
,
1272 EXCEPINFO
* pExcepInfo
,
1276 VARIANTARG
* rgVarRef
)
1279 VARIANTARG
*rgvarg
, *arg
;
1282 /* initialize out parameters, so that they can be marshalled
1283 * in case the real Invoke doesn't initialize them */
1284 VariantInit(pVarResult
);
1285 memset(pExcepInfo
, 0, sizeof(*pExcepInfo
));
1288 /* let the real Invoke operate on a copy of the in parameters,
1289 * so we don't risk losing pointers to allocated memory */
1290 rgvarg
= pDispParams
->rgvarg
;
1291 arg
= CoTaskMemAlloc(sizeof(VARIANTARG
)*pDispParams
->cArgs
);
1292 if (!arg
) return E_OUTOFMEMORY
;
1294 /* init all args so we can call VariantClear on all the args if the copy
1296 for (u
= 0; u
< pDispParams
->cArgs
; u
++)
1297 VariantInit(&arg
[u
]);
1299 for (u
= 0; u
< pDispParams
->cArgs
; u
++) {
1300 hr
= VariantCopy(&arg
[u
], &rgvarg
[u
]);
1305 if (SUCCEEDED(hr
)) {
1306 /* copy ref args to arg array */
1307 for (u
=0; u
<cVarRef
; u
++) {
1308 unsigned i
= rgVarRefIdx
[u
];
1309 VariantCopy(&arg
[i
], &rgVarRef
[u
]);
1312 pDispParams
->rgvarg
= arg
;
1314 hr
= IDispatch_Invoke(This
,
1324 /* copy ref args from arg array */
1325 for (u
=0; u
<cVarRef
; u
++) {
1326 unsigned i
= rgVarRefIdx
[u
];
1327 VariantCopy(&rgVarRef
[u
], &arg
[i
]);
1331 /* clear the duplicate argument list */
1332 for (u
=0; u
<pDispParams
->cArgs
; u
++)
1333 VariantClear(&arg
[u
]);
1335 pDispParams
->rgvarg
= rgvarg
;
1343 HRESULT CALLBACK
IEnumVARIANT_Next_Proxy(
1347 ULONG
* pCeltFetched
)
1351 pCeltFetched
= &fetched
;
1352 return IEnumVARIANT_RemoteNext_Proxy(This
,
1358 HRESULT __RPC_STUB
IEnumVARIANT_Next_Stub(
1362 ULONG
* pCeltFetched
)
1366 hr
= IEnumVARIANT_Next(This
,
1370 if (hr
== S_OK
) *pCeltFetched
= celt
;
1374 /* TypeInfo related freers */
1376 static void free_embedded_typedesc(TYPEDESC
*tdesc
);
1377 static void free_embedded_arraydesc(ARRAYDESC
*adesc
)
1379 switch(adesc
->tdescElem
.vt
)
1383 free_embedded_typedesc(adesc
->tdescElem
.u
.lptdesc
);
1384 CoTaskMemFree(adesc
->tdescElem
.u
.lptdesc
);
1387 free_embedded_arraydesc(adesc
->tdescElem
.u
.lpadesc
);
1388 CoTaskMemFree(adesc
->tdescElem
.u
.lpadesc
);
1393 static void free_embedded_typedesc(TYPEDESC
*tdesc
)
1399 free_embedded_typedesc(tdesc
->u
.lptdesc
);
1400 CoTaskMemFree(tdesc
->u
.lptdesc
);
1403 free_embedded_arraydesc(tdesc
->u
.lpadesc
);
1404 CoTaskMemFree(tdesc
->u
.lpadesc
);
1409 static void free_embedded_elemdesc(ELEMDESC
*edesc
)
1411 free_embedded_typedesc(&edesc
->tdesc
);
1412 if(edesc
->u
.paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
)
1413 CoTaskMemFree(edesc
->u
.paramdesc
.pparamdescex
);
1418 HRESULT CALLBACK
ITypeComp_Bind_Proxy(
1423 ITypeInfo
** ppTInfo
,
1424 DESCKIND
* pDescKind
,
1427 FIXME("not implemented\n");
1431 HRESULT __RPC_STUB
ITypeComp_Bind_Stub(
1436 ITypeInfo
** ppTInfo
,
1437 DESCKIND
* pDescKind
,
1438 LPFUNCDESC
* ppFuncDesc
,
1439 LPVARDESC
* ppVarDesc
,
1440 ITypeComp
** ppTypeComp
,
1441 CLEANLOCALSTORAGE
* pDummy
)
1443 FIXME("not implemented\n");
1447 HRESULT CALLBACK
ITypeComp_BindType_Proxy(
1451 ITypeInfo
** ppTInfo
,
1452 ITypeComp
** ppTComp
)
1454 FIXME("not implemented\n");
1458 HRESULT __RPC_STUB
ITypeComp_BindType_Stub(
1462 ITypeInfo
** ppTInfo
)
1464 FIXME("not implemented\n");
1470 HRESULT CALLBACK
ITypeInfo_GetTypeAttr_Proxy(
1472 TYPEATTR
** ppTypeAttr
)
1475 CLEANLOCALSTORAGE stg
;
1476 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1479 stg
.pStorage
= NULL
;
1480 stg
.pInterface
= NULL
;
1482 return ITypeInfo_RemoteGetTypeAttr_Proxy(This
, ppTypeAttr
, &stg
);
1485 HRESULT __RPC_STUB
ITypeInfo_GetTypeAttr_Stub(
1487 LPTYPEATTR
* ppTypeAttr
,
1488 CLEANLOCALSTORAGE
* pDummy
)
1491 TRACE("(%p, %p)\n", This
, ppTypeAttr
);
1493 hr
= ITypeInfo_GetTypeAttr(This
, ppTypeAttr
);
1497 pDummy
->flags
= CLS_TYPEATTR
;
1498 ITypeInfo_AddRef(This
);
1499 pDummy
->pInterface
= (IUnknown
*)This
;
1500 pDummy
->pStorage
= ppTypeAttr
;
1504 HRESULT CALLBACK
ITypeInfo_GetFuncDesc_Proxy(
1507 FUNCDESC
** ppFuncDesc
)
1509 CLEANLOCALSTORAGE stg
;
1510 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1513 stg
.pStorage
= NULL
;
1514 stg
.pInterface
= NULL
;
1516 return ITypeInfo_RemoteGetFuncDesc_Proxy(This
, index
, ppFuncDesc
, &stg
);
1519 HRESULT __RPC_STUB
ITypeInfo_GetFuncDesc_Stub(
1522 LPFUNCDESC
* ppFuncDesc
,
1523 CLEANLOCALSTORAGE
* pDummy
)
1526 TRACE("(%p, %d, %p)\n", This
, index
, ppFuncDesc
);
1528 hr
= ITypeInfo_GetFuncDesc(This
, index
, ppFuncDesc
);
1532 pDummy
->flags
= CLS_FUNCDESC
;
1533 ITypeInfo_AddRef(This
);
1534 pDummy
->pInterface
= (IUnknown
*)This
;
1535 pDummy
->pStorage
= ppFuncDesc
;
1539 HRESULT CALLBACK
ITypeInfo_GetVarDesc_Proxy(
1542 VARDESC
** ppVarDesc
)
1544 CLEANLOCALSTORAGE stg
;
1545 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1548 stg
.pStorage
= NULL
;
1549 stg
.pInterface
= NULL
;
1551 return ITypeInfo_RemoteGetVarDesc_Proxy(This
, index
, ppVarDesc
, &stg
);
1554 HRESULT __RPC_STUB
ITypeInfo_GetVarDesc_Stub(
1557 LPVARDESC
* ppVarDesc
,
1558 CLEANLOCALSTORAGE
* pDummy
)
1561 TRACE("(%p, %d, %p)\n", This
, index
, ppVarDesc
);
1563 hr
= ITypeInfo_GetVarDesc(This
, index
, ppVarDesc
);
1567 pDummy
->flags
= CLS_VARDESC
;
1568 ITypeInfo_AddRef(This
);
1569 pDummy
->pInterface
= (IUnknown
*)This
;
1570 pDummy
->pStorage
= ppVarDesc
;
1574 HRESULT CALLBACK
ITypeInfo_GetNames_Proxy(
1581 FIXME("not implemented\n");
1585 HRESULT __RPC_STUB
ITypeInfo_GetNames_Stub(
1592 FIXME("not implemented\n");
1596 HRESULT CALLBACK
ITypeInfo_GetIDsOfNames_Proxy(
1598 LPOLESTR
* rgszNames
,
1602 FIXME("not implemented\n");
1606 HRESULT __RPC_STUB
ITypeInfo_GetIDsOfNames_Stub(
1609 FIXME("not implemented\n");
1613 HRESULT CALLBACK
ITypeInfo_Invoke_Proxy(
1618 DISPPARAMS
* pDispParams
,
1619 VARIANT
* pVarResult
,
1620 EXCEPINFO
* pExcepInfo
,
1623 FIXME("not implemented\n");
1627 HRESULT __RPC_STUB
ITypeInfo_Invoke_Stub(
1630 FIXME("not implemented\n");
1634 HRESULT CALLBACK
ITypeInfo_GetDocumentation_Proxy(
1638 BSTR
* pBstrDocString
,
1639 DWORD
* pdwHelpContext
,
1640 BSTR
* pBstrHelpFile
)
1643 BSTR name
, doc_string
, help_file
;
1645 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1647 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1648 hr
= ITypeInfo_RemoteGetDocumentation_Proxy(This
, memid
, 0, &name
, &doc_string
, &help_context
, &help_file
);
1651 if(pBstrName
) *pBstrName
= name
;
1652 else SysFreeString(name
);
1654 if(pBstrDocString
) *pBstrDocString
= doc_string
;
1655 else SysFreeString(doc_string
);
1657 if(pBstrHelpFile
) *pBstrHelpFile
= help_file
;
1658 else SysFreeString(help_file
);
1660 if(pdwHelpContext
) *pdwHelpContext
= help_context
;
1665 HRESULT __RPC_STUB
ITypeInfo_GetDocumentation_Stub(
1670 BSTR
* pBstrDocString
,
1671 DWORD
* pdwHelpContext
,
1672 BSTR
* pBstrHelpFile
)
1674 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This
, memid
, refPtrFlags
, pBstrName
, pBstrDocString
,
1675 pdwHelpContext
, pBstrHelpFile
);
1676 return ITypeInfo_GetDocumentation(This
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
1679 HRESULT CALLBACK
ITypeInfo_GetDllEntry_Proxy(
1687 FIXME("not implemented\n");
1691 HRESULT __RPC_STUB
ITypeInfo_GetDllEntry_Stub(
1700 FIXME("not implemented\n");
1704 HRESULT CALLBACK
ITypeInfo_AddressOfMember_Proxy(
1710 FIXME("not implemented\n");
1714 HRESULT __RPC_STUB
ITypeInfo_AddressOfMember_Stub(
1717 FIXME("not implemented\n");
1721 HRESULT CALLBACK
ITypeInfo_CreateInstance_Proxy(
1723 IUnknown
* pUnkOuter
,
1727 FIXME("not implemented\n");
1731 HRESULT __RPC_STUB
ITypeInfo_CreateInstance_Stub(
1736 FIXME("not implemented\n");
1740 HRESULT CALLBACK
ITypeInfo_GetContainingTypeLib_Proxy(
1749 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1751 hr
= ITypeInfo_RemoteGetContainingTypeLib_Proxy(This
, &pTL
, &index
);
1760 ITypeLib_Release(pTL
);
1765 HRESULT __RPC_STUB
ITypeInfo_GetContainingTypeLib_Stub(
1770 TRACE("(%p, %p, %p)\n", This
, ppTLib
, pIndex
);
1771 return ITypeInfo_GetContainingTypeLib(This
, ppTLib
, pIndex
);
1774 void CALLBACK
ITypeInfo_ReleaseTypeAttr_Proxy(
1776 TYPEATTR
* pTypeAttr
)
1778 TRACE("(%p, %p)\n", This
, pTypeAttr
);
1779 free_embedded_typedesc(&pTypeAttr
->tdescAlias
);
1780 CoTaskMemFree(pTypeAttr
);
1783 HRESULT __RPC_STUB
ITypeInfo_ReleaseTypeAttr_Stub(
1786 TRACE("nothing to do\n");
1790 void CALLBACK
ITypeInfo_ReleaseFuncDesc_Proxy(
1792 FUNCDESC
* pFuncDesc
)
1795 TRACE("(%p, %p)\n", This
, pFuncDesc
);
1797 for(param
= 0; param
< pFuncDesc
->cParams
; param
++)
1798 free_embedded_elemdesc(pFuncDesc
->lprgelemdescParam
+ param
);
1800 CoTaskMemFree(pFuncDesc
->lprgelemdescParam
);
1802 free_embedded_elemdesc(&pFuncDesc
->elemdescFunc
);
1804 if(pFuncDesc
->cScodes
!= 0 && pFuncDesc
->cScodes
!= -1)
1805 CoTaskMemFree(pFuncDesc
->lprgscode
);
1807 CoTaskMemFree(pFuncDesc
);
1810 HRESULT __RPC_STUB
ITypeInfo_ReleaseFuncDesc_Stub(
1813 TRACE("nothing to do\n");
1817 void CALLBACK
ITypeInfo_ReleaseVarDesc_Proxy(
1821 TRACE("(%p, %p)\n", This
, pVarDesc
);
1823 CoTaskMemFree(pVarDesc
->lpstrSchema
);
1825 if(pVarDesc
->varkind
== VAR_CONST
)
1826 CoTaskMemFree(pVarDesc
->u
.lpvarValue
);
1828 free_embedded_elemdesc(&pVarDesc
->elemdescVar
);
1829 CoTaskMemFree(pVarDesc
);
1832 HRESULT __RPC_STUB
ITypeInfo_ReleaseVarDesc_Stub(
1835 TRACE("nothing to do\n");
1842 HRESULT CALLBACK
ITypeInfo2_GetDocumentation2_Proxy(
1846 BSTR
* pbstrHelpString
,
1847 DWORD
* pdwHelpStringContext
,
1848 BSTR
* pbstrHelpStringDll
)
1850 FIXME("not implemented\n");
1854 HRESULT __RPC_STUB
ITypeInfo2_GetDocumentation2_Stub(
1859 BSTR
* pbstrHelpString
,
1860 DWORD
* pdwHelpStringContext
,
1861 BSTR
* pbstrHelpStringDll
)
1863 FIXME("not implemented\n");
1869 UINT CALLBACK
ITypeLib_GetTypeInfoCount_Proxy(
1873 TRACE("(%p)\n", This
);
1875 ITypeLib_RemoteGetTypeInfoCount_Proxy(This
, &count
);
1880 HRESULT __RPC_STUB
ITypeLib_GetTypeInfoCount_Stub(
1884 TRACE("(%p, %p)\n", This
, pcTInfo
);
1885 *pcTInfo
= ITypeLib_GetTypeInfoCount(This
);
1889 HRESULT CALLBACK
ITypeLib_GetLibAttr_Proxy(
1891 TLIBATTR
** ppTLibAttr
)
1893 CLEANLOCALSTORAGE stg
;
1894 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1897 stg
.pStorage
= NULL
;
1898 stg
.pInterface
= NULL
;
1900 return ITypeLib_RemoteGetLibAttr_Proxy(This
, ppTLibAttr
, &stg
);
1903 HRESULT __RPC_STUB
ITypeLib_GetLibAttr_Stub(
1905 LPTLIBATTR
* ppTLibAttr
,
1906 CLEANLOCALSTORAGE
* pDummy
)
1909 TRACE("(%p, %p)\n", This
, ppTLibAttr
);
1911 hr
= ITypeLib_GetLibAttr(This
, ppTLibAttr
);
1915 pDummy
->flags
= CLS_LIBATTR
;
1916 ITypeLib_AddRef(This
);
1917 pDummy
->pInterface
= (IUnknown
*)This
;
1918 pDummy
->pStorage
= ppTLibAttr
;
1922 HRESULT CALLBACK
ITypeLib_GetDocumentation_Proxy(
1926 BSTR
* pBstrDocString
,
1927 DWORD
* pdwHelpContext
,
1928 BSTR
* pBstrHelpFile
)
1930 FIXME("not implemented\n");
1934 HRESULT __RPC_STUB
ITypeLib_GetDocumentation_Stub(
1939 BSTR
* pBstrDocString
,
1940 DWORD
* pdwHelpContext
,
1941 BSTR
* pBstrHelpFile
)
1943 FIXME("not implemented\n");
1947 HRESULT CALLBACK
ITypeLib_IsName_Proxy(
1953 FIXME("not implemented\n");
1957 HRESULT __RPC_STUB
ITypeLib_IsName_Stub(
1964 FIXME("not implemented\n");
1968 HRESULT CALLBACK
ITypeLib_FindName_Proxy(
1972 ITypeInfo
** ppTInfo
,
1976 FIXME("not implemented\n");
1980 HRESULT __RPC_STUB
ITypeLib_FindName_Stub(
1984 ITypeInfo
** ppTInfo
,
1989 FIXME("not implemented\n");
1993 void CALLBACK
ITypeLib_ReleaseTLibAttr_Proxy(
1995 TLIBATTR
* pTLibAttr
)
1997 TRACE("(%p, %p)\n", This
, pTLibAttr
);
1998 CoTaskMemFree(pTLibAttr
);
2001 HRESULT __RPC_STUB
ITypeLib_ReleaseTLibAttr_Stub(
2004 TRACE("nothing to do\n");
2011 HRESULT CALLBACK
ITypeLib2_GetLibStatistics_Proxy(
2013 ULONG
* pcUniqueNames
,
2014 ULONG
* pcchUniqueNames
)
2016 FIXME("not implemented\n");
2020 HRESULT __RPC_STUB
ITypeLib2_GetLibStatistics_Stub(
2022 ULONG
* pcUniqueNames
,
2023 ULONG
* pcchUniqueNames
)
2025 FIXME("not implemented\n");
2029 HRESULT CALLBACK
ITypeLib2_GetDocumentation2_Proxy(
2033 BSTR
* pbstrHelpString
,
2034 DWORD
* pdwHelpStringContext
,
2035 BSTR
* pbstrHelpStringDll
)
2037 FIXME("not implemented\n");
2041 HRESULT __RPC_STUB
ITypeLib2_GetDocumentation2_Stub(
2046 BSTR
* pbstrHelpString
,
2047 DWORD
* pdwHelpStringContext
,
2048 BSTR
* pbstrHelpStringDll
)
2050 FIXME("not implemented\n");
2054 HRESULT CALLBACK
IPropertyBag_Read_Proxy(
2056 LPCOLESTR pszPropName
,
2058 IErrorLog
*pErrorLog
)
2060 IUnknown
*pUnk
= NULL
;
2061 TRACE("(%p, %s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
2066 if(V_VT(pVar
) & (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2068 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2075 pUnk
= (IUnknown
*)V_DISPATCH(pVar
);
2078 pUnk
= V_UNKNOWN(pVar
);
2081 FIXME("Safearray support not yet implemented.\n");
2084 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar
));
2088 return IPropertyBag_RemoteRead_Proxy(This
, pszPropName
, pVar
, pErrorLog
,
2092 HRESULT __RPC_STUB
IPropertyBag_Read_Stub(
2094 LPCOLESTR pszPropName
,
2096 IErrorLog
*pErrorLog
,
2100 static const WCHAR emptyWstr
[1] = {0};
2103 TRACE("(%p, %s, %p, %p, %x, %p)\n", This
, debugstr_w(pszPropName
), pVar
,
2104 pErrorLog
, varType
, pUnkObj
);
2106 if(varType
& (VT_BYREF
| VT_ARRAY
| VT_VECTOR
))
2108 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar
));
2112 V_VT(pVar
) = varType
;
2116 hr
= IUnknown_QueryInterface(pUnkObj
, &IID_IDispatch
, (LPVOID
*)&disp
);
2119 IUnknown_Release(pUnkObj
);
2120 V_DISPATCH(pVar
) = disp
;
2123 V_UNKNOWN(pVar
) = pUnkObj
;
2126 V_BSTR(pVar
) = SysAllocString(emptyWstr
);
2129 FIXME("Safearray support not yet implemented.\n");
2134 hr
= IPropertyBag_Read(This
, pszPropName
, pVar
, pErrorLog
);
2141 /* call_as/local stubs for ocidl.idl */
2143 HRESULT CALLBACK
IClassFactory2_CreateInstanceLic_Proxy(
2144 IClassFactory2
* This
,
2145 IUnknown
*pUnkOuter
,
2146 IUnknown
*pUnkReserved
,
2151 FIXME("not implemented\n");
2155 HRESULT __RPC_STUB
IClassFactory2_CreateInstanceLic_Stub(
2156 IClassFactory2
* This
,
2161 FIXME("not implemented\n");
2165 HRESULT CALLBACK
IEnumConnections_Next_Proxy(
2166 IEnumConnections
* This
,
2171 FIXME("not implemented\n");
2175 HRESULT __RPC_STUB
IEnumConnections_Next_Stub(
2176 IEnumConnections
* This
,
2181 FIXME("not implemented\n");
2185 HRESULT CALLBACK
IEnumConnectionPoints_Next_Proxy(
2186 IEnumConnectionPoints
* This
,
2188 LPCONNECTIONPOINT
*ppCP
,
2191 FIXME("not implemented\n");
2195 HRESULT __RPC_STUB
IEnumConnectionPoints_Next_Stub(
2196 IEnumConnectionPoints
* This
,
2198 LPCONNECTIONPOINT
*ppCP
,
2201 FIXME("not implemented\n");
2205 HRESULT CALLBACK
IPersistMemory_Load_Proxy(
2206 IPersistMemory
* This
,
2210 FIXME("not implemented\n");
2214 HRESULT __RPC_STUB
IPersistMemory_Load_Stub(
2215 IPersistMemory
* This
,
2219 FIXME("not implemented\n");
2223 HRESULT CALLBACK
IPersistMemory_Save_Proxy(
2224 IPersistMemory
* This
,
2229 FIXME("not implemented\n");
2233 HRESULT __RPC_STUB
IPersistMemory_Save_Stub(
2234 IPersistMemory
* This
,
2239 FIXME("not implemented\n");
2243 void CALLBACK
IAdviseSinkEx_OnViewStatusChange_Proxy(
2244 IAdviseSinkEx
* This
,
2247 FIXME("not implemented\n");
2250 HRESULT __RPC_STUB
IAdviseSinkEx_OnViewStatusChange_Stub(
2251 IAdviseSinkEx
* This
,
2254 FIXME("not implemented\n");
2258 HRESULT CALLBACK
IEnumOleUndoUnits_Next_Proxy(
2259 IEnumOleUndoUnits
* This
,
2261 IOleUndoUnit
**rgElt
,
2262 ULONG
*pcEltFetched
)
2264 FIXME("not implemented\n");
2268 HRESULT __RPC_STUB
IEnumOleUndoUnits_Next_Stub(
2269 IEnumOleUndoUnits
* This
,
2271 IOleUndoUnit
**rgElt
,
2272 ULONG
*pcEltFetched
)
2274 FIXME("not implemented\n");
2278 HRESULT CALLBACK
IQuickActivate_QuickActivate_Proxy(
2279 IQuickActivate
* This
,
2280 QACONTAINER
*pQaContainer
,
2281 QACONTROL
*pQaControl
)
2283 FIXME("not implemented\n");
2287 HRESULT __RPC_STUB
IQuickActivate_QuickActivate_Stub(
2288 IQuickActivate
* This
,
2289 QACONTAINER
*pQaContainer
,
2290 QACONTROL
*pQaControl
)
2292 FIXME("not implemented\n");