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