2006-07-24 12:47:00 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2006 Mike McCormack for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
2007-02-08 09:20:55 +01:00
|
|
|
#include "oleauto.h"
|
2010-12-17 14:59:49 +01:00
|
|
|
#include "rpcproxy.h"
|
2006-07-24 12:47:00 +02:00
|
|
|
#include "msipriv.h"
|
2010-12-17 14:59:49 +01:00
|
|
|
#include "msiserver.h"
|
2006-07-24 12:47:00 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
static LONG dll_count;
|
|
|
|
|
|
|
|
/* the UI level */
|
2009-11-02 10:04:05 +01:00
|
|
|
INSTALLUILEVEL gUILevel = INSTALLUILEVEL_BASIC;
|
|
|
|
HWND gUIhwnd = 0;
|
|
|
|
INSTALLUI_HANDLERA gUIHandlerA = NULL;
|
|
|
|
INSTALLUI_HANDLERW gUIHandlerW = NULL;
|
|
|
|
INSTALLUI_HANDLER_RECORD gUIHandlerRecord = NULL;
|
|
|
|
DWORD gUIFilter = 0;
|
|
|
|
LPVOID gUIContext = NULL;
|
2010-10-26 12:42:34 +02:00
|
|
|
WCHAR *gszLogFile = NULL;
|
2006-07-24 12:47:00 +02:00
|
|
|
HINSTANCE msi_hInstance;
|
|
|
|
|
2007-11-06 14:38:54 +01:00
|
|
|
|
2006-07-24 12:47:00 +02:00
|
|
|
/*
|
|
|
|
* Dll lifetime tracking declaration
|
|
|
|
*/
|
|
|
|
static void LockModule(void)
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&dll_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UnlockModule(void)
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&dll_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2007-01-25 11:17:42 +01:00
|
|
|
* DllMain
|
2006-07-24 12:47:00 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
msi_hInstance = hinstDLL;
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
msi_dialog_unregister_class();
|
2006-08-29 10:08:01 +02:00
|
|
|
msi_free_handle_table();
|
2010-10-26 12:42:34 +02:00
|
|
|
msi_free( gszLogFile );
|
2006-07-24 12:47:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-02-08 09:20:55 +01:00
|
|
|
typedef struct tagIClassFactoryImpl {
|
2010-12-15 00:35:27 +01:00
|
|
|
IClassFactory IClassFactory_iface;
|
2007-02-08 09:20:55 +01:00
|
|
|
HRESULT (*create_object)( IUnknown*, LPVOID* );
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2010-12-15 00:35:27 +01:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2006-07-24 12:47:00 +02:00
|
|
|
static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
|
|
|
|
REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
2010-12-15 00:35:27 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2007-01-25 11:17:42 +01:00
|
|
|
|
|
|
|
TRACE("%p %s %p\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
|
|
|
|
if( IsEqualCLSID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualCLSID( riid, &IID_IClassFactory ) )
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef( iface );
|
|
|
|
*ppobj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-07-24 12:47:00 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
LockModule();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
UnlockModule();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
|
|
|
|
LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
2010-12-15 00:35:27 +01:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2007-01-25 11:18:18 +01:00
|
|
|
IUnknown *unk = NULL;
|
|
|
|
HRESULT r;
|
2006-07-24 12:47:00 +02:00
|
|
|
|
2007-01-25 11:18:18 +01:00
|
|
|
TRACE("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
|
|
|
|
|
2007-01-26 13:14:07 +01:00
|
|
|
r = This->create_object( pOuter, (LPVOID*) &unk );
|
2007-01-25 11:18:18 +01:00
|
|
|
if (SUCCEEDED(r))
|
|
|
|
{
|
|
|
|
r = IUnknown_QueryInterface( unk, riid, ppobj );
|
|
|
|
IUnknown_Release( unk );
|
|
|
|
}
|
|
|
|
return r;
|
2006-07-24 12:47:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
|
|
|
|
{
|
|
|
|
TRACE("%p %d\n", iface, dolock);
|
|
|
|
|
|
|
|
if (dolock)
|
|
|
|
LockModule();
|
|
|
|
else
|
|
|
|
UnlockModule();
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl MsiCF_Vtbl =
|
|
|
|
{
|
|
|
|
MsiCF_QueryInterface,
|
|
|
|
MsiCF_AddRef,
|
|
|
|
MsiCF_Release,
|
|
|
|
MsiCF_CreateInstance,
|
|
|
|
MsiCF_LockServer
|
|
|
|
};
|
|
|
|
|
2010-12-15 00:35:27 +01:00
|
|
|
static IClassFactoryImpl MsiServer_CF = { { &MsiCF_Vtbl }, create_msiserver };
|
|
|
|
static IClassFactoryImpl WineMsiCustomRemote_CF = { { &MsiCF_Vtbl }, create_msi_custom_remote };
|
|
|
|
static IClassFactoryImpl WineMsiRemotePackage_CF = { { &MsiCF_Vtbl }, create_msi_remote_package };
|
2006-07-24 12:47:00 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DllGetClassObject [MSI.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
|
2010-12-17 14:59:49 +01:00
|
|
|
if ( IsEqualCLSID (rclsid, &CLSID_MsiInstaller) )
|
2007-01-25 11:18:18 +01:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
*ppv = &MsiServer_CF;
|
2007-01-25 11:18:18 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:59:49 +01:00
|
|
|
if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemoteCustomAction) )
|
2006-07-24 12:47:00 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
*ppv = &WineMsiCustomRemote_CF;
|
2007-07-03 05:15:32 +02:00
|
|
|
return S_OK;
|
2006-07-24 12:47:00 +02:00
|
|
|
}
|
2007-01-25 11:18:18 +01:00
|
|
|
|
2010-12-17 14:59:49 +01:00
|
|
|
if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemotePackage) )
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
*ppv = &WineMsiRemotePackage_CF;
|
2007-07-03 05:15:01 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-17 14:59:49 +01:00
|
|
|
if( IsEqualCLSID (rclsid, &CLSID_MsiServerMessage) ||
|
|
|
|
IsEqualCLSID (rclsid, &CLSID_MsiServer) ||
|
|
|
|
IsEqualCLSID (rclsid, &CLSID_PSFactoryBuffer) ||
|
|
|
|
IsEqualCLSID (rclsid, &CLSID_MsiServerX3) )
|
2007-07-03 05:15:32 +02:00
|
|
|
{
|
|
|
|
FIXME("create %s object\n", debugstr_guid( rclsid ));
|
|
|
|
}
|
|
|
|
|
2006-07-24 12:47:00 +02:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DllGetVersion [MSI.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi)
|
|
|
|
{
|
|
|
|
TRACE("%p\n",pdvi);
|
|
|
|
|
2006-07-28 00:26:42 +02:00
|
|
|
if (pdvi->cbSize < sizeof(DLLVERSIONINFO))
|
2006-07-24 12:47:00 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pdvi->dwMajorVersion = MSI_MAJORVERSION;
|
|
|
|
pdvi->dwMinorVersion = MSI_MINORVERSION;
|
|
|
|
pdvi->dwBuildNumber = MSI_BUILDNUMBER;
|
2006-07-28 00:26:42 +02:00
|
|
|
pdvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
|
2006-07-24 12:47:00 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* DllCanUnloadNow [MSI.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
|
|
|
return dll_count == 0 ? S_OK : S_FALSE;
|
|
|
|
}
|
2010-12-17 14:59:49 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2011-06-30 12:16:02 +02:00
|
|
|
* DllRegisterServer (MSI.@)
|
2010-12-17 14:59:49 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
|
|
|
return __wine_register_resources( msi_hInstance, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2011-06-30 12:16:02 +02:00
|
|
|
* DllUnregisterServer (MSI.@)
|
2010-12-17 14:59:49 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
|
|
|
return __wine_unregister_resources( msi_hInstance, NULL );
|
|
|
|
}
|