ReactOS  0.4.14-dev-115-g4576127
jscript_main.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 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 "initguid.h"
20 
21 #include "jscript.h"
22 
23 #include "winreg.h"
24 #include "advpub.h"
25 #include "activaut.h"
26 #include "objsafe.h"
27 #include "mshtmhst.h"
28 #include "rpcproxy.h"
29 #include "jscript_classes.h"
30 
31 #include "wine/debug.h"
32 
34 
36 
37 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
38 
40 
42 {
43  *ppv = NULL;
44 
46  TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
47  *ppv = iface;
48  }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
49  TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
50  *ppv = iface;
51  }
52 
53  if(*ppv) {
54  IUnknown_AddRef((IUnknown*)*ppv);
55  return S_OK;
56  }
57 
58  FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
59  return E_NOINTERFACE;
60 }
61 
63 {
64  TRACE("(%p)\n", iface);
65  return 2;
66 }
67 
69 {
70  TRACE("(%p)\n", iface);
71  return 1;
72 }
73 
75 {
76  TRACE("(%p)->(%x)\n", iface, fLock);
77 
78  if(fLock)
79  lock_module();
80  else
81  unlock_module();
82 
83  return S_OK;
84 }
85 
87  REFIID riid, void **ppv)
88 {
89  TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
90 
91  if(outer) {
92  *ppv = NULL;
93  return CLASS_E_NOAGGREGATION;
94  }
95 
97 }
98 
99 static const IClassFactoryVtbl JScriptFactoryVtbl = {
105 };
106 
108 
110  REFIID riid, void **ppv)
111 {
112  TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
113 
114  if(outer) {
115  *ppv = NULL;
116  return CLASS_E_NOAGGREGATION;
117  }
118 
120 }
121 
122 static const IClassFactoryVtbl JScriptEncodeFactoryVtbl = {
128 };
129 
131 
132 /******************************************************************
133  * DllMain (jscript.@)
134  */
135 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
136 {
137  TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
138 
139  switch(fdwReason) {
140  case DLL_PROCESS_ATTACH:
141  DisableThreadLibraryCalls(hInstDLL);
142  jscript_hinstance = hInstDLL;
143  if(!init_strings())
144  return FALSE;
145  break;
146  case DLL_PROCESS_DETACH:
147  if (lpv) break;
148  free_strings();
149  }
150 
151  return TRUE;
152 }
153 
154 /***********************************************************************
155  * DllGetClassObject (jscript.@)
156  */
158 {
159  if(IsEqualGUID(&CLSID_JScript, rclsid)) {
160  TRACE("(CLSID_JScript %s %p)\n", debugstr_guid(riid), ppv);
161  return IClassFactory_QueryInterface(&JScriptFactory, riid, ppv);
162  }
163 
164  if(IsEqualGUID(&CLSID_JScriptEncode, rclsid)) {
165  TRACE("(CLSID_JScriptEncode %s %p)\n", debugstr_guid(riid), ppv);
166  return IClassFactory_QueryInterface(&JScriptEncodeFactory, riid, ppv);
167  }
168 
169  FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
171 }
172 
173 /***********************************************************************
174  * DllCanUnloadNow (jscript.@)
175  */
177 {
178  TRACE("() ref=%d\n", module_ref);
179 
180  return module_ref ? S_FALSE : S_OK;
181 }
182 
183 /***********************************************************************
184  * DllRegisterServer (jscript.@)
185  */
187 {
188  TRACE("()\n");
190 }
191 
192 /***********************************************************************
193  * DllUnregisterServer (jscript.@)
194  */
196 {
197  TRACE("()\n");
199 }
static const IClassFactoryVtbl JScriptFactoryVtbl
Definition: jscript_main.c:99
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
static const IClassFactoryVtbl JScriptEncodeFactoryVtbl
Definition: jscript_main.c:122
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
Definition: jscript_main.c:135
REFIID riid
Definition: precomp.h:44
HRESULT WINAPI DllRegisterServer(void)
Definition: jscript_main.c:186
#define REFCLSID
Definition: guiddef.h:117
static IClassFactory JScriptFactory
Definition: jscript_main.c:107
REFIID LPVOID * ppv
Definition: atlbase.h:39
static const CLSID CLSID_JScript
Definition: activex.c:57
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
Definition: jscript_main.c:74
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv)
Definition: jscript.c:1072
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
HRESULT WINAPI DllCanUnloadNow(void)
Definition: jscript_main.c:176
#define FIXME(fmt,...)
Definition: debug.h:110
static HRESULT WINAPI JScriptEncodeFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: jscript_main.c:109
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
#define DLL_PROCESS_DETACH
Definition: compat.h:119
HINSTANCE jscript_hinstance
Definition: jscript_main.c:39
#define TRACE(s)
Definition: solgame.cpp:4
LONG module_ref
Definition: jscript_main.c:35
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
static void unlock_module(void)
Definition: ieframe.h:339
unsigned long DWORD
Definition: ntddk_ex.h:95
WINE_DEFAULT_DEBUG_CHANNEL(jscript)
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
static IClassFactory JScriptEncodeFactory
Definition: jscript_main.c:130
#define GUID_NULL
Definition: ks.h:106
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: jscript_main.c:157
static HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: jscript_main.c:86
void free_strings(void)
Definition: jsstr.c:325
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
Definition: jscript_main.c:62
static const CLSID CLSID_JScriptEncode
Definition: jscript.c:50
static void lock_module(void)
Definition: ieframe.h:335
unsigned int ULONG
Definition: retypes.h:1
const GUID IID_IClassFactory
BOOL init_strings(void)
Definition: jsstr.c:308
HRESULT WINAPI DllUnregisterServer(void)
Definition: jscript_main.c:195
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
Definition: jscript_main.c:68
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
Definition: jscript_main.c:41