Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmsi_main.c
Go to the documentation of this file.
00001 /* 00002 * Implementation of the Microsoft Installer (msi.dll) 00003 * 00004 * Copyright 2006 Mike McCormack for CodeWeavers 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include <stdarg.h> 00022 00023 #define COBJMACROS 00024 #define NONAMELESSUNION 00025 00026 #include "windef.h" 00027 #include "winbase.h" 00028 #include "winreg.h" 00029 #include "shlwapi.h" 00030 #include "oleauto.h" 00031 #include "rpcproxy.h" 00032 #include "msipriv.h" 00033 #include "msiserver.h" 00034 00035 #include "wine/debug.h" 00036 00037 WINE_DEFAULT_DEBUG_CHANNEL(msi); 00038 00039 static LONG dll_count; 00040 00041 /* the UI level */ 00042 INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC; 00043 HWND gUIhwnd = 0; 00044 INSTALLUI_HANDLERA gUIHandlerA = NULL; 00045 INSTALLUI_HANDLERW gUIHandlerW = NULL; 00046 INSTALLUI_HANDLER_RECORD gUIHandlerRecord = NULL; 00047 DWORD gUIFilter = 0; 00048 LPVOID gUIContext = NULL; 00049 WCHAR *gszLogFile = NULL; 00050 HINSTANCE msi_hInstance; 00051 00052 00053 /* 00054 * Dll lifetime tracking declaration 00055 */ 00056 static void LockModule(void) 00057 { 00058 InterlockedIncrement(&dll_count); 00059 } 00060 00061 static void UnlockModule(void) 00062 { 00063 InterlockedDecrement(&dll_count); 00064 } 00065 00066 /****************************************************************** 00067 * DllMain 00068 */ 00069 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 00070 { 00071 switch (fdwReason) 00072 { 00073 case DLL_PROCESS_ATTACH: 00074 msi_hInstance = hinstDLL; 00075 DisableThreadLibraryCalls(hinstDLL); 00076 break; 00077 case DLL_PROCESS_DETACH: 00078 msi_dialog_unregister_class(); 00079 msi_free_handle_table(); 00080 msi_free( gszLogFile ); 00081 break; 00082 } 00083 return TRUE; 00084 } 00085 00086 typedef struct tagIClassFactoryImpl { 00087 IClassFactory IClassFactory_iface; 00088 HRESULT (*create_object)( IUnknown*, LPVOID* ); 00089 } IClassFactoryImpl; 00090 00091 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface) 00092 { 00093 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface); 00094 } 00095 00096 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface, 00097 REFIID riid,LPVOID *ppobj) 00098 { 00099 IClassFactoryImpl *This = impl_from_IClassFactory(iface); 00100 00101 TRACE("%p %s %p\n",This,debugstr_guid(riid),ppobj); 00102 00103 if( IsEqualCLSID( riid, &IID_IUnknown ) || 00104 IsEqualCLSID( riid, &IID_IClassFactory ) ) 00105 { 00106 IClassFactory_AddRef( iface ); 00107 *ppobj = iface; 00108 return S_OK; 00109 } 00110 return E_NOINTERFACE; 00111 } 00112 00113 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface) 00114 { 00115 LockModule(); 00116 return 2; 00117 } 00118 00119 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface) 00120 { 00121 UnlockModule(); 00122 return 1; 00123 } 00124 00125 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface, 00126 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) 00127 { 00128 IClassFactoryImpl *This = impl_from_IClassFactory(iface); 00129 IUnknown *unk = NULL; 00130 HRESULT r; 00131 00132 TRACE("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj); 00133 00134 r = This->create_object( pOuter, (LPVOID*) &unk ); 00135 if (SUCCEEDED(r)) 00136 { 00137 r = IUnknown_QueryInterface( unk, riid, ppobj ); 00138 IUnknown_Release( unk ); 00139 } 00140 return r; 00141 } 00142 00143 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock) 00144 { 00145 TRACE("%p %d\n", iface, dolock); 00146 00147 if (dolock) 00148 LockModule(); 00149 else 00150 UnlockModule(); 00151 00152 return S_OK; 00153 } 00154 00155 static const IClassFactoryVtbl MsiCF_Vtbl = 00156 { 00157 MsiCF_QueryInterface, 00158 MsiCF_AddRef, 00159 MsiCF_Release, 00160 MsiCF_CreateInstance, 00161 MsiCF_LockServer 00162 }; 00163 00164 static IClassFactoryImpl MsiServer_CF = { { &MsiCF_Vtbl }, create_msiserver }; 00165 static IClassFactoryImpl WineMsiCustomRemote_CF = { { &MsiCF_Vtbl }, create_msi_custom_remote }; 00166 static IClassFactoryImpl WineMsiRemotePackage_CF = { { &MsiCF_Vtbl }, create_msi_remote_package }; 00167 00168 /****************************************************************** 00169 * DllGetClassObject [MSI.@] 00170 */ 00171 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) 00172 { 00173 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); 00174 00175 if ( IsEqualCLSID (rclsid, &CLSID_MsiInstaller) ) 00176 { 00177 *ppv = &MsiServer_CF; 00178 return S_OK; 00179 } 00180 00181 if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemoteCustomAction) ) 00182 { 00183 *ppv = &WineMsiCustomRemote_CF; 00184 return S_OK; 00185 } 00186 00187 if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemotePackage) ) 00188 { 00189 *ppv = &WineMsiRemotePackage_CF; 00190 return S_OK; 00191 } 00192 00193 if( IsEqualCLSID (rclsid, &CLSID_MsiServerMessage) || 00194 IsEqualCLSID (rclsid, &CLSID_MsiServer) || 00195 IsEqualCLSID (rclsid, &CLSID_PSFactoryBuffer) || 00196 IsEqualCLSID (rclsid, &CLSID_MsiServerX3) ) 00197 { 00198 FIXME("create %s object\n", debugstr_guid( rclsid )); 00199 } 00200 00201 return CLASS_E_CLASSNOTAVAILABLE; 00202 } 00203 00204 /****************************************************************** 00205 * DllGetVersion [MSI.@] 00206 */ 00207 HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi) 00208 { 00209 TRACE("%p\n",pdvi); 00210 00211 if (pdvi->cbSize < sizeof(DLLVERSIONINFO)) 00212 return E_INVALIDARG; 00213 00214 pdvi->dwMajorVersion = MSI_MAJORVERSION; 00215 pdvi->dwMinorVersion = MSI_MINORVERSION; 00216 pdvi->dwBuildNumber = MSI_BUILDNUMBER; 00217 pdvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS; 00218 00219 return S_OK; 00220 } 00221 00222 /****************************************************************** 00223 * DllCanUnloadNow [MSI.@] 00224 */ 00225 HRESULT WINAPI DllCanUnloadNow(void) 00226 { 00227 return dll_count == 0 ? S_OK : S_FALSE; 00228 } 00229 00230 /*********************************************************************** 00231 * DllRegisterServer (MSI.@) 00232 */ 00233 HRESULT WINAPI DllRegisterServer(void) 00234 { 00235 return __wine_register_resources( msi_hInstance ); 00236 } 00237 00238 /*********************************************************************** 00239 * DllUnregisterServer (MSI.@) 00240 */ 00241 HRESULT WINAPI DllUnregisterServer(void) 00242 { 00243 return __wine_unregister_resources( msi_hInstance ); 00244 } Generated on Sat May 26 2012 04:23:48 for ReactOS by
1.7.6.1
|