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);
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)
556 if (V_VT(pvar) != header->vt)
559 V_BYREF(pvar) = CoTaskMemAlloc(type_size);
561 else if (!V_BYREF(pvar))
562 V_BYREF(pvar) = CoTaskMemAlloc(type_size);
563 memcpy(V_BYREF(pvar), Pos, type_size);
564 if((header->vt & VT_TYPEMASK) != VT_VARIANT)
572 if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
573 memcpy(pvar, Pos, type_size);
575 memcpy(&pvar->n1.n2.n3, Pos, type_size);
579 pvar->n1.n2.vt = header->vt;
580 pvar->n1.n2.wReserved1 = header->wReserved1;
581 pvar->n1.n2.wReserved2 = header->wReserved2;
582 pvar->n1.n2.wReserved3 = header->wReserved3;
584 if(header->vt & VT_ARRAY)
586 if(header->vt & VT_BYREF)
587 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, V_ARRAYREF(pvar));
589 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, &V_ARRAY(pvar));
597 Pos = BSTR_UserUnmarshal(pFlags, Pos, &V_BSTR(pvar));
599 case VT_BSTR | VT_BYREF:
600 *V_BSTRREF(pvar) = NULL;
601 Pos = BSTR_UserUnmarshal(pFlags, Pos, V_BSTRREF(pvar));
603 case VT_VARIANT | VT_BYREF:
604 Pos = VARIANT_UserUnmarshal(pFlags, Pos, V_VARIANTREF(pvar));
607 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
608 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, &V_UNKNOWN(pvar));
610 case VT_UNKNOWN | VT_BYREF:
611 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
612 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, V_UNKNOWNREF(pvar));
615 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
616 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)&V_DISPATCH(pvar));
618 case VT_DISPATCH | VT_BYREF:
619 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
620 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)V_DISPATCHREF(pvar));
623 FIXME("handle BRECORD by val\n");
625 case VT_RECORD | VT_BYREF:
626 FIXME("handle BRECORD by ref\n");
633 void WINAPI VARIANT_UserFree(ULONG *pFlags, VARIANT *pvar)
635 VARTYPE vt = V_VT(pvar);
638 TRACE("(%x,%p)\n", *pFlags, pvar);
639 TRACE("vt=%04x\n", V_VT(pvar));
641 if (vt & VT_BYREF) ref = pvar->n1.n2.n3.byref;
649 LPSAFEARRAY_UserFree(pFlags, V_ARRAYREF(pvar));
651 LPSAFEARRAY_UserFree(pFlags, &V_ARRAY(pvar));
657 case VT_BSTR | VT_BYREF:
658 BSTR_UserFree(pFlags, V_BSTRREF(pvar));
660 case VT_VARIANT | VT_BYREF:
661 VARIANT_UserFree(pFlags, V_VARIANTREF(pvar));
663 case VT_RECORD | VT_BYREF:
664 FIXME("handle BRECORD by ref\n");
666 case VT_UNKNOWN | VT_BYREF:
667 case VT_DISPATCH | VT_BYREF:
668 IUnknown_Release(*V_UNKNOWNREF(pvar));
678 /* Get the number of cells in a SafeArray */
679 static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa)
681 const SAFEARRAYBOUND* psab = psa->rgsabound;
682 USHORT cCount = psa->cDims;
683 ULONG ulNumCells = 1;
687 /* This is a valid bordercase. See testcases. -Marcus */
688 if (!psab->cElements)
690 ulNumCells *= psab->cElements;
696 static inline SF_TYPE SAFEARRAY_GetUnionType(SAFEARRAY *psa)
701 hr = SafeArrayGetVartype(psa, &vt);
704 if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT;
706 switch(psa->cbElements)
708 case 1: vt = VT_I1; break;
709 case 2: vt = VT_I2; break;
710 case 4: vt = VT_I4; break;
711 case 8: vt = VT_I8; break;
713 RpcRaiseException(hr);
717 if (psa->fFeatures & FADF_HAVEIID)
723 case VT_UI1: return SF_I1;
726 case VT_UI2: return SF_I2;
731 case VT_R4: return SF_I4;
736 case VT_UI8: return SF_I8;
738 case VT_UINT_PTR: return (sizeof(UINT_PTR) == 4 ? SF_I4 : SF_I8);
739 case VT_BSTR: return SF_BSTR;
740 case VT_DISPATCH: return SF_DISPATCH;
741 case VT_VARIANT: return SF_VARIANT;
742 case VT_UNKNOWN: return SF_UNKNOWN;
743 /* Note: Return a non-zero size to indicate vt is valid. The actual size
744 * of a UDT is taken from the result of IRecordInfo_GetSize().
746 case VT_RECORD: return SF_RECORD;
747 default: return SF_ERROR;
751 ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY *ppsa)
753 ULONG size = StartingSize;
755 TRACE("("); dump_user_flags(pFlags); TRACE(", %d, %p\n", StartingSize, *ppsa);
757 ALIGN_LENGTH(size, 3);
758 size += sizeof(ULONG_PTR);
761 SAFEARRAY *psa = *ppsa;
762 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
766 size += sizeof(ULONG);
767 size += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
769 sftype = SAFEARRAY_GetUnionType(psa);
770 size += sizeof(ULONG);
772 size += sizeof(ULONG);
773 size += sizeof(ULONG_PTR);
774 if (sftype == SF_HAVEIID)
777 size += sizeof(psa->rgsabound[0]) * psa->cDims;
779 size += sizeof(ULONG);
787 for (lpBstr = (BSTR*)psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
788 size = BSTR_UserSize(pFlags, size, lpBstr);
795 FIXME("size interfaces\n");
801 for (lpVariant = (VARIANT*)psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
802 size = VARIANT_UserSize(pFlags, size, lpVariant);
808 IRecordInfo* pRecInfo = NULL;
810 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
812 RpcRaiseException(hr);
816 FIXME("size record info %p\n", pRecInfo);
818 IRecordInfo_Release(pRecInfo);
823 ALIGN_LENGTH(size, 7);
828 size += ulCellCount * psa->cbElements;
839 unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
843 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
845 ALIGN_POINTER(Buffer, 3);
846 *(ULONG_PTR *)Buffer = *ppsa ? TRUE : FALSE;
847 Buffer += sizeof(ULONG_PTR);
851 SAFEARRAY *psa = *ppsa;
852 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
853 wireSAFEARRAY wiresa;
857 *(ULONG *)Buffer = psa->cDims;
858 Buffer += sizeof(ULONG);
859 wiresa = (wireSAFEARRAY)Buffer;
860 wiresa->cDims = psa->cDims;
861 wiresa->fFeatures = psa->fFeatures;
862 wiresa->cbElements = psa->cbElements;
864 hr = SafeArrayGetVartype(psa, &vt);
865 if (FAILED(hr)) vt = 0;
867 wiresa->cLocks = (USHORT)psa->cLocks | (vt << 16);
869 Buffer += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
871 sftype = SAFEARRAY_GetUnionType(psa);
872 *(ULONG *)Buffer = sftype;
873 Buffer += sizeof(ULONG);
875 *(ULONG *)Buffer = ulCellCount;
876 Buffer += sizeof(ULONG);
877 *(ULONG_PTR *)Buffer = (ULONG_PTR)psa->pvData;
878 Buffer += sizeof(ULONG_PTR);
879 if (sftype == SF_HAVEIID)
881 SafeArrayGetIID(psa, &guid);
882 memcpy(Buffer, &guid, sizeof(guid));
883 Buffer += sizeof(guid);
886 memcpy(Buffer, psa->rgsabound, sizeof(psa->rgsabound[0]) * psa->cDims);
887 Buffer += sizeof(psa->rgsabound[0]) * psa->cDims;
889 *(ULONG *)Buffer = ulCellCount;
890 Buffer += sizeof(ULONG);
900 for (lpBstr = (BSTR*)psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
901 Buffer = BSTR_UserMarshal(pFlags, Buffer, lpBstr);
908 FIXME("marshal interfaces\n");
914 for (lpVariant = (VARIANT*)psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
915 Buffer = VARIANT_UserMarshal(pFlags, Buffer, lpVariant);
921 IRecordInfo* pRecInfo = NULL;
923 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
925 RpcRaiseException(hr);
929 FIXME("write record info %p\n", pRecInfo);
931 IRecordInfo_Release(pRecInfo);
937 ALIGN_POINTER(Buffer, 7);
942 /* Just copy the data over */
943 memcpy(Buffer, psa->pvData, ulCellCount * psa->cbElements);
944 Buffer += ulCellCount * psa->cbElements;
955 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
956 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
957 FADF_VARIANT | FADF_CREATEVECTOR)
959 unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
962 wireSAFEARRAY wiresa;
969 SAFEARRAYBOUND *wiresab;
971 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
973 ALIGN_POINTER(Buffer, 3);
974 ptr = *(ULONG_PTR *)Buffer;
975 Buffer += sizeof(ULONG_PTR);
981 TRACE("NULL safe array unmarshaled\n");
986 cDims = *(ULONG *)Buffer;
987 Buffer += sizeof(ULONG);
989 wiresa = (wireSAFEARRAY)Buffer;
990 Buffer += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
992 if (cDims != wiresa->cDims)
993 RpcRaiseException(RPC_S_INVALID_BOUND);
995 /* FIXME: there should be a limit on how large cDims can be */
997 vt = HIWORD(wiresa->cLocks);
999 sftype = *(ULONG *)Buffer;
1000 Buffer += sizeof(ULONG);
1002 cell_count = *(ULONG *)Buffer;
1003 Buffer += sizeof(ULONG);
1004 ptr = *(ULONG_PTR *)Buffer;
1005 Buffer += sizeof(ULONG_PTR);
1006 if (sftype == SF_HAVEIID)
1008 memcpy(&guid, Buffer, sizeof(guid));
1009 Buffer += sizeof(guid);
1012 wiresab = (SAFEARRAYBOUND *)Buffer;
1013 Buffer += sizeof(wiresab[0]) * wiresa->cDims;
1016 *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
1019 SafeArrayAllocDescriptor(wiresa->cDims, ppsa);
1021 memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
1024 RpcRaiseException(E_OUTOFMEMORY);
1026 /* be careful about which flags we set since they could be a security
1028 (*ppsa)->fFeatures &= FADF_AUTOSETFLAGS;
1029 (*ppsa)->fFeatures |= (wiresa->fFeatures & ~(FADF_AUTOSETFLAGS));
1030 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1031 (*ppsa)->cbElements = wiresa->cbElements;
1032 (*ppsa)->cLocks = LOWORD(wiresa->cLocks);
1034 /* SafeArrayCreateEx allocates the data for us, but
1035 * SafeArrayAllocDescriptor doesn't */
1038 hr = SafeArrayAllocData(*ppsa);
1040 RpcRaiseException(hr);
1043 if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
1044 RpcRaiseException(RPC_S_INVALID_BOUND);
1045 Buffer += sizeof(ULONG);
1055 for (lpBstr = (BSTR*)(*ppsa)->pvData; cell_count; cell_count--, lpBstr++)
1056 Buffer = BSTR_UserUnmarshal(pFlags, Buffer, lpBstr);
1063 FIXME("marshal interfaces\n");
1069 for (lpVariant = (VARIANT*)(*ppsa)->pvData; cell_count; cell_count--, lpVariant++)
1070 Buffer = VARIANT_UserUnmarshal(pFlags, Buffer, lpVariant);
1076 FIXME("set record info\n");
1082 ALIGN_POINTER(Buffer, 7);
1087 /* Just copy the data over */
1088 memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
1089 Buffer += cell_count * (*ppsa)->cbElements;
1096 TRACE("safe array unmarshaled: %p\n", *ppsa);
1101 void WINAPI LPSAFEARRAY_UserFree(ULONG *pFlags, LPSAFEARRAY *ppsa)
1103 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *ppsa);
1105 SafeArrayDestroy(*ppsa);
1109 ULONG WINAPI HFONT_UserSize(ULONG *pFlags, ULONG Start, HFONT *phfont)
1115 unsigned char * WINAPI HFONT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1121 unsigned char * WINAPI HFONT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1127 void WINAPI HFONT_UserFree(ULONG *pFlags, HFONT *phfont)
1135 /* exactly how Invoke is marshalled is not very clear to me yet,
1136 * but the way I've done it seems to work for me */
1138 HRESULT CALLBACK IDispatch_Invoke_Proxy(
1140 DISPID dispIdMember,
1144 DISPPARAMS* pDispParams,
1145 VARIANT* pVarResult,
1146 EXCEPINFO* pExcepInfo,
1151 UINT* rgVarRefIdx = NULL;
1152 VARIANTARG* rgVarRef = NULL;
1155 EXCEPINFO ExcepInfo;
1157 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This,
1158 dispIdMember, debugstr_guid(riid),
1159 lcid, wFlags, pDispParams, pVarResult,
1160 pExcepInfo, puArgErr);
1162 /* [out] args can't be null, use dummy vars if needed */
1163 if (!pVarResult) pVarResult = &VarResult;
1164 if (!puArgErr) puArgErr = &uArgErr;
1165 if (!pExcepInfo) pExcepInfo = &ExcepInfo;
1167 /* count by-ref args */
1168 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1169 VARIANTARG* arg = &pDispParams->rgvarg[u];
1170 if (V_ISBYREF(arg)) {
1175 rgVarRefIdx = CoTaskMemAlloc(sizeof(UINT)*cVarRef);
1176 rgVarRef = CoTaskMemAlloc(sizeof(VARIANTARG)*cVarRef);
1177 /* make list of by-ref args */
1178 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1179 VARIANTARG* arg = &pDispParams->rgvarg[u];
1180 if (V_ISBYREF(arg)) {
1181 rgVarRefIdx[cVarRef] = u;
1182 VariantInit(&rgVarRef[cVarRef]);
1187 /* [out] args still can't be null,
1188 * but we can point these anywhere in this case,
1189 * since they won't be written to when cVarRef is 0 */
1190 rgVarRefIdx = puArgErr;
1191 rgVarRef = pVarResult;
1193 TRACE("passed by ref: %d args\n", cVarRef);
1194 hr = IDispatch_RemoteInvoke_Proxy(This,
1207 for (u=0; u<cVarRef; u++) {
1208 unsigned i = rgVarRefIdx[u];
1209 VariantCopy(&pDispParams->rgvarg[i],
1211 VariantClear(&rgVarRef[u]);
1213 CoTaskMemFree(rgVarRef);
1214 CoTaskMemFree(rgVarRefIdx);
1217 if(pExcepInfo == &ExcepInfo)
1219 SysFreeString(pExcepInfo->bstrSource);
1220 SysFreeString(pExcepInfo->bstrDescription);
1221 SysFreeString(pExcepInfo->bstrHelpFile);
1226 HRESULT __RPC_STUB IDispatch_Invoke_Stub(
1228 DISPID dispIdMember,
1232 DISPPARAMS* pDispParams,
1233 VARIANT* pVarResult,
1234 EXCEPINFO* pExcepInfo,
1238 VARIANTARG* rgVarRef)
1241 VARIANTARG *rgvarg, *arg;
1244 /* initialize out parameters, so that they can be marshalled
1245 * in case the real Invoke doesn't initialize them */
1246 VariantInit(pVarResult);
1247 memset(pExcepInfo, 0, sizeof(*pExcepInfo));
1250 /* let the real Invoke operate on a copy of the in parameters,
1251 * so we don't risk losing pointers to allocated memory */
1252 rgvarg = pDispParams->rgvarg;
1253 arg = CoTaskMemAlloc(sizeof(VARIANTARG)*pDispParams->cArgs);
1254 if (!arg) return E_OUTOFMEMORY;
1256 /* init all args so we can call VariantClear on all the args if the copy
1258 for (u = 0; u < pDispParams->cArgs; u++)
1259 VariantInit(&arg[u]);
1261 for (u = 0; u < pDispParams->cArgs; u++) {
1262 hr = VariantCopy(&arg[u], &rgvarg[u]);
1267 if (SUCCEEDED(hr)) {
1268 pDispParams->rgvarg = arg;
1270 hr = IDispatch_Invoke(This,
1280 /* copy ref args to out list */
1281 for (u=0; u<cVarRef; u++) {
1282 unsigned i = rgVarRefIdx[u];
1283 VariantInit(&rgVarRef[u]);
1284 VariantCopy(&rgVarRef[u], &arg[i]);
1285 /* clear original if equal, to avoid double-free */
1286 if (V_BYREF(&rgVarRef[u]) == V_BYREF(&rgvarg[i]))
1287 VariantClear(&rgvarg[i]);
1291 /* clear the duplicate argument list */
1292 for (u=0; u<pDispParams->cArgs; u++)
1293 VariantClear(&arg[u]);
1295 pDispParams->rgvarg = rgvarg;
1303 HRESULT CALLBACK IEnumVARIANT_Next_Proxy(
1307 ULONG* pCeltFetched)
1311 pCeltFetched = &fetched;
1312 return IEnumVARIANT_RemoteNext_Proxy(This,
1318 HRESULT __RPC_STUB IEnumVARIANT_Next_Stub(
1322 ULONG* pCeltFetched)
1326 hr = IEnumVARIANT_Next(This,
1330 if (hr == S_OK) *pCeltFetched = celt;
1334 /* TypeInfo related freers */
1336 static void free_embedded_typedesc(TYPEDESC *tdesc);
1337 static void free_embedded_arraydesc(ARRAYDESC *adesc)
1339 switch(adesc->tdescElem.vt)
1343 free_embedded_typedesc(adesc->tdescElem.u.lptdesc);
1344 CoTaskMemFree(adesc->tdescElem.u.lptdesc);
1347 free_embedded_arraydesc(adesc->tdescElem.u.lpadesc);
1348 CoTaskMemFree(adesc->tdescElem.u.lpadesc);
1353 static void free_embedded_typedesc(TYPEDESC *tdesc)
1359 free_embedded_typedesc(tdesc->u.lptdesc);
1360 CoTaskMemFree(tdesc->u.lptdesc);
1363 free_embedded_arraydesc(tdesc->u.lpadesc);
1364 CoTaskMemFree(tdesc->u.lpadesc);
1369 static void free_embedded_elemdesc(ELEMDESC *edesc)
1371 free_embedded_typedesc(&edesc->tdesc);
1372 if(edesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT)
1373 CoTaskMemFree(edesc->u.paramdesc.pparamdescex);
1378 HRESULT CALLBACK ITypeComp_Bind_Proxy(
1383 ITypeInfo** ppTInfo,
1384 DESCKIND* pDescKind,
1387 FIXME("not implemented\n");
1391 HRESULT __RPC_STUB ITypeComp_Bind_Stub(
1396 ITypeInfo** ppTInfo,
1397 DESCKIND* pDescKind,
1398 LPFUNCDESC* ppFuncDesc,
1399 LPVARDESC* ppVarDesc,
1400 ITypeComp** ppTypeComp,
1401 CLEANLOCALSTORAGE* pDummy)
1403 FIXME("not implemented\n");
1407 HRESULT CALLBACK ITypeComp_BindType_Proxy(
1411 ITypeInfo** ppTInfo,
1412 ITypeComp** ppTComp)
1414 FIXME("not implemented\n");
1418 HRESULT __RPC_STUB ITypeComp_BindType_Stub(
1422 ITypeInfo** ppTInfo)
1424 FIXME("not implemented\n");
1430 HRESULT CALLBACK ITypeInfo_GetTypeAttr_Proxy(
1432 TYPEATTR** ppTypeAttr)
1435 CLEANLOCALSTORAGE stg;
1436 TRACE("(%p, %p)\n", This, ppTypeAttr);
1439 stg.pStorage = NULL;
1440 stg.pInterface = NULL;
1442 return ITypeInfo_RemoteGetTypeAttr_Proxy(This, ppTypeAttr, &stg);
1445 HRESULT __RPC_STUB ITypeInfo_GetTypeAttr_Stub(
1447 LPTYPEATTR* ppTypeAttr,
1448 CLEANLOCALSTORAGE* pDummy)
1451 TRACE("(%p, %p)\n", This, ppTypeAttr);
1453 hr = ITypeInfo_GetTypeAttr(This, ppTypeAttr);
1457 pDummy->flags = CLS_TYPEATTR;
1458 ITypeInfo_AddRef(This);
1459 pDummy->pInterface = (IUnknown*)This;
1460 pDummy->pStorage = ppTypeAttr;
1464 HRESULT CALLBACK ITypeInfo_GetFuncDesc_Proxy(
1467 FUNCDESC** ppFuncDesc)
1469 CLEANLOCALSTORAGE stg;
1470 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1473 stg.pStorage = NULL;
1474 stg.pInterface = NULL;
1476 return ITypeInfo_RemoteGetFuncDesc_Proxy(This, index, ppFuncDesc, &stg);
1479 HRESULT __RPC_STUB ITypeInfo_GetFuncDesc_Stub(
1482 LPFUNCDESC* ppFuncDesc,
1483 CLEANLOCALSTORAGE* pDummy)
1486 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1488 hr = ITypeInfo_GetFuncDesc(This, index, ppFuncDesc);
1492 pDummy->flags = CLS_FUNCDESC;
1493 ITypeInfo_AddRef(This);
1494 pDummy->pInterface = (IUnknown*)This;
1495 pDummy->pStorage = ppFuncDesc;
1499 HRESULT CALLBACK ITypeInfo_GetVarDesc_Proxy(
1502 VARDESC** ppVarDesc)
1504 CLEANLOCALSTORAGE stg;
1505 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1508 stg.pStorage = NULL;
1509 stg.pInterface = NULL;
1511 return ITypeInfo_RemoteGetVarDesc_Proxy(This, index, ppVarDesc, &stg);
1514 HRESULT __RPC_STUB ITypeInfo_GetVarDesc_Stub(
1517 LPVARDESC* ppVarDesc,
1518 CLEANLOCALSTORAGE* pDummy)
1521 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1523 hr = ITypeInfo_GetVarDesc(This, index, ppVarDesc);
1527 pDummy->flags = CLS_VARDESC;
1528 ITypeInfo_AddRef(This);
1529 pDummy->pInterface = (IUnknown*)This;
1530 pDummy->pStorage = ppVarDesc;
1534 HRESULT CALLBACK ITypeInfo_GetNames_Proxy(
1541 FIXME("not implemented\n");
1545 HRESULT __RPC_STUB ITypeInfo_GetNames_Stub(
1552 FIXME("not implemented\n");
1556 HRESULT CALLBACK ITypeInfo_GetIDsOfNames_Proxy(
1558 LPOLESTR* rgszNames,
1562 FIXME("not implemented\n");
1566 HRESULT __RPC_STUB ITypeInfo_GetIDsOfNames_Stub(
1569 FIXME("not implemented\n");
1573 HRESULT CALLBACK ITypeInfo_Invoke_Proxy(
1578 DISPPARAMS* pDispParams,
1579 VARIANT* pVarResult,
1580 EXCEPINFO* pExcepInfo,
1583 FIXME("not implemented\n");
1587 HRESULT __RPC_STUB ITypeInfo_Invoke_Stub(
1590 FIXME("not implemented\n");
1594 HRESULT CALLBACK ITypeInfo_GetDocumentation_Proxy(
1598 BSTR* pBstrDocString,
1599 DWORD* pdwHelpContext,
1600 BSTR* pBstrHelpFile)
1603 BSTR name, doc_string, help_file;
1605 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1607 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1608 hr = ITypeInfo_RemoteGetDocumentation_Proxy(This, memid, 0, &name, &doc_string, &help_context, &help_file);
1611 if(pBstrName) *pBstrName = name;
1612 else SysFreeString(name);
1614 if(pBstrDocString) *pBstrDocString = doc_string;
1615 else SysFreeString(doc_string);
1617 if(pBstrHelpFile) *pBstrHelpFile = help_file;
1618 else SysFreeString(help_file);
1620 if(pdwHelpContext) *pdwHelpContext = help_context;
1625 HRESULT __RPC_STUB ITypeInfo_GetDocumentation_Stub(
1630 BSTR* pBstrDocString,
1631 DWORD* pdwHelpContext,
1632 BSTR* pBstrHelpFile)
1634 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This, memid, refPtrFlags, pBstrName, pBstrDocString,
1635 pdwHelpContext, pBstrHelpFile);
1636 return ITypeInfo_GetDocumentation(This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1639 HRESULT CALLBACK ITypeInfo_GetDllEntry_Proxy(
1647 FIXME("not implemented\n");
1651 HRESULT __RPC_STUB ITypeInfo_GetDllEntry_Stub(
1660 FIXME("not implemented\n");
1664 HRESULT CALLBACK ITypeInfo_AddressOfMember_Proxy(
1670 FIXME("not implemented\n");
1674 HRESULT __RPC_STUB ITypeInfo_AddressOfMember_Stub(
1677 FIXME("not implemented\n");
1681 HRESULT CALLBACK ITypeInfo_CreateInstance_Proxy(
1683 IUnknown* pUnkOuter,
1687 FIXME("not implemented\n");
1691 HRESULT __RPC_STUB ITypeInfo_CreateInstance_Stub(
1696 FIXME("not implemented\n");
1700 HRESULT CALLBACK ITypeInfo_GetContainingTypeLib_Proxy(
1709 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1711 hr = ITypeInfo_RemoteGetContainingTypeLib_Proxy(This, &pTL, &index);
1720 ITypeLib_Release(pTL);
1725 HRESULT __RPC_STUB ITypeInfo_GetContainingTypeLib_Stub(
1730 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1731 return ITypeInfo_GetContainingTypeLib(This, ppTLib, pIndex);
1734 void CALLBACK ITypeInfo_ReleaseTypeAttr_Proxy(
1736 TYPEATTR* pTypeAttr)
1738 TRACE("(%p, %p)\n", This, pTypeAttr);
1739 free_embedded_typedesc(&pTypeAttr->tdescAlias);
1740 CoTaskMemFree(pTypeAttr);
1743 HRESULT __RPC_STUB ITypeInfo_ReleaseTypeAttr_Stub(
1746 TRACE("nothing to do\n");
1750 void CALLBACK ITypeInfo_ReleaseFuncDesc_Proxy(
1752 FUNCDESC* pFuncDesc)
1755 TRACE("(%p, %p)\n", This, pFuncDesc);
1757 for(param = 0; param < pFuncDesc->cParams; param++)
1758 free_embedded_elemdesc(pFuncDesc->lprgelemdescParam + param);
1760 CoTaskMemFree(pFuncDesc->lprgelemdescParam);
1762 free_embedded_elemdesc(&pFuncDesc->elemdescFunc);
1764 if(pFuncDesc->cScodes != 0 && pFuncDesc->cScodes != -1)
1765 CoTaskMemFree(pFuncDesc->lprgscode);
1767 CoTaskMemFree(pFuncDesc);
1770 HRESULT __RPC_STUB ITypeInfo_ReleaseFuncDesc_Stub(
1773 TRACE("nothing to do\n");
1777 void CALLBACK ITypeInfo_ReleaseVarDesc_Proxy(
1781 TRACE("(%p, %p)\n", This, pVarDesc);
1783 CoTaskMemFree(pVarDesc->lpstrSchema);
1785 if(pVarDesc->varkind == VAR_CONST)
1786 CoTaskMemFree(pVarDesc->u.lpvarValue);
1788 free_embedded_elemdesc(&pVarDesc->elemdescVar);
1789 CoTaskMemFree(pVarDesc);
1792 HRESULT __RPC_STUB ITypeInfo_ReleaseVarDesc_Stub(
1795 TRACE("nothing to do\n");
1802 HRESULT CALLBACK ITypeInfo2_GetDocumentation2_Proxy(
1806 BSTR* pbstrHelpString,
1807 DWORD* pdwHelpStringContext,
1808 BSTR* pbstrHelpStringDll)
1810 FIXME("not implemented\n");
1814 HRESULT __RPC_STUB ITypeInfo2_GetDocumentation2_Stub(
1819 BSTR* pbstrHelpString,
1820 DWORD* pdwHelpStringContext,
1821 BSTR* pbstrHelpStringDll)
1823 FIXME("not implemented\n");
1829 UINT CALLBACK ITypeLib_GetTypeInfoCount_Proxy(
1833 TRACE("(%p)\n", This);
1835 ITypeLib_RemoteGetTypeInfoCount_Proxy(This, &count);
1840 HRESULT __RPC_STUB ITypeLib_GetTypeInfoCount_Stub(
1844 TRACE("(%p, %p)\n", This, pcTInfo);
1845 *pcTInfo = ITypeLib_GetTypeInfoCount(This);
1849 HRESULT CALLBACK ITypeLib_GetLibAttr_Proxy(
1851 TLIBATTR** ppTLibAttr)
1853 CLEANLOCALSTORAGE stg;
1854 TRACE("(%p, %p)\n", This, ppTLibAttr);
1857 stg.pStorage = NULL;
1858 stg.pInterface = NULL;
1860 return ITypeLib_RemoteGetLibAttr_Proxy(This, ppTLibAttr, &stg);
1863 HRESULT __RPC_STUB ITypeLib_GetLibAttr_Stub(
1865 LPTLIBATTR* ppTLibAttr,
1866 CLEANLOCALSTORAGE* pDummy)
1869 TRACE("(%p, %p)\n", This, ppTLibAttr);
1871 hr = ITypeLib_GetLibAttr(This, ppTLibAttr);
1875 pDummy->flags = CLS_LIBATTR;
1876 ITypeLib_AddRef(This);
1877 pDummy->pInterface = (IUnknown*)This;
1878 pDummy->pStorage = ppTLibAttr;
1882 HRESULT CALLBACK ITypeLib_GetDocumentation_Proxy(
1886 BSTR* pBstrDocString,
1887 DWORD* pdwHelpContext,
1888 BSTR* pBstrHelpFile)
1890 FIXME("not implemented\n");
1894 HRESULT __RPC_STUB ITypeLib_GetDocumentation_Stub(
1899 BSTR* pBstrDocString,
1900 DWORD* pdwHelpContext,
1901 BSTR* pBstrHelpFile)
1903 FIXME("not implemented\n");
1907 HRESULT CALLBACK ITypeLib_IsName_Proxy(
1913 FIXME("not implemented\n");
1917 HRESULT __RPC_STUB ITypeLib_IsName_Stub(
1924 FIXME("not implemented\n");
1928 HRESULT CALLBACK ITypeLib_FindName_Proxy(
1932 ITypeInfo** ppTInfo,
1936 FIXME("not implemented\n");
1940 HRESULT __RPC_STUB ITypeLib_FindName_Stub(
1944 ITypeInfo** ppTInfo,
1949 FIXME("not implemented\n");
1953 void CALLBACK ITypeLib_ReleaseTLibAttr_Proxy(
1955 TLIBATTR* pTLibAttr)
1957 TRACE("(%p, %p)\n", This, pTLibAttr);
1958 CoTaskMemFree(pTLibAttr);
1961 HRESULT __RPC_STUB ITypeLib_ReleaseTLibAttr_Stub(
1964 TRACE("nothing to do\n");
1971 HRESULT CALLBACK ITypeLib2_GetLibStatistics_Proxy(
1973 ULONG* pcUniqueNames,
1974 ULONG* pcchUniqueNames)
1976 FIXME("not implemented\n");
1980 HRESULT __RPC_STUB ITypeLib2_GetLibStatistics_Stub(
1982 ULONG* pcUniqueNames,
1983 ULONG* pcchUniqueNames)
1985 FIXME("not implemented\n");
1989 HRESULT CALLBACK ITypeLib2_GetDocumentation2_Proxy(
1993 BSTR* pbstrHelpString,
1994 DWORD* pdwHelpStringContext,
1995 BSTR* pbstrHelpStringDll)
1997 FIXME("not implemented\n");
2001 HRESULT __RPC_STUB ITypeLib2_GetDocumentation2_Stub(
2006 BSTR* pbstrHelpString,
2007 DWORD* pdwHelpStringContext,
2008 BSTR* pbstrHelpStringDll)
2010 FIXME("not implemented\n");
2014 HRESULT CALLBACK IPropertyBag_Read_Proxy(
2016 LPCOLESTR pszPropName,
2018 IErrorLog *pErrorLog)
2020 IUnknown *pUnk = NULL;
2021 TRACE("(%p, %s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
2026 if(V_VT(pVar) & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2028 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2035 pUnk = (IUnknown*)V_DISPATCH(pVar);
2038 pUnk = V_UNKNOWN(pVar);
2041 FIXME("Safearray support not yet implemented.\n");
2047 return IPropertyBag_RemoteRead_Proxy(This, pszPropName, pVar, pErrorLog,
2051 HRESULT __RPC_STUB IPropertyBag_Read_Stub(
2053 LPCOLESTR pszPropName,
2055 IErrorLog *pErrorLog,
2059 static const WCHAR emptyWstr[1] = {0};
2062 TRACE("(%p, %s, %p, %p, %x, %p)\n", This, debugstr_w(pszPropName), pVar,
2063 pErrorLog, varType, pUnkObj);
2065 if(varType & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2067 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2071 V_VT(pVar) = varType;
2075 hr = IUnknown_QueryInterface(pUnkObj, &IID_IDispatch, (LPVOID*)&disp);
2078 IUnknown_Release(pUnkObj);
2079 V_DISPATCH(pVar) = disp;
2082 V_UNKNOWN(pVar) = pUnkObj;
2085 V_BSTR(pVar) = SysAllocString(emptyWstr);
2088 FIXME("Safearray support not yet implemented.\n");
2093 hr = IPropertyBag_Read(This, pszPropName, pVar, pErrorLog);
2100 /* call_as/local stubs for ocidl.idl */
2102 HRESULT CALLBACK IClassFactory2_CreateInstanceLic_Proxy(
2103 IClassFactory2* This,
2104 IUnknown *pUnkOuter,
2105 IUnknown *pUnkReserved,
2110 FIXME("not implemented\n");
2114 HRESULT __RPC_STUB IClassFactory2_CreateInstanceLic_Stub(
2115 IClassFactory2* This,
2120 FIXME("not implemented\n");
2124 HRESULT CALLBACK IEnumConnections_Next_Proxy(
2125 IEnumConnections* This,
2130 FIXME("not implemented\n");
2134 HRESULT __RPC_STUB IEnumConnections_Next_Stub(
2135 IEnumConnections* This,
2140 FIXME("not implemented\n");
2144 HRESULT CALLBACK IEnumConnectionPoints_Next_Proxy(
2145 IEnumConnectionPoints* This,
2147 LPCONNECTIONPOINT *ppCP,
2150 FIXME("not implemented\n");
2154 HRESULT __RPC_STUB IEnumConnectionPoints_Next_Stub(
2155 IEnumConnectionPoints* This,
2157 LPCONNECTIONPOINT *ppCP,
2160 FIXME("not implemented\n");
2164 HRESULT CALLBACK IPersistMemory_Load_Proxy(
2165 IPersistMemory* This,
2169 FIXME("not implemented\n");
2173 HRESULT __RPC_STUB IPersistMemory_Load_Stub(
2174 IPersistMemory* This,
2178 FIXME("not implemented\n");
2182 HRESULT CALLBACK IPersistMemory_Save_Proxy(
2183 IPersistMemory* This,
2188 FIXME("not implemented\n");
2192 HRESULT __RPC_STUB IPersistMemory_Save_Stub(
2193 IPersistMemory* This,
2198 FIXME("not implemented\n");
2202 void CALLBACK IAdviseSinkEx_OnViewStatusChange_Proxy(
2203 IAdviseSinkEx* This,
2206 FIXME("not implemented\n");
2209 HRESULT __RPC_STUB IAdviseSinkEx_OnViewStatusChange_Stub(
2210 IAdviseSinkEx* This,
2213 FIXME("not implemented\n");
2217 HRESULT CALLBACK IEnumOleUndoUnits_Next_Proxy(
2218 IEnumOleUndoUnits* This,
2220 IOleUndoUnit **rgElt,
2221 ULONG *pcEltFetched)
2223 FIXME("not implemented\n");
2227 HRESULT __RPC_STUB IEnumOleUndoUnits_Next_Stub(
2228 IEnumOleUndoUnits* This,
2230 IOleUndoUnit **rgElt,
2231 ULONG *pcEltFetched)
2233 FIXME("not implemented\n");
2237 HRESULT CALLBACK IQuickActivate_QuickActivate_Proxy(
2238 IQuickActivate* This,
2239 QACONTAINER *pQaContainer,
2240 QACONTROL *pQaControl)
2242 FIXME("not implemented\n");
2246 HRESULT __RPC_STUB IQuickActivate_QuickActivate_Stub(
2247 IQuickActivate* This,
2248 QACONTAINER *pQaContainer,
2249 QACONTROL *pQaControl)
2251 FIXME("not implemented\n");