ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

jscript_main.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2008 Jacek Caban for CodeWeavers
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #include "initguid.h"
00020 
00021 #include "jscript.h"
00022 
00023 #include "winreg.h"
00024 #include "advpub.h"
00025 #include "activaut.h"
00026 #include "objsafe.h"
00027 #include "mshtmhst.h"
00028 
00029 #include "wine/debug.h"
00030 
00031 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
00032 
00033 LONG module_ref = 0;
00034 
00035 static const CLSID CLSID_JScript =
00036     {0xf414c260,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
00037 static const CLSID CLSID_JScriptAuthor =
00038     {0xf414c261,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
00039 static const CLSID CLSID_JScriptEncode =
00040     {0xf414c262,0x6ac0,0x11cf,{0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58}};
00041 
00042 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
00043 
00044 HINSTANCE jscript_hinstance;
00045 
00046 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
00047 {
00048     *ppv = NULL;
00049 
00050     if(IsEqualGUID(&IID_IUnknown, riid)) {
00051         TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
00052         *ppv = iface;
00053     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
00054         TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
00055         *ppv = iface;
00056     }
00057 
00058     if(*ppv) {
00059         IUnknown_AddRef((IUnknown*)*ppv);
00060         return S_OK;
00061     }
00062 
00063     FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
00064     return E_NOINTERFACE;
00065 }
00066 
00067 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
00068 {
00069     TRACE("(%p)\n", iface);
00070     return 2;
00071 }
00072 
00073 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
00074 {
00075     TRACE("(%p)\n", iface);
00076     return 1;
00077 }
00078 
00079 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
00080 {
00081     TRACE("(%p)->(%x)\n", iface, fLock);
00082 
00083     if(fLock)
00084         lock_module();
00085     else
00086         unlock_module();
00087 
00088     return S_OK;
00089 }
00090 
00091 static const IClassFactoryVtbl JScriptFactoryVtbl = {
00092     ClassFactory_QueryInterface,
00093     ClassFactory_AddRef,
00094     ClassFactory_Release,
00095     JScriptFactory_CreateInstance,
00096     ClassFactory_LockServer
00097 };
00098 
00099 static IClassFactory JScriptFactory = { &JScriptFactoryVtbl };
00100 
00101 /******************************************************************
00102  *              DllMain (jscript.@)
00103  */
00104 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
00105 {
00106     TRACE("(%p %d %p)\n", hInstDLL, fdwReason, lpv);
00107 
00108     switch(fdwReason)
00109     {
00110     case DLL_WINE_PREATTACH:
00111         return FALSE;  /* prefer native version */
00112     case DLL_PROCESS_ATTACH:
00113         DisableThreadLibraryCalls(hInstDLL);
00114         jscript_hinstance = hInstDLL;
00115         break;
00116     }
00117 
00118     return TRUE;
00119 }
00120 
00121 /***********************************************************************
00122  *      DllGetClassObject   (jscript.@)
00123  */
00124 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
00125 {
00126     if(IsEqualGUID(&CLSID_JScript, rclsid)) {
00127         TRACE("(CLSID_JScript %s %p)\n", debugstr_guid(riid), ppv);
00128         return IClassFactory_QueryInterface(&JScriptFactory, riid, ppv);
00129     }
00130 
00131     FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
00132     return CLASS_E_CLASSNOTAVAILABLE;
00133 }
00134 
00135 /***********************************************************************
00136  *          DllCanUnloadNow (jscript.@)
00137  */
00138 HRESULT WINAPI DllCanUnloadNow(void)
00139 {
00140     TRACE("() ref=%d\n", module_ref);
00141 
00142     return module_ref ? S_FALSE : S_OK;
00143 }
00144 
00145 /***********************************************************************
00146  *              register_inf
00147  */
00148 
00149 #define INF_SET_ID(id)             \
00150     do                             \
00151     {                              \
00152         static CHAR name[] = #id;  \
00153                                    \
00154         pse[i].pszName = name;     \
00155         clsids[i++] = &id;         \
00156     } while (0)
00157 
00158 static HRESULT register_inf(BOOL doregister)
00159 {
00160     HRESULT hres;
00161     HMODULE hAdvpack;
00162     HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
00163     STRTABLEA strtable;
00164     STRENTRYA pse[7];
00165     static CLSID const *clsids[7];
00166     unsigned int i = 0;
00167 
00168     static const WCHAR advpackW[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
00169 
00170     INF_SET_ID(CLSID_JScript);
00171     INF_SET_ID(CLSID_JScriptAuthor);
00172     INF_SET_ID(CLSID_JScriptEncode);
00173     INF_SET_ID(CATID_ActiveScript);
00174     INF_SET_ID(CATID_ActiveScriptParse);
00175     INF_SET_ID(CATID_ActiveScriptEncode);
00176     INF_SET_ID(CATID_ActiveScriptAuthor);
00177 
00178     for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
00179         pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
00180         sprintf(pse[i].pszValue, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
00181                 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
00182                 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
00183                 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
00184     }
00185 
00186     strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
00187     strtable.pse = pse;
00188 
00189     hAdvpack = LoadLibraryW(advpackW);
00190     pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
00191 
00192     hres = pRegInstall(jscript_hinstance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
00193 
00194     for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
00195         HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
00196 
00197     return hres;
00198 }
00199 
00200 #undef INF_SET_CLSID
00201 
00202 /***********************************************************************
00203  *          DllRegisterServer (jscript.@)
00204  */
00205 HRESULT WINAPI DllRegisterServer(void)
00206 {
00207     TRACE("()\n");
00208     return register_inf(TRUE);
00209 }
00210 
00211 /***********************************************************************
00212  *          DllUnregisterServer (jscript.@)
00213  */
00214 HRESULT WINAPI DllUnregisterServer(void)
00215 {
00216     TRACE("()\n");
00217     return register_inf(FALSE);
00218 }

Generated on Sat May 26 2012 04:22:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.