ReactOS 0.4.17-dev-934-g091855f
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}
33
36
37static REFIID tid_ids[] = {
38 &IID_NULL,
39 &IID_IWshCollection,
40 &IID_IWshEnvironment,
41 &IID_IWshExec,
42 &IID_IWshShell3,
43 &IID_IWshShortcut,
44 &IID_IWshNetwork2
45};
46
48{
50 ITypeLib *tl;
51
52 if(typelib)
53 return S_OK;
54
55 hres = LoadRegTypeLib(&LIBID_IWshRuntimeLibrary, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
56 if(FAILED(hres)) {
57 ERR("LoadRegTypeLib failed: %#lx.\n", hres);
58 return hres;
59 }
60
62 ITypeLib_Release(tl);
63 return hres;
64}
65
67{
69
70 if(FAILED(hres = load_typelib()))
71 return hres;
72
73 return ITypeLib_GetTypeInfoOfGuid(typelib, guid, tinfo);
74}
75
77{
79
80 if (FAILED(hres = load_typelib()))
81 return hres;
82
83 if(!typeinfos[tid]) {
84 ITypeInfo *ti;
85
86 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
87 if(FAILED(hres)) {
88 ERR("GetTypeInfoOfGuid(%s) failed: %#lx.\n", debugstr_guid(tid_ids[tid]), hres);
89 return hres;
90 }
91
93 ITypeInfo_Release(ti);
94 }
95
97 ITypeInfo_AddRef(*typeinfo);
98 return S_OK;
99}
100
101static
103{
104 unsigned i;
105
106 if(!typelib)
107 return;
108
109 for(i = 0; i < ARRAY_SIZE(typeinfos); i++)
110 if(typeinfos[i])
111 ITypeInfo_Release(typeinfos[i]);
112
113 ITypeLib_Release(typelib);
114}
115
117{
119
120 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
121
123 *obj = iface;
124 IProvideClassInfo_AddRef(iface);
125 return S_OK;
126 }
127 else
128 return IUnknown_QueryInterface(This->outer, riid, obj);
129}
130
132{
134 return IUnknown_AddRef(This->outer);
135}
136
138{
140 return IUnknown_Release(This->outer);
141}
142
144{
146
147 TRACE("(%p)->(%p)\n", This, ti);
148
149 return get_typeinfo_of_guid(This->guid, ti);
150}
151
152static const IProvideClassInfoVtbl provideclassinfovtbl = {
157};
158
160{
161 classinfo->IProvideClassInfo_iface.lpVtbl = &provideclassinfovtbl;
162 classinfo->outer = outer;
163 classinfo->guid = guid;
164}
165
167{
168 *ppv = NULL;
169
171 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
172 *ppv = iface;
173 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
174 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
175 *ppv = iface;
176 }
177
178 if(*ppv) {
179 IUnknown_AddRef((IUnknown*)*ppv);
180 return S_OK;
181 }
182
183 WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
184 return E_NOINTERFACE;
185}
186
188{
189 TRACE("(%p)\n", iface);
190 return 2;
191}
192
194{
195 TRACE("(%p)\n", iface);
196 return 1;
197}
198
200{
201 TRACE("(%p)->(%x)\n", iface, fLock);
202 return S_OK;
203}
204
205static const IClassFactoryVtbl WshShellFactoryVtbl = {
211};
212
213static const IClassFactoryVtbl WshNetworkFactoryVtbl = {
219};
220
223
224/******************************************************************
225 * DllMain (wshom.ocx.@)
226 */
228{
229 TRACE("%p, %ld, %p.\n", hInstDLL, fdwReason, lpv);
230
231 switch(fdwReason)
232 {
235 break;
237 if (lpv) break;
239 break;
240 }
241
242 return TRUE;
243}
244
245/***********************************************************************
246 * DllGetClassObject (wshom.ocx.@)
247 */
249{
250 if(IsEqualGUID(&CLSID_WshShell, rclsid)) {
251 TRACE("(CLSID_WshShell %s %p)\n", debugstr_guid(riid), ppv);
252 return IClassFactory_QueryInterface(&WshShellFactory, riid, ppv);
253 }
254 else if(IsEqualGUID(&CLSID_WshNetwork, rclsid)) {
255 TRACE("(CLSID_WshNetwork %s %p)\n", debugstr_guid(riid), ppv);
256 return IClassFactory_QueryInterface(&WshNetworkFactory, riid, ppv);
257 }
258
259 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
261}
static DWORD const fdwReason
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#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
GUID guid
Definition: version.c:147
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
Definition: typelib.c:507
HRESULT WINAPI WshNetworkFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: network.c:287
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: shell.c:1916
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
static TfClientId tid
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:432
static IUnknown * outer
Definition: compobj.c:82
#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
#define TRACE(s)
Definition: solgame.cpp:4
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 E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: wshom_main.c:199
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
Definition: wshom_main.c:227
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
Definition: wshom_main.c:159
static IClassFactory WshNetworkFactory
Definition: wshom_main.c:222
static ITypeLib * typelib
Definition: wshom_main.c:34
static IClassFactory WshShellFactory
Definition: wshom_main.c:221
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
Definition: wshom_main.c:76
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: wshom_main.c:193
static ULONG WINAPI provideclassinfo_Release(IProvideClassInfo *iface)
Definition: wshom_main.c:137
static HRESULT WINAPI provideclassinfo_QueryInterface(IProvideClassInfo *iface, REFIID riid, void **obj)
Definition: wshom_main.c:116
static ULONG WINAPI provideclassinfo_AddRef(IProvideClassInfo *iface)
Definition: wshom_main.c:131
static HRESULT get_typeinfo_of_guid(const GUID *guid, ITypeInfo **tinfo)
Definition: wshom_main.c:66
static const IClassFactoryVtbl WshShellFactoryVtbl
Definition: wshom_main.c:205
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: wshom_main.c:166
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: wshom_main.c:248
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: wshom_main.c:29
static HRESULT load_typelib(void)
Definition: wshom_main.c:47
static const IProvideClassInfoVtbl provideclassinfovtbl
Definition: wshom_main.c:152
static REFIID tid_ids[]
Definition: wshom_main.c:37
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: wshom_main.c:187
static HRESULT WINAPI provideclassinfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ti)
Definition: wshom_main.c:143
static const IClassFactoryVtbl WshNetworkFactoryVtbl
Definition: wshom_main.c:213
static void release_typelib(void)
Definition: wshom_main.c:102
static ITypeInfo * typeinfos[LAST_tid]
Definition: wshom_main.c:35