xref: /reactos/dll/win32/msxml3/dispex.c (revision bae2bac6)
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #define COBJMACROS
20 
21 #include "config.h"
22 
23 #include <stdarg.h>
24 #ifdef HAVE_LIBXML2
25 # include <libxml/parser.h>
26 # include <libxml/xmlerror.h>
27 #endif
28 
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "winnls.h"
33 #include "ole2.h"
34 #include "msxml6.h"
35 #include "msxml6did.h"
36 #include "wininet.h"
37 #include "urlmon.h"
38 #include "winreg.h"
39 #include "shlwapi.h"
40 
41 #include "wine/debug.h"
42 #include "wine/unicode.h"
43 
44 #include "msxml_private.h"
45 
46 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
47 
48 static CRITICAL_SECTION cs_dispex_static_data;
49 static CRITICAL_SECTION_DEBUG cs_dispex_static_data_dbg =
50 {
51     0, 0, &cs_dispex_static_data,
52     { &cs_dispex_static_data_dbg.ProcessLocksList, &cs_dispex_static_data_dbg.ProcessLocksList },
53       0, 0, { (DWORD_PTR)(__FILE__ ": dispex_static_data") }
54 };
55 static CRITICAL_SECTION cs_dispex_static_data = { &cs_dispex_static_data_dbg, -1, 0, 0, 0, 0 };
56 
57 
58 enum lib_version_t
59 {
60     LibXml = 0,
61     LibXml2,
62     LibXml_Last
63 };
64 
65 typedef struct {
66     REFIID iid;
67     enum lib_version_t lib;
68 } tid_id_t;
69 
70 typedef struct {
71     REFIID iid;
72     unsigned short major;
73 } lib_id_t;
74 
75 typedef struct {
76     DISPID id;
77     BSTR name;
78     enum tid_t tid;
79 } func_info_t;
80 
81 struct dispex_data_t {
82     DWORD func_cnt;
83     func_info_t *funcs;
84     func_info_t **name_table;
85 
86     struct list entry;
87 };
88 
89 static struct list dispex_data_list = LIST_INIT(dispex_data_list);
90 static ITypeLib *typelib[LibXml_Last];
91 static ITypeInfo *typeinfos[LAST_tid];
92 
93 /* indexed with lib_version_t values */
94 static lib_id_t lib_ids[] = {
95     { &LIBID_MSXML,  2 },
96     { &LIBID_MSXML2, 3 }
97 };
98 
99 static tid_id_t tid_ids[] = {
100     { &IID_NULL, LibXml_Last },
101     { &IID_IXMLDOMAttribute, LibXml2 },
102     { &IID_IXMLDOMCDATASection, LibXml2 },
103     { &IID_IXMLDOMComment, LibXml2 },
104     { &IID_IXMLDOMDocument, LibXml2 },
105     { &IID_IXMLDOMDocument2, LibXml2 },
106     { &IID_IXMLDOMDocument3, LibXml2 },
107     { &IID_IXMLDOMDocumentFragment, LibXml2 },
108     { &IID_IXMLDOMDocumentType, LibXml2 },
109     { &IID_IXMLDOMElement, LibXml2 },
110     { &IID_IXMLDOMEntityReference, LibXml2 },
111     { &IID_IXMLDOMImplementation, LibXml2 },
112     { &IID_IXMLDOMNamedNodeMap, LibXml2 },
113     { &IID_IXMLDOMNode, LibXml2 },
114     { &IID_IXMLDOMNodeList, LibXml2 },
115     { &IID_IXMLDOMParseError2, LibXml2 },
116     { &IID_IXMLDOMProcessingInstruction, LibXml2 },
117     { &IID_IXMLDOMSchemaCollection, LibXml2 },
118     { &IID_IXMLDOMSchemaCollection2, LibXml2 },
119     { &IID_IXMLDOMSelection, LibXml2 },
120     { &IID_IXMLDOMText, LibXml2 },
121     { &IID_IXMLElement, LibXml },
122     { &IID_IXMLDocument, LibXml },
123     { &IID_IXMLHTTPRequest, LibXml2 },
124     { &IID_IXSLProcessor, LibXml2 },
125     { &IID_IXSLTemplate, LibXml2 },
126     { &IID_IVBSAXAttributes, LibXml2 },
127     { &IID_IVBSAXContentHandler, LibXml2 },
128     { &IID_IVBSAXDeclHandler, LibXml2 },
129     { &IID_IVBSAXDTDHandler, LibXml2 },
130     { &IID_IVBSAXEntityResolver, LibXml2 },
131     { &IID_IVBSAXErrorHandler, LibXml2 },
132     { &IID_IVBSAXLexicalHandler, LibXml2 },
133     { &IID_IVBSAXLocator, LibXml2 },
134     { &IID_IVBSAXXMLFilter, LibXml2 },
135     { &IID_IVBSAXXMLReader, LibXml2 },
136     { &IID_IMXAttributes, LibXml2 },
137     { &IID_IMXReaderControl, LibXml2 },
138     { &IID_IMXWriter, LibXml2 },
139     { &IID_IVBMXNamespaceManager, LibXml2 },
140     { &IID_IServerXMLHTTPRequest, LibXml2 }
141 };
142 
143 const IID *get_riid_from_tid(tid_t tid)
144 {
145     return tid_ids[tid].iid;
146 }
147 
148 static inline unsigned get_libid_from_tid(tid_t tid)
149 {
150     return tid_ids[tid].lib;
151 }
152 
153 HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
154 {
155     unsigned lib = get_libid_from_tid(tid);
156     HRESULT hres;
157 
158     if(!typelib[lib]) {
159         ITypeLib *tl;
160 
161         hres = LoadRegTypeLib(lib_ids[lib].iid, lib_ids[lib].major, 0, LOCALE_SYSTEM_DEFAULT, &tl);
162         if(FAILED(hres)) {
163             ERR("LoadRegTypeLib failed: %08x\n", hres);
164             return hres;
165         }
166 
167         if(InterlockedCompareExchangePointer((void**)&typelib[lib], tl, NULL))
168             ITypeLib_Release(tl);
169     }
170 
171     if(!typeinfos[tid]) {
172         ITypeInfo *ti;
173 
174         hres = ITypeLib_GetTypeInfoOfGuid(typelib[lib], get_riid_from_tid(tid), &ti);
175         if(FAILED(hres)) {
176             /* try harder with typelib from msxml.dll */
177             hres = ITypeLib_GetTypeInfoOfGuid(typelib[LibXml], get_riid_from_tid(tid), &ti);
178             if(FAILED(hres)) {
179                 ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
180                 return hres;
181             }
182         }
183 
184         if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
185             ITypeInfo_Release(ti);
186     }
187 
188     *typeinfo = typeinfos[tid];
189 
190     ITypeInfo_AddRef(typeinfos[tid]);
191     return S_OK;
192 }
193 
194 void release_typelib(void)
195 {
196     dispex_data_t *iter;
197     unsigned i;
198 
199     while(!list_empty(&dispex_data_list)) {
200         iter = LIST_ENTRY(list_head(&dispex_data_list), dispex_data_t, entry);
201         list_remove(&iter->entry);
202 
203         for(i=0; i < iter->func_cnt; i++)
204             SysFreeString(iter->funcs[i].name);
205 
206         heap_free(iter->funcs);
207         heap_free(iter->name_table);
208         heap_free(iter);
209     }
210 
211     for(i=0; i < ARRAY_SIZE(typeinfos); i++)
212         if(typeinfos[i])
213             ITypeInfo_Release(typeinfos[i]);
214 
215     for(i=0; i < ARRAY_SIZE(typelib); i++)
216         if(typelib[i])
217             ITypeLib_Release(typelib[i]);
218 
219     DeleteCriticalSection(&cs_dispex_static_data);
220 }
221 
222 static void add_func_info(dispex_data_t *data, DWORD *size, tid_t tid, DISPID id, ITypeInfo *dti)
223 {
224     HRESULT hres;
225 
226     if(data->func_cnt && data->funcs[data->func_cnt-1].id == id)
227         return;
228 
229     if(data->func_cnt == *size)
230         data->funcs = heap_realloc(data->funcs, (*size <<= 1)*sizeof(func_info_t));
231 
232     hres = ITypeInfo_GetDocumentation(dti, id, &data->funcs[data->func_cnt].name, NULL, NULL, NULL);
233     if(FAILED(hres))
234         return;
235 
236     data->funcs[data->func_cnt].id = id;
237     data->funcs[data->func_cnt].tid = tid;
238 
239     data->func_cnt++;
240 }
241 
242 static int dispid_cmp(const void *p1, const void *p2)
243 {
244     return ((const func_info_t*)p1)->id - ((const func_info_t*)p2)->id;
245 }
246 
247 static int func_name_cmp(const void *p1, const void *p2)
248 {
249     return strcmpiW((*(func_info_t* const*)p1)->name, (*(func_info_t* const*)p2)->name);
250 }
251 
252 static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
253 {
254     const tid_t *tid = This->data->iface_tids;
255     FUNCDESC *funcdesc;
256     dispex_data_t *data;
257     DWORD size = 16, i;
258     ITypeInfo *ti, *dti;
259     HRESULT hres;
260 
261     TRACE("(%p)\n", This);
262 
263     hres = get_typeinfo(This->data->disp_tid, &dti);
264     if(FAILED(hres)) {
265         ERR("Could not get disp type info: %08x\n", hres);
266         return NULL;
267     }
268 
269     data = heap_alloc(sizeof(dispex_data_t));
270     data->func_cnt = 0;
271     data->funcs = heap_alloc(size*sizeof(func_info_t));
272     list_add_tail(&dispex_data_list, &data->entry);
273 
274     while(*tid) {
275         hres = get_typeinfo(*tid, &ti);
276         if(FAILED(hres))
277             break;
278 
279         i=0;
280         while(1) {
281             hres = ITypeInfo_GetFuncDesc(ti, i++, &funcdesc);
282             if(FAILED(hres))
283                 break;
284 
285             add_func_info(data, &size, *tid, funcdesc->memid, dti);
286             ITypeInfo_ReleaseFuncDesc(ti, funcdesc);
287         }
288 
289         ITypeInfo_Release(ti);
290         tid++;
291     }
292 
293     if(!data->func_cnt) {
294         heap_free(data->funcs);
295         data->funcs = NULL;
296     }else if(data->func_cnt != size) {
297         data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
298     }
299 
300     qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
301 
302     if(data->funcs) {
303         data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
304         for(i=0; i < data->func_cnt; i++)
305             data->name_table[i] = data->funcs+i;
306         qsort(data->name_table, data->func_cnt, sizeof(func_info_t*), func_name_cmp);
307     }else {
308         data->name_table = NULL;
309     }
310 
311     ITypeInfo_Release(dti);
312     return data;
313 }
314 
315 static dispex_data_t *get_dispex_data(DispatchEx *This)
316 {
317     if(This->data->data)
318         return This->data->data;
319 
320     EnterCriticalSection(&cs_dispex_static_data);
321 
322     if(!This->data->data)
323         This->data->data = preprocess_dispex_data(This);
324 
325     LeaveCriticalSection(&cs_dispex_static_data);
326 
327     return This->data->data;
328 }
329 
330 static inline DispatchEx *impl_from_IDispatchEx(IDispatchEx *iface)
331 {
332     return CONTAINING_RECORD(iface, DispatchEx, IDispatchEx_iface);
333 }
334 
335 static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
336 {
337     DispatchEx *This = impl_from_IDispatchEx(iface);
338 
339     return IUnknown_QueryInterface(This->outer, riid, ppv);
340 }
341 
342 static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface)
343 {
344     DispatchEx *This = impl_from_IDispatchEx(iface);
345 
346     return IUnknown_AddRef(This->outer);
347 }
348 
349 static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface)
350 {
351     DispatchEx *This = impl_from_IDispatchEx(iface);
352 
353     return IUnknown_Release(This->outer);
354 }
355 
356 static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
357 {
358     DispatchEx *This = impl_from_IDispatchEx(iface);
359 
360     TRACE("(%p)->(%p)\n", This, pctinfo);
361 
362     *pctinfo = 1;
363     return S_OK;
364 }
365 
366 static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
367                                               LCID lcid, ITypeInfo **ppTInfo)
368 {
369     DispatchEx *This = impl_from_IDispatchEx(iface);
370 
371     TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
372 
373     return get_typeinfo(This->data->disp_tid, ppTInfo);
374 }
375 
376 static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
377                                                 LPOLESTR *rgszNames, UINT cNames,
378                                                 LCID lcid, DISPID *rgDispId)
379 {
380     DispatchEx *This = impl_from_IDispatchEx(iface);
381     UINT i;
382     HRESULT hres;
383 
384     TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
385           lcid, rgDispId);
386 
387     for(i=0; i < cNames; i++) {
388         hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
389         if(FAILED(hres))
390             return hres;
391     }
392 
393     return S_OK;
394 }
395 
396 static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
397                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
398                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
399 {
400     DispatchEx *This = impl_from_IDispatchEx(iface);
401 
402     TRACE("(%p)->(%x %s %x %x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
403           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
404 
405     return IDispatchEx_InvokeEx(&This->IDispatchEx_iface, dispIdMember, lcid, wFlags,
406                                 pDispParams, pVarResult, pExcepInfo, NULL);
407 }
408 
409 static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
410 {
411     DispatchEx *This = impl_from_IDispatchEx(iface);
412     dispex_data_t *data;
413     int min, max, n, c;
414 
415     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
416 
417     if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit))
418         FIXME("Unsupported grfdex %x\n", grfdex);
419 
420     data = get_dispex_data(This);
421     if(!data)
422         return E_FAIL;
423 
424     min = 0;
425     max = data->func_cnt-1;
426 
427     while(min <= max) {
428         n = (min+max)/2;
429 
430         c = strcmpiW(data->name_table[n]->name, bstrName);
431         if(!c) {
432             if((grfdex & fdexNameCaseSensitive) && strcmpW(data->name_table[n]->name, bstrName))
433                 break;
434 
435             *pid = data->name_table[n]->id;
436             return S_OK;
437         }
438 
439         if(c > 0)
440             max = n-1;
441         else
442             min = n+1;
443     }
444 
445     if(This->data->vtbl && This->data->vtbl->get_dispid) {
446         HRESULT hres;
447 
448         hres = This->data->vtbl->get_dispid(This->outer, bstrName, grfdex, pid);
449         if(hres != DISP_E_UNKNOWNNAME)
450             return hres;
451     }
452 
453     TRACE("not found %s\n", debugstr_w(bstrName));
454     return DISP_E_UNKNOWNNAME;
455 }
456 
457 static BOOL is_propputref_id(DISPID id)
458 {
459     switch (id)
460     {
461     case DISPID_DOM_DOCUMENT_DOCUMENTELEMENT:
462     case DISPID_XMLDOM_DOCUMENT2_SCHEMAS:
463     case DISPID_XMLDOM_SELECTION_CONTEXT:
464     case DISPID_XMLDOM_TEMPLATE_STYLESHEET:
465     case DISPID_SAX_CONTENTHANDLER_DOCUMENTLOCATOR:
466     case DISPID_SAX_XMLFILTER_PARENT:
467     case DISPID_SAX_XMLREADER_ENTITYRESOLVER:
468     case DISPID_SAX_XMLREADER_CONTENTHANDLER:
469     case DISPID_SAX_XMLREADER_DTDHANDLER:
470     case DISPID_SAX_XMLREADER_ERRORHANDLER:
471     case DISPID_MXXML_FILTER_ENTITYRESOLVER:
472     case DISPID_MXXML_FILTER_CONTENTHANDLER:
473     case DISPID_MXXML_FILTER_DTDHANDLER:
474     case DISPID_MXXML_FILTER_ERRORHANDLER:
475         return TRUE;
476     default:
477         return FALSE;
478     }
479 }
480 
481 static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
482         VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
483 {
484     DispatchEx *This = impl_from_IDispatchEx(iface);
485     IUnknown *unk;
486     ITypeInfo *ti;
487     dispex_data_t *data;
488     UINT argerr=0;
489     int min, max, n;
490     HRESULT hres;
491 
492     TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
493 
494     if(This->data->vtbl && This->data->vtbl->invoke) {
495         hres = This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei);
496         if (hres != DISP_E_UNKNOWNNAME) return hres;
497     }
498 
499     if(wFlags == DISPATCH_CONSTRUCT) {
500         FIXME("DISPATCH_CONSTRUCT not implemented\n");
501         return E_NOTIMPL;
502     }
503 
504     data = get_dispex_data(This);
505     if(!data)
506         return E_FAIL;
507 
508     min = 0;
509     max = data->func_cnt-1;
510 
511     while(min <= max) {
512         n = (min+max)/2;
513 
514         if(data->funcs[n].id == id)
515             break;
516 
517         if(data->funcs[n].id < id)
518             min = n+1;
519         else
520             max = n-1;
521     }
522 
523     if(min > max) {
524         WARN("invalid id %x\n", id);
525         return DISP_E_UNKNOWNNAME;
526     }
527 
528     hres = get_typeinfo(data->funcs[n].tid, &ti);
529     if(FAILED(hres)) {
530         ERR("Could not get type info: %08x\n", hres);
531         return hres;
532     }
533 
534     hres = IUnknown_QueryInterface(This->outer, get_riid_from_tid(data->funcs[n].tid), (void**)&unk);
535     if(FAILED(hres)) {
536         ERR("Could not get iface: %08x\n", hres);
537         ITypeInfo_Release(ti);
538         return E_FAIL;
539     }
540 
541     if (is_propputref_id(id) && wFlags == DISPATCH_PROPERTYPUT)
542         wFlags = DISPATCH_PROPERTYPUTREF;
543     hres = ITypeInfo_Invoke(ti, unk, id, wFlags, pdp, pvarRes, pei, &argerr);
544 
545     ITypeInfo_Release(ti);
546     IUnknown_Release(unk);
547     return hres;
548 }
549 
550 static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
551 {
552     DispatchEx *This = impl_from_IDispatchEx(iface);
553     TRACE("Not implemented in native msxml3 (%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
554     return E_NOTIMPL;
555 }
556 
557 static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
558 {
559     DispatchEx *This = impl_from_IDispatchEx(iface);
560     TRACE("Not implemented in native msxml3 (%p)->(%x)\n", This, id);
561     return E_NOTIMPL;
562 }
563 
564 static HRESULT WINAPI DispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
565 {
566     DispatchEx *This = impl_from_IDispatchEx(iface);
567     TRACE("Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
568     return E_NOTIMPL;
569 }
570 
571 static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
572 {
573     DispatchEx *This = impl_from_IDispatchEx(iface);
574     TRACE("Not implemented in native msxml3 (%p)->(%x %p)\n", This, id, pbstrName);
575     return E_NOTIMPL;
576 }
577 
578 static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
579 {
580     DispatchEx *This = impl_from_IDispatchEx(iface);
581     TRACE(" Not implemented in native msxml3 (%p)->(%x %x %p)\n", This, grfdex, id, pid);
582     return E_NOTIMPL;
583 }
584 
585 static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
586 {
587     DispatchEx *This = impl_from_IDispatchEx(iface);
588     TRACE("Not implemented in native msxml3 (%p)->(%p)\n", This, ppunk);
589     return E_NOTIMPL;
590 }
591 
592 static IDispatchExVtbl DispatchExVtbl = {
593     DispatchEx_QueryInterface,
594     DispatchEx_AddRef,
595     DispatchEx_Release,
596     DispatchEx_GetTypeInfoCount,
597     DispatchEx_GetTypeInfo,
598     DispatchEx_GetIDsOfNames,
599     DispatchEx_Invoke,
600     DispatchEx_GetDispID,
601     DispatchEx_InvokeEx,
602     DispatchEx_DeleteMemberByName,
603     DispatchEx_DeleteMemberByDispID,
604     DispatchEx_GetMemberProperties,
605     DispatchEx_GetMemberName,
606     DispatchEx_GetNextDispID,
607     DispatchEx_GetNameSpaceParent
608 };
609 
610 BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
611 {
612     static const IID IID_UndocumentedScriptIface =
613         {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa0}};
614     static const IID IID_IDispatchJS =
615         {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}};
616 
617     if(IsEqualGUID(&IID_IDispatch, riid)) {
618         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
619         *ppv = &This->IDispatchEx_iface;
620     }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
621         TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
622         *ppv = &This->IDispatchEx_iface;
623     }else if(IsEqualGUID(&IID_IDispatchJS, riid)) {
624         TRACE("(%p)->(IID_IDispatchJS %p) returning NULL\n", This, ppv);
625         *ppv = NULL;
626     }else if(IsEqualGUID(&IID_UndocumentedScriptIface, riid)) {
627         TRACE("(%p)->(IID_UndocumentedScriptIface %p) returning NULL\n", This, ppv);
628         *ppv = NULL;
629     }else if (IsEqualGUID(&IID_IObjectIdentity, riid)) {
630         TRACE("IID_IObjectIdentity not supported returning NULL\n");
631         *ppv = NULL;
632     }else {
633         return FALSE;
634     }
635 
636     if(*ppv)
637         IUnknown_AddRef((IUnknown*)*ppv);
638     return TRUE;
639 }
640 
641 void init_dispex(DispatchEx *dispex, IUnknown *outer, dispex_static_data_t *data)
642 {
643     dispex->IDispatchEx_iface.lpVtbl = &DispatchExVtbl;
644     dispex->outer = outer;
645     dispex->data = data;
646 }
647