mshtml: Use proper BINF flags for form submit.
[wine.git] / dlls / oleaut32 / usrmarshal.c
blob0b541e436c7913fe3c3247c9171fcba44a5f0392
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)
1074 *ppsa = SafeArrayCreateEx(vt, wiresa->cDims, wiresab, NULL);
1075 if (!*ppsa) RpcRaiseException(E_OUTOFMEMORY);
1077 else
1079 if (FAILED(SafeArrayAllocDescriptor(wiresa->cDims, ppsa)))
1080 RpcRaiseException(E_OUTOFMEMORY);
1081 memcpy((*ppsa)->rgsabound, wiresab, sizeof(SAFEARRAYBOUND) * wiresa->cDims);
1084 /* be careful about which flags we set since they could be a security
1085 * risk */
1086 (*ppsa)->fFeatures &= FADF_AUTOSETFLAGS;
1087 (*ppsa)->fFeatures |= (wiresa->fFeatures & ~(FADF_AUTOSETFLAGS));
1088 /* FIXME: there should be a limit on how large wiresa->cbElements can be */
1089 (*ppsa)->cbElements = elem_mem_size(wiresa, sftype);
1090 (*ppsa)->cLocks = 0;
1092 /* SafeArrayCreateEx allocates the data for us, but
1093 * SafeArrayAllocDescriptor doesn't */
1094 if(!vt)
1096 hr = SafeArrayAllocData(*ppsa);
1097 if (FAILED(hr))
1098 RpcRaiseException(hr);
1101 if ((*(ULONG *)Buffer != cell_count) || (SAFEARRAY_GetCellCount(*ppsa) != cell_count))
1102 RpcRaiseException(RPC_S_INVALID_BOUND);
1103 Buffer += sizeof(ULONG);
1105 if (ptr)
1107 switch (sftype)
1109 case SF_BSTR:
1111 BSTR* lpBstr;
1113 for (lpBstr = (*ppsa)->pvData; cell_count; cell_count--, lpBstr++)
1114 Buffer = BSTR_UserUnmarshal(pFlags, Buffer, lpBstr);
1116 break;
1118 case SF_DISPATCH:
1119 case SF_UNKNOWN:
1120 case SF_HAVEIID:
1121 FIXME("marshal interfaces\n");
1122 break;
1123 case SF_VARIANT:
1125 VARIANT* lpVariant;
1127 for (lpVariant = (*ppsa)->pvData; cell_count; cell_count--, lpVariant++)
1128 Buffer = VARIANT_UserUnmarshal(pFlags, Buffer, lpVariant);
1130 break;
1132 case SF_RECORD:
1134 FIXME("set record info\n");
1136 break;
1139 case SF_I8:
1140 ALIGN_POINTER(Buffer, 7);
1141 /* fallthrough */
1142 case SF_I1:
1143 case SF_I2:
1144 case SF_I4:
1145 /* Just copy the data over */
1146 memcpy((*ppsa)->pvData, Buffer, cell_count * (*ppsa)->cbElements);
1147 Buffer += cell_count * (*ppsa)->cbElements;
1148 break;
1149 default:
1150 break;
1154 TRACE("safe array unmarshaled: %p\n", *ppsa);
1156 return Buffer;
1159 void WINAPI LPSAFEARRAY_UserFree(ULONG *pFlags, LPSAFEARRAY *ppsa)
1161 TRACE("("); dump_user_flags(pFlags); TRACE(", &%p\n", *ppsa);
1163 SafeArrayDestroy(*ppsa);
1167 ULONG WINAPI HFONT_UserSize(ULONG *pFlags, ULONG Start, HFONT *phfont)
1169 FIXME(":stub\n");
1170 return 0;
1173 unsigned char * WINAPI HFONT_UserMarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1175 FIXME(":stub\n");
1176 return NULL;
1179 unsigned char * WINAPI HFONT_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, HFONT *phfont)
1181 FIXME(":stub\n");
1182 return NULL;
1185 void WINAPI HFONT_UserFree(ULONG *pFlags, HFONT *phfont)
1187 FIXME(":stub\n");
1188 return;
1192 /* IDispatch */
1193 /* exactly how Invoke is marshalled is not very clear to me yet,
1194 * but the way I've done it seems to work for me */
1196 HRESULT CALLBACK IDispatch_Invoke_Proxy(
1197 IDispatch* This,
1198 DISPID dispIdMember,
1199 REFIID riid,
1200 LCID lcid,
1201 WORD wFlags,
1202 DISPPARAMS* pDispParams,
1203 VARIANT* pVarResult,
1204 EXCEPINFO* pExcepInfo,
1205 UINT* puArgErr)
1207 HRESULT hr;
1208 VARIANT VarResult;
1209 UINT* rgVarRefIdx = NULL;
1210 VARIANTARG* rgVarRef = NULL;
1211 UINT u, cVarRef;
1212 UINT uArgErr;
1213 EXCEPINFO ExcepInfo;
1215 TRACE("(%p)->(%d,%s,%x,%x,%p,%p,%p,%p)\n", This,
1216 dispIdMember, debugstr_guid(riid),
1217 lcid, wFlags, pDispParams, pVarResult,
1218 pExcepInfo, puArgErr);
1220 /* [out] args can't be null, use dummy vars if needed */
1221 if (!pVarResult) pVarResult = &VarResult;
1222 if (!puArgErr) puArgErr = &uArgErr;
1223 if (!pExcepInfo) pExcepInfo = &ExcepInfo;
1225 /* count by-ref args */
1226 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1227 VARIANTARG* arg = &pDispParams->rgvarg[u];
1228 if (V_ISBYREF(arg)) {
1229 cVarRef++;
1232 if (cVarRef) {
1233 rgVarRefIdx = CoTaskMemAlloc(sizeof(UINT)*cVarRef);
1234 rgVarRef = CoTaskMemAlloc(sizeof(VARIANTARG)*cVarRef);
1235 /* make list of by-ref args */
1236 for (cVarRef=0,u=0; u<pDispParams->cArgs; u++) {
1237 VARIANTARG* arg = &pDispParams->rgvarg[u];
1238 if (V_ISBYREF(arg)) {
1239 rgVarRefIdx[cVarRef] = u;
1240 VariantInit(&rgVarRef[cVarRef]);
1241 VariantCopy(&rgVarRef[cVarRef], arg);
1242 VariantClear(arg);
1243 cVarRef++;
1246 } else {
1247 /* [out] args still can't be null,
1248 * but we can point these anywhere in this case,
1249 * since they won't be written to when cVarRef is 0 */
1250 rgVarRefIdx = puArgErr;
1251 rgVarRef = pVarResult;
1253 TRACE("passed by ref: %d args\n", cVarRef);
1254 hr = IDispatch_RemoteInvoke_Proxy(This,
1255 dispIdMember,
1256 riid,
1257 lcid,
1258 wFlags,
1259 pDispParams,
1260 pVarResult,
1261 pExcepInfo,
1262 puArgErr,
1263 cVarRef,
1264 rgVarRefIdx,
1265 rgVarRef);
1266 if (cVarRef) {
1267 for (u=0; u<cVarRef; u++) {
1268 unsigned i = rgVarRefIdx[u];
1269 VariantCopy(&pDispParams->rgvarg[i],
1270 &rgVarRef[u]);
1271 VariantClear(&rgVarRef[u]);
1273 CoTaskMemFree(rgVarRef);
1274 CoTaskMemFree(rgVarRefIdx);
1277 if(pExcepInfo == &ExcepInfo)
1279 SysFreeString(pExcepInfo->bstrSource);
1280 SysFreeString(pExcepInfo->bstrDescription);
1281 SysFreeString(pExcepInfo->bstrHelpFile);
1283 return hr;
1286 HRESULT __RPC_STUB IDispatch_Invoke_Stub(
1287 IDispatch* This,
1288 DISPID dispIdMember,
1289 REFIID riid,
1290 LCID lcid,
1291 DWORD dwFlags,
1292 DISPPARAMS* pDispParams,
1293 VARIANT* pVarResult,
1294 EXCEPINFO* pExcepInfo,
1295 UINT* pArgErr,
1296 UINT cVarRef,
1297 UINT* rgVarRefIdx,
1298 VARIANTARG* rgVarRef)
1300 HRESULT hr = S_OK;
1301 VARIANTARG *rgvarg, *arg;
1302 UINT u;
1304 /* initialize out parameters, so that they can be marshalled
1305 * in case the real Invoke doesn't initialize them */
1306 VariantInit(pVarResult);
1307 memset(pExcepInfo, 0, sizeof(*pExcepInfo));
1308 *pArgErr = 0;
1310 /* let the real Invoke operate on a copy of the in parameters,
1311 * so we don't risk losing pointers to allocated memory */
1312 rgvarg = pDispParams->rgvarg;
1313 arg = CoTaskMemAlloc(sizeof(VARIANTARG)*pDispParams->cArgs);
1314 if (!arg) return E_OUTOFMEMORY;
1316 /* init all args so we can call VariantClear on all the args if the copy
1317 * below fails */
1318 for (u = 0; u < pDispParams->cArgs; u++)
1319 VariantInit(&arg[u]);
1321 for (u = 0; u < pDispParams->cArgs; u++) {
1322 hr = VariantCopy(&arg[u], &rgvarg[u]);
1323 if (FAILED(hr))
1324 break;
1327 if (SUCCEEDED(hr)) {
1328 /* copy ref args to arg array */
1329 for (u=0; u<cVarRef; u++) {
1330 unsigned i = rgVarRefIdx[u];
1331 VariantCopy(&arg[i], &rgVarRef[u]);
1334 pDispParams->rgvarg = arg;
1336 hr = IDispatch_Invoke(This,
1337 dispIdMember,
1338 riid,
1339 lcid,
1340 dwFlags,
1341 pDispParams,
1342 pVarResult,
1343 pExcepInfo,
1344 pArgErr);
1346 /* copy ref args from arg array */
1347 for (u=0; u<cVarRef; u++) {
1348 unsigned i = rgVarRefIdx[u];
1349 VariantCopy(&rgVarRef[u], &arg[i]);
1353 /* clear the duplicate argument list */
1354 for (u=0; u<pDispParams->cArgs; u++)
1355 VariantClear(&arg[u]);
1357 pDispParams->rgvarg = rgvarg;
1358 CoTaskMemFree(arg);
1360 return hr;
1363 /* IEnumVARIANT */
1365 HRESULT CALLBACK IEnumVARIANT_Next_Proxy(
1366 IEnumVARIANT* This,
1367 ULONG celt,
1368 VARIANT* rgVar,
1369 ULONG* pCeltFetched)
1371 ULONG fetched;
1372 if (!pCeltFetched)
1373 pCeltFetched = &fetched;
1374 return IEnumVARIANT_RemoteNext_Proxy(This,
1375 celt,
1376 rgVar,
1377 pCeltFetched);
1380 HRESULT __RPC_STUB IEnumVARIANT_Next_Stub(
1381 IEnumVARIANT* This,
1382 ULONG celt,
1383 VARIANT* rgVar,
1384 ULONG* pCeltFetched)
1386 HRESULT hr;
1387 *pCeltFetched = 0;
1388 hr = IEnumVARIANT_Next(This,
1389 celt,
1390 rgVar,
1391 pCeltFetched);
1392 if (hr == S_OK) *pCeltFetched = celt;
1393 return hr;
1396 /* TypeInfo related freers */
1398 static void free_embedded_typedesc(TYPEDESC *tdesc);
1399 static void free_embedded_arraydesc(ARRAYDESC *adesc)
1401 switch(adesc->tdescElem.vt)
1403 case VT_PTR:
1404 case VT_SAFEARRAY:
1405 free_embedded_typedesc(adesc->tdescElem.u.lptdesc);
1406 CoTaskMemFree(adesc->tdescElem.u.lptdesc);
1407 break;
1408 case VT_CARRAY:
1409 free_embedded_arraydesc(adesc->tdescElem.u.lpadesc);
1410 CoTaskMemFree(adesc->tdescElem.u.lpadesc);
1411 break;
1415 static void free_embedded_typedesc(TYPEDESC *tdesc)
1417 switch(tdesc->vt)
1419 case VT_PTR:
1420 case VT_SAFEARRAY:
1421 free_embedded_typedesc(tdesc->u.lptdesc);
1422 CoTaskMemFree(tdesc->u.lptdesc);
1423 break;
1424 case VT_CARRAY:
1425 free_embedded_arraydesc(tdesc->u.lpadesc);
1426 CoTaskMemFree(tdesc->u.lpadesc);
1427 break;
1431 static void free_embedded_elemdesc(ELEMDESC *edesc)
1433 free_embedded_typedesc(&edesc->tdesc);
1434 if(edesc->u.paramdesc.wParamFlags & PARAMFLAG_FHASDEFAULT)
1435 CoTaskMemFree(edesc->u.paramdesc.pparamdescex);
1438 /* ITypeComp */
1440 HRESULT CALLBACK ITypeComp_Bind_Proxy(
1441 ITypeComp* This,
1442 LPOLESTR szName,
1443 ULONG lHashVal,
1444 WORD wFlags,
1445 ITypeInfo** ppTInfo,
1446 DESCKIND* pDescKind,
1447 BINDPTR* pBindPtr)
1449 FIXME("not implemented\n");
1450 return E_FAIL;
1453 HRESULT __RPC_STUB ITypeComp_Bind_Stub(
1454 ITypeComp* This,
1455 LPOLESTR szName,
1456 ULONG lHashVal,
1457 WORD wFlags,
1458 ITypeInfo** ppTInfo,
1459 DESCKIND* pDescKind,
1460 LPFUNCDESC* ppFuncDesc,
1461 LPVARDESC* ppVarDesc,
1462 ITypeComp** ppTypeComp,
1463 CLEANLOCALSTORAGE* pDummy)
1465 FIXME("not implemented\n");
1466 return E_FAIL;
1469 HRESULT CALLBACK ITypeComp_BindType_Proxy(
1470 ITypeComp* This,
1471 LPOLESTR szName,
1472 ULONG lHashVal,
1473 ITypeInfo** ppTInfo,
1474 ITypeComp** ppTComp)
1476 FIXME("not implemented\n");
1477 return E_FAIL;
1480 HRESULT __RPC_STUB ITypeComp_BindType_Stub(
1481 ITypeComp* This,
1482 LPOLESTR szName,
1483 ULONG lHashVal,
1484 ITypeInfo** ppTInfo)
1486 FIXME("not implemented\n");
1487 return E_FAIL;
1490 /* ITypeInfo */
1492 HRESULT CALLBACK ITypeInfo_GetTypeAttr_Proxy(
1493 ITypeInfo* This,
1494 TYPEATTR** ppTypeAttr)
1497 CLEANLOCALSTORAGE stg;
1498 TRACE("(%p, %p)\n", This, ppTypeAttr);
1500 stg.flags = 0;
1501 stg.pStorage = NULL;
1502 stg.pInterface = NULL;
1504 return ITypeInfo_RemoteGetTypeAttr_Proxy(This, ppTypeAttr, &stg);
1507 HRESULT __RPC_STUB ITypeInfo_GetTypeAttr_Stub(
1508 ITypeInfo* This,
1509 LPTYPEATTR* ppTypeAttr,
1510 CLEANLOCALSTORAGE* pDummy)
1512 HRESULT hr;
1513 TRACE("(%p, %p)\n", This, ppTypeAttr);
1515 hr = ITypeInfo_GetTypeAttr(This, ppTypeAttr);
1516 if(hr != S_OK)
1517 return hr;
1519 pDummy->flags = CLS_TYPEATTR;
1520 ITypeInfo_AddRef(This);
1521 pDummy->pInterface = (IUnknown*)This;
1522 pDummy->pStorage = ppTypeAttr;
1523 return hr;
1526 HRESULT CALLBACK ITypeInfo_GetFuncDesc_Proxy(
1527 ITypeInfo* This,
1528 UINT index,
1529 FUNCDESC** ppFuncDesc)
1531 CLEANLOCALSTORAGE stg;
1532 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1534 stg.flags = 0;
1535 stg.pStorage = NULL;
1536 stg.pInterface = NULL;
1538 return ITypeInfo_RemoteGetFuncDesc_Proxy(This, index, ppFuncDesc, &stg);
1541 HRESULT __RPC_STUB ITypeInfo_GetFuncDesc_Stub(
1542 ITypeInfo* This,
1543 UINT index,
1544 LPFUNCDESC* ppFuncDesc,
1545 CLEANLOCALSTORAGE* pDummy)
1547 HRESULT hr;
1548 TRACE("(%p, %d, %p)\n", This, index, ppFuncDesc);
1550 hr = ITypeInfo_GetFuncDesc(This, index, ppFuncDesc);
1551 if(hr != S_OK)
1552 return hr;
1554 pDummy->flags = CLS_FUNCDESC;
1555 ITypeInfo_AddRef(This);
1556 pDummy->pInterface = (IUnknown*)This;
1557 pDummy->pStorage = ppFuncDesc;
1558 return hr;
1561 HRESULT CALLBACK ITypeInfo_GetVarDesc_Proxy(
1562 ITypeInfo* This,
1563 UINT index,
1564 VARDESC** ppVarDesc)
1566 CLEANLOCALSTORAGE stg;
1567 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1569 stg.flags = 0;
1570 stg.pStorage = NULL;
1571 stg.pInterface = NULL;
1573 return ITypeInfo_RemoteGetVarDesc_Proxy(This, index, ppVarDesc, &stg);
1576 HRESULT __RPC_STUB ITypeInfo_GetVarDesc_Stub(
1577 ITypeInfo* This,
1578 UINT index,
1579 LPVARDESC* ppVarDesc,
1580 CLEANLOCALSTORAGE* pDummy)
1582 HRESULT hr;
1583 TRACE("(%p, %d, %p)\n", This, index, ppVarDesc);
1585 hr = ITypeInfo_GetVarDesc(This, index, ppVarDesc);
1586 if(hr != S_OK)
1587 return hr;
1589 pDummy->flags = CLS_VARDESC;
1590 ITypeInfo_AddRef(This);
1591 pDummy->pInterface = (IUnknown*)This;
1592 pDummy->pStorage = ppVarDesc;
1593 return hr;
1596 HRESULT CALLBACK ITypeInfo_GetNames_Proxy(
1597 ITypeInfo* This,
1598 MEMBERID memid,
1599 BSTR* rgBstrNames,
1600 UINT cMaxNames,
1601 UINT* pcNames)
1603 TRACE("(%p, %08x, %p, %d, %p)\n", This, memid, rgBstrNames, cMaxNames, pcNames);
1605 return ITypeInfo_RemoteGetNames_Proxy(This, memid, rgBstrNames, cMaxNames, pcNames);
1608 HRESULT __RPC_STUB ITypeInfo_GetNames_Stub(
1609 ITypeInfo* This,
1610 MEMBERID memid,
1611 BSTR* rgBstrNames,
1612 UINT cMaxNames,
1613 UINT* pcNames)
1615 TRACE("(%p, %08x, %p, %d, %p)\n", This, memid, rgBstrNames, cMaxNames, pcNames);
1617 return ITypeInfo_GetNames(This, memid, rgBstrNames, cMaxNames, pcNames);
1620 HRESULT CALLBACK ITypeInfo_GetIDsOfNames_Proxy(
1621 ITypeInfo* This,
1622 LPOLESTR* rgszNames,
1623 UINT cNames,
1624 MEMBERID* pMemId)
1626 FIXME("not implemented\n");
1627 return E_FAIL;
1630 HRESULT __RPC_STUB ITypeInfo_GetIDsOfNames_Stub(
1631 ITypeInfo* This)
1633 FIXME("not implemented\n");
1634 return E_FAIL;
1637 HRESULT CALLBACK ITypeInfo_Invoke_Proxy(
1638 ITypeInfo* This,
1639 PVOID pvInstance,
1640 MEMBERID memid,
1641 WORD wFlags,
1642 DISPPARAMS* pDispParams,
1643 VARIANT* pVarResult,
1644 EXCEPINFO* pExcepInfo,
1645 UINT* puArgErr)
1647 FIXME("not implemented\n");
1648 return E_FAIL;
1651 HRESULT __RPC_STUB ITypeInfo_Invoke_Stub(
1652 ITypeInfo* This)
1654 FIXME("not implemented\n");
1655 return E_FAIL;
1658 HRESULT CALLBACK ITypeInfo_GetDocumentation_Proxy(ITypeInfo *This, MEMBERID memid,
1659 BSTR *name, BSTR *doc_string,
1660 DWORD *help_context, BSTR *help_file)
1662 DWORD dummy_help_context, flags = 0;
1663 BSTR dummy_name, dummy_doc_string, dummy_help_file;
1664 HRESULT hr;
1665 TRACE("(%p, %08x, %p, %p, %p, %p)\n", This, memid, name, doc_string, help_context, help_file);
1667 if(!name) name = &dummy_name;
1668 else flags = 1;
1670 if(!doc_string) doc_string = &dummy_doc_string;
1671 else flags |= 2;
1673 if(!help_context) help_context = &dummy_help_context;
1674 else flags |= 4;
1676 if(!help_file) help_file = &dummy_help_file;
1677 else flags |= 8;
1679 hr = ITypeInfo_RemoteGetDocumentation_Proxy(This, memid, flags, name, doc_string, help_context, help_file);
1681 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1683 return hr;
1686 HRESULT __RPC_STUB ITypeInfo_GetDocumentation_Stub(ITypeInfo *This, MEMBERID memid,
1687 DWORD flags, BSTR *name, BSTR *doc_string,
1688 DWORD *help_context, BSTR *help_file)
1690 TRACE("(%p, %08x, %08x, %p, %p, %p, %p)\n", This, memid, flags, name, doc_string, help_context, help_file);
1692 *name = *doc_string = *help_file = NULL;
1693 *help_context = 0;
1695 if(!(flags & 1)) name = NULL;
1696 if(!(flags & 2)) doc_string = NULL;
1697 if(!(flags & 4)) help_context = NULL;
1698 if(!(flags & 8)) help_file = NULL;
1700 return ITypeInfo_GetDocumentation(This, memid, name, doc_string, help_context, help_file);
1703 HRESULT CALLBACK ITypeInfo_GetDllEntry_Proxy(ITypeInfo *This, MEMBERID memid,
1704 INVOKEKIND invkind, BSTR *dll_name,
1705 BSTR* name, WORD *ordinal)
1707 DWORD flags = 0;
1708 BSTR dummy_dll_name, dummy_name;
1709 WORD dummy_ordinal;
1710 HRESULT hr;
1711 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This, memid, invkind, dll_name, name, ordinal);
1713 if(!dll_name) dll_name = &dummy_dll_name;
1714 else flags = 1;
1716 if(!name) name = &dummy_name;
1717 else flags |= 2;
1719 if(!ordinal) ordinal = &dummy_ordinal;
1720 else flags |= 4;
1722 hr = ITypeInfo_RemoteGetDllEntry_Proxy(This, memid, invkind, flags, dll_name, name, ordinal);
1724 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1726 return hr;
1729 HRESULT __RPC_STUB ITypeInfo_GetDllEntry_Stub(ITypeInfo *This, MEMBERID memid,
1730 INVOKEKIND invkind, DWORD flags,
1731 BSTR *dll_name, BSTR *name,
1732 WORD *ordinal)
1734 TRACE("(%p, %08x, %x, %p, %p, %p)\n", This, memid, invkind, dll_name, name, ordinal);
1736 *dll_name = *name = NULL;
1737 *ordinal = 0;
1739 if(!(flags & 1)) dll_name = NULL;
1740 if(!(flags & 2)) name = NULL;
1741 if(!(flags & 4)) ordinal = NULL;
1743 return ITypeInfo_GetDllEntry(This, memid, invkind, dll_name, name, ordinal);
1746 HRESULT CALLBACK ITypeInfo_AddressOfMember_Proxy(
1747 ITypeInfo* This,
1748 MEMBERID memid,
1749 INVOKEKIND invKind,
1750 PVOID* ppv)
1752 FIXME("not implemented\n");
1753 return E_FAIL;
1756 HRESULT __RPC_STUB ITypeInfo_AddressOfMember_Stub(
1757 ITypeInfo* This)
1759 FIXME("not implemented\n");
1760 return E_FAIL;
1763 HRESULT CALLBACK ITypeInfo_CreateInstance_Proxy(
1764 ITypeInfo* This,
1765 IUnknown* pUnkOuter,
1766 REFIID riid,
1767 PVOID* ppvObj)
1769 FIXME("not implemented\n");
1770 return E_FAIL;
1773 HRESULT __RPC_STUB ITypeInfo_CreateInstance_Stub(
1774 ITypeInfo* This,
1775 REFIID riid,
1776 IUnknown** ppvObj)
1778 FIXME("not implemented\n");
1779 return E_FAIL;
1782 HRESULT CALLBACK ITypeInfo_GetContainingTypeLib_Proxy(
1783 ITypeInfo* This,
1784 ITypeLib** ppTLib,
1785 UINT* pIndex)
1787 ITypeLib *pTL;
1788 UINT index;
1789 HRESULT hr;
1791 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1793 hr = ITypeInfo_RemoteGetContainingTypeLib_Proxy(This, &pTL, &index);
1794 if(SUCCEEDED(hr))
1796 if(pIndex)
1797 *pIndex = index;
1799 if(ppTLib)
1800 *ppTLib = pTL;
1801 else
1802 ITypeLib_Release(pTL);
1804 return hr;
1807 HRESULT __RPC_STUB ITypeInfo_GetContainingTypeLib_Stub(
1808 ITypeInfo* This,
1809 ITypeLib** ppTLib,
1810 UINT* pIndex)
1812 TRACE("(%p, %p, %p)\n", This, ppTLib, pIndex );
1813 return ITypeInfo_GetContainingTypeLib(This, ppTLib, pIndex);
1816 void CALLBACK ITypeInfo_ReleaseTypeAttr_Proxy(
1817 ITypeInfo* This,
1818 TYPEATTR* pTypeAttr)
1820 TRACE("(%p, %p)\n", This, pTypeAttr);
1821 free_embedded_typedesc(&pTypeAttr->tdescAlias);
1822 CoTaskMemFree(pTypeAttr);
1825 HRESULT __RPC_STUB ITypeInfo_ReleaseTypeAttr_Stub(
1826 ITypeInfo* This)
1828 TRACE("nothing to do\n");
1829 return S_OK;
1832 void CALLBACK ITypeInfo_ReleaseFuncDesc_Proxy(
1833 ITypeInfo* This,
1834 FUNCDESC* pFuncDesc)
1836 SHORT param;
1837 TRACE("(%p, %p)\n", This, pFuncDesc);
1839 for(param = 0; param < pFuncDesc->cParams; param++)
1840 free_embedded_elemdesc(pFuncDesc->lprgelemdescParam + param);
1841 if(param)
1842 CoTaskMemFree(pFuncDesc->lprgelemdescParam);
1844 free_embedded_elemdesc(&pFuncDesc->elemdescFunc);
1846 if(pFuncDesc->cScodes != 0 && pFuncDesc->cScodes != -1)
1847 CoTaskMemFree(pFuncDesc->lprgscode);
1849 CoTaskMemFree(pFuncDesc);
1852 HRESULT __RPC_STUB ITypeInfo_ReleaseFuncDesc_Stub(
1853 ITypeInfo* This)
1855 TRACE("nothing to do\n");
1856 return S_OK;
1859 void CALLBACK ITypeInfo_ReleaseVarDesc_Proxy(
1860 ITypeInfo* This,
1861 VARDESC* pVarDesc)
1863 TRACE("(%p, %p)\n", This, pVarDesc);
1865 CoTaskMemFree(pVarDesc->lpstrSchema);
1867 if(pVarDesc->varkind == VAR_CONST)
1868 CoTaskMemFree(pVarDesc->u.lpvarValue);
1870 free_embedded_elemdesc(&pVarDesc->elemdescVar);
1871 CoTaskMemFree(pVarDesc);
1874 HRESULT __RPC_STUB ITypeInfo_ReleaseVarDesc_Stub(
1875 ITypeInfo* This)
1877 TRACE("nothing to do\n");
1878 return S_OK;
1882 /* ITypeInfo2 */
1884 HRESULT CALLBACK ITypeInfo2_GetDocumentation2_Proxy(ITypeInfo2 *This, MEMBERID memid,
1885 LCID lcid, BSTR *help_string,
1886 DWORD *help_context, BSTR *help_dll)
1888 DWORD dummy_help_context, flags = 0;
1889 BSTR dummy_help_string, dummy_help_dll;
1890 HRESULT hr;
1891 TRACE("(%p, %08x, %08x, %p, %p, %p)\n", This, memid, lcid, help_string, help_context, help_dll);
1893 if(!help_string) help_string = &dummy_help_string;
1894 else flags = 1;
1896 if(!help_context) help_context = &dummy_help_context;
1897 else flags |= 2;
1899 if(!help_dll) help_dll = &dummy_help_dll;
1900 else flags |= 4;
1902 hr = ITypeInfo2_RemoteGetDocumentation2_Proxy(This, memid, lcid, flags, help_string, help_context, help_dll);
1904 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
1906 return hr;
1909 HRESULT __RPC_STUB ITypeInfo2_GetDocumentation2_Stub(ITypeInfo2 *This, MEMBERID memid,
1910 LCID lcid, DWORD flags,
1911 BSTR *help_string, DWORD *help_context,
1912 BSTR *help_dll)
1914 TRACE("(%p, %08x, %08x, %08x, %p, %p, %p)\n", This, memid, lcid, flags, help_string, help_context, help_dll);
1916 *help_string = *help_dll = NULL;
1917 *help_context = 0;
1919 if(!(flags & 1)) help_string = NULL;
1920 if(!(flags & 2)) help_context = NULL;
1921 if(!(flags & 4)) help_dll = NULL;
1923 return ITypeInfo2_GetDocumentation2(This, memid, lcid, help_string, help_context, help_dll);
1926 /* ITypeLib */
1928 UINT CALLBACK ITypeLib_GetTypeInfoCount_Proxy(
1929 ITypeLib* This)
1931 UINT count = 0;
1932 TRACE("(%p)\n", This);
1934 ITypeLib_RemoteGetTypeInfoCount_Proxy(This, &count);
1936 return count;
1939 HRESULT __RPC_STUB ITypeLib_GetTypeInfoCount_Stub(
1940 ITypeLib* This,
1941 UINT* pcTInfo)
1943 TRACE("(%p, %p)\n", This, pcTInfo);
1944 *pcTInfo = ITypeLib_GetTypeInfoCount(This);
1945 return S_OK;
1948 HRESULT CALLBACK ITypeLib_GetLibAttr_Proxy(
1949 ITypeLib* This,
1950 TLIBATTR** ppTLibAttr)
1952 CLEANLOCALSTORAGE stg;
1953 TRACE("(%p, %p)\n", This, ppTLibAttr);
1955 stg.flags = 0;
1956 stg.pStorage = NULL;
1957 stg.pInterface = NULL;
1959 return ITypeLib_RemoteGetLibAttr_Proxy(This, ppTLibAttr, &stg);
1962 HRESULT __RPC_STUB ITypeLib_GetLibAttr_Stub(
1963 ITypeLib* This,
1964 LPTLIBATTR* ppTLibAttr,
1965 CLEANLOCALSTORAGE* pDummy)
1967 HRESULT hr;
1968 TRACE("(%p, %p)\n", This, ppTLibAttr);
1970 hr = ITypeLib_GetLibAttr(This, ppTLibAttr);
1971 if(hr != S_OK)
1972 return hr;
1974 pDummy->flags = CLS_LIBATTR;
1975 ITypeLib_AddRef(This);
1976 pDummy->pInterface = (IUnknown*)This;
1977 pDummy->pStorage = ppTLibAttr;
1978 return hr;
1981 HRESULT CALLBACK ITypeLib_GetDocumentation_Proxy(ITypeLib *This, INT index, BSTR *name,
1982 BSTR *doc_string, DWORD *help_context,
1983 BSTR *help_file)
1985 DWORD dummy_help_context, flags = 0;
1986 BSTR dummy_name, dummy_doc_string, dummy_help_file;
1987 HRESULT hr;
1988 TRACE("(%p, %d, %p, %p, %p, %p)\n", This, index, name, doc_string, help_context, help_file);
1990 if(!name) name = &dummy_name;
1991 else flags = 1;
1993 if(!doc_string) doc_string = &dummy_doc_string;
1994 else flags |= 2;
1996 if(!help_context) help_context = &dummy_help_context;
1997 else flags |= 4;
1999 if(!help_file) help_file = &dummy_help_file;
2000 else flags |= 8;
2002 hr = ITypeLib_RemoteGetDocumentation_Proxy(This, index, flags, name, doc_string, help_context, help_file);
2004 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2006 return hr;
2009 HRESULT __RPC_STUB ITypeLib_GetDocumentation_Stub(ITypeLib *This, INT index, DWORD flags,
2010 BSTR *name, BSTR *doc_string,
2011 DWORD *help_context, BSTR *help_file)
2013 TRACE("(%p, %d, %08x, %p, %p, %p, %p)\n", This, index, flags, name, doc_string, help_context, help_file);
2015 *name = *doc_string = *help_file = NULL;
2016 *help_context = 0;
2018 if(!(flags & 1)) name = NULL;
2019 if(!(flags & 2)) doc_string = NULL;
2020 if(!(flags & 4)) help_context = NULL;
2021 if(!(flags & 8)) help_file = NULL;
2023 return ITypeLib_GetDocumentation(This, index, name, doc_string, help_context, help_file);
2026 HRESULT CALLBACK ITypeLib_IsName_Proxy(
2027 ITypeLib* This,
2028 LPOLESTR szNameBuf,
2029 ULONG lHashVal,
2030 BOOL* pfName)
2032 FIXME("not implemented\n");
2033 return E_FAIL;
2036 HRESULT __RPC_STUB ITypeLib_IsName_Stub(
2037 ITypeLib* This,
2038 LPOLESTR szNameBuf,
2039 ULONG lHashVal,
2040 BOOL* pfName,
2041 BSTR* pBstrLibName)
2043 FIXME("not implemented\n");
2044 return E_FAIL;
2047 HRESULT CALLBACK ITypeLib_FindName_Proxy(
2048 ITypeLib* This,
2049 LPOLESTR szNameBuf,
2050 ULONG lHashVal,
2051 ITypeInfo** ppTInfo,
2052 MEMBERID* rgMemId,
2053 USHORT* pcFound)
2055 FIXME("not implemented\n");
2056 return E_FAIL;
2059 HRESULT __RPC_STUB ITypeLib_FindName_Stub(
2060 ITypeLib* This,
2061 LPOLESTR szNameBuf,
2062 ULONG lHashVal,
2063 ITypeInfo** ppTInfo,
2064 MEMBERID* rgMemId,
2065 USHORT* pcFound,
2066 BSTR* pBstrLibName)
2068 FIXME("not implemented\n");
2069 return E_FAIL;
2072 void CALLBACK ITypeLib_ReleaseTLibAttr_Proxy(
2073 ITypeLib* This,
2074 TLIBATTR* pTLibAttr)
2076 TRACE("(%p, %p)\n", This, pTLibAttr);
2077 CoTaskMemFree(pTLibAttr);
2080 HRESULT __RPC_STUB ITypeLib_ReleaseTLibAttr_Stub(
2081 ITypeLib* This)
2083 TRACE("nothing to do\n");
2084 return S_OK;
2088 /* ITypeLib2 */
2090 HRESULT CALLBACK ITypeLib2_GetLibStatistics_Proxy(
2091 ITypeLib2* This,
2092 ULONG* pcUniqueNames,
2093 ULONG* pcchUniqueNames)
2095 FIXME("not implemented\n");
2096 return E_FAIL;
2099 HRESULT __RPC_STUB ITypeLib2_GetLibStatistics_Stub(
2100 ITypeLib2* This,
2101 ULONG* pcUniqueNames,
2102 ULONG* pcchUniqueNames)
2104 FIXME("not implemented\n");
2105 return E_FAIL;
2108 HRESULT CALLBACK ITypeLib2_GetDocumentation2_Proxy(ITypeLib2 *This, INT index,
2109 LCID lcid, BSTR *help_string,
2110 DWORD *help_context, BSTR *help_dll)
2112 DWORD dummy_help_context, flags = 0;
2113 BSTR dummy_help_string, dummy_help_dll;
2114 HRESULT hr;
2115 TRACE("(%p, %d, %08x, %p, %p, %p)\n", This, index, lcid, help_string, help_context, help_dll);
2117 if(!help_string) help_string = &dummy_help_string;
2118 else flags = 1;
2120 if(!help_context) help_context = &dummy_help_context;
2121 else flags |= 2;
2123 if(!help_dll) help_dll = &dummy_help_dll;
2124 else flags |= 4;
2126 hr = ITypeLib2_RemoteGetDocumentation2_Proxy(This, index, lcid, flags, help_string, help_context, help_dll);
2128 /* We don't need to free the dummy BSTRs since the stub ensures that these will be NULLs. */
2130 return hr;
2133 HRESULT __RPC_STUB ITypeLib2_GetDocumentation2_Stub(ITypeLib2 *This, INT index, LCID lcid,
2134 DWORD flags, BSTR *help_string,
2135 DWORD *help_context, BSTR *help_dll)
2137 TRACE("(%p, %d, %08x, %08x, %p, %p, %p)\n", This, index, lcid, flags, help_string, help_context, help_dll);
2139 *help_string = *help_dll = NULL;
2140 *help_context = 0;
2142 if(!(flags & 1)) help_string = NULL;
2143 if(!(flags & 2)) help_context = NULL;
2144 if(!(flags & 4)) help_dll = NULL;
2146 return ITypeLib2_GetDocumentation2(This, index, lcid, help_string, help_context, help_dll);
2149 HRESULT CALLBACK IPropertyBag_Read_Proxy(
2150 IPropertyBag* This,
2151 LPCOLESTR pszPropName,
2152 VARIANT *pVar,
2153 IErrorLog *pErrorLog)
2155 IUnknown *pUnk = NULL;
2156 TRACE("(%p, %s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
2158 if(!pVar)
2159 return E_POINTER;
2161 if(V_VT(pVar) & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2163 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2164 return E_NOTIMPL;
2167 switch(V_VT(pVar))
2169 case VT_DISPATCH:
2170 pUnk = (IUnknown*)V_DISPATCH(pVar);
2171 break;
2172 case VT_UNKNOWN:
2173 pUnk = V_UNKNOWN(pVar);
2174 break;
2175 case VT_SAFEARRAY:
2176 FIXME("Safearray support not yet implemented.\n");
2177 return E_NOTIMPL;
2178 default:
2179 FIXME("Unknown V_VT %d - support not yet implemented.\n", V_VT(pVar));
2180 return E_NOTIMPL;
2183 return IPropertyBag_RemoteRead_Proxy(This, pszPropName, pVar, pErrorLog,
2184 V_VT(pVar), pUnk);
2187 HRESULT __RPC_STUB IPropertyBag_Read_Stub(
2188 IPropertyBag* This,
2189 LPCOLESTR pszPropName,
2190 VARIANT *pVar,
2191 IErrorLog *pErrorLog,
2192 DWORD varType,
2193 IUnknown *pUnkObj)
2195 static const WCHAR emptyWstr[] = {0};
2196 IDispatch *disp;
2197 HRESULT hr;
2198 TRACE("(%p, %s, %p, %p, %x, %p)\n", This, debugstr_w(pszPropName), pVar,
2199 pErrorLog, varType, pUnkObj);
2201 if(varType & (VT_BYREF | VT_ARRAY | VT_VECTOR))
2203 FIXME("Variant type %x is byref, array or vector. Not implemented.\n", V_VT(pVar));
2204 return E_NOTIMPL;
2207 V_VT(pVar) = varType;
2208 switch(varType)
2210 case VT_DISPATCH:
2211 hr = IUnknown_QueryInterface(pUnkObj, &IID_IDispatch, (LPVOID*)&disp);
2212 if(FAILED(hr))
2213 return hr;
2214 IUnknown_Release(pUnkObj);
2215 V_DISPATCH(pVar) = disp;
2216 break;
2217 case VT_UNKNOWN:
2218 V_UNKNOWN(pVar) = pUnkObj;
2219 break;
2220 case VT_BSTR:
2221 V_BSTR(pVar) = SysAllocString(emptyWstr);
2222 break;
2223 case VT_SAFEARRAY:
2224 FIXME("Safearray support not yet implemented.\n");
2225 return E_NOTIMPL;
2226 default:
2227 break;
2229 hr = IPropertyBag_Read(This, pszPropName, pVar, pErrorLog);
2230 if(FAILED(hr))
2231 VariantClear(pVar);
2233 return hr;
2236 /* call_as/local stubs for ocidl.idl */
2238 HRESULT CALLBACK IClassFactory2_CreateInstanceLic_Proxy(
2239 IClassFactory2* This,
2240 IUnknown *pUnkOuter,
2241 IUnknown *pUnkReserved,
2242 REFIID riid,
2243 BSTR bstrKey,
2244 PVOID *ppvObj)
2246 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppvObj);
2248 *ppvObj = NULL;
2250 if (pUnkOuter)
2252 ERR("aggregation is not allowed on remote objects\n");
2253 return CLASS_E_NOAGGREGATION;
2256 return IClassFactory2_RemoteCreateInstanceLic_Proxy(This, riid, bstrKey, (IUnknown**)ppvObj);
2259 HRESULT __RPC_STUB IClassFactory2_CreateInstanceLic_Stub(
2260 IClassFactory2* This,
2261 REFIID riid,
2262 BSTR bstrKey,
2263 IUnknown **ppvObj)
2265 TRACE("(%s, %p)\n", debugstr_guid(riid), ppvObj);
2266 return IClassFactory2_CreateInstanceLic(This, NULL, NULL, riid, bstrKey, (void**)ppvObj);
2269 HRESULT CALLBACK IEnumConnections_Next_Proxy(
2270 IEnumConnections* This,
2271 ULONG cConnections,
2272 LPCONNECTDATA rgcd,
2273 ULONG *pcFetched)
2275 FIXME("not implemented\n");
2276 return E_NOTIMPL;
2279 HRESULT __RPC_STUB IEnumConnections_Next_Stub(
2280 IEnumConnections* This,
2281 ULONG cConnections,
2282 LPCONNECTDATA rgcd,
2283 ULONG *pcFetched)
2285 FIXME("not implemented\n");
2286 return E_NOTIMPL;
2289 HRESULT CALLBACK IEnumConnectionPoints_Next_Proxy(
2290 IEnumConnectionPoints* This,
2291 ULONG cConnections,
2292 LPCONNECTIONPOINT *ppCP,
2293 ULONG *pcFetched)
2295 FIXME("not implemented\n");
2296 return E_NOTIMPL;
2299 HRESULT __RPC_STUB IEnumConnectionPoints_Next_Stub(
2300 IEnumConnectionPoints* This,
2301 ULONG cConnections,
2302 LPCONNECTIONPOINT *ppCP,
2303 ULONG *pcFetched)
2305 FIXME("not implemented\n");
2306 return E_NOTIMPL;
2309 HRESULT CALLBACK IPersistMemory_Load_Proxy(
2310 IPersistMemory* This,
2311 LPVOID pMem,
2312 ULONG cbSize)
2314 FIXME("not implemented\n");
2315 return E_NOTIMPL;
2318 HRESULT __RPC_STUB IPersistMemory_Load_Stub(
2319 IPersistMemory* This,
2320 BYTE *pMem,
2321 ULONG cbSize)
2323 FIXME("not implemented\n");
2324 return E_NOTIMPL;
2327 HRESULT CALLBACK IPersistMemory_Save_Proxy(
2328 IPersistMemory* This,
2329 LPVOID pMem,
2330 BOOL fClearDirty,
2331 ULONG cbSize)
2333 FIXME("not implemented\n");
2334 return E_NOTIMPL;
2337 HRESULT __RPC_STUB IPersistMemory_Save_Stub(
2338 IPersistMemory* This,
2339 BYTE *pMem,
2340 BOOL fClearDirty,
2341 ULONG cbSize)
2343 FIXME("not implemented\n");
2344 return E_NOTIMPL;
2347 void CALLBACK IAdviseSinkEx_OnViewStatusChange_Proxy(
2348 IAdviseSinkEx* This,
2349 DWORD dwViewStatus)
2351 FIXME("not implemented\n");
2354 HRESULT __RPC_STUB IAdviseSinkEx_OnViewStatusChange_Stub(
2355 IAdviseSinkEx* This,
2356 DWORD dwViewStatus)
2358 FIXME("not implemented\n");
2359 return E_NOTIMPL;
2362 HRESULT CALLBACK IEnumOleUndoUnits_Next_Proxy(
2363 IEnumOleUndoUnits* This,
2364 ULONG cElt,
2365 IOleUndoUnit **rgElt,
2366 ULONG *pcEltFetched)
2368 FIXME("not implemented\n");
2369 return E_NOTIMPL;
2372 HRESULT __RPC_STUB IEnumOleUndoUnits_Next_Stub(
2373 IEnumOleUndoUnits* This,
2374 ULONG cElt,
2375 IOleUndoUnit **rgElt,
2376 ULONG *pcEltFetched)
2378 FIXME("not implemented\n");
2379 return E_NOTIMPL;
2382 HRESULT CALLBACK IQuickActivate_QuickActivate_Proxy(
2383 IQuickActivate* This,
2384 QACONTAINER *pQaContainer,
2385 QACONTROL *pQaControl)
2387 FIXME("not implemented\n");
2388 return E_NOTIMPL;
2391 HRESULT __RPC_STUB IQuickActivate_QuickActivate_Stub(
2392 IQuickActivate* This,
2393 QACONTAINER *pQaContainer,
2394 QACONTROL *pQaControl)
2396 FIXME("not implemented\n");
2397 return E_NOTIMPL;