d3dxof: Make SaveTemplates stub return DXFILE_OK.
[wine/multimedia.git] / dlls / oleaut32 / usrmarshal.c
blob2414a9ec8e30c46cd7ec371c65e7cb5a55813fc9
1 /*
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
22 #include <stdarg.h>
23 #include <string.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winerror.h"
35 #include "ole2.h"
36 #include "oleauto.h"
37 #include "typelib.h"
38 #include "ocidl.h"
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, ");
52 else
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;
81 switch(pstg->flags)
83 case CLS_LIBATTR:
84 ITypeLib_ReleaseTLibAttr((ITypeLib*)pstg->pInterface, *(TLIBATTR**)pstg->pStorage);
85 break;
86 case CLS_TYPEATTR:
87 ITypeInfo_ReleaseTypeAttr((ITypeInfo*)pstg->pInterface, *(TYPEATTR**)pstg->pStorage);
88 break;
89 case CLS_FUNCDESC:
90 ITypeInfo_ReleaseFuncDesc((ITypeInfo*)pstg->pInterface, *(FUNCDESC**)pstg->pStorage);
91 break;
92 case CLS_VARDESC:
93 ITypeInfo_ReleaseVarDesc((ITypeInfo*)pstg->pInterface, *(VARDESC**)pstg->pStorage);
94 break;
96 default:
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)
116 /* Nothing to do */
119 /* BSTR */
121 typedef struct
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 */
126 } bstr_wire_t;
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);
135 return Start;
138 unsigned char * WINAPI BSTR_UserMarshal(ULONG *pFlags, unsigned char *Buffer, BSTR *pstr)
140 bstr_wire_t *header;
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;
149 if (*pstr)
151 header->byte_len = len;
152 memcpy(header + 1, *pstr, header->len * 2);
154 else
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)
162 bstr_wire_t *header;
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 if (header->byte_len == 0xffffffff)
172 SysFreeString(*pstr);
173 *pstr = NULL;
175 else SysReAllocStringLen( pstr, (OLECHAR *)(header + 1), header->len );
177 if (*pstr) TRACE("string=%s\n", debugstr_w(*pstr));
178 return Buffer + sizeof(*header) + sizeof(OLECHAR) * header->len;
181 void WINAPI BSTR_UserFree(ULONG *pFlags, BSTR *pstr)
183 TRACE("(%x,%p) => %p\n", *pFlags, pstr, *pstr);
184 SysFreeString(*pstr);
185 *pstr = NULL;
188 /* VARIANT */
190 typedef struct
192 DWORD clSize;
193 DWORD rpcReserved;
194 USHORT vt;
195 USHORT wReserved1;
196 USHORT wReserved2;
197 USHORT wReserved3;
198 DWORD switch_is;
199 } variant_wire_t;
201 static unsigned int get_type_size(ULONG *pFlags, VARTYPE vt)
203 if (vt & VT_ARRAY) return 4;
205 switch (vt & ~VT_BYREF) {
206 case VT_EMPTY:
207 case VT_NULL:
208 return 0;
209 case VT_I1:
210 case VT_UI1:
211 return sizeof(CHAR);
212 case VT_I2:
213 case VT_UI2:
214 return sizeof(SHORT);
215 case VT_I4:
216 case VT_UI4:
217 return sizeof(LONG);
218 case VT_INT:
219 case VT_UINT:
220 return sizeof(INT);
221 case VT_R4:
222 return sizeof(FLOAT);
223 case VT_R8:
224 return sizeof(DOUBLE);
225 case VT_BOOL:
226 return sizeof(VARIANT_BOOL);
227 case VT_ERROR:
228 return sizeof(SCODE);
229 case VT_DATE:
230 return sizeof(DATE);
231 case VT_CY:
232 return sizeof(CY);
233 case VT_DECIMAL:
234 return sizeof(DECIMAL);
235 case VT_BSTR:
236 return sizeof(ULONG);
237 case VT_VARIANT:
238 return sizeof(VARIANT);
239 case VT_UNKNOWN:
240 case VT_DISPATCH:
241 case VT_RECORD:
242 return 0;
243 default:
244 FIXME("unhandled VT %d\n", vt);
245 return 0;
249 static unsigned int get_type_alignment(ULONG *pFlags, VARTYPE vt)
251 unsigned int size = get_type_size(pFlags, vt);
252 if(vt & VT_BYREF) return 3;
253 if(size == 0) return 0;
254 if(size <= 4) return size - 1;
255 return 7;
258 static unsigned interface_variant_size(const ULONG *pFlags, REFIID riid, IUnknown *punk)
260 ULONG size = 0;
261 HRESULT hr;
263 if (punk)
265 hr = CoGetMarshalSizeMax(&size, riid, punk, LOWORD(*pFlags), NULL, MSHLFLAGS_NORMAL);
266 if (FAILED(hr))
268 ERR("interface variant buffer size calculation failed, HRESULT=0x%x\n", hr);
269 return 0;
272 size += sizeof(ULONG); /* we have to store the buffersize in the stream */
273 TRACE("wire-size extra of interface variant is %d\n", size);
274 return size;
277 static ULONG wire_extra_user_size(ULONG *pFlags, ULONG Start, VARIANT *pvar)
279 if (V_ISARRAY(pvar))
281 if (V_ISBYREF(pvar))
282 return LPSAFEARRAY_UserSize(pFlags, Start, V_ARRAYREF(pvar));
283 else
284 return LPSAFEARRAY_UserSize(pFlags, Start, &V_ARRAY(pvar));
287 switch (V_VT(pvar)) {
288 case VT_BSTR:
289 return BSTR_UserSize(pFlags, Start, &V_BSTR(pvar));
290 case VT_BSTR | VT_BYREF:
291 return BSTR_UserSize(pFlags, Start, V_BSTRREF(pvar));
292 case VT_VARIANT | VT_BYREF:
293 return VARIANT_UserSize(pFlags, Start, V_VARIANTREF(pvar));
294 case VT_UNKNOWN:
295 return Start + interface_variant_size(pFlags, &IID_IUnknown, V_UNKNOWN(pvar));
296 case VT_UNKNOWN | VT_BYREF:
297 return Start + interface_variant_size(pFlags, &IID_IUnknown, *V_UNKNOWNREF(pvar));
298 case VT_DISPATCH:
299 return Start + interface_variant_size(pFlags, &IID_IDispatch, (IUnknown*)V_DISPATCH(pvar));
300 case VT_DISPATCH | VT_BYREF:
301 return Start + interface_variant_size(pFlags, &IID_IDispatch, (IUnknown*)*V_DISPATCHREF(pvar));
302 case VT_RECORD:
303 FIXME("wire-size record\n");
304 return Start;
305 case VT_SAFEARRAY:
306 case VT_SAFEARRAY | VT_BYREF:
307 FIXME("wire-size safearray: shouldn't be marshaling this\n");
308 return Start;
309 default:
310 return Start;
314 /* helper: called for VT_DISPATCH variants to marshal the IDispatch* into the buffer. returns Buffer on failure, new position otherwise */
315 static unsigned char* interface_variant_marshal(const ULONG *pFlags, unsigned char *Buffer,
316 REFIID riid, IUnknown *punk)
318 IStream *working;
319 HGLOBAL working_mem;
320 void *working_memlocked;
321 unsigned char *oldpos;
322 ULONG size;
323 HRESULT hr;
325 TRACE("pFlags=%d, Buffer=%p, pUnk=%p\n", *pFlags, Buffer, punk);
327 if(!punk)
329 memset(Buffer, 0, sizeof(ULONG));
330 return Buffer + sizeof(ULONG);
333 oldpos = Buffer;
335 /* CoMarshalInterface needs a stream, whereas at this level we are operating in terms of buffers.
336 * We create a stream on an HGLOBAL, so we can simply do a memcpy to move it to the buffer.
337 * in rpcrt4/ndr_ole.c, a simple IStream implementation is wrapped around the buffer object,
338 * but that would be overkill here, hence this implementation. We save the size because the unmarshal
339 * code has no way to know how long the marshalled buffer is. */
341 size = interface_variant_size(pFlags, riid, punk);
343 working_mem = GlobalAlloc(0, size);
344 if (!working_mem) return oldpos;
346 hr = CreateStreamOnHGlobal(working_mem, TRUE, &working);
347 if (hr != S_OK) {
348 GlobalFree(working_mem);
349 return oldpos;
352 hr = CoMarshalInterface(working, riid, punk, LOWORD(*pFlags), NULL, MSHLFLAGS_NORMAL);
353 if (hr != S_OK) {
354 IStream_Release(working); /* this also releases the hglobal */
355 return oldpos;
358 working_memlocked = GlobalLock(working_mem);
359 memcpy(Buffer, &size, sizeof(ULONG)); /* copy the buffersize */
360 memcpy(Buffer + sizeof(ULONG), working_memlocked, size - sizeof(ULONG));
361 GlobalUnlock(working_mem);
363 IStream_Release(working);
365 /* size includes the ULONG for the size written above */
366 TRACE("done, size=%d\n", size);
367 return Buffer + size;
370 /* helper: called for VT_DISPATCH / VT_UNKNOWN variants to unmarshal the buffer. returns Buffer on failure, new position otherwise */
371 static unsigned char *interface_variant_unmarshal(const ULONG *pFlags, unsigned char *Buffer,
372 REFIID riid, IUnknown **ppunk)
374 IStream *working;
375 HGLOBAL working_mem;
376 void *working_memlocked;
377 unsigned char *oldpos;
378 ULONG size;
379 HRESULT hr;
381 TRACE("pFlags=%d, Buffer=%p, ppUnk=%p\n", *pFlags, Buffer, ppunk);
383 oldpos = Buffer;
385 /* get the buffersize */
386 memcpy(&size, Buffer, sizeof(ULONG));
387 TRACE("buffersize=%d\n", size);
389 if(!size)
391 *ppunk = NULL;
392 return Buffer + sizeof(ULONG);
395 working_mem = GlobalAlloc(0, size);
396 if (!working_mem) return oldpos;
398 hr = CreateStreamOnHGlobal(working_mem, TRUE, &working);
399 if (hr != S_OK) {
400 GlobalFree(working_mem);
401 return oldpos;
404 working_memlocked = GlobalLock(working_mem);
406 /* now we copy the contents of the marshalling buffer to working_memlocked, unlock it, and demarshal the stream */
407 memcpy(working_memlocked, Buffer + sizeof(ULONG), size);
408 GlobalUnlock(working_mem);
410 hr = CoUnmarshalInterface(working, riid, (void**)ppunk);
411 if (hr != S_OK) {
412 IStream_Release(working);
413 return oldpos;
416 IStream_Release(working); /* this also frees the underlying hglobal */
418 /* size includes the ULONG for the size written above */
419 TRACE("done, processed=%d bytes\n", size);
420 return Buffer + size;
424 ULONG WINAPI VARIANT_UserSize(ULONG *pFlags, ULONG Start, VARIANT *pvar)
426 int align;
427 TRACE("(%x,%d,%p)\n", *pFlags, Start, pvar);
428 TRACE("vt=%04x\n", V_VT(pvar));
430 ALIGN_LENGTH(Start, 7);
431 Start += sizeof(variant_wire_t);
432 if(V_VT(pvar) & VT_BYREF)
433 Start += 4;
435 align = get_type_alignment(pFlags, V_VT(pvar));
436 ALIGN_LENGTH(Start, align);
437 if(V_VT(pvar) == (VT_VARIANT | VT_BYREF))
438 Start += 4;
439 else
440 Start += get_type_size(pFlags, V_VT(pvar));
441 Start = wire_extra_user_size(pFlags, Start, pvar);
443 TRACE("returning %d\n", Start);
444 return Start;
447 unsigned char * WINAPI VARIANT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, VARIANT *pvar)
449 variant_wire_t *header;
450 ULONG type_size;
451 int align;
452 unsigned char *Pos;
454 TRACE("(%x,%p,%p)\n", *pFlags, Buffer, pvar);
455 TRACE("vt=%04x\n", V_VT(pvar));
457 ALIGN_POINTER(Buffer, 7);
459 header = (variant_wire_t *)Buffer;
461 header->clSize = 0; /* fixed up at the end */
462 header->rpcReserved = 0;
463 header->vt = pvar->n1.n2.vt;
464 header->wReserved1 = pvar->n1.n2.wReserved1;
465 header->wReserved2 = pvar->n1.n2.wReserved2;
466 header->wReserved3 = pvar->n1.n2.wReserved3;
467 header->switch_is = pvar->n1.n2.vt;
468 if(header->switch_is & VT_ARRAY)
469 header->switch_is &= ~VT_TYPEMASK;
471 Pos = (unsigned char*)(header + 1);
472 type_size = get_type_size(pFlags, V_VT(pvar));
473 align = get_type_alignment(pFlags, V_VT(pvar));
474 ALIGN_POINTER(Pos, align);
476 if(header->vt & VT_BYREF)
478 *(DWORD *)Pos = max(type_size, 4);
479 Pos += 4;
480 if((header->vt & VT_TYPEMASK) != VT_VARIANT)
482 memcpy(Pos, pvar->n1.n2.n3.byref, type_size);
483 Pos += type_size;
485 else
487 *(DWORD*)Pos = 'U' | 's' << 8 | 'e' << 16 | 'r' << 24;
488 Pos += 4;
491 else
493 if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
494 memcpy(Pos, pvar, type_size);
495 else
496 memcpy(Pos, &pvar->n1.n2.n3, type_size);
497 Pos += type_size;
500 if(header->vt & VT_ARRAY)
502 if(header->vt & VT_BYREF)
503 Pos = LPSAFEARRAY_UserMarshal(pFlags, Pos, V_ARRAYREF(pvar));
504 else
505 Pos = LPSAFEARRAY_UserMarshal(pFlags, Pos, &V_ARRAY(pvar));
507 else
509 switch (header->vt)
511 case VT_BSTR:
512 Pos = BSTR_UserMarshal(pFlags, Pos, &V_BSTR(pvar));
513 break;
514 case VT_BSTR | VT_BYREF:
515 Pos = BSTR_UserMarshal(pFlags, Pos, V_BSTRREF(pvar));
516 break;
517 case VT_VARIANT | VT_BYREF:
518 Pos = VARIANT_UserMarshal(pFlags, Pos, V_VARIANTREF(pvar));
519 break;
520 case VT_UNKNOWN:
521 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
522 Pos = interface_variant_marshal(pFlags, Pos, &IID_IUnknown, V_UNKNOWN(pvar));
523 break;
524 case VT_UNKNOWN | VT_BYREF:
525 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
526 Pos = interface_variant_marshal(pFlags, Pos, &IID_IUnknown, *V_UNKNOWNREF(pvar));
527 break;
528 case VT_DISPATCH:
529 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
530 Pos = interface_variant_marshal(pFlags, Pos, &IID_IDispatch, (IUnknown*)V_DISPATCH(pvar));
531 break;
532 case VT_DISPATCH | VT_BYREF:
533 /* this should probably call WdtpInterfacePointer_UserMarshal in ole32.dll */
534 Pos = interface_variant_marshal(pFlags, Pos, &IID_IDispatch, (IUnknown*)*V_DISPATCHREF(pvar));
535 break;
536 case VT_RECORD:
537 FIXME("handle BRECORD by val\n");
538 break;
539 case VT_RECORD | VT_BYREF:
540 FIXME("handle BRECORD by ref\n");
541 break;
544 header->clSize = ((Pos - Buffer) + 7) >> 3;
545 TRACE("marshalled size=%d\n", header->clSize);
546 return Pos;
549 unsigned char * WINAPI VARIANT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, VARIANT *pvar)
551 variant_wire_t *header;
552 ULONG type_size;
553 int align;
554 unsigned char *Pos;
556 TRACE("(%x,%p,%p)\n", *pFlags, Buffer, pvar);
558 ALIGN_POINTER(Buffer, 7);
560 header = (variant_wire_t *)Buffer;
562 Pos = (unsigned char*)(header + 1);
563 type_size = get_type_size(pFlags, header->vt);
564 align = get_type_alignment(pFlags, header->vt);
565 ALIGN_POINTER(Pos, align);
567 if(header->vt & VT_BYREF)
569 ULONG mem_size;
570 Pos += 4;
572 switch (header->vt & ~VT_BYREF)
574 /* these types have a different memory size compared to wire size */
575 case VT_UNKNOWN:
576 case VT_DISPATCH:
577 case VT_BSTR:
578 mem_size = sizeof(void *);
579 break;
580 default:
581 mem_size = type_size;
582 break;
585 if (V_VT(pvar) != header->vt)
587 VariantClear(pvar);
588 V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
590 else if (!V_BYREF(pvar))
591 V_BYREF(pvar) = CoTaskMemAlloc(mem_size);
592 memcpy(V_BYREF(pvar), Pos, type_size);
593 if((header->vt & VT_TYPEMASK) != VT_VARIANT)
594 Pos += type_size;
595 else
596 Pos += 4;
598 else
600 VariantClear(pvar);
601 if((header->vt & VT_TYPEMASK) == VT_DECIMAL)
602 memcpy(pvar, Pos, type_size);
603 else
604 memcpy(&pvar->n1.n2.n3, Pos, type_size);
605 Pos += type_size;
608 pvar->n1.n2.vt = header->vt;
609 pvar->n1.n2.wReserved1 = header->wReserved1;
610 pvar->n1.n2.wReserved2 = header->wReserved2;
611 pvar->n1.n2.wReserved3 = header->wReserved3;
613 if(header->vt & VT_ARRAY)
615 if(header->vt & VT_BYREF)
616 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, V_ARRAYREF(pvar));
617 else
618 Pos = LPSAFEARRAY_UserUnmarshal(pFlags, Pos, &V_ARRAY(pvar));
620 else
622 switch (header->vt)
624 case VT_BSTR:
625 V_BSTR(pvar) = NULL;
626 Pos = BSTR_UserUnmarshal(pFlags, Pos, &V_BSTR(pvar));
627 break;
628 case VT_BSTR | VT_BYREF:
629 *V_BSTRREF(pvar) = NULL;
630 Pos = BSTR_UserUnmarshal(pFlags, Pos, V_BSTRREF(pvar));
631 break;
632 case VT_VARIANT | VT_BYREF:
633 Pos = VARIANT_UserUnmarshal(pFlags, Pos, V_VARIANTREF(pvar));
634 break;
635 case VT_UNKNOWN:
636 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
637 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, &V_UNKNOWN(pvar));
638 break;
639 case VT_UNKNOWN | VT_BYREF:
640 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
641 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IUnknown, V_UNKNOWNREF(pvar));
642 break;
643 case VT_DISPATCH:
644 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
645 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)&V_DISPATCH(pvar));
646 break;
647 case VT_DISPATCH | VT_BYREF:
648 /* this should probably call WdtpInterfacePointer_UserUnmarshal in ole32.dll */
649 Pos = interface_variant_unmarshal(pFlags, Pos, &IID_IDispatch, (IUnknown**)V_DISPATCHREF(pvar));
650 break;
651 case VT_RECORD:
652 FIXME("handle BRECORD by val\n");
653 break;
654 case VT_RECORD | VT_BYREF:
655 FIXME("handle BRECORD by ref\n");
656 break;
659 return Pos;
662 void WINAPI VARIANT_UserFree(ULONG *pFlags, VARIANT *pvar)
664 VARTYPE vt = V_VT(pvar);
665 PVOID ref = NULL;
667 TRACE("(%x,%p)\n", *pFlags, pvar);
668 TRACE("vt=%04x\n", V_VT(pvar));
670 if (vt & VT_BYREF) ref = pvar->n1.n2.n3.byref;
672 VariantClear(pvar);
673 if (!ref) return;
675 if(vt & VT_ARRAY)
677 if (vt & VT_BYREF)
678 LPSAFEARRAY_UserFree(pFlags, V_ARRAYREF(pvar));
679 else
680 LPSAFEARRAY_UserFree(pFlags, &V_ARRAY(pvar));
682 else
684 switch (vt)
686 case VT_BSTR | VT_BYREF:
687 BSTR_UserFree(pFlags, V_BSTRREF(pvar));
688 break;
689 case VT_VARIANT | VT_BYREF:
690 VARIANT_UserFree(pFlags, V_VARIANTREF(pvar));
691 break;
692 case VT_RECORD | VT_BYREF:
693 FIXME("handle BRECORD by ref\n");
694 break;
695 case VT_UNKNOWN | VT_BYREF:
696 case VT_DISPATCH | VT_BYREF:
697 IUnknown_Release(*V_UNKNOWNREF(pvar));
698 break;
702 CoTaskMemFree(ref);
705 /* LPSAFEARRAY */
707 /* Get the number of cells in a SafeArray */
708 static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa)
710 const SAFEARRAYBOUND* psab = psa->rgsabound;
711 USHORT cCount = psa->cDims;
712 ULONG ulNumCells = 1;
714 while (cCount--)
716 /* This is a valid bordercase. See testcases. -Marcus */
717 if (!psab->cElements)
718 return 0;
719 ulNumCells *= psab->cElements;
720 psab++;
722 return ulNumCells;
725 static inline SF_TYPE SAFEARRAY_GetUnionType(SAFEARRAY *psa)
727 VARTYPE vt;
728 HRESULT hr;
730 hr = SafeArrayGetVartype(psa, &vt);
731 if (FAILED(hr))
733 if(psa->fFeatures & FADF_VARIANT) return SF_VARIANT;
735 switch(psa->cbElements)
737 case 1: vt = VT_I1; break;
738 case 2: vt = VT_I2; break;
739 case 4: vt = VT_I4; break;
740 case 8: vt = VT_I8; break;
741 default:
742 RpcRaiseException(hr);
746 if (psa->fFeatures & FADF_HAVEIID)
747 return SF_HAVEIID;
749 switch (vt)
751 case VT_I1:
752 case VT_UI1: return SF_I1;
753 case VT_BOOL:
754 case VT_I2:
755 case VT_UI2: return SF_I2;
756 case VT_INT:
757 case VT_UINT:
758 case VT_I4:
759 case VT_UI4:
760 case VT_R4: return SF_I4;
761 case VT_DATE:
762 case VT_CY:
763 case VT_R8:
764 case VT_I8:
765 case VT_UI8: return SF_I8;
766 case VT_INT_PTR:
767 case VT_UINT_PTR: return (sizeof(UINT_PTR) == 4 ? SF_I4 : SF_I8);
768 case VT_BSTR: return SF_BSTR;
769 case VT_DISPATCH: return SF_DISPATCH;
770 case VT_VARIANT: return SF_VARIANT;
771 case VT_UNKNOWN: return SF_UNKNOWN;
772 /* Note: Return a non-zero size to indicate vt is valid. The actual size
773 * of a UDT is taken from the result of IRecordInfo_GetSize().
775 case VT_RECORD: return SF_RECORD;
776 default: return SF_ERROR;
780 static DWORD elem_wire_size(LPSAFEARRAY lpsa, SF_TYPE sftype)
782 if (sftype == SF_BSTR)
783 return sizeof(DWORD);
784 else if (sftype == SF_VARIANT)
785 return sizeof(variant_wire_t) - sizeof(DWORD);
786 else
787 return lpsa->cbElements;
790 static DWORD elem_mem_size(wireSAFEARRAY wiresa, SF_TYPE sftype)
792 if (sftype == SF_BSTR)
793 return sizeof(BSTR);
794 else if (sftype == SF_VARIANT)
795 return sizeof(VARIANT);
796 else
797 return wiresa->cbElements;
800 ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY *ppsa)
802 ULONG size = StartingSize;
804 TRACE("("); dump_user_flags(pFlags); TRACE(", %d, %p\n", StartingSize, *ppsa);
806 ALIGN_LENGTH(size, 3);
807 size += sizeof(ULONG);
808 if (*ppsa)
810 SAFEARRAY *psa = *ppsa;
811 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
812 SF_TYPE sftype;
813 HRESULT hr;
815 size += sizeof(ULONG);
816 size += 2 * sizeof(USHORT) + 2 * sizeof(ULONG);
818 sftype = SAFEARRAY_GetUnionType(psa);
819 size += sizeof(ULONG);
821 size += sizeof(ULONG);
822 size += sizeof(ULONG);
823 if (sftype == SF_HAVEIID)
824 size += sizeof(IID);
826 size += sizeof(psa->rgsabound[0]) * psa->cDims;
828 size += sizeof(ULONG);
830 switch (sftype)
832 case SF_BSTR:
834 BSTR* lpBstr;
836 for (lpBstr = psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
837 size = BSTR_UserSize(pFlags, size, lpBstr);
839 break;
841 case SF_DISPATCH:
842 case SF_UNKNOWN:
843 case SF_HAVEIID:
844 FIXME("size interfaces\n");
845 break;
846 case SF_VARIANT:
848 VARIANT* lpVariant;
850 for (lpVariant = psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
851 size = VARIANT_UserSize(pFlags, size, lpVariant);
853 break;
855 case SF_RECORD:
857 IRecordInfo* pRecInfo = NULL;
859 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
860 if (FAILED(hr))
861 RpcRaiseException(hr);
863 if (pRecInfo)
865 FIXME("size record info %p\n", pRecInfo);
867 IRecordInfo_Release(pRecInfo);
869 break;
871 case SF_I8:
872 ALIGN_LENGTH(size, 7);
873 /* fallthrough */
874 case SF_I1:
875 case SF_I2:
876 case SF_I4:
877 size += ulCellCount * psa->cbElements;
878 break;
879 default:
880 break;
885 return size;
888 unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
890 HRESULT hr;
892 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
894 ALIGN_POINTER(Buffer, 3);
895 *(ULONG *)Buffer = *ppsa ? 0x1 : 0x0;
896 Buffer += sizeof(ULONG);
897 if (*ppsa)
899 VARTYPE vt;
900 SAFEARRAY *psa = *ppsa;
901 ULONG ulCellCount = SAFEARRAY_GetCellCount(psa);
902 SAFEARRAYBOUND *bound;
903 SF_TYPE sftype;
904 GUID guid;
905 INT i;
907 sftype = SAFEARRAY_GetUnionType(psa);
909 *(ULONG *)Buffer = psa->cDims;
910 Buffer += sizeof(ULONG);
911 *(USHORT *)Buffer = psa->cDims;
912 Buffer += sizeof(USHORT);
913 *(USHORT *)Buffer = psa->fFeatures;
914 Buffer += sizeof(USHORT);
915 *(ULONG *)Buffer = elem_wire_size(psa, sftype);
916 Buffer += sizeof(ULONG);
918 hr = SafeArrayGetVartype(psa, &vt);
919 if (FAILED(hr)) vt = 0;
921 *(ULONG *)Buffer = (USHORT)psa->cLocks | (vt << 16);
922 Buffer += sizeof(ULONG);
924 *(ULONG *)Buffer = sftype;
925 Buffer += sizeof(ULONG);
927 *(ULONG *)Buffer = ulCellCount;
928 Buffer += sizeof(ULONG);
929 *(ULONG *)Buffer = psa->pvData ? 0x2 : 0x0;
930 Buffer += sizeof(ULONG);
931 if (sftype == SF_HAVEIID)
933 SafeArrayGetIID(psa, &guid);
934 memcpy(Buffer, &guid, sizeof(guid));
935 Buffer += sizeof(guid);
938 /* bounds are marshaled in opposite order comparing to storage layout */
939 bound = (SAFEARRAYBOUND*)Buffer;
940 for (i = 0; i < psa->cDims; i++)
942 memcpy(bound++, &psa->rgsabound[psa->cDims-i-1], sizeof(psa->rgsabound[0]));
944 Buffer += sizeof(psa->rgsabound[0]) * psa->cDims;
946 *(ULONG *)Buffer = ulCellCount;
947 Buffer += sizeof(ULONG);
949 if (psa->pvData)
951 switch (sftype)
953 case SF_BSTR:
955 BSTR* lpBstr;
957 for (lpBstr = psa->pvData; ulCellCount; ulCellCount--, lpBstr++)
958 Buffer = BSTR_UserMarshal(pFlags, Buffer, lpBstr);
960 break;
962 case SF_DISPATCH:
963 case SF_UNKNOWN:
964 case SF_HAVEIID:
965 FIXME("marshal interfaces\n");
966 break;
967 case SF_VARIANT:
969 VARIANT* lpVariant;
971 for (lpVariant = psa->pvData; ulCellCount; ulCellCount--, lpVariant++)
972 Buffer = VARIANT_UserMarshal(pFlags, Buffer, lpVariant);
974 break;
976 case SF_RECORD:
978 IRecordInfo* pRecInfo = NULL;
980 hr = SafeArrayGetRecordInfo(psa, &pRecInfo);
981 if (FAILED(hr))
982 RpcRaiseException(hr);
984 if (pRecInfo)
986 FIXME("write record info %p\n", pRecInfo);
988 IRecordInfo_Release(pRecInfo);
990 break;
993 case SF_I8:
994 ALIGN_POINTER(Buffer, 7);
995 /* fallthrough */
996 case SF_I1:
997 case SF_I2:
998 case SF_I4:
999 /* Just copy the data over */
1000 memcpy(Buffer, psa->pvData, ulCellCount * psa->cbElements);
1001 Buffer += ulCellCount * psa->cbElements;
1002 break;
1003 default:
1004 break;
1009 return Buffer;
1012 #define FADF_AUTOSETFLAGS (FADF_HAVEIID | FADF_RECORD | FADF_HAVEVARTYPE | \
1013 FADF_BSTR | FADF_UNKNOWN | FADF_DISPATCH | \
1014 FADF_VARIANT | FADF_CREATEVECTOR)
1016 unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
1018 ULONG ptr;
1019 wireSAFEARRAY wiresa;
1020 ULONG cDims;
1021 HRESULT hr;
1022 SF_TYPE sftype;
1023 ULONG cell_count;
1024 GUID guid;
1025 VARTYPE vt;
1026 SAFEARRAYBOUND *wiresab;
1028 TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
1030 ALIGN_POINTER(Buffer, 3);
1031 ptr = *(ULONG *)Buffer;
1032 Buffer += sizeof(ULONG);
1034 if (!ptr)
1036 *ppsa = NULL;
1038 TRACE("NULL safe array unmarshaled\n");
1040 return Buffer;
1043 cDims = *(ULONG *)Buffer;
1044 Buffer += sizeof(ULONG);
1046 wiresa = (wireSAFEARRAY)Buffer;
1047 Buffer += 2 * sizeof(USHORT) + 2 * sizeof(ULONG);
1049 if (cDims != wiresa->cDims)
1050 RpcRaiseException(RPC_S_INVALID_BOUND);
1052 /* FIXME: there should be a limit on how large cDims can be */
1054 vt = HIWORD(wiresa->cLocks);
1056 sftype = *(ULONG *)Buffer;
1057 Buffer += sizeof(ULONG);
1059 cell_count = *(ULONG *)Buffer;
1060 Buffer += sizeof(ULONG);
1061 ptr = *(ULONG *)Buffer;
1062 Buffer += sizeof(ULONG);
1063 if (sftype == SF_HAVEIID)
1065 memcpy(&guid, Buffer, sizeof(guid));
1066 Buffer += sizeof(guid);
1069 wiresab = (SAFEARRAYBOUND *)Buffer;
1070 Buffer += sizeof(wiresab[0]) * wiresa->cDims;
1072 if(vt)
1073 *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
1074 else
1076 SafeArrayAllocDescriptor(wiresa->cDims, ppsa);
1077 if(*ppsa)
1078 memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
1080 if (!*ppsa)
1081 RpcRaiseException(E_OUTOFMEMORY);
1083 /* be careful about which flags we set since they could be a security
1084 * risk */
1085 (*ppsa)->fFeatures &= FADF_AUTOSETFLAGS;
1086 (*ppsa)->fFeatures |= (wiresa->fFeatures & ~(FADF_AUTOSETFLAGS));
1087 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1088 (*ppsa)->cbElements = elem_mem_size(wiresa, sftype);
1089 (*ppsa)->cLocks = 0;
1091 /* SafeArrayCreateEx allocates the data for us, but
1092 * SafeArrayAllocDescriptor doesn't */
1093 if(!vt)
1095 hr = SafeArrayAllocData(*ppsa);
1096 if (FAILED(hr))
1097 RpcRaiseException(hr);
1100 if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
1101 RpcRaiseException(RPC_S_INVALID_BOUND);
1102 Buffer += sizeof(ULONG);
1104 if (ptr)
1106 switch (sftype)
1108 case SF_BSTR:
1110 BSTR* lpBstr;
1112 for (lpBstr = (*ppsa)->pvData; cell_count; cell_count--, lpBstr++)
1113 Buffer = BSTR_UserUnmarshal(pFlags, Buffer, lpBstr);
1115 break;
1117 case SF_DISPATCH:
1118 case SF_UNKNOWN:
1119 case SF_HAVEIID:
1120 FIXME("marshal interfaces\n");
1121 break;
1122 case SF_VARIANT:
1124 VARIANT* lpVariant;
1126 for (lpVariant = (*ppsa)->pvData; cell_count; cell_count--, lpVariant++)
1127 Buffer = VARIANT_UserUnmarshal(pFlags, Buffer, lpVariant);
1129 break;
1131 case SF_RECORD:
1133 FIXME("set record info\n");
1135 break;
1138 case SF_I8:
1139 ALIGN_POINTER(Buffer, 7);
1140 /* fallthrough */
1141 case SF_I1:
1142 case SF_I2:
1143 case SF_I4:
1144 /* Just copy the data over */
1145 memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
1146 Buffer += cell_count * (*ppsa)->cbElements;
1147 break;
1148 default:
1149 break;
1153 TRACE("safe array unmarshaled: %p\n", *ppsa);
1155 return Buffer;
1158 void WINAPI LPSAFEARRAY_UserFree(ULONG *pFlags, LPSAFEARRAY *ppsa)
1160 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *ppsa);
1162 SafeArrayDestroy(*ppsa);
1166 ULONG WINAPI HFONT_UserSize(ULONG *pFlags, ULONG Start, HFONT *phfont)
1168 FIXME(":stub\n");
1169 return 0;
1172 unsigned char * WINAPI HFONT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1174 FIXME(":stub\n");
1175 return NULL;
1178 unsigned char * WINAPI HFONT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1180 FIXME(":stub\n");
1181 return NULL;
1184 void WINAPI HFONT_UserFree(ULONG *pFlags, HFONT *phfont)
1186 FIXME(":stub\n");
1187 return;
1191 /* IDispatch */
1192 /* exactly how Invoke is marshalled is not very clear to me yet,
1193 * but the way I've done it seems to work for me */
1195 HRESULT CALLBACK IDispatch_Invoke_Proxy(
1196 IDispatch* This,
1197 DISPID dispIdMember,
1198 REFIID riid,
1199 LCID lcid,
1200 WORD wFlags,
1201 DISPPARAMS* pDispParams,
1202 VARIANT* pVarResult,
1203 EXCEPINFO* pExcepInfo,
1204 UINT* puArgErr)
1206 HRESULT hr;
1207 VARIANT VarResult;
1208 UINT* rgVarRefIdx = NULL;
1209 VARIANTARG* rgVarRef = NULL;
1210 UINT u, cVarRef;
1211 UINT uArgErr;
1212 EXCEPINFO ExcepInfo;
1214 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This,
1215 dispIdMember, debugstr_guid(riid),
1216 lcid, wFlags, pDispParams, pVarResult,
1217 pExcepInfo, puArgErr);
1219 /* [out] args can't be null, use dummy vars if needed */
1220 if (!pVarResult) pVarResult = &VarResult;
1221 if (!puArgErr) puArgErr = &uArgErr;
1222 if (!pExcepInfo) pExcepInfo = &ExcepInfo;
1224 /* count by-ref args */
1225 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1226 VARIANTARG* arg = &pDispParams->rgvarg[u];
1227 if (V_ISBYREF(arg)) {
1228 cVarRef++;
1231 if (cVarRef) {
1232 rgVarRefIdx = CoTaskMemAlloc(sizeof(UINT)*cVarRef);
1233 rgVarRef = CoTaskMemAlloc(sizeof(VARIANTARG)*cVarRef);
1234 /* make list of by-ref args */
1235 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1236 VARIANTARG* arg = &pDispParams->rgvarg[u];
1237 if (V_ISBYREF(arg)) {
1238 rgVarRefIdx[cVarRef] = u;
1239 VariantInit(&rgVarRef[cVarRef]);
1240 VariantCopy(&rgVarRef[cVarRef], arg);
1241 VariantClear(arg);
1242 cVarRef++;
1245 } else {
1246 /* [out] args still can't be null,
1247 * but we can point these anywhere in this case,
1248 * since they won't be written to when cVarRef is 0 */
1249 rgVarRefIdx = puArgErr;
1250 rgVarRef = pVarResult;
1252 TRACE("passed by ref: %d args\n", cVarRef);
1253 hr = IDispatch_RemoteInvoke_Proxy(This,
1254 dispIdMember,
1255 riid,
1256 lcid,
1257 wFlags,
1258 pDispParams,
1259 pVarResult,
1260 pExcepInfo,
1261 puArgErr,
1262 cVarRef,
1263 rgVarRefIdx,
1264 rgVarRef);
1265 if (cVarRef) {
1266 for (u=0; u<cVarRef; u++) {
1267 unsigned i = rgVarRefIdx[u];
1268 VariantCopy(&pDispParams->rgvarg[i],
1269 &rgVarRef[u]);
1270 VariantClear(&rgVarRef[u]);
1272 CoTaskMemFree(rgVarRef);
1273 CoTaskMemFree(rgVarRefIdx);
1276 if(pExcepInfo == &ExcepInfo)
1278 SysFreeString(pExcepInfo->bstrSource);
1279 SysFreeString(pExcepInfo->bstrDescription);
1280 SysFreeString(pExcepInfo->bstrHelpFile);
1282 return hr;
1285 HRESULT __RPC_STUB IDispatch_Invoke_Stub(
1286 IDispatch* This,
1287 DISPID dispIdMember,
1288 REFIID riid,
1289 LCID lcid,
1290 DWORD dwFlags,
1291 DISPPARAMS* pDispParams,
1292 VARIANT* pVarResult,
1293 EXCEPINFO* pExcepInfo,
1294 UINT* pArgErr,
1295 UINT cVarRef,
1296 UINT* rgVarRefIdx,
1297 VARIANTARG* rgVarRef)
1299 HRESULT hr = S_OK;
1300 VARIANTARG *rgvarg, *arg;
1301 UINT u;
1303 /* initialize out parameters, so that they can be marshalled
1304 * in case the real Invoke doesn't initialize them */
1305 VariantInit(pVarResult);
1306 memset(pExcepInfo, 0, sizeof(*pExcepInfo));
1307 *pArgErr = 0;
1309 /* let the real Invoke operate on a copy of the in parameters,
1310 * so we don't risk losing pointers to allocated memory */
1311 rgvarg = pDispParams->rgvarg;
1312 arg = CoTaskMemAlloc(sizeof(VARIANTARG)*pDispParams->cArgs);
1313 if (!arg) return E_OUTOFMEMORY;
1315 /* init all args so we can call VariantClear on all the args if the copy
1316 * below fails */
1317 for (u = 0; u < pDispParams->cArgs; u++)
1318 VariantInit(&arg[u]);
1320 for (u = 0; u < pDispParams->cArgs; u++) {
1321 hr = VariantCopy(&arg[u], &rgvarg[u]);
1322 if (FAILED(hr))
1323 break;
1326 if (SUCCEEDED(hr)) {
1327 /* copy ref args to arg array */
1328 for (u=0; u<cVarRef; u++) {
1329 unsigned i = rgVarRefIdx[u];
1330 VariantCopy(&arg[i], &rgVarRef[u]);
1333 pDispParams->rgvarg = arg;
1335 hr = IDispatch_Invoke(This,
1336 dispIdMember,
1337 riid,
1338 lcid,
1339 dwFlags,
1340 pDispParams,
1341 pVarResult,
1342 pExcepInfo,
1343 pArgErr);
1345 /* copy ref args from arg array */
1346 for (u=0; u<cVarRef; u++) {
1347 unsigned i = rgVarRefIdx[u];
1348 VariantCopy(&rgVarRef[u], &arg[i]);
1352 /* clear the duplicate argument list */
1353 for (u=0; u<pDispParams->cArgs; u++)
1354 VariantClear(&arg[u]);
1356 pDispParams->rgvarg = rgvarg;
1357 CoTaskMemFree(arg);
1359 return hr;
1362 /* IEnumVARIANT */
1364 HRESULT CALLBACK IEnumVARIANT_Next_Proxy(
1365 IEnumVARIANT* This,
1366 ULONG celt,
1367 VARIANT* rgVar,
1368 ULONG* pCeltFetched)
1370 ULONG fetched;
1371 if (!pCeltFetched)
1372 pCeltFetched = &fetched;
1373 return IEnumVARIANT_RemoteNext_Proxy(This,
1374 celt,
1375 rgVar,
1376 pCeltFetched);
1379 HRESULT __RPC_STUB IEnumVARIANT_Next_Stub(
1380 IEnumVARIANT* This,
1381 ULONG celt,
1382 VARIANT* rgVar,
1383 ULONG* pCeltFetched)
1385 HRESULT hr;
1386 *pCeltFetched = 0;
1387 hr = IEnumVARIANT_Next(This,
1388 celt,
1389 rgVar,
1390 pCeltFetched);
1391 if (hr == S_OK) *pCeltFetched = celt;
1392 return hr;
1395 /* TypeInfo related freers */
1397 static void free_embedded_typedesc(TYPEDESC *tdesc);
1398 static void free_embedded_arraydesc(ARRAYDESC *adesc)
1400 switch(adesc->tdescElem.vt)
1402 case VT_PTR:
1403 case VT_SAFEARRAY:
1404 free_embedded_typedesc(adesc->tdescElem.u.lptdesc);
1405 CoTaskMemFree(adesc->tdescElem.u.lptdesc);
1406 break;
1407 case VT_CARRAY:
1408 free_embedded_arraydesc(adesc->tdescElem.u.lpadesc);
1409 CoTaskMemFree(adesc->tdescElem.u.lpadesc);
1410 break;
1414 static void free_embedded_typedesc(TYPEDESC *tdesc)
1416 switch(tdesc->vt)
1418 case VT_PTR:
1419 case VT_SAFEARRAY:
1420 free_embedded_typedesc(tdesc->u.lptdesc);
1421 CoTaskMemFree(tdesc->u.lptdesc);
1422 break;
1423 case VT_CARRAY:
1424 free_embedded_arraydesc(tdesc->u.lpadesc);
1425 CoTaskMemFree(tdesc->u.lpadesc);
1426 break;
1430 static void free_embedded_elemdesc(ELEMDESC *edesc)
1432 free_embedded_typedesc(&edesc->tdesc);
1433 if(edesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT)
1434 CoTaskMemFree(edesc->u.paramdesc.pparamdescex);
1437 /* ITypeComp */
1439 HRESULT CALLBACK ITypeComp_Bind_Proxy(
1440 ITypeComp* This,
1441 LPOLESTR szName,
1442 ULONG lHashVal,
1443 WORD wFlags,
1444 ITypeInfo** ppTInfo,
1445 DESCKIND* pDescKind,
1446 BINDPTR* pBindPtr)
1448 FIXME("not implemented\n");
1449 return E_FAIL;
1452 HRESULT __RPC_STUB ITypeComp_Bind_Stub(
1453 ITypeComp* This,
1454 LPOLESTR szName,
1455 ULONG lHashVal,
1456 WORD wFlags,
1457 ITypeInfo** ppTInfo,
1458 DESCKIND* pDescKind,
1459 LPFUNCDESC* ppFuncDesc,
1460 LPVARDESC* ppVarDesc,
1461 ITypeComp** ppTypeComp,
1462 CLEANLOCALSTORAGE* pDummy)
1464 FIXME("not implemented\n");
1465 return E_FAIL;
1468 HRESULT CALLBACK ITypeComp_BindType_Proxy(
1469 ITypeComp* This,
1470 LPOLESTR szName,
1471 ULONG lHashVal,
1472 ITypeInfo** ppTInfo,
1473 ITypeComp** ppTComp)
1475 FIXME("not implemented\n");
1476 return E_FAIL;
1479 HRESULT __RPC_STUB ITypeComp_BindType_Stub(
1480 ITypeComp* This,
1481 LPOLESTR szName,
1482 ULONG lHashVal,
1483 ITypeInfo** ppTInfo)
1485 FIXME("not implemented\n");
1486 return E_FAIL;
1489 /* ITypeInfo */
1491 HRESULT CALLBACK ITypeInfo_GetTypeAttr_Proxy(
1492 ITypeInfo* This,
1493 TYPEATTR** ppTypeAttr)
1496 CLEANLOCALSTORAGE stg;
1497 TRACE("(%p, %p)\n", This, ppTypeAttr);
1499 stg.flags = 0;
1500 stg.pStorage = NULL;
1501 stg.pInterface = NULL;
1503 return ITypeInfo_RemoteGetTypeAttr_Proxy(This, ppTypeAttr, &stg);
1506 HRESULT __RPC_STUB ITypeInfo_GetTypeAttr_Stub(
1507 ITypeInfo* This,
1508 LPTYPEATTR* ppTypeAttr,
1509 CLEANLOCALSTORAGE* pDummy)
1511 HRESULT hr;
1512 TRACE("(%p, %p)\n", This, ppTypeAttr);
1514 hr = ITypeInfo_GetTypeAttr(This, ppTypeAttr);
1515 if(hr != S_OK)
1516 return hr;
1518 pDummy->flags = CLS_TYPEATTR;
1519 ITypeInfo_AddRef(This);
1520 pDummy->pInterface = (IUnknown*)This;
1521 pDummy->pStorage = ppTypeAttr;
1522 return hr;
1525 HRESULT CALLBACK ITypeInfo_GetFuncDesc_Proxy(
1526 ITypeInfo* This,
1527 UINT index,
1528 FUNCDESC** ppFuncDesc)
1530 CLEANLOCALSTORAGE stg;
1531 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1533 stg.flags = 0;
1534 stg.pStorage = NULL;
1535 stg.pInterface = NULL;
1537 return ITypeInfo_RemoteGetFuncDesc_Proxy(This, index, ppFuncDesc, &stg);
1540 HRESULT __RPC_STUB ITypeInfo_GetFuncDesc_Stub(
1541 ITypeInfo* This,
1542 UINT index,
1543 LPFUNCDESC* ppFuncDesc,
1544 CLEANLOCALSTORAGE* pDummy)
1546 HRESULT hr;
1547 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1549 hr = ITypeInfo_GetFuncDesc(This, index, ppFuncDesc);
1550 if(hr != S_OK)
1551 return hr;
1553 pDummy->flags = CLS_FUNCDESC;
1554 ITypeInfo_AddRef(This);
1555 pDummy->pInterface = (IUnknown*)This;
1556 pDummy->pStorage = ppFuncDesc;
1557 return hr;
1560 HRESULT CALLBACK ITypeInfo_GetVarDesc_Proxy(
1561 ITypeInfo* This,
1562 UINT index,
1563 VARDESC** ppVarDesc)
1565 CLEANLOCALSTORAGE stg;
1566 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1568 stg.flags = 0;
1569 stg.pStorage = NULL;
1570 stg.pInterface = NULL;
1572 return ITypeInfo_RemoteGetVarDesc_Proxy(This, index, ppVarDesc, &stg);
1575 HRESULT __RPC_STUB ITypeInfo_GetVarDesc_Stub(
1576 ITypeInfo* This,
1577 UINT index,
1578 LPVARDESC* ppVarDesc,
1579 CLEANLOCALSTORAGE* pDummy)
1581 HRESULT hr;
1582 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1584 hr = ITypeInfo_GetVarDesc(This, index, ppVarDesc);
1585 if(hr != S_OK)
1586 return hr;
1588 pDummy->flags = CLS_VARDESC;
1589 ITypeInfo_AddRef(This);
1590 pDummy->pInterface = (IUnknown*)This;
1591 pDummy->pStorage = ppVarDesc;
1592 return hr;
1595 HRESULT CALLBACK ITypeInfo_GetNames_Proxy(
1596 ITypeInfo* This,
1597 MEMBERID memid,
1598 BSTR* rgBstrNames,
1599 UINT cMaxNames,
1600 UINT* pcNames)
1602 TRACE("(%p, %08x, %p, %d, %p)\n", This, memid, rgBstrNames, cMaxNames, pcNames);
1604 return ITypeInfo_RemoteGetNames_Proxy(This, memid, rgBstrNames, cMaxNames, pcNames);
1607 HRESULT __RPC_STUB ITypeInfo_GetNames_Stub(
1608 ITypeInfo* This,
1609 MEMBERID memid,
1610 BSTR* rgBstrNames,
1611 UINT cMaxNames,
1612 UINT* pcNames)
1614 TRACE("(%p, %08x, %p, %d, %p)\n", This, memid, rgBstrNames, cMaxNames, pcNames);
1616 return ITypeInfo_GetNames(This, memid, rgBstrNames, cMaxNames, pcNames);
1619 HRESULT CALLBACK ITypeInfo_GetIDsOfNames_Proxy(
1620 ITypeInfo* This,
1621 LPOLESTR* rgszNames,
1622 UINT cNames,
1623 MEMBERID* pMemId)
1625 FIXME("not implemented\n");
1626 return E_FAIL;
1629 HRESULT __RPC_STUB ITypeInfo_GetIDsOfNames_Stub(
1630 ITypeInfo* This)
1632 FIXME("not implemented\n");
1633 return E_FAIL;
1636 HRESULT CALLBACK ITypeInfo_Invoke_Proxy(
1637 ITypeInfo* This,
1638 PVOID pvInstance,
1639 MEMBERID memid,
1640 WORD wFlags,
1641 DISPPARAMS* pDispParams,
1642 VARIANT* pVarResult,
1643 EXCEPINFO* pExcepInfo,
1644 UINT* puArgErr)
1646 FIXME("not implemented\n");
1647 return E_FAIL;
1650 HRESULT __RPC_STUB ITypeInfo_Invoke_Stub(
1651 ITypeInfo* This)
1653 FIXME("not implemented\n");
1654 return E_FAIL;
1657 HRESULT CALLBACK ITypeInfo_GetDocumentation_Proxy(ITypeInfo *This, MEMBERID memid,
1658 BSTR *name, BSTR *doc_string,
1659 DWORD *help_context, BSTR *help_file)
1661 DWORD dummy_help_context, flags = 0;
1662 BSTR dummy_name, dummy_doc_string, dummy_help_file;
1663 HRESULT hr;
1664 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This, memid, name, doc_string, help_context, help_file);
1666 if(!name) name = &dummy_name;
1667 else flags = 1;
1669 if(!doc_string) doc_string = &dummy_doc_string;
1670 else flags |= 2;
1672 if(!help_context) help_context = &dummy_help_context;
1673 else flags |= 4;
1675 if(!help_file) help_file = &dummy_help_file;
1676 else flags |= 8;
1678 hr = ITypeInfo_RemoteGetDocumentation_Proxy(This, memid, flags, name, doc_string, help_context, help_file);
1680 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1682 return hr;
1685 HRESULT __RPC_STUB ITypeInfo_GetDocumentation_Stub(ITypeInfo *This, MEMBERID memid,
1686 DWORD flags, BSTR *name, BSTR *doc_string,
1687 DWORD *help_context, BSTR *help_file)
1689 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This, memid, flags, name, doc_string, help_context, help_file);
1691 *name = *doc_string = *help_file = NULL;
1692 *help_context = 0;
1694 if(!(flags & 1)) name = NULL;
1695 if(!(flags & 2)) doc_string = NULL;
1696 if(!(flags & 4)) help_context = NULL;
1697 if(!(flags & 8)) help_file = NULL;
1699 return ITypeInfo_GetDocumentation(This, memid, name, doc_string, help_context, help_file);
1702 HRESULT CALLBACK ITypeInfo_GetDllEntry_Proxy(ITypeInfo *This, MEMBERID memid,
1703 INVOKEKIND invkind, BSTR *dll_name,
1704 BSTR* name, WORD *ordinal)
1706 DWORD flags = 0;
1707 BSTR dummy_dll_name, dummy_name;
1708 WORD dummy_ordinal;
1709 HRESULT hr;
1710 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This, memid, invkind, dll_name, name, ordinal);
1712 if(!dll_name) dll_name = &dummy_dll_name;
1713 else flags = 1;
1715 if(!name) name = &dummy_name;
1716 else flags |= 2;
1718 if(!ordinal) ordinal = &dummy_ordinal;
1719 else flags |= 4;
1721 hr = ITypeInfo_RemoteGetDllEntry_Proxy(This, memid, invkind, flags, dll_name, name, ordinal);
1723 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1725 return hr;
1728 HRESULT __RPC_STUB ITypeInfo_GetDllEntry_Stub(ITypeInfo *This, MEMBERID memid,
1729 INVOKEKIND invkind, DWORD flags,
1730 BSTR *dll_name, BSTR *name,
1731 WORD *ordinal)
1733 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This, memid, invkind, dll_name, name, ordinal);
1735 *dll_name = *name = NULL;
1736 *ordinal = 0;
1738 if(!(flags & 1)) dll_name = NULL;
1739 if(!(flags & 2)) name = NULL;
1740 if(!(flags & 4)) ordinal = NULL;
1742 return ITypeInfo_GetDllEntry(This, memid, invkind, dll_name, name, ordinal);
1745 HRESULT CALLBACK ITypeInfo_AddressOfMember_Proxy(
1746 ITypeInfo* This,
1747 MEMBERID memid,
1748 INVOKEKIND invKind,
1749 PVOID* ppv)
1751 FIXME("not implemented\n");
1752 return E_FAIL;
1755 HRESULT __RPC_STUB ITypeInfo_AddressOfMember_Stub(
1756 ITypeInfo* This)
1758 FIXME("not implemented\n");
1759 return E_FAIL;
1762 HRESULT CALLBACK ITypeInfo_CreateInstance_Proxy(
1763 ITypeInfo* This,
1764 IUnknown* pUnkOuter,
1765 REFIID riid,
1766 PVOID* ppvObj)
1768 FIXME("not implemented\n");
1769 return E_FAIL;
1772 HRESULT __RPC_STUB ITypeInfo_CreateInstance_Stub(
1773 ITypeInfo* This,
1774 REFIID riid,
1775 IUnknown** ppvObj)
1777 FIXME("not implemented\n");
1778 return E_FAIL;
1781 HRESULT CALLBACK ITypeInfo_GetContainingTypeLib_Proxy(
1782 ITypeInfo* This,
1783 ITypeLib** ppTLib,
1784 UINT* pIndex)
1786 ITypeLib *pTL;
1787 UINT index;
1788 HRESULT hr;
1790 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1792 hr = ITypeInfo_RemoteGetContainingTypeLib_Proxy(This, &pTL, &index);
1793 if(SUCCEEDED(hr))
1795 if(pIndex)
1796 *pIndex = index;
1798 if(ppTLib)
1799 *ppTLib = pTL;
1800 else
1801 ITypeLib_Release(pTL);
1803 return hr;
1806 HRESULT __RPC_STUB ITypeInfo_GetContainingTypeLib_Stub(
1807 ITypeInfo* This,
1808 ITypeLib** ppTLib,
1809 UINT* pIndex)
1811 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1812 return ITypeInfo_GetContainingTypeLib(This, ppTLib, pIndex);
1815 void CALLBACK ITypeInfo_ReleaseTypeAttr_Proxy(
1816 ITypeInfo* This,
1817 TYPEATTR* pTypeAttr)
1819 TRACE("(%p, %p)\n", This, pTypeAttr);
1820 free_embedded_typedesc(&pTypeAttr->tdescAlias);
1821 CoTaskMemFree(pTypeAttr);
1824 HRESULT __RPC_STUB ITypeInfo_ReleaseTypeAttr_Stub(
1825 ITypeInfo* This)
1827 TRACE("nothing to do\n");
1828 return S_OK;
1831 void CALLBACK ITypeInfo_ReleaseFuncDesc_Proxy(
1832 ITypeInfo* This,
1833 FUNCDESC* pFuncDesc)
1835 SHORT param;
1836 TRACE("(%p, %p)\n", This, pFuncDesc);
1838 for(param = 0; param < pFuncDesc->cParams; param++)
1839 free_embedded_elemdesc(pFuncDesc->lprgelemdescParam + param);
1840 if(param)
1841 CoTaskMemFree(pFuncDesc->lprgelemdescParam);
1843 free_embedded_elemdesc(&pFuncDesc->elemdescFunc);
1845 if(pFuncDesc->cScodes != 0 && pFuncDesc->cScodes != -1)
1846 CoTaskMemFree(pFuncDesc->lprgscode);
1848 CoTaskMemFree(pFuncDesc);
1851 HRESULT __RPC_STUB ITypeInfo_ReleaseFuncDesc_Stub(
1852 ITypeInfo* This)
1854 TRACE("nothing to do\n");
1855 return S_OK;
1858 void CALLBACK ITypeInfo_ReleaseVarDesc_Proxy(
1859 ITypeInfo* This,
1860 VARDESC* pVarDesc)
1862 TRACE("(%p, %p)\n", This, pVarDesc);
1864 CoTaskMemFree(pVarDesc->lpstrSchema);
1866 if(pVarDesc->varkind == VAR_CONST)
1867 CoTaskMemFree(pVarDesc->u.lpvarValue);
1869 free_embedded_elemdesc(&pVarDesc->elemdescVar);
1870 CoTaskMemFree(pVarDesc);
1873 HRESULT __RPC_STUB ITypeInfo_ReleaseVarDesc_Stub(
1874 ITypeInfo* This)
1876 TRACE("nothing to do\n");
1877 return S_OK;
1881 /* ITypeInfo2 */
1883 HRESULT CALLBACK ITypeInfo2_GetDocumentation2_Proxy(ITypeInfo2 *This, MEMBERID memid,
1884 LCID lcid, BSTR *help_string,
1885 DWORD *help_context, BSTR *help_dll)
1887 DWORD dummy_help_context, flags = 0;
1888 BSTR dummy_help_string, dummy_help_dll;
1889 HRESULT hr;
1890 TRACE("(%p, %08x, %08x, %p, %p, %p)\n", This, memid, lcid, help_string, help_context, help_dll);
1892 if(!help_string) help_string = &dummy_help_string;
1893 else flags = 1;
1895 if(!help_context) help_context = &dummy_help_context;
1896 else flags |= 2;
1898 if(!help_dll) help_dll = &dummy_help_dll;
1899 else flags |= 4;
1901 hr = ITypeInfo2_RemoteGetDocumentation2_Proxy(This, memid, lcid, flags, help_string, help_context, help_dll);
1903 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1905 return hr;
1908 HRESULT __RPC_STUB ITypeInfo2_GetDocumentation2_Stub(ITypeInfo2 *This, MEMBERID memid,
1909 LCID lcid, DWORD flags,
1910 BSTR *help_string, DWORD *help_context,
1911 BSTR *help_dll)
1913 TRACE("(%p, %08x, %08x, %08x, %p, %p, %p)\n", This, memid, lcid, flags, help_string, help_context, help_dll);
1915 *help_string = *help_dll = NULL;
1916 *help_context = 0;
1918 if(!(flags & 1)) help_string = NULL;
1919 if(!(flags & 2)) help_context = NULL;
1920 if(!(flags & 4)) help_dll = NULL;
1922 return ITypeInfo2_GetDocumentation2(This, memid, lcid, help_string, help_context, help_dll);
1925 /* ITypeLib */
1927 UINT CALLBACK ITypeLib_GetTypeInfoCount_Proxy(
1928 ITypeLib* This)
1930 UINT count = 0;
1931 TRACE("(%p)\n", This);
1933 ITypeLib_RemoteGetTypeInfoCount_Proxy(This, &count);
1935 return count;
1938 HRESULT __RPC_STUB ITypeLib_GetTypeInfoCount_Stub(
1939 ITypeLib* This,
1940 UINT* pcTInfo)
1942 TRACE("(%p, %p)\n", This, pcTInfo);
1943 *pcTInfo = ITypeLib_GetTypeInfoCount(This);
1944 return S_OK;
1947 HRESULT CALLBACK ITypeLib_GetLibAttr_Proxy(
1948 ITypeLib* This,
1949 TLIBATTR** ppTLibAttr)
1951 CLEANLOCALSTORAGE stg;
1952 TRACE("(%p, %p)\n", This, ppTLibAttr);
1954 stg.flags = 0;
1955 stg.pStorage = NULL;
1956 stg.pInterface = NULL;
1958 return ITypeLib_RemoteGetLibAttr_Proxy(This, ppTLibAttr, &stg);
1961 HRESULT __RPC_STUB ITypeLib_GetLibAttr_Stub(
1962 ITypeLib* This,
1963 LPTLIBATTR* ppTLibAttr,
1964 CLEANLOCALSTORAGE* pDummy)
1966 HRESULT hr;
1967 TRACE("(%p, %p)\n", This, ppTLibAttr);
1969 hr = ITypeLib_GetLibAttr(This, ppTLibAttr);
1970 if(hr != S_OK)
1971 return hr;
1973 pDummy->flags = CLS_LIBATTR;
1974 ITypeLib_AddRef(This);
1975 pDummy->pInterface = (IUnknown*)This;
1976 pDummy->pStorage = ppTLibAttr;
1977 return hr;
1980 HRESULT CALLBACK ITypeLib_GetDocumentation_Proxy(ITypeLib *This, INT index, BSTR *name,
1981 BSTR *doc_string, DWORD *help_context,
1982 BSTR *help_file)
1984 DWORD dummy_help_context, flags = 0;
1985 BSTR dummy_name, dummy_doc_string, dummy_help_file;
1986 HRESULT hr;
1987 TRACE("(%p, %d, %p, %p, %p, %p)\n", This, index, name, doc_string, help_context, help_file);
1989 if(!name) name = &dummy_name;
1990 else flags = 1;
1992 if(!doc_string) doc_string = &dummy_doc_string;
1993 else flags |= 2;
1995 if(!help_context) help_context = &dummy_help_context;
1996 else flags |= 4;
1998 if(!help_file) help_file = &dummy_help_file;
1999 else flags |= 8;
2001 hr = ITypeLib_RemoteGetDocumentation_Proxy(This, index, flags, name, doc_string, help_context, help_file);
2003 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2005 return hr;
2008 HRESULT __RPC_STUB ITypeLib_GetDocumentation_Stub(ITypeLib *This, INT index, DWORD flags,
2009 BSTR *name, BSTR *doc_string,
2010 DWORD *help_context, BSTR *help_file)
2012 TRACE("(%p, %d, %08x, %p, %p, %p, %p)\n", This, index, flags, name, doc_string, help_context, help_file);
2014 *name = *doc_string = *help_file = NULL;
2015 *help_context = 0;
2017 if(!(flags & 1)) name = NULL;
2018 if(!(flags & 2)) doc_string = NULL;
2019 if(!(flags & 4)) help_context = NULL;
2020 if(!(flags & 8)) help_file = NULL;
2022 return ITypeLib_GetDocumentation(This, index, name, doc_string, help_context, help_file);
2025 HRESULT CALLBACK ITypeLib_IsName_Proxy(
2026 ITypeLib* This,
2027 LPOLESTR szNameBuf,
2028 ULONG lHashVal,
2029 BOOL* pfName)
2031 FIXME("not implemented\n");
2032 return E_FAIL;
2035 HRESULT __RPC_STUB ITypeLib_IsName_Stub(
2036 ITypeLib* This,
2037 LPOLESTR szNameBuf,
2038 ULONG lHashVal,
2039 BOOL* pfName,
2040 BSTR* pBstrLibName)
2042 FIXME("not implemented\n");
2043 return E_FAIL;
2046 HRESULT CALLBACK ITypeLib_FindName_Proxy(
2047 ITypeLib* This,
2048 LPOLESTR szNameBuf,
2049 ULONG lHashVal,
2050 ITypeInfo** ppTInfo,
2051 MEMBERID* rgMemId,
2052 USHORT* pcFound)
2054 FIXME("not implemented\n");
2055 return E_FAIL;
2058 HRESULT __RPC_STUB ITypeLib_FindName_Stub(
2059 ITypeLib* This,
2060 LPOLESTR szNameBuf,
2061 ULONG lHashVal,
2062 ITypeInfo** ppTInfo,
2063 MEMBERID* rgMemId,
2064 USHORT* pcFound,
2065 BSTR* pBstrLibName)
2067 FIXME("not implemented\n");
2068 return E_FAIL;
2071 void CALLBACK ITypeLib_ReleaseTLibAttr_Proxy(
2072 ITypeLib* This,
2073 TLIBATTR* pTLibAttr)
2075 TRACE("(%p, %p)\n", This, pTLibAttr);
2076 CoTaskMemFree(pTLibAttr);
2079 HRESULT __RPC_STUB ITypeLib_ReleaseTLibAttr_Stub(
2080 ITypeLib* This)
2082 TRACE("nothing to do\n");
2083 return S_OK;
2087 /* ITypeLib2 */
2089 HRESULT CALLBACK ITypeLib2_GetLibStatistics_Proxy(
2090 ITypeLib2* This,
2091 ULONG* pcUniqueNames,
2092 ULONG* pcchUniqueNames)
2094 FIXME("not implemented\n");
2095 return E_FAIL;
2098 HRESULT __RPC_STUB ITypeLib2_GetLibStatistics_Stub(
2099 ITypeLib2* This,
2100 ULONG* pcUniqueNames,
2101 ULONG* pcchUniqueNames)
2103 FIXME("not implemented\n");
2104 return E_FAIL;
2107 HRESULT CALLBACK ITypeLib2_GetDocumentation2_Proxy(ITypeLib2 *This, INT index,
2108 LCID lcid, BSTR *help_string,
2109 DWORD *help_context, BSTR *help_dll)
2111 DWORD dummy_help_context, flags = 0;
2112 BSTR dummy_help_string, dummy_help_dll;
2113 HRESULT hr;
2114 TRACE("(%p, %d, %08x, %p, %p, %p)\n", This, index, lcid, help_string, help_context, help_dll);
2116 if(!help_string) help_string = &dummy_help_string;
2117 else flags = 1;
2119 if(!help_context) help_context = &dummy_help_context;
2120 else flags |= 2;
2122 if(!help_dll) help_dll = &dummy_help_dll;
2123 else flags |= 4;
2125 hr = ITypeLib2_RemoteGetDocumentation2_Proxy(This, index, lcid, flags, help_string, help_context, help_dll);
2127 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2129 return hr;
2132 HRESULT __RPC_STUB ITypeLib2_GetDocumentation2_Stub(ITypeLib2 *This, INT index, LCID lcid,
2133 DWORD flags, BSTR *help_string,
2134 DWORD *help_context, BSTR *help_dll)
2136 TRACE("(%p, %d, %08x, %08x, %p, %p, %p)\n", This, index, lcid, flags, help_string, help_context, help_dll);
2138 *help_string = *help_dll = NULL;
2139 *help_context = 0;
2141 if(!(flags & 1)) help_string = NULL;
2142 if(!(flags & 2)) help_context = NULL;
2143 if(!(flags & 4)) help_dll = NULL;
2145 return ITypeLib2_GetDocumentation2(This, index, lcid, help_string, help_context, help_dll);
2148 HRESULT CALLBACK IPropertyBag_Read_Proxy(
2149 IPropertyBag* This,
2150 LPCOLESTR pszPropName,
2151 VARIANT *pVar,
2152 IErrorLog *pErrorLog)
2154 IUnknown *pUnk = NULL;
2155 TRACE("(%p, %s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
2157 if(!pVar)
2158 return E_POINTER;
2160 if(V_VT(pVar) & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2162 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2163 return E_NOTIMPL;
2166 switch(V_VT(pVar))
2168 case VT_DISPATCH:
2169 pUnk = (IUnknown*)V_DISPATCH(pVar);
2170 break;
2171 case VT_UNKNOWN:
2172 pUnk = V_UNKNOWN(pVar);
2173 break;
2174 case VT_SAFEARRAY:
2175 FIXME("Safearray support not yet implemented.\n");
2176 return E_NOTIMPL;
2177 default:
2178 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar));
2179 return E_NOTIMPL;
2182 return IPropertyBag_RemoteRead_Proxy(This, pszPropName, pVar, pErrorLog,
2183 V_VT(pVar), pUnk);
2186 HRESULT __RPC_STUB IPropertyBag_Read_Stub(
2187 IPropertyBag* This,
2188 LPCOLESTR pszPropName,
2189 VARIANT *pVar,
2190 IErrorLog *pErrorLog,
2191 DWORD varType,
2192 IUnknown *pUnkObj)
2194 static const WCHAR emptyWstr[] = {0};
2195 IDispatch *disp;
2196 HRESULT hr;
2197 TRACE("(%p, %s, %p, %p, %x, %p)\n", This, debugstr_w(pszPropName), pVar,
2198 pErrorLog, varType, pUnkObj);
2200 if(varType & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2202 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2203 return E_NOTIMPL;
2206 V_VT(pVar) = varType;
2207 switch(varType)
2209 case VT_DISPATCH:
2210 hr = IUnknown_QueryInterface(pUnkObj, &IID_IDispatch, (LPVOID*)&disp);
2211 if(FAILED(hr))
2212 return hr;
2213 IUnknown_Release(pUnkObj);
2214 V_DISPATCH(pVar) = disp;
2215 break;
2216 case VT_UNKNOWN:
2217 V_UNKNOWN(pVar) = pUnkObj;
2218 break;
2219 case VT_BSTR:
2220 V_BSTR(pVar) = SysAllocString(emptyWstr);
2221 break;
2222 case VT_SAFEARRAY:
2223 FIXME("Safearray support not yet implemented.\n");
2224 return E_NOTIMPL;
2225 default:
2226 break;
2228 hr = IPropertyBag_Read(This, pszPropName, pVar, pErrorLog);
2229 if(FAILED(hr))
2230 VariantClear(pVar);
2232 return hr;
2235 /* call_as/local stubs for ocidl.idl */
2237 HRESULT CALLBACK IClassFactory2_CreateInstanceLic_Proxy(
2238 IClassFactory2* This,
2239 IUnknown *pUnkOuter,
2240 IUnknown *pUnkReserved,
2241 REFIID riid,
2242 BSTR bstrKey,
2243 PVOID *ppvObj)
2245 FIXME("not implemented\n");
2246 return E_NOTIMPL;
2249 HRESULT __RPC_STUB IClassFactory2_CreateInstanceLic_Stub(
2250 IClassFactory2* This,
2251 REFIID riid,
2252 BSTR bstrKey,
2253 IUnknown **ppvObj)
2255 FIXME("not implemented\n");
2256 return E_NOTIMPL;
2259 HRESULT CALLBACK IEnumConnections_Next_Proxy(
2260 IEnumConnections* This,
2261 ULONG cConnections,
2262 LPCONNECTDATA rgcd,
2263 ULONG *pcFetched)
2265 FIXME("not implemented\n");
2266 return E_NOTIMPL;
2269 HRESULT __RPC_STUB IEnumConnections_Next_Stub(
2270 IEnumConnections* This,
2271 ULONG cConnections,
2272 LPCONNECTDATA rgcd,
2273 ULONG *pcFetched)
2275 FIXME("not implemented\n");
2276 return E_NOTIMPL;
2279 HRESULT CALLBACK IEnumConnectionPoints_Next_Proxy(
2280 IEnumConnectionPoints* This,
2281 ULONG cConnections,
2282 LPCONNECTIONPOINT *ppCP,
2283 ULONG *pcFetched)
2285 FIXME("not implemented\n");
2286 return E_NOTIMPL;
2289 HRESULT __RPC_STUB IEnumConnectionPoints_Next_Stub(
2290 IEnumConnectionPoints* This,
2291 ULONG cConnections,
2292 LPCONNECTIONPOINT *ppCP,
2293 ULONG *pcFetched)
2295 FIXME("not implemented\n");
2296 return E_NOTIMPL;
2299 HRESULT CALLBACK IPersistMemory_Load_Proxy(
2300 IPersistMemory* This,
2301 LPVOID pMem,
2302 ULONG cbSize)
2304 FIXME("not implemented\n");
2305 return E_NOTIMPL;
2308 HRESULT __RPC_STUB IPersistMemory_Load_Stub(
2309 IPersistMemory* This,
2310 BYTE *pMem,
2311 ULONG cbSize)
2313 FIXME("not implemented\n");
2314 return E_NOTIMPL;
2317 HRESULT CALLBACK IPersistMemory_Save_Proxy(
2318 IPersistMemory* This,
2319 LPVOID pMem,
2320 BOOL fClearDirty,
2321 ULONG cbSize)
2323 FIXME("not implemented\n");
2324 return E_NOTIMPL;
2327 HRESULT __RPC_STUB IPersistMemory_Save_Stub(
2328 IPersistMemory* This,
2329 BYTE *pMem,
2330 BOOL fClearDirty,
2331 ULONG cbSize)
2333 FIXME("not implemented\n");
2334 return E_NOTIMPL;
2337 void CALLBACK IAdviseSinkEx_OnViewStatusChange_Proxy(
2338 IAdviseSinkEx* This,
2339 DWORD dwViewStatus)
2341 FIXME("not implemented\n");
2344 HRESULT __RPC_STUB IAdviseSinkEx_OnViewStatusChange_Stub(
2345 IAdviseSinkEx* This,
2346 DWORD dwViewStatus)
2348 FIXME("not implemented\n");
2349 return E_NOTIMPL;
2352 HRESULT CALLBACK IEnumOleUndoUnits_Next_Proxy(
2353 IEnumOleUndoUnits* This,
2354 ULONG cElt,
2355 IOleUndoUnit **rgElt,
2356 ULONG *pcEltFetched)
2358 FIXME("not implemented\n");
2359 return E_NOTIMPL;
2362 HRESULT __RPC_STUB IEnumOleUndoUnits_Next_Stub(
2363 IEnumOleUndoUnits* This,
2364 ULONG cElt,
2365 IOleUndoUnit **rgElt,
2366 ULONG *pcEltFetched)
2368 FIXME("not implemented\n");
2369 return E_NOTIMPL;
2372 HRESULT CALLBACK IQuickActivate_QuickActivate_Proxy(
2373 IQuickActivate* This,
2374 QACONTAINER *pQaContainer,
2375 QACONTROL *pQaControl)
2377 FIXME("not implemented\n");
2378 return E_NOTIMPL;
2381 HRESULT __RPC_STUB IQuickActivate_QuickActivate_Stub(
2382 IQuickActivate* This,
2383 QACONTAINER *pQaContainer,
2384 QACONTROL *pQaControl)
2386 FIXME("not implemented\n");
2387 return E_NOTIMPL;