ReactOS  0.4.13-dev-961-g238ea69
ieframe_main.c
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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 #include "ieframe.h"
20 
21 #include "initguid.h"
22 #include "rpcproxy.h"
23 #include "shlguid.h"
24 #include "isguids.h"
25 #include "ieautomation.h"
26 
27 #include "wine/debug.h"
28 
30 
33 
34 static ITypeLib *typelib;
36 
37 static REFIID tid_ids[] = {
38 #define XIID(iface) &IID_ ## iface,
39 #define XCLSID(class) &CLSID_ ## class,
41 #undef XIID
42 #undef XCLSID
43 };
44 
45 static HRESULT load_typelib(void)
46 {
47  HRESULT hres;
48  ITypeLib *tl;
49 
50  hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 1, LOCALE_SYSTEM_DEFAULT, &tl);
51  if(FAILED(hres)) {
52  ERR("LoadRegTypeLib failed: %08x\n", hres);
53  return hres;
54  }
55 
57  ITypeLib_Release(tl);
58  return hres;
59 }
60 
62 {
63  HRESULT hres;
64 
65  if(!typelib)
66  hres = load_typelib();
67  if(!typelib)
68  return hres;
69 
70  if(!typeinfos[tid]) {
71  ITypeInfo *ti;
72 
73  hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
74  if(FAILED(hres)) {
75  ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
76  return hres;
77  }
78 
80  ITypeInfo_Release(ti);
81  }
82 
84  return S_OK;
85 }
86 
87 static void release_typelib(void)
88 {
89  unsigned i;
90 
91  if(!typelib)
92  return;
93 
94  for(i=0; i < ARRAY_SIZE(typeinfos); i++) {
95  if(typeinfos[i])
96  ITypeInfo_Release(typeinfos[i]);
97  }
98 
99  ITypeLib_Release(typelib);
100 }
101 
103 {
104  *ppv = NULL;
105 
106  if(IsEqualGUID(&IID_IUnknown, riid)) {
107  TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
108  *ppv = iface;
109  }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
110  TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
111  *ppv = iface;
112  }
113 
114  if(*ppv) {
115  IUnknown_AddRef((IUnknown*)*ppv);
116  return S_OK;
117  }
118 
119  FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
120  return E_NOINTERFACE;
121 }
122 
124 {
125  TRACE("(%p)\n", iface);
126  return 2;
127 }
128 
130 {
131  TRACE("(%p)\n", iface);
132  return 1;
133 }
134 
136 {
137  TRACE("(%p)->(%x)\n", iface, fLock);
138  return S_OK;
139 }
140 
141 static const IClassFactoryVtbl WebBrowserFactoryVtbl = {
147 };
148 
150 
151 static const IClassFactoryVtbl WebBrowserV1FactoryVtbl = {
157 };
158 
160 
161 static const IClassFactoryVtbl InternetShortcutFactoryVtbl = {
167 };
168 
170 
171 static const IClassFactoryVtbl CUrlHistoryFactoryVtbl = {
177 };
178 
180 
181 /******************************************************************
182  * DllMain (ieframe.@)
183  */
184 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
185 {
186  TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
187 
188  switch(fdwReason)
189  {
190  case DLL_WINE_PREATTACH:
191  return FALSE; /* prefer native version */
192  case DLL_PROCESS_ATTACH:
193  ieframe_instance = hInstDLL;
196  break;
197  case DLL_PROCESS_DETACH:
198  if (lpv) break;
200  release_typelib();
201  }
202 
203  return TRUE;
204 }
205 
206 /***********************************************************************
207  * DllGetClassObject (ieframe.@)
208  */
210 {
211  if(IsEqualGUID(&CLSID_WebBrowser, rclsid)) {
212  TRACE("(CLSID_WebBrowser %s %p)\n", debugstr_guid(riid), ppv);
213  return IClassFactory_QueryInterface(&WebBrowserFactory, riid, ppv);
214  }
215 
216  if(IsEqualGUID(&CLSID_WebBrowser_V1, rclsid)) {
217  TRACE("(CLSID_WebBrowser_V1 %s %p)\n", debugstr_guid(riid), ppv);
218  return IClassFactory_QueryInterface(&WebBrowserV1Factory, riid, ppv);
219  }
220 
221  if(IsEqualGUID(rclsid, &CLSID_InternetShortcut)) {
222  TRACE("(CLSID_InternetShortcut %s %p)\n", debugstr_guid(riid), ppv);
223  return IClassFactory_QueryInterface(&InternetShortcutFactory, riid, ppv);
224  }
225 
226  if(IsEqualGUID(&CLSID_CUrlHistory, rclsid)) {
227  TRACE("(CLSID_CUrlHistory %s %p)\n", debugstr_guid(riid), ppv);
228  return IClassFactory_QueryInterface(&CUrlHistoryFactory, riid, ppv);
229  }
230 
231  FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
233 }
234 
235 static const IClassFactoryVtbl InternetExplorerFactoryVtbl = {
241 };
242 
244 
245 static const IClassFactoryVtbl InternetExplorerManagerFactoryVtbl = {
251 };
252 
254 
255 /***********************************************************************
256  * DllCanUnloadNow (ieframe.@)
257  */
259 {
260  TRACE("()\n");
261  return module_ref ? S_FALSE : S_OK;
262 }
263 
264 /***********************************************************************
265  * DllRegisterServer (ieframe.@)
266  */
268 {
269  TRACE("()\n");
271 }
272 
273 /***********************************************************************
274  * DllUnregisterServer (ieframe.@)
275  */
277 {
278  TRACE("()\n");
280 }
281 
282 /***********************************************************************
283  * IEGetWriteableHKCU (ieframe.@)
284  */
286 {
287  FIXME("(%p) stub\n", pkey);
288  return E_NOTIMPL;
289 }
HRESULT WINAPI InternetExplorer_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: iexplore.c:837
IClassFactory InternetExplorerManagerFactory
Definition: ieframe_main.c:253
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
static void release_typelib(void)
Definition: ieframe_main.c:87
HRESULT WINAPI IEGetWriteableHKCU(HKEY *pkey)
Definition: ieframe_main.c:285
static REFIID tid_ids[]
Definition: ieframe_main.c:37
static ITypeLib * typelib
Definition: ieframe_main.c:34
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: ieframe_main.c:102
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static const IClassFactoryVtbl WebBrowserFactoryVtbl
Definition: ieframe_main.c:141
REFIID riid
Definition: precomp.h:44
static IClassFactory WebBrowserFactory
Definition: ieframe_main.c:149
#define REFCLSID
Definition: guiddef.h:117
tid_t
Definition: ieframe.h:311
HRESULT WINAPI CUrlHistory_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: urlhist.c:126
WINE_DEFAULT_DEBUG_CHANNEL(ieframe)
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI DllCanUnloadNow(void)
Definition: ieframe_main.c:258
HINSTANCE ieframe_instance
Definition: ieframe_main.c:32
HRESULT WINAPI WebBrowserV1_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: webbrowser.c:1264
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
LONG module_ref
Definition: ieframe_main.c:31
HRESULT WINAPI DllRegisterServer(void)
Definition: ieframe_main.c:267
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: ieframe_main.c:129
static ITypeInfo * typeinfos[LAST_tid]
Definition: ieframe_main.c:35
void register_iewindow_class(void) DECLSPEC_HIDDEN
Definition: iexplore.c:713
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define FIXME(fmt,...)
Definition: debug.h:110
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
void unregister_iewindow_class(void) DECLSPEC_HIDDEN
Definition: iexplore.c:735
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define TID_LIST
Definition: ieframe.h:306
HRESULT WINAPI DllUnregisterServer(void)
Definition: ieframe_main.c:276
static const IClassFactoryVtbl CUrlHistoryFactoryVtbl
Definition: ieframe_main.c:171
#define DLL_PROCESS_DETACH
Definition: compat.h:119
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: ieframe_main.c:123
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
Definition: ieframe_main.c:184
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static HRESULT load_typelib(void)
Definition: ieframe_main.c:45
static const IClassFactoryVtbl InternetExplorerFactoryVtbl
Definition: ieframe_main.c:235
#define WINAPI
Definition: msvc.h:8
#define LOCALE_SYSTEM_DEFAULT
unsigned long DWORD
Definition: ntddk_ex.h:95
static const IClassFactoryVtbl InternetShortcutFactoryVtbl
Definition: ieframe_main.c:161
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
static const IClassFactoryVtbl WebBrowserV1FactoryVtbl
Definition: ieframe_main.c:151
static IClassFactory WebBrowserV1Factory
Definition: ieframe_main.c:159
static IClassFactory CUrlHistoryFactory
Definition: ieframe_main.c:179
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
Definition: ieframe_main.c:61
static const IClassFactoryVtbl InternetExplorerManagerFactoryVtbl
Definition: ieframe_main.c:245
static IClassFactory InternetShortcutFactory
Definition: ieframe_main.c:169
#define ERR(fmt,...)
Definition: debug.h:109
IClassFactory InternetExplorerFactory
Definition: ieframe_main.c:243
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
Definition: typelib.c:534
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: ieframe_main.c:209
#define ARRAY_SIZE(a)
Definition: main.h:24
#define E_NOTIMPL
Definition: ddrawi.h:99
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HRESULT WINAPI InternetExplorerManager_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: iexplore.c:926
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI WebBrowser_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: webbrowser.c:1269
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: ieframe_main.c:135
const GUID IID_IClassFactory
HRESULT WINAPI InternetShortcut_Create(IClassFactory *, IUnknown *, REFIID, void **) DECLSPEC_HIDDEN
Definition: intshcut.c:824
static TfClientId tid