ReactOS 0.4.15-dev-5865-g640e228
wshom_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 "wshom_private.h"
20
21#include "initguid.h"
22#include "wshom.h"
23#include "rpcproxy.h"
24
25#include "wine/debug.h"
26
28
30
32{
34}
35
38
39static REFIID tid_ids[] = {
40 &IID_NULL,
41 &IID_IWshCollection,
42 &IID_IWshEnvironment,
43 &IID_IWshExec,
44 &IID_IWshShell3,
45 &IID_IWshShortcut
46};
47
49{
51 ITypeLib *tl;
52
53 if(typelib)
54 return S_OK;
55
56 hres = LoadRegTypeLib(&LIBID_IWshRuntimeLibrary, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
57 if(FAILED(hres)) {
58 ERR("LoadRegTypeLib failed: %08x\n", hres);
59 return hres;
60 }
61
63 ITypeLib_Release(tl);
64 return hres;
65}
66
68{
70
71 if(FAILED(hres = load_typelib()))
72 return hres;
73
74 return ITypeLib_GetTypeInfoOfGuid(typelib, guid, tinfo);
75}
76
78{
80
81 if (FAILED(hres = load_typelib()))
82 return hres;
83
84 if(!typeinfos[tid]) {
85 ITypeInfo *ti;
86
87 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
88 if(FAILED(hres)) {
89 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
90 return hres;
91 }
92
94 ITypeInfo_Release(ti);
95 }
96
98 ITypeInfo_AddRef(*typeinfo);
99 return S_OK;
100}
101
102static
104{
105 unsigned i;
106
107 if(!typelib)
108 return;
109
110 for(i = 0; i < ARRAY_SIZE(typeinfos); i++)
111 if(typeinfos[i])
112 ITypeInfo_Release(typeinfos[i]);
113
114 ITypeLib_Release(typelib);
115}
116
118{
120
121 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
122
124 *obj = iface;
125 IProvideClassInfo_AddRef(iface);
126 return S_OK;
127 }
128 else
129 return IUnknown_QueryInterface(This->outer, riid, obj);
130}
131
133{
135 return IUnknown_AddRef(This->outer);
136}
137
139{
141 return IUnknown_Release(This->outer);
142}
143
145{
147
148 TRACE("(%p)->(%p)\n", This, ti);
149
150 return get_typeinfo_of_guid(This->guid, ti);
151}
152
153static const IProvideClassInfoVtbl provideclassinfovtbl = {
158};
159
161{
162 classinfo->IProvideClassInfo_iface.lpVtbl = &provideclassinfovtbl;
163 classinfo->outer = outer;
164 classinfo->guid = guid;
165}
166
168{
169 *ppv = NULL;
170
172 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
173 *ppv = iface;
174 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
175 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
176 *ppv = iface;
177 }
178
179 if(*ppv) {
180 IUnknown_AddRef((IUnknown*)*ppv);
181 return S_OK;
182 }
183
184 WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
185 return E_NOINTERFACE;
186}
187
189{
190 TRACE("(%p)\n", iface);
191 return 2;
192}
193
195{
196 TRACE("(%p)\n", iface);
197 return 1;
198}
199
201{
202 TRACE("(%p)->(%x)\n", iface, fLock);
203 return S_OK;
204}
205
206static const IClassFactoryVtbl WshShellFactoryVtbl = {
212};
213
215
216/******************************************************************
217 * DllMain (wshom.ocx.@)
218 */
219BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
220{
221 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
222
223 switch(fdwReason)
224 {
225 case DLL_WINE_PREATTACH:
226 return FALSE; /* prefer native version */
228 wshom_instance = hInstDLL;
230 break;
232 if (lpv) break;
234 break;
235 }
236
237 return TRUE;
238}
239
240/***********************************************************************
241 * DllGetClassObject (wshom.ocx.@)
242 */
244{
245 if(IsEqualGUID(&CLSID_WshShell, rclsid)) {
246 TRACE("(CLSID_WshShell %s %p)\n", debugstr_guid(riid), ppv);
247 return IClassFactory_QueryInterface(&WshShellFactory, riid, ppv);
248 }
249
250 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
252}
253
254/***********************************************************************
255 * DllCanUnloadNow (wshom.ocx.@)
256 */
258{
259 return S_FALSE;
260}
261
262/***********************************************************************
263 * DllRegisterServer (wshom.ocx.@)
264 */
266{
267 TRACE("()\n");
269}
270
271/***********************************************************************
272 * DllUnregisterServer (wshom.ocx.@)
273 */
275{
276 TRACE("()\n");
278}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:33
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
#define ERR(fmt,...)
Definition: debug.h:110
classinfo
Definition: clsfactory.c:43
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
Definition: typelib.c:531
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: shell.c:1816
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
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
tid_t
Definition: ieframe.h:311
@ LAST_tid
Definition: ieframe.h:317
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
const GUID * guid
HRESULT hres
Definition: protocol.c:465
static TfClientId tid
#define LOCALE_SYSTEM_DEFAULT
const GUID IID_IProvideClassInfo
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define IID_NULL
Definition: guiddef.h:98
#define REFCLSID
Definition: guiddef.h:117
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
#define TRACE(s)
Definition: solgame.cpp:4
IUnknown * outer
IProvideClassInfo IProvideClassInfo_iface
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: wshom_main.c:200
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
Definition: wshom_main.c:219
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
Definition: wshom_main.c:160
HRESULT WINAPI DllRegisterServer(void)
Definition: wshom_main.c:265
static ITypeLib * typelib
Definition: wshom_main.c:36
static IClassFactory WshShellFactory
Definition: wshom_main.c:214
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
Definition: wshom_main.c:77
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: wshom_main.c:194
static ULONG WINAPI provideclassinfo_Release(IProvideClassInfo *iface)
Definition: wshom_main.c:138
static HRESULT WINAPI provideclassinfo_QueryInterface(IProvideClassInfo *iface, REFIID riid, void **obj)
Definition: wshom_main.c:117
static ULONG WINAPI provideclassinfo_AddRef(IProvideClassInfo *iface)
Definition: wshom_main.c:132
HRESULT WINAPI DllUnregisterServer(void)
Definition: wshom_main.c:274
static HRESULT get_typeinfo_of_guid(const GUID *guid, ITypeInfo **tinfo)
Definition: wshom_main.c:67
static const IClassFactoryVtbl WshShellFactoryVtbl
Definition: wshom_main.c:206
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: wshom_main.c:167
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: wshom_main.c:243
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: wshom_main.c:31
static HRESULT load_typelib(void)
Definition: wshom_main.c:48
static const IProvideClassInfoVtbl provideclassinfovtbl
Definition: wshom_main.c:153
static REFIID tid_ids[]
Definition: wshom_main.c:39
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: wshom_main.c:188
static HRESULT WINAPI provideclassinfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ti)
Definition: wshom_main.c:144
static HINSTANCE wshom_instance
Definition: wshom_main.c:29
HRESULT WINAPI DllCanUnloadNow(void)
Definition: wshom_main.c:257
static void release_typelib(void)
Definition: wshom_main.c:103
static ITypeInfo * typeinfos[LAST_tid]
Definition: wshom_main.c:37