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
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
44 #define ALIGNED_LENGTH(_Len, _Align) (((_Len)+(_Align))&~(_Align))
45 #define ALIGNED_POINTER(_Ptr, _Align) ((LPVOID)ALIGNED_LENGTH((ULONG_PTR)(_Ptr), _Align))
46 #define ALIGN_LENGTH(_Len, _Align) _Len = ALIGNED_LENGTH(_Len, _Align)
47 #define ALIGN_POINTER(_Ptr, _Align) _Ptr = ALIGNED_POINTER(_Ptr, _Align)
49 static CStdPSFactoryBuffer PSFactoryBuffer;
51 CSTDSTUBBUFFERRELEASE(&PSFactoryBuffer)
53 extern const ExtendedProxyFileInfo oleaut32_oaidl_ProxyFileInfo;
54 extern const ExtendedProxyFileInfo oleaut32_ocidl_ProxyFileInfo;
56 static const ProxyFileInfo *OLEAUT32_ProxyFileList[] = {
57 &oleaut32_oaidl_ProxyFileInfo,
58 &oleaut32_ocidl_ProxyFileInfo,
62 HRESULT OLEAUTPS_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
64 return NdrDllGetClassObject(rclsid, riid, ppv, OLEAUT32_ProxyFileList,
65 &CLSID_PSDispatch, &PSFactoryBuffer);
68 static void dump_user_flags(const ULONG *pFlags)
70 if (HIWORD(*pFlags) == NDR_LOCAL_DATA_REPRESENTATION)
71 TRACE("MAKELONG(NDR_LOCAL_REPRESENTATION, ");
73 TRACE("MAKELONG(0x%04x, ", HIWORD(*pFlags));
74 switch (LOWORD(*pFlags))
76 case MSHCTX_LOCAL: TRACE("MSHCTX_LOCAL)"); break;
77 case MSHCTX_NOSHAREDMEM: TRACE("MSHCTX_NOSHAREDMEM)"); break;
78 case MSHCTX_DIFFERENTMACHINE: TRACE("MSHCTX_DIFFERENTMACHINE)"); break;
79 case MSHCTX_INPROC: TRACE("MSHCTX_INPROC)"); break;
80 default: TRACE("%d)", LOWORD(*pFlags));
84 /* CLEANLOCALSTORAGE */
86 #define CLS_FUNCDESC 'f'
87 #define CLS_LIBATTR 'l'
88 #define CLS_TYPEATTR 't'
89 #define CLS_VARDESC 'v'
91 ULONG WINAPI CLEANLOCALSTORAGE_UserSize(ULONG *pFlags, ULONG Start, CLEANLOCALSTORAGE *pstg)
93 ALIGN_LENGTH(Start, 3);
94 return Start + sizeof(DWORD);
97 unsigned char * WINAPI CLEANLOCALSTORAGE_UserMarshal(ULONG *pFlags, unsigned char *Buffer, CLEANLOCALSTORAGE *pstg)
99 ALIGN_POINTER(Buffer, 3);
100 *(DWORD*)Buffer = pstg->flags;
104 ITypeLib_ReleaseTLibAttr((ITypeLib*)pstg->pInterface, *(TLIBATTR**)pstg->pStorage);
107 ITypeInfo_ReleaseTypeAttr((ITypeInfo*)pstg->pInterface, *(TYPEATTR**)pstg->pStorage);
110 ITypeInfo_ReleaseFuncDesc((ITypeInfo*)pstg->pInterface, *(FUNCDESC**)pstg->pStorage);
113 ITypeInfo_ReleaseVarDesc((ITypeInfo*)pstg->pInterface, *(VARDESC**)pstg->pStorage);
117 ERR("Unknown type %x\n", pstg->flags);
120 *(VOID**)pstg->pStorage = NULL;
121 IUnknown_Release(pstg->pInterface);
122 pstg->pInterface = NULL;
124 return Buffer + sizeof(DWORD);
127 unsigned char * WINAPI CLEANLOCALSTORAGE_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, CLEANLOCALSTORAGE *pstr)
129 ALIGN_POINTER(Buffer, 3);
130 pstr->flags = *(DWORD*)Buffer;
131 return Buffer + sizeof(DWORD);
134 void WINAPI CLEANLOCALSTORAGE_UserFree(ULONG *pFlags, CLEANLOCALSTORAGE *pstr)
143 DWORD len; /* No. of chars not including trailing '\0' */
144 DWORD byte_len; /* len * 2 or 0xffffffff if len == 0 */
145 DWORD len2; /* == len */
148 ULONG WINAPI BSTR_UserSize(ULONG *pFlags, ULONG Start, BSTR *pstr)
150 TRACE("(%x,%d,%p) => %p\n", *pFlags, Start, pstr, *pstr);
151 if (*pstr) TRACE("string=%s\n", debugstr_w(*pstr));
152 ALIGN_LENGTH(Start, 3);
153 Start += sizeof(bstr_wire_t) + ((SysStringByteLen(*pstr) + 1) & ~1);
154 TRACE("returning %d\n", Start);
158 unsigned char * WINAPI BSTR_UserMarshal(ULONG *pFlags, unsigned char *Buffer, BSTR *pstr)
161 DWORD len = SysStringByteLen(*pstr);
163 TRACE("(%x,%p,%p) => %p\n", *pFlags, Buffer, pstr, *pstr);
164 if (*pstr) TRACE("string=%s\n", debugstr_w(*pstr));
166 ALIGN_POINTER(Buffer, 3);
167 header = (bstr_wire_t*)Buffer;
168 header->len = header->len2 = (len + 1) / 2;
171 header->byte_len = len;
172 memcpy(header + 1, *pstr, header->len * 2);
175 header->byte_len = 0xffffffff; /* special case for a null bstr */
177 return Buffer + sizeof(*header) + sizeof(OLECHAR) * header->len;
180 unsigned char * WINAPI BSTR_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, BSTR *pstr)
183 TRACE("(%x,%p,%p) => %p\n", *pFlags, Buffer, pstr, *pstr);
185 ALIGN_POINTER(Buffer, 3);
186 header = (bstr_wire_t*)Buffer;
187 if(header->len != header->len2)
188 FIXME("len %08x != len2 %08x\n", header->len, header->len2);
190 SysFreeString(*pstr);
193 if(header->byte_len != 0xffffffff)
194 *pstr = SysAllocStringByteLen((char*)(header + 1), header->byte_len);
196 if (*pstr) TRACE("string=%s\n", debugstr_w(*pstr));
197 return Buffer + sizeof(*header) + sizeof(OLECHAR) * header->len;
200 void WINAPI BSTR_UserFree(ULONG *pFlags, BSTR *pstr)
202 TRACE("(%x,%p) => %p\n", *pFlags, pstr, *pstr);
203 SysFreeString(*pstr);
220 static unsigned int get_type_size(ULONG *pFlags, VARTYPE vt)
222 if (vt & VT_ARRAY) return 4;
224 switch (vt & ~VT_BYREF) {
233 return sizeof(SHORT);
241 return sizeof(FLOAT);
243 return sizeof(DOUBLE);
245 return sizeof(VARIANT_BOOL);
247 return sizeof(SCODE);
253 return sizeof(DECIMAL);
257 return sizeof(VARIANT);
263 FIXME("unhandled VT %d\n", vt);
268 static unsigned int get_type_alignment(ULONG *pFlags, VARTYPE vt)
270 unsigned int size = get_type_size(pFlags, vt);
271 if(vt & VT_BYREF) return 3;
272 if(size == 0) return 0;
273 if(size <= 4) return size - 1;
277 static unsigned interface_variant_size(const ULONG *pFlags, REFIID riid, IUnknown *punk)
281 /* find the buffer size of the marshalled dispatch interface */
282 hr = CoGetMarshalSizeMax(&size, riid, punk, LOWORD(*pFlags), NULL, MSHLFLAGS_NORMAL);
285 WARN("NULL dispatch pointer\n");
287 ERR("Dispatch variant buffer size calculation failed, HRESULT=0x%x\n", hr);
290 size += sizeof(ULONG); /* we have to store the buffersize in the stream */
291 TRACE("wire-size extra of dispatch variant is %d\n", size);
295 static ULONG wire_extra_user_size(ULONG *pFlags, ULONG Start, VARIANT *pvar)
300 return LPSAFEARRAY_UserSize(pFlags, Start, V_ARRAYREF(pvar));
302 return LPSAFEARRAY_UserSize(pFlags, Start, &V_ARRAY(pvar));
305 switch (V_VT(pvar)) {
307 return BSTR_UserSize(pFlags, Start, &V_BSTR(pvar));
308 case VT_BSTR | VT_BYREF:
309 return BSTR_UserSize(pFlags, Start, V_BSTRREF(pvar));
310 case VT_VARIANT | VT_BYREF:
311 return VARIANT_UserSize(pFlags, Start, V_VARIANTREF(pvar));
313 return Start + interface_variant_size(pFlags, &IID_IUnknown, V_UNKNOWN(pvar));
314 case VT_UNKNOWN | VT_BYREF:
315 return Start + interface_variant_size(pFlags, &IID_IUnknown, *V_UNKNOWNREF(pvar));
317 return Start + interface_variant_size(pFlags, &IID_IDispatch, (IUnknown*)V_DISPATCH(pvar));
318 case VT_DISPATCH | VT_BYREF:
319 return Start + interface_variant_size(pFlags, &IID_IDispatch, (IUnknown*)*V_DISPATCHREF(pvar));
321 FIXME("wire-size record\n");
324 case VT_SAFEARRAY | VT_BYREF:
325 FIXME("wire-size safearray: shouldn't be marshaling this\n");
332 /* helper: called for VT_DISPATCH variants to marshal the IDispatch* into the buffer. returns Buffer on failure, new position otherwise */
333 static unsigned char* interface_variant_marshal(const ULONG *pFlags, unsigned char *Buffer,
334 REFIID riid, IUnknown *punk)
338 void *working_memlocked;
339 unsigned char *oldpos;
343 TRACE("pFlags=%d, Buffer=%p, pUnk=%p\n", *pFlags, Buffer, punk);
347 /* CoMarshalInterface needs a stream, whereas at this level we are operating in terms of buffers.
348 * We create a stream on an HGLOBAL, so we can simply do a memcpy to move it to the buffer.
349 * in rpcrt4/ndr_ole.c, a simple IStream implementation is wrapped around the buffer object,
350 * but that would be overkill here, hence this implementation. We save the size because the unmarshal
351 * code has no way to know how long the marshalled buffer is. */
353 size = interface_variant_size(pFlags, riid, punk);
355 working_mem = GlobalAlloc(0, size);
356 if (!working_mem) return oldpos;
358 hr = CreateStreamOnHGlobal(working_mem, TRUE, &working);
360 GlobalFree(working_mem);
364 hr = CoMarshalInterface(working, riid, punk, LOWORD(*pFlags), NULL, MSHLFLAGS_NORMAL);
366 IStream_Release(working); /* this also releases the hglobal */
370 working_memlocked = GlobalLock(working_mem);
371 memcpy(Buffer, &size, sizeof(ULONG)); /* copy the buffersize */
372 memcpy(Buffer + sizeof(ULONG), working_memlocked, size - sizeof(ULONG));
373 GlobalUnlock(working_mem);
375 IStream_Release(working);
377 /* size includes the ULONG for the size written above */
378 TRACE("done, size=%d\n", size);
379 return Buffer + size;
382 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
383 static unsigned char *interface_variant_unmarshal(const ULONG *pFlags, unsigned char *Buffer,
384 REFIID riid, IUnknown **ppunk)
388 void *working_memlocked;
389 unsigned char *oldpos;
393 TRACE("pFlags=%d, Buffer=%p, ppUnk=%p\n", *pFlags, Buffer, ppunk);
397 /* get the buffersize */
398 memcpy(&size, Buffer, sizeof(ULONG));
399 TRACE("buffersize=%d\n", size);
401 working_mem = GlobalAlloc(0, size);
402 if (!working_mem) return oldpos;
404 hr = CreateStreamOnHGlobal(working_mem, TRUE, &working);
406 GlobalFree(working_mem);
410 working_memlocked = GlobalLock(working_mem);
412 /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
413 memcpy(working_memlocked, Buffer + sizeof(ULONG), size);
414 GlobalUnlock(working_mem);
416 hr = CoUnmarshalInterface(working, riid, (void**)ppunk);
418 IStream_Release(working);
422 IStream_Release(working); /* this also frees the underlying hglobal */
424 /* size includes the ULONG for the size written above */
425 TRACE("done, processed=%d bytes\n", size);
426 return Buffer + size;
430 ULONG WINAPI VARIANT_UserSize(ULONG *pFlags, ULONG Start, VARIANT *pvar)
433 TRACE("(%x,%d,%p)\n", *pFlags, Start, pvar);
434 TRACE("vt=%04x\n", V_VT(pvar));
436 ALIGN_LENGTH(Start, 7);
437 Start += sizeof(variant_wire_t);
438 if(V_VT(pvar) & VT_BYREF)
441 align = get_type_alignment(pFlags, V_VT(pvar));
442 ALIGN_LENGTH(Start, align);
443 if(V_VT(pvar) == (VT_VARIANT | VT_BYREF))
446 Start += get_type_size(pFlags, V_VT(pvar));
447 Start = wire_extra_user_size(pFlags, Start, pvar);
449 TRACE("returning %d\n", Start);
453 unsigned char * WINAPI VARIANT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, VARIANT *pvar)
455 variant_wire_t *header;
460 TRACE("(%x,%p,%p)\n", *pFlags, Buffer, pvar);
461 TRACE("vt=%04x\n", V_VT(pvar));
463 ALIGN_POINTER(Buffer, 7);
465 header = (variant_wire_t *)Buffer;
467 header->clSize = 0; /* fixed up at the end */
468 header->rpcReserverd = 0;
469 header->vt = pvar->n1.n2.vt;
470 header->wReserved1 = pvar->n1.n2.wReserved1;
471 header->wReserved2 = pvar->n1.n2.wReserved2;
472 header->wReserved3 = pvar->n1.n2.wReserved3;
473 header->switch_is = pvar->n1.n2.vt;
474 if(header->switch_is & VT_ARRAY)
475 header->switch_is &= ~VT_TYPEMASK;
477 Pos = (unsigned char*)(header + 1);
478 type_size = get_type_size(pFlags, V_VT(pvar));
479 align = get_type_alignment(pFlags, V_VT(pvar));
480 ALIGN_POINTER(Pos, align);
482 if(header->vt & VT_BYREF)
484 *(DWORD *)Pos = max(type_size, 4);
486 if((header->vt & VT_TYPEMASK) != VT_VARIANT)
488 memcpy(Pos, pvar->n1.n2.n3.byref, type_size);
493 *(DWORD*)Pos = 'U' | 's' << 8 | 'e' << 16 | 'r' << 24;
499 if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
500 memcpy(Pos, pvar, type_size);
502 memcpy(Pos, &pvar->n1.n2.n3, type_size);
506 if(header->vt & VT_ARRAY)
508 if(header->vt & VT_BYREF)
509 Pos = LPSAFEARRAY_UserMarshal(pFlags, Pos, V_ARRAYREF(pvar));
511 Pos = LPSAFEARRAY_UserMarshal(pFlags, Pos, &V_ARRAY(pvar));
518 Pos = BSTR_UserMarshal(pFlags, Pos, &V_BSTR(pvar));
520 case VT_BSTR | VT_BYREF:
521 Pos = BSTR_UserMarshal(pFlags, Pos, V_BSTRREF(pvar));
523 case VT_VARIANT | VT_BYREF:
524 Pos = VARIANT_UserMarshal(pFlags, Pos, V_VARIANTREF(pvar));
527 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
528 Pos = interface_variant_marshal(pFlags, Pos, &IID_IUnknown, V_UNKNOWN(pvar));
530 case VT_UNKNOWN | VT_BYREF:
531 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
532 Pos = interface_variant_marshal(pFlags, Pos, &IID_IUnknown, *V_UNKNOWNREF(pvar));
535 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
536 Pos = interface_variant_marshal(pFlags, Pos, &IID_IDispatch, (IUnknown*)V_DISPATCH(pvar));
538 case VT_DISPATCH | VT_BYREF:
539 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
540 Pos = interface_variant_marshal(pFlags, Pos, &IID_IDispatch, (IUnknown*)*V_DISPATCHREF(pvar));
543 FIXME("handle BRECORD by val\n");
545 case VT_RECORD | VT_BYREF:
546 FIXME("handle BRECORD by ref\n");
550 header->clSize = ((Pos - Buffer) + 7) >> 3;
551 TRACE("marshalled size=%d\n", header->clSize);
555 unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, VARIANT *pvar)
557 variant_wire_t *header;
562 TRACE("(%x,%p,%p)\n", *pFlags, Buffer, pvar);
564 ALIGN_POINTER(Buffer, 7);
566 header = (variant_wire_t *)Buffer;
568 Pos = (unsigned char*)(header + 1);
569 type_size = get_type_size(pFlags, header->vt);
570 align = get_type_alignment(pFlags, header->vt);
571 ALIGN_POINTER(Pos, align);
573 if(header->vt & VT_BYREF)
576 if (V_VT(pvar) != header->vt)
579 V_BYREF(pvar) = CoTaskMemAlloc(type_size);
581 else if (!V_BYREF(pvar))
582 V_BYREF(pvar) = CoTaskMemAlloc(type_size);
583 memcpy(V_BYREF(pvar), Pos, type_size);
584 if((header->vt & VT_TYPEMASK) != VT_VARIANT)
592 if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
593 memcpy(pvar, Pos, type_size);
595 memcpy(&pvar->n1.n2.n3, Pos, type_size);
599 pvar->n1.n2.vt = header->vt;
600 pvar->n1.n2.wReserved1 = header->wReserved1;
601 pvar->n1.n2.wReserved2 = header->wReserved2;
602 pvar->n1.n2.wReserved3 = header->wReserved3;
604 if(header->vt & VT_ARRAY)
606 if(header->vt & VT_BYREF)
607 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, V_ARRAYREF(pvar));
609 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, &V_ARRAY(pvar));
617 Pos = BSTR_UserUnmarshal(pFlags, Pos, &V_BSTR(pvar));
619 case VT_BSTR | VT_BYREF:
620 *V_BSTRREF(pvar) = NULL;
621 Pos = BSTR_UserUnmarshal(pFlags, Pos, V_BSTRREF(pvar));
623 case VT_VARIANT | VT_BYREF:
624 Pos = VARIANT_UserUnmarshal(pFlags, Pos, V_VARIANTREF(pvar));
627 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
628 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, &V_UNKNOWN(pvar));
630 case VT_UNKNOWN | VT_BYREF:
631 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
632 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, V_UNKNOWNREF(pvar));
635 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
636 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)&V_DISPATCH(pvar));
638 case VT_DISPATCH | VT_BYREF:
639 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
640 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)V_DISPATCHREF(pvar));
643 FIXME("handle BRECORD by val\n");
645 case VT_RECORD | VT_BYREF:
646 FIXME("handle BRECORD by ref\n");
653 void WINAPI VARIANT_UserFree(ULONG *pFlags, VARIANT *pvar)
655 VARTYPE vt = V_VT(pvar);
658 TRACE("(%x,%p)\n", *pFlags, pvar);
659 TRACE("vt=%04x\n", V_VT(pvar));
661 if (vt & VT_BYREF) ref = pvar->n1.n2.n3.byref;
669 LPSAFEARRAY_UserFree(pFlags, V_ARRAYREF(pvar));
671 LPSAFEARRAY_UserFree(pFlags, &V_ARRAY(pvar));
677 case VT_BSTR | VT_BYREF:
678 BSTR_UserFree(pFlags, V_BSTRREF(pvar));
680 case VT_VARIANT | VT_BYREF:
681 VARIANT_UserFree(pFlags, V_VARIANTREF(pvar));
683 case VT_RECORD | VT_BYREF:
684 FIXME("handle BRECORD by ref\n");
686 case VT_UNKNOWN | VT_BYREF:
687 case VT_DISPATCH | VT_BYREF:
688 IUnknown_Release(*V_UNKNOWNREF(pvar));
698 /* Get the number of cells in a SafeArray */
699 static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa)
701 const SAFEARRAYBOUND* psab = psa->rgsabound;
702 USHORT cCount = psa->cDims;
703 ULONG ulNumCells = 1;
707 /* This is a valid bordercase. See testcases. -Marcus */
708 if (!psab->cElements)
710 ulNumCells *= psab->cElements;
716 static inline SF_TYPE SAFEARRAY_GetUnionType(SAFEARRAY *psa)
721 hr = SafeArrayGetVartype(psa, &vt);
724 if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT;
726 switch(psa->cbElements)
728 case 1: vt = VT_I1; break;
729 case 2: vt = VT_I2; break;
730 case 4: vt = VT_I4; break;
731 case 8: vt = VT_I8; break;
733 RpcRaiseException(hr);
737 if (psa->fFeatures & FADF_HAVEIID)
743 case VT_UI1: return SF_I1;
746 case VT_UI2: return SF_I2;
751 case VT_R4: return SF_I4;
756 case VT_UI8: return SF_I8;
758 case VT_UINT_PTR: return (sizeof(UINT_PTR) == 4 ? SF_I4 : SF_I8);
759 case VT_BSTR: return SF_BSTR;
760 case VT_DISPATCH: return SF_DISPATCH;
761 case VT_VARIANT: return SF_VARIANT;
762 case VT_UNKNOWN: return SF_UNKNOWN;
763 /* Note: Return a non-zero size to indicate vt is valid. The actual size
764 * of a UDT is taken from the result of IRecordInfo_GetSize().
766 case VT_RECORD: return SF_RECORD;
767 default: return SF_ERROR;
771 ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY *ppsa)
773 ULONG size = StartingSize;
775 TRACE("("); dump_user_flags(pFlags); TRACE(", %d, %p\n", StartingSize, *ppsa);
777 ALIGN_LENGTH(size, 3);
778 size += sizeof(ULONG_PTR);
781 SAFEARRAY *psa = *ppsa;
782 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
786 size += sizeof(ULONG);
787 size += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
789 sftype = SAFEARRAY_GetUnionType(psa);
790 size += sizeof(ULONG);
792 size += sizeof(ULONG);
793 size += sizeof(ULONG_PTR);
794 if (sftype == SF_HAVEIID)
797 size += sizeof(psa->rgsabound[0]) * psa->cDims;
799 size += sizeof(ULONG);
807 for (lpBstr = (BSTR*)psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
808 size = BSTR_UserSize(pFlags, size, lpBstr);
815 FIXME("size interfaces\n");
821 for (lpVariant = (VARIANT*)psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
822 size = VARIANT_UserSize(pFlags, size, lpVariant);
828 IRecordInfo* pRecInfo = NULL;
830 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
832 RpcRaiseException(hr);
836 FIXME("size record info %p\n", pRecInfo);
838 IRecordInfo_Release(pRecInfo);
843 ALIGN_LENGTH(size, 7);
848 size += ulCellCount * psa->cbElements;
859 unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
863 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
865 ALIGN_POINTER(Buffer, 3);
866 *(ULONG_PTR *)Buffer = *ppsa ? TRUE : FALSE;
867 Buffer += sizeof(ULONG_PTR);
871 SAFEARRAY *psa = *ppsa;
872 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
873 wireSAFEARRAY wiresa;
877 *(ULONG *)Buffer = psa->cDims;
878 Buffer += sizeof(ULONG);
879 wiresa = (wireSAFEARRAY)Buffer;
880 wiresa->cDims = psa->cDims;
881 wiresa->fFeatures = psa->fFeatures;
882 wiresa->cbElements = psa->cbElements;
884 hr = SafeArrayGetVartype(psa, &vt);
885 if (FAILED(hr)) vt = 0;
887 wiresa->cLocks = (USHORT)psa->cLocks | (vt << 16);
889 Buffer += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
891 sftype = SAFEARRAY_GetUnionType(psa);
892 *(ULONG *)Buffer = sftype;
893 Buffer += sizeof(ULONG);
895 *(ULONG *)Buffer = ulCellCount;
896 Buffer += sizeof(ULONG);
897 *(ULONG_PTR *)Buffer = (ULONG_PTR)psa->pvData;
898 Buffer += sizeof(ULONG_PTR);
899 if (sftype == SF_HAVEIID)
901 SafeArrayGetIID(psa, &guid);
902 memcpy(Buffer, &guid, sizeof(guid));
903 Buffer += sizeof(guid);
906 memcpy(Buffer, psa->rgsabound, sizeof(psa->rgsabound[0]) * psa->cDims);
907 Buffer += sizeof(psa->rgsabound[0]) * psa->cDims;
909 *(ULONG *)Buffer = ulCellCount;
910 Buffer += sizeof(ULONG);
920 for (lpBstr = (BSTR*)psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
921 Buffer = BSTR_UserMarshal(pFlags, Buffer, lpBstr);
928 FIXME("marshal interfaces\n");
934 for (lpVariant = (VARIANT*)psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
935 Buffer = VARIANT_UserMarshal(pFlags, Buffer, lpVariant);
941 IRecordInfo* pRecInfo = NULL;
943 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
945 RpcRaiseException(hr);
949 FIXME("write record info %p\n", pRecInfo);
951 IRecordInfo_Release(pRecInfo);
957 ALIGN_POINTER(Buffer, 7);
962 /* Just copy the data over */
963 memcpy(Buffer, psa->pvData, ulCellCount * psa->cbElements);
964 Buffer += ulCellCount * psa->cbElements;
975 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
976 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
977 FADF_VARIANT | FADF_CREATEVECTOR)
979 unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
982 wireSAFEARRAY wiresa;
989 SAFEARRAYBOUND *wiresab;
991 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
993 ALIGN_POINTER(Buffer, 3);
994 ptr = *(ULONG_PTR *)Buffer;
995 Buffer += sizeof(ULONG_PTR);
1001 TRACE("NULL safe array unmarshaled\n");
1006 cDims = *(ULONG *)Buffer;
1007 Buffer += sizeof(ULONG);
1009 wiresa = (wireSAFEARRAY)Buffer;
1010 Buffer += FIELD_OFFSET(struct _wireSAFEARRAY, uArrayStructs);
1012 if (cDims != wiresa->cDims)
1013 RpcRaiseException(RPC_S_INVALID_BOUND);
1015 /* FIXME: there should be a limit on how large cDims can be */
1017 vt = HIWORD(wiresa->cLocks);
1019 sftype = *(ULONG *)Buffer;
1020 Buffer += sizeof(ULONG);
1022 cell_count = *(ULONG *)Buffer;
1023 Buffer += sizeof(ULONG);
1024 ptr = *(ULONG_PTR *)Buffer;
1025 Buffer += sizeof(ULONG_PTR);
1026 if (sftype == SF_HAVEIID)
1028 memcpy(&guid, Buffer, sizeof(guid));
1029 Buffer += sizeof(guid);
1032 wiresab = (SAFEARRAYBOUND *)Buffer;
1033 Buffer += sizeof(wiresab[0]) * wiresa->cDims;
1036 *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
1039 SafeArrayAllocDescriptor(wiresa->cDims, ppsa);
1041 memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
1044 RpcRaiseException(E_OUTOFMEMORY);
1046 /* be careful about which flags we set since they could be a security
1048 (*ppsa)->fFeatures &= FADF_AUTOSETFLAGS;
1049 (*ppsa)->fFeatures |= (wiresa->fFeatures & ~(FADF_AUTOSETFLAGS));
1050 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1051 (*ppsa)->cbElements = wiresa->cbElements;
1052 (*ppsa)->cLocks = LOWORD(wiresa->cLocks);
1054 /* SafeArrayCreateEx allocates the data for us, but
1055 * SafeArrayAllocDescriptor doesn't */
1058 hr = SafeArrayAllocData(*ppsa);
1060 RpcRaiseException(hr);
1063 if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
1064 RpcRaiseException(RPC_S_INVALID_BOUND);
1065 Buffer += sizeof(ULONG);
1075 for (lpBstr = (BSTR*)(*ppsa)->pvData; cell_count; cell_count--, lpBstr++)
1076 Buffer = BSTR_UserUnmarshal(pFlags, Buffer, lpBstr);
1083 FIXME("marshal interfaces\n");
1089 for (lpVariant = (VARIANT*)(*ppsa)->pvData; cell_count; cell_count--, lpVariant++)
1090 Buffer = VARIANT_UserUnmarshal(pFlags, Buffer, lpVariant);
1096 FIXME("set record info\n");
1102 ALIGN_POINTER(Buffer, 7);
1107 /* Just copy the data over */
1108 memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
1109 Buffer += cell_count * (*ppsa)->cbElements;
1116 TRACE("safe array unmarshaled: %p\n", *ppsa);
1121 void WINAPI LPSAFEARRAY_UserFree(ULONG *pFlags, LPSAFEARRAY *ppsa)
1123 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *ppsa);
1125 SafeArrayDestroy(*ppsa);
1129 ULONG WINAPI HFONT_UserSize(ULONG *pFlags, ULONG Start, HFONT *phfont)
1135 unsigned char * WINAPI HFONT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1141 unsigned char * WINAPI HFONT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1147 void WINAPI HFONT_UserFree(ULONG *pFlags, HFONT *phfont)
1155 /* exactly how Invoke is marshalled is not very clear to me yet,
1156 * but the way I've done it seems to work for me */
1158 HRESULT CALLBACK IDispatch_Invoke_Proxy(
1160 DISPID dispIdMember,
1164 DISPPARAMS* pDispParams,
1165 VARIANT* pVarResult,
1166 EXCEPINFO* pExcepInfo,
1171 UINT* rgVarRefIdx = NULL;
1172 VARIANTARG* rgVarRef = NULL;
1175 EXCEPINFO ExcepInfo;
1177 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This,
1178 dispIdMember, debugstr_guid(riid),
1179 lcid, wFlags, pDispParams, pVarResult,
1180 pExcepInfo, puArgErr);
1182 /* [out] args can't be null, use dummy vars if needed */
1183 if (!pVarResult) pVarResult = &VarResult;
1184 if (!puArgErr) puArgErr = &uArgErr;
1185 if (!pExcepInfo) pExcepInfo = &ExcepInfo;
1187 /* count by-ref args */
1188 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1189 VARIANTARG* arg = &pDispParams->rgvarg[u];
1190 if (V_ISBYREF(arg)) {
1195 rgVarRefIdx = CoTaskMemAlloc(sizeof(UINT)*cVarRef);
1196 rgVarRef = CoTaskMemAlloc(sizeof(VARIANTARG)*cVarRef);
1197 /* make list of by-ref args */
1198 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1199 VARIANTARG* arg = &pDispParams->rgvarg[u];
1200 if (V_ISBYREF(arg)) {
1201 rgVarRefIdx[cVarRef] = u;
1202 VariantInit(&rgVarRef[cVarRef]);
1207 /* [out] args still can't be null,
1208 * but we can point these anywhere in this case,
1209 * since they won't be written to when cVarRef is 0 */
1210 rgVarRefIdx = puArgErr;
1211 rgVarRef = pVarResult;
1213 TRACE("passed by ref: %d args\n", cVarRef);
1214 hr = IDispatch_RemoteInvoke_Proxy(This,
1227 for (u=0; u<cVarRef; u++) {
1228 unsigned i = rgVarRefIdx[u];
1229 VariantCopy(&pDispParams->rgvarg[i],
1231 VariantClear(&rgVarRef[u]);
1233 CoTaskMemFree(rgVarRef);
1234 CoTaskMemFree(rgVarRefIdx);
1237 if(pExcepInfo == &ExcepInfo)
1239 SysFreeString(pExcepInfo->bstrSource);
1240 SysFreeString(pExcepInfo->bstrDescription);
1241 SysFreeString(pExcepInfo->bstrHelpFile);
1246 HRESULT __RPC_STUB IDispatch_Invoke_Stub(
1248 DISPID dispIdMember,
1252 DISPPARAMS* pDispParams,
1253 VARIANT* pVarResult,
1254 EXCEPINFO* pExcepInfo,
1258 VARIANTARG* rgVarRef)
1261 VARIANTARG *rgvarg, *arg;
1264 /* initialize out parameters, so that they can be marshalled
1265 * in case the real Invoke doesn't initialize them */
1266 VariantInit(pVarResult);
1267 memset(pExcepInfo, 0, sizeof(*pExcepInfo));
1270 /* let the real Invoke operate on a copy of the in parameters,
1271 * so we don't risk losing pointers to allocated memory */
1272 rgvarg = pDispParams->rgvarg;
1273 arg = CoTaskMemAlloc(sizeof(VARIANTARG)*pDispParams->cArgs);
1274 if (!arg) return E_OUTOFMEMORY;
1276 /* init all args so we can call VariantClear on all the args if the copy
1278 for (u = 0; u < pDispParams->cArgs; u++)
1279 VariantInit(&arg[u]);
1281 for (u = 0; u < pDispParams->cArgs; u++) {
1282 hr = VariantCopy(&arg[u], &rgvarg[u]);
1287 if (SUCCEEDED(hr)) {
1288 pDispParams->rgvarg = arg;
1290 hr = IDispatch_Invoke(This,
1300 /* copy ref args to out list */
1301 for (u=0; u<cVarRef; u++) {
1302 unsigned i = rgVarRefIdx[u];
1303 VariantInit(&rgVarRef[u]);
1304 VariantCopy(&rgVarRef[u], &arg[i]);
1305 /* clear original if equal, to avoid double-free */
1306 if (V_BYREF(&rgVarRef[u]) == V_BYREF(&rgvarg[i]))
1307 VariantClear(&rgvarg[i]);
1311 /* clear the duplicate argument list */
1312 for (u=0; u<pDispParams->cArgs; u++)
1313 VariantClear(&arg[u]);
1315 pDispParams->rgvarg = rgvarg;
1323 HRESULT CALLBACK IEnumVARIANT_Next_Proxy(
1327 ULONG* pCeltFetched)
1331 pCeltFetched = &fetched;
1332 return IEnumVARIANT_RemoteNext_Proxy(This,
1338 HRESULT __RPC_STUB IEnumVARIANT_Next_Stub(
1342 ULONG* pCeltFetched)
1346 hr = IEnumVARIANT_Next(This,
1350 if (hr == S_OK) *pCeltFetched = celt;
1354 /* TypeInfo related freers */
1356 static void free_embedded_typedesc(TYPEDESC *tdesc);
1357 static void free_embedded_arraydesc(ARRAYDESC *adesc)
1359 switch(adesc->tdescElem.vt)
1363 free_embedded_typedesc(adesc->tdescElem.u.lptdesc);
1364 CoTaskMemFree(adesc->tdescElem.u.lptdesc);
1367 free_embedded_arraydesc(adesc->tdescElem.u.lpadesc);
1368 CoTaskMemFree(adesc->tdescElem.u.lpadesc);
1373 static void free_embedded_typedesc(TYPEDESC *tdesc)
1379 free_embedded_typedesc(tdesc->u.lptdesc);
1380 CoTaskMemFree(tdesc->u.lptdesc);
1383 free_embedded_arraydesc(tdesc->u.lpadesc);
1384 CoTaskMemFree(tdesc->u.lpadesc);
1389 static void free_embedded_elemdesc(ELEMDESC *edesc)
1391 free_embedded_typedesc(&edesc->tdesc);
1392 if(edesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT)
1393 CoTaskMemFree(edesc->u.paramdesc.pparamdescex);
1398 HRESULT CALLBACK ITypeComp_Bind_Proxy(
1403 ITypeInfo** ppTInfo,
1404 DESCKIND* pDescKind,
1407 FIXME("not implemented\n");
1411 HRESULT __RPC_STUB ITypeComp_Bind_Stub(
1416 ITypeInfo** ppTInfo,
1417 DESCKIND* pDescKind,
1418 LPFUNCDESC* ppFuncDesc,
1419 LPVARDESC* ppVarDesc,
1420 ITypeComp** ppTypeComp,
1421 CLEANLOCALSTORAGE* pDummy)
1423 FIXME("not implemented\n");
1427 HRESULT CALLBACK ITypeComp_BindType_Proxy(
1431 ITypeInfo** ppTInfo,
1432 ITypeComp** ppTComp)
1434 FIXME("not implemented\n");
1438 HRESULT __RPC_STUB ITypeComp_BindType_Stub(
1442 ITypeInfo** ppTInfo)
1444 FIXME("not implemented\n");
1450 HRESULT CALLBACK ITypeInfo_GetTypeAttr_Proxy(
1452 TYPEATTR** ppTypeAttr)
1455 CLEANLOCALSTORAGE stg;
1456 TRACE("(%p, %p)\n", This, ppTypeAttr);
1459 stg.pStorage = NULL;
1460 stg.pInterface = NULL;
1462 return ITypeInfo_RemoteGetTypeAttr_Proxy(This, ppTypeAttr, &stg);
1465 HRESULT __RPC_STUB ITypeInfo_GetTypeAttr_Stub(
1467 LPTYPEATTR* ppTypeAttr,
1468 CLEANLOCALSTORAGE* pDummy)
1471 TRACE("(%p, %p)\n", This, ppTypeAttr);
1473 hr = ITypeInfo_GetTypeAttr(This, ppTypeAttr);
1477 pDummy->flags = CLS_TYPEATTR;
1478 ITypeInfo_AddRef(This);
1479 pDummy->pInterface = (IUnknown*)This;
1480 pDummy->pStorage = ppTypeAttr;
1484 HRESULT CALLBACK ITypeInfo_GetFuncDesc_Proxy(
1487 FUNCDESC** ppFuncDesc)
1489 CLEANLOCALSTORAGE stg;
1490 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1493 stg.pStorage = NULL;
1494 stg.pInterface = NULL;
1496 return ITypeInfo_RemoteGetFuncDesc_Proxy(This, index, ppFuncDesc, &stg);
1499 HRESULT __RPC_STUB ITypeInfo_GetFuncDesc_Stub(
1502 LPFUNCDESC* ppFuncDesc,
1503 CLEANLOCALSTORAGE* pDummy)
1506 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1508 hr = ITypeInfo_GetFuncDesc(This, index, ppFuncDesc);
1512 pDummy->flags = CLS_FUNCDESC;
1513 ITypeInfo_AddRef(This);
1514 pDummy->pInterface = (IUnknown*)This;
1515 pDummy->pStorage = ppFuncDesc;
1519 HRESULT CALLBACK ITypeInfo_GetVarDesc_Proxy(
1522 VARDESC** ppVarDesc)
1524 CLEANLOCALSTORAGE stg;
1525 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1528 stg.pStorage = NULL;
1529 stg.pInterface = NULL;
1531 return ITypeInfo_RemoteGetVarDesc_Proxy(This, index, ppVarDesc, &stg);
1534 HRESULT __RPC_STUB ITypeInfo_GetVarDesc_Stub(
1537 LPVARDESC* ppVarDesc,
1538 CLEANLOCALSTORAGE* pDummy)
1541 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1543 hr = ITypeInfo_GetVarDesc(This, index, ppVarDesc);
1547 pDummy->flags = CLS_VARDESC;
1548 ITypeInfo_AddRef(This);
1549 pDummy->pInterface = (IUnknown*)This;
1550 pDummy->pStorage = ppVarDesc;
1554 HRESULT CALLBACK ITypeInfo_GetNames_Proxy(
1561 FIXME("not implemented\n");
1565 HRESULT __RPC_STUB ITypeInfo_GetNames_Stub(
1572 FIXME("not implemented\n");
1576 HRESULT CALLBACK ITypeInfo_GetIDsOfNames_Proxy(
1578 LPOLESTR* rgszNames,
1582 FIXME("not implemented\n");
1586 HRESULT __RPC_STUB ITypeInfo_GetIDsOfNames_Stub(
1589 FIXME("not implemented\n");
1593 HRESULT CALLBACK ITypeInfo_Invoke_Proxy(
1598 DISPPARAMS* pDispParams,
1599 VARIANT* pVarResult,
1600 EXCEPINFO* pExcepInfo,
1603 FIXME("not implemented\n");
1607 HRESULT __RPC_STUB ITypeInfo_Invoke_Stub(
1610 FIXME("not implemented\n");
1614 HRESULT CALLBACK ITypeInfo_GetDocumentation_Proxy(
1618 BSTR* pBstrDocString,
1619 DWORD* pdwHelpContext,
1620 BSTR* pBstrHelpFile)
1623 BSTR name, doc_string, help_file;
1625 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1627 /* FIXME: presumably refPtrFlags is supposed to be a bitmask of which ptrs we actually want? */
1628 hr = ITypeInfo_RemoteGetDocumentation_Proxy(This, memid, 0, &name, &doc_string, &help_context, &help_file);
1631 if(pBstrName) *pBstrName = name;
1632 else SysFreeString(name);
1634 if(pBstrDocString) *pBstrDocString = doc_string;
1635 else SysFreeString(doc_string);
1637 if(pBstrHelpFile) *pBstrHelpFile = help_file;
1638 else SysFreeString(help_file);
1640 if(pdwHelpContext) *pdwHelpContext = help_context;
1645 HRESULT __RPC_STUB ITypeInfo_GetDocumentation_Stub(
1650 BSTR* pBstrDocString,
1651 DWORD* pdwHelpContext,
1652 BSTR* pBstrHelpFile)
1654 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This, memid, refPtrFlags, pBstrName, pBstrDocString,
1655 pdwHelpContext, pBstrHelpFile);
1656 return ITypeInfo_GetDocumentation(This, memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
1659 HRESULT CALLBACK ITypeInfo_GetDllEntry_Proxy(
1667 FIXME("not implemented\n");
1671 HRESULT __RPC_STUB ITypeInfo_GetDllEntry_Stub(
1680 FIXME("not implemented\n");
1684 HRESULT CALLBACK ITypeInfo_AddressOfMember_Proxy(
1690 FIXME("not implemented\n");
1694 HRESULT __RPC_STUB ITypeInfo_AddressOfMember_Stub(
1697 FIXME("not implemented\n");
1701 HRESULT CALLBACK ITypeInfo_CreateInstance_Proxy(
1703 IUnknown* pUnkOuter,
1707 FIXME("not implemented\n");
1711 HRESULT __RPC_STUB ITypeInfo_CreateInstance_Stub(
1716 FIXME("not implemented\n");
1720 HRESULT CALLBACK ITypeInfo_GetContainingTypeLib_Proxy(
1729 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1731 hr = ITypeInfo_RemoteGetContainingTypeLib_Proxy(This, &pTL, &index);
1740 ITypeLib_Release(pTL);
1745 HRESULT __RPC_STUB ITypeInfo_GetContainingTypeLib_Stub(
1750 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1751 return ITypeInfo_GetContainingTypeLib(This, ppTLib, pIndex);
1754 void CALLBACK ITypeInfo_ReleaseTypeAttr_Proxy(
1756 TYPEATTR* pTypeAttr)
1758 TRACE("(%p, %p)\n", This, pTypeAttr);
1759 free_embedded_typedesc(&pTypeAttr->tdescAlias);
1760 CoTaskMemFree(pTypeAttr);
1763 HRESULT __RPC_STUB ITypeInfo_ReleaseTypeAttr_Stub(
1766 TRACE("nothing to do\n");
1770 void CALLBACK ITypeInfo_ReleaseFuncDesc_Proxy(
1772 FUNCDESC* pFuncDesc)
1775 TRACE("(%p, %p)\n", This, pFuncDesc);
1777 for(param = 0; param < pFuncDesc->cParams; param++)
1778 free_embedded_elemdesc(pFuncDesc->lprgelemdescParam + param);
1780 CoTaskMemFree(pFuncDesc->lprgelemdescParam);
1782 free_embedded_elemdesc(&pFuncDesc->elemdescFunc);
1784 if(pFuncDesc->cScodes != 0 && pFuncDesc->cScodes != -1)
1785 CoTaskMemFree(pFuncDesc->lprgscode);
1787 CoTaskMemFree(pFuncDesc);
1790 HRESULT __RPC_STUB ITypeInfo_ReleaseFuncDesc_Stub(
1793 TRACE("nothing to do\n");
1797 void CALLBACK ITypeInfo_ReleaseVarDesc_Proxy(
1801 TRACE("(%p, %p)\n", This, pVarDesc);
1803 CoTaskMemFree(pVarDesc->lpstrSchema);
1805 if(pVarDesc->varkind == VAR_CONST)
1806 CoTaskMemFree(pVarDesc->u.lpvarValue);
1808 free_embedded_elemdesc(&pVarDesc->elemdescVar);
1809 CoTaskMemFree(pVarDesc);
1812 HRESULT __RPC_STUB ITypeInfo_ReleaseVarDesc_Stub(
1815 TRACE("nothing to do\n");
1822 HRESULT CALLBACK ITypeInfo2_GetDocumentation2_Proxy(
1826 BSTR* pbstrHelpString,
1827 DWORD* pdwHelpStringContext,
1828 BSTR* pbstrHelpStringDll)
1830 FIXME("not implemented\n");
1834 HRESULT __RPC_STUB ITypeInfo2_GetDocumentation2_Stub(
1839 BSTR* pbstrHelpString,
1840 DWORD* pdwHelpStringContext,
1841 BSTR* pbstrHelpStringDll)
1843 FIXME("not implemented\n");
1849 UINT CALLBACK ITypeLib_GetTypeInfoCount_Proxy(
1853 TRACE("(%p)\n", This);
1855 ITypeLib_RemoteGetTypeInfoCount_Proxy(This, &count);
1860 HRESULT __RPC_STUB ITypeLib_GetTypeInfoCount_Stub(
1864 TRACE("(%p, %p)\n", This, pcTInfo);
1865 *pcTInfo = ITypeLib_GetTypeInfoCount(This);
1869 HRESULT CALLBACK ITypeLib_GetLibAttr_Proxy(
1871 TLIBATTR** ppTLibAttr)
1873 CLEANLOCALSTORAGE stg;
1874 TRACE("(%p, %p)\n", This, ppTLibAttr);
1877 stg.pStorage = NULL;
1878 stg.pInterface = NULL;
1880 return ITypeLib_RemoteGetLibAttr_Proxy(This, ppTLibAttr, &stg);
1883 HRESULT __RPC_STUB ITypeLib_GetLibAttr_Stub(
1885 LPTLIBATTR* ppTLibAttr,
1886 CLEANLOCALSTORAGE* pDummy)
1889 TRACE("(%p, %p)\n", This, ppTLibAttr);
1891 hr = ITypeLib_GetLibAttr(This, ppTLibAttr);
1895 pDummy->flags = CLS_LIBATTR;
1896 ITypeLib_AddRef(This);
1897 pDummy->pInterface = (IUnknown*)This;
1898 pDummy->pStorage = ppTLibAttr;
1902 HRESULT CALLBACK ITypeLib_GetDocumentation_Proxy(
1906 BSTR* pBstrDocString,
1907 DWORD* pdwHelpContext,
1908 BSTR* pBstrHelpFile)
1910 FIXME("not implemented\n");
1914 HRESULT __RPC_STUB ITypeLib_GetDocumentation_Stub(
1919 BSTR* pBstrDocString,
1920 DWORD* pdwHelpContext,
1921 BSTR* pBstrHelpFile)
1923 FIXME("not implemented\n");
1927 HRESULT CALLBACK ITypeLib_IsName_Proxy(
1933 FIXME("not implemented\n");
1937 HRESULT __RPC_STUB ITypeLib_IsName_Stub(
1944 FIXME("not implemented\n");
1948 HRESULT CALLBACK ITypeLib_FindName_Proxy(
1952 ITypeInfo** ppTInfo,
1956 FIXME("not implemented\n");
1960 HRESULT __RPC_STUB ITypeLib_FindName_Stub(
1964 ITypeInfo** ppTInfo,
1969 FIXME("not implemented\n");
1973 void CALLBACK ITypeLib_ReleaseTLibAttr_Proxy(
1975 TLIBATTR* pTLibAttr)
1977 TRACE("(%p, %p)\n", This, pTLibAttr);
1978 CoTaskMemFree(pTLibAttr);
1981 HRESULT __RPC_STUB ITypeLib_ReleaseTLibAttr_Stub(
1984 TRACE("nothing to do\n");
1991 HRESULT CALLBACK ITypeLib2_GetLibStatistics_Proxy(
1993 ULONG* pcUniqueNames,
1994 ULONG* pcchUniqueNames)
1996 FIXME("not implemented\n");
2000 HRESULT __RPC_STUB ITypeLib2_GetLibStatistics_Stub(
2002 ULONG* pcUniqueNames,
2003 ULONG* pcchUniqueNames)
2005 FIXME("not implemented\n");
2009 HRESULT CALLBACK ITypeLib2_GetDocumentation2_Proxy(
2013 BSTR* pbstrHelpString,
2014 DWORD* pdwHelpStringContext,
2015 BSTR* pbstrHelpStringDll)
2017 FIXME("not implemented\n");
2021 HRESULT __RPC_STUB ITypeLib2_GetDocumentation2_Stub(
2026 BSTR* pbstrHelpString,
2027 DWORD* pdwHelpStringContext,
2028 BSTR* pbstrHelpStringDll)
2030 FIXME("not implemented\n");
2034 HRESULT CALLBACK IPropertyBag_Read_Proxy(
2036 LPCOLESTR pszPropName,
2038 IErrorLog *pErrorLog)
2040 FIXME("not implemented\n");
2044 HRESULT __RPC_STUB IPropertyBag_Read_Stub(
2046 LPCOLESTR pszPropName,
2048 IErrorLog *pErrorLog,
2052 FIXME("not implemented\n");
2056 /* call_as/local stubs for ocidl.idl */
2058 HRESULT CALLBACK IClassFactory2_CreateInstanceLic_Proxy(
2059 IClassFactory2* This,
2060 IUnknown *pUnkOuter,
2061 IUnknown *pUnkReserved,
2066 FIXME("not implemented\n");
2070 HRESULT __RPC_STUB IClassFactory2_CreateInstanceLic_Stub(
2071 IClassFactory2* This,
2076 FIXME("not implemented\n");
2080 HRESULT CALLBACK IEnumConnections_Next_Proxy(
2081 IEnumConnections* This,
2086 FIXME("not implemented\n");
2090 HRESULT __RPC_STUB IEnumConnections_Next_Stub(
2091 IEnumConnections* This,
2096 FIXME("not implemented\n");
2100 HRESULT CALLBACK IEnumConnectionPoints_Next_Proxy(
2101 IEnumConnectionPoints* This,
2103 LPCONNECTIONPOINT *ppCP,
2106 FIXME("not implemented\n");
2110 HRESULT __RPC_STUB IEnumConnectionPoints_Next_Stub(
2111 IEnumConnectionPoints* This,
2113 LPCONNECTIONPOINT *ppCP,
2116 FIXME("not implemented\n");
2120 HRESULT CALLBACK IPersistMemory_Load_Proxy(
2121 IPersistMemory* This,
2125 FIXME("not implemented\n");
2129 HRESULT __RPC_STUB IPersistMemory_Load_Stub(
2130 IPersistMemory* This,
2134 FIXME("not implemented\n");
2138 HRESULT CALLBACK IPersistMemory_Save_Proxy(
2139 IPersistMemory* This,
2144 FIXME("not implemented\n");
2148 HRESULT __RPC_STUB IPersistMemory_Save_Stub(
2149 IPersistMemory* This,
2154 FIXME("not implemented\n");
2158 void CALLBACK IAdviseSinkEx_OnViewStatusChange_Proxy(
2159 IAdviseSinkEx* This,
2162 FIXME("not implemented\n");
2165 HRESULT __RPC_STUB IAdviseSinkEx_OnViewStatusChange_Stub(
2166 IAdviseSinkEx* This,
2169 FIXME("not implemented\n");
2173 HRESULT CALLBACK IEnumOleUndoUnits_Next_Proxy(
2174 IEnumOleUndoUnits* This,
2176 IOleUndoUnit **rgElt,
2177 ULONG *pcEltFetched)
2179 FIXME("not implemented\n");
2183 HRESULT __RPC_STUB IEnumOleUndoUnits_Next_Stub(
2184 IEnumOleUndoUnits* This,
2186 IOleUndoUnit **rgElt,
2187 ULONG *pcEltFetched)
2189 FIXME("not implemented\n");
2193 HRESULT CALLBACK IQuickActivate_QuickActivate_Proxy(
2194 IQuickActivate* This,
2195 QACONTAINER *pQaContainer,
2196 QACONTROL *pQaControl)
2198 FIXME("not implemented\n");
2202 HRESULT __RPC_STUB IQuickActivate_QuickActivate_Stub(
2203 IQuickActivate* This,
2204 QACONTAINER *pQaContainer,
2205 QACONTROL *pQaControl)
2207 FIXME("not implemented\n");