ReactOS 0.4.16-dev-257-g6aa11ac
scrrun.c
Go to the documentation of this file.
1/*
2 * Copyright 2011 Hans Leidekker 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#define COBJMACROS
19
20#include <stdarg.h>
21
22#include "windef.h"
23#include "winbase.h"
24#include "ole2.h"
25#include "olectl.h"
26#include "rpcproxy.h"
27
28#include <initguid.h>
29#include "scrrun.h"
30#include "scrrun_private.h"
31
32#include "wine/debug.h"
33
35
37
39{
41}
42
43typedef HRESULT (*fnCreateInstance)(LPVOID *ppObj);
44
46{
47 *ppv = NULL;
48
50 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
51 *ppv = iface;
53 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
54 *ppv = iface;
55 }
56
57 if(*ppv) {
58 IUnknown_AddRef((IUnknown*)*ppv);
59 return S_OK;
60 }
61
62 WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
63 return E_NOINTERFACE;
64}
65
67{
68 TRACE("(%p)\n", iface);
69 return 2;
70}
71
73{
74 TRACE("(%p)\n", iface);
75 return 1;
76}
77
79{
80 TRACE("(%p)->(%x)\n", iface, fLock);
81 return S_OK;
82}
83
84static const struct IClassFactoryVtbl scrruncf_vtbl =
85{
91};
92
93static const struct IClassFactoryVtbl dictcf_vtbl =
94{
100};
101
104
107
108static REFIID tid_ids[] = {
109 &IID_NULL,
110 &IID_IDictionary,
111 &IID_IDrive,
112 &IID_IDriveCollection,
113 &IID_IFile,
114 &IID_IFileCollection,
115 &IID_IFileSystem3,
116 &IID_IFolder,
117 &IID_IFolderCollection,
118 &IID_ITextStream
119};
120
122{
124 ITypeLib *tl;
125
126 if(typelib)
127 return S_OK;
128
129 hres = LoadRegTypeLib(&LIBID_Scripting, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
130 if(FAILED(hres)) {
131 ERR("LoadRegTypeLib failed: %08x\n", hres);
132 return hres;
133 }
134
136 ITypeLib_Release(tl);
137 return hres;
138}
139
141{
143
144 if(FAILED(hres = load_typelib()))
145 return hres;
146
147 return ITypeLib_GetTypeInfoOfGuid(typelib, guid, tinfo);
148}
149
151{
153
154 if (FAILED(hres = load_typelib()))
155 return hres;
156
157 if(!typeinfos[tid]) {
158 ITypeInfo *ti;
159
160 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
161 if(FAILED(hres)) {
162 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
163 return hres;
164 }
165
167 ITypeInfo_Release(ti);
168 }
169
171 ITypeInfo_AddRef(typeinfos[tid]);
172 return S_OK;
173}
174
175static void release_typelib(void)
176{
177 unsigned i;
178
179 if(!typelib)
180 return;
181
182 for (i = 0; i < ARRAY_SIZE(typeinfos); i++)
183 if(typeinfos[i])
184 ITypeInfo_Release(typeinfos[i]);
185
186 ITypeLib_Release(typelib);
187}
188
190{
192
193 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
194
196 *obj = iface;
197 IProvideClassInfo_AddRef(iface);
198 return S_OK;
199 }
200 else
201 return IUnknown_QueryInterface(This->outer, riid, obj);
202}
203
205{
207 return IUnknown_AddRef(This->outer);
208}
209
211{
213 return IUnknown_Release(This->outer);
214}
215
217{
219
220 TRACE("(%p)->(%p)\n", This, ti);
221
222 return get_typeinfo_of_guid(This->guid, ti);
223}
224
225static const IProvideClassInfoVtbl provideclassinfovtbl = {
230};
231
233{
234 classinfo->IProvideClassInfo_iface.lpVtbl = &provideclassinfovtbl;
235 classinfo->outer = outer;
236 classinfo->guid = guid;
237}
238
240{
241 TRACE("%p, %u, %p\n", hinst, reason, reserved);
242
243 switch (reason)
244 {
245 case DLL_WINE_PREATTACH:
246 return FALSE; /* prefer native version */
250 break;
252 if (reserved) break;
254 break;
255 }
256 return TRUE;
257}
258
259/***********************************************************************
260 * DllRegisterServer (scrrun.@)
261 */
263{
264 TRACE("()\n");
266}
267
268/***********************************************************************
269 * DllUnregisterServer (scrrun.@)
270 */
272{
273 TRACE("()\n");
275}
276
277/***********************************************************************
278 * DllGetClassObject (scrrun.@)
279 */
280
282{
283 if(IsEqualGUID(&CLSID_FileSystemObject, rclsid)) {
284 TRACE("(CLSID_FileSystemObject %s %p)\n", debugstr_guid(riid), ppv);
285 return IClassFactory_QueryInterface(&FileSystemFactory, riid, ppv);
286 }
287 else if(IsEqualGUID(&CLSID_Dictionary, rclsid)) {
288 TRACE("(CLSID_Dictionary %s %p)\n", debugstr_guid(riid), ppv);
289 return IClassFactory_QueryInterface(&DictionaryFactory, riid, ppv);
290 }
291
292 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
294}
295
296/***********************************************************************
297 * DllCanUnloadNow (scrrun.@)
298 */
300{
301 return S_FALSE;
302}
#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
classinfo
Definition: clsfactory.c:43
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
#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 Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **obj)
Definition: dictionary.c:892
HRESULT WINAPI FileSystem_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: filesystem.c:3998
r reserved
Definition: btrfs.c:3006
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
static HINSTANCE hinst
Definition: edit.c:551
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
static const struct IClassFactoryVtbl dictcf_vtbl
Definition: scrrun.c:93
HRESULT(* fnCreateInstance)(LPVOID *ppObj)
Definition: scrrun.c:43
void init_classinfo(const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
Definition: scrrun.c:232
HRESULT WINAPI DllRegisterServer(void)
Definition: scrrun.c:262
static HRESULT WINAPI scrruncf_LockServer(IClassFactory *iface, BOOL fLock)
Definition: scrrun.c:78
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
Definition: scrrun.c:239
static ITypeLib * typelib
Definition: scrrun.c:105
static HINSTANCE scrrun_instance
Definition: scrrun.c:36
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
Definition: scrrun.c:150
static HRESULT WINAPI scrruncf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
Definition: scrrun.c:45
static ULONG WINAPI provideclassinfo_Release(IProvideClassInfo *iface)
Definition: scrrun.c:210
static HRESULT WINAPI provideclassinfo_QueryInterface(IProvideClassInfo *iface, REFIID riid, void **obj)
Definition: scrrun.c:189
static ULONG WINAPI provideclassinfo_AddRef(IProvideClassInfo *iface)
Definition: scrrun.c:204
static const struct IClassFactoryVtbl scrruncf_vtbl
Definition: scrrun.c:84
HRESULT WINAPI DllUnregisterServer(void)
Definition: scrrun.c:271
static HRESULT get_typeinfo_of_guid(const GUID *guid, ITypeInfo **tinfo)
Definition: scrrun.c:140
static IClassFactory FileSystemFactory
Definition: scrrun.c:102
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: scrrun.c:281
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: scrrun.c:38
static HRESULT load_typelib(void)
Definition: scrrun.c:121
static ULONG WINAPI scrruncf_AddRef(IClassFactory *iface)
Definition: scrrun.c:66
static const IProvideClassInfoVtbl provideclassinfovtbl
Definition: scrrun.c:225
static REFIID tid_ids[]
Definition: scrrun.c:108
static HRESULT WINAPI provideclassinfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ti)
Definition: scrrun.c:216
static IClassFactory DictionaryFactory
Definition: scrrun.c:103
HRESULT WINAPI DllCanUnloadNow(void)
Definition: scrrun.c:299
static void release_typelib(void)
Definition: scrrun.c:175
static ULONG WINAPI scrruncf_Release(IClassFactory *iface)
Definition: scrrun.c:72
static ITypeInfo * typeinfos[LAST_tid]
Definition: scrrun.c:106
#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 HRESULT
Definition: msvc.h:7
#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