ReactOS  0.4.15-dev-1377-ga59cecd
scrrun.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "ole2.h"
#include "olectl.h"
#include "rpcproxy.h"
#include <initguid.h>
#include "scrrun.h"
#include "scrrun_private.h"
#include "wine/debug.h"
Include dependency graph for scrrun.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Typedefs

typedef HRESULT(* fnCreateInstance) (LPVOID *ppObj)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (scrrun)
 
static struct provideclassinfoimpl_from_IProvideClassInfo (IProvideClassInfo *iface)
 
static HRESULT WINAPI scrruncf_QueryInterface (IClassFactory *iface, REFIID riid, LPVOID *ppv)
 
static ULONG WINAPI scrruncf_AddRef (IClassFactory *iface)
 
static ULONG WINAPI scrruncf_Release (IClassFactory *iface)
 
static HRESULT WINAPI scrruncf_LockServer (IClassFactory *iface, BOOL fLock)
 
static HRESULT load_typelib (void)
 
static HRESULT get_typeinfo_of_guid (const GUID *guid, ITypeInfo **tinfo)
 
HRESULT get_typeinfo (tid_t tid, ITypeInfo **typeinfo)
 
static void release_typelib (void)
 
static HRESULT WINAPI provideclassinfo_QueryInterface (IProvideClassInfo *iface, REFIID riid, void **obj)
 
static ULONG WINAPI provideclassinfo_AddRef (IProvideClassInfo *iface)
 
static ULONG WINAPI provideclassinfo_Release (IProvideClassInfo *iface)
 
static HRESULT WINAPI provideclassinfo_GetClassInfo (IProvideClassInfo *iface, ITypeInfo **ti)
 
void init_classinfo (const GUID *guid, IUnknown *outer, struct provideclassinfo *classinfo)
 
BOOL WINAPI DllMain (HINSTANCE hinst, DWORD reason, LPVOID reserved)
 
HRESULT WINAPI DllRegisterServer (void)
 
HRESULT WINAPI DllUnregisterServer (void)
 
HRESULT WINAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID *ppv)
 
HRESULT WINAPI DllCanUnloadNow (void)
 

Variables

static HINSTANCE scrrun_instance
 
static const struct IClassFactoryVtbl scrruncf_vtbl
 
static const struct IClassFactoryVtbl dictcf_vtbl
 
static IClassFactory FileSystemFactory = { &scrruncf_vtbl }
 
static IClassFactory DictionaryFactory = { &dictcf_vtbl }
 
static ITypeLibtypelib
 
static ITypeInfotypeinfos [LAST_tid]
 
static REFIID tid_ids []
 
static const IProvideClassInfoVtbl provideclassinfovtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 18 of file scrrun.c.

Typedef Documentation

◆ fnCreateInstance

typedef HRESULT(* fnCreateInstance) (LPVOID *ppObj)

Definition at line 43 of file scrrun.c.

Function Documentation

◆ DllCanUnloadNow()

HRESULT WINAPI DllCanUnloadNow ( void  )

Definition at line 299 of file scrrun.c.

300 {
301  return S_FALSE;
302 }
#define S_FALSE
Definition: winerror.h:2357

◆ DllGetClassObject()

HRESULT WINAPI DllGetClassObject ( REFCLSID  rclsid,
REFIID  riid,
LPVOID ppv 
)

Definition at line 281 of file scrrun.c.

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 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define FIXME(fmt,...)
Definition: debug.h:111
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
static IClassFactory DictionaryFactory
Definition: scrrun.c:103
static IClassFactory FileSystemFactory
Definition: scrrun.c:102
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinst,
DWORD  reason,
LPVOID  reserved 
)

Definition at line 239 of file scrrun.c.

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 */
247  case DLL_PROCESS_ATTACH:
250  break;
251  case DLL_PROCESS_DETACH:
252  if (reserved) break;
253  release_typelib();
254  break;
255  }
256  return TRUE;
257 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define FALSE
Definition: types.h:117
r reserved
Definition: btrfs.c:2940
#define DLL_PROCESS_DETACH
Definition: compat.h:130
static HINSTANCE scrrun_instance
Definition: scrrun.c:36
#define TRACE(s)
Definition: solgame.cpp:4
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
static HINSTANCE hinst
Definition: edit.c:551
static void release_typelib(void)
Definition: scrrun.c:175

◆ DllRegisterServer()

HRESULT WINAPI DllRegisterServer ( void  )

Definition at line 262 of file scrrun.c.

263 {
264  TRACE("()\n");
266 }
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static HINSTANCE scrrun_instance
Definition: scrrun.c:36
#define TRACE(s)
Definition: solgame.cpp:4

◆ DllUnregisterServer()

HRESULT WINAPI DllUnregisterServer ( void  )

Definition at line 271 of file scrrun.c.

272 {
273  TRACE("()\n");
275 }
static HINSTANCE scrrun_instance
Definition: scrrun.c:36
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110

◆ get_typeinfo()

HRESULT get_typeinfo ( tid_t  tid,
ITypeInfo **  typeinfo 
)

Definition at line 150 of file scrrun.c.

151 {
152  HRESULT hres;
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 
170  *typeinfo = typeinfos[tid];
171  ITypeInfo_AddRef(typeinfos[tid]);
172  return S_OK;
173 }
static ITypeInfo * typeinfos[LAST_tid]
Definition: scrrun.c:106
static REFIID tid_ids[]
Definition: scrrun.c:108
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
static ITypeLib * typelib
Definition: scrrun.c:105
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
static HRESULT load_typelib(void)
Definition: scrrun.c:121
static TfClientId tid

◆ get_typeinfo_of_guid()

static HRESULT get_typeinfo_of_guid ( const GUID guid,
ITypeInfo **  tinfo 
)
static

Definition at line 140 of file scrrun.c.

141 {
142  HRESULT hres;
143 
144  if(FAILED(hres = load_typelib()))
145  return hres;
146 
147  return ITypeLib_GetTypeInfoOfGuid(typelib, guid, tinfo);
148 }
const GUID * guid
static ITypeLib * typelib
Definition: scrrun.c:105
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
static HRESULT load_typelib(void)
Definition: scrrun.c:121

Referenced by provideclassinfo_GetClassInfo().

◆ impl_from_IProvideClassInfo()

static struct provideclassinfo* impl_from_IProvideClassInfo ( IProvideClassInfo iface)
inlinestatic

Definition at line 38 of file scrrun.c.

39 {
40  return CONTAINING_RECORD(iface, struct provideclassinfo, IProvideClassInfo_iface);
41 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560

Referenced by provideclassinfo_AddRef(), provideclassinfo_GetClassInfo(), provideclassinfo_QueryInterface(), and provideclassinfo_Release().

◆ init_classinfo()

void init_classinfo ( const GUID guid,
IUnknown outer,
struct provideclassinfo classinfo 
)

Definition at line 232 of file scrrun.c.

233 {
234  classinfo->IProvideClassInfo_iface.lpVtbl = &provideclassinfovtbl;
235  classinfo->outer = outer;
236  classinfo->guid = guid;
237 }
classinfo
Definition: clsfactory.c:43
static const IProvideClassInfoVtbl provideclassinfovtbl
Definition: scrrun.c:225
const GUID * guid

Referenced by create_drive(), create_drivecoll(), create_file(), create_filecoll(), create_folder(), create_foldercoll(), create_textstream(), Dictionary_CreateInstance(), FileSystem_CreateInstance(), WshCollection_Create(), WshEnvironment_Create(), WshExec_create(), WshShellFactory_CreateInstance(), and WshShortcut_Create().

◆ load_typelib()

static HRESULT load_typelib ( void  )
static

Definition at line 121 of file scrrun.c.

122 {
123  HRESULT hres;
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 }
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
static ITypeLib * typelib
Definition: scrrun.c:105
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:79
#define LOCALE_SYSTEM_DEFAULT
#define ERR(fmt,...)
Definition: debug.h:110
#define S_OK
Definition: intsafe.h:51
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
Definition: typelib.c:531
#define NULL
Definition: types.h:112

Referenced by get_typeinfo(), and get_typeinfo_of_guid().

◆ provideclassinfo_AddRef()

static ULONG WINAPI provideclassinfo_AddRef ( IProvideClassInfo iface)
static

Definition at line 204 of file scrrun.c.

205 {
207  return IUnknown_AddRef(This->outer);
208 }
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: scrrun.c:38

◆ provideclassinfo_GetClassInfo()

static HRESULT WINAPI provideclassinfo_GetClassInfo ( IProvideClassInfo iface,
ITypeInfo **  ti 
)
static

Definition at line 216 of file scrrun.c.

217 {
219 
220  TRACE("(%p)->(%p)\n", This, ti);
221 
222  return get_typeinfo_of_guid(This->guid, ti);
223 }
static HRESULT get_typeinfo_of_guid(const GUID *guid, ITypeInfo **tinfo)
Definition: scrrun.c:140
#define TRACE(s)
Definition: solgame.cpp:4
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: scrrun.c:38

◆ provideclassinfo_QueryInterface()

static HRESULT WINAPI provideclassinfo_QueryInterface ( IProvideClassInfo iface,
REFIID  riid,
void **  obj 
)
static

Definition at line 189 of file scrrun.c.

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 }
REFIID riid
Definition: precomp.h:44
const GUID IID_IProvideClassInfo
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: scrrun.c:38
#define S_OK
Definition: intsafe.h:51
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95

◆ provideclassinfo_Release()

static ULONG WINAPI provideclassinfo_Release ( IProvideClassInfo iface)
static

Definition at line 210 of file scrrun.c.

211 {
213  return IUnknown_Release(This->outer);
214 }
static struct provideclassinfo * impl_from_IProvideClassInfo(IProvideClassInfo *iface)
Definition: scrrun.c:38

◆ release_typelib()

static void release_typelib ( void  )
static

Definition at line 175 of file scrrun.c.

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 }
static ITypeInfo * typeinfos[LAST_tid]
Definition: scrrun.c:106
static ITypeLib * typelib
Definition: scrrun.c:105
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
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by DllMain().

◆ scrruncf_AddRef()

static ULONG WINAPI scrruncf_AddRef ( IClassFactory iface)
static

Definition at line 66 of file scrrun.c.

67 {
68  TRACE("(%p)\n", iface);
69  return 2;
70 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ scrruncf_LockServer()

static HRESULT WINAPI scrruncf_LockServer ( IClassFactory iface,
BOOL  fLock 
)
static

Definition at line 78 of file scrrun.c.

79 {
80  TRACE("(%p)->(%x)\n", iface, fLock);
81  return S_OK;
82 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:51

◆ scrruncf_QueryInterface()

static HRESULT WINAPI scrruncf_QueryInterface ( IClassFactory iface,
REFIID  riid,
LPVOID ppv 
)
static

Definition at line 45 of file scrrun.c.

46 {
47  *ppv = NULL;
48 
50  TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
51  *ppv = iface;
52  }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
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 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:112
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:51
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
const GUID IID_IClassFactory

◆ scrruncf_Release()

static ULONG WINAPI scrruncf_Release ( IClassFactory iface)
static

Definition at line 72 of file scrrun.c.

73 {
74  TRACE("(%p)\n", iface);
75  return 1;
76 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( scrrun  )

Variable Documentation

◆ dictcf_vtbl

const struct IClassFactoryVtbl dictcf_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI scrruncf_AddRef(IClassFactory *iface)
Definition: scrrun.c:66
HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **obj)
Definition: dictionary.c:892
static HRESULT WINAPI scrruncf_LockServer(IClassFactory *iface, BOOL fLock)
Definition: scrrun.c:78
static HRESULT WINAPI scrruncf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
Definition: scrrun.c:45
static ULONG WINAPI scrruncf_Release(IClassFactory *iface)
Definition: scrrun.c:72

Definition at line 93 of file scrrun.c.

◆ DictionaryFactory

IClassFactory DictionaryFactory = { &dictcf_vtbl }
static

Definition at line 103 of file scrrun.c.

Referenced by DllGetClassObject().

◆ FileSystemFactory

IClassFactory FileSystemFactory = { &scrruncf_vtbl }
static

Definition at line 102 of file scrrun.c.

Referenced by DllGetClassObject().

◆ provideclassinfovtbl

const IProvideClassInfoVtbl provideclassinfovtbl
static
Initial value:
= {
}
static HRESULT WINAPI provideclassinfo_GetClassInfo(IProvideClassInfo *iface, ITypeInfo **ti)
Definition: scrrun.c:216
static ULONG WINAPI provideclassinfo_AddRef(IProvideClassInfo *iface)
Definition: scrrun.c:204
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

Definition at line 225 of file scrrun.c.

Referenced by init_classinfo().

◆ scrrun_instance

HINSTANCE scrrun_instance
static

Definition at line 36 of file scrrun.c.

Referenced by DllMain(), DllRegisterServer(), and DllUnregisterServer().

◆ scrruncf_vtbl

const struct IClassFactoryVtbl scrruncf_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI scrruncf_AddRef(IClassFactory *iface)
Definition: scrrun.c:66
HRESULT WINAPI FileSystem_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: filesystem.c:3998
static HRESULT WINAPI scrruncf_LockServer(IClassFactory *iface, BOOL fLock)
Definition: scrrun.c:78
static HRESULT WINAPI scrruncf_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppv)
Definition: scrrun.c:45
static ULONG WINAPI scrruncf_Release(IClassFactory *iface)
Definition: scrrun.c:72

Definition at line 84 of file scrrun.c.

◆ tid_ids

REFIID tid_ids[]
static
Initial value:
= {
&IID_IDictionary,
&IID_IDrive,
&IID_IDriveCollection,
&IID_IFile,
&IID_IFileCollection,
&IID_IFileSystem3,
&IID_IFolder,
&IID_IFolderCollection,
&IID_ITextStream
}
#define IID_NULL
Definition: guiddef.h:98

Definition at line 108 of file scrrun.c.

Referenced by get_typeinfo().

◆ typeinfos

ITypeInfo* typeinfos[LAST_tid]
static

Definition at line 106 of file scrrun.c.

Referenced by get_typeinfo(), and release_typelib().

◆ typelib

ITypeLib* typelib
static

Definition at line 105 of file scrrun.c.

Referenced by get_typeinfo(), get_typeinfo_of_guid(), load_typelib(), and release_typelib().