xref: /reactos/dll/win32/mshtml/main.c (revision 845faec4)
1 /*
2  *    MSHTML Class Factory
3  *
4  * Copyright 2002 Lionel Ulmer
5  * Copyright 2003 Mike McCormack
6  * Copyright 2005 Jacek Caban
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22 
23 #include "mshtml_private.h"
24 
25 #include <advpub.h>
26 #include <rpcproxy.h>
27 #include <mlang.h>
28 #include <initguid.h>
29 
30 HINSTANCE hInst;
31 DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
32 
33 static HINSTANCE shdoclc = NULL;
34 static HDC display_dc;
35 static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
36 static IMultiLanguage2 *mlang;
37 
38 UINT cp_from_charset_string(BSTR charset)
39 {
40     MIMECSETINFO info;
41     HRESULT hres;
42 
43     if(!mlang) {
44         IMultiLanguage2 *new_mlang;
45 
46         hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
47                 &IID_IMultiLanguage2, (void**)&new_mlang);
48         if(FAILED(hres)) {
49             ERR("Could not create CMultiLanguage instance\n");
50             return CP_UTF8;
51         }
52 
53         if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
54             IMultiLanguage2_Release(new_mlang);
55     }
56 
57     hres = IMultiLanguage2_GetCharsetInfo(mlang, charset, &info);
58     if(FAILED(hres)) {
59         FIXME("GetCharsetInfo failed: %08x\n", hres);
60         return CP_UTF8;
61     }
62 
63     return info.uiInternetEncoding;
64 }
65 
66 static void thread_detach(void)
67 {
68     thread_data_t *thread_data;
69 
70     thread_data = get_thread_data(FALSE);
71     if(!thread_data)
72         return;
73 
74     if(thread_data->thread_hwnd)
75         DestroyWindow(thread_data->thread_hwnd);
76 
77     heap_free(thread_data);
78 }
79 
80 static void free_strings(void)
81 {
82     unsigned int i;
83     for(i = 0; i < sizeof(status_strings)/sizeof(*status_strings); i++)
84         heap_free(status_strings[i]);
85 }
86 
87 static void process_detach(void)
88 {
89     close_gecko();
90     release_typelib();
91 
92     if(shdoclc)
93         FreeLibrary(shdoclc);
94     if(mshtml_tls != TLS_OUT_OF_INDEXES)
95         TlsFree(mshtml_tls);
96     if(display_dc)
97         DeleteObject(display_dc);
98     if(mlang)
99         IMultiLanguage2_Release(mlang);
100 
101     free_strings();
102 }
103 
104 void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg)
105 {
106     int index = id - IDS_STATUS_FIRST;
107     WCHAR *p = status_strings[index];
108     DWORD len;
109 
110     if(!doc->frame)
111         return;
112 
113     if(!p) {
114         len = 255;
115         p = heap_alloc(len * sizeof(WCHAR));
116         len = LoadStringW(hInst, id, p, len) + 1;
117         p = heap_realloc(p, len * sizeof(WCHAR));
118         if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) {
119             heap_free(p);
120             p = status_strings[index];
121         }
122     }
123 
124     if(arg) {
125         WCHAR *buf;
126 
127         len = lstrlenW(p) + lstrlenW(arg) - 1;
128         buf = heap_alloc(len * sizeof(WCHAR));
129 
130         snprintfW(buf, len, p, arg);
131 
132         p = buf;
133     }
134 
135     IOleInPlaceFrame_SetStatusText(doc->frame, p);
136 
137     if(arg)
138         heap_free(p);
139 }
140 
141 HRESULT do_query_service(IUnknown *unk, REFGUID guid_service, REFIID riid, void **ppv)
142 {
143     IServiceProvider *sp;
144     HRESULT hres;
145 
146     hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&sp);
147     if(FAILED(hres))
148         return hres;
149 
150     hres = IServiceProvider_QueryService(sp, guid_service, riid, ppv);
151     IServiceProvider_Release(sp);
152     return hres;
153 }
154 
155 HINSTANCE get_shdoclc(void)
156 {
157     static const WCHAR wszShdoclc[] =
158         {'s','h','d','o','c','l','c','.','d','l','l',0};
159 
160     if(shdoclc)
161         return shdoclc;
162 
163     return shdoclc = LoadLibraryExW(wszShdoclc, NULL, LOAD_LIBRARY_AS_DATAFILE);
164 }
165 
166 HDC get_display_dc(void)
167 {
168     static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
169 
170     if(!display_dc) {
171         HDC hdc;
172 
173         hdc = CreateICW(displayW, NULL, NULL, NULL);
174         if(InterlockedCompareExchangePointer((void**)&display_dc, hdc, NULL))
175             DeleteObject(hdc);
176     }
177 
178     return display_dc;
179 }
180 
181 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
182 {
183     switch(fdwReason) {
184     case DLL_PROCESS_ATTACH:
185         hInst = hInstDLL;
186         break;
187     case DLL_PROCESS_DETACH:
188         if (reserved) break;
189         process_detach();
190         break;
191     case DLL_THREAD_DETACH:
192         thread_detach();
193         break;
194     }
195     return TRUE;
196 }
197 
198 /***********************************************************
199  *    ClassFactory implementation
200  */
201 typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**);
202 typedef struct {
203     IClassFactory IClassFactory_iface;
204     LONG ref;
205     CreateInstanceFunc fnCreateInstance;
206 } ClassFactory;
207 
208 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
209 {
210     return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
211 }
212 
213 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFGUID riid, void **ppvObject)
214 {
215     if(IsEqualGUID(&IID_IClassFactory, riid) || IsEqualGUID(&IID_IUnknown, riid)) {
216         IClassFactory_AddRef(iface);
217         *ppvObject = iface;
218         return S_OK;
219     }
220 
221     WARN("not supported iid %s\n", debugstr_mshtml_guid(riid));
222     *ppvObject = NULL;
223     return E_NOINTERFACE;
224 }
225 
226 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
227 {
228     ClassFactory *This = impl_from_IClassFactory(iface);
229     ULONG ref = InterlockedIncrement(&This->ref);
230     TRACE("(%p) ref = %u\n", This, ref);
231     return ref;
232 }
233 
234 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
235 {
236     ClassFactory *This = impl_from_IClassFactory(iface);
237     ULONG ref = InterlockedDecrement(&This->ref);
238 
239     TRACE("(%p) ref = %u\n", This, ref);
240 
241     if(!ref) {
242         heap_free(This);
243     }
244 
245     return ref;
246 }
247 
248 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
249         REFIID riid, void **ppvObject)
250 {
251     ClassFactory *This = impl_from_IClassFactory(iface);
252     return This->fnCreateInstance(pUnkOuter, riid, ppvObject);
253 }
254 
255 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
256 {
257     TRACE("(%p)->(%x)\n", iface, dolock);
258 
259     /* We never unload the DLL. See DllCanUnloadNow(). */
260     return S_OK;
261 }
262 
263 static const IClassFactoryVtbl HTMLClassFactoryVtbl = {
264     ClassFactory_QueryInterface,
265     ClassFactory_AddRef,
266     ClassFactory_Release,
267     ClassFactory_CreateInstance,
268     ClassFactory_LockServer
269 };
270 
271 static HRESULT ClassFactory_Create(REFIID riid, void **ppv, CreateInstanceFunc fnCreateInstance)
272 {
273     ClassFactory *ret = heap_alloc(sizeof(ClassFactory));
274     HRESULT hres;
275 
276     ret->IClassFactory_iface.lpVtbl = &HTMLClassFactoryVtbl;
277     ret->ref = 0;
278     ret->fnCreateInstance = fnCreateInstance;
279 
280     hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
281     if(FAILED(hres)) {
282         heap_free(ret);
283         *ppv = NULL;
284     }
285     return hres;
286 }
287 
288 /******************************************************************
289  *		DllGetClassObject (MSHTML.@)
290  */
291 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
292 {
293     if(IsEqualGUID(&CLSID_HTMLDocument, rclsid)) {
294         TRACE("(CLSID_HTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
295         return ClassFactory_Create(riid, ppv, HTMLDocument_Create);
296     }else if(IsEqualGUID(&CLSID_AboutProtocol, rclsid)) {
297         TRACE("(CLSID_AboutProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
298         return ProtocolFactory_Create(rclsid, riid, ppv);
299     }else if(IsEqualGUID(&CLSID_JSProtocol, rclsid)) {
300         TRACE("(CLSID_JSProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
301         return ProtocolFactory_Create(rclsid, riid, ppv);
302     }else if(IsEqualGUID(&CLSID_MailtoProtocol, rclsid)) {
303         TRACE("(CLSID_MailtoProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
304         return ProtocolFactory_Create(rclsid, riid, ppv);
305     }else if(IsEqualGUID(&CLSID_ResProtocol, rclsid)) {
306         TRACE("(CLSID_ResProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
307         return ProtocolFactory_Create(rclsid, riid, ppv);
308     }else if(IsEqualGUID(&CLSID_SysimageProtocol, rclsid)) {
309         TRACE("(CLSID_SysimageProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
310         return ProtocolFactory_Create(rclsid, riid, ppv);
311     }else if(IsEqualGUID(&CLSID_HTMLLoadOptions, rclsid)) {
312         TRACE("(CLSID_HTMLLoadOptions %s %p)\n", debugstr_mshtml_guid(riid), ppv);
313         return ClassFactory_Create(riid, ppv, HTMLLoadOptions_Create);
314     }
315 
316     FIXME("Unknown class %s\n", debugstr_guid(rclsid));
317     return CLASS_E_CLASSNOTAVAILABLE;
318 }
319 
320 /******************************************************************
321  *              DllCanUnloadNow (MSHTML.@)
322  */
323 HRESULT WINAPI DllCanUnloadNow(void)
324 {
325     TRACE("()\n");
326     /* The cost of keeping this DLL in memory is small. */
327     return S_FALSE;
328 }
329 
330 /***********************************************************************
331  *          RunHTMLApplication (MSHTML.@)
332  *
333  * Appears to have the same prototype as WinMain.
334  */
335 HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
336                                LPSTR szCmdLine, INT nCmdShow )
337 {
338     FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
339     return 0;
340 }
341 
342 /***********************************************************************
343  *          RNIGetCompatibleVersion (MSHTML.@)
344  */
345 DWORD WINAPI RNIGetCompatibleVersion(void)
346 {
347     TRACE("()\n");
348     return 0x20000;
349 }
350 
351 /***********************************************************************
352  *          DllInstall (MSHTML.@)
353  */
354 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
355 {
356     FIXME("stub %d %s: returning S_OK\n", bInstall, debugstr_w(cmdline));
357     return S_OK;
358 }
359 
360 /***********************************************************************
361  *          ShowHTMLDialog (MSHTML.@)
362  */
363 HRESULT WINAPI ShowHTMLDialog(HWND hwndParent, IMoniker *pMk, VARIANT *pvarArgIn,
364         WCHAR *pchOptions, VARIANT *pvarArgOut)
365 {
366     FIXME("(%p %p %p %s %p)\n", hwndParent, pMk, pvarArgIn, debugstr_w(pchOptions), pvarArgOut);
367     return E_NOTIMPL;
368 }
369 
370 /***********************************************************************
371  *          PrintHTML (MSHTML.@)
372  */
373 void WINAPI PrintHTML(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
374 {
375     FIXME("(%p %p %s %x)\n", hwnd, handle, debugstr_a(cmdline), show);
376 }
377 
378 DEFINE_GUID(CLSID_CBackgroundPropertyPage, 0x3050F232, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
379 DEFINE_GUID(CLSID_CCDAnchorPropertyPage, 0x3050F1FC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
380 DEFINE_GUID(CLSID_CCDGenericPropertyPage, 0x3050F17F, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
381 DEFINE_GUID(CLSID_CDwnBindInfo, 0x3050F3C2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
382 DEFINE_GUID(CLSID_CHiFiUses, 0x5AAF51B3, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
383 DEFINE_GUID(CLSID_CHtmlComponentConstructor, 0x3050F4F8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
384 DEFINE_GUID(CLSID_CInlineStylePropertyPage, 0x3050F296, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
385 DEFINE_GUID(CLSID_CPeerHandler, 0x5AAF51B2, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
386 DEFINE_GUID(CLSID_CRecalcEngine, 0x3050F499, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
387 DEFINE_GUID(CLSID_CSvrOMUses, 0x3050F4F0, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
388 DEFINE_GUID(CLSID_CrSource, 0x65014010, 0x9F62, 0x11D1, 0xA6,0x51, 0x00,0x60,0x08,0x11,0xD5,0xCE);
389 DEFINE_GUID(CLSID_ExternalFrameworkSite, 0x3050F163, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
390 DEFINE_GUID(CLSID_HTADocument, 0x3050F5C8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
391 DEFINE_GUID(CLSID_HTMLPluginDocument, 0x25336921, 0x03F9, 0x11CF, 0x8F,0xD0, 0x00,0xAA,0x00,0x68,0x6F,0x13);
392 DEFINE_GUID(CLSID_HTMLPopup, 0x3050F667, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
393 DEFINE_GUID(CLSID_HTMLPopupDoc, 0x3050F67D, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
394 DEFINE_GUID(CLSID_HTMLServerDoc, 0x3050F4E7, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
395 DEFINE_GUID(CLSID_IImageDecodeFilter, 0x607FD4E8, 0x0A03, 0x11D1, 0xAB,0x1D, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
396 DEFINE_GUID(CLSID_IImgCtx, 0x3050F3D6, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
397 DEFINE_GUID(CLSID_IntDitherer, 0x05F6FE1A, 0xECEF, 0x11D0, 0xAA,0xE7, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
398 DEFINE_GUID(CLSID_MHTMLDocument, 0x3050F3D9, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
399 DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89);
400 
401 #define INF_SET_ID(id)            \
402     do                            \
403     {                             \
404         static CHAR name[] = #id; \
405                                   \
406         pse[i].pszName = name;    \
407         clsids[i++] = &id;        \
408     } while (0)
409 
410 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
411 
412 static HRESULT register_server(BOOL do_register)
413 {
414     HRESULT hres;
415     HMODULE hAdvpack;
416     HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
417     STRTABLEA strtable;
418     STRENTRYA pse[35];
419     static CLSID const *clsids[35];
420     unsigned int i = 0;
421 
422     static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
423 
424     TRACE("(%x)\n", do_register);
425 
426     INF_SET_CLSID(AboutProtocol);
427     INF_SET_CLSID(CAnchorBrowsePropertyPage);
428     INF_SET_CLSID(CBackgroundPropertyPage);
429     INF_SET_CLSID(CCDAnchorPropertyPage);
430     INF_SET_CLSID(CCDGenericPropertyPage);
431     INF_SET_CLSID(CDocBrowsePropertyPage);
432     INF_SET_CLSID(CDwnBindInfo);
433     INF_SET_CLSID(CHiFiUses);
434     INF_SET_CLSID(CHtmlComponentConstructor);
435     INF_SET_CLSID(CImageBrowsePropertyPage);
436     INF_SET_CLSID(CInlineStylePropertyPage);
437     INF_SET_CLSID(CPeerHandler);
438     INF_SET_CLSID(CRecalcEngine);
439     INF_SET_CLSID(CSvrOMUses);
440     INF_SET_CLSID(CrSource);
441     INF_SET_CLSID(ExternalFrameworkSite);
442     INF_SET_CLSID(HTADocument);
443     INF_SET_CLSID(HTMLDocument);
444     INF_SET_CLSID(HTMLLoadOptions);
445     INF_SET_CLSID(HTMLPluginDocument);
446     INF_SET_CLSID(HTMLPopup);
447     INF_SET_CLSID(HTMLPopupDoc);
448     INF_SET_CLSID(HTMLServerDoc);
449     INF_SET_CLSID(HTMLWindowProxy);
450     INF_SET_CLSID(IImageDecodeFilter);
451     INF_SET_CLSID(IImgCtx);
452     INF_SET_CLSID(IntDitherer);
453     INF_SET_CLSID(JSProtocol);
454     INF_SET_CLSID(MHTMLDocument);
455     INF_SET_CLSID(MailtoProtocol);
456     INF_SET_CLSID(ResProtocol);
457     INF_SET_CLSID(Scriptlet);
458     INF_SET_CLSID(SysimageProtocol);
459     INF_SET_CLSID(TridentAPI);
460     INF_SET_ID(LIBID_MSHTML);
461 
462     for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) {
463         pse[i].pszValue = heap_alloc(39);
464         sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
465                 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
466                 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
467                 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
468     }
469 
470     strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
471     strtable.pse = pse;
472 
473     hAdvpack = LoadLibraryW(wszAdvpack);
474     pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
475 
476     hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
477 
478     FreeLibrary(hAdvpack);
479 
480     for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
481         heap_free(pse[i].pszValue);
482 
483     if(FAILED(hres)) {
484         ERR("RegInstall failed: %08x\n", hres);
485         return hres;
486     }
487 
488     if(do_register) {
489         ITypeLib *typelib;
490 
491         static const WCHAR wszMSHTML[] = {'m','s','h','t','m','l','.','t','l','b',0};
492 
493         hres = LoadTypeLibEx(wszMSHTML, REGKIND_REGISTER, &typelib);
494         if(SUCCEEDED(hres))
495             ITypeLib_Release(typelib);
496     }else {
497         hres = UnRegisterTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, SYS_WIN32);
498     }
499 
500     if(FAILED(hres))
501         ERR("typelib registration failed: %08x\n", hres);
502 
503     return hres;
504 }
505 
506 #undef INF_SET_CLSID
507 #undef INF_SET_ID
508 
509 /***********************************************************************
510  *          DllRegisterServer (MSHTML.@)
511  */
512 HRESULT WINAPI DllRegisterServer(void)
513 {
514     HRESULT hres;
515 
516     hres = __wine_register_resources( hInst );
517     if(SUCCEEDED(hres))
518         hres = register_server(TRUE);
519     if(SUCCEEDED(hres))
520         load_gecko();
521 
522     return hres;
523 }
524 
525 /***********************************************************************
526  *          DllUnregisterServer (MSHTML.@)
527  */
528 HRESULT WINAPI DllUnregisterServer(void)
529 {
530     HRESULT hres = __wine_unregister_resources( hInst );
531     if(SUCCEEDED(hres)) hres = register_server(FALSE);
532     return hres;
533 }
534 
535 const char *debugstr_mshtml_guid(const GUID *iid)
536 {
537 #define X(x) if(IsEqualGUID(iid, &x)) return #x
538     X(DIID_HTMLDocumentEvents);
539     X(DIID_HTMLDocumentEvents2);
540     X(DIID_HTMLTableEvents);
541     X(DIID_HTMLTextContainerEvents);
542     X(IID_HTMLPluginContainer);
543     X(IID_IConnectionPoint);
544     X(IID_IConnectionPointContainer);
545     X(IID_ICustomDoc);
546     X(IID_IDispatch);
547     X(IID_IDispatchEx);
548     X(IID_IDispatchJS);
549     X(IID_UndocumentedScriptIface);
550     X(IID_IEnumConnections);
551     X(IID_IEnumVARIANT);
552     X(IID_IHlinkTarget);
553     X(IID_IHTMLDocument6);
554     X(IID_IHTMLDocument7);
555     X(IID_IHTMLEditServices);
556     X(IID_IHTMLFramesCollection2);
557     X(IID_IHTMLPrivateWindow);
558     X(IID_IHtmlLoadOptions);
559     X(IID_IInternetHostSecurityManager);
560     X(IID_IMonikerProp);
561     X(IID_IObjectIdentity);
562     X(IID_IObjectSafety);
563     X(IID_IObjectWithSite);
564     X(IID_IOleContainer);
565     X(IID_IOleCommandTarget);
566     X(IID_IOleControl);
567     X(IID_IOleDocument);
568     X(IID_IOleDocumentView);
569     X(IID_IOleInPlaceActiveObject);
570     X(IID_IOleInPlaceFrame);
571     X(IID_IOleInPlaceObject);
572     X(IID_IOleInPlaceObjectWindowless);
573     X(IID_IOleInPlaceUIWindow);
574     X(IID_IOleObject);
575     X(IID_IOleWindow);
576     X(IID_IOptionArray);
577     X(IID_IPersist);
578     X(IID_IPersistFile);
579     X(IID_IPersistHistory);
580     X(IID_IPersistMoniker);
581     X(IID_IPersistStreamInit);
582     X(IID_IPropertyNotifySink);
583     X(IID_IProvideClassInfo);
584     X(IID_IServiceProvider);
585     X(IID_ISupportErrorInfo);
586     X(IID_ITargetContainer);
587     X(IID_ITravelLogClient);
588     X(IID_IUnknown);
589     X(IID_IViewObject);
590     X(IID_IViewObject2);
591     X(IID_IViewObjectEx);
592     X(IID_nsCycleCollectionISupports);
593     X(IID_nsXPCOMCycleCollectionParticipant);
594 #define XIID(x) X(IID_##x);
595 #define XDIID(x) X(DIID_##x);
596     TID_LIST
597 #undef XIID
598 #undef XDIID
599 #undef X
600 
601     return debugstr_guid(iid);
602 }
603