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 ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY *ppsa)
768 ULONG size = StartingSize;
770 TRACE("("); dump_user_flags(pFlags); TRACE(", %d, %p\n", StartingSize, *ppsa);
772 ALIGN_LENGTH(size, 3);
773 size += sizeof(ULONG);
776 SAFEARRAY *psa = *ppsa;
777 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
781 size += sizeof(ULONG);
782 size += 2 * sizeof(USHORT) + 2 * sizeof(ULONG);
784 sftype = SAFEARRAY_GetUnionType(psa);
785 size += sizeof(ULONG);
787 size += sizeof(ULONG);
788 size += sizeof(ULONG);
789 if (sftype == SF_HAVEIID)
792 size += sizeof(psa->rgsabound[0]) * psa->cDims;
794 size += sizeof(ULONG);
802 for (lpBstr = psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
803 size = BSTR_UserSize(pFlags, size, lpBstr);
810 FIXME("size interfaces\n");
816 for (lpVariant = psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
817 size = VARIANT_UserSize(pFlags, size, lpVariant);
823 IRecordInfo* pRecInfo = NULL;
825 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
827 RpcRaiseException(hr);
831 FIXME("size record info %p\n", pRecInfo);
833 IRecordInfo_Release(pRecInfo);
838 ALIGN_LENGTH(size, 7);
843 size += ulCellCount * psa->cbElements;
854 unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
858 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
860 ALIGN_POINTER(Buffer, 3);
861 *(ULONG *)Buffer = *ppsa ? 0x1 : 0x0;
862 Buffer += sizeof(ULONG);
866 SAFEARRAY *psa = *ppsa;
867 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
871 *(ULONG *)Buffer = psa->cDims;
872 Buffer += sizeof(ULONG);
873 *(USHORT *)Buffer = psa->cDims;
874 Buffer += sizeof(USHORT);
875 *(USHORT *)Buffer = psa->fFeatures;
876 Buffer += sizeof(USHORT);
877 *(ULONG *)Buffer = psa->cbElements;
878 Buffer += sizeof(ULONG);
880 hr = SafeArrayGetVartype(psa, &vt);
881 if (FAILED(hr)) vt = 0;
883 *(ULONG *)Buffer = (USHORT)psa->cLocks | (vt << 16);
884 Buffer += sizeof(ULONG);
886 sftype = SAFEARRAY_GetUnionType(psa);
887 *(ULONG *)Buffer = sftype;
888 Buffer += sizeof(ULONG);
890 *(ULONG *)Buffer = ulCellCount;
891 Buffer += sizeof(ULONG);
892 *(ULONG *)Buffer = psa->pvData ? 0x2 : 0x0;
893 Buffer += sizeof(ULONG);
894 if (sftype == SF_HAVEIID)
896 SafeArrayGetIID(psa, &guid);
897 memcpy(Buffer, &guid, sizeof(guid));
898 Buffer += sizeof(guid);
901 memcpy(Buffer, psa->rgsabound, sizeof(psa->rgsabound[0]) * psa->cDims);
902 Buffer += sizeof(psa->rgsabound[0]) * psa->cDims;
904 *(ULONG *)Buffer = ulCellCount;
905 Buffer += sizeof(ULONG);
915 for (lpBstr = psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
916 Buffer = BSTR_UserMarshal(pFlags, Buffer, lpBstr);
923 FIXME("marshal interfaces\n");
929 for (lpVariant = psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
930 Buffer = VARIANT_UserMarshal(pFlags, Buffer, lpVariant);
936 IRecordInfo* pRecInfo = NULL;
938 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
940 RpcRaiseException(hr);
944 FIXME("write record info %p\n", pRecInfo);
946 IRecordInfo_Release(pRecInfo);
952 ALIGN_POINTER(Buffer, 7);
957 /* Just copy the data over */
958 memcpy(Buffer, psa->pvData, ulCellCount * psa->cbElements);
959 Buffer += ulCellCount * psa->cbElements;
970 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
971 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
972 FADF_VARIANT | FADF_CREATEVECTOR)
974 unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
977 wireSAFEARRAY wiresa;
984 SAFEARRAYBOUND *wiresab;
986 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
988 ALIGN_POINTER(Buffer, 3);
989 ptr = *(ULONG *)Buffer;
990 Buffer += sizeof(ULONG);
996 TRACE("NULL safe array unmarshaled\n");
1001 cDims = *(ULONG *)Buffer;
1002 Buffer += sizeof(ULONG);
1004 wiresa = (wireSAFEARRAY)Buffer;
1005 Buffer += 2 * sizeof(USHORT) + 2 * sizeof(ULONG);
1007 if (cDims != wiresa->cDims)
1008 RpcRaiseException(RPC_S_INVALID_BOUND);
1010 /* FIXME: there should be a limit on how large cDims can be */
1012 vt = HIWORD(wiresa->cLocks);
1014 sftype = *(ULONG *)Buffer;
1015 Buffer += sizeof(ULONG);
1017 cell_count = *(ULONG *)Buffer;
1018 Buffer += sizeof(ULONG);
1019 ptr = *(ULONG *)Buffer;
1020 Buffer += sizeof(ULONG);
1021 if (sftype == SF_HAVEIID)
1023 memcpy(&guid, Buffer, sizeof(guid));
1024 Buffer += sizeof(guid);
1027 wiresab = (SAFEARRAYBOUND *)Buffer;
1028 Buffer += sizeof(wiresab[0]) * wiresa->cDims;
1031 *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
1034 SafeArrayAllocDescriptor(wiresa->cDims, ppsa);
1036 memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
1039 RpcRaiseException(E_OUTOFMEMORY);
1041 /* be careful about which flags we set since they could be a security
1043 (*ppsa)->fFeatures &= FADF_AUTOSETFLAGS;
1044 (*ppsa)->fFeatures |= (wiresa->fFeatures & ~(FADF_AUTOSETFLAGS));
1045 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1046 (*ppsa)->cbElements = wiresa->cbElements;
1047 (*ppsa)->cLocks = LOWORD(wiresa->cLocks);
1049 /* SafeArrayCreateEx allocates the data for us, but
1050 * SafeArrayAllocDescriptor doesn't */
1053 hr = SafeArrayAllocData(*ppsa);
1055 RpcRaiseException(hr);
1058 if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
1059 RpcRaiseException(RPC_S_INVALID_BOUND);
1060 Buffer += sizeof(ULONG);
1070 for (lpBstr = (*ppsa)->pvData; cell_count; cell_count--, lpBstr++)
1071 Buffer = BSTR_UserUnmarshal(pFlags, Buffer, lpBstr);
1078 FIXME("marshal interfaces\n");
1084 for (lpVariant = (*ppsa)->pvData; cell_count; cell_count--, lpVariant++)
1085 Buffer = VARIANT_UserUnmarshal(pFlags, Buffer, lpVariant);
1091 FIXME("set record info\n");
1097 ALIGN_POINTER(Buffer, 7);
1102 /* Just copy the data over */
1103 memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
1104 Buffer += cell_count * (*ppsa)->cbElements;
1111 TRACE("safe array unmarshaled: %p\n", *ppsa);
1116 void WINAPI LPSAFEARRAY_UserFree(ULONG *pFlags, LPSAFEARRAY *ppsa)
1118 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *ppsa);
1120 SafeArrayDestroy(*ppsa);
1124 ULONG WINAPI HFONT_UserSize(ULONG *pFlags, ULONG Start, HFONT *phfont)
1130 unsigned char * WINAPI HFONT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1136 unsigned char * WINAPI HFONT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1142 void WINAPI HFONT_UserFree(ULONG *pFlags, HFONT *phfont)
1150 /* exactly how Invoke is marshalled is not very clear to me yet,
1151 * but the way I've done it seems to work for me */
1153 HRESULT CALLBACK IDispatch_Invoke_Proxy(
1155 DISPID dispIdMember,
1159 DISPPARAMS* pDispParams,
1160 VARIANT* pVarResult,
1161 EXCEPINFO* pExcepInfo,
1166 UINT* rgVarRefIdx = NULL;
1167 VARIANTARG* rgVarRef = NULL;
1170 EXCEPINFO ExcepInfo;
1172 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This,
1173 dispIdMember, debugstr_guid(riid),
1174 lcid, wFlags, pDispParams, pVarResult,
1175 pExcepInfo, puArgErr);
1177 /* [out] args can't be null, use dummy vars if needed */
1178 if (!pVarResult) pVarResult = &VarResult;
1179 if (!puArgErr) puArgErr = &uArgErr;
1180 if (!pExcepInfo) pExcepInfo = &ExcepInfo;
1182 /* count by-ref args */
1183 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1184 VARIANTARG* arg = &pDispParams->rgvarg[u];
1185 if (V_ISBYREF(arg)) {
1190 rgVarRefIdx = CoTaskMemAlloc(sizeof(UINT)*cVarRef);
1191 rgVarRef = CoTaskMemAlloc(sizeof(VARIANTARG)*cVarRef);
1192 /* make list of by-ref args */
1193 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1194 VARIANTARG* arg = &pDispParams->rgvarg[u];
1195 if (V_ISBYREF(arg)) {
1196 rgVarRefIdx[cVarRef] = u;
1197 VariantInit(&rgVarRef[cVarRef]);
1198 VariantCopy(&rgVarRef[cVarRef], arg);
1204 /* [out] args still can't be null,
1205 * but we can point these anywhere in this case,
1206 * since they won't be written to when cVarRef is 0 */
1207 rgVarRefIdx = puArgErr;
1208 rgVarRef = pVarResult;
1210 TRACE("passed by ref: %d args\n", cVarRef);
1211 hr = IDispatch_RemoteInvoke_Proxy(This,
1224 for (u=0; u<cVarRef; u++) {
1225 unsigned i = rgVarRefIdx[u];
1226 VariantCopy(&pDispParams->rgvarg[i],
1228 VariantClear(&rgVarRef[u]);
1230 CoTaskMemFree(rgVarRef);
1231 CoTaskMemFree(rgVarRefIdx);
1234 if(pExcepInfo == &ExcepInfo)
1236 SysFreeString(pExcepInfo->bstrSource);
1237 SysFreeString(pExcepInfo->bstrDescription);
1238 SysFreeString(pExcepInfo->bstrHelpFile);
1243 HRESULT __RPC_STUB IDispatch_Invoke_Stub(
1245 DISPID dispIdMember,
1249 DISPPARAMS* pDispParams,
1250 VARIANT* pVarResult,
1251 EXCEPINFO* pExcepInfo,
1255 VARIANTARG* rgVarRef)
1258 VARIANTARG *rgvarg, *arg;
1261 /* initialize out parameters, so that they can be marshalled
1262 * in case the real Invoke doesn't initialize them */
1263 VariantInit(pVarResult);
1264 memset(pExcepInfo, 0, sizeof(*pExcepInfo));
1267 /* let the real Invoke operate on a copy of the in parameters,
1268 * so we don't risk losing pointers to allocated memory */
1269 rgvarg = pDispParams->rgvarg;
1270 arg = CoTaskMemAlloc(sizeof(VARIANTARG)*pDispParams->cArgs);
1271 if (!arg) return E_OUTOFMEMORY;
1273 /* init all args so we can call VariantClear on all the args if the copy
1275 for (u = 0; u < pDispParams->cArgs; u++)
1276 VariantInit(&arg[u]);
1278 for (u = 0; u < pDispParams->cArgs; u++) {
1279 hr = VariantCopy(&arg[u], &rgvarg[u]);
1284 if (SUCCEEDED(hr)) {
1285 /* copy ref args to arg array */
1286 for (u=0; u<cVarRef; u++) {
1287 unsigned i = rgVarRefIdx[u];
1288 VariantCopy(&arg[i], &rgVarRef[u]);
1291 pDispParams->rgvarg = arg;
1293 hr = IDispatch_Invoke(This,
1303 /* copy ref args from arg array */
1304 for (u=0; u<cVarRef; u++) {
1305 unsigned i = rgVarRefIdx[u];
1306 VariantCopy(&rgVarRef[u], &arg[i]);
1310 /* clear the duplicate argument list */
1311 for (u=0; u<pDispParams->cArgs; u++)
1312 VariantClear(&arg[u]);
1314 pDispParams->rgvarg = rgvarg;
1322 HRESULT CALLBACK IEnumVARIANT_Next_Proxy(
1326 ULONG* pCeltFetched)
1330 pCeltFetched = &fetched;
1331 return IEnumVARIANT_RemoteNext_Proxy(This,
1337 HRESULT __RPC_STUB IEnumVARIANT_Next_Stub(
1341 ULONG* pCeltFetched)
1345 hr = IEnumVARIANT_Next(This,
1349 if (hr == S_OK) *pCeltFetched = celt;
1353 /* TypeInfo related freers */
1355 static void free_embedded_typedesc(TYPEDESC *tdesc);
1356 static void free_embedded_arraydesc(ARRAYDESC *adesc)
1358 switch(adesc->tdescElem.vt)
1362 free_embedded_typedesc(adesc->tdescElem.u.lptdesc);
1363 CoTaskMemFree(adesc->tdescElem.u.lptdesc);
1366 free_embedded_arraydesc(adesc->tdescElem.u.lpadesc);
1367 CoTaskMemFree(adesc->tdescElem.u.lpadesc);
1372 static void free_embedded_typedesc(TYPEDESC *tdesc)
1378 free_embedded_typedesc(tdesc->u.lptdesc);
1379 CoTaskMemFree(tdesc->u.lptdesc);
1382 free_embedded_arraydesc(tdesc->u.lpadesc);
1383 CoTaskMemFree(tdesc->u.lpadesc);
1388 static void free_embedded_elemdesc(ELEMDESC *edesc)
1390 free_embedded_typedesc(&edesc->tdesc);
1391 if(edesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT)
1392 CoTaskMemFree(edesc->u.paramdesc.pparamdescex);
1397 HRESULT CALLBACK ITypeComp_Bind_Proxy(
1402 ITypeInfo** ppTInfo,
1403 DESCKIND* pDescKind,
1406 FIXME("not implemented\n");
1410 HRESULT __RPC_STUB ITypeComp_Bind_Stub(
1415 ITypeInfo** ppTInfo,
1416 DESCKIND* pDescKind,
1417 LPFUNCDESC* ppFuncDesc,
1418 LPVARDESC* ppVarDesc,
1419 ITypeComp** ppTypeComp,
1420 CLEANLOCALSTORAGE* pDummy)
1422 FIXME("not implemented\n");
1426 HRESULT CALLBACK ITypeComp_BindType_Proxy(
1430 ITypeInfo** ppTInfo,
1431 ITypeComp** ppTComp)
1433 FIXME("not implemented\n");
1437 HRESULT __RPC_STUB ITypeComp_BindType_Stub(
1441 ITypeInfo** ppTInfo)
1443 FIXME("not implemented\n");
1449 HRESULT CALLBACK ITypeInfo_GetTypeAttr_Proxy(
1451 TYPEATTR** ppTypeAttr)
1454 CLEANLOCALSTORAGE stg;
1455 TRACE("(%p, %p)\n", This, ppTypeAttr);
1458 stg.pStorage = NULL;
1459 stg.pInterface = NULL;
1461 return ITypeInfo_RemoteGetTypeAttr_Proxy(This, ppTypeAttr, &stg);
1464 HRESULT __RPC_STUB ITypeInfo_GetTypeAttr_Stub(
1466 LPTYPEATTR* ppTypeAttr,
1467 CLEANLOCALSTORAGE* pDummy)
1470 TRACE("(%p, %p)\n", This, ppTypeAttr);
1472 hr = ITypeInfo_GetTypeAttr(This, ppTypeAttr);
1476 pDummy->flags = CLS_TYPEATTR;
1477 ITypeInfo_AddRef(This);
1478 pDummy->pInterface = (IUnknown*)This;
1479 pDummy->pStorage = ppTypeAttr;
1483 HRESULT CALLBACK ITypeInfo_GetFuncDesc_Proxy(
1486 FUNCDESC** ppFuncDesc)
1488 CLEANLOCALSTORAGE stg;
1489 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1492 stg.pStorage = NULL;
1493 stg.pInterface = NULL;
1495 return ITypeInfo_RemoteGetFuncDesc_Proxy(This, index, ppFuncDesc, &stg);
1498 HRESULT __RPC_STUB ITypeInfo_GetFuncDesc_Stub(
1501 LPFUNCDESC* ppFuncDesc,
1502 CLEANLOCALSTORAGE* pDummy)
1505 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1507 hr = ITypeInfo_GetFuncDesc(This, index, ppFuncDesc);
1511 pDummy->flags = CLS_FUNCDESC;
1512 ITypeInfo_AddRef(This);
1513 pDummy->pInterface = (IUnknown*)This;
1514 pDummy->pStorage = ppFuncDesc;
1518 HRESULT CALLBACK ITypeInfo_GetVarDesc_Proxy(
1521 VARDESC** ppVarDesc)
1523 CLEANLOCALSTORAGE stg;
1524 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1527 stg.pStorage = NULL;
1528 stg.pInterface = NULL;
1530 return ITypeInfo_RemoteGetVarDesc_Proxy(This, index, ppVarDesc, &stg);
1533 HRESULT __RPC_STUB ITypeInfo_GetVarDesc_Stub(
1536 LPVARDESC* ppVarDesc,
1537 CLEANLOCALSTORAGE* pDummy)
1540 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1542 hr = ITypeInfo_GetVarDesc(This, index, ppVarDesc);
1546 pDummy->flags = CLS_VARDESC;
1547 ITypeInfo_AddRef(This);
1548 pDummy->pInterface = (IUnknown*)This;
1549 pDummy->pStorage = ppVarDesc;
1553 HRESULT CALLBACK ITypeInfo_GetNames_Proxy(
1560 FIXME("not implemented\n");
1564 HRESULT __RPC_STUB ITypeInfo_GetNames_Stub(
1571 FIXME("not implemented\n");
1575 HRESULT CALLBACK ITypeInfo_GetIDsOfNames_Proxy(
1577 LPOLESTR* rgszNames,
1581 FIXME("not implemented\n");
1585 HRESULT __RPC_STUB ITypeInfo_GetIDsOfNames_Stub(
1588 FIXME("not implemented\n");
1592 HRESULT CALLBACK ITypeInfo_Invoke_Proxy(
1597 DISPPARAMS* pDispParams,
1598 VARIANT* pVarResult,
1599 EXCEPINFO* pExcepInfo,
1602 FIXME("not implemented\n");
1606 HRESULT __RPC_STUB ITypeInfo_Invoke_Stub(
1609 FIXME("not implemented\n");
1613 HRESULT CALLBACK ITypeInfo_GetDocumentation_Proxy(
1617 BSTR* pBstrDocString,
1618 DWORD* pdwHelpContext,
1619 BSTR* pBstrHelpFile)
1622 BSTR name, doc_string, help_file;
1624 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1626 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1627 hr = ITypeInfo_RemoteGetDocumentation_Proxy(This, memid, 0, &name, &doc_string, &help_context, &help_file);
1630 if(pBstrName) *pBstrName = name;
1631 else SysFreeString(name);
1633 if(pBstrDocString) *pBstrDocString = doc_string;
1634 else SysFreeString(doc_string);
1636 if(pBstrHelpFile) *pBstrHelpFile = help_file;
1637 else SysFreeString(help_file);
1639 if(pdwHelpContext) *pdwHelpContext = help_context;
1644 HRESULT __RPC_STUB ITypeInfo_GetDocumentation_Stub(
1649 BSTR* pBstrDocString,
1650 DWORD* pdwHelpContext,
1651 BSTR* pBstrHelpFile)
1653 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This, memid, refPtrFlags, pBstrName, pBstrDocString,
1654 pdwHelpContext, pBstrHelpFile);
1655 return ITypeInfo_GetDocumentation(This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1658 HRESULT CALLBACK ITypeInfo_GetDllEntry_Proxy(
1666 FIXME("not implemented\n");
1670 HRESULT __RPC_STUB ITypeInfo_GetDllEntry_Stub(
1679 FIXME("not implemented\n");
1683 HRESULT CALLBACK ITypeInfo_AddressOfMember_Proxy(
1689 FIXME("not implemented\n");
1693 HRESULT __RPC_STUB ITypeInfo_AddressOfMember_Stub(
1696 FIXME("not implemented\n");
1700 HRESULT CALLBACK ITypeInfo_CreateInstance_Proxy(
1702 IUnknown* pUnkOuter,
1706 FIXME("not implemented\n");
1710 HRESULT __RPC_STUB ITypeInfo_CreateInstance_Stub(
1715 FIXME("not implemented\n");
1719 HRESULT CALLBACK ITypeInfo_GetContainingTypeLib_Proxy(
1728 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1730 hr = ITypeInfo_RemoteGetContainingTypeLib_Proxy(This, &pTL, &index);
1739 ITypeLib_Release(pTL);
1744 HRESULT __RPC_STUB ITypeInfo_GetContainingTypeLib_Stub(
1749 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1750 return ITypeInfo_GetContainingTypeLib(This, ppTLib, pIndex);
1753 void CALLBACK ITypeInfo_ReleaseTypeAttr_Proxy(
1755 TYPEATTR* pTypeAttr)
1757 TRACE("(%p, %p)\n", This, pTypeAttr);
1758 free_embedded_typedesc(&pTypeAttr->tdescAlias);
1759 CoTaskMemFree(pTypeAttr);
1762 HRESULT __RPC_STUB ITypeInfo_ReleaseTypeAttr_Stub(
1765 TRACE("nothing to do\n");
1769 void CALLBACK ITypeInfo_ReleaseFuncDesc_Proxy(
1771 FUNCDESC* pFuncDesc)
1774 TRACE("(%p, %p)\n", This, pFuncDesc);
1776 for(param = 0; param < pFuncDesc->cParams; param++)
1777 free_embedded_elemdesc(pFuncDesc->lprgelemdescParam + param);
1779 CoTaskMemFree(pFuncDesc->lprgelemdescParam);
1781 free_embedded_elemdesc(&pFuncDesc->elemdescFunc);
1783 if(pFuncDesc->cScodes != 0 && pFuncDesc->cScodes != -1)
1784 CoTaskMemFree(pFuncDesc->lprgscode);
1786 CoTaskMemFree(pFuncDesc);
1789 HRESULT __RPC_STUB ITypeInfo_ReleaseFuncDesc_Stub(
1792 TRACE("nothing to do\n");
1796 void CALLBACK ITypeInfo_ReleaseVarDesc_Proxy(
1800 TRACE("(%p, %p)\n", This, pVarDesc);
1802 CoTaskMemFree(pVarDesc->lpstrSchema);
1804 if(pVarDesc->varkind == VAR_CONST)
1805 CoTaskMemFree(pVarDesc->u.lpvarValue);
1807 free_embedded_elemdesc(&pVarDesc->elemdescVar);
1808 CoTaskMemFree(pVarDesc);
1811 HRESULT __RPC_STUB ITypeInfo_ReleaseVarDesc_Stub(
1814 TRACE("nothing to do\n");
1821 HRESULT CALLBACK ITypeInfo2_GetDocumentation2_Proxy(
1825 BSTR* pbstrHelpString,
1826 DWORD* pdwHelpStringContext,
1827 BSTR* pbstrHelpStringDll)
1829 FIXME("not implemented\n");
1833 HRESULT __RPC_STUB ITypeInfo2_GetDocumentation2_Stub(
1838 BSTR* pbstrHelpString,
1839 DWORD* pdwHelpStringContext,
1840 BSTR* pbstrHelpStringDll)
1842 FIXME("not implemented\n");
1848 UINT CALLBACK ITypeLib_GetTypeInfoCount_Proxy(
1852 TRACE("(%p)\n", This);
1854 ITypeLib_RemoteGetTypeInfoCount_Proxy(This, &count);
1859 HRESULT __RPC_STUB ITypeLib_GetTypeInfoCount_Stub(
1863 TRACE("(%p, %p)\n", This, pcTInfo);
1864 *pcTInfo = ITypeLib_GetTypeInfoCount(This);
1868 HRESULT CALLBACK ITypeLib_GetLibAttr_Proxy(
1870 TLIBATTR** ppTLibAttr)
1872 CLEANLOCALSTORAGE stg;
1873 TRACE("(%p, %p)\n", This, ppTLibAttr);
1876 stg.pStorage = NULL;
1877 stg.pInterface = NULL;
1879 return ITypeLib_RemoteGetLibAttr_Proxy(This, ppTLibAttr, &stg);
1882 HRESULT __RPC_STUB ITypeLib_GetLibAttr_Stub(
1884 LPTLIBATTR* ppTLibAttr,
1885 CLEANLOCALSTORAGE* pDummy)
1888 TRACE("(%p, %p)\n", This, ppTLibAttr);
1890 hr = ITypeLib_GetLibAttr(This, ppTLibAttr);
1894 pDummy->flags = CLS_LIBATTR;
1895 ITypeLib_AddRef(This);
1896 pDummy->pInterface = (IUnknown*)This;
1897 pDummy->pStorage = ppTLibAttr;
1901 HRESULT CALLBACK ITypeLib_GetDocumentation_Proxy(
1905 BSTR* pBstrDocString,
1906 DWORD* pdwHelpContext,
1907 BSTR* pBstrHelpFile)
1909 FIXME("not implemented\n");
1913 HRESULT __RPC_STUB ITypeLib_GetDocumentation_Stub(
1918 BSTR* pBstrDocString,
1919 DWORD* pdwHelpContext,
1920 BSTR* pBstrHelpFile)
1922 FIXME("not implemented\n");
1926 HRESULT CALLBACK ITypeLib_IsName_Proxy(
1932 FIXME("not implemented\n");
1936 HRESULT __RPC_STUB ITypeLib_IsName_Stub(
1943 FIXME("not implemented\n");
1947 HRESULT CALLBACK ITypeLib_FindName_Proxy(
1951 ITypeInfo** ppTInfo,
1955 FIXME("not implemented\n");
1959 HRESULT __RPC_STUB ITypeLib_FindName_Stub(
1963 ITypeInfo** ppTInfo,
1968 FIXME("not implemented\n");
1972 void CALLBACK ITypeLib_ReleaseTLibAttr_Proxy(
1974 TLIBATTR* pTLibAttr)
1976 TRACE("(%p, %p)\n", This, pTLibAttr);
1977 CoTaskMemFree(pTLibAttr);
1980 HRESULT __RPC_STUB ITypeLib_ReleaseTLibAttr_Stub(
1983 TRACE("nothing to do\n");
1990 HRESULT CALLBACK ITypeLib2_GetLibStatistics_Proxy(
1992 ULONG* pcUniqueNames,
1993 ULONG* pcchUniqueNames)
1995 FIXME("not implemented\n");
1999 HRESULT __RPC_STUB ITypeLib2_GetLibStatistics_Stub(
2001 ULONG* pcUniqueNames,
2002 ULONG* pcchUniqueNames)
2004 FIXME("not implemented\n");
2008 HRESULT CALLBACK ITypeLib2_GetDocumentation2_Proxy(
2012 BSTR* pbstrHelpString,
2013 DWORD* pdwHelpStringContext,
2014 BSTR* pbstrHelpStringDll)
2016 FIXME("not implemented\n");
2020 HRESULT __RPC_STUB ITypeLib2_GetDocumentation2_Stub(
2025 BSTR* pbstrHelpString,
2026 DWORD* pdwHelpStringContext,
2027 BSTR* pbstrHelpStringDll)
2029 FIXME("not implemented\n");
2033 HRESULT CALLBACK IPropertyBag_Read_Proxy(
2035 LPCOLESTR pszPropName,
2037 IErrorLog *pErrorLog)
2039 IUnknown *pUnk = NULL;
2040 TRACE("(%p, %s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
2045 if(V_VT(pVar) & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2047 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2054 pUnk = (IUnknown*)V_DISPATCH(pVar);
2057 pUnk = V_UNKNOWN(pVar);
2060 FIXME("Safearray support not yet implemented.\n");
2063 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar));
2067 return IPropertyBag_RemoteRead_Proxy(This, pszPropName, pVar, pErrorLog,
2071 HRESULT __RPC_STUB IPropertyBag_Read_Stub(
2073 LPCOLESTR pszPropName,
2075 IErrorLog *pErrorLog,
2079 static const WCHAR emptyWstr[1] = {0};
2082 TRACE("(%p, %s, %p, %p, %x, %p)\n", This, debugstr_w(pszPropName), pVar,
2083 pErrorLog, varType, pUnkObj);
2085 if(varType & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2087 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2091 V_VT(pVar) = varType;
2095 hr = IUnknown_QueryInterface(pUnkObj, &IID_IDispatch, (LPVOID*)&disp);
2098 IUnknown_Release(pUnkObj);
2099 V_DISPATCH(pVar) = disp;
2102 V_UNKNOWN(pVar) = pUnkObj;
2105 V_BSTR(pVar) = SysAllocString(emptyWstr);
2108 FIXME("Safearray support not yet implemented.\n");
2113 hr = IPropertyBag_Read(This, pszPropName, pVar, pErrorLog);
2120 /* call_as/local stubs for ocidl.idl */
2122 HRESULT CALLBACK IClassFactory2_CreateInstanceLic_Proxy(
2123 IClassFactory2* This,
2124 IUnknown *pUnkOuter,
2125 IUnknown *pUnkReserved,
2130 FIXME("not implemented\n");
2134 HRESULT __RPC_STUB IClassFactory2_CreateInstanceLic_Stub(
2135 IClassFactory2* This,
2140 FIXME("not implemented\n");
2144 HRESULT CALLBACK IEnumConnections_Next_Proxy(
2145 IEnumConnections* This,
2150 FIXME("not implemented\n");
2154 HRESULT __RPC_STUB IEnumConnections_Next_Stub(
2155 IEnumConnections* This,
2160 FIXME("not implemented\n");
2164 HRESULT CALLBACK IEnumConnectionPoints_Next_Proxy(
2165 IEnumConnectionPoints* This,
2167 LPCONNECTIONPOINT *ppCP,
2170 FIXME("not implemented\n");
2174 HRESULT __RPC_STUB IEnumConnectionPoints_Next_Stub(
2175 IEnumConnectionPoints* This,
2177 LPCONNECTIONPOINT *ppCP,
2180 FIXME("not implemented\n");
2184 HRESULT CALLBACK IPersistMemory_Load_Proxy(
2185 IPersistMemory* This,
2189 FIXME("not implemented\n");
2193 HRESULT __RPC_STUB IPersistMemory_Load_Stub(
2194 IPersistMemory* This,
2198 FIXME("not implemented\n");
2202 HRESULT CALLBACK IPersistMemory_Save_Proxy(
2203 IPersistMemory* This,
2208 FIXME("not implemented\n");
2212 HRESULT __RPC_STUB IPersistMemory_Save_Stub(
2213 IPersistMemory* This,
2218 FIXME("not implemented\n");
2222 void CALLBACK IAdviseSinkEx_OnViewStatusChange_Proxy(
2223 IAdviseSinkEx* This,
2226 FIXME("not implemented\n");
2229 HRESULT __RPC_STUB IAdviseSinkEx_OnViewStatusChange_Stub(
2230 IAdviseSinkEx* This,
2233 FIXME("not implemented\n");
2237 HRESULT CALLBACK IEnumOleUndoUnits_Next_Proxy(
2238 IEnumOleUndoUnits* This,
2240 IOleUndoUnit **rgElt,
2241 ULONG *pcEltFetched)
2243 FIXME("not implemented\n");
2247 HRESULT __RPC_STUB IEnumOleUndoUnits_Next_Stub(
2248 IEnumOleUndoUnits* This,
2250 IOleUndoUnit **rgElt,
2251 ULONG *pcEltFetched)
2253 FIXME("not implemented\n");
2257 HRESULT CALLBACK IQuickActivate_QuickActivate_Proxy(
2258 IQuickActivate* This,
2259 QACONTAINER *pQaContainer,
2260 QACONTROL *pQaControl)
2262 FIXME("not implemented\n");
2266 HRESULT __RPC_STUB IQuickActivate_QuickActivate_Stub(
2267 IQuickActivate* This,
2268 QACONTAINER *pQaContainer,
2269 QACONTROL *pQaControl)
2271 FIXME("not implemented\n");