mshtml: Fix classList toggle() when return value pointer is NULL.
[wine.git] / dlls / mshtml / main.c
bloba45a2c111dc1152bcdba02723539534323b76bc9
1 /*
2 * MSHTML Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003 Mike McCormack
6 * Copyright 2005 Jacek Caban
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.
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.
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
23 #include <stdarg.h>
24 #include <stdio.h>
26 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "winreg.h"
32 #include "ole2.h"
33 #include "advpub.h"
34 #include "shlwapi.h"
35 #include "optary.h"
36 #include "rpcproxy.h"
37 #include "shlguid.h"
38 #include "mlang.h"
39 #include "wininet.h"
41 #include "wine/debug.h"
43 #define INIT_GUID
44 #include "mshtml_private.h"
45 #include "resource.h"
46 #include "pluginhost.h"
47 #include "mscoree.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
51 HINSTANCE hInst;
52 DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
54 void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjCallback*);
55 nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*,ExternalCycleCollectionParticipant*);
56 nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*);
57 void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt);
58 void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*);
59 void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
61 static HINSTANCE shdoclc = NULL;
62 static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
63 static IMultiLanguage2 *mlang;
64 static IInternetSecurityManager *security_manager;
65 static unsigned global_max_compat_mode = COMPAT_MODE_IE11;
66 static struct list compat_config = LIST_INIT(compat_config);
68 typedef struct {
69 struct list entry;
70 compat_mode_t max_compat_mode;
71 WCHAR host[1];
72 } compat_config_t;
74 static BOOL ensure_mlang(void)
76 IMultiLanguage2 *new_mlang;
77 HRESULT hres;
79 if(mlang)
80 return TRUE;
82 hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
83 &IID_IMultiLanguage2, (void**)&new_mlang);
84 if(FAILED(hres)) {
85 ERR("Could not create CMultiLanguage instance\n");
86 return FALSE;
89 if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
90 IMultiLanguage2_Release(new_mlang);
92 return TRUE;
95 UINT cp_from_charset_string(BSTR charset)
97 MIMECSETINFO info;
98 HRESULT hres;
100 if(!ensure_mlang())
101 return CP_UTF8;
103 hres = IMultiLanguage2_GetCharsetInfo(mlang, charset, &info);
104 if(FAILED(hres)) {
105 FIXME("GetCharsetInfo failed: %08lx\n", hres);
106 return CP_UTF8;
109 return info.uiInternetEncoding;
112 BSTR charset_string_from_cp(UINT cp)
114 MIMECPINFO info;
115 HRESULT hres;
117 if(!ensure_mlang())
118 return SysAllocString(NULL);
120 hres = IMultiLanguage2_GetCodePageInfo(mlang, cp, GetUserDefaultUILanguage(), &info);
121 if(FAILED(hres)) {
122 ERR("GetCodePageInfo failed: %08lx\n", hres);
123 return SysAllocString(NULL);
126 return SysAllocString(info.wszWebCharset);
129 HRESULT get_mime_type_display_name(const WCHAR *content_type, BSTR *ret)
131 /* undocumented */
132 extern BOOL WINAPI GetMIMETypeSubKeyW(LPCWSTR,LPWSTR,DWORD);
134 WCHAR buffer[128], ext[128], *str, *progid;
135 DWORD type, len;
136 HKEY key = NULL;
137 LSTATUS status;
138 HRESULT hres;
139 CLSID clsid;
141 str = buffer;
142 if(!GetMIMETypeSubKeyW(content_type, buffer, ARRAY_SIZE(buffer))) {
143 len = wcslen(content_type) + 32;
144 for(;;) {
145 if(!(str = malloc(len * sizeof(WCHAR))))
146 return E_OUTOFMEMORY;
147 if(GetMIMETypeSubKeyW(content_type, str, len))
148 break;
149 free(str);
150 len *= 2;
154 status = RegOpenKeyExW(HKEY_CLASSES_ROOT, str, 0, KEY_QUERY_VALUE, &key);
155 if(str != buffer)
156 free(str);
157 if(status != ERROR_SUCCESS)
158 goto fail;
160 len = sizeof(ext);
161 status = RegQueryValueExW(key, L"Extension", NULL, &type, (BYTE*)ext, &len);
162 if(status != ERROR_SUCCESS || type != REG_SZ) {
163 len = sizeof(buffer);
164 status = RegQueryValueExW(key, L"CLSID", NULL, &type, (BYTE*)buffer, &len);
165 if(status != ERROR_SUCCESS || type != REG_SZ || CLSIDFromString(buffer, &clsid) != S_OK)
166 goto fail;
168 hres = ProgIDFromCLSID(&clsid, &progid);
169 if(hres == E_OUTOFMEMORY) {
170 RegCloseKey(key);
171 return hres;
173 if(hres != S_OK)
174 goto fail;
175 }else {
176 progid = ext;
179 len = ARRAY_SIZE(buffer);
180 str = buffer;
181 for(;;) {
182 hres = AssocQueryStringW(ASSOCF_NOTRUNCATE, ASSOCSTR_FRIENDLYDOCNAME, progid, NULL, str, &len);
183 if(hres == S_OK && len)
184 break;
185 if(str != buffer)
186 free(str);
187 if(hres != E_POINTER) {
188 if(progid != ext) {
189 CoTaskMemFree(progid);
190 goto fail;
193 /* Try from CLSID */
194 len = sizeof(buffer);
195 status = RegQueryValueExW(key, L"CLSID", NULL, &type, (BYTE*)buffer, &len);
196 if(status != ERROR_SUCCESS || type != REG_SZ || CLSIDFromString(buffer, &clsid) != S_OK)
197 goto fail;
199 hres = ProgIDFromCLSID(&clsid, &progid);
200 if(hres == E_OUTOFMEMORY) {
201 RegCloseKey(key);
202 return hres;
204 if(hres != S_OK)
205 goto fail;
207 len = ARRAY_SIZE(buffer);
208 str = buffer;
209 continue;
211 str = malloc(len * sizeof(WCHAR));
213 if(progid != ext)
214 CoTaskMemFree(progid);
215 RegCloseKey(key);
217 *ret = SysAllocString(str);
218 if(str != buffer)
219 free(str);
220 return *ret ? S_OK : E_OUTOFMEMORY;
222 fail:
223 RegCloseKey(key);
225 WARN("Did not find MIME in database for %s\n", debugstr_w(content_type));
227 /* native seems to return "File" when it doesn't know the content type */
228 *ret = SysAllocString(L"File");
229 return *ret ? S_OK : E_OUTOFMEMORY;
232 IInternetSecurityManager *get_security_manager(void)
234 if(!security_manager) {
235 IInternetSecurityManager *manager;
236 HRESULT hres;
238 hres = CoInternetCreateSecurityManager(NULL, &manager, 0);
239 if(FAILED(hres))
240 return NULL;
242 if(InterlockedCompareExchangePointer((void**)&security_manager, manager, NULL))
243 IInternetSecurityManager_Release(manager);
246 return security_manager;
249 static BOOL read_compat_mode(HKEY key, compat_mode_t *r)
251 WCHAR version[32];
252 DWORD type, size;
253 LSTATUS status;
255 size = sizeof(version);
256 status = RegQueryValueExW(key, L"MaxCompatMode", NULL, &type, (BYTE*)version, &size);
257 if(status != ERROR_SUCCESS || type != REG_SZ)
258 return FALSE;
260 return parse_compat_version(version, r) != NULL;
263 static BOOL WINAPI load_compat_settings(INIT_ONCE *once, void *param, void **context)
265 WCHAR key_name[INTERNET_MAX_HOST_NAME_LENGTH];
266 DWORD index = 0, name_size;
267 compat_config_t *new_entry;
268 compat_mode_t max_compat_mode;
269 HKEY key, host_key;
270 DWORD res;
272 /* @@ Wine registry key: HKCU\Software\Wine\MSHTML\CompatMode */
273 res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Wine\\MSHTML\\CompatMode", &key);
274 if(res != ERROR_SUCCESS)
275 return TRUE;
277 if(read_compat_mode(key, &max_compat_mode)) {
278 TRACE("Setting global max compat mode to %u\n", max_compat_mode);
279 global_max_compat_mode = max_compat_mode;
282 while(1) {
283 res = RegEnumKeyW(key, index, key_name, ARRAY_SIZE(key_name));
284 if(res == ERROR_NO_MORE_ITEMS)
285 break;
286 index++;
287 if(res != ERROR_SUCCESS) {
288 WARN("RegEnumKey failed: %lu\n", GetLastError());
289 continue;
292 name_size = lstrlenW(key_name) + 1;
293 new_entry = malloc(FIELD_OFFSET(compat_config_t, host[name_size]));
294 if(!new_entry)
295 continue;
297 new_entry->max_compat_mode = COMPAT_MODE_IE11;
298 memcpy(new_entry->host, key_name, name_size * sizeof(WCHAR));
299 list_add_tail(&compat_config, &new_entry->entry);
301 res = RegOpenKeyW(key, key_name, &host_key);
302 if(res != ERROR_SUCCESS)
303 continue;
305 if(read_compat_mode(host_key, &max_compat_mode)) {
306 TRACE("Setting max compat mode for %s to %u\n", debugstr_w(key_name), max_compat_mode);
307 new_entry->max_compat_mode = max_compat_mode;
310 RegCloseKey(host_key);
313 RegCloseKey(key);
314 return TRUE;
317 compat_mode_t get_max_compat_mode(IUri *uri)
319 compat_config_t *iter;
320 size_t len, iter_len;
321 BSTR host = NULL;
322 HRESULT hres;
324 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
325 InitOnceExecuteOnce(&init_once, load_compat_settings, NULL, NULL);
327 if(!uri)
328 return global_max_compat_mode;
329 hres = IUri_GetHost(uri, &host);
330 if(hres != S_OK) {
331 SysFreeString(host);
332 return global_max_compat_mode;
334 len = SysStringLen(host);
336 LIST_FOR_EACH_ENTRY(iter, &compat_config, compat_config_t, entry) {
337 iter_len = lstrlenW(iter->host);
338 /* If configured host starts with '.', we also match subdomains */
339 if((len == iter_len || (iter->host[0] == '.' && len > iter_len))
340 && !memcmp(host + len - iter_len, iter->host, iter_len * sizeof(WCHAR))) {
341 TRACE("Found max mode %u\n", iter->max_compat_mode);
342 return iter->max_compat_mode;
346 SysFreeString(host);
347 TRACE("Using global max mode %u\n", global_max_compat_mode);
348 return global_max_compat_mode;
351 static void thread_detach(void)
353 thread_data_t *thread_data;
355 thread_data = get_thread_data(FALSE);
356 if(!thread_data)
357 return;
359 if(thread_data->thread_hwnd)
360 DestroyWindow(thread_data->thread_hwnd);
362 destroy_session_storage(thread_data);
363 free(thread_data);
366 static void free_strings(void)
368 unsigned int i;
369 for(i = 0; i < ARRAY_SIZE(status_strings); i++)
370 free(status_strings[i]);
373 static void process_detach(void)
375 compat_config_t *config;
377 close_gecko();
378 release_typelib();
380 while(!list_empty(&compat_config)) {
381 config = LIST_ENTRY(list_head(&compat_config), compat_config_t, entry);
382 list_remove(&config->entry);
383 free(config);
386 if(shdoclc)
387 FreeLibrary(shdoclc);
388 if(mshtml_tls != TLS_OUT_OF_INDEXES)
389 TlsFree(mshtml_tls);
390 if(mlang)
391 IMultiLanguage2_Release(mlang);
392 if(security_manager)
393 IInternetSecurityManager_Release(security_manager);
395 free_strings();
398 void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg)
400 int index = id - IDS_STATUS_FIRST;
401 WCHAR *p = status_strings[index];
402 DWORD len;
404 if(!doc->frame)
405 return;
407 if(!p) {
408 len = 255;
409 p = malloc(len * sizeof(WCHAR));
410 if (!p) return;
411 len = LoadStringW(hInst, id, p, len) + 1;
412 p = realloc(p, len * sizeof(WCHAR));
413 if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) {
414 free(p);
415 p = status_strings[index];
419 if(arg) {
420 WCHAR *buf;
422 len = lstrlenW(p) + lstrlenW(arg) - 1;
423 buf = malloc(len * sizeof(WCHAR));
424 if (!buf) return;
426 swprintf(buf, len, p, arg);
428 p = buf;
431 IOleInPlaceFrame_SetStatusText(doc->frame, p);
433 if(arg)
434 free(p);
437 HRESULT do_query_service(IUnknown *unk, REFGUID guid_service, REFIID riid, void **ppv)
439 IServiceProvider *sp;
440 HRESULT hres;
442 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&sp);
443 if(FAILED(hres))
444 return hres;
446 hres = IServiceProvider_QueryService(sp, guid_service, riid, ppv);
447 IServiceProvider_Release(sp);
448 return hres;
451 HINSTANCE get_shdoclc(void)
453 if(shdoclc)
454 return shdoclc;
456 return shdoclc = LoadLibraryExW(L"shdoclc.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
459 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
461 switch(fdwReason) {
462 case DLL_PROCESS_ATTACH:
463 hInst = hInstDLL;
464 break;
465 case DLL_PROCESS_DETACH:
466 if (reserved) break;
467 process_detach();
468 break;
469 case DLL_THREAD_DETACH:
470 thread_detach();
471 break;
473 return TRUE;
476 /***********************************************************
477 * ClassFactory implementation
479 typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**);
480 typedef struct {
481 IClassFactory IClassFactory_iface;
482 LONG ref;
483 CreateInstanceFunc fnCreateInstance;
484 } ClassFactory;
486 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
488 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
491 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFGUID riid, void **ppvObject)
493 if(IsEqualGUID(&IID_IClassFactory, riid) || IsEqualGUID(&IID_IUnknown, riid)) {
494 IClassFactory_AddRef(iface);
495 *ppvObject = iface;
496 return S_OK;
499 WARN("not supported iid %s\n", debugstr_mshtml_guid(riid));
500 *ppvObject = NULL;
501 return E_NOINTERFACE;
504 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
506 ClassFactory *This = impl_from_IClassFactory(iface);
507 ULONG ref = InterlockedIncrement(&This->ref);
508 TRACE("(%p) ref = %lu\n", This, ref);
509 return ref;
512 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
514 ClassFactory *This = impl_from_IClassFactory(iface);
515 ULONG ref = InterlockedDecrement(&This->ref);
517 TRACE("(%p) ref = %lu\n", This, ref);
519 if(!ref) {
520 free(This);
523 return ref;
526 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
527 REFIID riid, void **ppvObject)
529 ClassFactory *This = impl_from_IClassFactory(iface);
530 return This->fnCreateInstance(pUnkOuter, riid, ppvObject);
533 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
535 TRACE("(%p)->(%x)\n", iface, dolock);
537 /* We never unload the DLL. See DllCanUnloadNow(). */
538 return S_OK;
541 static const IClassFactoryVtbl HTMLClassFactoryVtbl = {
542 ClassFactory_QueryInterface,
543 ClassFactory_AddRef,
544 ClassFactory_Release,
545 ClassFactory_CreateInstance,
546 ClassFactory_LockServer
549 static HRESULT ClassFactory_Create(REFIID riid, void **ppv, CreateInstanceFunc fnCreateInstance)
551 ClassFactory *ret = malloc(sizeof(ClassFactory));
552 HRESULT hres;
554 ret->IClassFactory_iface.lpVtbl = &HTMLClassFactoryVtbl;
555 ret->ref = 0;
556 ret->fnCreateInstance = fnCreateInstance;
558 hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
559 if(FAILED(hres)) {
560 free(ret);
561 *ppv = NULL;
563 return hres;
566 /******************************************************************
567 * DllGetClassObject (MSHTML.@)
569 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
571 if(IsEqualGUID(&CLSID_HTMLDocument, rclsid)) {
572 TRACE("(CLSID_HTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
573 return ClassFactory_Create(riid, ppv, HTMLDocument_Create);
574 }else if(IsEqualGUID(&CLSID_MHTMLDocument, rclsid)) {
575 TRACE("(CLSID_MHTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
576 return ClassFactory_Create(riid, ppv, MHTMLDocument_Create);
577 }else if(IsEqualGUID(&CLSID_AboutProtocol, rclsid)) {
578 TRACE("(CLSID_AboutProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
579 return ProtocolFactory_Create(rclsid, riid, ppv);
580 }else if(IsEqualGUID(&CLSID_JSProtocol, rclsid)) {
581 TRACE("(CLSID_JSProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
582 return ProtocolFactory_Create(rclsid, riid, ppv);
583 }else if(IsEqualGUID(&CLSID_MailtoProtocol, rclsid)) {
584 TRACE("(CLSID_MailtoProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
585 return ProtocolFactory_Create(rclsid, riid, ppv);
586 }else if(IsEqualGUID(&CLSID_ResProtocol, rclsid)) {
587 TRACE("(CLSID_ResProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
588 return ProtocolFactory_Create(rclsid, riid, ppv);
589 }else if(IsEqualGUID(&CLSID_SysimageProtocol, rclsid)) {
590 TRACE("(CLSID_SysimageProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
591 return ProtocolFactory_Create(rclsid, riid, ppv);
592 }else if(IsEqualGUID(&CLSID_HTMLLoadOptions, rclsid)) {
593 TRACE("(CLSID_HTMLLoadOptions %s %p)\n", debugstr_mshtml_guid(riid), ppv);
594 return ClassFactory_Create(riid, ppv, HTMLLoadOptions_Create);
597 FIXME("Unknown class %s\n", debugstr_guid(rclsid));
598 return CLASS_E_CLASSNOTAVAILABLE;
601 /***********************************************************************
602 * RunHTMLApplication (MSHTML.@)
604 * Appears to have the same prototype as WinMain.
606 HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
607 LPSTR szCmdLine, INT nCmdShow )
609 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
610 return S_OK;
613 /***********************************************************************
614 * RNIGetCompatibleVersion (MSHTML.@)
616 DWORD WINAPI RNIGetCompatibleVersion(void)
618 TRACE("()\n");
619 return 0x20000;
622 /***********************************************************************
623 * DllInstall (MSHTML.@)
625 HRESULT WINAPI DllInstall(BOOL install, const WCHAR *cmdline)
627 TRACE("(%x %s)\n", install, debugstr_w(cmdline));
629 if(cmdline && *cmdline)
630 FIXME("unsupported cmdline: %s\n", debugstr_w(cmdline));
631 else if(install)
632 load_gecko();
634 return S_OK;
637 /***********************************************************************
638 * ShowHTMLDialog (MSHTML.@)
640 HRESULT WINAPI ShowHTMLDialog(HWND hwndParent, IMoniker *pMk, VARIANT *pvarArgIn,
641 WCHAR *pchOptions, VARIANT *pvarArgOut)
643 FIXME("(%p %p %p %s %p)\n", hwndParent, pMk, pvarArgIn, debugstr_w(pchOptions), pvarArgOut);
644 return E_NOTIMPL;
647 /***********************************************************************
648 * PrintHTML (MSHTML.@)
650 void WINAPI PrintHTML(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
652 FIXME("(%p %p %s %x)\n", hwnd, handle, debugstr_a(cmdline), show);
655 DEFINE_GUID(CLSID_CBackgroundPropertyPage, 0x3050F232, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
656 DEFINE_GUID(CLSID_CCDAnchorPropertyPage, 0x3050F1FC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
657 DEFINE_GUID(CLSID_CCDGenericPropertyPage, 0x3050F17F, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
658 DEFINE_GUID(CLSID_CDwnBindInfo, 0x3050F3C2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
659 DEFINE_GUID(CLSID_CHiFiUses, 0x5AAF51B3, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
660 DEFINE_GUID(CLSID_CHtmlComponentConstructor, 0x3050F4F8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
661 DEFINE_GUID(CLSID_CInlineStylePropertyPage, 0x3050F296, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
662 DEFINE_GUID(CLSID_CPeerHandler, 0x5AAF51B2, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
663 DEFINE_GUID(CLSID_CRecalcEngine, 0x3050F499, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
664 DEFINE_GUID(CLSID_CSvrOMUses, 0x3050F4F0, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
665 DEFINE_GUID(CLSID_CrSource, 0x65014010, 0x9F62, 0x11D1, 0xA6,0x51, 0x00,0x60,0x08,0x11,0xD5,0xCE);
666 DEFINE_GUID(CLSID_ExternalFrameworkSite, 0x3050F163, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
667 DEFINE_GUID(CLSID_HTADocument, 0x3050F5C8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
668 DEFINE_GUID(CLSID_HTMLPluginDocument, 0x25336921, 0x03F9, 0x11CF, 0x8F,0xD0, 0x00,0xAA,0x00,0x68,0x6F,0x13);
669 DEFINE_GUID(CLSID_HTMLPopup, 0x3050F667, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
670 DEFINE_GUID(CLSID_HTMLPopupDoc, 0x3050F67D, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
671 DEFINE_GUID(CLSID_HTMLServerDoc, 0x3050F4E7, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
672 DEFINE_GUID(CLSID_IImageDecodeFilter, 0x607FD4E8, 0x0A03, 0x11D1, 0xAB,0x1D, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
673 DEFINE_GUID(CLSID_IImgCtx, 0x3050F3D6, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
674 DEFINE_GUID(CLSID_IntDitherer, 0x05F6FE1A, 0xECEF, 0x11D0, 0xAA,0xE7, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
675 DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89);
677 #define INF_SET_ID(id) \
678 do \
680 static CHAR name[] = #id; \
682 pse[i].pszName = name; \
683 clsids[i++] = &id; \
684 } while (0)
686 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
688 static HRESULT register_server(BOOL do_register)
690 HRESULT hres;
691 HMODULE hAdvpack;
692 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
693 STRTABLEA strtable;
694 STRENTRYA pse[35];
695 static CLSID const *clsids[35];
696 unsigned int i = 0;
698 TRACE("(%x)\n", do_register);
700 INF_SET_CLSID(AboutProtocol);
701 INF_SET_CLSID(CAnchorBrowsePropertyPage);
702 INF_SET_CLSID(CBackgroundPropertyPage);
703 INF_SET_CLSID(CCDAnchorPropertyPage);
704 INF_SET_CLSID(CCDGenericPropertyPage);
705 INF_SET_CLSID(CDocBrowsePropertyPage);
706 INF_SET_CLSID(CDwnBindInfo);
707 INF_SET_CLSID(CHiFiUses);
708 INF_SET_CLSID(CHtmlComponentConstructor);
709 INF_SET_CLSID(CImageBrowsePropertyPage);
710 INF_SET_CLSID(CInlineStylePropertyPage);
711 INF_SET_CLSID(CPeerHandler);
712 INF_SET_CLSID(CRecalcEngine);
713 INF_SET_CLSID(CSvrOMUses);
714 INF_SET_CLSID(CrSource);
715 INF_SET_CLSID(ExternalFrameworkSite);
716 INF_SET_CLSID(HTADocument);
717 INF_SET_CLSID(HTMLDocument);
718 INF_SET_CLSID(HTMLLoadOptions);
719 INF_SET_CLSID(HTMLPluginDocument);
720 INF_SET_CLSID(HTMLPopup);
721 INF_SET_CLSID(HTMLPopupDoc);
722 INF_SET_CLSID(HTMLServerDoc);
723 INF_SET_CLSID(HTMLWindowProxy);
724 INF_SET_CLSID(IImageDecodeFilter);
725 INF_SET_CLSID(IImgCtx);
726 INF_SET_CLSID(IntDitherer);
727 INF_SET_CLSID(JSProtocol);
728 INF_SET_CLSID(MHTMLDocument);
729 INF_SET_CLSID(MailtoProtocol);
730 INF_SET_CLSID(ResProtocol);
731 INF_SET_CLSID(Scriptlet);
732 INF_SET_CLSID(SysimageProtocol);
733 INF_SET_CLSID(TridentAPI);
734 INF_SET_ID(LIBID_MSHTML);
736 for(i=0; i < ARRAY_SIZE(pse); i++) {
737 pse[i].pszValue = malloc(39);
738 sprintf(pse[i].pszValue, "{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
739 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
740 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
741 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
744 strtable.cEntries = ARRAY_SIZE(pse);
745 strtable.pse = pse;
747 hAdvpack = LoadLibraryW(L"advpack.dll");
748 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
750 hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
752 FreeLibrary(hAdvpack);
754 for(i=0; i < ARRAY_SIZE(pse); i++)
755 free(pse[i].pszValue);
757 if(FAILED(hres))
758 ERR("RegInstall failed: %08lx\n", hres);
760 return hres;
763 #undef INF_SET_CLSID
764 #undef INF_SET_ID
766 /***********************************************************************
767 * DllRegisterServer (MSHTML.@)
769 HRESULT WINAPI DllRegisterServer(void)
771 HRESULT hres;
773 hres = __wine_register_resources();
774 if(SUCCEEDED(hres))
775 hres = register_server(TRUE);
776 return hres;
779 /***********************************************************************
780 * DllUnregisterServer (MSHTML.@)
782 HRESULT WINAPI DllUnregisterServer(void)
784 HRESULT hres = __wine_unregister_resources();
785 if(SUCCEEDED(hres)) hres = register_server(FALSE);
786 return hres;
789 const char *debugstr_mshtml_guid(const GUID *iid)
791 #define X(x) if(IsEqualGUID(iid, &x)) return #x
792 X(DIID_HTMLDocumentEvents);
793 X(DIID_HTMLDocumentEvents2);
794 X(DIID_HTMLTableEvents);
795 X(DIID_HTMLTextContainerEvents);
796 X(IID_HTMLPluginContainer);
797 X(IID_IConnectionPoint);
798 X(IID_IConnectionPointContainer);
799 X(IID_ICustomDoc);
800 X(IID_IDispatch);
801 X(IID_IDispatchEx);
802 X(IID_IDispatchJS);
803 X(IID_IDisplayServices);
804 X(IID_UndocumentedScriptIface);
805 X(IID_IEnumConnections);
806 X(IID_IEnumVARIANT);
807 X(IID_IHlinkTarget);
808 X(IID_IHTMLDocument6);
809 X(IID_IHTMLDocument7);
810 X(IID_IHTMLEditServices);
811 X(IID_IHTMLFramesCollection2);
812 X(IID_IHTMLPrivateWindow);
813 X(IID_IHtmlLoadOptions);
814 X(IID_IInternetHostSecurityManager);
815 X(IID_IInternetProtocol);
816 X(IID_IInternetProtocolRoot);
817 X(IID_IManagedObject);
818 X(IID_IMarkupContainer);
819 X(IID_IMarkupServices);
820 X(IID_IMarshal);
821 X(IID_IMonikerProp);
822 X(IID_IObjectIdentity);
823 X(IID_IObjectSafety);
824 X(IID_IObjectWithSite);
825 X(IID_IOleContainer);
826 X(IID_IOleCommandTarget);
827 X(IID_IOleControl);
828 X(IID_IOleDocument);
829 X(IID_IOleDocumentView);
830 X(IID_IOleInPlaceActiveObject);
831 X(IID_IOleInPlaceFrame);
832 X(IID_IOleInPlaceObject);
833 X(IID_IOleInPlaceObjectWindowless);
834 X(IID_IOleInPlaceUIWindow);
835 X(IID_IOleObject);
836 X(IID_IOleWindow);
837 X(IID_IOptionArray);
838 X(IID_IPersist);
839 X(IID_IPersistFile);
840 X(IID_IPersistHistory);
841 X(IID_IPersistMoniker);
842 X(IID_IPersistStreamInit);
843 X(IID_IPropertyNotifySink);
844 X(IID_IProvideClassInfo);
845 X(IID_IProvideClassInfo2);
846 X(IID_IProvideMultipleClassInfo);
847 X(IID_IServiceProvider);
848 X(IID_ISupportErrorInfo);
849 X(IID_ITargetContainer);
850 X(IID_ITravelLogClient);
851 X(IID_IUnknown);
852 X(IID_IViewObject);
853 X(IID_IViewObject2);
854 X(IID_IViewObjectEx);
855 X(IID_nsCycleCollectionISupports);
856 X(IID_nsXPCOMCycleCollectionParticipant);
857 #define XIID(x) X(IID_##x);
858 #define XDIID(x) X(DIID_##x);
859 TID_LIST
860 #undef XIID
861 #undef XDIID
862 #undef X
864 return debugstr_guid(iid);