2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
29 #include "jscript_classes.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
37 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
39 HINSTANCE jscript_hinstance;
41 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
45 if(IsEqualGUID(&IID_IUnknown, riid)) {
46 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
48 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
49 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
54 IUnknown_AddRef((IUnknown*)*ppv);
58 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
62 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
64 TRACE("(%p)\n", iface);
68 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
70 TRACE("(%p)\n", iface);
74 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
76 TRACE("(%p)->(%x)\n", iface, fLock);
86 static const IClassFactoryVtbl JScriptFactoryVtbl = {
87 ClassFactory_QueryInterface,
90 JScriptFactory_CreateInstance,
91 ClassFactory_LockServer
94 static IClassFactory JScriptFactory = { &JScriptFactoryVtbl };
96 /******************************************************************
99 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
101 TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
105 case DLL_WINE_PREATTACH:
106 return FALSE; /* prefer native version */
107 case DLL_PROCESS_ATTACH:
108 DisableThreadLibraryCalls(hInstDLL);
109 jscript_hinstance = hInstDLL;
116 /***********************************************************************
117 * DllGetClassObject (jscript.@)
119 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
121 if(IsEqualGUID(&CLSID_JScript, rclsid)) {
122 TRACE("(CLSID_JScript %s %p)\n", debugstr_guid(riid), ppv);
123 return IClassFactory_QueryInterface(&JScriptFactory, riid, ppv);
126 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
127 return CLASS_E_CLASSNOTAVAILABLE;
130 /***********************************************************************
131 * DllCanUnloadNow (jscript.@)
133 HRESULT WINAPI DllCanUnloadNow(void)
135 TRACE("() ref=%d\n", module_ref);
137 return module_ref ? S_FALSE : S_OK;
140 /***********************************************************************
144 #define INF_SET_ID(id) \
147 static CHAR name[] = #id; \
149 pse[i].pszName = name; \
153 static HRESULT register_inf(BOOL doregister)
157 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
160 static CLSID const *clsids[7];
163 static const WCHAR advpackW[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
165 INF_SET_ID(CLSID_JScript);
166 INF_SET_ID(CLSID_JScriptAuthor);
167 INF_SET_ID(CLSID_JScriptEncode);
168 INF_SET_ID(CATID_ActiveScript);
169 INF_SET_ID(CATID_ActiveScriptParse);
170 INF_SET_ID(CATID_ActiveScriptEncode);
171 INF_SET_ID(CATID_ActiveScriptAuthor);
173 for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
174 pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
175 sprintf(pse[i].pszValue, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
176 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
177 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
178 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
181 strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
184 hAdvpack = LoadLibraryW(advpackW);
185 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
187 hres = pRegInstall(jscript_hinstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
189 for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
190 HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
197 /***********************************************************************
198 * DllRegisterServer (jscript.@)
200 HRESULT WINAPI DllRegisterServer(void)
206 hres = __wine_register_resources(jscript_hinstance, NULL);
210 return register_inf(TRUE);
213 /***********************************************************************
214 * DllUnregisterServer (jscript.@)
216 HRESULT WINAPI DllUnregisterServer(void)
222 hres = __wine_unregister_resources(jscript_hinstance, NULL);
226 return register_inf(FALSE);