2004-06-28 22:34:35 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2005-06-17 22:56:55 +02:00
|
|
|
* Copyright 2004,2005 Aric Stewart for CodeWeavers
|
2004-06-28 22:34:35 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-28 22:34:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
2006-10-20 00:49:54 +02:00
|
|
|
#include "winsvc.h"
|
2006-11-28 03:20:33 +01:00
|
|
|
#include "odbcinst.h"
|
2004-06-28 22:34:35 +02:00
|
|
|
#include "wine/debug.h"
|
2005-02-24 13:47:43 +01:00
|
|
|
#include "msidefs.h"
|
2004-06-28 22:34:35 +02:00
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlobj.h"
|
2008-04-30 11:22:46 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "mscoree.h"
|
|
|
|
#include "shlwapi.h"
|
2011-05-24 10:49:56 +02:00
|
|
|
#include "imagehlp.h"
|
2004-06-28 22:34:35 +02:00
|
|
|
#include "wine/unicode.h"
|
2005-04-11 18:10:33 +02:00
|
|
|
#include "winver.h"
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2005-01-03 21:00:13 +01:00
|
|
|
#define REG_PROGRESS_VALUE 13200
|
|
|
|
#define COMPONENT_PROGRESS_VALUE 24000
|
2004-06-28 22:34:35 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szCreateFolders[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'C','r','e','a','t','e','F','o','l','d','e','r','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szCostFinalize[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'C','o','s','t','F','i','n','a','l','i','z','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szWriteRegistryValues[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'W','r','i','t','e','R','e','g','i','s','t','r','y','V','a','l','u','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szFileCost[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'F','i','l','e','C','o','s','t',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallInitialize[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','I','n','i','t','i','a','l','i','z','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallValidate[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','V','a','l','i','d','a','t','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szLaunchConditions[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szProcessComponents[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','r','o','c','e','s','s','C','o','m','p','o','n','e','n','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRegisterTypeLibraries[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'R','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r','i','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szCreateShortcuts[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'C','r','e','a','t','e','S','h','o','r','t','c','u','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szPublishProduct[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','u','b','l','i','s','h','P','r','o','d','u','c','t',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szWriteIniValues[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'W','r','i','t','e','I','n','i','V','a','l','u','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szSelfRegModules[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','e','l','f','R','e','g','M','o','d','u','l','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szPublishFeatures[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRegisterProduct[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','g','i','s','t','e','r','P','r','o','d','u','c','t',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallExecute[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','E','x','e','c','u','t','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallExecuteAgain[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'I','n','s','t','a','l','l','E','x','e','c','u','t','e','A','g','a','i','n',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallFinalize[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','F','i','n','a','l','i','z','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szForceReboot[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'F','o','r','c','e','R','e','b','o','o','t',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szResolveSource[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','s','o','l','v','e','S','o','u','r','c','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szAllocateRegistrySpace[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'A','l','l','o','c','a','t','e','R','e','g','i','s','t','r','y','S','p','a','c','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szBindImage[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'B','i','n','d','I','m','a','g','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szDeleteServices[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'D','e','l','e','t','e','S','e','r','v','i','c','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szDisableRollback[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'D','i','s','a','b','l','e','R','o','l','l','b','a','c','k',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szExecuteAction[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'E','x','e','c','u','t','e','A','c','t','i','o','n',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallAdminPackage[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'I','n','s','t','a','l','l','A','d','m','i','n','P','a','c','k','a','g','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallSFPCatalogFile[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'I','n','s','t','a','l','l','S','F','P','C','a','t','a','l','o','g','F','i','l','e',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szIsolateComponents[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','s','o','l','a','t','e','C','o','m','p','o','n','e','n','t','s',0};
|
2009-10-15 12:46:27 +02:00
|
|
|
static const WCHAR szMigrateFeatureStates[] =
|
|
|
|
{'M','i','g','r','a','t','e','F','e','a','t','u','r','e','S','t','a','t','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szMsiUnpublishAssemblies[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'M','s','i','U','n','p','u','b','l','i','s','h','A','s','s','e','m','b','l','i','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallODBC[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','O','D','B','C',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szInstallServices[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'I','n','s','t','a','l','l','S','e','r','v','i','c','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szPublishComponents[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','u','b','l','i','s','h','C','o','m','p','o','n','e','n','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRegisterComPlus[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRegisterUser[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','g','i','s','t','e','r','U','s','e','r',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveEnvironmentStrings[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'R','e','m','o','v','e','E','n','v','i','r','o','n','m','e','n','t','S','t','r','i','n','g','s',0};
|
|
|
|
static const WCHAR szRemoveExistingProducts[] =
|
|
|
|
{'R','e','m','o','v','e','E','x','i','s','t','i','n','g','P','r','o','d','u','c','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveFolders[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','m','o','v','e','F','o','l','d','e','r','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveIniValues[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','m','o','v','e','I','n','i','V','a','l','u','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveODBC[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','m','o','v','e','O','D','B','C',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveRegistryValues[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'R','e','m','o','v','e','R','e','g','i','s','t','r','y','V','a','l','u','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRemoveShortcuts[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','e','m','o','v','e','S','h','o','r','t','c','u','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szRMCCPSearch[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'R','M','C','C','P','S','e','a','r','c','h',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szScheduleReboot[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','c','h','e','d','u','l','e','R','e','b','o','o','t',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szSelfUnregModules[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','e','l','f','U','n','r','e','g','M','o','d','u','l','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szSetODBCFolders[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','e','t','O','D','B','C','F','o','l','d','e','r','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szStartServices[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','t','a','r','t','S','e','r','v','i','c','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szStopServices[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','t','o','p','S','e','r','v','i','c','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szUnpublishComponents[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'U','n','p','u','b','l','i','s','h', 'C','o','m','p','o','n','e','n','t','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szUnpublishFeatures[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'U','n','p','u','b','l','i','s','h','F','e','a','t','u','r','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szUnregisterComPlus[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'U','n','r','e','g','i','s','t','e','r','C','o','m','P','l','u','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szUnregisterTypeLibraries[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'U','n','r','e','g','i','s','t','e','r','T','y','p','e','L','i','b','r','a','r','i','e','s',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szValidateProductID[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'V','a','l','i','d','a','t','e','P','r','o','d','u','c','t','I','D',0};
|
2005-10-30 20:04:26 +01:00
|
|
|
static const WCHAR szWriteEnvironmentStrings[] =
|
2009-10-15 12:46:27 +02:00
|
|
|
{'W','r','i','t','e','E','n','v','i','r','o','n','m','e','n','t','S','t','r','i','n','g','s',0};
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static void ui_actionstart(MSIPACKAGE *package, LPCWSTR action)
|
2004-07-06 20:48:15 +02:00
|
|
|
{
|
|
|
|
static const WCHAR Query_t[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
|
|
|
|
'W','H','E','R','E', ' ','`','A','c','t','i','o','n','`',' ','=',
|
|
|
|
' ','\'','%','s','\'',0};
|
2006-01-23 17:30:31 +01:00
|
|
|
MSIRECORD * row;
|
2004-07-06 20:48:15 +02:00
|
|
|
|
2005-06-02 12:29:57 +02:00
|
|
|
row = MSI_QueryGetRecord( package->db, Query_t, action );
|
|
|
|
if (!row)
|
2004-07-06 20:48:15 +02:00
|
|
|
return;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONSTART, row);
|
|
|
|
msiobj_release(&row->hdr);
|
2004-07-06 20:48:15 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static void ui_actioninfo(MSIPACKAGE *package, LPCWSTR action, BOOL start,
|
2004-07-06 20:48:15 +02:00
|
|
|
UINT rc)
|
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIRECORD * row;
|
2004-07-06 20:48:15 +02:00
|
|
|
static const WCHAR template_s[]=
|
2005-03-01 12:45:19 +01:00
|
|
|
{'A','c','t','i','o','n',' ','s','t','a','r','t',' ','%','s',':',' ',
|
|
|
|
'%','s', '.',0};
|
2004-07-06 20:48:15 +02:00
|
|
|
static const WCHAR template_e[]=
|
2005-03-01 12:45:19 +01:00
|
|
|
{'A','c','t','i','o','n',' ','e','n','d','e','d',' ','%','s',':',' ',
|
|
|
|
'%','s', '.',' ','R','e','t','u','r','n',' ','v','a','l','u','e',' ',
|
|
|
|
'%','i','.',0};
|
2004-07-06 20:48:15 +02:00
|
|
|
static const WCHAR format[] =
|
2005-03-01 12:45:19 +01:00
|
|
|
{'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
|
2004-07-06 20:48:15 +02:00
|
|
|
WCHAR message[1024];
|
|
|
|
WCHAR timet[0x100];
|
|
|
|
|
|
|
|
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
|
|
|
|
if (start)
|
|
|
|
sprintfW(message,template_s,timet,action);
|
|
|
|
else
|
|
|
|
sprintfW(message,template_e,timet,action,rc);
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
row = MSI_CreateRecord(1);
|
|
|
|
MSI_RecordSetStringW(row,1,message);
|
2004-07-06 20:48:15 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_INFO, row);
|
|
|
|
msiobj_release(&row->hdr);
|
2004-07-06 20:48:15 +02:00
|
|
|
}
|
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
enum parse_state
|
|
|
|
{
|
|
|
|
state_whitespace,
|
|
|
|
state_token,
|
|
|
|
state_quote
|
|
|
|
};
|
|
|
|
|
|
|
|
static int parse_prop( const WCHAR *str, WCHAR *value, int *quotes )
|
|
|
|
{
|
|
|
|
enum parse_state state = state_quote;
|
|
|
|
const WCHAR *p;
|
|
|
|
WCHAR *out = value;
|
|
|
|
int ignore, in_quotes = 0, count = 0, len = 0;
|
|
|
|
|
|
|
|
for (p = str; *p; p++)
|
|
|
|
{
|
|
|
|
ignore = 0;
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case state_whitespace:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case ' ':
|
|
|
|
if (!count) goto done;
|
|
|
|
in_quotes = 1;
|
|
|
|
ignore = 1;
|
2011-04-05 12:03:36 +02:00
|
|
|
len++;
|
2010-12-23 17:07:55 +01:00
|
|
|
break;
|
|
|
|
case '"':
|
|
|
|
state = state_quote;
|
|
|
|
if (in_quotes) count--;
|
|
|
|
else count++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = state_token;
|
|
|
|
if (!count) in_quotes = 0;
|
|
|
|
else in_quotes = 1;
|
|
|
|
len++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case state_token:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
state = state_quote;
|
|
|
|
if (in_quotes) count--;
|
|
|
|
else count++;
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
state = state_whitespace;
|
|
|
|
if (!count) goto done;
|
|
|
|
in_quotes = 1;
|
2011-04-05 12:03:36 +02:00
|
|
|
len++;
|
2010-12-23 17:07:55 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!count) in_quotes = 0;
|
|
|
|
else in_quotes = 1;
|
|
|
|
len++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case state_quote:
|
|
|
|
switch (*p)
|
|
|
|
{
|
|
|
|
case '"':
|
|
|
|
if (in_quotes) count--;
|
|
|
|
else count++;
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
state = state_whitespace;
|
2011-04-05 12:03:36 +02:00
|
|
|
if (!count || (count > 1 && !len)) goto done;
|
2010-12-23 17:07:55 +01:00
|
|
|
in_quotes = 1;
|
2011-04-05 12:03:36 +02:00
|
|
|
len++;
|
2010-12-23 17:07:55 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = state_token;
|
|
|
|
if (!count) in_quotes = 0;
|
|
|
|
else in_quotes = 1;
|
|
|
|
len++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
if (!ignore) *out++ = *p;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (!len) *value = 0;
|
|
|
|
else *out = 0;
|
|
|
|
|
|
|
|
*quotes = count;
|
|
|
|
return p - str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void remove_quotes( WCHAR *str )
|
|
|
|
{
|
|
|
|
WCHAR *p = str;
|
|
|
|
int len = strlenW( str );
|
|
|
|
|
|
|
|
while ((p = strchrW( p, '"' )))
|
|
|
|
{
|
|
|
|
memmove( p, p + 1, (len - (p - str)) * sizeof(WCHAR) );
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:03:07 +01:00
|
|
|
UINT msi_parse_command_line( MSIPACKAGE *package, LPCWSTR szCommandLine,
|
|
|
|
BOOL preserve_case )
|
2005-09-28 17:12:32 +02:00
|
|
|
{
|
2010-12-23 17:07:55 +01:00
|
|
|
LPCWSTR ptr, ptr2;
|
2011-03-30 12:31:19 +02:00
|
|
|
int num_quotes;
|
2005-09-28 17:12:32 +02:00
|
|
|
DWORD len;
|
2010-12-23 17:07:55 +01:00
|
|
|
WCHAR *prop, *val;
|
|
|
|
UINT r;
|
2005-09-28 17:12:32 +02:00
|
|
|
|
|
|
|
if (!szCommandLine)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
ptr = szCommandLine;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
2010-12-23 17:07:55 +01:00
|
|
|
while (*ptr == ' ') ptr++;
|
|
|
|
if (!*ptr) break;
|
2005-09-28 17:12:32 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
ptr2 = strchrW( ptr, '=' );
|
|
|
|
if (!ptr2) return ERROR_INVALID_COMMAND_LINE;
|
2005-09-28 17:12:32 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
len = ptr2 - ptr;
|
|
|
|
if (!len) return ERROR_INVALID_COMMAND_LINE;
|
2005-09-28 17:12:32 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
prop = msi_alloc( (len + 1) * sizeof(WCHAR) );
|
|
|
|
memcpy( prop, ptr, len * sizeof(WCHAR) );
|
|
|
|
prop[len] = 0;
|
|
|
|
if (!preserve_case) struprW( prop );
|
2008-10-30 10:03:07 +01:00
|
|
|
|
2005-09-28 17:12:32 +02:00
|
|
|
ptr2++;
|
2010-12-23 17:07:55 +01:00
|
|
|
while (*ptr2 == ' ') ptr2++;
|
|
|
|
|
2011-03-30 12:31:19 +02:00
|
|
|
num_quotes = 0;
|
2010-12-23 17:07:55 +01:00
|
|
|
val = msi_alloc( (strlenW( ptr2 ) + 1) * sizeof(WCHAR) );
|
2011-03-30 12:31:19 +02:00
|
|
|
len = parse_prop( ptr2, val, &num_quotes );
|
|
|
|
if (num_quotes % 2)
|
2005-09-28 17:12:32 +02:00
|
|
|
{
|
2010-12-23 17:07:55 +01:00
|
|
|
WARN("unbalanced quotes\n");
|
|
|
|
msi_free( val );
|
|
|
|
msi_free( prop );
|
|
|
|
return ERROR_INVALID_COMMAND_LINE;
|
2005-09-28 17:12:32 +02:00
|
|
|
}
|
2010-12-23 17:07:55 +01:00
|
|
|
remove_quotes( val );
|
|
|
|
TRACE("Found commandline property %s = %s\n", debugstr_w(prop), debugstr_w(val));
|
2005-09-28 17:12:32 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
r = msi_set_property( package->db, prop, val );
|
2011-05-02 16:04:25 +02:00
|
|
|
if (r == ERROR_SUCCESS && !strcmpW( prop, szSourceDir ))
|
2010-12-23 17:07:55 +01:00
|
|
|
msi_reset_folders( package, TRUE );
|
2010-04-21 11:38:17 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
msi_free( val );
|
|
|
|
msi_free( prop );
|
2010-04-21 11:38:17 +02:00
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
ptr = ptr2 + len;
|
2005-09-28 17:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-01-12 14:04:28 +01:00
|
|
|
WCHAR **msi_split_string( const WCHAR *str, WCHAR sep )
|
2005-10-26 14:06:21 +02:00
|
|
|
{
|
2006-09-17 09:52:49 +02:00
|
|
|
LPCWSTR pc;
|
2005-10-26 14:06:21 +02:00
|
|
|
LPWSTR p, *ret = NULL;
|
|
|
|
UINT count = 0;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* count the number of substrings */
|
2006-09-17 09:52:49 +02:00
|
|
|
for ( pc = str, count = 0; pc; count++ )
|
2005-10-26 14:06:21 +02:00
|
|
|
{
|
2006-09-17 09:52:49 +02:00
|
|
|
pc = strchrW( pc, sep );
|
|
|
|
if (pc)
|
|
|
|
pc++;
|
2005-10-26 14:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate space for an array of substring pointers and the substrings */
|
|
|
|
ret = msi_alloc( (count+1) * sizeof (LPWSTR) +
|
|
|
|
(lstrlenW(str)+1) * sizeof(WCHAR) );
|
|
|
|
if (!ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* copy the string and set the pointers */
|
|
|
|
p = (LPWSTR) &ret[count+1];
|
|
|
|
lstrcpyW( p, str );
|
|
|
|
for( count = 0; (ret[count] = p); count++ )
|
|
|
|
{
|
|
|
|
p = strchrW( p, sep );
|
|
|
|
if (p)
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-03-01 06:29:43 +01:00
|
|
|
static BOOL ui_sequence_exists( MSIPACKAGE *package )
|
2007-04-15 10:10:58 +02:00
|
|
|
{
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
static const WCHAR ExecSeqQuery [] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','I','n','s','t','a','l','l',
|
|
|
|
'U','I','S','e','q','u','e','n','c','e','`',
|
|
|
|
' ','W','H','E','R','E',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',' ',
|
|
|
|
'>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-07-23 09:42:37 +02:00
|
|
|
UINT msi_set_sourcedir_props(MSIPACKAGE *package, BOOL replace)
|
2008-01-05 21:45:13 +01:00
|
|
|
{
|
|
|
|
LPWSTR source, check;
|
2008-01-05 21:50:59 +01:00
|
|
|
|
2010-05-11 14:05:32 +02:00
|
|
|
if (msi_get_property_int( package->db, szInstalled, 0 ))
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
2008-01-05 21:46:39 +01:00
|
|
|
|
2010-05-11 14:05:32 +02:00
|
|
|
MSIREG_OpenInstallProps( package->ProductCode, package->Context, NULL, &hkey, FALSE );
|
|
|
|
source = msi_reg_get_val_str( hkey, INSTALLPROPERTY_INSTALLSOURCEW );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
else
|
2008-01-05 21:46:39 +01:00
|
|
|
{
|
2010-05-11 14:05:32 +02:00
|
|
|
LPWSTR p, db;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
db = msi_dup_property( package->db, szOriginalDatabase );
|
|
|
|
if (!db)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
p = strrchrW( db, '\\' );
|
2008-01-05 21:47:14 +01:00
|
|
|
if (!p)
|
|
|
|
{
|
2010-05-11 14:05:32 +02:00
|
|
|
p = strrchrW( db, '/' );
|
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
msi_free(db);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2008-01-05 21:47:14 +01:00
|
|
|
}
|
2008-01-05 21:45:13 +01:00
|
|
|
|
2010-05-11 14:05:32 +02:00
|
|
|
len = p - db + 2;
|
|
|
|
source = msi_alloc( len * sizeof(WCHAR) );
|
|
|
|
lstrcpynW( source, db, len );
|
|
|
|
msi_free( db );
|
|
|
|
}
|
2008-01-05 21:45:13 +01:00
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
check = msi_dup_property( package->db, szSourceDir );
|
2008-01-05 21:45:13 +01:00
|
|
|
if (!check || replace)
|
2010-04-21 11:38:17 +02:00
|
|
|
{
|
2011-05-02 16:04:25 +02:00
|
|
|
UINT r = msi_set_property( package->db, szSourceDir, source );
|
2010-04-21 11:38:17 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
msi_reset_folders( package, TRUE );
|
|
|
|
}
|
2008-01-05 21:45:13 +01:00
|
|
|
msi_free( check );
|
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
check = msi_dup_property( package->db, szSOURCEDIR );
|
2008-01-05 21:45:13 +01:00
|
|
|
if (!check || replace)
|
2011-05-02 16:04:25 +02:00
|
|
|
msi_set_property( package->db, szSOURCEDIR, source );
|
2008-01-05 21:45:13 +01:00
|
|
|
|
|
|
|
msi_free( check );
|
|
|
|
msi_free( source );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
static BOOL needs_ui_sequence(MSIPACKAGE *package)
|
|
|
|
{
|
2010-04-21 11:37:54 +02:00
|
|
|
INT level = msi_get_property_int(package->db, szUILevel, 0);
|
2009-10-15 12:48:26 +02:00
|
|
|
return (level & INSTALLUILEVEL_MASK) >= INSTALLUILEVEL_REDUCED;
|
|
|
|
}
|
|
|
|
|
2010-05-05 14:37:55 +02:00
|
|
|
UINT msi_set_context(MSIPACKAGE *package)
|
2008-06-18 07:50:28 +02:00
|
|
|
{
|
2010-04-29 09:39:08 +02:00
|
|
|
int num;
|
2008-06-18 07:50:28 +02:00
|
|
|
|
|
|
|
package->Context = MSIINSTALLCONTEXT_USERUNMANAGED;
|
|
|
|
|
2010-04-29 09:39:08 +02:00
|
|
|
num = msi_get_property_int(package->db, szAllUsers, 0);
|
|
|
|
if (num == 1 || num == 2)
|
|
|
|
package->Context = MSIINSTALLCONTEXT_MACHINE;
|
2008-06-18 07:50:28 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:33:10 +02:00
|
|
|
static UINT ITERATE_Actions(MSIRECORD *row, LPVOID param)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
LPCWSTR cond, action;
|
2009-10-15 12:48:26 +02:00
|
|
|
MSIPACKAGE *package = param;
|
2005-06-20 17:33:10 +02:00
|
|
|
|
|
|
|
action = MSI_RecordGetString(row,1);
|
|
|
|
if (!action)
|
|
|
|
{
|
|
|
|
ERR("Error is retrieving action name\n");
|
2006-10-27 10:29:02 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-06-20 17:33:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check conditions */
|
|
|
|
cond = MSI_RecordGetString(row,2);
|
2006-10-27 10:29:02 +02:00
|
|
|
|
|
|
|
/* this is a hack to skip errors in the condition code */
|
2009-10-15 12:48:26 +02:00
|
|
|
if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
|
2005-06-20 17:33:10 +02:00
|
|
|
{
|
2006-10-27 10:29:02 +02:00
|
|
|
TRACE("Skipping action: %s (condition is false)\n", debugstr_w(action));
|
|
|
|
return ERROR_SUCCESS;
|
2005-06-20 17:33:10 +02:00
|
|
|
}
|
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
if (needs_ui_sequence(package))
|
|
|
|
rc = ACTION_PerformUIAction(package, action, -1);
|
2005-06-20 17:33:10 +02:00
|
|
|
else
|
2010-07-23 09:42:21 +02:00
|
|
|
rc = ACTION_PerformAction(package, action, -1);
|
2005-06-20 17:33:10 +02:00
|
|
|
|
2005-07-06 17:44:51 +02:00
|
|
|
msi_dialog_check_messages( NULL );
|
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
if (package->CurrentInstallState != ERROR_SUCCESS)
|
|
|
|
rc = package->CurrentInstallState;
|
2005-07-06 17:44:51 +02:00
|
|
|
|
2005-06-20 17:33:10 +02:00
|
|
|
if (rc == ERROR_FUNCTION_NOT_CALLED)
|
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-10-27 14:39:28 +02:00
|
|
|
ERR("Execution halted, action %s returned %i\n", debugstr_w(action), rc);
|
2005-06-20 17:33:10 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-09-21 12:55:23 +02:00
|
|
|
UINT MSI_Sequence( MSIPACKAGE *package, LPCWSTR szTable, INT iSequenceMode )
|
|
|
|
{
|
|
|
|
MSIQUERY * view;
|
|
|
|
UINT r;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','%','s','`',
|
|
|
|
' ','W','H','E','R','E',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',' ',
|
|
|
|
'>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',0};
|
|
|
|
|
|
|
|
TRACE("%p %s %i\n", package, debugstr_w(szTable), iSequenceMode );
|
|
|
|
|
|
|
|
r = MSI_OpenQuery( package->db, &view, query, szTable );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
2009-10-15 12:48:26 +02:00
|
|
|
r = MSI_IterateRecords( view, NULL, ITERATE_Actions, package );
|
2005-09-21 12:55:23 +02:00
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_ProcessExecSequence(MSIPACKAGE *package, BOOL UIran)
|
2004-07-04 02:26:54 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY * view;
|
2004-07-04 02:26:54 +02:00
|
|
|
UINT rc;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
|
|
|
|
'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',' ', '>',' ','%','i',' ',
|
2005-03-01 12:45:19 +01:00
|
|
|
'O','R','D','E','R',' ', 'B','Y',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','S','e','q','u','e','n','c','e','`',0 };
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR IVQuery[] =
|
2005-05-20 11:40:42 +02:00
|
|
|
{'S','E','L','E','C','T',' ','`','S','e','q','u','e','n','c','e','`',
|
|
|
|
' ', 'F','R','O','M',' ','`','I','n','s','t','a','l','l',
|
|
|
|
'E','x','e','c','u','t','e','S','e','q','u','e','n','c','e','`',' ',
|
|
|
|
'W','H','E','R','E',' ','`','A','c','t','i','o','n','`',' ','=',
|
|
|
|
' ','\'', 'I','n','s','t','a','l','l',
|
|
|
|
'V','a','l','i','d','a','t','e','\'', 0};
|
2004-12-22 16:05:07 +01:00
|
|
|
INT seq = 0;
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2005-05-27 21:24:22 +02:00
|
|
|
if (package->script->ExecuteSequenceRun)
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
|
|
|
TRACE("Execute Sequence already Run\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-05-27 21:24:22 +02:00
|
|
|
package->script->ExecuteSequenceRun = TRUE;
|
2005-06-20 17:33:10 +02:00
|
|
|
|
2004-12-22 16:05:07 +01:00
|
|
|
/* get the sequence number */
|
2004-07-04 02:26:54 +02:00
|
|
|
if (UIran)
|
|
|
|
{
|
2009-10-15 12:48:26 +02:00
|
|
|
MSIRECORD *row = MSI_QueryGetRecord(package->db, IVQuery);
|
2005-06-02 12:29:57 +02:00
|
|
|
if( !row )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2004-07-10 00:25:34 +02:00
|
|
|
seq = MSI_RecordGetInteger(row,1);
|
|
|
|
msiobj_release(&row->hdr);
|
2004-07-04 02:26:54 +02:00
|
|
|
}
|
2004-12-22 16:05:07 +01:00
|
|
|
|
2005-01-21 17:19:11 +01:00
|
|
|
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, seq);
|
2004-06-28 22:34:35 +02:00
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
2005-06-20 17:33:10 +02:00
|
|
|
TRACE("Running the actions\n");
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
msi_set_property(package->db, szSourceDir, NULL);
|
2010-07-23 09:42:37 +02:00
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_ProcessUISequence(MSIPACKAGE *package)
|
2004-07-04 02:26:54 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY * view;
|
2004-07-04 02:26:54 +02:00
|
|
|
UINT rc;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR ExecSeqQuery [] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','I','n','s','t','a','l','l',
|
|
|
|
'U','I','S','e','q','u','e','n','c','e','`',
|
|
|
|
' ','W','H','E','R','E',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',' ',
|
2005-03-01 12:45:19 +01:00
|
|
|
'>',' ','0',' ','O','R','D','E','R',' ','B','Y',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','S','e','q','u','e','n','c','e','`',0};
|
2005-06-20 17:33:10 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
2004-07-04 02:26:54 +02:00
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("Running the actions\n");
|
2004-07-04 02:26:54 +02:00
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_Actions, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2004-07-04 02:26:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
/********************************************************
|
|
|
|
* ACTION helper functions and functions that perform the actions
|
|
|
|
*******************************************************/
|
2005-06-07 22:29:51 +02:00
|
|
|
static BOOL ACTION_HandleCustomAction( MSIPACKAGE* package, LPCWSTR action,
|
2007-06-25 21:47:38 +02:00
|
|
|
UINT* rc, UINT script, BOOL force )
|
2005-02-01 19:46:26 +01:00
|
|
|
{
|
|
|
|
BOOL ret=FALSE;
|
|
|
|
UINT arc;
|
|
|
|
|
2007-06-25 21:47:38 +02:00
|
|
|
arc = ACTION_CustomAction(package, action, script, force);
|
2005-02-01 19:46:26 +01:00
|
|
|
|
|
|
|
if (arc != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
|
|
|
*rc = arc;
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
MSICOMPONENT *msi_get_loaded_component( MSIPACKAGE *package, const WCHAR *Component )
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
|
|
|
|
{
|
|
|
|
if (!strcmpW( Component, comp->Component )) return comp;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSIFEATURE *msi_get_loaded_feature(MSIPACKAGE* package, const WCHAR *Feature )
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
|
|
|
if (!strcmpW( Feature, feature->Feature )) return feature;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSIFILE *msi_get_loaded_file( MSIPACKAGE *package, const WCHAR *key )
|
|
|
|
{
|
|
|
|
MSIFILE *file;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
|
|
|
{
|
|
|
|
if (!strcmpW( key, file->File )) return file;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSIFILEPATCH *msi_get_loaded_filepatch( MSIPACKAGE *package, const WCHAR *key )
|
|
|
|
{
|
|
|
|
MSIFILEPATCH *patch;
|
|
|
|
|
|
|
|
/* FIXME: There might be more than one patch */
|
|
|
|
LIST_FOR_EACH_ENTRY( patch, &package->filepatches, MSIFILEPATCH, entry )
|
|
|
|
{
|
|
|
|
if (!strcmpW( key, patch->File->File )) return patch;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSIFOLDER *msi_get_loaded_folder( MSIPACKAGE *package, const WCHAR *dir )
|
|
|
|
{
|
|
|
|
MSIFOLDER *folder;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
|
|
|
|
{
|
|
|
|
if (!strcmpW( dir, folder->Directory )) return folder;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:03:46 +02:00
|
|
|
/*
|
2011-05-06 14:39:17 +02:00
|
|
|
* Recursively create all directories in the path.
|
|
|
|
* shamelessly stolen from setupapi/queue.c
|
2005-06-21 22:03:46 +02:00
|
|
|
*/
|
2011-05-06 14:39:17 +02:00
|
|
|
BOOL msi_create_full_path( const WCHAR *path )
|
|
|
|
{
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
WCHAR *new_path;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
new_path = msi_alloc( (strlenW( path ) + 1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( new_path, path );
|
|
|
|
|
|
|
|
while ((len = strlenW( new_path )) && new_path[len - 1] == '\\')
|
|
|
|
new_path[len - 1] = 0;
|
|
|
|
|
|
|
|
while (!CreateDirectoryW( new_path, NULL ))
|
|
|
|
{
|
|
|
|
WCHAR *slash;
|
|
|
|
DWORD last_error = GetLastError();
|
|
|
|
if (last_error == ERROR_ALREADY_EXISTS) break;
|
|
|
|
if (last_error != ERROR_PATH_NOT_FOUND)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(slash = strrchrW( new_path, '\\' )))
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
len = slash - new_path;
|
|
|
|
new_path[len] = 0;
|
|
|
|
if (!msi_create_full_path( new_path ))
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
new_path[len] = '\\';
|
|
|
|
}
|
|
|
|
msi_free( new_path );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void msi_ui_progress( MSIPACKAGE *package, int a, int b, int c, int d )
|
|
|
|
{
|
|
|
|
MSIRECORD *row;
|
|
|
|
|
|
|
|
row = MSI_CreateRecord( 4 );
|
|
|
|
MSI_RecordSetInteger( row, 1, a );
|
|
|
|
MSI_RecordSetInteger( row, 2, b );
|
|
|
|
MSI_RecordSetInteger( row, 3, c );
|
|
|
|
MSI_RecordSetInteger( row, 4, d );
|
|
|
|
MSI_ProcessMessage( package, INSTALLMESSAGE_PROGRESS, row );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
|
|
|
|
msi_dialog_check_messages( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
void msi_ui_actiondata( MSIPACKAGE *package, const WCHAR *action, MSIRECORD *record )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','A','c','t','i','o', 'n','T','e','x','t','`',' ',
|
|
|
|
'W','H','E','R','E',' ', '`','A','c','t','i','o','n','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
WCHAR message[1024];
|
|
|
|
MSIRECORD *row = 0;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (!package->LastAction || strcmpW( package->LastAction, action ))
|
|
|
|
{
|
|
|
|
if (!(row = MSI_QueryGetRecord( package->db, query, action ))) return;
|
|
|
|
|
|
|
|
if (MSI_RecordIsNull( row, 3 ))
|
|
|
|
{
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* update the cached action format */
|
|
|
|
msi_free( package->ActionFormat );
|
|
|
|
package->ActionFormat = msi_dup_record_field( row, 3 );
|
|
|
|
msi_free( package->LastAction );
|
|
|
|
package->LastAction = strdupW( action );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
}
|
|
|
|
size = 1024;
|
|
|
|
MSI_RecordSetStringW( record, 0, package->ActionFormat );
|
|
|
|
MSI_FormatRecordW( package, record, message, &size );
|
|
|
|
row = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( row, 1, message );
|
|
|
|
MSI_ProcessMessage( package, INSTALLMESSAGE_ACTIONDATA, row );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
}
|
2005-06-21 22:03:46 +02:00
|
|
|
|
2011-05-24 10:50:28 +02:00
|
|
|
INSTALLSTATE msi_get_component_action( MSIPACKAGE *package, MSICOMPONENT *comp )
|
|
|
|
{
|
|
|
|
if (!comp->Enabled)
|
|
|
|
{
|
|
|
|
TRACE("component is disabled: %s\n", debugstr_w(comp->Component));
|
|
|
|
return INSTALLSTATE_UNKNOWN;
|
|
|
|
}
|
|
|
|
if (package->need_rollback) return comp->Installed;
|
|
|
|
return comp->ActionRequest;
|
|
|
|
}
|
|
|
|
|
2011-05-24 10:51:15 +02:00
|
|
|
INSTALLSTATE msi_get_feature_action( MSIPACKAGE *package, MSIFEATURE *feature )
|
|
|
|
{
|
|
|
|
if (package->need_rollback) return feature->Installed;
|
|
|
|
return feature->ActionRequest;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:03:46 +02:00
|
|
|
static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2011-05-02 16:03:32 +02:00
|
|
|
LPCWSTR dir, component, full_path;
|
2005-06-21 22:03:46 +02:00
|
|
|
MSIRECORD *uirow;
|
|
|
|
MSIFOLDER *folder;
|
2010-02-16 11:45:34 +01:00
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString(row, 2);
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!component)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-02-16 11:45:34 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:50:28 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-02-16 11:45:34 +01:00
|
|
|
{
|
2011-05-24 10:50:28 +02:00
|
|
|
TRACE("component not scheduled for installation: %s\n", debugstr_w(component));
|
2010-02-16 11:45:34 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-21 22:03:46 +02:00
|
|
|
|
|
|
|
dir = MSI_RecordGetString(row,1);
|
|
|
|
if (!dir)
|
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
ERR("Unable to get folder id\n");
|
2005-06-21 22:03:46 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:24:18 +01:00
|
|
|
uirow = MSI_CreateRecord(1);
|
|
|
|
MSI_RecordSetStringW(uirow, 1, dir);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata(package, szCreateFolders, uirow);
|
2010-03-05 12:24:18 +01:00
|
|
|
msiobj_release(&uirow->hdr);
|
|
|
|
|
2011-05-02 16:03:32 +02:00
|
|
|
full_path = msi_get_target_folder( package, dir );
|
2005-06-21 22:03:46 +02:00
|
|
|
if (!full_path)
|
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
ERR("Unable to retrieve folder %s\n", debugstr_w(dir));
|
2005-06-21 22:03:46 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2011-05-02 16:03:32 +02:00
|
|
|
TRACE("folder is %s\n", debugstr_w(full_path));
|
2005-06-21 22:03:46 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
folder = msi_get_loaded_folder( package, dir );
|
|
|
|
if (folder->State == 0) msi_create_full_path( full_path );
|
2005-06-21 22:03:46 +02:00
|
|
|
folder->State = 3;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_CreateFolders(MSIPACKAGE *package)
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2010-11-26 14:03:31 +01:00
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
|
2004-06-28 22:34:35 +02:00
|
|
|
UINT rc;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY *view;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-28 11:39:29 +02:00
|
|
|
/* create all the empty folders specified in the CreateFolder table */
|
2010-11-26 14:03:31 +01:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, query, &view );
|
2004-06-28 22:34:35 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2004-07-20 03:22:37 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2005-06-21 22:03:46 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2005-10-28 11:39:29 +02:00
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-05 14:47:55 +01:00
|
|
|
static UINT ITERATE_RemoveFolders( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
2011-05-02 16:03:32 +02:00
|
|
|
LPCWSTR dir, component, full_path;
|
2010-02-05 14:47:55 +01:00
|
|
|
MSIRECORD *uirow;
|
|
|
|
MSIFOLDER *folder;
|
2010-02-16 11:45:34 +01:00
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString(row, 2);
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!component)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-02-16 11:45:34 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:50:28 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-02-16 11:45:34 +01:00
|
|
|
{
|
2011-05-24 10:50:28 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-02-16 11:45:34 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-02-05 14:47:55 +01:00
|
|
|
|
|
|
|
dir = MSI_RecordGetString( row, 1 );
|
|
|
|
if (!dir)
|
|
|
|
{
|
|
|
|
ERR("Unable to get folder id\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:32 +02:00
|
|
|
full_path = msi_get_target_folder( package, dir );
|
2010-02-05 14:47:55 +01:00
|
|
|
if (!full_path)
|
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
ERR("Unable to resolve folder %s\n", debugstr_w(dir));
|
2010-02-05 14:47:55 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
TRACE("folder is %s\n", debugstr_w(full_path));
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 1 );
|
2010-06-09 12:09:21 +02:00
|
|
|
MSI_RecordSetStringW( uirow, 1, dir );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveFolders, uirow );
|
2010-02-05 14:47:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
RemoveDirectoryW( full_path );
|
2011-05-06 14:39:17 +02:00
|
|
|
folder = msi_get_loaded_folder( package, dir );
|
2010-02-05 14:47:55 +01:00
|
|
|
folder->State = 0;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveFolders( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] =
|
2010-11-26 14:03:31 +01:00
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','C','r','e','a','t','e','F','o','l','d','e','r','`',0};
|
2010-02-05 14:47:55 +01:00
|
|
|
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveFolders, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
static UINT load_component( MSIRECORD *row, LPVOID param )
|
2004-07-04 02:32:48 +02:00
|
|
|
{
|
2006-07-25 14:49:44 +02:00
|
|
|
MSIPACKAGE *package = param;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
comp = msi_alloc_zero( sizeof(MSICOMPONENT) );
|
2005-08-22 11:15:23 +02:00
|
|
|
if (!comp)
|
2006-07-25 14:49:44 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
list_add_tail( &package->components, &comp->entry );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
/* fill in the data */
|
2005-10-27 14:36:12 +02:00
|
|
|
comp->Component = msi_dup_record_field( row, 1 );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-09-12 14:07:15 +02:00
|
|
|
TRACE("Loading Component %s\n", debugstr_w(comp->Component));
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
comp->ComponentId = msi_dup_record_field( row, 2 );
|
|
|
|
comp->Directory = msi_dup_record_field( row, 3 );
|
2005-08-22 11:15:23 +02:00
|
|
|
comp->Attributes = MSI_RecordGetInteger(row,4);
|
2005-10-27 14:36:12 +02:00
|
|
|
comp->Condition = msi_dup_record_field( row, 5 );
|
|
|
|
comp->KeyPath = msi_dup_record_field( row, 6 );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2006-09-21 04:55:01 +02:00
|
|
|
comp->Installed = INSTALLSTATE_UNKNOWN;
|
2010-11-30 15:18:00 +01:00
|
|
|
comp->Action = INSTALLSTATE_UNKNOWN;
|
|
|
|
comp->ActionRequest = INSTALLSTATE_UNKNOWN;
|
2004-12-27 20:06:22 +01:00
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
comp->assembly = msi_load_assembly( package, comp );
|
2006-07-25 14:49:44 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT load_all_components( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
|
|
|
|
'`','C','o','m','p','o','n','e','n','t','`',0 };
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!list_empty(&package->components))
|
|
|
|
return ERROR_SUCCESS;
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
if (!msi_init_assembly_caches( package ))
|
|
|
|
{
|
|
|
|
ERR("can't initialize assembly caches\n");
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
r = MSI_IterateRecords(view, NULL, load_component, package);
|
|
|
|
msiobj_release(&view->hdr);
|
2011-05-06 14:39:58 +02:00
|
|
|
|
|
|
|
msi_destroy_assembly_caches( package );
|
2006-07-25 14:49:44 +02:00
|
|
|
return r;
|
2004-07-04 02:32:48 +02:00
|
|
|
}
|
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
typedef struct {
|
|
|
|
MSIPACKAGE *package;
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-06-23 18:43:24 +02:00
|
|
|
} _ilfs;
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
static UINT add_feature_component( MSIFEATURE *feature, MSICOMPONENT *comp )
|
2005-08-19 12:03:11 +02:00
|
|
|
{
|
|
|
|
ComponentList *cl;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
cl = msi_alloc( sizeof (*cl) );
|
2005-08-19 12:03:11 +02:00
|
|
|
if ( !cl )
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2005-08-22 11:15:23 +02:00
|
|
|
cl->component = comp;
|
2005-08-22 16:09:17 +02:00
|
|
|
list_add_tail( &feature->Components, &cl->entry );
|
2005-08-19 12:03:11 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
static UINT add_feature_child( MSIFEATURE *parent, MSIFEATURE *child )
|
|
|
|
{
|
|
|
|
FeatureList *fl;
|
|
|
|
|
|
|
|
fl = msi_alloc( sizeof(*fl) );
|
|
|
|
if ( !fl )
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
fl->feature = child;
|
|
|
|
list_add_tail( &parent->Children, &fl->entry );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
static UINT iterate_load_featurecomponents(MSIRECORD *row, LPVOID param)
|
2004-07-04 02:32:48 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
_ilfs* ilfs = param;
|
2005-06-23 18:43:24 +02:00
|
|
|
LPCWSTR component;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2005-06-23 18:43:24 +02:00
|
|
|
|
|
|
|
component = MSI_RecordGetString(row,1);
|
|
|
|
|
|
|
|
/* check to see if the component is already loaded */
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( ilfs->package, component );
|
2006-07-25 14:49:44 +02:00
|
|
|
if (!comp)
|
2005-06-23 18:43:24 +02:00
|
|
|
{
|
2006-07-25 14:49:44 +02:00
|
|
|
ERR("unknown component %s\n", debugstr_w(component));
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-06-23 18:43:24 +02:00
|
|
|
}
|
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
add_feature_component( ilfs->feature, comp );
|
|
|
|
comp->Enabled = TRUE;
|
2005-06-23 18:43:24 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
static MSIFEATURE *find_feature_by_name( MSIPACKAGE *package, LPCWSTR name )
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
|
2008-04-30 11:22:46 +02:00
|
|
|
if ( !name )
|
|
|
|
return NULL;
|
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
2010-10-19 11:27:44 +02:00
|
|
|
if ( !strcmpW( feature->Feature, name ) )
|
2006-09-21 04:59:19 +02:00
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
static UINT load_feature(MSIRECORD * row, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE* feature;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR Query1[] =
|
2005-05-20 11:40:42 +02:00
|
|
|
{'S','E','L','E','C','T',' ',
|
|
|
|
'`','C','o','m','p','o','n','e','n','t','_','`',
|
|
|
|
' ','F','R','O','M',' ','`','F','e','a','t','u','r','e',
|
|
|
|
'C','o','m','p','o','n','e','n','t','s','`',' ',
|
|
|
|
'W','H','E','R','E',' ',
|
|
|
|
'`','F','e', 'a','t','u','r','e','_','`',' ','=','\'','%','s','\'',0};
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY * view;
|
|
|
|
UINT rc;
|
2005-06-23 18:43:24 +02:00
|
|
|
_ilfs ilfs;
|
|
|
|
|
2004-07-04 02:32:48 +02:00
|
|
|
/* fill in the data */
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
feature = msi_alloc_zero( sizeof (MSIFEATURE) );
|
2005-08-22 16:09:17 +02:00
|
|
|
if (!feature)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2005-08-19 12:03:11 +02:00
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
list_init( &feature->Children );
|
2005-08-22 16:09:17 +02:00
|
|
|
list_init( &feature->Components );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
feature->Feature = msi_dup_record_field( row, 1 );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
TRACE("Loading feature %s\n",debugstr_w(feature->Feature));
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
feature->Feature_Parent = msi_dup_record_field( row, 2 );
|
|
|
|
feature->Title = msi_dup_record_field( row, 3 );
|
|
|
|
feature->Description = msi_dup_record_field( row, 4 );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
if (!MSI_RecordIsNull(row,5))
|
2005-08-22 16:09:17 +02:00
|
|
|
feature->Display = MSI_RecordGetInteger(row,5);
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
feature->Level= MSI_RecordGetInteger(row,6);
|
2005-10-27 14:36:12 +02:00
|
|
|
feature->Directory = msi_dup_record_field( row, 7 );
|
2005-08-22 16:09:17 +02:00
|
|
|
feature->Attributes = MSI_RecordGetInteger(row,8);
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2006-09-21 04:53:56 +02:00
|
|
|
feature->Installed = INSTALLSTATE_UNKNOWN;
|
2011-02-10 15:56:15 +01:00
|
|
|
feature->Action = INSTALLSTATE_UNKNOWN;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_UNKNOWN;
|
2004-12-27 20:06:22 +01:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
list_add_tail( &package->features, &feature->entry );
|
2004-07-04 02:32:48 +02:00
|
|
|
|
|
|
|
/* load feature components */
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
rc = MSI_OpenQuery( package->db, &view, Query1, feature->Feature );
|
2004-07-10 00:25:34 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-06-23 18:43:24 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
ilfs.package = package;
|
|
|
|
ilfs.feature = feature;
|
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
MSI_IterateRecords(view, NULL, iterate_load_featurecomponents , &ilfs);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2005-06-23 18:43:24 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2004-07-04 02:32:48 +02:00
|
|
|
}
|
|
|
|
|
2006-09-21 04:59:19 +02:00
|
|
|
static UINT find_feature_children(MSIRECORD * row, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2006-09-21 04:59:19 +02:00
|
|
|
MSIFEATURE *parent, *child;
|
|
|
|
|
|
|
|
child = find_feature_by_name( package, MSI_RecordGetString( row, 1 ) );
|
|
|
|
if (!child)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if (!child->Feature_Parent)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
parent = find_feature_by_name( package, child->Feature_Parent );
|
|
|
|
if (!parent)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
add_feature_child( parent, child );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
static UINT load_all_features( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
|
|
|
'`','F','e','a','t','u','r','e','`',' ','O','R','D','E','R',
|
|
|
|
' ','B','Y',' ','`','D','i','s','p','l','a','y','`',0};
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!list_empty(&package->features))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, NULL, load_feature, package );
|
2006-09-21 04:59:19 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MSI_IterateRecords( view, NULL, find_feature_children, package );
|
2006-07-25 14:49:44 +02:00
|
|
|
msiobj_release( &view->hdr );
|
2006-09-21 04:59:19 +02:00
|
|
|
|
2006-07-25 14:49:44 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-03-21 11:40:36 +01:00
|
|
|
static LPWSTR folder_split_path(LPWSTR p, WCHAR ch)
|
|
|
|
{
|
|
|
|
if (!p)
|
|
|
|
return p;
|
|
|
|
p = strchrW(p, ch);
|
|
|
|
if (!p)
|
|
|
|
return p;
|
|
|
|
*p = 0;
|
|
|
|
return p+1;
|
|
|
|
}
|
|
|
|
|
2007-11-26 01:01:19 +01:00
|
|
|
static UINT load_file_hash(MSIPACKAGE *package, MSIFILE *file)
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
|
|
|
'`','M','s','i','F','i','l','e','H','a','s','h','`',' ',
|
|
|
|
'W','H','E','R','E',' ','`','F','i','l','e','_','`',' ','=',' ','\'','%','s','\'',0};
|
|
|
|
MSIQUERY *view = NULL;
|
2007-12-14 22:18:05 +01:00
|
|
|
MSIRECORD *row = NULL;
|
2007-11-26 01:01:19 +01:00
|
|
|
UINT r;
|
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(file->File));
|
|
|
|
|
|
|
|
r = MSI_OpenQuery(package->db, &view, query, file->File);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MSI_ViewExecute(view, NULL);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MSI_ViewFetch(view, &row);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
file->hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
|
|
|
|
file->hash.dwData[0] = MSI_RecordGetInteger(row, 3);
|
|
|
|
file->hash.dwData[1] = MSI_RecordGetInteger(row, 4);
|
|
|
|
file->hash.dwData[2] = MSI_RecordGetInteger(row, 5);
|
|
|
|
file->hash.dwData[3] = MSI_RecordGetInteger(row, 6);
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (view) msiobj_release(&view->hdr);
|
2007-12-14 22:18:05 +01:00
|
|
|
if (row) msiobj_release(&row->hdr);
|
2007-11-26 01:01:19 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-05-12 14:18:15 +02:00
|
|
|
static UINT load_file_disk_id( MSIPACKAGE *package, MSIFILE *file )
|
|
|
|
{
|
|
|
|
MSIRECORD *row;
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','`','D','i','s','k','I','d','`',' ', 'F','R','O','M',' ',
|
|
|
|
'`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',' ','%','i',0};
|
|
|
|
|
|
|
|
row = MSI_QueryGetRecord( package->db, query, file->Sequence );
|
|
|
|
if (!row)
|
|
|
|
{
|
|
|
|
WARN("query failed\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
file->disk_id = MSI_RecordGetInteger( row, 1 );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
static UINT load_file(MSIRECORD *row, LPVOID param)
|
2004-07-04 02:35:52 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2005-06-09 22:30:59 +02:00
|
|
|
LPCWSTR component;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
|
|
|
/* fill in the data */
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
file = msi_alloc_zero( sizeof (MSIFILE) );
|
2005-08-23 12:03:17 +02:00
|
|
|
if (!file)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
2004-12-22 16:05:07 +01:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
file->File = msi_dup_record_field( row, 1 );
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
component = MSI_RecordGetString( row, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
file->Component = msi_get_loaded_component( package, component );
|
2005-06-09 22:30:59 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
if (!file->Component)
|
2008-08-19 06:00:20 +02:00
|
|
|
{
|
|
|
|
WARN("Component not found: %s\n", debugstr_w(component));
|
|
|
|
msi_free(file->File);
|
|
|
|
msi_free(file);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
file->FileName = msi_dup_record_field( row, 3 );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_reduce_to_long_filename( file->FileName );
|
2005-05-18 15:23:52 +02:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
file->ShortName = msi_dup_record_field( row, 3 );
|
2006-03-21 11:40:36 +01:00
|
|
|
file->LongName = strdupW( folder_split_path(file->ShortName, '|'));
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
file->FileSize = MSI_RecordGetInteger( row, 4 );
|
2005-10-27 14:36:12 +02:00
|
|
|
file->Version = msi_dup_record_field( row, 5 );
|
|
|
|
file->Language = msi_dup_record_field( row, 6 );
|
2005-08-23 12:03:17 +02:00
|
|
|
file->Attributes = MSI_RecordGetInteger( row, 7 );
|
|
|
|
file->Sequence = MSI_RecordGetInteger( row, 8 );
|
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
file->state = msifs_invalid;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2006-08-07 20:37:49 +02:00
|
|
|
/* if the compressed bits are not set in the file attributes,
|
|
|
|
* then read the information from the package word count property
|
|
|
|
*/
|
2008-10-17 05:55:21 +02:00
|
|
|
if (package->WordCount & msidbSumInfoSourceTypeAdminImage)
|
|
|
|
{
|
|
|
|
file->IsCompressed = FALSE;
|
|
|
|
}
|
|
|
|
else if (file->Attributes &
|
|
|
|
(msidbFileAttributesCompressed | msidbFileAttributesPatchAdded))
|
2006-08-07 20:37:49 +02:00
|
|
|
{
|
|
|
|
file->IsCompressed = TRUE;
|
|
|
|
}
|
|
|
|
else if (file->Attributes & msidbFileAttributesNoncompressed)
|
|
|
|
{
|
|
|
|
file->IsCompressed = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-22 07:54:27 +02:00
|
|
|
file->IsCompressed = package->WordCount & msidbSumInfoSourceTypeCompressed;
|
2006-08-07 20:37:49 +02:00
|
|
|
}
|
|
|
|
|
2007-11-26 01:01:19 +01:00
|
|
|
load_file_hash(package, file);
|
2010-05-12 14:18:15 +02:00
|
|
|
load_file_disk_id(package, file);
|
2007-11-26 01:01:19 +01:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
TRACE("File Loaded (%s)\n",debugstr_w(file->File));
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
list_add_tail( &package->files, &file->entry );
|
2004-07-04 02:35:52 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-05-18 19:46:12 +02:00
|
|
|
static UINT load_all_files(MSIPACKAGE *package)
|
2004-07-04 02:35:52 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY * view;
|
2004-07-04 02:35:52 +02:00
|
|
|
UINT rc;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','F','i','l','e','`',' ', 'O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`', 0};
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2006-07-19 10:01:07 +02:00
|
|
|
if (!list_empty(&package->files))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
2004-07-04 02:35:52 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2004-07-20 03:22:37 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2005-06-23 18:43:24 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, load_file, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2004-07-04 02:32:48 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-04-14 14:42:48 +02:00
|
|
|
static UINT load_media( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
UINT disk_id = MSI_RecordGetInteger( row, 1 );
|
|
|
|
const WCHAR *cabinet = MSI_RecordGetString( row, 4 );
|
|
|
|
|
|
|
|
/* FIXME: load external cabinets and directory sources too */
|
|
|
|
if (!cabinet || cabinet[0] != '#') return ERROR_SUCCESS;
|
|
|
|
msi_add_cabinet_stream( package, disk_id, package->db->storage, cabinet );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT load_all_media( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','M','e','d','i','a','`',' ',
|
|
|
|
'O','R','D','E','R',' ','B','Y',' ','`','D','i','s','k','I','d','`',0};
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r != ERROR_SUCCESS) return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
MSI_IterateRecords( view, NULL, load_media, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-03-22 20:45:11 +01:00
|
|
|
static UINT load_patch(MSIRECORD *row, LPVOID param)
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
MSIFILEPATCH *patch;
|
|
|
|
LPWSTR file_key;
|
|
|
|
|
|
|
|
patch = msi_alloc_zero( sizeof (MSIFILEPATCH) );
|
|
|
|
if (!patch)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
file_key = msi_dup_record_field( row, 1 );
|
2011-05-06 14:39:17 +02:00
|
|
|
patch->File = msi_get_loaded_file( package, file_key );
|
2011-03-22 20:45:11 +01:00
|
|
|
msi_free(file_key);
|
|
|
|
|
|
|
|
if( !patch->File )
|
|
|
|
{
|
|
|
|
ERR("Failed to find target for patch in File table\n");
|
|
|
|
msi_free(patch);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
patch->Sequence = MSI_RecordGetInteger( row, 2 );
|
|
|
|
|
|
|
|
/* FIXME: The database should be properly transformed */
|
|
|
|
patch->Sequence += MSI_INITIAL_MEDIA_TRANSFORM_OFFSET;
|
|
|
|
|
|
|
|
patch->PatchSize = MSI_RecordGetInteger( row, 3 );
|
|
|
|
patch->Attributes = MSI_RecordGetInteger( row, 4 );
|
|
|
|
patch->IsApplied = FALSE;
|
|
|
|
|
|
|
|
/* FIXME:
|
|
|
|
* Header field - for patch validation.
|
|
|
|
* _StreamRef - External key into MsiPatchHeaders (instead of the header field)
|
|
|
|
*/
|
|
|
|
|
|
|
|
TRACE("Patch Loaded (%s)\n", debugstr_w(patch->File->File));
|
|
|
|
|
|
|
|
list_add_tail( &package->filepatches, &patch->entry );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT load_all_patches(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT rc;
|
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','P','a','t','c','h','`',' ','O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',0};
|
|
|
|
|
|
|
|
if (!list_empty(&package->filepatches))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, load_patch, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-11-22 07:13:12 +01:00
|
|
|
static UINT load_folder( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
static WCHAR szEmpty[] = { 0 };
|
|
|
|
LPWSTR p, tgt_short, tgt_long, src_short, src_long;
|
|
|
|
MSIFOLDER *folder;
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
if (!(folder = msi_alloc_zero( sizeof(*folder) ))) return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
list_init( &folder->children );
|
2006-11-22 07:13:12 +01:00
|
|
|
folder->Directory = msi_dup_record_field( row, 1 );
|
2011-05-02 16:03:55 +02:00
|
|
|
folder->Parent = msi_dup_record_field( row, 2 );
|
|
|
|
p = msi_dup_record_field(row, 3);
|
2006-11-22 07:13:12 +01:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_w(folder->Directory));
|
|
|
|
|
|
|
|
/* split src and target dir */
|
|
|
|
tgt_short = p;
|
|
|
|
src_short = folder_split_path( p, ':' );
|
|
|
|
|
|
|
|
/* split the long and short paths */
|
|
|
|
tgt_long = folder_split_path( tgt_short, '|' );
|
|
|
|
src_long = folder_split_path( src_short, '|' );
|
|
|
|
|
|
|
|
/* check for no-op dirs */
|
2010-10-19 11:27:44 +02:00
|
|
|
if (tgt_short && !strcmpW( szDot, tgt_short ))
|
2006-11-22 07:13:12 +01:00
|
|
|
tgt_short = szEmpty;
|
2010-10-19 11:27:44 +02:00
|
|
|
if (src_short && !strcmpW( szDot, src_short ))
|
2006-11-22 07:13:12 +01:00
|
|
|
src_short = szEmpty;
|
|
|
|
|
|
|
|
if (!tgt_long)
|
|
|
|
tgt_long = tgt_short;
|
|
|
|
|
|
|
|
if (!src_short) {
|
|
|
|
src_short = tgt_short;
|
|
|
|
src_long = tgt_long;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!src_long)
|
|
|
|
src_long = src_short;
|
|
|
|
|
|
|
|
/* FIXME: use the target short path too */
|
|
|
|
folder->TargetDefault = strdupW(tgt_long);
|
|
|
|
folder->SourceShortPath = strdupW(src_short);
|
|
|
|
folder->SourceLongPath = strdupW(src_long);
|
|
|
|
msi_free(p);
|
|
|
|
|
|
|
|
TRACE("TargetDefault = %s\n",debugstr_w( folder->TargetDefault ));
|
|
|
|
TRACE("SourceLong = %s\n", debugstr_w( folder->SourceLongPath ));
|
|
|
|
TRACE("SourceShort = %s\n", debugstr_w( folder->SourceShortPath ));
|
|
|
|
|
|
|
|
list_add_tail( &package->folders, &folder->entry );
|
2011-05-02 16:03:55 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-11-22 07:13:12 +01:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
static UINT add_folder_child( MSIFOLDER *parent, MSIFOLDER *child )
|
|
|
|
{
|
|
|
|
FolderList *fl;
|
2006-11-22 07:13:12 +01:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
if (!(fl = msi_alloc( sizeof(*fl) ))) return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
fl->folder = child;
|
|
|
|
list_add_tail( &parent->children, &fl->entry );
|
2006-11-22 07:13:12 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
static UINT find_folder_children( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
MSIFOLDER *parent, *child;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!(child = msi_get_loaded_folder( package, MSI_RecordGetString( row, 1 ) )))
|
2011-05-02 16:03:55 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if (!child->Parent) return ERROR_SUCCESS;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!(parent = msi_get_loaded_folder( package, child->Parent )))
|
2011-05-02 16:03:55 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
return add_folder_child( parent, child );
|
|
|
|
}
|
|
|
|
|
2006-11-22 07:13:12 +01:00
|
|
|
static UINT load_all_folders( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R', 'O','M',' ',
|
|
|
|
'`','D','i','r','e','c','t','o','r','y','`',0 };
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!list_empty(&package->folders))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
r = MSI_IterateRecords( view, NULL, load_folder, package );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
r = MSI_IterateRecords( view, NULL, find_folder_children, package );
|
|
|
|
msiobj_release( &view->hdr );
|
2006-11-22 07:13:12 +01:00
|
|
|
return r;
|
|
|
|
}
|
2005-05-18 19:46:12 +02:00
|
|
|
|
|
|
|
static UINT ACTION_CostInitialize(MSIPACKAGE *package)
|
|
|
|
{
|
2011-04-01 14:54:12 +02:00
|
|
|
msi_set_property( package->db, szCostingComplete, szZero );
|
2011-05-02 16:04:25 +02:00
|
|
|
msi_set_property( package->db, szRootDrive, szCRoot );
|
2005-05-18 19:46:12 +02:00
|
|
|
|
2008-06-11 00:33:29 +02:00
|
|
|
load_all_folders( package );
|
2006-07-25 14:49:44 +02:00
|
|
|
load_all_components( package );
|
|
|
|
load_all_features( package );
|
|
|
|
load_all_files( package );
|
2011-03-22 20:45:11 +01:00
|
|
|
load_all_patches( package );
|
2011-04-14 14:42:48 +02:00
|
|
|
load_all_media( package );
|
2005-05-18 19:46:12 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-20 12:34:00 +02:00
|
|
|
static UINT execute_script_action( MSIPACKAGE *package, UINT script, UINT index )
|
2005-05-27 21:24:22 +02:00
|
|
|
{
|
2011-05-20 12:34:00 +02:00
|
|
|
const WCHAR *action = package->script->Actions[script][index];
|
|
|
|
ui_actionstart( package, action );
|
|
|
|
TRACE("executing %s\n", debugstr_w(action));
|
|
|
|
return ACTION_PerformAction( package, action, script );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT execute_script( MSIPACKAGE *package, UINT script )
|
|
|
|
{
|
|
|
|
UINT i, rc = ERROR_SUCCESS;
|
2005-05-27 21:24:22 +02:00
|
|
|
|
2011-05-20 12:34:00 +02:00
|
|
|
TRACE("executing script %u\n", script);
|
2005-05-27 21:24:22 +02:00
|
|
|
|
2006-01-10 12:09:19 +01:00
|
|
|
if (!package->script)
|
|
|
|
{
|
|
|
|
ERR("no script!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2011-05-20 12:34:00 +02:00
|
|
|
if (script == ROLLBACK_SCRIPT)
|
2005-05-27 21:24:22 +02:00
|
|
|
{
|
2011-05-20 12:34:00 +02:00
|
|
|
for (i = package->script->ActionCount[script]; i > 0; i--)
|
|
|
|
{
|
|
|
|
rc = execute_script_action( package, script, i - 1 );
|
|
|
|
if (rc != ERROR_SUCCESS) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < package->script->ActionCount[script]; i++)
|
|
|
|
{
|
|
|
|
rc = execute_script_action( package, script, i );
|
|
|
|
if (rc != ERROR_SUCCESS) break;
|
|
|
|
}
|
2005-05-27 21:24:22 +02:00
|
|
|
}
|
2006-11-02 10:12:43 +01:00
|
|
|
msi_free_action_script(package, script);
|
2005-05-27 21:24:22 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-05-18 19:46:12 +02:00
|
|
|
static UINT ACTION_FileCost(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-10-30 08:35:09 +01:00
|
|
|
static void ACTION_GetComponentInstallStates(MSIPACKAGE *package)
|
2005-02-22 16:47:00 +01:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2008-08-19 06:14:19 +02:00
|
|
|
UINT r;
|
2005-02-22 16:47:00 +01:00
|
|
|
|
2008-08-19 06:14:19 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(comp, &package->components, MSICOMPONENT, entry)
|
|
|
|
{
|
2011-01-19 12:05:31 +01:00
|
|
|
if (!comp->ComponentId) continue;
|
2006-09-21 04:57:03 +02:00
|
|
|
|
2011-02-10 15:56:15 +01:00
|
|
|
r = MsiQueryComponentStateW( package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED, comp->ComponentId,
|
|
|
|
&comp->Installed );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2011-01-20 09:06:19 +01:00
|
|
|
r = MsiQueryComponentStateW( package->ProductCode, NULL,
|
2011-02-10 15:56:15 +01:00
|
|
|
MSIINSTALLCONTEXT_USERUNMANAGED, comp->ComponentId,
|
2011-01-20 09:06:19 +01:00
|
|
|
&comp->Installed );
|
2011-02-10 15:56:15 +01:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
r = MsiQueryComponentStateW( package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_MACHINE, comp->ComponentId,
|
|
|
|
&comp->Installed );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
comp->Installed = INSTALLSTATE_ABSENT;
|
2005-02-22 16:47:00 +01:00
|
|
|
}
|
2006-10-30 08:35:09 +01:00
|
|
|
}
|
|
|
|
|
2008-08-19 06:14:53 +02:00
|
|
|
static void ACTION_GetFeatureInstallStates(MSIPACKAGE *package)
|
2006-10-30 08:35:09 +01:00
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
2005-02-22 16:47:00 +01:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-02-22 16:47:00 +01:00
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
INSTALLSTATE state = MsiQueryFeatureStateW( package->ProductCode, feature->Feature );
|
|
|
|
|
|
|
|
if (state == INSTALLSTATE_UNKNOWN || state == INSTALLSTATE_INVALIDARG)
|
2008-08-19 06:14:53 +02:00
|
|
|
feature->Installed = INSTALLSTATE_ABSENT;
|
|
|
|
else
|
2011-02-10 15:56:15 +01:00
|
|
|
feature->Installed = state;
|
2005-02-22 16:47:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-24 15:31:43 +01:00
|
|
|
static inline BOOL is_feature_selected( MSIFEATURE *feature, INT level )
|
|
|
|
{
|
|
|
|
return (feature->Level > 0 && feature->Level <= level);
|
|
|
|
}
|
|
|
|
|
2008-08-25 07:06:43 +02:00
|
|
|
static BOOL process_state_property(MSIPACKAGE* package, int level,
|
|
|
|
LPCWSTR property, INSTALLSTATE state)
|
2004-12-27 20:02:59 +01:00
|
|
|
{
|
2005-09-08 13:03:35 +02:00
|
|
|
LPWSTR override;
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2004-12-27 20:02:59 +01:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
override = msi_dup_property( package->db, property );
|
2005-09-08 13:03:35 +02:00
|
|
|
if (!override)
|
|
|
|
return FALSE;
|
2006-10-26 07:09:29 +02:00
|
|
|
|
2005-09-08 13:03:35 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2004-12-27 20:02:59 +01:00
|
|
|
{
|
2010-12-24 15:31:43 +01:00
|
|
|
if (strcmpW( property, szRemove ) && !is_feature_selected( feature, level ))
|
2008-08-25 07:06:43 +02:00
|
|
|
continue;
|
|
|
|
|
2009-10-15 12:46:27 +02:00
|
|
|
if (!strcmpW(property, szReinstall)) state = feature->Installed;
|
2009-03-12 11:46:35 +01:00
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpiW( override, szAll ))
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
if (feature->Installed != state)
|
|
|
|
{
|
|
|
|
feature->Action = state;
|
|
|
|
feature->ActionRequest = state;
|
|
|
|
}
|
|
|
|
}
|
2005-09-08 13:03:35 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LPWSTR ptr = override;
|
|
|
|
LPWSTR ptr2 = strchrW(override,',');
|
2004-12-27 20:12:35 +01:00
|
|
|
|
2005-09-08 13:03:35 +02:00
|
|
|
while (ptr)
|
|
|
|
{
|
2010-01-18 13:10:15 +01:00
|
|
|
int len = ptr2 - ptr;
|
|
|
|
|
|
|
|
if ((ptr2 && strlenW(feature->Feature) == len && !strncmpW(ptr, feature->Feature, len))
|
|
|
|
|| (!ptr2 && !strcmpW(ptr, feature->Feature)))
|
2004-12-27 20:12:35 +01:00
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
if (feature->Installed != state)
|
|
|
|
{
|
|
|
|
feature->Action = state;
|
|
|
|
feature->ActionRequest = state;
|
|
|
|
}
|
2005-09-08 13:03:35 +02:00
|
|
|
break;
|
2004-12-27 20:12:35 +01:00
|
|
|
}
|
2005-09-08 13:03:35 +02:00
|
|
|
if (ptr2)
|
|
|
|
{
|
|
|
|
ptr=ptr2+1;
|
|
|
|
ptr2 = strchrW(ptr,',');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2004-12-27 20:12:35 +01:00
|
|
|
}
|
2004-12-27 20:06:22 +01:00
|
|
|
}
|
2006-10-26 05:34:52 +02:00
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(override);
|
2005-09-08 13:03:35 +02:00
|
|
|
return TRUE;
|
2005-02-22 16:47:00 +01:00
|
|
|
}
|
|
|
|
|
2010-01-27 11:18:02 +01:00
|
|
|
static BOOL process_overrides( MSIPACKAGE *package, int level )
|
2005-02-22 16:47:00 +01:00
|
|
|
{
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR szAddLocal[] =
|
|
|
|
{'A','D','D','L','O','C','A','L',0};
|
2007-11-06 12:22:11 +01:00
|
|
|
static const WCHAR szAddSource[] =
|
|
|
|
{'A','D','D','S','O','U','R','C','E',0};
|
2009-03-13 11:34:46 +01:00
|
|
|
static const WCHAR szAdvertise[] =
|
|
|
|
{'A','D','V','E','R','T','I','S','E',0};
|
2010-01-27 11:18:02 +01:00
|
|
|
BOOL ret = FALSE;
|
2005-08-22 16:09:17 +02:00
|
|
|
|
2010-01-27 11:18:02 +01:00
|
|
|
/* all these activation/deactivation things happen in order and things
|
|
|
|
* later on the list override things earlier on the list.
|
|
|
|
*
|
|
|
|
* 0 INSTALLLEVEL processing
|
|
|
|
* 1 ADDLOCAL
|
|
|
|
* 2 REMOVE
|
|
|
|
* 3 ADDSOURCE
|
|
|
|
* 4 ADDDEFAULT
|
|
|
|
* 5 REINSTALL
|
|
|
|
* 6 ADVERTISE
|
|
|
|
* 7 COMPADDLOCAL
|
|
|
|
* 8 COMPADDSOURCE
|
|
|
|
* 9 FILEADDLOCAL
|
|
|
|
* 10 FILEADDSOURCE
|
|
|
|
* 11 FILEADDDEFAULT
|
|
|
|
*/
|
|
|
|
ret |= process_state_property( package, level, szAddLocal, INSTALLSTATE_LOCAL );
|
|
|
|
ret |= process_state_property( package, level, szRemove, INSTALLSTATE_ABSENT );
|
|
|
|
ret |= process_state_property( package, level, szAddSource, INSTALLSTATE_SOURCE );
|
|
|
|
ret |= process_state_property( package, level, szReinstall, INSTALLSTATE_UNKNOWN );
|
|
|
|
ret |= process_state_property( package, level, szAdvertise, INSTALLSTATE_ADVERTISED );
|
2005-02-22 16:47:00 +01:00
|
|
|
|
2010-01-27 11:18:02 +01:00
|
|
|
if (ret)
|
2010-04-21 11:38:40 +02:00
|
|
|
msi_set_property( package->db, szPreselected, szOne );
|
2010-01-27 11:18:02 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT MSI_SetFeatureStates(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
int level;
|
|
|
|
MSICOMPONENT* component;
|
|
|
|
MSIFEATURE *feature;
|
2005-02-22 16:47:00 +01:00
|
|
|
|
|
|
|
TRACE("Checking Install Level\n");
|
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
level = msi_get_property_int(package->db, szInstallLevel, 1);
|
2005-02-22 16:47:00 +01:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
if (!msi_get_property_int( package->db, szPreselected, 0 ))
|
2004-12-27 20:06:22 +01:00
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2004-12-27 20:06:22 +01:00
|
|
|
{
|
2010-12-24 15:31:43 +01:00
|
|
|
if (!is_feature_selected( feature, level )) continue;
|
2004-12-27 20:02:59 +01:00
|
|
|
|
2010-12-24 15:31:43 +01:00
|
|
|
if (feature->ActionRequest == INSTALLSTATE_UNKNOWN)
|
2004-12-27 20:06:22 +01:00
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
if (feature->Attributes & msidbFeatureAttributesFavorSource)
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
feature->Action = INSTALLSTATE_SOURCE;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_SOURCE;
|
|
|
|
}
|
2005-08-22 16:09:17 +02:00
|
|
|
else if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
feature->Action = INSTALLSTATE_ADVERTISED;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_ADVERTISED;
|
|
|
|
}
|
2005-05-13 15:56:39 +02:00
|
|
|
else
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
feature->Action = INSTALLSTATE_LOCAL;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
2004-12-27 20:06:22 +01:00
|
|
|
}
|
2004-12-27 20:02:59 +01:00
|
|
|
}
|
2011-04-05 14:05:00 +02:00
|
|
|
/* disable child features of unselected parent or follow parent */
|
2006-09-21 04:59:19 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
|
|
|
FeatureList *fl;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( fl, &feature->Children, FeatureList, entry )
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
2011-04-05 14:05:00 +02:00
|
|
|
if (!is_feature_selected( feature, level ))
|
|
|
|
{
|
|
|
|
fl->feature->Action = INSTALLSTATE_UNKNOWN;
|
|
|
|
fl->feature->ActionRequest = INSTALLSTATE_UNKNOWN;
|
|
|
|
}
|
|
|
|
else if (fl->feature->Attributes & msidbFeatureAttributesFollowParent)
|
|
|
|
{
|
|
|
|
fl->feature->Action = feature->Action;
|
|
|
|
fl->feature->ActionRequest = feature->ActionRequest;
|
|
|
|
}
|
2011-02-10 15:56:15 +01:00
|
|
|
}
|
2006-09-21 04:59:19 +02:00
|
|
|
}
|
2004-12-27 20:06:22 +01:00
|
|
|
}
|
2010-12-24 15:31:43 +01:00
|
|
|
else /* preselected */
|
2010-07-21 09:46:46 +02:00
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
2010-12-24 15:31:43 +01:00
|
|
|
if (!is_feature_selected( feature, level )) continue;
|
2010-07-21 09:46:46 +02:00
|
|
|
|
2010-12-24 15:31:43 +01:00
|
|
|
if (feature->ActionRequest == INSTALLSTATE_UNKNOWN)
|
2010-07-21 09:46:46 +02:00
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
if (feature->Installed == INSTALLSTATE_ABSENT)
|
|
|
|
{
|
|
|
|
feature->Action = INSTALLSTATE_UNKNOWN;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_UNKNOWN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
feature->Action = feature->Installed;
|
|
|
|
feature->ActionRequest = feature->Installed;
|
|
|
|
}
|
2010-07-21 09:46:46 +02:00
|
|
|
}
|
|
|
|
}
|
2011-04-05 14:05:00 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
|
|
|
{
|
|
|
|
FeatureList *fl;
|
|
|
|
|
|
|
|
if (!is_feature_selected( feature, level )) continue;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( fl, &feature->Children, FeatureList, entry )
|
|
|
|
{
|
|
|
|
if (fl->feature->Attributes & msidbFeatureAttributesFollowParent)
|
|
|
|
{
|
|
|
|
fl->feature->Action = feature->Action;
|
|
|
|
fl->feature->ActionRequest = feature->ActionRequest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-21 09:46:46 +02:00
|
|
|
}
|
2004-12-27 20:06:22 +01:00
|
|
|
|
2011-02-10 15:56:15 +01:00
|
|
|
/* now we want to set component state based based on feature state */
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2004-12-27 20:06:22 +01:00
|
|
|
{
|
2005-08-19 12:03:11 +02:00
|
|
|
ComponentList *cl;
|
|
|
|
|
2010-07-21 09:47:03 +02:00
|
|
|
TRACE("Examining Feature %s (Level %d Installed %d Request %d Action %d)\n",
|
|
|
|
debugstr_w(feature->Feature), feature->Level, feature->Installed,
|
|
|
|
feature->ActionRequest, feature->Action);
|
2008-05-19 09:27:50 +02:00
|
|
|
|
2010-12-24 15:31:43 +01:00
|
|
|
if (!is_feature_selected( feature, level )) continue;
|
2006-12-05 10:24:39 +01:00
|
|
|
|
|
|
|
/* features with components that have compressed files are made local */
|
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
|
|
|
{
|
2010-07-21 09:47:03 +02:00
|
|
|
if (cl->component->ForceLocalState &&
|
2010-10-06 15:44:54 +02:00
|
|
|
feature->ActionRequest == INSTALLSTATE_SOURCE)
|
2006-12-05 10:24:39 +01:00
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
feature->Action = INSTALLSTATE_LOCAL;
|
|
|
|
feature->ActionRequest = INSTALLSTATE_LOCAL;
|
2006-12-05 10:24:39 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-12-27 20:02:59 +01:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2004-12-27 20:02:59 +01:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
component = cl->component;
|
2004-12-27 20:06:22 +01:00
|
|
|
|
2010-10-06 15:44:54 +02:00
|
|
|
switch (feature->ActionRequest)
|
2006-11-10 07:38:31 +01:00
|
|
|
{
|
2007-11-01 09:12:41 +01:00
|
|
|
case INSTALLSTATE_ABSENT:
|
|
|
|
component->anyAbsent = 1;
|
|
|
|
break;
|
2006-12-05 10:24:39 +01:00
|
|
|
case INSTALLSTATE_ADVERTISED:
|
|
|
|
component->hasAdvertiseFeature = 1;
|
|
|
|
break;
|
|
|
|
case INSTALLSTATE_SOURCE:
|
|
|
|
component->hasSourceFeature = 1;
|
|
|
|
break;
|
|
|
|
case INSTALLSTATE_LOCAL:
|
|
|
|
component->hasLocalFeature = 1;
|
|
|
|
break;
|
|
|
|
case INSTALLSTATE_DEFAULT:
|
|
|
|
if (feature->Attributes & msidbFeatureAttributesFavorAdvertise)
|
|
|
|
component->hasAdvertiseFeature = 1;
|
|
|
|
else if (feature->Attributes & msidbFeatureAttributesFavorSource)
|
|
|
|
component->hasSourceFeature = 1;
|
2006-11-10 07:38:31 +01:00
|
|
|
else
|
2006-12-05 10:24:39 +01:00
|
|
|
component->hasLocalFeature = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2006-10-20 00:51:33 +02:00
|
|
|
}
|
2006-12-05 10:24:39 +01:00
|
|
|
}
|
|
|
|
}
|
2006-10-20 00:51:33 +02:00
|
|
|
|
2006-12-05 10:24:39 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
|
|
|
|
{
|
|
|
|
/* check if it's local or source */
|
|
|
|
if (!(component->Attributes & msidbComponentAttributesOptional) &&
|
|
|
|
(component->hasLocalFeature || component->hasSourceFeature))
|
|
|
|
{
|
|
|
|
if ((component->Attributes & msidbComponentAttributesSourceOnly) &&
|
|
|
|
!component->ForceLocalState)
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_SOURCE;
|
|
|
|
component->ActionRequest = INSTALLSTATE_SOURCE;
|
|
|
|
}
|
2006-12-05 10:24:39 +01:00
|
|
|
else
|
2011-02-10 15:56:15 +01:00
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
2006-12-05 10:24:39 +01:00
|
|
|
continue;
|
|
|
|
}
|
2006-10-20 00:51:33 +02:00
|
|
|
|
2006-12-05 10:24:39 +01:00
|
|
|
/* if any feature is local, the component must be local too */
|
|
|
|
if (component->hasLocalFeature)
|
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
2006-12-05 10:24:39 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (component->hasSourceFeature)
|
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
component->Action = INSTALLSTATE_SOURCE;
|
|
|
|
component->ActionRequest = INSTALLSTATE_SOURCE;
|
2006-12-05 10:24:39 +01:00
|
|
|
continue;
|
2004-12-27 20:02:59 +01:00
|
|
|
}
|
2006-12-05 10:24:39 +01:00
|
|
|
if (component->hasAdvertiseFeature)
|
|
|
|
{
|
2011-02-10 15:56:15 +01:00
|
|
|
component->Action = INSTALLSTATE_ADVERTISED;
|
|
|
|
component->ActionRequest = INSTALLSTATE_ADVERTISED;
|
2006-12-05 10:24:39 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
TRACE("nobody wants component %s\n", debugstr_w(component->Component));
|
2011-02-10 15:56:15 +01:00
|
|
|
if (component->anyAbsent &&
|
|
|
|
(component->Installed == INSTALLSTATE_LOCAL || component->Installed == INSTALLSTATE_SOURCE))
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_ABSENT;
|
|
|
|
component->ActionRequest = INSTALLSTATE_ABSENT;
|
|
|
|
}
|
2006-10-26 05:34:52 +02:00
|
|
|
}
|
2004-12-27 20:06:22 +01:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( component, &package->components, MSICOMPONENT, entry )
|
2004-12-27 20:06:22 +01:00
|
|
|
{
|
2010-07-21 09:47:03 +02:00
|
|
|
if (component->ActionRequest == INSTALLSTATE_DEFAULT)
|
2006-11-07 09:55:43 +01:00
|
|
|
{
|
|
|
|
TRACE("%s was default, setting to local\n", debugstr_w(component->Component));
|
2011-02-10 15:56:15 +01:00
|
|
|
component->Action = INSTALLSTATE_LOCAL;
|
|
|
|
component->ActionRequest = INSTALLSTATE_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (component->ActionRequest == INSTALLSTATE_SOURCE &&
|
|
|
|
component->Installed == INSTALLSTATE_SOURCE &&
|
|
|
|
component->hasSourceFeature)
|
|
|
|
{
|
|
|
|
component->Action = INSTALLSTATE_UNKNOWN;
|
|
|
|
component->ActionRequest = INSTALLSTATE_UNKNOWN;
|
2006-11-07 09:55:43 +01:00
|
|
|
}
|
|
|
|
|
2010-07-21 09:47:03 +02:00
|
|
|
TRACE("Result: Component %s (Installed %d Request %d Action %d)\n",
|
|
|
|
debugstr_w(component->Component), component->Installed, component->ActionRequest, component->Action);
|
2004-12-27 20:06:22 +01:00
|
|
|
}
|
|
|
|
|
2004-12-27 20:02:59 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:50:12 +02:00
|
|
|
static UINT ITERATE_CostFinalizeConditions(MSIRECORD *row, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2005-08-22 16:09:17 +02:00
|
|
|
LPCWSTR name;
|
|
|
|
MSIFEATURE *feature;
|
2005-06-21 22:50:12 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
name = MSI_RecordGetString( row, 1 );
|
2005-06-21 22:50:12 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
feature = msi_get_loaded_feature( package, name );
|
2005-08-22 16:09:17 +02:00
|
|
|
if (!feature)
|
|
|
|
ERR("FAILED to find loaded feature %s\n",debugstr_w(name));
|
2005-06-21 22:50:12 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LPCWSTR Condition;
|
|
|
|
Condition = MSI_RecordGetString(row,3);
|
|
|
|
|
2005-06-24 13:51:29 +02:00
|
|
|
if (MSI_EvaluateConditionW(package,Condition) == MSICONDITION_TRUE)
|
2005-06-21 22:50:12 +02:00
|
|
|
{
|
|
|
|
int level = MSI_RecordGetInteger(row,2);
|
2008-05-06 20:01:59 +02:00
|
|
|
TRACE("Resetting feature %s to level %i\n", debugstr_w(name), level);
|
2005-08-22 16:09:17 +02:00
|
|
|
feature->Level = level;
|
2005-06-21 22:50:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-06-11 15:19:15 +02:00
|
|
|
VS_FIXEDFILEINFO *msi_get_disk_file_version( LPCWSTR filename )
|
2006-10-24 10:37:26 +02:00
|
|
|
{
|
2008-05-26 06:06:47 +02:00
|
|
|
static const WCHAR name[] = {'\\',0};
|
2010-10-22 18:08:58 +02:00
|
|
|
VS_FIXEDFILEINFO *ptr, *ret;
|
2006-10-24 10:37:26 +02:00
|
|
|
LPVOID version;
|
2010-06-11 15:19:15 +02:00
|
|
|
DWORD versize, handle;
|
2006-10-24 10:37:26 +02:00
|
|
|
UINT sz;
|
|
|
|
|
|
|
|
versize = GetFileVersionInfoSizeW( filename, &handle );
|
|
|
|
if (!versize)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
version = msi_alloc( versize );
|
2010-06-11 15:19:15 +02:00
|
|
|
if (!version)
|
|
|
|
return NULL;
|
|
|
|
|
2006-10-24 10:37:26 +02:00
|
|
|
GetFileVersionInfoW( filename, 0, versize, version );
|
|
|
|
|
2010-10-22 18:08:58 +02:00
|
|
|
if (!VerQueryValueW( version, name, (LPVOID *)&ptr, &sz ))
|
2007-06-26 23:22:52 +02:00
|
|
|
{
|
|
|
|
msi_free( version );
|
|
|
|
return NULL;
|
|
|
|
}
|
2006-10-24 10:37:26 +02:00
|
|
|
|
2010-10-22 18:08:58 +02:00
|
|
|
ret = msi_alloc( sz );
|
|
|
|
memcpy( ret, ptr, sz );
|
|
|
|
|
2007-06-26 23:23:30 +02:00
|
|
|
msi_free( version );
|
2010-06-11 15:19:15 +02:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-26 23:23:30 +02:00
|
|
|
|
2010-06-11 15:19:15 +02:00
|
|
|
int msi_compare_file_versions( VS_FIXEDFILEINFO *fi, const WCHAR *version )
|
|
|
|
{
|
|
|
|
DWORD ms, ls;
|
|
|
|
|
|
|
|
msi_parse_version_string( version, &ms, &ls );
|
|
|
|
|
|
|
|
if (fi->dwFileVersionMS > ms) return 1;
|
|
|
|
else if (fi->dwFileVersionMS < ms) return -1;
|
|
|
|
else if (fi->dwFileVersionLS > ls) return 1;
|
|
|
|
else if (fi->dwFileVersionLS < ls) return -1;
|
|
|
|
return 0;
|
2006-10-24 10:37:26 +02:00
|
|
|
}
|
|
|
|
|
2011-03-08 10:08:16 +01:00
|
|
|
int msi_compare_font_versions( const WCHAR *ver1, const WCHAR *ver2 )
|
2011-01-11 10:28:16 +01:00
|
|
|
{
|
|
|
|
DWORD ms1, ms2;
|
|
|
|
|
|
|
|
msi_parse_version_string( ver1, &ms1, NULL );
|
|
|
|
msi_parse_version_string( ver2, &ms2, NULL );
|
|
|
|
|
|
|
|
if (ms1 > ms2) return 1;
|
|
|
|
else if (ms1 < ms2) return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-03-08 10:08:16 +01:00
|
|
|
DWORD msi_get_disk_file_size( LPCWSTR filename )
|
2010-04-27 13:30:32 +02:00
|
|
|
{
|
|
|
|
HANDLE file;
|
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
file = CreateFileW( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL );
|
|
|
|
if (file == INVALID_HANDLE_VALUE)
|
|
|
|
return INVALID_FILE_SIZE;
|
|
|
|
|
|
|
|
size = GetFileSize( file, NULL );
|
2011-05-12 17:22:34 +02:00
|
|
|
TRACE("size is %u\n", size);
|
2010-04-27 13:30:32 +02:00
|
|
|
CloseHandle( file );
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2011-03-08 10:08:16 +01:00
|
|
|
BOOL msi_file_hash_matches( MSIFILE *file )
|
2010-04-27 13:30:32 +02:00
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIFILEHASHINFO hash;
|
|
|
|
|
|
|
|
hash.dwFileHashInfoSize = sizeof(MSIFILEHASHINFO);
|
|
|
|
r = MsiGetFileHashW( file->TargetPath, 0, &hash );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return !memcmp( &hash, &file->hash, sizeof(MSIFILEHASHINFO) );
|
|
|
|
}
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
static WCHAR *get_temp_dir( void )
|
|
|
|
{
|
|
|
|
static UINT id;
|
|
|
|
WCHAR tmp[MAX_PATH], dir[MAX_PATH];
|
|
|
|
|
|
|
|
GetTempPathW( MAX_PATH, tmp );
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!GetTempFileNameW( tmp, szMsi, ++id, dir )) return NULL;
|
|
|
|
if (CreateDirectoryW( dir, NULL )) break;
|
|
|
|
}
|
|
|
|
return strdupW( dir );
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
/*
|
|
|
|
* msi_build_directory_name()
|
|
|
|
*
|
|
|
|
* This function is to save messing round with directory names
|
|
|
|
* It handles adding backslashes between path segments,
|
|
|
|
* and can add \ at the end of the directory name if told to.
|
|
|
|
*
|
|
|
|
* It takes a variable number of arguments.
|
|
|
|
* It always allocates a new string for the result, so make sure
|
|
|
|
* to free the return value when finished with it.
|
|
|
|
*
|
|
|
|
* The first arg is the number of path segments that follow.
|
|
|
|
* The arguments following count are a list of path segments.
|
|
|
|
* A path segment may be NULL.
|
|
|
|
*
|
|
|
|
* Path segments will be added with a \ separating them.
|
|
|
|
* A \ will not be added after the last segment, however if the
|
|
|
|
* last segment is NULL, then the last character will be a \
|
|
|
|
*/
|
|
|
|
WCHAR *msi_build_directory_name( DWORD count, ... )
|
|
|
|
{
|
|
|
|
DWORD sz = 1, i;
|
|
|
|
WCHAR *dir;
|
|
|
|
va_list va;
|
|
|
|
|
|
|
|
va_start( va, count );
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
const WCHAR *str = va_arg( va, const WCHAR * );
|
|
|
|
if (str) sz += strlenW( str ) + 1;
|
|
|
|
}
|
|
|
|
va_end( va );
|
|
|
|
|
|
|
|
dir = msi_alloc( sz * sizeof(WCHAR) );
|
|
|
|
dir[0] = 0;
|
|
|
|
|
|
|
|
va_start( va, count );
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
const WCHAR *str = va_arg( va, const WCHAR * );
|
|
|
|
if (!str) continue;
|
|
|
|
strcatW( dir, str );
|
|
|
|
if ( i + 1 != count && dir[strlenW( dir ) - 1] != '\\') strcatW( dir, szBackSlash );
|
|
|
|
}
|
|
|
|
va_end( va );
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
static void set_target_path( MSIPACKAGE *package, MSIFILE *file )
|
|
|
|
{
|
|
|
|
MSIASSEMBLY *assembly = file->Component->assembly;
|
|
|
|
|
|
|
|
TRACE("file %s is named %s\n", debugstr_w(file->File), debugstr_w(file->FileName));
|
|
|
|
|
|
|
|
msi_free( file->TargetPath );
|
2010-11-12 16:18:08 +01:00
|
|
|
if (assembly && !assembly->application)
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
|
|
|
if (!assembly->tempdir) assembly->tempdir = get_temp_dir();
|
2011-05-06 14:39:17 +02:00
|
|
|
file->TargetPath = msi_build_directory_name( 2, assembly->tempdir, file->FileName );
|
|
|
|
msi_track_tempfile( package, file->TargetPath );
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
const WCHAR *dir = msi_get_target_folder( package, file->Component->Directory );
|
2011-05-06 14:39:17 +02:00
|
|
|
file->TargetPath = msi_build_directory_name( 2, dir, file->FileName );
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("resolves to %s\n", debugstr_w(file->TargetPath));
|
|
|
|
}
|
|
|
|
|
2011-03-08 10:08:16 +01:00
|
|
|
static UINT calculate_file_cost( MSIPACKAGE *package )
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2010-06-11 15:19:15 +02:00
|
|
|
VS_FIXEDFILEINFO *file_version;
|
2011-01-11 10:28:16 +01:00
|
|
|
WCHAR *font_version;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
2004-07-04 02:35:52 +02:00
|
|
|
{
|
2010-11-11 10:45:42 +01:00
|
|
|
MSICOMPONENT *comp = file->Component;
|
2010-04-27 13:30:32 +02:00
|
|
|
DWORD file_size;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2010-11-11 10:45:20 +01:00
|
|
|
if (!comp->Enabled) continue;
|
2004-07-04 02:35:52 +02:00
|
|
|
|
2006-09-21 04:55:01 +02:00
|
|
|
if (file->IsCompressed)
|
|
|
|
comp->ForceLocalState = TRUE;
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
set_target_path( package, file );
|
2004-12-22 19:46:17 +01:00
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
if ((comp->assembly && !comp->assembly->installed) ||
|
|
|
|
GetFileAttributesW(file->TargetPath) == INVALID_FILE_ATTRIBUTES)
|
2005-09-09 16:48:51 +02:00
|
|
|
{
|
|
|
|
comp->Cost += file->FileSize;
|
|
|
|
continue;
|
|
|
|
}
|
2011-03-08 10:08:16 +01:00
|
|
|
file_size = msi_get_disk_file_size( file->TargetPath );
|
|
|
|
|
2011-01-11 10:28:16 +01:00
|
|
|
if (file->Version)
|
2005-09-09 16:48:51 +02:00
|
|
|
{
|
2011-01-11 10:28:16 +01:00
|
|
|
if ((file_version = msi_get_disk_file_version( file->TargetPath )))
|
2004-07-04 02:35:52 +02:00
|
|
|
{
|
2011-01-11 10:28:16 +01:00
|
|
|
if (msi_compare_file_versions( file_version, file->Version ) < 0)
|
|
|
|
{
|
2011-03-08 10:08:16 +01:00
|
|
|
comp->Cost += file->FileSize - file_size;
|
2011-01-11 10:28:16 +01:00
|
|
|
}
|
|
|
|
msi_free( file_version );
|
|
|
|
continue;
|
2004-07-04 02:35:52 +02:00
|
|
|
}
|
2011-01-11 10:28:16 +01:00
|
|
|
else if ((font_version = font_version_from_file( file->TargetPath )))
|
2010-04-27 13:30:32 +02:00
|
|
|
{
|
2011-01-11 10:28:16 +01:00
|
|
|
if (msi_compare_font_versions( font_version, file->Version ) < 0)
|
|
|
|
{
|
2011-03-08 10:08:16 +01:00
|
|
|
comp->Cost += file->FileSize - file_size;
|
2011-01-11 10:28:16 +01:00
|
|
|
}
|
|
|
|
msi_free( font_version );
|
|
|
|
continue;
|
2010-04-27 13:30:32 +02:00
|
|
|
}
|
2005-09-09 16:48:51 +02:00
|
|
|
}
|
2011-03-08 10:08:16 +01:00
|
|
|
if (file_size != file->FileSize)
|
2010-04-19 12:38:30 +02:00
|
|
|
{
|
2010-04-27 13:30:32 +02:00
|
|
|
comp->Cost += file->FileSize - file_size;
|
|
|
|
}
|
2004-07-04 02:35:52 +02:00
|
|
|
}
|
2006-11-07 07:05:48 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
void msi_clean_path( WCHAR *p )
|
|
|
|
{
|
|
|
|
WCHAR *q = p;
|
|
|
|
int n, len = 0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/* copy until the end of the string or a space */
|
|
|
|
while (*p != ' ' && (*q = *p))
|
|
|
|
{
|
|
|
|
p++, len++;
|
|
|
|
/* reduce many backslashes to one */
|
|
|
|
if (*p != '\\' || *q != '\\')
|
|
|
|
q++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* quit at the end of the string */
|
|
|
|
if (!*p)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* count the number of spaces */
|
|
|
|
n = 0;
|
|
|
|
while (p[n] == ' ')
|
|
|
|
n++;
|
|
|
|
|
|
|
|
/* if it's leading or trailing space, skip it */
|
|
|
|
if ( len == 0 || p[-1] == '\\' || p[n] == '\\' )
|
|
|
|
p += n;
|
|
|
|
else /* copy n spaces */
|
|
|
|
while (n && (*q++ = *p++)) n--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-17 11:09:43 +02:00
|
|
|
static WCHAR *get_target_dir_property( MSIDATABASE *db )
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
WCHAR *path, *target_dir = msi_dup_property( db, szTargetDir );
|
|
|
|
|
|
|
|
if (!target_dir) return NULL;
|
|
|
|
|
|
|
|
len = strlenW( target_dir );
|
|
|
|
if (target_dir[len - 1] == '\\') return target_dir;
|
|
|
|
if ((path = msi_alloc( (len + 2) * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
strcpyW( path, target_dir );
|
|
|
|
path[len] = '\\';
|
|
|
|
path[len + 1] = 0;
|
|
|
|
}
|
|
|
|
msi_free( target_dir );
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
void msi_resolve_target_folder( MSIPACKAGE *package, const WCHAR *name, BOOL load_prop )
|
|
|
|
{
|
|
|
|
FolderList *fl;
|
|
|
|
MSIFOLDER *folder, *parent, *child;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
TRACE("resolving %s\n", debugstr_w(name));
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!(folder = msi_get_loaded_folder( package, name ))) return;
|
2011-05-02 16:03:55 +02:00
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
if (!strcmpW( folder->Directory, szTargetDir )) /* special resolving for target root dir */
|
2011-05-02 16:03:55 +02:00
|
|
|
{
|
2011-05-17 11:09:43 +02:00
|
|
|
if (!load_prop || !(path = get_target_dir_property( package->db )))
|
2011-05-02 16:03:55 +02:00
|
|
|
{
|
2011-05-02 16:04:25 +02:00
|
|
|
path = msi_dup_property( package->db, szRootDrive );
|
2011-05-02 16:03:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!load_prop || !(path = msi_dup_property( package->db, folder->Directory )))
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
parent = msi_get_loaded_folder( package, folder->Parent );
|
|
|
|
path = msi_build_directory_name( 3, parent->ResolvedTarget, folder->TargetDefault, NULL );
|
2011-05-02 16:03:55 +02:00
|
|
|
}
|
|
|
|
msi_clean_path( path );
|
2011-05-11 11:25:40 +02:00
|
|
|
if (folder->ResolvedTarget && !strcmpiW( path, folder->ResolvedTarget ))
|
|
|
|
{
|
|
|
|
TRACE("%s already resolved to %s\n", debugstr_w(name), debugstr_w(folder->ResolvedTarget));
|
|
|
|
msi_free( path );
|
|
|
|
return;
|
|
|
|
}
|
2011-05-02 16:03:55 +02:00
|
|
|
msi_set_property( package->db, folder->Directory, path );
|
|
|
|
msi_free( folder->ResolvedTarget );
|
|
|
|
folder->ResolvedTarget = path;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( fl, &folder->children, FolderList, entry )
|
|
|
|
{
|
|
|
|
child = fl->folder;
|
|
|
|
msi_resolve_target_folder( package, child->Directory, load_prop );
|
|
|
|
}
|
|
|
|
TRACE("%s resolves to %s\n", debugstr_w(name), debugstr_w(folder->ResolvedTarget));
|
|
|
|
}
|
|
|
|
|
2006-11-07 07:05:48 +01:00
|
|
|
static UINT ACTION_CostFinalize(MSIPACKAGE *package)
|
|
|
|
{
|
2011-05-02 16:03:55 +02:00
|
|
|
static const WCHAR condition_query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','`','C','o','n','d','i','t','i','o','n','`',0};
|
2008-05-14 03:31:44 +02:00
|
|
|
static const WCHAR szOutOfDiskSpace[] =
|
|
|
|
{'O','u','t','O','f','D','i','s','k','S','p','a','c','e',0};
|
2006-11-07 07:05:48 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-01-27 11:18:02 +01:00
|
|
|
UINT rc = ERROR_SUCCESS;
|
2006-11-07 07:05:48 +01:00
|
|
|
MSIQUERY * view;
|
|
|
|
LPWSTR level;
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
TRACE("Building directory properties\n");
|
2011-05-02 16:04:25 +02:00
|
|
|
msi_resolve_target_folder( package, szTargetDir, TRUE );
|
2006-11-07 07:05:48 +01:00
|
|
|
|
2010-11-30 15:18:00 +01:00
|
|
|
TRACE("Evaluating component conditions\n");
|
|
|
|
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
|
|
|
|
{
|
|
|
|
if (MSI_EvaluateConditionW( package, comp->Condition ) == MSICONDITION_FALSE)
|
|
|
|
{
|
|
|
|
TRACE("Disabling component %s\n", debugstr_w(comp->Component));
|
|
|
|
comp->Enabled = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
comp->Enabled = TRUE;
|
|
|
|
}
|
|
|
|
|
2006-11-07 07:05:48 +01:00
|
|
|
/* read components states from the registry */
|
|
|
|
ACTION_GetComponentInstallStates(package);
|
2008-08-19 06:14:53 +02:00
|
|
|
ACTION_GetFeatureInstallStates(package);
|
2006-11-07 07:05:48 +01:00
|
|
|
|
2011-05-02 16:04:25 +02:00
|
|
|
if (!process_overrides( package, msi_get_property_int( package->db, szInstallLevel, 1 ) ))
|
2004-07-20 03:22:37 +02:00
|
|
|
{
|
2010-04-27 13:30:10 +02:00
|
|
|
TRACE("Evaluating feature conditions\n");
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, condition_query, &view );
|
2010-01-27 11:18:02 +01:00
|
|
|
if (rc == ERROR_SUCCESS)
|
2004-07-04 02:36:58 +02:00
|
|
|
{
|
2010-01-27 11:18:02 +01:00
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_CostFinalizeConditions, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
}
|
2010-04-27 13:30:10 +02:00
|
|
|
}
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2011-03-08 10:08:16 +01:00
|
|
|
TRACE("Calculating file cost\n");
|
|
|
|
calculate_file_cost( package );
|
2010-11-11 10:45:20 +01:00
|
|
|
|
2011-04-01 14:54:12 +02:00
|
|
|
msi_set_property( package->db, szCostingComplete, szOne );
|
2004-12-27 19:56:30 +01:00
|
|
|
/* set default run level if not set */
|
2011-05-02 16:04:25 +02:00
|
|
|
level = msi_dup_property( package->db, szInstallLevel );
|
2004-12-27 19:56:30 +01:00
|
|
|
if (!level)
|
2011-05-02 16:04:25 +02:00
|
|
|
msi_set_property( package->db, szInstallLevel, szOne );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(level);
|
2004-12-27 20:02:59 +01:00
|
|
|
|
2008-05-14 03:31:44 +02:00
|
|
|
/* FIXME: check volume disk space */
|
2010-04-21 11:38:40 +02:00
|
|
|
msi_set_property( package->db, szOutOfDiskSpace, szZero );
|
2008-05-14 03:31:44 +02:00
|
|
|
|
2006-07-19 20:15:37 +02:00
|
|
|
return MSI_SetFeatureStates(package);
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2005-01-26 22:09:04 +01:00
|
|
|
/* OK this value is "interpreted" and then formatted based on the
|
2004-06-29 06:07:22 +02:00
|
|
|
first few characters */
|
2005-06-09 22:30:59 +02:00
|
|
|
static LPSTR parse_value(MSIPACKAGE *package, LPCWSTR value, DWORD *type,
|
2004-06-28 22:34:35 +02:00
|
|
|
DWORD *size)
|
|
|
|
{
|
|
|
|
LPSTR data = NULL;
|
2008-02-05 02:06:53 +01:00
|
|
|
|
2004-06-29 06:07:22 +02:00
|
|
|
if (value[0]=='#' && value[1]!='#' && value[1]!='%')
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2004-06-29 06:07:22 +02:00
|
|
|
if (value[1]=='x')
|
|
|
|
{
|
|
|
|
LPWSTR ptr;
|
|
|
|
CHAR byte[5];
|
2005-05-16 23:37:35 +02:00
|
|
|
LPWSTR deformated = NULL;
|
2004-06-29 06:07:22 +02:00
|
|
|
int count;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
deformat_string(package, &value[2], &deformated);
|
2004-06-29 06:07:22 +02:00
|
|
|
|
|
|
|
/* binary value type */
|
2005-05-16 23:37:35 +02:00
|
|
|
ptr = deformated;
|
|
|
|
*type = REG_BINARY;
|
|
|
|
if (strlenW(ptr)%2)
|
|
|
|
*size = (strlenW(ptr)/2)+1;
|
|
|
|
else
|
|
|
|
*size = strlenW(ptr)/2;
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
data = msi_alloc(*size);
|
2005-05-16 23:37:35 +02:00
|
|
|
|
2004-06-29 06:07:22 +02:00
|
|
|
byte[0] = '0';
|
|
|
|
byte[1] = 'x';
|
|
|
|
byte[4] = 0;
|
|
|
|
count = 0;
|
2005-05-16 23:37:35 +02:00
|
|
|
/* if uneven pad with a zero in front */
|
|
|
|
if (strlenW(ptr)%2)
|
|
|
|
{
|
|
|
|
byte[2]= '0';
|
|
|
|
byte[3]= *ptr;
|
|
|
|
ptr++;
|
|
|
|
data[count] = (BYTE)strtol(byte,NULL,0);
|
|
|
|
count ++;
|
|
|
|
TRACE("Uneven byte count\n");
|
|
|
|
}
|
2004-06-29 06:07:22 +02:00
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
byte[2]= *ptr;
|
|
|
|
ptr++;
|
|
|
|
byte[3]= *ptr;
|
|
|
|
ptr++;
|
|
|
|
data[count] = (BYTE)strtol(byte,NULL,0);
|
|
|
|
count ++;
|
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(deformated);
|
2004-06-29 06:07:22 +02:00
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("Data %i bytes(%i)\n",*size,count);
|
2004-06-29 06:07:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPWSTR deformated;
|
2005-02-24 13:47:43 +01:00
|
|
|
LPWSTR p;
|
|
|
|
DWORD d = 0;
|
2004-07-10 00:25:34 +02:00
|
|
|
deformat_string(package, &value[1], &deformated);
|
2004-06-29 06:07:22 +02:00
|
|
|
|
|
|
|
*type=REG_DWORD;
|
|
|
|
*size = sizeof(DWORD);
|
2005-09-20 13:59:14 +02:00
|
|
|
data = msi_alloc(*size);
|
2005-02-24 13:47:43 +01:00
|
|
|
p = deformated;
|
|
|
|
if (*p == '-')
|
|
|
|
p++;
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
if ( (*p < '0') || (*p > '9') )
|
|
|
|
break;
|
|
|
|
d *= 10;
|
|
|
|
d += (*p - '0');
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
if (deformated[0] == '-')
|
|
|
|
d = -d;
|
|
|
|
*(LPDWORD)data = d;
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("DWORD %i\n",*(LPDWORD)data);
|
2004-06-29 06:07:22 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(deformated);
|
2004-06-29 06:07:22 +02:00
|
|
|
}
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-25 21:17:09 +01:00
|
|
|
static const WCHAR szMulti[] = {'[','~',']',0};
|
2005-06-09 22:30:59 +02:00
|
|
|
LPCWSTR ptr;
|
2004-06-29 06:07:22 +02:00
|
|
|
*type=REG_SZ;
|
|
|
|
|
2004-06-28 22:34:35 +02:00
|
|
|
if (value[0]=='#')
|
2004-06-29 06:07:22 +02:00
|
|
|
{
|
|
|
|
if (value[1]=='%')
|
|
|
|
{
|
|
|
|
ptr = &value[2];
|
|
|
|
*type=REG_EXPAND_SZ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ptr = &value[1];
|
|
|
|
}
|
|
|
|
else
|
2004-06-28 22:34:35 +02:00
|
|
|
ptr=value;
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (strstrW(value, szMulti))
|
2005-01-25 21:17:09 +01:00
|
|
|
*type = REG_MULTI_SZ;
|
|
|
|
|
2008-02-05 02:06:53 +01:00
|
|
|
/* remove initial delimiter */
|
|
|
|
if (!strncmpW(value, szMulti, 3))
|
|
|
|
ptr = value + 3;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
*size = deformat_string(package, ptr,(LPWSTR*)&data);
|
2008-02-05 02:06:53 +01:00
|
|
|
|
|
|
|
/* add double NULL terminator */
|
|
|
|
if (*type == REG_MULTI_SZ)
|
|
|
|
{
|
2008-02-25 03:15:31 +01:00
|
|
|
*size += 2 * sizeof(WCHAR); /* two NULL terminators */
|
|
|
|
data = msi_realloc_zero(data, *size);
|
2008-02-05 02:06:53 +01:00
|
|
|
}
|
2004-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2010-02-25 15:17:11 +01:00
|
|
|
static const WCHAR *get_root_key( MSIPACKAGE *package, INT root, HKEY *root_key )
|
|
|
|
{
|
|
|
|
const WCHAR *ret;
|
|
|
|
|
|
|
|
switch (root)
|
|
|
|
{
|
|
|
|
case -1:
|
2010-04-21 11:37:54 +02:00
|
|
|
if (msi_get_property_int( package->db, szAllUsers, 0 ))
|
2010-02-25 15:17:11 +01:00
|
|
|
{
|
|
|
|
*root_key = HKEY_LOCAL_MACHINE;
|
|
|
|
ret = szHLM;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*root_key = HKEY_CURRENT_USER;
|
|
|
|
ret = szHCU;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
*root_key = HKEY_CLASSES_ROOT;
|
|
|
|
ret = szHCR;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
*root_key = HKEY_CURRENT_USER;
|
|
|
|
ret = szHCU;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
*root_key = HKEY_LOCAL_MACHINE;
|
|
|
|
ret = szHLM;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
*root_key = HKEY_USERS;
|
|
|
|
ret = szHU;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("Unknown root %i\n", root);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-10-13 14:23:34 +02:00
|
|
|
static WCHAR *get_keypath( MSIPACKAGE *package, HKEY root, const WCHAR *path )
|
|
|
|
{
|
|
|
|
static const WCHAR prefixW[] = {'S','O','F','T','W','A','R','E','\\'};
|
|
|
|
static const UINT len = sizeof(prefixW) / sizeof(prefixW[0]);
|
|
|
|
|
|
|
|
if (is_64bit && package->platform == PLATFORM_INTEL &&
|
|
|
|
root == HKEY_LOCAL_MACHINE && !strncmpiW( path, prefixW, len ))
|
|
|
|
{
|
|
|
|
UINT size;
|
|
|
|
WCHAR *path_32node;
|
|
|
|
|
2011-03-31 11:57:25 +02:00
|
|
|
size = (strlenW( path ) + strlenW( szWow6432Node ) + 2) * sizeof(WCHAR);
|
|
|
|
if (!(path_32node = msi_alloc( size ))) return NULL;
|
2010-10-13 14:23:34 +02:00
|
|
|
|
|
|
|
memcpy( path_32node, path, len * sizeof(WCHAR) );
|
2011-03-31 11:57:25 +02:00
|
|
|
strcpyW( path_32node + len, szWow6432Node );
|
2010-10-13 14:23:34 +02:00
|
|
|
strcatW( path_32node, szBackSlash );
|
|
|
|
strcatW( path_32node, path + len );
|
|
|
|
return path_32node;
|
|
|
|
}
|
|
|
|
|
|
|
|
return strdupW( path );
|
|
|
|
}
|
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2005-06-21 22:21:18 +02:00
|
|
|
LPSTR value_data = NULL;
|
|
|
|
HKEY root_key, hkey;
|
|
|
|
DWORD type,size;
|
2010-10-13 14:23:34 +02:00
|
|
|
LPWSTR deformated, uikey, keypath;
|
2005-06-21 22:21:18 +02:00
|
|
|
LPCWSTR szRoot, component, name, key, value;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2005-06-21 22:21:18 +02:00
|
|
|
MSIRECORD * uirow;
|
|
|
|
INT root;
|
|
|
|
BOOL check_first = FALSE;
|
2004-06-28 22:34:35 +02:00
|
|
|
UINT rc;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 2, 0, 0, 0 );
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
component = MSI_RecordGetString(row, 6);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package,component);
|
2005-08-24 12:57:27 +02:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
2004-07-06 20:48:15 +02:00
|
|
|
|
2011-05-24 10:51:00 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2004-06-28 22:34:35 +02:00
|
|
|
{
|
2011-05-24 10:51:00 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2005-06-21 22:21:18 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
name = MSI_RecordGetString(row, 4);
|
|
|
|
if( MSI_RecordIsNull(row,5) && name )
|
|
|
|
{
|
|
|
|
/* null values can have special meanings */
|
|
|
|
if (name[0]=='-' && name[1] == 0)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
else if ((name[0]=='+' && name[1] == 0) ||
|
|
|
|
(name[0] == '*' && name[1] == 0))
|
2005-02-24 13:47:43 +01:00
|
|
|
name = NULL;
|
2005-06-21 22:21:18 +02:00
|
|
|
check_first = TRUE;
|
|
|
|
}
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
root = MSI_RecordGetInteger(row,2);
|
|
|
|
key = MSI_RecordGetString(row, 3);
|
|
|
|
|
2010-02-25 15:17:11 +01:00
|
|
|
szRoot = get_root_key( package, root, &root_key );
|
|
|
|
if (!szRoot)
|
2005-06-21 22:21:18 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
deformat_string(package, key , &deformated);
|
|
|
|
size = strlenW(deformated) + strlenW(szRoot) + 1;
|
2005-09-20 13:59:14 +02:00
|
|
|
uikey = msi_alloc(size*sizeof(WCHAR));
|
2005-06-21 22:21:18 +02:00
|
|
|
strcpyW(uikey,szRoot);
|
|
|
|
strcatW(uikey,deformated);
|
2005-01-06 20:34:16 +01:00
|
|
|
|
2010-10-13 14:23:34 +02:00
|
|
|
keypath = get_keypath( package, root_key, deformated );
|
|
|
|
msi_free( deformated );
|
|
|
|
if (RegCreateKeyW( root_key, keypath, &hkey ))
|
2005-06-21 22:21:18 +02:00
|
|
|
{
|
2010-10-13 14:23:34 +02:00
|
|
|
ERR("Could not create key %s\n", debugstr_w(keypath));
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(uikey);
|
2011-01-12 14:04:13 +01:00
|
|
|
msi_free(keypath);
|
2005-06-21 22:21:18 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-06-29 06:07:22 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
value = MSI_RecordGetString(row,5);
|
|
|
|
if (value)
|
|
|
|
value_data = parse_value(package, value, &type, &size);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value_data = (LPSTR)strdupW(szEmpty);
|
2008-04-22 17:05:05 +02:00
|
|
|
size = sizeof(szEmpty);
|
2005-06-21 22:21:18 +02:00
|
|
|
type = REG_SZ;
|
|
|
|
}
|
2004-06-28 22:34:35 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
deformat_string(package, name, &deformated);
|
2005-01-06 20:34:16 +01:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
if (!check_first)
|
|
|
|
{
|
|
|
|
TRACE("Setting value %s of %s\n",debugstr_w(deformated),
|
|
|
|
debugstr_w(uikey));
|
2005-07-06 12:33:30 +02:00
|
|
|
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE)value_data, size);
|
2005-06-21 22:21:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD sz = 0;
|
|
|
|
rc = RegQueryValueExW(hkey, deformated, NULL, NULL, NULL, &sz);
|
|
|
|
if (rc == ERROR_SUCCESS || rc == ERROR_MORE_DATA)
|
2005-05-20 11:40:42 +02:00
|
|
|
{
|
2005-06-21 22:21:18 +02:00
|
|
|
TRACE("value %s of %s checked already exists\n",
|
|
|
|
debugstr_w(deformated), debugstr_w(uikey));
|
2005-05-20 11:40:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-21 22:21:18 +02:00
|
|
|
TRACE("Checked and setting value %s of %s\n",
|
|
|
|
debugstr_w(deformated), debugstr_w(uikey));
|
|
|
|
if (deformated || size)
|
2005-07-06 12:33:30 +02:00
|
|
|
RegSetValueExW(hkey, deformated, 0, type, (LPBYTE) value_data, size);
|
2005-05-20 11:40:42 +02:00
|
|
|
}
|
2005-06-21 22:21:18 +02:00
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
2004-07-06 20:48:15 +02:00
|
|
|
|
2005-06-21 22:21:18 +02:00
|
|
|
uirow = MSI_CreateRecord(3);
|
|
|
|
MSI_RecordSetStringW(uirow,2,deformated);
|
|
|
|
MSI_RecordSetStringW(uirow,1,uikey);
|
2010-03-23 11:47:42 +01:00
|
|
|
if (type == REG_SZ || type == REG_EXPAND_SZ)
|
2005-06-21 22:21:18 +02:00
|
|
|
MSI_RecordSetStringW(uirow,3,(LPWSTR)value_data);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szWriteRegistryValues, uirow );
|
2005-06-21 22:21:18 +02:00
|
|
|
msiobj_release( &uirow->hdr );
|
2004-07-06 20:48:15 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(value_data);
|
|
|
|
msi_free(deformated);
|
|
|
|
msi_free(uikey);
|
2011-01-12 14:04:13 +01:00
|
|
|
msi_free(keypath);
|
2005-06-21 22:21:18 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','R','e','g','i','s','t','r','y','`',0 };
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
/* increment progress bar each time action data is sent */
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 1, REG_PROGRESS_VALUE, 1, 0 );
|
2005-06-21 22:21:18 +02:00
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_WriteRegistryValues, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2004-06-28 22:34:35 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-25 15:17:11 +01:00
|
|
|
static void delete_reg_key_or_value( HKEY hkey_root, LPCWSTR key, LPCWSTR value, BOOL delete_key )
|
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD num_subkeys, num_values;
|
|
|
|
|
|
|
|
if (delete_key)
|
|
|
|
{
|
|
|
|
if ((res = RegDeleteTreeW( hkey_root, key )))
|
|
|
|
{
|
2010-11-03 15:05:22 +01:00
|
|
|
TRACE("Failed to delete key %s (%d)\n", debugstr_w(key), res);
|
2010-02-25 15:17:11 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(res = RegOpenKeyW( hkey_root, key, &hkey )))
|
|
|
|
{
|
|
|
|
if ((res = RegDeleteValueW( hkey, value )))
|
|
|
|
{
|
2010-11-03 15:05:22 +01:00
|
|
|
TRACE("Failed to delete value %s (%d)\n", debugstr_w(value), res);
|
2010-02-25 15:17:11 +01:00
|
|
|
}
|
|
|
|
res = RegQueryInfoKeyW( hkey, NULL, NULL, NULL, &num_subkeys, NULL, NULL, &num_values,
|
|
|
|
NULL, NULL, NULL, NULL );
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
if (!res && !num_subkeys && !num_values)
|
|
|
|
{
|
|
|
|
TRACE("Removing empty key %s\n", debugstr_w(key));
|
|
|
|
RegDeleteKeyW( hkey_root, key );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2010-11-03 15:05:22 +01:00
|
|
|
TRACE("Failed to open key %s (%d)\n", debugstr_w(key), res);
|
2010-02-25 15:17:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static UINT ITERATE_RemoveRegistryValuesOnUninstall( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR component, name, key_str, root_key_str;
|
2010-10-13 14:23:34 +02:00
|
|
|
LPWSTR deformated_key, deformated_name, ui_key_str, keypath;
|
2010-02-25 15:17:11 +01:00
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
BOOL delete_key = FALSE;
|
|
|
|
HKEY hkey_root;
|
|
|
|
UINT size;
|
|
|
|
INT root;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 2, 0, 0, 0 );
|
2010-02-25 15:17:11 +01:00
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 6 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-02-25 15:17:11 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:00 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-02-25 15:17:11 +01:00
|
|
|
{
|
2011-05-24 10:51:00 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-02-25 15:17:11 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = MSI_RecordGetString( row, 4 );
|
|
|
|
if (MSI_RecordIsNull( row, 5 ) && name )
|
|
|
|
{
|
|
|
|
if (name[0] == '+' && !name[1])
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
else if ((name[0] == '-' && !name[1]) || (name[0] == '*' && !name[1]))
|
|
|
|
{
|
|
|
|
delete_key = TRUE;
|
|
|
|
name = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
root = MSI_RecordGetInteger( row, 2 );
|
|
|
|
key_str = MSI_RecordGetString( row, 3 );
|
|
|
|
|
|
|
|
root_key_str = get_root_key( package, root, &hkey_root );
|
|
|
|
if (!root_key_str)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
deformat_string( package, key_str, &deformated_key );
|
|
|
|
size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1;
|
|
|
|
ui_key_str = msi_alloc( size * sizeof(WCHAR) );
|
|
|
|
strcpyW( ui_key_str, root_key_str );
|
|
|
|
strcatW( ui_key_str, deformated_key );
|
|
|
|
|
|
|
|
deformat_string( package, name, &deformated_name );
|
|
|
|
|
2010-10-13 14:23:34 +02:00
|
|
|
keypath = get_keypath( package, hkey_root, deformated_key );
|
2010-02-25 15:17:11 +01:00
|
|
|
msi_free( deformated_key );
|
2010-10-13 14:23:34 +02:00
|
|
|
delete_reg_key_or_value( hkey_root, keypath, deformated_name, delete_key );
|
|
|
|
msi_free( keypath );
|
2010-02-25 15:17:11 +01:00
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, ui_key_str );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, deformated_name );
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveRegistryValues, uirow );
|
2010-02-25 15:17:11 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
msi_free( ui_key_str );
|
|
|
|
msi_free( deformated_name );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_RemoveRegistryValuesOnInstall( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR component, name, key_str, root_key_str;
|
2010-10-13 14:23:34 +02:00
|
|
|
LPWSTR deformated_key, deformated_name, ui_key_str, keypath;
|
2010-02-25 15:17:11 +01:00
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
BOOL delete_key = FALSE;
|
|
|
|
HKEY hkey_root;
|
|
|
|
UINT size;
|
|
|
|
INT root;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 2, 0, 0, 0 );
|
2010-02-25 15:17:11 +01:00
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 5 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-02-25 15:17:11 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:00 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-02-25 15:17:11 +01:00
|
|
|
{
|
2011-05-24 10:51:00 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-02-25 15:17:11 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((name = MSI_RecordGetString( row, 4 )))
|
|
|
|
{
|
|
|
|
if (name[0] == '-' && !name[1])
|
|
|
|
{
|
|
|
|
delete_key = TRUE;
|
|
|
|
name = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
root = MSI_RecordGetInteger( row, 2 );
|
|
|
|
key_str = MSI_RecordGetString( row, 3 );
|
|
|
|
|
|
|
|
root_key_str = get_root_key( package, root, &hkey_root );
|
|
|
|
if (!root_key_str)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
deformat_string( package, key_str, &deformated_key );
|
|
|
|
size = strlenW( deformated_key ) + strlenW( root_key_str ) + 1;
|
|
|
|
ui_key_str = msi_alloc( size * sizeof(WCHAR) );
|
|
|
|
strcpyW( ui_key_str, root_key_str );
|
|
|
|
strcatW( ui_key_str, deformated_key );
|
|
|
|
|
|
|
|
deformat_string( package, name, &deformated_name );
|
|
|
|
|
2010-10-13 14:23:34 +02:00
|
|
|
keypath = get_keypath( package, hkey_root, deformated_key );
|
2010-02-25 15:17:11 +01:00
|
|
|
msi_free( deformated_key );
|
2010-10-13 14:23:34 +02:00
|
|
|
delete_reg_key_or_value( hkey_root, keypath, deformated_name, delete_key );
|
|
|
|
msi_free( keypath );
|
2010-02-25 15:17:11 +01:00
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, ui_key_str );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, deformated_name );
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveRegistryValues, uirow );
|
2010-02-25 15:17:11 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
msi_free( ui_key_str );
|
|
|
|
msi_free( deformated_name );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveRegistryValues( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR registry_query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','R','e','g','i','s','t','r','y','`',0 };
|
|
|
|
static const WCHAR remove_registry_query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','R','e','m','o','v','e','R','e','g','i','s','t','r','y','`',0 };
|
|
|
|
|
|
|
|
/* increment progress bar each time action data is sent */
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 1, REG_PROGRESS_VALUE, 1, 0 );
|
2010-02-25 15:17:11 +01:00
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, registry_query, &view );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnUninstall, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, remove_registry_query, &view );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveRegistryValuesOnInstall, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_InstallInitialize(MSIPACKAGE *package)
|
2004-07-04 02:36:58 +02:00
|
|
|
{
|
2005-05-27 21:24:22 +02:00
|
|
|
package->script->CurrentlyScripting = TRUE;
|
|
|
|
|
2004-07-04 02:36:58 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-12-27 20:02:59 +01:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_InstallValidate(MSIPACKAGE *package)
|
2004-07-04 02:36:58 +02:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2004-07-04 02:36:58 +02:00
|
|
|
DWORD progress = 0;
|
2005-01-03 21:00:13 +01:00
|
|
|
DWORD total = 0;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR q1[]=
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','R','e','g','i','s','t','r','y','`',0};
|
2004-07-04 02:36:58 +02:00
|
|
|
UINT rc;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIQUERY * view;
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2005-09-21 12:20:03 +02:00
|
|
|
TRACE("InstallValidate\n");
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, q1, &view);
|
2005-09-21 12:20:03 +02:00
|
|
|
if (rc == ERROR_SUCCESS)
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2005-09-21 12:20:03 +02:00
|
|
|
MSI_IterateRecords( view, &progress, NULL, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
total += progress * REG_PROGRESS_VALUE;
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
|
|
|
|
total += COMPONENT_PROGRESS_VALUE;
|
2005-09-21 12:20:03 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
|
|
|
total += file->FileSize;
|
2005-09-21 12:20:03 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 0, total, 0, 0 );
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-05-13 15:56:39 +02:00
|
|
|
{
|
2010-07-21 09:47:03 +02:00
|
|
|
TRACE("Feature: %s Installed %d Request %d Action %d\n",
|
|
|
|
debugstr_w(feature->Feature), feature->Installed,
|
|
|
|
feature->ActionRequest, feature->Action);
|
2005-05-13 15:56:39 +02:00
|
|
|
}
|
|
|
|
|
2004-07-04 02:36:58 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-06-22 20:03:08 +02:00
|
|
|
static UINT ITERATE_LaunchConditions(MSIRECORD *row, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2005-06-22 20:03:08 +02:00
|
|
|
LPCWSTR cond = NULL;
|
|
|
|
LPCWSTR message = NULL;
|
2007-06-29 00:38:58 +02:00
|
|
|
UINT r;
|
|
|
|
|
2005-06-22 20:03:08 +02:00
|
|
|
static const WCHAR title[]=
|
|
|
|
{'I','n','s','t','a','l','l',' ','F','a', 'i','l','e','d',0};
|
|
|
|
|
|
|
|
cond = MSI_RecordGetString(row,1);
|
|
|
|
|
2007-06-29 00:38:58 +02:00
|
|
|
r = MSI_EvaluateConditionW(package,cond);
|
|
|
|
if (r == MSICONDITION_FALSE)
|
2005-06-22 20:03:08 +02:00
|
|
|
{
|
2007-06-29 00:38:58 +02:00
|
|
|
if ((gUILevel & INSTALLUILEVEL_MASK) != INSTALLUILEVEL_NONE)
|
|
|
|
{
|
|
|
|
LPWSTR deformated;
|
|
|
|
message = MSI_RecordGetString(row,2);
|
|
|
|
deformat_string(package,message,&deformated);
|
|
|
|
MessageBoxW(NULL,deformated,title,MB_OK);
|
|
|
|
msi_free(deformated);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_INSTALL_FAILURE;
|
2005-06-22 20:03:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_LaunchConditions(MSIPACKAGE *package)
|
2004-07-06 20:47:09 +02:00
|
|
|
{
|
|
|
|
UINT rc;
|
2004-07-19 21:35:05 +02:00
|
|
|
MSIQUERY * view = NULL;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','L','a','u','n','c','h','C','o','n','d','i','t','i','o','n','`',0};
|
2004-07-06 20:47:09 +02:00
|
|
|
|
|
|
|
TRACE("Checking launch conditions\n");
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
2004-07-06 20:47:09 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2004-07-20 03:22:37 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-06 20:47:09 +02:00
|
|
|
|
2005-06-22 20:03:08 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_LaunchConditions, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2005-06-22 20:03:08 +02:00
|
|
|
|
2004-07-06 20:47:09 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
|
2004-07-06 20:50:02 +02:00
|
|
|
{
|
|
|
|
|
2005-09-12 14:07:15 +02:00
|
|
|
if (!cmp->KeyPath)
|
2011-05-02 16:03:32 +02:00
|
|
|
return strdupW( msi_get_target_folder( package, cmp->Directory ) );
|
2005-09-12 14:07:15 +02:00
|
|
|
|
2005-02-24 13:47:43 +01:00
|
|
|
if (cmp->Attributes & msidbComponentAttributesRegistryKeyPath)
|
2004-07-06 20:50:02 +02:00
|
|
|
{
|
2005-01-17 14:40:39 +01:00
|
|
|
MSIRECORD * row = 0;
|
2005-06-02 12:29:57 +02:00
|
|
|
UINT root,len;
|
2005-06-09 22:30:59 +02:00
|
|
|
LPWSTR deformated,buffer,deformated_name;
|
|
|
|
LPCWSTR key,name;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','R','e','g','i','s','t','r','y','`',' ',
|
|
|
|
'W','H','E','R','E',' ', '`','R','e','g','i','s','t','r','y','`',
|
|
|
|
' ','=',' ' ,'\'','%','s','\'',0 };
|
2005-02-24 13:47:43 +01:00
|
|
|
static const WCHAR fmt[]={'%','0','2','i',':','\\','%','s','\\',0};
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR fmt2[]=
|
|
|
|
{'%','0','2','i',':','\\','%','s','\\','%','s',0};
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2005-06-02 12:29:57 +02:00
|
|
|
row = MSI_QueryGetRecord(package->db, ExecSeqQuery,cmp->KeyPath);
|
|
|
|
if (!row)
|
2005-01-17 14:40:39 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
root = MSI_RecordGetInteger(row,2);
|
2005-06-09 22:30:59 +02:00
|
|
|
key = MSI_RecordGetString(row, 3);
|
|
|
|
name = MSI_RecordGetString(row, 4);
|
2005-01-17 14:40:39 +01:00
|
|
|
deformat_string(package, key , &deformated);
|
|
|
|
deformat_string(package, name, &deformated_name);
|
|
|
|
|
2005-03-08 17:44:51 +01:00
|
|
|
len = strlenW(deformated) + 6;
|
2005-01-17 14:40:39 +01:00
|
|
|
if (deformated_name)
|
|
|
|
len+=strlenW(deformated_name);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
buffer = msi_alloc( len *sizeof(WCHAR));
|
2005-01-17 14:40:39 +01:00
|
|
|
|
|
|
|
if (deformated_name)
|
|
|
|
sprintfW(buffer,fmt2,root,deformated,deformated_name);
|
|
|
|
else
|
|
|
|
sprintfW(buffer,fmt,root,deformated);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(deformated);
|
|
|
|
msi_free(deformated_name);
|
2005-01-17 14:40:39 +01:00
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
2005-02-24 13:47:43 +01:00
|
|
|
else if (cmp->Attributes & msidbComponentAttributesODBCDataSource)
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
|
|
|
FIXME("UNIMPLEMENTED keypath as ODBC Source\n");
|
2004-12-22 19:46:17 +01:00
|
|
|
return NULL;
|
2004-07-06 20:50:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
MSIFILE *file = msi_get_loaded_file( package, cmp->KeyPath );
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
if (file)
|
|
|
|
return strdupW( file->TargetPath );
|
2004-07-06 20:50:02 +02:00
|
|
|
}
|
2004-12-22 19:46:17 +01:00
|
|
|
return NULL;
|
2004-07-06 20:50:02 +02:00
|
|
|
}
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static HKEY openSharedDLLsKey(void)
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
|
|
|
HKEY hkey=0;
|
2005-03-01 12:45:19 +01:00
|
|
|
static const WCHAR path[] =
|
|
|
|
{'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'S','h','a','r','e','d','D','L','L','s',0};
|
2005-02-24 13:47:43 +01:00
|
|
|
|
|
|
|
RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey);
|
|
|
|
return hkey;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
DWORD count=0;
|
|
|
|
DWORD type;
|
|
|
|
DWORD sz = sizeof(count);
|
|
|
|
DWORD rc;
|
|
|
|
|
|
|
|
hkey = openSharedDLLsKey();
|
|
|
|
rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
count = 0;
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
hkey = openSharedDLLsKey();
|
|
|
|
if (count > 0)
|
2005-09-15 16:58:38 +02:00
|
|
|
msi_reg_set_val_dword( hkey, path, count );
|
2005-02-24 13:47:43 +01:00
|
|
|
else
|
|
|
|
RegDeleteValueW(hkey,path);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-02-24 13:47:43 +01:00
|
|
|
INT count = 0;
|
|
|
|
BOOL write = FALSE;
|
|
|
|
|
|
|
|
/* only refcount DLLs */
|
2005-09-12 14:07:15 +02:00
|
|
|
if (comp->KeyPath == NULL ||
|
2011-03-16 09:22:48 +01:00
|
|
|
comp->assembly ||
|
2005-08-22 11:15:23 +02:00
|
|
|
comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
|
|
|
|
comp->Attributes & msidbComponentAttributesODBCDataSource)
|
2005-02-24 13:47:43 +01:00
|
|
|
write = FALSE;
|
|
|
|
else
|
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
count = ACTION_GetSharedDLLsCount( comp->FullKeypath);
|
2005-02-24 13:47:43 +01:00
|
|
|
write = (count > 0);
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
if (comp->Attributes & msidbComponentAttributesSharedDllRefCount)
|
2005-02-24 13:47:43 +01:00
|
|
|
write = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* increment counts */
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-19 12:03:11 +02:00
|
|
|
ComponentList *cl;
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2010-02-16 11:45:05 +01:00
|
|
|
if (feature->ActionRequest != INSTALLSTATE_LOCAL)
|
2005-02-24 13:47:43 +01:00
|
|
|
continue;
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
if ( cl->component == comp )
|
2005-02-24 13:47:43 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2005-08-23 12:03:17 +02:00
|
|
|
|
2005-02-24 13:47:43 +01:00
|
|
|
/* decrement counts */
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-19 12:03:11 +02:00
|
|
|
ComponentList *cl;
|
|
|
|
|
2010-02-16 11:45:05 +01:00
|
|
|
if (feature->ActionRequest != INSTALLSTATE_ABSENT)
|
2005-02-24 13:47:43 +01:00
|
|
|
continue;
|
|
|
|
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
if ( cl->component == comp )
|
2005-02-24 13:47:43 +01:00
|
|
|
count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ref count all the files in the component */
|
|
|
|
if (write)
|
2005-08-23 12:03:17 +02:00
|
|
|
{
|
|
|
|
MSIFILE *file;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
2005-02-24 13:47:43 +01:00
|
|
|
{
|
2005-08-23 12:03:17 +02:00
|
|
|
if (file->Component == comp)
|
|
|
|
ACTION_WriteSharedDLLsCount( file->TargetPath, count );
|
2005-02-24 13:47:43 +01:00
|
|
|
}
|
2005-08-23 12:03:17 +02:00
|
|
|
}
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2008-04-07 21:44:23 +02:00
|
|
|
/* add a count for permanent */
|
2005-08-22 11:15:23 +02:00
|
|
|
if (comp->Attributes & msidbComponentAttributesPermanent)
|
2005-02-24 13:47:43 +01:00
|
|
|
count ++;
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
comp->RefCount = count;
|
2005-02-24 13:47:43 +01:00
|
|
|
|
|
|
|
if (write)
|
2005-08-22 11:15:23 +02:00
|
|
|
ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount );
|
2005-02-24 13:47:43 +01:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
|
2004-07-06 20:50:02 +02:00
|
|
|
{
|
2005-01-25 12:05:37 +01:00
|
|
|
WCHAR squished_pc[GUID_SIZE];
|
|
|
|
WCHAR squished_cc[GUID_SIZE];
|
2004-07-06 20:50:02 +02:00
|
|
|
UINT rc;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2008-06-18 07:49:42 +02:00
|
|
|
HKEY hkey;
|
2004-07-06 20:50:02 +02:00
|
|
|
|
2007-11-01 09:12:41 +01:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-07-07 22:27:06 +02:00
|
|
|
squash_guid(package->ProductCode,squished_pc);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 1, COMPONENT_PROGRESS_VALUE, 1, 0 );
|
2005-08-22 11:15:23 +02:00
|
|
|
|
2010-07-23 09:42:37 +02:00
|
|
|
msi_set_sourcedir_props(package, FALSE);
|
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
|
2004-07-06 20:50:02 +02:00
|
|
|
{
|
2006-03-09 06:21:37 +01:00
|
|
|
MSIRECORD * uirow;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_progress( package, 2, 0, 0, 0 );
|
2006-03-09 06:21:37 +01:00
|
|
|
if (!comp->ComponentId)
|
|
|
|
continue;
|
2004-07-06 20:50:02 +02:00
|
|
|
|
2006-03-09 06:21:37 +01:00
|
|
|
squash_guid(comp->ComponentId,squished_cc);
|
2006-11-29 08:36:58 +01:00
|
|
|
|
2006-03-09 06:21:37 +01:00
|
|
|
msi_free(comp->FullKeypath);
|
2011-03-09 08:58:46 +01:00
|
|
|
if (comp->assembly)
|
|
|
|
{
|
|
|
|
const WCHAR prefixW[] = {'<','\\',0};
|
|
|
|
DWORD len = strlenW( prefixW ) + strlenW( comp->assembly->display_name );
|
|
|
|
|
|
|
|
comp->FullKeypath = msi_alloc( (len + 1) * sizeof(WCHAR) );
|
|
|
|
if (comp->FullKeypath)
|
|
|
|
{
|
|
|
|
strcpyW( comp->FullKeypath, prefixW );
|
|
|
|
strcatW( comp->FullKeypath, comp->assembly->display_name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else comp->FullKeypath = resolve_keypath( package, comp );
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2006-03-09 06:21:37 +01:00
|
|
|
ACTION_RefCountComponent( package, comp );
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2010-07-21 09:47:03 +02:00
|
|
|
TRACE("Component %s (%s), Keypath=%s, RefCount=%i Request=%u\n",
|
2005-08-22 11:15:23 +02:00
|
|
|
debugstr_w(comp->Component),
|
2005-05-18 19:46:12 +02:00
|
|
|
debugstr_w(squished_cc),
|
2006-03-09 06:21:37 +01:00
|
|
|
debugstr_w(comp->FullKeypath),
|
2010-07-21 09:47:03 +02:00
|
|
|
comp->RefCount,
|
|
|
|
comp->ActionRequest);
|
2008-08-21 09:14:26 +02:00
|
|
|
|
2011-05-24 10:51:00 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action == INSTALLSTATE_LOCAL ||
|
|
|
|
comp->Action == INSTALLSTATE_SOURCE)
|
2006-03-09 06:21:37 +01:00
|
|
|
{
|
2008-06-18 07:51:13 +02:00
|
|
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
2011-03-09 08:58:29 +01:00
|
|
|
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, szLocalSid, &hkey, TRUE);
|
2008-06-18 07:51:13 +02:00
|
|
|
else
|
2011-03-09 08:58:29 +01:00
|
|
|
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, NULL, &hkey, TRUE);
|
2008-06-18 07:51:13 +02:00
|
|
|
|
2008-06-18 07:49:42 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
continue;
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2006-03-09 06:21:37 +01:00
|
|
|
if (comp->Attributes & msidbComponentAttributesPermanent)
|
2004-12-22 19:46:17 +01:00
|
|
|
{
|
2006-03-09 06:21:37 +01:00
|
|
|
static const WCHAR szPermKey[] =
|
|
|
|
{ '0','0','0','0','0','0','0','0','0','0','0','0',
|
|
|
|
'0','0','0','0','0','0','0','0','0','0','0','0',
|
|
|
|
'0','0','0','0','0','0','0','0',0 };
|
2005-05-13 15:56:39 +02:00
|
|
|
|
2008-06-18 07:49:42 +02:00
|
|
|
msi_reg_set_val_str(hkey, szPermKey, comp->FullKeypath);
|
2006-03-09 06:21:37 +01:00
|
|
|
}
|
2005-05-13 15:56:39 +02:00
|
|
|
|
2011-05-24 10:51:00 +02:00
|
|
|
if (comp->Action == INSTALLSTATE_LOCAL)
|
2008-08-21 09:14:26 +02:00
|
|
|
msi_reg_set_val_str(hkey, squished_pc, comp->FullKeypath);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MSIFILE *file;
|
|
|
|
MSIRECORD *row;
|
|
|
|
LPWSTR ptr, ptr2;
|
|
|
|
WCHAR source[MAX_PATH];
|
|
|
|
WCHAR base[MAX_PATH];
|
2008-10-07 05:26:20 +02:00
|
|
|
LPWSTR sourcepath;
|
2008-08-21 09:14:26 +02:00
|
|
|
|
|
|
|
static const WCHAR fmt[] = {'%','0','2','d','\\',0};
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
|
|
|
'`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ',
|
|
|
|
'>','=',' ','%','i',' ','O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','D','i','s','k','I','d','`',0};
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!comp->KeyPath || !(file = msi_get_loaded_file(package, comp->KeyPath)))
|
2008-08-21 09:14:26 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
row = MSI_QueryGetRecord(package->db, query, file->Sequence);
|
|
|
|
sprintfW(source, fmt, MSI_RecordGetInteger(row, 1));
|
|
|
|
ptr2 = strrchrW(source, '\\') + 1;
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
|
|
|
|
lstrcpyW(base, package->PackagePath);
|
|
|
|
ptr = strrchrW(base, '\\');
|
|
|
|
*(ptr + 1) = '\0';
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
sourcepath = msi_resolve_file_source(package, file);
|
2008-10-07 05:26:20 +02:00
|
|
|
ptr = sourcepath + lstrlenW(base);
|
2008-08-21 09:14:26 +02:00
|
|
|
lstrcpyW(ptr2, ptr);
|
2008-10-07 05:26:20 +02:00
|
|
|
msi_free(sourcepath);
|
2008-08-21 09:14:26 +02:00
|
|
|
|
|
|
|
msi_reg_set_val_str(hkey, squished_pc, source);
|
|
|
|
}
|
2008-06-18 07:49:42 +02:00
|
|
|
RegCloseKey(hkey);
|
2006-03-09 06:21:37 +01:00
|
|
|
}
|
2011-05-24 10:51:00 +02:00
|
|
|
else if (comp->Action == INSTALLSTATE_ABSENT)
|
2008-06-18 07:51:13 +02:00
|
|
|
{
|
|
|
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
2008-12-09 07:21:19 +01:00
|
|
|
MSIREG_DeleteUserDataComponentKey(comp->ComponentId, szLocalSid);
|
2008-06-18 07:51:13 +02:00
|
|
|
else
|
2008-12-09 07:21:19 +01:00
|
|
|
MSIREG_DeleteUserDataComponentKey(comp->ComponentId, NULL);
|
2008-06-18 07:51:13 +02:00
|
|
|
}
|
2006-11-29 08:36:58 +01:00
|
|
|
|
|
|
|
/* UI stuff */
|
|
|
|
uirow = MSI_CreateRecord(3);
|
|
|
|
MSI_RecordSetStringW(uirow,1,package->ProductCode);
|
|
|
|
MSI_RecordSetStringW(uirow,2,comp->ComponentId);
|
|
|
|
MSI_RecordSetStringW(uirow,3,comp->FullKeypath);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szProcessComponents, uirow );
|
2006-11-29 08:36:58 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
}
|
2008-06-18 07:49:42 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-06 20:50:02 +02:00
|
|
|
}
|
|
|
|
|
2005-03-30 12:19:08 +02:00
|
|
|
typedef struct {
|
|
|
|
CLSID clsid;
|
|
|
|
LPWSTR source;
|
|
|
|
|
|
|
|
LPWSTR path;
|
|
|
|
ITypeLib *ptLib;
|
|
|
|
} typelib_struct;
|
|
|
|
|
2005-06-07 22:29:51 +02:00
|
|
|
static BOOL CALLBACK Typelib_EnumResNameProc( HMODULE hModule, LPCWSTR lpszType,
|
2005-03-30 12:19:08 +02:00
|
|
|
LPWSTR lpszName, LONG_PTR lParam)
|
|
|
|
{
|
|
|
|
TLIBATTR *attr;
|
|
|
|
typelib_struct *tl_struct = (typelib_struct*) lParam;
|
|
|
|
static const WCHAR fmt[] = {'%','s','\\','%','i',0};
|
|
|
|
int sz;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
if (!IS_INTRESOURCE(lpszName))
|
|
|
|
{
|
|
|
|
ERR("Not Int Resource Name %s\n",debugstr_w(lpszName));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
sz = strlenW(tl_struct->source)+4;
|
|
|
|
sz *= sizeof(WCHAR);
|
|
|
|
|
2006-05-25 04:41:39 +02:00
|
|
|
if ((INT_PTR)lpszName == 1)
|
2005-06-02 17:13:57 +02:00
|
|
|
tl_struct->path = strdupW(tl_struct->source);
|
|
|
|
else
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
tl_struct->path = msi_alloc(sz);
|
2005-06-02 17:13:57 +02:00
|
|
|
sprintfW(tl_struct->path,fmt,tl_struct->source, lpszName);
|
|
|
|
}
|
2005-03-30 12:19:08 +02:00
|
|
|
|
|
|
|
TRACE("trying %s\n", debugstr_w(tl_struct->path));
|
|
|
|
res = LoadTypeLib(tl_struct->path,&tl_struct->ptLib);
|
2008-10-08 01:33:34 +02:00
|
|
|
if (FAILED(res))
|
2005-03-30 12:19:08 +02:00
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(tl_struct->path);
|
2005-03-30 12:19:08 +02:00
|
|
|
tl_struct->path = NULL;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ITypeLib_GetLibAttr(tl_struct->ptLib, &attr);
|
|
|
|
if (IsEqualGUID(&(tl_struct->clsid),&(attr->guid)))
|
|
|
|
{
|
|
|
|
ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(tl_struct->path);
|
2005-03-30 12:19:08 +02:00
|
|
|
tl_struct->path = NULL;
|
|
|
|
|
|
|
|
ITypeLib_ReleaseTLibAttr(tl_struct->ptLib, attr);
|
|
|
|
ITypeLib_Release(tl_struct->ptLib);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-06-22 20:27:34 +02:00
|
|
|
static UINT ITERATE_RegisterTypeLibraries(MSIRECORD *row, LPVOID param)
|
2004-07-06 20:51:16 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2005-06-22 20:27:34 +02:00
|
|
|
LPCWSTR component;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2005-06-22 20:27:34 +02:00
|
|
|
typelib_struct tl_struct;
|
2008-07-29 05:19:47 +02:00
|
|
|
ITypeLib *tlib;
|
2005-06-22 20:27:34 +02:00
|
|
|
HMODULE module;
|
2008-07-29 05:19:47 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2005-06-22 20:27:34 +02:00
|
|
|
component = MSI_RecordGetString(row,3);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package,component);
|
2005-08-22 11:15:23 +02:00
|
|
|
if (!comp)
|
2004-07-20 03:22:37 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2004-07-06 20:51:16 +02:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2005-06-22 20:27:34 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
if (!comp->KeyPath || !(file = msi_get_loaded_file( package, comp->KeyPath )))
|
2010-11-03 15:04:49 +01:00
|
|
|
{
|
|
|
|
TRACE("component has no key path\n");
|
2005-06-22 20:27:34 +02:00
|
|
|
return ERROR_SUCCESS;
|
2010-11-03 15:04:49 +01:00
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRegisterTypeLibraries, row );
|
2010-02-16 11:44:34 +01:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
module = LoadLibraryExW( file->TargetPath, NULL, LOAD_LIBRARY_AS_DATAFILE );
|
2005-10-27 14:36:12 +02:00
|
|
|
if (module)
|
2005-06-22 20:27:34 +02:00
|
|
|
{
|
2005-10-27 14:36:12 +02:00
|
|
|
LPCWSTR guid;
|
|
|
|
guid = MSI_RecordGetString(row,1);
|
2010-03-26 18:59:50 +01:00
|
|
|
CLSIDFromString((LPCWSTR)guid, &tl_struct.clsid);
|
2005-08-23 12:03:17 +02:00
|
|
|
tl_struct.source = strdupW( file->TargetPath );
|
2005-06-22 20:27:34 +02:00
|
|
|
tl_struct.path = NULL;
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2005-06-22 20:27:34 +02:00
|
|
|
EnumResourceNamesW(module, szTYPELIB, Typelib_EnumResNameProc,
|
|
|
|
(LONG_PTR)&tl_struct);
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2005-10-27 14:36:12 +02:00
|
|
|
if (tl_struct.path)
|
2004-07-06 20:51:16 +02:00
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
LPCWSTR helpid, help_path = NULL;
|
2005-06-22 20:27:34 +02:00
|
|
|
HRESULT res;
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2005-06-22 20:27:34 +02:00
|
|
|
helpid = MSI_RecordGetString(row,6);
|
2004-07-06 20:51:16 +02:00
|
|
|
|
2011-05-02 16:03:32 +02:00
|
|
|
if (helpid) help_path = msi_get_target_folder( package, helpid );
|
|
|
|
res = RegisterTypeLib( tl_struct.ptLib, tl_struct.path, (OLECHAR *)help_path );
|
2004-12-22 16:25:30 +01:00
|
|
|
|
2008-10-08 01:33:34 +02:00
|
|
|
if (FAILED(res))
|
2011-05-02 16:03:32 +02:00
|
|
|
ERR("Failed to register type library %s\n", debugstr_w(tl_struct.path));
|
2005-06-22 20:27:34 +02:00
|
|
|
else
|
|
|
|
TRACE("Registered %s\n", debugstr_w(tl_struct.path));
|
|
|
|
|
|
|
|
ITypeLib_Release(tl_struct.ptLib);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(tl_struct.path);
|
2004-07-06 20:51:16 +02:00
|
|
|
}
|
2011-05-02 16:03:32 +02:00
|
|
|
else ERR("Failed to load type library %s\n", debugstr_w(tl_struct.source));
|
2005-06-22 20:27:34 +02:00
|
|
|
|
|
|
|
FreeLibrary(module);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(tl_struct.source);
|
2004-07-06 20:51:16 +02:00
|
|
|
}
|
2005-06-22 20:27:34 +02:00
|
|
|
else
|
2008-07-29 05:19:47 +02:00
|
|
|
{
|
|
|
|
hr = LoadTypeLibEx(file->TargetPath, REGKIND_REGISTER, &tlib);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to load type library: %08x\n", hr);
|
2010-02-12 10:33:00 +01:00
|
|
|
return ERROR_INSTALL_FAILURE;
|
2008-07-29 05:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ITypeLib_Release(tlib);
|
|
|
|
}
|
2005-06-22 20:27:34 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RegisterTypeLibraries(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* OK this is a bit confusing.. I am given a _Component key and I believe
|
|
|
|
* that the file that is being registered as a type library is the "key file
|
|
|
|
* of that component" which I interpret to mean "The file in the KeyPath of
|
|
|
|
* that component".
|
|
|
|
*/
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','T','y','p','e','L','i','b','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_RegisterTypeLibraries, package);
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2004-07-06 20:51:16 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-12 10:32:35 +01:00
|
|
|
static UINT ITERATE_UnregisterTypeLibraries( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR component, guid;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
GUID libid;
|
|
|
|
UINT version;
|
|
|
|
LCID language;
|
|
|
|
SYSKIND syskind;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 3 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-02-12 10:32:35 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-02-12 10:32:35 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-02-12 10:32:35 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szUnregisterTypeLibraries, row );
|
2010-02-16 11:44:34 +01:00
|
|
|
|
2010-02-12 10:32:35 +01:00
|
|
|
guid = MSI_RecordGetString( row, 1 );
|
2010-03-26 18:59:50 +01:00
|
|
|
CLSIDFromString( (LPCWSTR)guid, &libid );
|
2010-02-12 10:32:35 +01:00
|
|
|
version = MSI_RecordGetInteger( row, 4 );
|
|
|
|
language = MSI_RecordGetInteger( row, 2 );
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
syskind = SYS_WIN64;
|
|
|
|
#else
|
|
|
|
syskind = SYS_WIN32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
hr = UnRegisterTypeLib( &libid, (version >> 8) & 0xffff, version & 0xff, language, syskind );
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to unregister typelib: %08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_UnregisterTypeLibraries( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','T','y','p','e','L','i','b','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_UnregisterTypeLibraries, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
static WCHAR *get_link_file( MSIPACKAGE *package, MSIRECORD *row )
|
|
|
|
{
|
|
|
|
static const WCHAR szlnk[] = {'.','l','n','k',0};
|
2011-05-02 16:03:32 +02:00
|
|
|
LPCWSTR directory, extension, link_folder;
|
|
|
|
LPWSTR link_file, filename;
|
2010-02-15 10:20:01 +01:00
|
|
|
|
|
|
|
directory = MSI_RecordGetString( row, 2 );
|
2011-05-02 16:03:32 +02:00
|
|
|
link_folder = msi_get_target_folder( package, directory );
|
2010-02-15 10:20:01 +01:00
|
|
|
|
|
|
|
/* may be needed because of a bug somewhere else */
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_create_full_path( link_folder );
|
2010-02-15 10:20:01 +01:00
|
|
|
|
|
|
|
filename = msi_dup_record_field( row, 3 );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_reduce_to_long_filename( filename );
|
2010-02-15 10:20:01 +01:00
|
|
|
|
|
|
|
extension = strchrW( filename, '.' );
|
|
|
|
if (!extension || strcmpiW( extension, szlnk ))
|
|
|
|
{
|
|
|
|
int len = strlenW( filename );
|
|
|
|
filename = msi_realloc( filename, len * sizeof(WCHAR) + sizeof(szlnk) );
|
|
|
|
memcpy( filename + len, szlnk, sizeof(szlnk) );
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
link_file = msi_build_directory_name( 2, link_folder, filename );
|
2010-02-15 10:20:01 +01:00
|
|
|
msi_free( filename );
|
|
|
|
|
|
|
|
return link_file;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
WCHAR *msi_build_icon_path( MSIPACKAGE *package, const WCHAR *icon_name )
|
|
|
|
{
|
|
|
|
static const WCHAR szMicrosoft[] = {'M','i','c','r','o','s','o','f','t','\\',0};
|
|
|
|
static const WCHAR szInstaller[] = {'I','n','s','t','a','l','l','e','r','\\',0};
|
|
|
|
WCHAR *folder, *dest, *path;
|
|
|
|
|
|
|
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
folder = msi_dup_property( package->db, szWindowsFolder );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR *appdata = msi_dup_property( package->db, szAppDataFolder );
|
|
|
|
folder = msi_build_directory_name( 2, appdata, szMicrosoft );
|
|
|
|
msi_free( appdata );
|
|
|
|
}
|
|
|
|
dest = msi_build_directory_name( 3, folder, szInstaller, package->ProductCode );
|
|
|
|
msi_create_full_path( dest );
|
|
|
|
path = msi_build_directory_name( 2, dest, icon_name );
|
|
|
|
msi_free( folder );
|
|
|
|
msi_free( dest );
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
static UINT ITERATE_CreateShortcuts(MSIRECORD *row, LPVOID param)
|
2004-07-06 21:00:23 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-02-15 10:20:01 +01:00
|
|
|
LPWSTR link_file, deformated, path;
|
|
|
|
LPCWSTR component, target;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2006-05-24 10:41:04 +02:00
|
|
|
IShellLinkW *sl = NULL;
|
|
|
|
IPersistFile *pf = NULL;
|
2004-07-06 21:00:23 +02:00
|
|
|
HRESULT res;
|
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
component = MSI_RecordGetString(row, 4);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2005-08-22 11:15:23 +02:00
|
|
|
if (!comp)
|
2004-07-20 03:22:37 +02:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2004-07-06 21:00:23 +02:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2005-06-24 13:58:21 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szCreateShortcuts, row );
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
res = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkW, (LPVOID *) &sl );
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2006-05-24 10:41:04 +02:00
|
|
|
if (FAILED( res ))
|
2005-06-24 13:58:21 +02:00
|
|
|
{
|
2006-05-24 10:41:04 +02:00
|
|
|
ERR("CLSID_ShellLink not available\n");
|
|
|
|
goto err;
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
res = IShellLinkW_QueryInterface( sl, &IID_IPersistFile,(LPVOID*) &pf );
|
2006-05-24 10:41:04 +02:00
|
|
|
if (FAILED( res ))
|
2005-06-24 13:58:21 +02:00
|
|
|
{
|
2006-05-24 10:41:04 +02:00
|
|
|
ERR("QueryInterface(IID_IPersistFile) failed\n");
|
|
|
|
goto err;
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
target = MSI_RecordGetString(row, 5);
|
|
|
|
if (strchrW(target, '['))
|
2006-02-22 17:31:00 +01:00
|
|
|
{
|
2010-02-15 10:20:01 +01:00
|
|
|
deformat_string(package, target, &deformated);
|
2005-06-24 13:58:21 +02:00
|
|
|
IShellLinkW_SetPath(sl,deformated);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(deformated);
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("poorly handled shortcut format, advertised shortcut\n");
|
2005-09-22 12:49:17 +02:00
|
|
|
IShellLinkW_SetPath(sl,comp->FullKeypath);
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,6))
|
|
|
|
{
|
2010-02-15 10:20:01 +01:00
|
|
|
LPCWSTR arguments = MSI_RecordGetString(row, 6);
|
|
|
|
deformat_string(package, arguments, &deformated);
|
2005-06-24 13:58:21 +02:00
|
|
|
IShellLinkW_SetArguments(sl,deformated);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(deformated);
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,7))
|
|
|
|
{
|
2010-02-15 10:20:01 +01:00
|
|
|
LPCWSTR description = MSI_RecordGetString(row, 7);
|
|
|
|
IShellLinkW_SetDescription(sl, description);
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2004-12-27 19:56:30 +01:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,8))
|
|
|
|
IShellLinkW_SetHotkey(sl,MSI_RecordGetInteger(row,8));
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,9))
|
|
|
|
{
|
|
|
|
INT index;
|
2010-02-15 10:20:01 +01:00
|
|
|
LPCWSTR icon = MSI_RecordGetString(row, 9);
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
path = msi_build_icon_path(package, icon);
|
2005-06-24 13:58:21 +02:00
|
|
|
index = MSI_RecordGetInteger(row,10);
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2006-08-03 21:24:10 +02:00
|
|
|
/* no value means 0 */
|
|
|
|
if (index == MSI_NULL_INTEGER)
|
|
|
|
index = 0;
|
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
IShellLinkW_SetIconLocation(sl, path, index);
|
|
|
|
msi_free(path);
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,11))
|
|
|
|
IShellLinkW_SetShowCmd(sl,MSI_RecordGetInteger(row,11));
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
if (!MSI_RecordIsNull(row,12))
|
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
LPCWSTR full_path, wkdir = MSI_RecordGetString( row, 12 );
|
|
|
|
full_path = msi_get_target_folder( package, wkdir );
|
|
|
|
if (full_path) IShellLinkW_SetWorkingDirectory( sl, full_path );
|
2005-06-24 13:58:21 +02:00
|
|
|
}
|
2010-02-15 10:20:01 +01:00
|
|
|
link_file = get_link_file(package, row);
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
TRACE("Writing shortcut to %s\n", debugstr_w(link_file));
|
|
|
|
IPersistFile_Save(pf, link_file, FALSE);
|
|
|
|
msi_free(link_file);
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2006-05-24 10:41:04 +02:00
|
|
|
err:
|
|
|
|
if (pf)
|
|
|
|
IPersistFile_Release( pf );
|
|
|
|
if (sl)
|
|
|
|
IShellLinkW_Release( sl );
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
static UINT ACTION_CreateShortcuts(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
HRESULT res;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR Query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','S','h','o','r','t','c','u','t','`',0};
|
2004-12-22 19:46:17 +01:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
res = CoInitialize( NULL );
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2005-06-24 13:58:21 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_CreateShortcuts, package);
|
|
|
|
msiobj_release(&view->hdr);
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2009-09-10 10:10:33 +02:00
|
|
|
if (SUCCEEDED(res))
|
|
|
|
CoUninitialize();
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2004-07-06 20:53:11 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-15 10:20:01 +01:00
|
|
|
static UINT ITERATE_RemoveShortcuts( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPWSTR link_file;
|
|
|
|
LPCWSTR component;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 4 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-02-15 10:20:01 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-02-15 10:20:01 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-02-15 10:20:01 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveShortcuts, row );
|
2010-02-15 10:20:01 +01:00
|
|
|
|
|
|
|
link_file = get_link_file( package, row );
|
|
|
|
|
|
|
|
TRACE("Removing shortcut file %s\n", debugstr_w( link_file ));
|
|
|
|
if (!DeleteFileW( link_file ))
|
|
|
|
{
|
|
|
|
WARN("Failed to remove shortcut file %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
msi_free( link_file );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveShortcuts( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','S','h','o','r','t','c','u','t','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveShortcuts, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-06-24 05:56:56 +02:00
|
|
|
static UINT ITERATE_PublishIcon(MSIRECORD *row, LPVOID param)
|
2005-06-22 20:42:19 +02:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE* package = param;
|
2005-06-22 20:42:19 +02:00
|
|
|
HANDLE the_file;
|
2005-09-22 12:33:57 +02:00
|
|
|
LPWSTR FilePath;
|
|
|
|
LPCWSTR FileName;
|
2005-06-22 20:42:19 +02:00
|
|
|
CHAR buffer[1024];
|
|
|
|
DWORD sz;
|
|
|
|
UINT rc;
|
|
|
|
|
|
|
|
FileName = MSI_RecordGetString(row,1);
|
|
|
|
if (!FileName)
|
|
|
|
{
|
|
|
|
ERR("Unable to get FileName\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
FilePath = msi_build_icon_path(package, FileName);
|
2005-06-22 20:42:19 +02:00
|
|
|
|
|
|
|
TRACE("Creating icon file at %s\n",debugstr_w(FilePath));
|
|
|
|
|
|
|
|
the_file = CreateFileW(FilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
if (the_file == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
ERR("Unable to create file %s\n",debugstr_w(FilePath));
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(FilePath);
|
2005-06-22 20:42:19 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
DWORD write;
|
|
|
|
sz = 1024;
|
|
|
|
rc = MSI_RecordReadStream(row,2,buffer,&sz);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to get stream\n");
|
|
|
|
CloseHandle(the_file);
|
|
|
|
DeleteFileW(FilePath);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
WriteFile(the_file,buffer,sz,&write,NULL);
|
|
|
|
} while (sz == 1024);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(FilePath);
|
2005-06-22 20:42:19 +02:00
|
|
|
CloseHandle(the_file);
|
2006-01-23 17:29:50 +01:00
|
|
|
|
2005-06-22 20:42:19 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2008-06-24 05:56:56 +02:00
|
|
|
static UINT msi_publish_icons(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR query[]= {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','I','c','o','n','`',0};
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW(package->db, query, &view);
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
MSI_IterateRecords(view, NULL, ITERATE_PublishIcon, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-06-24 06:05:25 +02:00
|
|
|
static UINT msi_publish_sourcelist(MSIPACKAGE *package, HKEY hkey)
|
2008-06-24 05:57:36 +02:00
|
|
|
{
|
|
|
|
UINT r;
|
2008-06-24 06:05:25 +02:00
|
|
|
HKEY source;
|
2008-06-24 05:57:36 +02:00
|
|
|
LPWSTR buffer;
|
|
|
|
MSIMEDIADISK *disk;
|
|
|
|
MSISOURCELISTINFO *info;
|
|
|
|
|
2008-06-24 06:05:25 +02:00
|
|
|
r = RegCreateKeyW(hkey, szSourceList, &source);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
RegCloseKey(source);
|
2008-06-24 05:57:36 +02:00
|
|
|
|
|
|
|
buffer = strrchrW(package->PackagePath, '\\') + 1;
|
|
|
|
r = MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
package->Context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_PACKAGENAMEW, buffer);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
package->Context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_MEDIAPACKAGEPATHW, szEmpty);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
package->Context, MSICODE_PRODUCT,
|
|
|
|
INSTALLPROPERTY_DISKPROMPTW, szEmpty);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(info, &package->sourcelist_info, MSISOURCELISTINFO, entry)
|
|
|
|
{
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( info->property, INSTALLPROPERTY_LASTUSEDSOURCEW ))
|
2008-06-24 05:57:36 +02:00
|
|
|
msi_set_last_used_source(package->ProductCode, NULL, info->context,
|
|
|
|
info->options, info->value);
|
|
|
|
else
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
info->context, info->options,
|
|
|
|
info->property, info->value);
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(disk, &package->sourcelist_media, MSIMEDIADISK, entry)
|
|
|
|
{
|
|
|
|
MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
|
|
|
|
disk->context, disk->options,
|
|
|
|
disk->disk_id, disk->volume_label, disk->disk_prompt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-06-24 05:59:41 +02:00
|
|
|
static UINT msi_publish_product_properties(MSIPACKAGE *package, HKEY hkey)
|
|
|
|
{
|
|
|
|
MSIHANDLE hdb, suminfo;
|
|
|
|
WCHAR guids[MAX_PATH];
|
2008-06-24 06:00:21 +02:00
|
|
|
WCHAR packcode[SQUISH_GUID_SIZE];
|
2008-06-24 05:59:41 +02:00
|
|
|
LPWSTR buffer;
|
|
|
|
LPWSTR ptr;
|
|
|
|
DWORD langid;
|
|
|
|
DWORD size;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
static const WCHAR szARPProductIcon[] =
|
|
|
|
{'A','R','P','P','R','O','D','U','C','T','I','C','O','N',0};
|
2008-06-24 06:01:44 +02:00
|
|
|
static const WCHAR szAssignment[] =
|
|
|
|
{'A','s','s','i','g','n','m','e','n','t',0};
|
|
|
|
static const WCHAR szAdvertiseFlags[] =
|
|
|
|
{'A','d','v','e','r','t','i','s','e','F','l','a','g','s',0};
|
|
|
|
static const WCHAR szClients[] =
|
|
|
|
{'C','l','i','e','n','t','s',0};
|
|
|
|
static const WCHAR szColon[] = {':',0};
|
2008-06-24 05:59:41 +02:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
buffer = msi_dup_property(package->db, INSTALLPROPERTY_PRODUCTNAMEW);
|
2008-06-24 05:59:41 +02:00
|
|
|
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PRODUCTNAMEW, buffer);
|
|
|
|
msi_free(buffer);
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
langid = msi_get_property_int(package->db, szProductLanguage, 0);
|
2008-06-24 05:59:41 +02:00
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_LANGUAGEW, langid);
|
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_AUTHORIZED_LUA_APPW, 0);
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
buffer = msi_dup_property(package->db, szARPProductIcon);
|
2008-06-24 05:59:41 +02:00
|
|
|
if (buffer)
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
LPWSTR path = msi_build_icon_path(package, buffer);
|
2008-06-24 05:59:41 +02:00
|
|
|
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PRODUCTICONW, path);
|
|
|
|
msi_free(path);
|
|
|
|
msi_free(buffer);
|
|
|
|
}
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
buffer = msi_dup_property(package->db, szProductVersion);
|
2008-06-24 05:59:41 +02:00
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
DWORD verdword = msi_version_str_to_dword(buffer);
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONW, verdword);
|
|
|
|
msi_free(buffer);
|
|
|
|
}
|
|
|
|
|
2008-06-24 06:01:44 +02:00
|
|
|
msi_reg_set_val_dword(hkey, szAssignment, 0);
|
|
|
|
msi_reg_set_val_dword(hkey, szAdvertiseFlags, 0x184);
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_INSTANCETYPEW, 0);
|
|
|
|
msi_reg_set_val_str(hkey, szClients, szColon);
|
|
|
|
|
2008-06-24 05:59:41 +02:00
|
|
|
hdb = alloc_msihandle(&package->db->hdr);
|
|
|
|
if (!hdb)
|
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
|
|
|
|
r = MsiGetSummaryInformationW(hdb, NULL, 0, &suminfo);
|
|
|
|
MsiCloseHandle(hdb);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = MAX_PATH;
|
|
|
|
r = MsiSummaryInfoGetPropertyW(suminfo, PID_REVNUMBER, NULL, NULL,
|
|
|
|
NULL, guids, &size);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
ptr = strchrW(guids, ';');
|
|
|
|
if (ptr) *ptr = 0;
|
2008-06-24 06:00:21 +02:00
|
|
|
squash_guid(guids, packcode);
|
|
|
|
msi_reg_set_val_str(hkey, INSTALLPROPERTY_PACKAGECODEW, packcode);
|
2008-06-24 05:59:41 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
MsiCloseHandle(suminfo);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-06-24 06:02:54 +02:00
|
|
|
static UINT msi_publish_upgrade_code(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
HKEY hkey;
|
|
|
|
LPWSTR upgrade;
|
|
|
|
WCHAR squashed_pc[SQUISH_GUID_SIZE];
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
upgrade = msi_dup_property(package->db, szUpgradeCode);
|
2008-06-24 06:02:54 +02:00
|
|
|
if (!upgrade)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2008-06-24 06:04:46 +02:00
|
|
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
r = MSIREG_OpenClassesUpgradeCodesKey(upgrade, &hkey, TRUE);
|
|
|
|
else
|
|
|
|
r = MSIREG_OpenUserUpgradeCodesKey(upgrade, &hkey, TRUE);
|
2008-06-24 06:02:54 +02:00
|
|
|
|
2011-03-30 12:29:59 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("failed to open upgrade code key\n");
|
|
|
|
msi_free(upgrade);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2008-06-24 06:02:54 +02:00
|
|
|
squash_guid(package->ProductCode, squashed_pc);
|
|
|
|
msi_reg_set_val_str(hkey, squashed_pc, NULL);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
msi_free(upgrade);
|
2011-03-30 12:29:59 +02:00
|
|
|
return ERROR_SUCCESS;
|
2008-06-24 06:02:54 +02:00
|
|
|
}
|
|
|
|
|
2007-07-03 05:21:26 +02:00
|
|
|
static BOOL msi_check_publish(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
|
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
feature->Action = msi_get_feature_action( package, feature );
|
|
|
|
if (feature->Action == INSTALLSTATE_LOCAL)
|
2007-07-03 05:21:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-06-24 06:02:54 +02:00
|
|
|
static BOOL msi_check_unpublish(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
|
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
feature->Action = msi_get_feature_action( package, feature );
|
|
|
|
if (feature->Action != INSTALLSTATE_ABSENT)
|
2008-06-24 06:02:54 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-07-21 09:46:30 +02:00
|
|
|
static UINT msi_publish_patches( MSIPACKAGE *package )
|
2008-12-15 04:07:23 +01:00
|
|
|
{
|
2010-05-04 09:07:39 +02:00
|
|
|
static const WCHAR szAllPatches[] = {'A','l','l','P','a','t','c','h','e','s',0};
|
2008-12-15 04:07:23 +01:00
|
|
|
WCHAR patch_squashed[GUID_SIZE];
|
2010-07-21 09:46:30 +02:00
|
|
|
HKEY patches_key = NULL, product_patches_key = NULL, product_key;
|
2008-12-15 04:07:23 +01:00
|
|
|
LONG res;
|
2010-04-29 09:39:22 +02:00
|
|
|
MSIPATCHINFO *patch;
|
2010-05-04 09:07:39 +02:00
|
|
|
UINT r;
|
2010-04-29 09:39:22 +02:00
|
|
|
WCHAR *p, *all_patches = NULL;
|
|
|
|
DWORD len = 0;
|
2008-12-15 04:07:23 +01:00
|
|
|
|
2010-08-27 10:49:55 +02:00
|
|
|
r = MSIREG_OpenProductKey( package->ProductCode, NULL, package->Context, &product_key, TRUE );
|
2010-07-21 09:46:30 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
2008-12-15 04:07:23 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2010-07-21 09:46:30 +02:00
|
|
|
res = RegCreateKeyExW( product_key, szPatches, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &patches_key, NULL );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-05-04 09:07:39 +02:00
|
|
|
r = MSIREG_OpenUserDataProductPatchesKey( package->ProductCode, package->Context, &product_patches_key, TRUE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2010-04-29 09:39:22 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( patch, &package->patches, MSIPATCHINFO, entry )
|
|
|
|
{
|
|
|
|
squash_guid( patch->patchcode, patch_squashed );
|
|
|
|
len += strlenW( patch_squashed ) + 1;
|
|
|
|
}
|
2008-12-15 04:07:23 +01:00
|
|
|
|
2010-04-29 09:39:22 +02:00
|
|
|
p = all_patches = msi_alloc( (len + 1) * sizeof(WCHAR) );
|
|
|
|
if (!all_patches)
|
2008-12-15 04:07:23 +01:00
|
|
|
goto done;
|
|
|
|
|
2010-04-29 09:39:22 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( patch, &package->patches, MSIPATCHINFO, entry )
|
|
|
|
{
|
2010-05-04 09:07:39 +02:00
|
|
|
HKEY patch_key;
|
|
|
|
|
2010-04-29 09:39:22 +02:00
|
|
|
squash_guid( patch->patchcode, p );
|
|
|
|
p += strlenW( p ) + 1;
|
|
|
|
|
2010-05-04 09:07:39 +02:00
|
|
|
res = RegSetValueExW( patches_key, patch_squashed, 0, REG_SZ,
|
2010-04-29 09:39:22 +02:00
|
|
|
(const BYTE *)patch->transforms,
|
|
|
|
(strlenW(patch->transforms) + 1) * sizeof(WCHAR) );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2010-05-04 09:07:39 +02:00
|
|
|
|
|
|
|
r = MSIREG_OpenUserDataPatchKey( patch->patchcode, package->Context, &patch_key, TRUE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
res = RegSetValueExW( patch_key, szLocalPackage, 0, REG_SZ,
|
|
|
|
(const BYTE *)patch->localfile,
|
|
|
|
(strlenW(patch->localfile) + 1) * sizeof(WCHAR) );
|
|
|
|
RegCloseKey( patch_key );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
res = RegCreateKeyExW( product_patches_key, patch_squashed, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &patch_key, NULL );
|
2010-07-20 14:54:34 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
res = RegSetValueExW( patch_key, szState, 0, REG_DWORD, (const BYTE *)&patch->state, sizeof(patch->state) );
|
2010-05-04 09:07:39 +02:00
|
|
|
RegCloseKey( patch_key );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2010-04-29 09:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
all_patches[len] = 0;
|
2010-05-04 09:07:39 +02:00
|
|
|
res = RegSetValueExW( patches_key, szPatches, 0, REG_MULTI_SZ,
|
2010-04-29 09:39:22 +02:00
|
|
|
(const BYTE *)all_patches, (len + 1) * sizeof(WCHAR) );
|
2010-05-04 09:07:39 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
res = RegSetValueExW( product_patches_key, szAllPatches, 0, REG_MULTI_SZ,
|
|
|
|
(const BYTE *)all_patches, (len + 1) * sizeof(WCHAR) );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
2008-12-15 04:07:23 +01:00
|
|
|
|
|
|
|
done:
|
2010-05-04 09:07:39 +02:00
|
|
|
RegCloseKey( product_patches_key );
|
|
|
|
RegCloseKey( patches_key );
|
2010-07-21 09:46:30 +02:00
|
|
|
RegCloseKey( product_key );
|
2010-04-29 09:39:22 +02:00
|
|
|
msi_free( all_patches );
|
2008-12-15 04:07:23 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static UINT ACTION_PublishProduct(MSIPACKAGE *package)
|
2004-07-06 21:00:23 +02:00
|
|
|
{
|
|
|
|
UINT rc;
|
2010-03-05 12:27:49 +01:00
|
|
|
HKEY hukey = NULL, hudkey = NULL;
|
|
|
|
MSIRECORD *uirow;
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2010-07-21 09:46:30 +02:00
|
|
|
if (!list_empty(&package->patches))
|
|
|
|
{
|
|
|
|
rc = msi_publish_patches(package);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2007-07-03 05:21:26 +02:00
|
|
|
/* FIXME: also need to publish if the product is in advertise mode */
|
|
|
|
if (!msi_check_publish(package))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2009-03-22 22:30:16 +01:00
|
|
|
rc = MSIREG_OpenProductKey(package->ProductCode, NULL, package->Context,
|
2008-11-04 05:16:43 +01:00
|
|
|
&hukey, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
2008-12-15 04:07:06 +01:00
|
|
|
rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context,
|
|
|
|
NULL, &hudkey, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2008-06-24 06:02:54 +02:00
|
|
|
rc = msi_publish_upgrade_code(package);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
2008-06-24 05:59:41 +02:00
|
|
|
|
|
|
|
rc = msi_publish_product_properties(package, hukey);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2006-08-28 18:44:35 +02:00
|
|
|
goto end;
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2008-06-24 06:05:25 +02:00
|
|
|
rc = msi_publish_sourcelist(package, hukey);
|
2008-06-24 05:57:36 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
2007-07-03 05:20:20 +02:00
|
|
|
|
2008-06-24 05:57:36 +02:00
|
|
|
rc = msi_publish_icons(package);
|
2008-06-24 05:56:56 +02:00
|
|
|
|
2005-01-17 14:40:39 +01:00
|
|
|
end:
|
2010-03-05 12:27:49 +01:00
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, package->ProductCode );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szPublishProduct, uirow );
|
2010-03-05 12:27:49 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2005-01-17 14:40:39 +01:00
|
|
|
RegCloseKey(hukey);
|
2007-06-27 04:22:46 +02:00
|
|
|
RegCloseKey(hudkey);
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2004-07-06 21:00:23 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-03-02 14:58:55 +01:00
|
|
|
static WCHAR *get_ini_file_name( MSIPACKAGE *package, MSIRECORD *row )
|
|
|
|
{
|
|
|
|
WCHAR *filename, *ptr, *folder, *ret;
|
|
|
|
const WCHAR *dirprop;
|
|
|
|
|
|
|
|
filename = msi_dup_record_field( row, 2 );
|
|
|
|
if (filename && (ptr = strchrW( filename, '|' )))
|
|
|
|
ptr++;
|
|
|
|
else
|
|
|
|
ptr = filename;
|
|
|
|
|
|
|
|
dirprop = MSI_RecordGetString( row, 3 );
|
|
|
|
if (dirprop)
|
|
|
|
{
|
2011-05-02 16:03:32 +02:00
|
|
|
folder = strdupW( msi_get_target_folder( package, dirprop ) );
|
|
|
|
if (!folder) folder = msi_dup_property( package->db, dirprop );
|
2010-03-02 14:58:55 +01:00
|
|
|
}
|
|
|
|
else
|
2010-04-21 11:37:54 +02:00
|
|
|
folder = msi_dup_property( package->db, szWindowsFolder );
|
2010-03-02 14:58:55 +01:00
|
|
|
|
|
|
|
if (!folder)
|
|
|
|
{
|
|
|
|
ERR("Unable to resolve folder %s\n", debugstr_w(dirprop));
|
|
|
|
msi_free( filename );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
ret = msi_build_directory_name( 2, folder, ptr );
|
2010-03-02 14:58:55 +01:00
|
|
|
|
|
|
|
msi_free( filename );
|
|
|
|
msi_free( folder );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
static UINT ITERATE_WriteIniValues(MSIRECORD *row, LPVOID param)
|
2005-01-14 16:59:26 +01:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-03-02 14:58:55 +01:00
|
|
|
LPCWSTR component, section, key, value, identifier;
|
|
|
|
LPWSTR deformated_section, deformated_key, deformated_value, fullname;
|
2005-06-23 11:46:31 +02:00
|
|
|
MSIRECORD * uirow;
|
2005-08-22 11:15:23 +02:00
|
|
|
INT action;
|
|
|
|
MSICOMPONENT *comp;
|
2005-01-14 16:59:26 +01:00
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
component = MSI_RecordGetString(row, 8);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package,component);
|
2010-02-16 11:44:47 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-14 16:59:26 +01:00
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2005-01-14 16:59:26 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2005-06-23 11:46:31 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
identifier = MSI_RecordGetString(row,1);
|
|
|
|
section = MSI_RecordGetString(row,4);
|
|
|
|
key = MSI_RecordGetString(row,5);
|
|
|
|
value = MSI_RecordGetString(row,6);
|
|
|
|
action = MSI_RecordGetInteger(row,7);
|
2005-01-31 17:23:12 +01:00
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
deformat_string(package,section,&deformated_section);
|
|
|
|
deformat_string(package,key,&deformated_key);
|
|
|
|
deformat_string(package,value,&deformated_value);
|
2005-01-14 16:59:26 +01:00
|
|
|
|
2010-03-02 14:58:55 +01:00
|
|
|
fullname = get_ini_file_name(package, row);
|
2005-01-14 16:59:26 +01:00
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
if (action == 0)
|
|
|
|
{
|
|
|
|
TRACE("Adding value %s to section %s in %s\n",
|
2005-01-14 16:59:26 +01:00
|
|
|
debugstr_w(deformated_key), debugstr_w(deformated_section),
|
|
|
|
debugstr_w(fullname));
|
2005-06-23 11:46:31 +02:00
|
|
|
WritePrivateProfileStringW(deformated_section, deformated_key,
|
|
|
|
deformated_value, fullname);
|
|
|
|
}
|
|
|
|
else if (action == 1)
|
|
|
|
{
|
|
|
|
WCHAR returned[10];
|
|
|
|
GetPrivateProfileStringW(deformated_section, deformated_key, NULL,
|
|
|
|
returned, 10, fullname);
|
|
|
|
if (returned[0] == 0)
|
2005-01-14 16:59:26 +01:00
|
|
|
{
|
2005-06-23 11:46:31 +02:00
|
|
|
TRACE("Adding value %s to section %s in %s\n",
|
2005-01-14 16:59:26 +01:00
|
|
|
debugstr_w(deformated_key), debugstr_w(deformated_section),
|
|
|
|
debugstr_w(fullname));
|
|
|
|
|
2005-06-23 11:46:31 +02:00
|
|
|
WritePrivateProfileStringW(deformated_section, deformated_key,
|
2005-01-14 16:59:26 +01:00
|
|
|
deformated_value, fullname);
|
|
|
|
}
|
2005-06-23 11:46:31 +02:00
|
|
|
}
|
|
|
|
else if (action == 3)
|
|
|
|
FIXME("Append to existing section not yet implemented\n");
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord(4);
|
|
|
|
MSI_RecordSetStringW(uirow,1,identifier);
|
|
|
|
MSI_RecordSetStringW(uirow,2,deformated_section);
|
|
|
|
MSI_RecordSetStringW(uirow,3,deformated_key);
|
|
|
|
MSI_RecordSetStringW(uirow,4,deformated_value);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szWriteIniValues, uirow );
|
2005-06-23 11:46:31 +02:00
|
|
|
msiobj_release( &uirow->hdr );
|
2008-10-27 06:56:04 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(fullname);
|
|
|
|
msi_free(deformated_key);
|
|
|
|
msi_free(deformated_value);
|
|
|
|
msi_free(deformated_section);
|
2005-06-23 11:46:31 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_WriteIniValues(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','I','n','i','F','i','l','e','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("no IniFile table\n");
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-14 16:59:26 +01:00
|
|
|
}
|
2005-06-23 11:46:31 +02:00
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_WriteIniValues, package);
|
2005-01-14 16:59:26 +01:00
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-03-02 14:58:55 +01:00
|
|
|
static UINT ITERATE_RemoveIniValuesOnUninstall( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR component, section, key, value, identifier;
|
|
|
|
LPWSTR deformated_section, deformated_key, deformated_value, filename;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
INT action;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 8 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-03-02 14:58:55 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-03-02 14:58:55 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-03-02 14:58:55 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
identifier = MSI_RecordGetString( row, 1 );
|
|
|
|
section = MSI_RecordGetString( row, 4 );
|
|
|
|
key = MSI_RecordGetString( row, 5 );
|
|
|
|
value = MSI_RecordGetString( row, 6 );
|
|
|
|
action = MSI_RecordGetInteger( row, 7 );
|
|
|
|
|
|
|
|
deformat_string( package, section, &deformated_section );
|
|
|
|
deformat_string( package, key, &deformated_key );
|
|
|
|
deformat_string( package, value, &deformated_value );
|
|
|
|
|
|
|
|
if (action == msidbIniFileActionAddLine || action == msidbIniFileActionCreateLine)
|
|
|
|
{
|
|
|
|
filename = get_ini_file_name( package, row );
|
|
|
|
|
|
|
|
TRACE("Removing key %s from section %s in %s\n",
|
|
|
|
debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename));
|
|
|
|
|
|
|
|
if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename ))
|
|
|
|
{
|
|
|
|
WARN("Unable to remove key %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
msi_free( filename );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FIXME("Unsupported action %d\n", action);
|
|
|
|
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 4 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, identifier );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, deformated_section );
|
|
|
|
MSI_RecordSetStringW( uirow, 3, deformated_key );
|
|
|
|
MSI_RecordSetStringW( uirow, 4, deformated_value );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveIniValues, uirow );
|
2010-03-02 14:58:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
msi_free( deformated_key );
|
|
|
|
msi_free( deformated_value );
|
|
|
|
msi_free( deformated_section );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_RemoveIniValuesOnInstall( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR component, section, key, value, identifier;
|
|
|
|
LPWSTR deformated_section, deformated_key, deformated_value, filename;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
INT action;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( row, 8 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-03-02 14:58:55 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-03-02 14:58:55 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-03-02 14:58:55 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
identifier = MSI_RecordGetString( row, 1 );
|
|
|
|
section = MSI_RecordGetString( row, 4 );
|
|
|
|
key = MSI_RecordGetString( row, 5 );
|
|
|
|
value = MSI_RecordGetString( row, 6 );
|
|
|
|
action = MSI_RecordGetInteger( row, 7 );
|
|
|
|
|
|
|
|
deformat_string( package, section, &deformated_section );
|
|
|
|
deformat_string( package, key, &deformated_key );
|
|
|
|
deformat_string( package, value, &deformated_value );
|
|
|
|
|
|
|
|
if (action == msidbIniFileActionRemoveLine)
|
|
|
|
{
|
|
|
|
filename = get_ini_file_name( package, row );
|
|
|
|
|
|
|
|
TRACE("Removing key %s from section %s in %s\n",
|
|
|
|
debugstr_w(deformated_key), debugstr_w(deformated_section), debugstr_w(filename));
|
|
|
|
|
|
|
|
if (!WritePrivateProfileStringW( deformated_section, deformated_key, NULL, filename ))
|
|
|
|
{
|
|
|
|
WARN("Unable to remove key %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
msi_free( filename );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FIXME("Unsupported action %d\n", action);
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 4 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, identifier );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, deformated_section );
|
|
|
|
MSI_RecordSetStringW( uirow, 3, deformated_key );
|
|
|
|
MSI_RecordSetStringW( uirow, 4, deformated_value );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveIniValues, uirow );
|
2010-03-02 14:58:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
msi_free( deformated_key );
|
|
|
|
msi_free( deformated_value );
|
|
|
|
msi_free( deformated_section );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveIniValues( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','I','n','i','F','i','l','e','`',0};
|
|
|
|
static const WCHAR remove_query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','R','e','m','o','v','e','I','n','i','F','i','l','e','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnUninstall, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, remove_query, &view );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveIniValuesOnInstall, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-07-23 09:43:27 +02:00
|
|
|
static void register_dll( const WCHAR *dll, BOOL unregister )
|
|
|
|
{
|
|
|
|
HMODULE hmod;
|
|
|
|
|
|
|
|
hmod = LoadLibraryExW( dll, 0, LOAD_WITH_ALTERED_SEARCH_PATH );
|
|
|
|
if (hmod)
|
|
|
|
{
|
|
|
|
HRESULT (WINAPI *func_ptr)( void );
|
|
|
|
const char *func = unregister ? "DllUnregisterServer" : "DllRegisterServer";
|
|
|
|
|
|
|
|
func_ptr = (void *)GetProcAddress( hmod, func );
|
|
|
|
if (func_ptr)
|
|
|
|
{
|
|
|
|
HRESULT hr = func_ptr();
|
|
|
|
if (FAILED( hr ))
|
|
|
|
WARN("failed to register dll 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("entry point %s not found\n", func);
|
|
|
|
FreeLibrary( hmod );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
WARN("failed to load library %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2005-06-24 13:33:02 +02:00
|
|
|
static UINT ITERATE_SelfRegModules(MSIRECORD *row, LPVOID param)
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2005-06-24 13:33:02 +02:00
|
|
|
LPCWSTR filename;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIRECORD *uirow;
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2005-06-24 13:33:02 +02:00
|
|
|
filename = MSI_RecordGetString(row,1);
|
2011-05-06 14:39:17 +02:00
|
|
|
file = msi_get_loaded_file( package, filename );
|
2005-08-23 12:03:17 +02:00
|
|
|
if (!file)
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
WARN("unable to find file %s\n", debugstr_w(filename));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
file->Component->Action = msi_get_component_action( package, file->Component );
|
|
|
|
if (file->Component->Action != INSTALLSTATE_LOCAL)
|
|
|
|
{
|
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(file->Component->Component));
|
2005-06-24 13:33:02 +02:00
|
|
|
return ERROR_SUCCESS;
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
|
|
|
|
2010-07-23 09:43:27 +02:00
|
|
|
TRACE("Registering %s\n", debugstr_w( file->TargetPath ));
|
|
|
|
register_dll( file->TargetPath, FALSE );
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
uirow = MSI_CreateRecord( 2 );
|
2010-03-23 11:45:33 +01:00
|
|
|
MSI_RecordSetStringW( uirow, 1, filename );
|
2010-06-09 12:09:21 +02:00
|
|
|
MSI_RecordSetStringW( uirow, 2, file->Component->Directory );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szSelfRegModules, uirow );
|
2006-01-23 17:29:50 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2005-06-24 13:33:02 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2005-06-24 13:33:02 +02:00
|
|
|
static UINT ACTION_SelfRegModules(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','S','e','l','f','R','e','g','`',0};
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2005-06-24 13:33:02 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("no SelfReg table\n");
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
2005-06-24 13:33:02 +02:00
|
|
|
|
|
|
|
MSI_IterateRecords(view, NULL, ITERATE_SelfRegModules, package);
|
2005-01-17 14:40:39 +01:00
|
|
|
msiobj_release(&view->hdr);
|
2005-06-24 13:33:02 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
|
|
|
|
2010-02-05 14:48:20 +01:00
|
|
|
static UINT ITERATE_SelfUnregModules( MSIRECORD *row, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR filename;
|
|
|
|
MSIFILE *file;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
|
|
|
|
filename = MSI_RecordGetString( row, 1 );
|
2011-05-06 14:39:17 +02:00
|
|
|
file = msi_get_loaded_file( package, filename );
|
2010-02-05 14:48:20 +01:00
|
|
|
if (!file)
|
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
WARN("unable to find file %s\n", debugstr_w(filename));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
file->Component->Action = msi_get_component_action( package, file->Component );
|
|
|
|
if (file->Component->Action != INSTALLSTATE_ABSENT)
|
|
|
|
{
|
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(file->Component->Component));
|
2010-02-05 14:48:20 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-07-23 09:43:27 +02:00
|
|
|
TRACE("Unregistering %s\n", debugstr_w( file->TargetPath ));
|
|
|
|
register_dll( file->TargetPath, TRUE );
|
2010-02-05 14:48:20 +01:00
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
2010-03-23 11:45:33 +01:00
|
|
|
MSI_RecordSetStringW( uirow, 1, filename );
|
2010-06-09 12:09:21 +02:00
|
|
|
MSI_RecordSetStringW( uirow, 2, file->Component->Directory );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szSelfUnregModules, uirow );
|
2010-02-05 14:48:20 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_SelfUnregModules( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','S','e','l','f','R','e','g','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("no SelfReg table\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSI_IterateRecords( view, NULL, ITERATE_SelfUnregModules, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-01-17 14:40:39 +01:00
|
|
|
static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
|
|
|
|
{
|
2005-08-22 16:09:17 +02:00
|
|
|
MSIFEATURE *feature;
|
2005-01-17 14:40:39 +01:00
|
|
|
UINT rc;
|
2010-03-04 09:17:50 +01:00
|
|
|
HKEY hkey = NULL, userdata = NULL;
|
2007-08-09 20:38:48 +02:00
|
|
|
|
|
|
|
if (!msi_check_publish(package))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2008-11-04 05:16:50 +01:00
|
|
|
rc = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
|
|
|
|
&hkey, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
2008-11-04 05:16:54 +01:00
|
|
|
rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
|
|
|
|
&userdata, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
2007-11-01 09:13:28 +01:00
|
|
|
|
2005-01-17 14:40:39 +01:00
|
|
|
/* here the guids are base 85 encoded */
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
2005-08-19 12:03:11 +02:00
|
|
|
ComponentList *cl;
|
2005-01-17 14:40:39 +01:00
|
|
|
LPWSTR data = NULL;
|
|
|
|
GUID clsid;
|
|
|
|
INT size;
|
2005-05-13 15:56:39 +02:00
|
|
|
BOOL absent = FALSE;
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIRECORD *uirow;
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
if (feature->Action != INSTALLSTATE_LOCAL &&
|
|
|
|
feature->Action != INSTALLSTATE_SOURCE &&
|
|
|
|
feature->Action != INSTALLSTATE_ADVERTISED) absent = TRUE;
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2005-08-19 12:03:11 +02:00
|
|
|
size = 1;
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2005-08-19 12:03:11 +02:00
|
|
|
{
|
|
|
|
size += 21;
|
|
|
|
}
|
2005-09-13 12:37:37 +02:00
|
|
|
if (feature->Feature_Parent)
|
2005-08-22 16:09:17 +02:00
|
|
|
size += strlenW( feature->Feature_Parent )+2;
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
data = msi_alloc(size * sizeof(WCHAR));
|
2005-01-17 14:40:39 +01:00
|
|
|
|
|
|
|
data[0] = 0;
|
2005-08-22 16:09:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( cl, &feature->Components, ComponentList, entry )
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT* component = cl->component;
|
2005-01-17 14:40:39 +01:00
|
|
|
WCHAR buf[21];
|
2005-08-19 12:03:11 +02:00
|
|
|
|
2006-04-18 19:29:03 +02:00
|
|
|
buf[0] = 0;
|
2005-09-12 14:07:15 +02:00
|
|
|
if (component->ComponentId)
|
2005-05-18 19:46:12 +02:00
|
|
|
{
|
2005-08-19 12:03:11 +02:00
|
|
|
TRACE("From %s\n",debugstr_w(component->ComponentId));
|
|
|
|
CLSIDFromString(component->ComponentId, &clsid);
|
2005-05-18 19:46:12 +02:00
|
|
|
encode_base85_guid(&clsid,buf);
|
|
|
|
TRACE("to %s\n",debugstr_w(buf));
|
|
|
|
strcatW(data,buf);
|
|
|
|
}
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
2007-11-01 09:13:28 +01:00
|
|
|
|
2005-09-13 12:37:37 +02:00
|
|
|
if (feature->Feature_Parent)
|
2005-01-17 14:40:39 +01:00
|
|
|
{
|
|
|
|
static const WCHAR sep[] = {'\2',0};
|
|
|
|
strcatW(data,sep);
|
2005-08-22 16:09:17 +02:00
|
|
|
strcatW(data,feature->Feature_Parent);
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
|
|
|
|
2007-11-01 09:13:28 +01:00
|
|
|
msi_reg_set_val_str( userdata, feature->Feature, data );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(data);
|
2005-01-17 14:40:39 +01:00
|
|
|
|
2005-09-13 12:37:37 +02:00
|
|
|
size = 0;
|
|
|
|
if (feature->Feature_Parent)
|
|
|
|
size = strlenW(feature->Feature_Parent)*sizeof(WCHAR);
|
2005-05-13 15:56:39 +02:00
|
|
|
if (!absent)
|
|
|
|
{
|
2008-04-22 17:05:05 +02:00
|
|
|
size += sizeof(WCHAR);
|
2008-06-19 07:32:59 +02:00
|
|
|
RegSetValueExW(hkey,feature->Feature,0,REG_SZ,
|
2010-03-27 15:48:20 +01:00
|
|
|
(const BYTE*)(feature->Feature_Parent ? feature->Feature_Parent : szEmpty),size);
|
2005-05-13 15:56:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-13 12:37:37 +02:00
|
|
|
size += 2*sizeof(WCHAR);
|
2005-09-20 13:59:14 +02:00
|
|
|
data = msi_alloc(size);
|
2005-05-13 15:56:39 +02:00
|
|
|
data[0] = 0x6;
|
2005-09-13 12:37:37 +02:00
|
|
|
data[1] = 0;
|
|
|
|
if (feature->Feature_Parent)
|
|
|
|
strcpyW( &data[1], feature->Feature_Parent );
|
2008-06-19 07:32:59 +02:00
|
|
|
RegSetValueExW(hkey,feature->Feature,0,REG_SZ,
|
2005-07-06 12:33:30 +02:00
|
|
|
(LPBYTE)data,size);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(data);
|
2005-05-13 15:56:39 +02:00
|
|
|
}
|
2006-01-23 17:29:50 +01:00
|
|
|
|
|
|
|
/* the UI chunk */
|
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, feature->Feature );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szPublishFeatures, uirow );
|
2006-01-23 17:29:50 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
2011-05-06 14:39:17 +02:00
|
|
|
/* FIXME: call msi_ui_progress? */
|
2005-01-17 14:40:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2008-06-19 07:32:59 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
RegCloseKey(userdata);
|
2005-01-17 14:40:39 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-08-09 20:38:48 +02:00
|
|
|
static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
HKEY hkey;
|
2010-03-23 11:47:19 +01:00
|
|
|
MSIRECORD *uirow;
|
2007-08-09 20:38:48 +02:00
|
|
|
|
|
|
|
TRACE("unpublishing feature %s\n", debugstr_w(feature->Feature));
|
|
|
|
|
2008-11-04 05:16:50 +01:00
|
|
|
r = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
|
|
|
|
&hkey, FALSE);
|
2007-08-09 20:38:48 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegDeleteValueW(hkey, feature->Feature);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2008-11-04 05:16:54 +01:00
|
|
|
r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
|
|
|
|
&hkey, FALSE);
|
2007-08-09 20:38:48 +02:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegDeleteValueW(hkey, feature->Feature);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2010-03-23 11:47:19 +01:00
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, feature->Feature );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szUnpublishFeatures, uirow );
|
2010-03-23 11:47:19 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2007-08-09 20:38:48 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_UnpublishFeatures(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature;
|
|
|
|
|
2007-11-01 09:14:18 +01:00
|
|
|
if (!msi_check_unpublish(package))
|
2007-08-09 20:38:48 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
|
|
|
|
{
|
|
|
|
msi_unpublish_feature(package, feature);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-06-19 07:36:10 +02:00
|
|
|
static UINT msi_publish_install_properties(MSIPACKAGE *package, HKEY hkey)
|
2005-10-27 14:08:16 +02:00
|
|
|
{
|
2008-06-19 07:36:10 +02:00
|
|
|
SYSTEMTIME systime;
|
|
|
|
DWORD size, langid;
|
2010-05-11 14:03:08 +02:00
|
|
|
WCHAR date[9], *val, *buffer;
|
|
|
|
const WCHAR *prop, *key;
|
2008-06-19 07:36:10 +02:00
|
|
|
|
|
|
|
static const WCHAR date_fmt[] = {'%','i','%','0','2','i','%','0','2','i',0};
|
|
|
|
static const WCHAR modpath_fmt[] =
|
|
|
|
{'M','s','i','E','x','e','c','.','e','x','e',' ',
|
|
|
|
'/','I','[','P','r','o','d','u','c','t','C','o','d','e',']',0};
|
|
|
|
static const WCHAR szModifyPath[] =
|
|
|
|
{'M','o','d','i','f','y','P','a','t','h',0};
|
|
|
|
static const WCHAR szUninstallString[] =
|
|
|
|
{'U','n','i','n','s','t','a','l','l','S','t','r','i','n','g',0};
|
|
|
|
static const WCHAR szEstimatedSize[] =
|
|
|
|
{'E','s','t','i','m','a','t','e','d','S','i','z','e',0};
|
|
|
|
static const WCHAR szDisplayVersion[] =
|
|
|
|
{'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0};
|
2010-05-11 14:03:08 +02:00
|
|
|
static const WCHAR szInstallSource[] =
|
|
|
|
{'I','n','s','t','a','l','l','S','o','u','r','c','e',0};
|
|
|
|
static const WCHAR szARPAUTHORIZEDCDFPREFIX[] =
|
|
|
|
{'A','R','P','A','U','T','H','O','R','I','Z','E','D','C','D','F','P','R','E','F','I','X',0};
|
|
|
|
static const WCHAR szAuthorizedCDFPrefix[] =
|
|
|
|
{'A','u','t','h','o','r','i','z','e','d','C','D','F','P','r','e','f','i','x',0};
|
|
|
|
static const WCHAR szARPCONTACT[] =
|
|
|
|
{'A','R','P','C','O','N','T','A','C','T',0};
|
|
|
|
static const WCHAR szContact[] =
|
|
|
|
{'C','o','n','t','a','c','t',0};
|
|
|
|
static const WCHAR szARPCOMMENTS[] =
|
|
|
|
{'A','R','P','C','O','M','M','E','N','T','S',0};
|
|
|
|
static const WCHAR szComments[] =
|
|
|
|
{'C','o','m','m','e','n','t','s',0};
|
|
|
|
static const WCHAR szProductName[] =
|
|
|
|
{'P','r','o','d','u','c','t','N','a','m','e',0};
|
|
|
|
static const WCHAR szDisplayName[] =
|
|
|
|
{'D','i','s','p','l','a','y','N','a','m','e',0};
|
|
|
|
static const WCHAR szARPHELPLINK[] =
|
|
|
|
{'A','R','P','H','E','L','P','L','I','N','K',0};
|
|
|
|
static const WCHAR szHelpLink[] =
|
|
|
|
{'H','e','l','p','L','i','n','k',0};
|
|
|
|
static const WCHAR szARPHELPTELEPHONE[] =
|
|
|
|
{'A','R','P','H','E','L','P','T','E','L','E','P','H','O','N','E',0};
|
|
|
|
static const WCHAR szHelpTelephone[] =
|
|
|
|
{'H','e','l','p','T','e','l','e','p','h','o','n','e',0};
|
|
|
|
static const WCHAR szARPINSTALLLOCATION[] =
|
|
|
|
{'A','R','P','I','N','S','T','A','L','L','L','O','C','A','T','I','O','N',0};
|
|
|
|
static const WCHAR szInstallLocation[] =
|
|
|
|
{'I','n','s','t','a','l','l','L','o','c','a','t','i','o','n',0};
|
|
|
|
static const WCHAR szManufacturer[] =
|
|
|
|
{'M','a','n','u','f','a','c','t','u','r','e','r',0};
|
|
|
|
static const WCHAR szPublisher[] =
|
|
|
|
{'P','u','b','l','i','s','h','e','r',0};
|
|
|
|
static const WCHAR szARPREADME[] =
|
|
|
|
{'A','R','P','R','E','A','D','M','E',0};
|
|
|
|
static const WCHAR szReadme[] =
|
|
|
|
{'R','e','a','d','M','e',0};
|
|
|
|
static const WCHAR szARPSIZE[] =
|
|
|
|
{'A','R','P','S','I','Z','E',0};
|
|
|
|
static const WCHAR szSize[] =
|
|
|
|
{'S','i','z','e',0};
|
|
|
|
static const WCHAR szARPURLINFOABOUT[] =
|
|
|
|
{'A','R','P','U','R','L','I','N','F','O','A','B','O','U','T',0};
|
|
|
|
static const WCHAR szURLInfoAbout[] =
|
|
|
|
{'U','R','L','I','n','f','o','A','b','o','u','t',0};
|
|
|
|
static const WCHAR szARPURLUPDATEINFO[] =
|
|
|
|
{'A','R','P','U','R','L','U','P','D','A','T','E','I','N','F','O',0};
|
|
|
|
static const WCHAR szURLUpdateInfo[] =
|
|
|
|
{'U','R','L','U','p','d','a','t','e','I','n','f','o',0};
|
|
|
|
|
|
|
|
static const WCHAR *propval[] = {
|
|
|
|
szARPAUTHORIZEDCDFPREFIX, szAuthorizedCDFPrefix,
|
|
|
|
szARPCONTACT, szContact,
|
|
|
|
szARPCOMMENTS, szComments,
|
|
|
|
szProductName, szDisplayName,
|
|
|
|
szARPHELPLINK, szHelpLink,
|
|
|
|
szARPHELPTELEPHONE, szHelpTelephone,
|
|
|
|
szARPINSTALLLOCATION, szInstallLocation,
|
2011-05-02 16:04:25 +02:00
|
|
|
szSourceDir, szInstallSource,
|
2010-05-11 14:03:08 +02:00
|
|
|
szManufacturer, szPublisher,
|
|
|
|
szARPREADME, szReadme,
|
|
|
|
szARPSIZE, szSize,
|
|
|
|
szARPURLINFOABOUT, szURLInfoAbout,
|
|
|
|
szARPURLUPDATEINFO, szURLUpdateInfo,
|
|
|
|
NULL
|
2005-10-27 14:08:16 +02:00
|
|
|
};
|
2010-05-11 14:03:08 +02:00
|
|
|
const WCHAR **p = propval;
|
2005-10-27 14:08:16 +02:00
|
|
|
|
2008-06-19 07:36:10 +02:00
|
|
|
while (*p)
|
2005-10-27 14:08:16 +02:00
|
|
|
{
|
2010-05-11 14:03:08 +02:00
|
|
|
prop = *p++;
|
|
|
|
key = *p++;
|
2010-04-21 11:37:54 +02:00
|
|
|
val = msi_dup_property(package->db, prop);
|
2008-06-19 07:36:10 +02:00
|
|
|
msi_reg_set_val_str(hkey, key, val);
|
2005-10-27 14:08:16 +02:00
|
|
|
msi_free(val);
|
|
|
|
}
|
2008-06-19 07:36:10 +02:00
|
|
|
|
|
|
|
msi_reg_set_val_dword(hkey, szWindowsInstaller, 1);
|
|
|
|
|
|
|
|
size = deformat_string(package, modpath_fmt, &buffer);
|
|
|
|
RegSetValueExW(hkey, szModifyPath, 0, REG_EXPAND_SZ, (LPBYTE)buffer, size);
|
|
|
|
RegSetValueExW(hkey, szUninstallString, 0, REG_EXPAND_SZ, (LPBYTE)buffer, size);
|
|
|
|
msi_free(buffer);
|
|
|
|
|
|
|
|
/* FIXME: Write real Estimated Size when we have it */
|
|
|
|
msi_reg_set_val_dword(hkey, szEstimatedSize, 0);
|
|
|
|
|
|
|
|
GetLocalTime(&systime);
|
|
|
|
sprintfW(date, date_fmt, systime.wYear, systime.wMonth, systime.wDay);
|
|
|
|
msi_reg_set_val_str(hkey, INSTALLPROPERTY_INSTALLDATEW, date);
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
langid = msi_get_property_int(package->db, szProductLanguage, 0);
|
2008-06-19 07:36:10 +02:00
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_LANGUAGEW, langid);
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
buffer = msi_dup_property(package->db, szProductVersion);
|
2008-06-19 07:36:10 +02:00
|
|
|
msi_reg_set_val_str(hkey, szDisplayVersion, buffer);
|
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
DWORD verdword = msi_version_str_to_dword(buffer);
|
|
|
|
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONW, verdword);
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONMAJORW, verdword >> 24);
|
|
|
|
msi_reg_set_val_dword(hkey, INSTALLPROPERTY_VERSIONMINORW, (verdword >> 16) & 0xFF);
|
|
|
|
msi_free(buffer);
|
|
|
|
}
|
|
|
|
|
2005-10-27 14:08:16 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-01-19 20:07:40 +01:00
|
|
|
static UINT ACTION_RegisterProduct(MSIPACKAGE *package)
|
|
|
|
{
|
2008-06-19 07:36:10 +02:00
|
|
|
WCHAR squashed_pc[SQUISH_GUID_SIZE];
|
2010-03-05 12:28:11 +01:00
|
|
|
MSIRECORD *uirow;
|
2008-06-19 07:36:10 +02:00
|
|
|
LPWSTR upgrade_code;
|
2011-04-14 14:39:55 +02:00
|
|
|
HKEY hkey, props, upgrade_key;
|
2005-10-27 14:08:16 +02:00
|
|
|
UINT rc;
|
2005-06-17 23:25:41 +02:00
|
|
|
|
2007-07-03 05:21:58 +02:00
|
|
|
/* FIXME: also need to publish if the product is in advertise mode */
|
|
|
|
if (!msi_check_publish(package))
|
|
|
|
return ERROR_SUCCESS;
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2011-03-30 12:31:04 +02:00
|
|
|
rc = MSIREG_OpenUninstallKey(package->ProductCode, package->platform, &hkey, TRUE);
|
2005-01-19 20:07:40 +01:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-10-27 14:08:16 +02:00
|
|
|
return rc;
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context,
|
|
|
|
NULL, &props, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2008-03-06 23:12:40 +01:00
|
|
|
|
2009-10-20 14:09:53 +02:00
|
|
|
msi_reg_set_val_str( props, INSTALLPROPERTY_LOCALPACKAGEW, package->db->localfile );
|
|
|
|
msi_free( package->db->localfile );
|
|
|
|
package->db->localfile = NULL;
|
2008-03-06 23:12:40 +01:00
|
|
|
|
2008-06-19 07:36:10 +02:00
|
|
|
rc = msi_publish_install_properties(package, hkey);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2005-06-17 23:25:41 +02:00
|
|
|
|
2008-06-19 07:36:10 +02:00
|
|
|
rc = msi_publish_install_properties(package, props);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto done;
|
2005-09-15 16:58:38 +02:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
upgrade_code = msi_dup_property(package->db, szUpgradeCode);
|
2005-06-08 21:07:52 +02:00
|
|
|
if (upgrade_code)
|
|
|
|
{
|
2011-04-14 14:39:55 +02:00
|
|
|
rc = MSIREG_OpenUpgradeCodesKey( upgrade_code, &upgrade_key, TRUE );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
squash_guid( package->ProductCode, squashed_pc );
|
|
|
|
msi_reg_set_val_str( upgrade_key, squashed_pc, NULL );
|
|
|
|
RegCloseKey( upgrade_key );
|
|
|
|
}
|
|
|
|
msi_free( upgrade_code );
|
2005-06-08 21:07:52 +02:00
|
|
|
}
|
2008-04-05 13:02:04 +02:00
|
|
|
|
2008-06-19 07:36:10 +02:00
|
|
|
done:
|
2010-03-05 12:28:11 +01:00
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, package->ProductCode );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRegisterProduct, uirow );
|
2010-03-05 12:28:11 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2010-03-05 12:28:11 +01:00
|
|
|
RegCloseKey(hkey);
|
2005-01-19 20:07:40 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_InstallExecute(MSIPACKAGE *package)
|
|
|
|
{
|
2005-11-03 10:56:29 +01:00
|
|
|
return execute_script(package,INSTALL_SCRIPT);
|
2005-01-19 20:07:40 +01:00
|
|
|
}
|
|
|
|
|
2010-07-20 14:54:50 +02:00
|
|
|
static UINT msi_unpublish_product(MSIPACKAGE *package, WCHAR *remove)
|
2007-07-03 05:20:54 +02:00
|
|
|
{
|
2010-07-20 14:54:50 +02:00
|
|
|
WCHAR *upgrade, **features;
|
2007-07-03 05:20:54 +02:00
|
|
|
BOOL full_uninstall = TRUE;
|
|
|
|
MSIFEATURE *feature;
|
2010-05-04 09:07:39 +02:00
|
|
|
MSIPATCHINFO *patch;
|
2007-07-03 05:20:54 +02:00
|
|
|
|
2008-06-24 06:02:54 +02:00
|
|
|
static const WCHAR szUpgradeCode[] =
|
|
|
|
{'U','p','g','r','a','d','e','C','o','d','e',0};
|
2007-07-03 05:20:54 +02:00
|
|
|
|
|
|
|
features = msi_split_string(remove, ',');
|
|
|
|
if (!features)
|
|
|
|
{
|
|
|
|
ERR("REMOVE feature list is empty!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( features[0], szAll ))
|
2007-07-03 05:20:54 +02:00
|
|
|
full_uninstall = TRUE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LIST_FOR_EACH_ENTRY(feature, &package->features, MSIFEATURE, entry)
|
|
|
|
{
|
|
|
|
if (feature->Action != INSTALLSTATE_ABSENT)
|
|
|
|
full_uninstall = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2010-07-20 14:54:50 +02:00
|
|
|
msi_free(features);
|
2007-07-03 05:20:54 +02:00
|
|
|
|
|
|
|
if (!full_uninstall)
|
2010-07-20 14:54:50 +02:00
|
|
|
return ERROR_SUCCESS;
|
2007-07-03 05:20:54 +02:00
|
|
|
|
|
|
|
MSIREG_DeleteProductKey(package->ProductCode);
|
|
|
|
MSIREG_DeleteUserDataProductKey(package->ProductCode);
|
2011-03-30 12:31:04 +02:00
|
|
|
MSIREG_DeleteUninstallKey(package->ProductCode, package->platform);
|
2007-07-03 05:20:54 +02:00
|
|
|
|
2011-01-20 09:06:47 +01:00
|
|
|
MSIREG_DeleteLocalClassesProductKey(package->ProductCode);
|
|
|
|
MSIREG_DeleteLocalClassesFeaturesKey(package->ProductCode);
|
|
|
|
MSIREG_DeleteUserProductKey(package->ProductCode);
|
|
|
|
MSIREG_DeleteUserFeaturesKey(package->ProductCode);
|
2008-07-29 01:46:32 +02:00
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
upgrade = msi_dup_property(package->db, szUpgradeCode);
|
2008-06-24 06:02:54 +02:00
|
|
|
if (upgrade)
|
|
|
|
{
|
|
|
|
MSIREG_DeleteUserUpgradeCodesKey(upgrade);
|
2011-01-20 09:06:47 +01:00
|
|
|
MSIREG_DeleteClassesUpgradeCodesKey(upgrade);
|
2008-06-24 06:02:54 +02:00
|
|
|
msi_free(upgrade);
|
|
|
|
}
|
|
|
|
|
2010-05-04 09:07:39 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(patch, &package->patches, MSIPATCHINFO, entry)
|
|
|
|
{
|
|
|
|
MSIREG_DeleteUserDataPatchKey(patch->patchcode, package->Context);
|
|
|
|
}
|
|
|
|
|
2007-07-03 05:20:54 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-01-19 20:07:40 +01:00
|
|
|
static UINT ACTION_InstallFinalize(MSIPACKAGE *package)
|
|
|
|
{
|
2005-05-27 21:24:22 +02:00
|
|
|
UINT rc;
|
2010-07-20 14:54:50 +02:00
|
|
|
WCHAR *remove;
|
2007-07-03 05:20:54 +02:00
|
|
|
|
2006-11-12 19:51:37 +01:00
|
|
|
/* turn off scheduling */
|
2005-05-27 21:24:22 +02:00
|
|
|
package->script->CurrentlyScripting= FALSE;
|
|
|
|
|
2005-01-25 21:17:09 +01:00
|
|
|
/* first do the same as an InstallExecute */
|
2005-05-27 21:24:22 +02:00
|
|
|
rc = ACTION_InstallExecute(package);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
2005-01-25 21:17:09 +01:00
|
|
|
|
|
|
|
/* then handle Commit Actions */
|
2005-05-27 21:24:22 +02:00
|
|
|
rc = execute_script(package,COMMIT_SCRIPT);
|
2010-07-20 14:54:50 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
remove = msi_dup_property(package->db, szRemove);
|
|
|
|
if (remove)
|
|
|
|
rc = msi_unpublish_product(package, remove);
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2010-07-20 14:54:50 +02:00
|
|
|
msi_free(remove);
|
2005-05-27 21:24:22 +02:00
|
|
|
return rc;
|
2005-01-19 20:07:40 +01:00
|
|
|
}
|
|
|
|
|
2007-05-29 21:03:05 +02:00
|
|
|
UINT ACTION_ForceReboot(MSIPACKAGE *package)
|
2005-01-19 20:07:40 +01:00
|
|
|
{
|
|
|
|
static const WCHAR RunOnce[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
2005-02-22 20:31:45 +01:00
|
|
|
'R','u','n','O','n','c','e',0};
|
2005-01-19 20:07:40 +01:00
|
|
|
static const WCHAR InstallRunOnce[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'I','n','s','t','a','l','l','e','r','\\',
|
2005-02-22 20:31:45 +01:00
|
|
|
'R','u','n','O','n','c','e','E','n','t','r','i','e','s',0};
|
2005-01-19 20:07:40 +01:00
|
|
|
|
|
|
|
static const WCHAR msiexec_fmt[] = {
|
2005-03-01 11:41:52 +01:00
|
|
|
'%','s',
|
2005-01-19 20:07:40 +01:00
|
|
|
'\\','M','s','i','E','x','e','c','.','e','x','e',' ','/','@',' ',
|
|
|
|
'\"','%','s','\"',0};
|
|
|
|
static const WCHAR install_fmt[] = {
|
|
|
|
'/','I',' ','\"','%','s','\"',' ',
|
|
|
|
'A','F','T','E','R','R','E','B','O','O','T','=','1',' ',
|
|
|
|
'R','U','N','O','N','C','E','E','N','T','R','Y','=','\"','%','s','\"',0};
|
2005-03-01 11:41:52 +01:00
|
|
|
WCHAR buffer[256], sysdir[MAX_PATH];
|
2005-07-07 22:27:06 +02:00
|
|
|
HKEY hkey;
|
2005-09-15 16:58:38 +02:00
|
|
|
WCHAR squished_pc[100];
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2005-07-07 22:27:06 +02:00
|
|
|
squash_guid(package->ProductCode,squished_pc);
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2005-03-01 11:41:52 +01:00
|
|
|
GetSystemDirectoryW(sysdir, sizeof(sysdir)/sizeof(sysdir[0]));
|
2005-01-19 20:07:40 +01:00
|
|
|
RegCreateKeyW(HKEY_LOCAL_MACHINE,RunOnce,&hkey);
|
2005-03-01 11:41:52 +01:00
|
|
|
snprintfW(buffer,sizeof(buffer)/sizeof(buffer[0]),msiexec_fmt,sysdir,
|
|
|
|
squished_pc);
|
2005-01-19 20:07:40 +01:00
|
|
|
|
2005-09-15 16:58:38 +02:00
|
|
|
msi_reg_set_val_str( hkey, squished_pc, buffer );
|
2005-01-19 20:07:40 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
TRACE("Reboot command %s\n",debugstr_w(buffer));
|
|
|
|
|
|
|
|
RegCreateKeyW(HKEY_LOCAL_MACHINE,InstallRunOnce,&hkey);
|
2005-07-07 22:27:06 +02:00
|
|
|
sprintfW(buffer,install_fmt,package->ProductCode,squished_pc);
|
2005-02-24 13:47:43 +01:00
|
|
|
|
2005-09-15 16:58:38 +02:00
|
|
|
msi_reg_set_val_str( hkey, squished_pc, buffer );
|
2005-01-19 20:07:40 +01:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2005-01-25 12:05:37 +01:00
|
|
|
return ERROR_INSTALL_SUSPEND;
|
2005-01-19 20:07:40 +01:00
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
WCHAR *msi_build_error_string( MSIPACKAGE *package, UINT error, DWORD count, ... )
|
|
|
|
{
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','`','M','e','s','s','a','g','e','`',' ',
|
|
|
|
'F','R','O','M',' ','`','E','r','r','o','r','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','E','r','r','o','r','`',' ','=',' ','%','i',0};
|
|
|
|
MSIRECORD *rec, *row;
|
|
|
|
DWORD i, size = 0;
|
|
|
|
va_list va;
|
|
|
|
const WCHAR *str;
|
|
|
|
WCHAR *data;
|
|
|
|
|
|
|
|
if (!(row = MSI_QueryGetRecord( package->db, query, error ))) return 0;
|
|
|
|
|
|
|
|
rec = MSI_CreateRecord( count + 2 );
|
|
|
|
str = MSI_RecordGetString( row, 1 );
|
|
|
|
MSI_RecordSetStringW( rec, 0, str );
|
|
|
|
msiobj_release( &row->hdr );
|
|
|
|
MSI_RecordSetInteger( rec, 1, error );
|
|
|
|
|
|
|
|
va_start( va, count );
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
str = va_arg( va, const WCHAR *);
|
|
|
|
MSI_RecordSetStringW( rec, i + 2, str );
|
|
|
|
}
|
|
|
|
va_end( va );
|
|
|
|
|
|
|
|
MSI_FormatRecordW( package, rec, NULL, &size );
|
|
|
|
size++;
|
|
|
|
data = msi_alloc( size * sizeof(WCHAR) );
|
|
|
|
if (size > 1) MSI_FormatRecordW( package, rec, data, &size );
|
|
|
|
else data[0] = 0;
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2006-10-09 09:05:04 +02:00
|
|
|
static UINT ACTION_ResolveSource(MSIPACKAGE* package)
|
2005-01-31 17:23:12 +01:00
|
|
|
{
|
2006-11-20 08:27:36 +01:00
|
|
|
DWORD attrib;
|
2005-08-15 22:50:06 +02:00
|
|
|
UINT rc;
|
2006-11-20 08:17:03 +01:00
|
|
|
|
2005-01-31 17:23:12 +01:00
|
|
|
/*
|
2006-11-20 08:17:03 +01:00
|
|
|
* We are currently doing what should be done here in the top level Install
|
|
|
|
* however for Administrative and uninstalls this step will be needed
|
2005-01-31 17:23:12 +01:00
|
|
|
*/
|
2005-08-15 22:50:06 +02:00
|
|
|
if (!package->PackagePath)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2008-01-05 21:45:13 +01:00
|
|
|
msi_set_sourcedir_props(package, TRUE);
|
2006-10-10 22:39:50 +02:00
|
|
|
|
2008-01-05 21:48:32 +01:00
|
|
|
attrib = GetFileAttributesW(package->db->path);
|
2005-08-15 22:50:06 +02:00
|
|
|
if (attrib == INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
LPWSTR prompt;
|
|
|
|
LPWSTR msg;
|
|
|
|
DWORD size = 0;
|
|
|
|
|
|
|
|
rc = MsiSourceListGetInfoW(package->ProductCode, NULL,
|
2008-04-05 07:10:02 +02:00
|
|
|
package->Context, MSICODE_PRODUCT,
|
2005-08-15 22:50:06 +02:00
|
|
|
INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
|
|
|
|
if (rc == ERROR_MORE_DATA)
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
prompt = msi_alloc(size * sizeof(WCHAR));
|
2005-08-15 22:50:06 +02:00
|
|
|
MsiSourceListGetInfoW(package->ProductCode, NULL,
|
2008-04-05 07:10:02 +02:00
|
|
|
package->Context, MSICODE_PRODUCT,
|
2005-08-15 22:50:06 +02:00
|
|
|
INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
|
|
|
|
}
|
|
|
|
else
|
2008-01-05 21:48:32 +01:00
|
|
|
prompt = strdupW(package->db->path);
|
2005-08-15 22:50:06 +02:00
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
msg = msi_build_error_string(package, 1302, 1, prompt);
|
2005-08-15 22:50:06 +02:00
|
|
|
while(attrib == INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
rc = MessageBoxW(NULL,msg,NULL,MB_OKCANCEL);
|
|
|
|
if (rc == IDCANCEL)
|
|
|
|
{
|
|
|
|
rc = ERROR_INSTALL_USEREXIT;
|
|
|
|
break;
|
|
|
|
}
|
2008-01-05 21:48:32 +01:00
|
|
|
attrib = GetFileAttributesW(package->db->path);
|
2005-08-15 22:50:06 +02:00
|
|
|
}
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(prompt);
|
2005-08-15 22:50:06 +02:00
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
return rc;
|
2005-01-31 17:23:12 +01:00
|
|
|
}
|
|
|
|
|
2005-02-10 18:09:44 +01:00
|
|
|
static UINT ACTION_RegisterUser(MSIPACKAGE *package)
|
|
|
|
{
|
2010-03-05 12:28:34 +01:00
|
|
|
HKEY hkey = 0;
|
|
|
|
LPWSTR buffer, productid = NULL;
|
|
|
|
UINT i, rc = ERROR_SUCCESS;
|
|
|
|
MSIRECORD *uirow;
|
2005-02-10 18:09:44 +01:00
|
|
|
|
|
|
|
static const WCHAR szPropKeys[][80] =
|
|
|
|
{
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','r','o','d','u','c','t','I','D',0},
|
|
|
|
{'U','S','E','R','N','A','M','E',0},
|
|
|
|
{'C','O','M','P','A','N','Y','N','A','M','E',0},
|
|
|
|
{0},
|
2005-02-10 18:09:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR szRegKeys[][80] =
|
|
|
|
{
|
2005-03-01 12:45:19 +01:00
|
|
|
{'P','r','o','d','u','c','t','I','D',0},
|
|
|
|
{'R','e','g','O','w','n','e','r',0},
|
|
|
|
{'R','e','g','C','o','m','p','a','n','y',0},
|
|
|
|
{0},
|
2005-02-10 18:09:44 +01:00
|
|
|
};
|
|
|
|
|
2008-03-06 23:12:40 +01:00
|
|
|
if (msi_check_unpublish(package))
|
|
|
|
{
|
|
|
|
MSIREG_DeleteUserDataProductKey(package->ProductCode);
|
2010-03-05 12:28:34 +01:00
|
|
|
goto end;
|
2008-03-06 23:12:40 +01:00
|
|
|
}
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
productid = msi_dup_property( package->db, INSTALLPROPERTY_PRODUCTIDW );
|
2005-02-10 18:09:44 +01:00
|
|
|
if (!productid)
|
2010-03-05 12:28:34 +01:00
|
|
|
goto end;
|
2005-02-10 18:09:44 +01:00
|
|
|
|
2008-12-15 04:07:14 +01:00
|
|
|
rc = MSIREG_OpenInstallProps(package->ProductCode, package->Context,
|
|
|
|
NULL, &hkey, TRUE);
|
2005-02-10 18:09:44 +01:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
2005-09-16 20:45:19 +02:00
|
|
|
for( i = 0; szPropKeys[i][0]; i++ )
|
2005-02-10 18:09:44 +01:00
|
|
|
{
|
2010-04-21 11:37:54 +02:00
|
|
|
buffer = msi_dup_property( package->db, szPropKeys[i] );
|
2005-09-15 16:58:38 +02:00
|
|
|
msi_reg_set_val_str( hkey, szRegKeys[i], buffer );
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free( buffer );
|
2005-02-10 18:09:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2010-03-05 12:28:34 +01:00
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, productid );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRegisterUser, uirow );
|
2010-03-05 12:28:34 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(productid);
|
2005-02-10 18:09:44 +01:00
|
|
|
RegCloseKey(hkey);
|
2008-03-06 23:12:40 +01:00
|
|
|
return rc;
|
2005-02-10 18:09:44 +01:00
|
|
|
}
|
|
|
|
|
2005-02-24 13:47:43 +01:00
|
|
|
|
|
|
|
static UINT ACTION_ExecuteAction(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
2005-06-24 14:14:52 +02:00
|
|
|
|
2005-06-30 22:45:43 +02:00
|
|
|
package->script->InWhatSequence |= SEQUENCE_EXEC;
|
2005-05-13 15:56:39 +02:00
|
|
|
rc = ACTION_ProcessExecSequence(package,FALSE);
|
2005-02-24 13:47:43 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
WCHAR *msi_create_component_advertise_string( MSIPACKAGE *package, MSICOMPONENT *component, const WCHAR *feature )
|
|
|
|
{
|
|
|
|
static const WCHAR fmt[] = {'%','s','%','s','%','c','%','s',0};
|
|
|
|
WCHAR productid_85[21], component_85[21], *ret;
|
|
|
|
GUID clsid;
|
|
|
|
DWORD sz;
|
|
|
|
|
|
|
|
/* > is used if there is a component GUID and < if not. */
|
|
|
|
|
|
|
|
productid_85[0] = 0;
|
|
|
|
component_85[0] = 0;
|
|
|
|
CLSIDFromString( package->ProductCode, &clsid );
|
|
|
|
|
|
|
|
encode_base85_guid( &clsid, productid_85 );
|
|
|
|
if (component)
|
|
|
|
{
|
|
|
|
CLSIDFromString( component->ComponentId, &clsid );
|
|
|
|
encode_base85_guid( &clsid, component_85 );
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("product=%s feature=%s component=%s\n", debugstr_w(productid_85), debugstr_w(feature),
|
|
|
|
debugstr_w(component_85));
|
|
|
|
|
|
|
|
sz = 20 + strlenW( feature ) + 20 + 3;
|
|
|
|
ret = msi_alloc_zero( sz * sizeof(WCHAR) );
|
|
|
|
if (ret) sprintfW( ret, fmt, productid_85, feature, component ? '>' : '<', component_85 );
|
|
|
|
return ret;
|
|
|
|
}
|
2005-02-25 15:00:09 +01:00
|
|
|
|
2005-04-20 14:50:05 +02:00
|
|
|
static UINT ITERATE_PublishComponent(MSIRECORD *rec, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-02-17 09:55:03 +01:00
|
|
|
LPCWSTR compgroupid, component, feature, qualifier, text;
|
2011-02-10 15:56:41 +01:00
|
|
|
LPWSTR advertise = NULL, output = NULL, existing = NULL, p, q;
|
2010-03-04 09:17:50 +01:00
|
|
|
HKEY hkey = NULL;
|
2010-02-17 09:55:03 +01:00
|
|
|
UINT rc;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2010-02-17 09:55:03 +01:00
|
|
|
MSIFEATURE *feat;
|
|
|
|
DWORD sz;
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIRECORD *uirow;
|
2011-02-10 15:56:41 +01:00
|
|
|
int len;
|
2005-05-13 15:56:39 +02:00
|
|
|
|
2010-02-17 09:55:03 +01:00
|
|
|
feature = MSI_RecordGetString(rec, 5);
|
2011-05-06 14:39:17 +02:00
|
|
|
feat = msi_get_loaded_feature(package, feature);
|
2010-02-17 09:55:03 +01:00
|
|
|
if (!feat)
|
2010-02-16 11:44:47 +01:00
|
|
|
return ERROR_SUCCESS;
|
2005-08-22 11:15:23 +02:00
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
feat->Action = msi_get_feature_action( package, feat );
|
|
|
|
if (feat->Action != INSTALLSTATE_LOCAL &&
|
|
|
|
feat->Action != INSTALLSTATE_SOURCE &&
|
|
|
|
feat->Action != INSTALLSTATE_ADVERTISED)
|
2005-05-13 15:56:39 +02:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("feature not scheduled for installation %s\n", debugstr_w(feature));
|
2005-05-13 15:56:39 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2010-02-17 09:55:03 +01:00
|
|
|
component = MSI_RecordGetString(rec, 3);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-02-17 09:55:03 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2005-06-09 22:30:59 +02:00
|
|
|
compgroupid = MSI_RecordGetString(rec,1);
|
2006-01-23 17:29:50 +01:00
|
|
|
qualifier = MSI_RecordGetString(rec,2);
|
2005-04-20 14:50:05 +02:00
|
|
|
|
|
|
|
rc = MSIREG_OpenUserComponentsKey(compgroupid, &hkey, TRUE);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
goto end;
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
advertise = msi_create_component_advertise_string( package, comp, feature );
|
2011-02-10 15:56:41 +01:00
|
|
|
text = MSI_RecordGetString( rec, 4 );
|
2005-04-20 14:50:05 +02:00
|
|
|
if (text)
|
2011-02-10 15:56:41 +01:00
|
|
|
{
|
|
|
|
p = msi_alloc( (strlenW( advertise ) + strlenW( text ) + 1) * sizeof(WCHAR) );
|
|
|
|
strcpyW( p, advertise );
|
|
|
|
strcatW( p, text );
|
|
|
|
msi_free( advertise );
|
|
|
|
advertise = p;
|
|
|
|
}
|
|
|
|
existing = msi_reg_get_val_str( hkey, qualifier );
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2011-02-10 15:56:41 +01:00
|
|
|
sz = strlenW( advertise ) + 1;
|
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
for (p = existing; *p; p += len)
|
|
|
|
{
|
|
|
|
len = strlenW( p ) + 1;
|
|
|
|
if (strcmpW( advertise, p )) sz += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!(output = msi_alloc( (sz + 1) * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
rc = ERROR_OUTOFMEMORY;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
q = output;
|
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
for (p = existing; *p; p += len)
|
|
|
|
{
|
|
|
|
len = strlenW( p ) + 1;
|
|
|
|
if (strcmpW( advertise, p ))
|
|
|
|
{
|
|
|
|
memcpy( q, p, len * sizeof(WCHAR) );
|
|
|
|
q += len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpyW( q, advertise );
|
|
|
|
q[strlenW( q ) + 1] = 0;
|
2005-04-20 14:50:05 +02:00
|
|
|
|
2005-09-15 16:58:38 +02:00
|
|
|
msi_reg_set_val_multi_str( hkey, qualifier, output );
|
2005-04-20 14:50:05 +02:00
|
|
|
|
|
|
|
end:
|
|
|
|
RegCloseKey(hkey);
|
2011-02-10 15:56:41 +01:00
|
|
|
msi_free( output );
|
|
|
|
msi_free( advertise );
|
|
|
|
msi_free( existing );
|
2006-01-23 17:29:50 +01:00
|
|
|
|
|
|
|
/* the UI chunk */
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, compgroupid );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, qualifier);
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szPublishComponents, uirow );
|
2006-01-23 17:29:50 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
/* FIXME: call ui_progress? */
|
|
|
|
|
2005-04-20 14:50:05 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At present I am ignorning the advertised components part of this and only
|
|
|
|
* focusing on the qualified component sets
|
|
|
|
*/
|
|
|
|
static UINT ACTION_PublishComponents(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
2005-05-20 11:40:42 +02:00
|
|
|
'`','P','u','b','l','i','s','h',
|
|
|
|
'C','o','m','p','o','n','e','n','t','`',0};
|
2005-04-20 14:50:05 +02:00
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_PublishComponent, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2005-09-23 12:09:18 +02:00
|
|
|
|
2010-02-17 09:55:31 +01:00
|
|
|
static UINT ITERATE_UnpublishComponent( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
static const WCHAR szInstallerComponents[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'I','n','s','t','a','l','l','e','r','\\',
|
|
|
|
'C','o','m','p','o','n','e','n','t','s','\\',0};
|
|
|
|
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR compgroupid, component, feature, qualifier;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIFEATURE *feat;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
WCHAR squashed[GUID_SIZE], keypath[MAX_PATH];
|
|
|
|
LONG res;
|
|
|
|
|
|
|
|
feature = MSI_RecordGetString( rec, 5 );
|
2011-05-06 14:39:17 +02:00
|
|
|
feat = msi_get_loaded_feature( package, feature );
|
2010-02-17 09:55:31 +01:00
|
|
|
if (!feat)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
feat->Action = msi_get_feature_action( package, feat );
|
|
|
|
if (feat->Action != INSTALLSTATE_ABSENT)
|
2010-02-17 09:55:31 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("feature not scheduled for removal %s\n", debugstr_w(feature));
|
2010-02-17 09:55:31 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( rec, 3 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-02-17 09:55:31 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
compgroupid = MSI_RecordGetString( rec, 1 );
|
|
|
|
qualifier = MSI_RecordGetString( rec, 2 );
|
|
|
|
|
|
|
|
squash_guid( compgroupid, squashed );
|
|
|
|
strcpyW( keypath, szInstallerComponents );
|
|
|
|
strcatW( keypath, squashed );
|
|
|
|
|
|
|
|
res = RegDeleteKeyW( HKEY_CURRENT_USER, keypath );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("Unable to delete component key %d\n", res);
|
|
|
|
}
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, compgroupid );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, qualifier );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szUnpublishComponents, uirow );
|
2010-02-17 09:55:31 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_UnpublishComponents( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','P','u','b','l','i','s','h',
|
|
|
|
'C','o','m','p','o','n','e','n','t','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_UnpublishComponent, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-10-20 00:49:54 +02:00
|
|
|
static UINT ITERATE_InstallService(MSIRECORD *rec, LPVOID param)
|
|
|
|
{
|
2011-05-02 16:03:14 +02:00
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','C','o','m','p','o','n','e','n','t','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','C','o','m','p','o','n','e','n','t','`',' ','=','\'','%','s','\'',0};
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2011-05-02 16:03:14 +02:00
|
|
|
MSICOMPONENT *component;
|
2006-10-20 00:49:54 +02:00
|
|
|
MSIRECORD *row;
|
|
|
|
MSIFILE *file;
|
2011-05-02 16:03:14 +02:00
|
|
|
SC_HANDLE hscm = NULL, service = NULL;
|
2010-10-22 10:36:45 +02:00
|
|
|
LPCWSTR comp, key;
|
|
|
|
LPWSTR name = NULL, disp = NULL, load_order = NULL, serv_name = NULL;
|
2010-10-22 10:37:02 +02:00
|
|
|
LPWSTR depends = NULL, pass = NULL, args = NULL, image_path = NULL;
|
|
|
|
DWORD serv_type, start_type, err_control;
|
2010-10-22 10:36:20 +02:00
|
|
|
SERVICE_DESCRIPTIONW sd = {NULL};
|
2006-10-20 00:49:54 +02:00
|
|
|
|
2011-05-02 16:03:14 +02:00
|
|
|
comp = MSI_RecordGetString( rec, 12 );
|
2011-05-06 14:39:17 +02:00
|
|
|
component = msi_get_loaded_component( package, comp );
|
2011-05-02 16:03:14 +02:00
|
|
|
if (!component)
|
|
|
|
{
|
|
|
|
WARN("service component not found\n");
|
|
|
|
goto done;
|
|
|
|
}
|
2011-05-24 10:51:33 +02:00
|
|
|
component->Action = msi_get_component_action( package, component );
|
|
|
|
if (component->Action != INSTALLSTATE_LOCAL)
|
2011-05-02 16:03:14 +02:00
|
|
|
{
|
2011-05-24 10:51:33 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(comp));
|
2011-05-02 16:03:14 +02:00
|
|
|
goto done;
|
|
|
|
}
|
2006-10-20 00:49:54 +02:00
|
|
|
hscm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, GENERIC_WRITE);
|
|
|
|
if (!hscm)
|
|
|
|
{
|
|
|
|
ERR("Failed to open the SC Manager!\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
start_type = MSI_RecordGetInteger(rec, 5);
|
|
|
|
if (start_type == SERVICE_BOOT_START || start_type == SERVICE_SYSTEM_START)
|
|
|
|
goto done;
|
|
|
|
|
2008-03-12 00:08:57 +01:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 2), &name);
|
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 3), &disp);
|
2006-10-20 00:49:54 +02:00
|
|
|
serv_type = MSI_RecordGetInteger(rec, 4);
|
|
|
|
err_control = MSI_RecordGetInteger(rec, 6);
|
2010-10-22 10:36:32 +02:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 7), &load_order);
|
2010-10-22 10:36:45 +02:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 8), &depends);
|
2010-10-22 10:36:32 +02:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 9), &serv_name);
|
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 10), &pass);
|
2010-10-22 10:37:02 +02:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 11), &args);
|
2010-10-22 10:36:20 +02:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 13), &sd.lpDescription);
|
2006-10-20 00:49:54 +02:00
|
|
|
|
|
|
|
/* fetch the service path */
|
|
|
|
row = MSI_QueryGetRecord(package->db, query, comp);
|
|
|
|
if (!row)
|
|
|
|
{
|
2011-05-02 16:03:14 +02:00
|
|
|
ERR("Query failed\n");
|
2006-10-20 00:49:54 +02:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
key = MSI_RecordGetString(row, 6);
|
2011-05-06 14:39:17 +02:00
|
|
|
file = msi_get_loaded_file(package, key);
|
2007-10-23 10:06:59 +02:00
|
|
|
msiobj_release(&row->hdr);
|
2006-10-20 00:49:54 +02:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
ERR("Failed to load the service file\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-10-22 10:37:02 +02:00
|
|
|
if (!args || !args[0]) image_path = file->TargetPath;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len = strlenW(file->TargetPath) + strlenW(args) + 2;
|
|
|
|
if (!(image_path = msi_alloc(len * sizeof(WCHAR))))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
strcpyW(image_path, file->TargetPath);
|
|
|
|
strcatW(image_path, szSpace);
|
|
|
|
strcatW(image_path, args);
|
|
|
|
}
|
2006-10-20 00:49:54 +02:00
|
|
|
service = CreateServiceW(hscm, name, disp, GENERIC_ALL, serv_type,
|
2010-10-22 10:37:02 +02:00
|
|
|
start_type, err_control, image_path, load_order,
|
|
|
|
NULL, depends, serv_name, pass);
|
|
|
|
|
2006-10-20 00:49:54 +02:00
|
|
|
if (!service)
|
|
|
|
{
|
|
|
|
if (GetLastError() != ERROR_SERVICE_EXISTS)
|
|
|
|
ERR("Failed to create service %s: %d\n", debugstr_w(name), GetLastError());
|
|
|
|
}
|
2010-10-22 10:36:20 +02:00
|
|
|
else if (sd.lpDescription)
|
|
|
|
{
|
|
|
|
if (!ChangeServiceConfig2W(service, SERVICE_CONFIG_DESCRIPTION, &sd))
|
|
|
|
WARN("failed to set service description %u\n", GetLastError());
|
|
|
|
}
|
2006-10-20 00:49:54 +02:00
|
|
|
|
2010-10-22 10:37:02 +02:00
|
|
|
if (image_path != file->TargetPath) msi_free(image_path);
|
2006-10-20 00:49:54 +02:00
|
|
|
done:
|
|
|
|
CloseServiceHandle(service);
|
|
|
|
CloseServiceHandle(hscm);
|
2008-03-12 00:08:57 +01:00
|
|
|
msi_free(name);
|
|
|
|
msi_free(disp);
|
2010-10-22 10:36:20 +02:00
|
|
|
msi_free(sd.lpDescription);
|
2010-10-22 10:36:32 +02:00
|
|
|
msi_free(load_order);
|
|
|
|
msi_free(serv_name);
|
|
|
|
msi_free(pass);
|
2010-10-22 10:36:45 +02:00
|
|
|
msi_free(depends);
|
2010-10-22 10:37:02 +02:00
|
|
|
msi_free(args);
|
2006-10-20 00:49:54 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_InstallServices( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'S','e','r','v','i','c','e','I','n','s','t','a','l','l',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_InstallService, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-12-01 22:22:59 +01:00
|
|
|
/* converts arg1[~]arg2[~]arg3 to a list of ptrs to the strings */
|
2007-11-05 10:37:44 +01:00
|
|
|
static LPCWSTR *msi_service_args_to_vector(LPWSTR args, DWORD *numargs)
|
2006-12-01 22:22:59 +01:00
|
|
|
{
|
2007-12-30 19:01:09 +01:00
|
|
|
LPCWSTR *vector, *temp_vector;
|
2006-12-01 22:22:59 +01:00
|
|
|
LPWSTR p, q;
|
|
|
|
DWORD sep_len;
|
|
|
|
|
|
|
|
static const WCHAR separator[] = {'[','~',']',0};
|
|
|
|
|
|
|
|
*numargs = 0;
|
|
|
|
sep_len = sizeof(separator) / sizeof(WCHAR) - 1;
|
|
|
|
|
|
|
|
if (!args)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
vector = msi_alloc(sizeof(LPWSTR));
|
|
|
|
if (!vector)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
p = args;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
(*numargs)++;
|
|
|
|
vector[*numargs - 1] = p;
|
|
|
|
|
|
|
|
if ((q = strstrW(p, separator)))
|
|
|
|
{
|
|
|
|
*q = '\0';
|
|
|
|
|
2007-12-30 19:01:09 +01:00
|
|
|
temp_vector = msi_realloc(vector, (*numargs + 1) * sizeof(LPWSTR));
|
|
|
|
if (!temp_vector)
|
|
|
|
{
|
|
|
|
msi_free(vector);
|
2006-12-01 22:22:59 +01:00
|
|
|
return NULL;
|
2007-12-30 19:01:09 +01:00
|
|
|
}
|
|
|
|
vector = temp_vector;
|
2006-12-01 22:22:59 +01:00
|
|
|
|
|
|
|
p = q + sep_len;
|
|
|
|
}
|
|
|
|
} while (q);
|
|
|
|
|
|
|
|
return vector;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_StartService(MSIRECORD *rec, LPVOID param)
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2006-12-01 22:22:59 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-26 12:11:21 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-02-12 10:33:23 +01:00
|
|
|
SC_HANDLE scm = NULL, service = NULL;
|
2010-03-02 14:56:01 +01:00
|
|
|
LPCWSTR component, *vector = NULL;
|
2010-03-26 12:11:21 +01:00
|
|
|
LPWSTR name, args, display_name = NULL;
|
|
|
|
DWORD event, numargs, len;
|
2006-12-01 22:22:59 +01:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
|
2010-03-02 14:56:01 +01:00
|
|
|
component = MSI_RecordGetString(rec, 6);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-03-02 14:56:01 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:33 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-03-02 14:56:01 +01:00
|
|
|
{
|
2011-05-24 10:51:33 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2006-12-01 22:22:59 +01:00
|
|
|
return ERROR_SUCCESS;
|
2010-03-02 14:56:01 +01:00
|
|
|
}
|
2006-12-01 22:22:59 +01:00
|
|
|
|
2010-01-28 11:05:34 +01:00
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 2), &name);
|
|
|
|
deformat_string(package, MSI_RecordGetString(rec, 4), &args);
|
2006-12-01 22:22:59 +01:00
|
|
|
event = MSI_RecordGetInteger(rec, 3);
|
|
|
|
|
|
|
|
if (!(event & msidbServiceControlEventStart))
|
2010-02-12 10:33:23 +01:00
|
|
|
{
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
2006-12-01 22:22:59 +01:00
|
|
|
|
|
|
|
scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_CONNECT);
|
|
|
|
if (!scm)
|
|
|
|
{
|
|
|
|
ERR("Failed to open the service control manager\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-03-26 12:11:21 +01:00
|
|
|
len = 0;
|
|
|
|
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
|
|
|
|
GetServiceDisplayNameW( scm, name, display_name, &len );
|
|
|
|
}
|
|
|
|
|
2006-12-01 22:22:59 +01:00
|
|
|
service = OpenServiceW(scm, name, SERVICE_START);
|
|
|
|
if (!service)
|
|
|
|
{
|
2010-01-28 11:06:05 +01:00
|
|
|
ERR("Failed to open service %s (%u)\n", debugstr_w(name), GetLastError());
|
2006-12-01 22:22:59 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-11-05 10:37:44 +01:00
|
|
|
vector = msi_service_args_to_vector(args, &numargs);
|
2006-12-01 22:22:59 +01:00
|
|
|
|
2010-02-01 09:55:08 +01:00
|
|
|
if (!StartServiceW(service, numargs, vector) &&
|
|
|
|
GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)
|
2006-12-01 22:22:59 +01:00
|
|
|
{
|
2010-01-28 11:06:05 +01:00
|
|
|
ERR("Failed to start service %s (%u)\n", debugstr_w(name), GetLastError());
|
2006-12-01 22:22:59 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
done:
|
2010-03-26 12:11:21 +01:00
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, display_name );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, name );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szStartServices, uirow );
|
2010-03-26 12:11:21 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2006-12-01 22:22:59 +01:00
|
|
|
CloseServiceHandle(service);
|
|
|
|
CloseServiceHandle(scm);
|
|
|
|
|
2010-01-28 11:05:34 +01:00
|
|
|
msi_free(name);
|
2006-12-01 22:22:59 +01:00
|
|
|
msi_free(args);
|
|
|
|
msi_free(vector);
|
2010-03-26 12:11:21 +01:00
|
|
|
msi_free(display_name);
|
2006-12-01 22:22:59 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_StartServices( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_StartService, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2008-03-24 07:31:07 +01:00
|
|
|
static BOOL stop_service_dependents(SC_HANDLE scm, SC_HANDLE service)
|
|
|
|
{
|
|
|
|
DWORD i, needed, count;
|
|
|
|
ENUM_SERVICE_STATUSW *dependencies;
|
|
|
|
SERVICE_STATUS ss;
|
|
|
|
SC_HANDLE depserv;
|
|
|
|
|
|
|
|
if (EnumDependentServicesW(service, SERVICE_ACTIVE, NULL,
|
|
|
|
0, &needed, &count))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (GetLastError() != ERROR_MORE_DATA)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
dependencies = msi_alloc(needed);
|
|
|
|
if (!dependencies)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!EnumDependentServicesW(service, SERVICE_ACTIVE, dependencies,
|
|
|
|
needed, &needed, &count))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
depserv = OpenServiceW(scm, dependencies[i].lpServiceName,
|
|
|
|
SERVICE_STOP | SERVICE_QUERY_STATUS);
|
|
|
|
if (!depserv)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!ControlService(depserv, SERVICE_CONTROL_STOP, &ss))
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
msi_free(dependencies);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-02-04 10:04:09 +01:00
|
|
|
static UINT stop_service( LPCWSTR name )
|
2008-03-24 07:31:07 +01:00
|
|
|
{
|
2010-02-04 10:04:09 +01:00
|
|
|
SC_HANDLE scm = NULL, service = NULL;
|
2008-03-24 07:31:07 +01:00
|
|
|
SERVICE_STATUS status;
|
|
|
|
SERVICE_STATUS_PROCESS ssp;
|
2010-02-04 10:04:09 +01:00
|
|
|
DWORD needed;
|
2008-03-24 07:31:07 +01:00
|
|
|
|
|
|
|
scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
|
|
if (!scm)
|
|
|
|
{
|
|
|
|
WARN("Failed to open the SCM: %d\n", GetLastError());
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
service = OpenServiceW(scm, name,
|
|
|
|
SERVICE_STOP |
|
|
|
|
SERVICE_QUERY_STATUS |
|
|
|
|
SERVICE_ENUMERATE_DEPENDENTS);
|
|
|
|
if (!service)
|
|
|
|
{
|
2010-02-04 10:04:09 +01:00
|
|
|
WARN("Failed to open service (%s): %d\n", debugstr_w(name), GetLastError());
|
2008-03-24 07:31:07 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp,
|
|
|
|
sizeof(SERVICE_STATUS_PROCESS), &needed))
|
|
|
|
{
|
2010-02-04 10:04:09 +01:00
|
|
|
WARN("Failed to query service status (%s): %d\n", debugstr_w(name), GetLastError());
|
2008-03-24 07:31:07 +01:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ssp.dwCurrentState == SERVICE_STOPPED)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
stop_service_dependents(scm, service);
|
|
|
|
|
2008-03-24 22:16:58 +01:00
|
|
|
if (!ControlService(service, SERVICE_CONTROL_STOP, &status))
|
2008-03-24 07:31:07 +01:00
|
|
|
WARN("Failed to stop service (%s): %d\n", debugstr_w(name), GetLastError());
|
|
|
|
|
|
|
|
done:
|
|
|
|
CloseServiceHandle(service);
|
|
|
|
CloseServiceHandle(scm);
|
2010-02-04 10:04:09 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_StopService( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
MSICOMPONENT *comp;
|
2010-03-26 12:11:21 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-03-02 14:56:26 +01:00
|
|
|
LPCWSTR component;
|
2010-03-26 12:11:21 +01:00
|
|
|
LPWSTR name = NULL, display_name = NULL;
|
|
|
|
DWORD event, len;
|
|
|
|
SC_HANDLE scm;
|
2010-02-04 10:04:09 +01:00
|
|
|
|
|
|
|
event = MSI_RecordGetInteger( rec, 3 );
|
|
|
|
if (!(event & msidbServiceControlEventStop))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2010-03-02 14:56:26 +01:00
|
|
|
component = MSI_RecordGetString( rec, 6 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-03-02 14:56:26 +01:00
|
|
|
if (!comp)
|
2010-02-04 10:04:09 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:33 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-03-02 14:56:26 +01:00
|
|
|
{
|
2011-05-24 10:51:33 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-03-02 14:56:26 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-03-26 12:11:21 +01:00
|
|
|
scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT );
|
|
|
|
if (!scm)
|
|
|
|
{
|
|
|
|
ERR("Failed to open the service control manager\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
|
|
|
|
GetServiceDisplayNameW( scm, name, display_name, &len );
|
|
|
|
}
|
|
|
|
CloseServiceHandle( scm );
|
|
|
|
|
2010-02-04 10:04:09 +01:00
|
|
|
deformat_string( package, MSI_RecordGetString( rec, 2 ), &name );
|
|
|
|
stop_service( name );
|
2008-03-24 07:31:07 +01:00
|
|
|
|
2010-03-26 12:11:21 +01:00
|
|
|
done:
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, display_name );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, name );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szStopServices, uirow );
|
2010-03-26 12:11:21 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
msi_free( name );
|
|
|
|
msi_free( display_name );
|
2008-03-24 07:31:07 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_StopServices( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_StopService, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-04 10:04:09 +01:00
|
|
|
static UINT ITERATE_DeleteService( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:24:41 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-03-02 14:56:51 +01:00
|
|
|
LPCWSTR component;
|
2010-03-05 12:24:41 +01:00
|
|
|
LPWSTR name = NULL, display_name = NULL;
|
|
|
|
DWORD event, len;
|
2010-02-04 10:04:09 +01:00
|
|
|
SC_HANDLE scm = NULL, service = NULL;
|
|
|
|
|
|
|
|
event = MSI_RecordGetInteger( rec, 3 );
|
|
|
|
if (!(event & msidbServiceControlEventDelete))
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2010-03-02 14:56:51 +01:00
|
|
|
component = MSI_RecordGetString(rec, 6);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-03-02 14:56:51 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:33 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-03-02 14:56:51 +01:00
|
|
|
{
|
2011-05-24 10:51:33 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-02-04 10:04:09 +01:00
|
|
|
return ERROR_SUCCESS;
|
2010-03-02 14:56:51 +01:00
|
|
|
}
|
2010-02-04 10:04:09 +01:00
|
|
|
|
|
|
|
deformat_string( package, MSI_RecordGetString(rec, 2), &name );
|
|
|
|
stop_service( name );
|
|
|
|
|
|
|
|
scm = OpenSCManagerW( NULL, NULL, SC_MANAGER_ALL_ACCESS );
|
|
|
|
if (!scm)
|
|
|
|
{
|
|
|
|
WARN("Failed to open the SCM: %d\n", GetLastError());
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:24:41 +01:00
|
|
|
len = 0;
|
|
|
|
if (!GetServiceDisplayNameW( scm, name, NULL, &len ) &&
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
{
|
|
|
|
if ((display_name = msi_alloc( ++len * sizeof(WCHAR ))))
|
|
|
|
GetServiceDisplayNameW( scm, name, display_name, &len );
|
|
|
|
}
|
|
|
|
|
2010-02-04 10:04:09 +01:00
|
|
|
service = OpenServiceW( scm, name, DELETE );
|
|
|
|
if (!service)
|
|
|
|
{
|
|
|
|
WARN("Failed to open service (%s): %u\n", debugstr_w(name), GetLastError());
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!DeleteService( service ))
|
|
|
|
WARN("Failed to delete service (%s): %u\n", debugstr_w(name), GetLastError());
|
|
|
|
|
|
|
|
done:
|
2010-03-05 12:24:41 +01:00
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, display_name );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, name );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szDeleteServices, uirow );
|
2010-03-05 12:24:41 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2010-02-04 10:04:09 +01:00
|
|
|
CloseServiceHandle( service );
|
|
|
|
CloseServiceHandle( scm );
|
|
|
|
msi_free( name );
|
2010-03-05 12:24:41 +01:00
|
|
|
msi_free( display_name );
|
2010-02-04 10:04:09 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_DeleteServices( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'S','e','r','v','i','c','e','C','o','n','t','r','o','l',0 };
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_DeleteService, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2006-11-28 03:20:33 +01:00
|
|
|
static UINT ITERATE_InstallODBCDriver( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2006-11-28 03:20:33 +01:00
|
|
|
LPWSTR driver, driver_path, ptr;
|
|
|
|
WCHAR outpath[MAX_PATH];
|
2010-10-19 11:27:44 +02:00
|
|
|
MSIFILE *driver_file = NULL, *setup_file = NULL;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:25:55 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, file_key, component;
|
2006-11-28 03:20:33 +01:00
|
|
|
DWORD len, usage;
|
|
|
|
UINT r = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
static const WCHAR driver_fmt[] = {
|
|
|
|
'D','r','i','v','e','r','=','%','s',0};
|
|
|
|
static const WCHAR setup_fmt[] = {
|
|
|
|
'S','e','t','u','p','=','%','s',0};
|
|
|
|
static const WCHAR usage_fmt[] = {
|
|
|
|
'F','i','l','e','U','s','a','g','e','=','1',0};
|
|
|
|
|
2010-12-09 10:27:56 +01:00
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2006-11-28 03:20:33 +01:00
|
|
|
desc = MSI_RecordGetString(rec, 3);
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
file_key = MSI_RecordGetString( rec, 4 );
|
2011-05-06 14:39:17 +02:00
|
|
|
if (file_key) driver_file = msi_get_loaded_file( package, file_key );
|
2010-10-19 11:27:44 +02:00
|
|
|
|
|
|
|
file_key = MSI_RecordGetString( rec, 5 );
|
2011-05-06 14:39:17 +02:00
|
|
|
if (file_key) setup_file = msi_get_loaded_file( package, file_key );
|
2006-11-28 03:20:33 +01:00
|
|
|
|
2010-02-11 13:12:55 +01:00
|
|
|
if (!driver_file)
|
2006-11-28 03:20:33 +01:00
|
|
|
{
|
|
|
|
ERR("ODBC Driver entry not found!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-02-11 13:12:55 +01:00
|
|
|
len = lstrlenW(desc) + lstrlenW(driver_fmt) + lstrlenW(driver_file->FileName);
|
|
|
|
if (setup_file)
|
|
|
|
len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName);
|
2010-02-22 12:26:09 +01:00
|
|
|
len += lstrlenW(usage_fmt) + 2; /* \0\0 */
|
2010-02-11 13:12:55 +01:00
|
|
|
|
2006-11-28 03:20:33 +01:00
|
|
|
driver = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!driver)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ptr = driver;
|
|
|
|
lstrcpyW(ptr, desc);
|
|
|
|
ptr += lstrlenW(ptr) + 1;
|
|
|
|
|
2010-02-22 12:26:09 +01:00
|
|
|
len = sprintfW(ptr, driver_fmt, driver_file->FileName);
|
|
|
|
ptr += len + 1;
|
2006-11-28 03:20:33 +01:00
|
|
|
|
2010-02-11 13:12:55 +01:00
|
|
|
if (setup_file)
|
|
|
|
{
|
2010-02-22 12:26:09 +01:00
|
|
|
len = sprintfW(ptr, setup_fmt, setup_file->FileName);
|
|
|
|
ptr += len + 1;
|
2010-02-11 13:12:55 +01:00
|
|
|
}
|
2006-11-28 03:20:33 +01:00
|
|
|
|
|
|
|
lstrcpyW(ptr, usage_fmt);
|
|
|
|
ptr += lstrlenW(ptr) + 1;
|
|
|
|
*ptr = '\0';
|
|
|
|
|
|
|
|
driver_path = strdupW(driver_file->TargetPath);
|
|
|
|
ptr = strrchrW(driver_path, '\\');
|
|
|
|
if (ptr) *ptr = '\0';
|
|
|
|
|
|
|
|
if (!SQLInstallDriverExW(driver, driver_path, outpath, MAX_PATH,
|
|
|
|
NULL, ODBC_INSTALL_COMPLETE, &usage))
|
|
|
|
{
|
|
|
|
ERR("Failed to install SQL driver!\n");
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:25:55 +01:00
|
|
|
uirow = MSI_CreateRecord( 5 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
2010-06-09 12:09:21 +02:00
|
|
|
MSI_RecordSetStringW( uirow, 3, driver_file->Component->Directory );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szInstallODBC, uirow );
|
2010-03-05 12:25:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2006-11-28 03:20:33 +01:00
|
|
|
msi_free(driver);
|
|
|
|
msi_free(driver_path);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
static UINT ITERATE_InstallODBCTranslator( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2009-01-15 09:46:57 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2007-04-22 11:37:51 +02:00
|
|
|
LPWSTR translator, translator_path, ptr;
|
|
|
|
WCHAR outpath[MAX_PATH];
|
2010-10-19 11:27:44 +02:00
|
|
|
MSIFILE *translator_file = NULL, *setup_file = NULL;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:25:55 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, file_key, component;
|
2007-04-22 11:37:51 +02:00
|
|
|
DWORD len, usage;
|
|
|
|
UINT r = ERROR_SUCCESS;
|
|
|
|
|
|
|
|
static const WCHAR translator_fmt[] = {
|
|
|
|
'T','r','a','n','s','l','a','t','o','r','=','%','s',0};
|
|
|
|
static const WCHAR setup_fmt[] = {
|
|
|
|
'S','e','t','u','p','=','%','s',0};
|
|
|
|
|
2010-12-09 10:27:56 +01:00
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2007-04-22 11:37:51 +02:00
|
|
|
desc = MSI_RecordGetString(rec, 3);
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
file_key = MSI_RecordGetString( rec, 4 );
|
2011-05-06 14:39:17 +02:00
|
|
|
if (file_key) translator_file = msi_get_loaded_file( package, file_key );
|
2010-10-19 11:27:44 +02:00
|
|
|
|
|
|
|
file_key = MSI_RecordGetString( rec, 5 );
|
2011-05-06 14:39:17 +02:00
|
|
|
if (file_key) setup_file = msi_get_loaded_file( package, file_key );
|
2007-04-22 11:37:51 +02:00
|
|
|
|
2010-02-11 13:12:55 +01:00
|
|
|
if (!translator_file)
|
2007-04-22 11:37:51 +02:00
|
|
|
{
|
|
|
|
ERR("ODBC Translator entry not found!\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-02-22 12:26:09 +01:00
|
|
|
len = lstrlenW(desc) + lstrlenW(translator_fmt) + lstrlenW(translator_file->FileName) + 2; /* \0\0 */
|
2010-02-11 13:12:55 +01:00
|
|
|
if (setup_file)
|
|
|
|
len += lstrlenW(setup_fmt) + lstrlenW(setup_file->FileName);
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
translator = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!translator)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ptr = translator;
|
|
|
|
lstrcpyW(ptr, desc);
|
|
|
|
ptr += lstrlenW(ptr) + 1;
|
|
|
|
|
2010-02-22 12:26:09 +01:00
|
|
|
len = sprintfW(ptr, translator_fmt, translator_file->FileName);
|
|
|
|
ptr += len + 1;
|
2007-04-22 11:37:51 +02:00
|
|
|
|
2010-02-11 13:12:55 +01:00
|
|
|
if (setup_file)
|
|
|
|
{
|
2010-02-22 12:26:09 +01:00
|
|
|
len = sprintfW(ptr, setup_fmt, setup_file->FileName);
|
|
|
|
ptr += len + 1;
|
2010-02-11 13:12:55 +01:00
|
|
|
}
|
2007-04-22 11:37:51 +02:00
|
|
|
*ptr = '\0';
|
|
|
|
|
|
|
|
translator_path = strdupW(translator_file->TargetPath);
|
|
|
|
ptr = strrchrW(translator_path, '\\');
|
|
|
|
if (ptr) *ptr = '\0';
|
|
|
|
|
|
|
|
if (!SQLInstallTranslatorExW(translator, translator_path, outpath, MAX_PATH,
|
|
|
|
NULL, ODBC_INSTALL_COMPLETE, &usage))
|
|
|
|
{
|
|
|
|
ERR("Failed to install SQL translator!\n");
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:25:55 +01:00
|
|
|
uirow = MSI_CreateRecord( 5 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
2010-06-09 12:09:21 +02:00
|
|
|
MSI_RecordSetStringW( uirow, 3, translator_file->Component->Directory );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szInstallODBC, uirow );
|
2010-03-05 12:25:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
msi_free(translator);
|
|
|
|
msi_free(translator_path);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-04-22 11:38:02 +02:00
|
|
|
static UINT ITERATE_InstallODBCDataSource( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2010-03-05 12:25:55 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2007-04-22 11:38:02 +02:00
|
|
|
LPWSTR attrs;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, driver, component;
|
2007-04-22 11:38:02 +02:00
|
|
|
WORD request = ODBC_ADD_SYS_DSN;
|
|
|
|
INT registration;
|
|
|
|
DWORD len;
|
|
|
|
UINT r = ERROR_SUCCESS;
|
2010-03-05 12:25:55 +01:00
|
|
|
MSIRECORD *uirow;
|
2007-04-22 11:38:02 +02:00
|
|
|
|
|
|
|
static const WCHAR attrs_fmt[] = {
|
|
|
|
'D','S','N','=','%','s',0 };
|
|
|
|
|
2010-12-09 10:27:56 +01:00
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-04-22 11:38:02 +02:00
|
|
|
desc = MSI_RecordGetString(rec, 3);
|
|
|
|
driver = MSI_RecordGetString(rec, 4);
|
|
|
|
registration = MSI_RecordGetInteger(rec, 5);
|
|
|
|
|
|
|
|
if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_ADD_SYS_DSN;
|
|
|
|
else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_ADD_DSN;
|
|
|
|
|
2010-02-22 12:26:09 +01:00
|
|
|
len = lstrlenW(attrs_fmt) + lstrlenW(desc) + 2; /* \0\0 */
|
2007-04-22 11:38:02 +02:00
|
|
|
attrs = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!attrs)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
2010-02-11 13:13:19 +01:00
|
|
|
len = sprintfW(attrs, attrs_fmt, desc);
|
|
|
|
attrs[len + 1] = 0;
|
2007-04-22 11:38:02 +02:00
|
|
|
|
|
|
|
if (!SQLConfigDataSourceW(NULL, request, driver, attrs))
|
|
|
|
{
|
|
|
|
ERR("Failed to install SQL data source!\n");
|
|
|
|
r = ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:25:55 +01:00
|
|
|
uirow = MSI_CreateRecord( 5 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
|
|
|
MSI_RecordSetInteger( uirow, 3, request );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szInstallODBC, uirow );
|
2010-03-05 12:25:55 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2007-04-22 11:38:02 +02:00
|
|
|
msi_free(attrs);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-11-28 03:20:33 +01:00
|
|
|
static UINT ACTION_InstallODBC( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
static const WCHAR driver_query[] = {
|
2006-11-28 03:20:33 +01:00
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','D','r','i','v','e','r',0 };
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
static const WCHAR translator_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
|
|
|
|
|
2007-04-22 11:38:02 +02:00
|
|
|
static const WCHAR source_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 };
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, driver_query, &view);
|
2006-11-28 03:20:33 +01:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_InstallODBCDriver, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
2007-04-22 11:37:51 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, translator_query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_InstallODBCTranslator, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
2007-04-22 11:38:02 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, source_query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_InstallODBCDataSource, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
2006-11-28 03:20:33 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-11 13:13:41 +01:00
|
|
|
static UINT ITERATE_RemoveODBCDriver( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-02-11 13:13:41 +01:00
|
|
|
DWORD usage;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, component;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-02-11 13:13:41 +01:00
|
|
|
|
|
|
|
desc = MSI_RecordGetString( rec, 3 );
|
|
|
|
if (!SQLRemoveDriverW( desc, FALSE, &usage ))
|
|
|
|
{
|
|
|
|
WARN("Failed to remove ODBC driver\n");
|
|
|
|
}
|
|
|
|
else if (!usage)
|
|
|
|
{
|
|
|
|
FIXME("Usage count reached 0\n");
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:26:21 +01:00
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveODBC, uirow );
|
2010-03-05 12:26:21 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2010-02-11 13:13:41 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_RemoveODBCTranslator( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-02-11 13:13:41 +01:00
|
|
|
DWORD usage;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, component;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-02-11 13:13:41 +01:00
|
|
|
|
|
|
|
desc = MSI_RecordGetString( rec, 3 );
|
|
|
|
if (!SQLRemoveTranslatorW( desc, &usage ))
|
|
|
|
{
|
|
|
|
WARN("Failed to remove ODBC translator\n");
|
|
|
|
}
|
|
|
|
else if (!usage)
|
|
|
|
{
|
|
|
|
FIXME("Usage count reached 0\n");
|
|
|
|
}
|
|
|
|
|
2010-03-05 12:26:21 +01:00
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveODBC, uirow );
|
2010-03-05 12:26:21 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2010-02-11 13:13:41 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_RemoveODBCDataSource( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIPACKAGE *package = param;
|
2010-12-09 10:27:56 +01:00
|
|
|
MSICOMPONENT *comp;
|
2010-03-05 12:26:21 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-02-11 13:13:41 +01:00
|
|
|
LPWSTR attrs;
|
2010-12-09 10:27:56 +01:00
|
|
|
LPCWSTR desc, driver, component;
|
2010-02-11 13:13:41 +01:00
|
|
|
WORD request = ODBC_REMOVE_SYS_DSN;
|
|
|
|
INT registration;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
static const WCHAR attrs_fmt[] = {
|
|
|
|
'D','S','N','=','%','s',0 };
|
|
|
|
|
2010-12-09 10:27:56 +01:00
|
|
|
component = MSI_RecordGetString( rec, 2 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-12-09 10:27:56 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-24 10:51:52 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-12-09 10:27:56 +01:00
|
|
|
{
|
2011-05-24 10:51:52 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-12-09 10:27:56 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-02-11 13:13:41 +01:00
|
|
|
desc = MSI_RecordGetString( rec, 3 );
|
|
|
|
driver = MSI_RecordGetString( rec, 4 );
|
|
|
|
registration = MSI_RecordGetInteger( rec, 5 );
|
|
|
|
|
|
|
|
if (registration == msidbODBCDataSourceRegistrationPerMachine) request = ODBC_REMOVE_SYS_DSN;
|
|
|
|
else if (registration == msidbODBCDataSourceRegistrationPerUser) request = ODBC_REMOVE_DSN;
|
|
|
|
|
2010-02-22 12:26:09 +01:00
|
|
|
len = strlenW( attrs_fmt ) + strlenW( desc ) + 2; /* \0\0 */
|
2010-02-11 13:13:41 +01:00
|
|
|
attrs = msi_alloc( len * sizeof(WCHAR) );
|
|
|
|
if (!attrs)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
FIXME("Use ODBCSourceAttribute table\n");
|
|
|
|
|
|
|
|
len = sprintfW( attrs, attrs_fmt, desc );
|
|
|
|
attrs[len + 1] = 0;
|
|
|
|
|
|
|
|
if (!SQLConfigDataSourceW( NULL, request, driver, attrs ))
|
|
|
|
{
|
|
|
|
WARN("Failed to remove ODBC data source\n");
|
|
|
|
}
|
|
|
|
msi_free( attrs );
|
|
|
|
|
2010-03-05 12:26:21 +01:00
|
|
|
uirow = MSI_CreateRecord( 3 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, desc );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, MSI_RecordGetString(rec, 2) );
|
|
|
|
MSI_RecordSetInteger( uirow, 3, request );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveODBC, uirow );
|
2010-03-05 12:26:21 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2010-02-11 13:13:41 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveODBC( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR driver_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','D','r','i','v','e','r',0 };
|
|
|
|
|
|
|
|
static const WCHAR translator_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
|
|
|
|
|
|
|
|
static const WCHAR source_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','D','a','t','a','S','o','u','r','c','e',0 };
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, driver_query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDriver, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, translator_query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCTranslator, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, source_query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveODBCDataSource, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2007-05-30 19:57:31 +02:00
|
|
|
#define ENV_ACT_SETALWAYS 0x1
|
|
|
|
#define ENV_ACT_SETABSENT 0x2
|
|
|
|
#define ENV_ACT_REMOVE 0x4
|
2007-06-14 02:46:09 +02:00
|
|
|
#define ENV_ACT_REMOVEMATCH 0x8
|
2007-05-30 19:57:31 +02:00
|
|
|
|
|
|
|
#define ENV_MOD_MACHINE 0x20000000
|
|
|
|
#define ENV_MOD_APPEND 0x40000000
|
|
|
|
#define ENV_MOD_PREFIX 0x80000000
|
2007-06-14 02:46:09 +02:00
|
|
|
#define ENV_MOD_MASK 0xC0000000
|
|
|
|
|
|
|
|
#define check_flag_combo(x, y) ((x) & ~(y)) == (y)
|
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
static UINT env_parse_flags( LPCWSTR *name, LPCWSTR *value, DWORD *flags )
|
2007-06-14 02:46:09 +02:00
|
|
|
{
|
|
|
|
LPCWSTR cptr = *name;
|
|
|
|
|
|
|
|
static const WCHAR prefix[] = {'[','~',']',0};
|
2007-10-18 03:22:16 +02:00
|
|
|
static const int prefix_len = 3;
|
2007-06-14 02:46:09 +02:00
|
|
|
|
|
|
|
*flags = 0;
|
2007-06-15 10:43:40 +02:00
|
|
|
while (*cptr)
|
2007-06-14 02:46:09 +02:00
|
|
|
{
|
2007-06-15 10:43:40 +02:00
|
|
|
if (*cptr == '=')
|
2007-06-14 02:46:09 +02:00
|
|
|
*flags |= ENV_ACT_SETALWAYS;
|
2007-06-15 10:43:40 +02:00
|
|
|
else if (*cptr == '+')
|
2007-06-14 02:46:09 +02:00
|
|
|
*flags |= ENV_ACT_SETABSENT;
|
2007-06-15 10:43:40 +02:00
|
|
|
else if (*cptr == '-')
|
2007-06-14 02:46:09 +02:00
|
|
|
*flags |= ENV_ACT_REMOVE;
|
2007-06-15 10:43:40 +02:00
|
|
|
else if (*cptr == '!')
|
2007-06-14 02:46:09 +02:00
|
|
|
*flags |= ENV_ACT_REMOVEMATCH;
|
2007-06-15 10:43:40 +02:00
|
|
|
else if (*cptr == '*')
|
2007-06-14 02:46:09 +02:00
|
|
|
*flags |= ENV_MOD_MACHINE;
|
2007-06-15 10:43:40 +02:00
|
|
|
else
|
2007-06-14 02:46:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
cptr++;
|
|
|
|
(*name)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*cptr)
|
|
|
|
{
|
|
|
|
ERR("Missing environment variable\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-11-13 11:06:12 +01:00
|
|
|
if (*value)
|
2007-06-14 02:46:09 +02:00
|
|
|
{
|
2009-11-13 11:06:12 +01:00
|
|
|
LPCWSTR ptr = *value;
|
|
|
|
if (!strncmpW(ptr, prefix, prefix_len))
|
2007-06-14 02:46:09 +02:00
|
|
|
{
|
2010-01-20 10:40:37 +01:00
|
|
|
if (ptr[prefix_len] == szSemiColon[0])
|
|
|
|
{
|
|
|
|
*flags |= ENV_MOD_APPEND;
|
|
|
|
*value += lstrlenW(prefix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*value = NULL;
|
|
|
|
}
|
2009-11-13 11:06:12 +01:00
|
|
|
}
|
|
|
|
else if (lstrlenW(*value) >= prefix_len)
|
|
|
|
{
|
|
|
|
ptr += lstrlenW(ptr) - prefix_len;
|
2010-10-19 11:27:44 +02:00
|
|
|
if (!strcmpW( ptr, prefix ))
|
2009-11-13 11:06:12 +01:00
|
|
|
{
|
2010-01-20 10:40:37 +01:00
|
|
|
if ((ptr-1) > *value && *(ptr-1) == szSemiColon[0])
|
|
|
|
{
|
|
|
|
*flags |= ENV_MOD_PREFIX;
|
|
|
|
/* the "[~]" will be removed by deformat_string */;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*value = NULL;
|
|
|
|
}
|
2009-11-13 11:06:12 +01:00
|
|
|
}
|
2007-06-14 02:46:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-15 20:52:39 +02:00
|
|
|
if (check_flag_combo(*flags, ENV_ACT_SETALWAYS | ENV_ACT_SETABSENT) ||
|
2007-06-14 02:46:09 +02:00
|
|
|
check_flag_combo(*flags, ENV_ACT_REMOVEMATCH | ENV_ACT_SETABSENT) ||
|
|
|
|
check_flag_combo(*flags, ENV_ACT_REMOVEMATCH | ENV_ACT_SETALWAYS) ||
|
|
|
|
check_flag_combo(*flags, ENV_ACT_SETABSENT | ENV_MOD_MASK))
|
|
|
|
{
|
|
|
|
ERR("Invalid flags: %08x\n", *flags);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2009-09-15 20:52:39 +02:00
|
|
|
if (!*flags)
|
|
|
|
*flags = ENV_ACT_SETALWAYS | ENV_ACT_REMOVE;
|
|
|
|
|
2007-06-14 02:46:09 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
static UINT open_env_key( DWORD flags, HKEY *key )
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2007-11-05 10:47:12 +01:00
|
|
|
static const WCHAR user_env[] =
|
|
|
|
{'E','n','v','i','r','o','n','m','e','n','t',0};
|
|
|
|
static const WCHAR machine_env[] =
|
2007-05-30 19:57:31 +02:00
|
|
|
{'S','y','s','t','e','m','\\',
|
|
|
|
'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
|
|
|
|
'C','o','n','t','r','o','l','\\',
|
|
|
|
'S','e','s','s','i','o','n',' ','M','a','n','a','g','e','r','\\',
|
|
|
|
'E','n','v','i','r','o','n','m','e','n','t',0};
|
2010-03-03 14:38:06 +01:00
|
|
|
const WCHAR *env;
|
|
|
|
HKEY root;
|
|
|
|
LONG res;
|
|
|
|
|
|
|
|
if (flags & ENV_MOD_MACHINE)
|
|
|
|
{
|
|
|
|
env = machine_env;
|
|
|
|
root = HKEY_LOCAL_MACHINE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
env = user_env;
|
|
|
|
root = HKEY_CURRENT_USER;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = RegOpenKeyExW( root, env, 0, KEY_ALL_ACCESS, key );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("Failed to open key %s (%d)\n", debugstr_w(env), res);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_WriteEnvironmentString( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR name, value, component;
|
|
|
|
LPWSTR data = NULL, newval = NULL, deformatted = NULL, ptr;
|
|
|
|
DWORD flags, type, size;
|
|
|
|
UINT res;
|
2010-03-04 09:17:50 +01:00
|
|
|
HKEY env = NULL;
|
2010-03-03 14:38:06 +01:00
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
int action = 0;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2010-03-02 14:55:31 +01:00
|
|
|
component = MSI_RecordGetString(rec, 4);
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component(package, component);
|
2010-03-02 14:55:31 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2010-03-02 14:55:31 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(component));
|
2010-03-02 14:55:31 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2007-06-14 02:46:09 +02:00
|
|
|
name = MSI_RecordGetString(rec, 2);
|
|
|
|
value = MSI_RecordGetString(rec, 3);
|
|
|
|
|
2009-09-15 20:52:39 +02:00
|
|
|
TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value));
|
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
res = env_parse_flags(&name, &value, &flags);
|
2010-01-20 10:40:37 +01:00
|
|
|
if (res != ERROR_SUCCESS || !value)
|
2007-06-14 02:46:09 +02:00
|
|
|
goto done;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2009-11-13 11:06:12 +01:00
|
|
|
if (value && !deformat_string(package, value, &deformatted))
|
2007-10-18 03:22:16 +02:00
|
|
|
{
|
|
|
|
res = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-06-14 02:46:09 +02:00
|
|
|
value = deformatted;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
res = open_env_key( flags, &env );
|
2007-05-30 19:57:31 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
2007-06-14 02:46:09 +02:00
|
|
|
goto done;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
if (flags & ENV_MOD_MACHINE)
|
|
|
|
action |= 0x20000000;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
|
|
|
size = 0;
|
2009-12-17 04:05:27 +01:00
|
|
|
type = REG_SZ;
|
2007-06-14 02:46:09 +02:00
|
|
|
res = RegQueryValueExW(env, name, NULL, &type, NULL, &size);
|
|
|
|
if ((res != ERROR_SUCCESS && res != ERROR_FILE_NOT_FOUND) ||
|
2008-01-05 18:46:09 +01:00
|
|
|
(res == ERROR_SUCCESS && type != REG_SZ && type != REG_EXPAND_SZ))
|
2007-06-14 02:46:09 +02:00
|
|
|
goto done;
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
if ((res == ERROR_FILE_NOT_FOUND || !(flags & ENV_MOD_MASK)))
|
|
|
|
{
|
2010-03-03 14:38:06 +01:00
|
|
|
action = 0x2;
|
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
/* Nothing to do. */
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
res = ERROR_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2010-01-20 10:40:37 +01:00
|
|
|
/* If we are appending but the string was empty, strip ; */
|
|
|
|
if ((flags & ENV_MOD_APPEND) && (value[0] == szSemiColon[0])) value++;
|
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
size = (lstrlenW(value) + 1) * sizeof(WCHAR);
|
|
|
|
newval = strdupW(value);
|
|
|
|
if (!newval)
|
|
|
|
{
|
|
|
|
res = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2010-03-03 14:38:06 +01:00
|
|
|
action = 0x1;
|
|
|
|
|
2010-01-20 10:40:37 +01:00
|
|
|
/* Contrary to MSDN, +-variable to [~];path works */
|
|
|
|
if (flags & ENV_ACT_SETABSENT && !(flags & ENV_MOD_MASK))
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
|
|
|
res = ERROR_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-06-14 02:46:09 +02:00
|
|
|
data = msi_alloc(size);
|
|
|
|
if (!data)
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2007-06-14 02:46:09 +02:00
|
|
|
RegCloseKey(env);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2007-05-30 19:57:31 +02:00
|
|
|
}
|
|
|
|
|
2007-06-14 02:46:09 +02:00
|
|
|
res = RegQueryValueExW(env, name, NULL, &type, (LPVOID)data, &size);
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
2010-10-19 11:27:44 +02:00
|
|
|
if (flags & ENV_ACT_REMOVEMATCH && (!value || !strcmpW( data, value )))
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2010-03-03 14:38:06 +01:00
|
|
|
action = 0x4;
|
|
|
|
res = RegDeleteValueW(env, name);
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
WARN("Failed to remove value %s (%d)\n", debugstr_w(name), res);
|
2007-06-14 02:46:09 +02:00
|
|
|
goto done;
|
2007-05-30 19:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
size = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
|
|
|
if (flags & ENV_MOD_MASK)
|
|
|
|
{
|
|
|
|
DWORD mod_size;
|
|
|
|
int multiplier = 0;
|
|
|
|
if (flags & ENV_MOD_APPEND) multiplier++;
|
|
|
|
if (flags & ENV_MOD_PREFIX) multiplier++;
|
2010-01-20 10:40:37 +01:00
|
|
|
mod_size = lstrlenW(value) * multiplier;
|
2009-12-16 03:19:19 +01:00
|
|
|
size += mod_size * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
newval = msi_alloc(size);
|
2007-06-14 02:46:09 +02:00
|
|
|
ptr = newval;
|
|
|
|
if (!newval)
|
|
|
|
{
|
|
|
|
res = ERROR_OUTOFMEMORY;
|
2007-05-30 19:57:31 +02:00
|
|
|
goto done;
|
2007-06-14 02:46:09 +02:00
|
|
|
}
|
2007-05-30 19:57:31 +02:00
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
if (flags & ENV_MOD_PREFIX)
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2009-12-16 03:19:19 +01:00
|
|
|
lstrcpyW(newval, value);
|
2010-01-20 10:40:37 +01:00
|
|
|
ptr = newval + lstrlenW(value);
|
2010-03-03 14:38:06 +01:00
|
|
|
action |= 0x80000000;
|
2009-12-16 03:19:19 +01:00
|
|
|
}
|
2007-06-14 02:46:09 +02:00
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
lstrcpyW(ptr, data);
|
2007-06-14 02:46:09 +02:00
|
|
|
|
2009-12-16 03:19:19 +01:00
|
|
|
if (flags & ENV_MOD_APPEND)
|
2007-05-30 19:57:31 +02:00
|
|
|
{
|
2009-12-16 03:19:19 +01:00
|
|
|
lstrcatW(newval, value);
|
2010-03-03 14:38:06 +01:00
|
|
|
action |= 0x40000000;
|
2007-05-30 19:57:31 +02:00
|
|
|
}
|
|
|
|
}
|
2009-12-22 09:32:03 +01:00
|
|
|
TRACE("setting %s to %s\n", debugstr_w(name), debugstr_w(newval));
|
|
|
|
res = RegSetValueExW(env, name, 0, type, (LPVOID)newval, size);
|
2010-03-03 14:38:06 +01:00
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
WARN("Failed to set %s to %s (%d)\n", debugstr_w(name), debugstr_w(newval), res);
|
|
|
|
}
|
2007-05-30 19:57:31 +02:00
|
|
|
|
|
|
|
done:
|
2010-03-03 14:38:06 +01:00
|
|
|
uirow = MSI_CreateRecord( 3 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, name );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, newval );
|
|
|
|
MSI_RecordSetInteger( uirow, 3, action );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szWriteEnvironmentStrings, uirow );
|
2010-03-03 14:38:06 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
2007-06-23 18:28:50 +02:00
|
|
|
if (env) RegCloseKey(env);
|
2007-06-14 02:46:09 +02:00
|
|
|
msi_free(deformatted);
|
|
|
|
msi_free(data);
|
|
|
|
msi_free(newval);
|
2007-05-30 19:57:31 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_WriteEnvironmentStrings( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','E','n','v','i','r','o','n','m','e','n','t','`',0};
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_WriteEnvironmentString, package);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:38:06 +01:00
|
|
|
static UINT ITERATE_RemoveEnvironmentString( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
LPCWSTR name, value, component;
|
|
|
|
LPWSTR deformatted = NULL;
|
|
|
|
DWORD flags;
|
|
|
|
HKEY env;
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
int action = 0;
|
|
|
|
LONG res;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
component = MSI_RecordGetString( rec, 4 );
|
2011-05-06 14:39:17 +02:00
|
|
|
comp = msi_get_loaded_component( package, component );
|
2010-03-03 14:38:06 +01:00
|
|
|
if (!comp)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
2011-05-25 10:39:41 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2010-03-03 14:38:06 +01:00
|
|
|
{
|
2011-05-25 10:39:41 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(component));
|
2010-03-03 14:38:06 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
name = MSI_RecordGetString( rec, 2 );
|
|
|
|
value = MSI_RecordGetString( rec, 3 );
|
|
|
|
|
|
|
|
TRACE("name %s value %s\n", debugstr_w(name), debugstr_w(value));
|
|
|
|
|
|
|
|
r = env_parse_flags( &name, &value, &flags );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
if (!(flags & ENV_ACT_REMOVE))
|
|
|
|
{
|
|
|
|
TRACE("Environment variable %s not marked for removal\n", debugstr_w(name));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value && !deformat_string( package, value, &deformatted ))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
value = deformatted;
|
|
|
|
|
|
|
|
r = open_env_key( flags, &env );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & ENV_MOD_MACHINE)
|
|
|
|
action |= 0x20000000;
|
|
|
|
|
|
|
|
TRACE("Removing %s\n", debugstr_w(name));
|
|
|
|
|
|
|
|
res = RegDeleteValueW( env, name );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("Failed to delete value %s (%d)\n", debugstr_w(name), res);
|
|
|
|
r = ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
uirow = MSI_CreateRecord( 3 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, name );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, value );
|
|
|
|
MSI_RecordSetInteger( uirow, 3, action );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szRemoveEnvironmentStrings, uirow );
|
2010-03-03 14:38:06 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
|
|
|
|
if (env) RegCloseKey( env );
|
|
|
|
msi_free( deformatted );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveEnvironmentStrings( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','E','n','v','i','r','o','n','m','e','n','t','`',0};
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
|
|
|
|
rc = MSI_IterateRecords( view, NULL, ITERATE_RemoveEnvironmentString, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-02-10 11:55:59 +01:00
|
|
|
static UINT ACTION_ValidateProductID( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
LPWSTR key, template, id;
|
|
|
|
UINT r = ERROR_SUCCESS;
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
id = msi_dup_property( package->db, szProductID );
|
2010-02-10 11:55:59 +01:00
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
msi_free( id );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-04-21 11:37:54 +02:00
|
|
|
template = msi_dup_property( package->db, szPIDTemplate );
|
|
|
|
key = msi_dup_property( package->db, szPIDKEY );
|
2010-02-10 11:55:59 +01:00
|
|
|
|
|
|
|
if (key && template)
|
|
|
|
{
|
|
|
|
FIXME( "partial stub: template %s key %s\n", debugstr_w(template), debugstr_w(key) );
|
2010-04-21 11:38:40 +02:00
|
|
|
r = msi_set_property( package->db, szProductID, key );
|
2010-02-10 11:55:59 +01:00
|
|
|
}
|
|
|
|
msi_free( template );
|
|
|
|
msi_free( key );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-02-03 09:20:22 +01:00
|
|
|
static UINT ACTION_ScheduleReboot( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
package->need_reboot = 1;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-02-10 11:54:57 +01:00
|
|
|
static UINT ACTION_AllocateRegistrySpace( MSIPACKAGE *package )
|
|
|
|
{
|
2010-03-02 14:55:06 +01:00
|
|
|
static const WCHAR szAvailableFreeReg[] =
|
|
|
|
{'A','V','A','I','L','A','B','L','E','F','R','E','E','R','E','G',0};
|
2010-03-05 12:23:22 +01:00
|
|
|
MSIRECORD *uirow;
|
2010-04-21 11:37:54 +02:00
|
|
|
int space = msi_get_property_int( package->db, szAvailableFreeReg, 0 );
|
2010-03-05 12:23:22 +01:00
|
|
|
|
|
|
|
TRACE("%p %d kilobytes\n", package, space);
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 1 );
|
|
|
|
MSI_RecordSetInteger( uirow, 1, space );
|
2011-05-06 14:39:17 +02:00
|
|
|
msi_ui_actiondata( package, szAllocateRegistrySpace, uirow );
|
2010-03-05 12:23:22 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
2010-03-02 14:55:06 +01:00
|
|
|
|
2010-02-10 11:54:57 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_DisableRollback( MSIPACKAGE *package )
|
|
|
|
{
|
2011-05-20 12:33:16 +02:00
|
|
|
TRACE("%p\n", package);
|
|
|
|
|
|
|
|
msi_set_property( package->db, szRollbackDisabled, szOne );
|
2010-02-10 11:54:57 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_InstallAdminPackage( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
FIXME("%p\n", package);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-03-26 12:12:35 +01:00
|
|
|
static UINT ACTION_SetODBCFolders( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT r, count;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR driver_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','D','r','i','v','e','r',0 };
|
|
|
|
|
|
|
|
static const WCHAR translator_query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'O','D','B','C','T','r','a','n','s','l','a','t','o','r',0 };
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, driver_query, &view );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
r = MSI_IterateRecords( view, &count, NULL, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (count) FIXME("ignored %u rows in ODBCDriver table\n", count);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, translator_query, &view );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
count = 0;
|
|
|
|
r = MSI_IterateRecords( view, &count, NULL, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
if (count) FIXME("ignored %u rows in ODBCTranslator table\n", count);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-11-30 15:18:36 +01:00
|
|
|
static UINT ITERATE_RemoveExistingProducts( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
const WCHAR *property = MSI_RecordGetString( rec, 1 );
|
|
|
|
WCHAR *value;
|
|
|
|
|
|
|
|
if ((value = msi_dup_property( package->db, property )))
|
|
|
|
{
|
|
|
|
FIXME("remove %s\n", debugstr_w(value));
|
|
|
|
msi_free( value );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_RemoveExistingProducts( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view;
|
|
|
|
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','A','c','t','i','o','n','P','r','o','p','e','r','t','y',
|
|
|
|
' ','F','R','O','M',' ','U','p','g','r','a','d','e',0};
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = MSI_IterateRecords( view, NULL, ITERATE_RemoveExistingProducts, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_MigrateFeatureStates( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
int attributes = MSI_RecordGetInteger( rec, 5 );
|
|
|
|
|
|
|
|
if (attributes & msidbUpgradeAttributesMigrateFeatures)
|
|
|
|
{
|
|
|
|
const WCHAR *upgrade_code = MSI_RecordGetString( rec, 1 );
|
|
|
|
const WCHAR *version_min = MSI_RecordGetString( rec, 2 );
|
|
|
|
const WCHAR *version_max = MSI_RecordGetString( rec, 3 );
|
|
|
|
const WCHAR *language = MSI_RecordGetString( rec, 4 );
|
|
|
|
HKEY hkey;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
r = MSIREG_OpenClassesUpgradeCodesKey( upgrade_code, &hkey, FALSE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = MSIREG_OpenUserUpgradeCodesKey( upgrade_code, &hkey, FALSE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
|
|
|
|
FIXME("migrate feature states from %s version min %s version max %s language %s\n",
|
|
|
|
debugstr_w(upgrade_code), debugstr_w(version_min),
|
|
|
|
debugstr_w(version_max), debugstr_w(language));
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_MigrateFeatureStates( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','U','p','g','r','a','d','e',0};
|
|
|
|
|
|
|
|
if (msi_get_property_int( package->db, szInstalled, 0 ))
|
|
|
|
{
|
|
|
|
TRACE("product is installed, skipping action\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (msi_get_property_int( package->db, szPreselected, 0 ))
|
|
|
|
{
|
|
|
|
TRACE("Preselected property is set, not migrating feature states\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = MSI_IterateRecords( view, NULL, ITERATE_MigrateFeatureStates, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-05-24 10:49:56 +02:00
|
|
|
static void bind_image( const char *filename, const char *path )
|
|
|
|
{
|
|
|
|
if (!BindImageEx( 0, filename, path, NULL, NULL ))
|
|
|
|
{
|
|
|
|
WARN("failed to bind image %u\n", GetLastError());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ITERATE_BindImage( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
MSIFILE *file;
|
|
|
|
MSIPACKAGE *package = param;
|
|
|
|
const WCHAR *key = MSI_RecordGetString( rec, 1 );
|
|
|
|
const WCHAR *paths = MSI_RecordGetString( rec, 2 );
|
|
|
|
char *filenameA, *pathA;
|
|
|
|
WCHAR *pathW, **path_list;
|
|
|
|
|
|
|
|
if (!(file = msi_get_loaded_file( package, key )))
|
|
|
|
{
|
|
|
|
WARN("file %s not found\n", debugstr_w(key));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (!(filenameA = strdupWtoA( file->TargetPath ))) return ERROR_SUCCESS;
|
|
|
|
path_list = msi_split_string( paths, ';' );
|
|
|
|
if (!path_list) bind_image( filenameA, NULL );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; path_list[i] && path_list[i][0]; i++)
|
|
|
|
{
|
|
|
|
deformat_string( package, path_list[i], &pathW );
|
|
|
|
if ((pathA = strdupWtoA( pathW )))
|
|
|
|
{
|
|
|
|
bind_image( filenameA, pathA );
|
|
|
|
msi_free( pathA );
|
|
|
|
}
|
|
|
|
msi_free( pathW );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msi_free( path_list );
|
|
|
|
msi_free( filenameA );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_BindImage( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
MSIQUERY *view;
|
|
|
|
static const WCHAR query[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','B','i','n','d','I','m','a','g','e',0};
|
|
|
|
|
|
|
|
r = MSI_DatabaseOpenViewW( package->db, query, &view );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
r = MSI_IterateRecords( view, NULL, ITERATE_BindImage, package );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:56:18 +02:00
|
|
|
static UINT msi_unimplemented_action_stub( MSIPACKAGE *package,
|
|
|
|
LPCSTR action, LPCWSTR table )
|
2005-09-23 12:09:18 +02:00
|
|
|
{
|
2005-09-26 11:56:18 +02:00
|
|
|
static const WCHAR query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','%','s','`',0 };
|
2005-09-23 12:09:18 +02:00
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
DWORD count = 0;
|
2005-09-26 11:56:18 +02:00
|
|
|
UINT r;
|
2005-09-23 12:09:18 +02:00
|
|
|
|
2005-09-26 11:56:18 +02:00
|
|
|
r = MSI_OpenQuery( package->db, &view, query, table );
|
|
|
|
if (r == ERROR_SUCCESS)
|
2005-09-23 12:09:18 +02:00
|
|
|
{
|
2005-09-26 11:56:18 +02:00
|
|
|
r = MSI_IterateRecords(view, &count, NULL, package);
|
2005-09-23 12:09:18 +02:00
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
}
|
|
|
|
|
2005-09-26 11:56:18 +02:00
|
|
|
if (count)
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("%s -> %u ignored %s table values\n",
|
2005-09-26 11:56:18 +02:00
|
|
|
action, count, debugstr_w(table));
|
|
|
|
|
2005-09-23 12:09:18 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-09-23 12:48:17 +02:00
|
|
|
|
2005-09-26 11:56:18 +02:00
|
|
|
static UINT ACTION_IsolateComponents( MSIPACKAGE *package )
|
2005-09-23 19:21:10 +02:00
|
|
|
{
|
2005-09-26 11:56:18 +02:00
|
|
|
static const WCHAR table[] = {
|
2010-02-26 14:09:29 +01:00
|
|
|
'I','s','o','l','a','t','e','d','C','o','m','p','o','n','e','n','t',0 };
|
2005-09-26 11:56:18 +02:00
|
|
|
return msi_unimplemented_action_stub( package, "IsolateComponents", table );
|
|
|
|
}
|
2005-09-23 19:21:10 +02:00
|
|
|
|
2005-12-31 13:14:23 +01:00
|
|
|
static UINT ACTION_RMCCPSearch( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR table[] = { 'C','C','P','S','e','a','r','c','h',0 };
|
|
|
|
return msi_unimplemented_action_stub( package, "RMCCPSearch", table );
|
|
|
|
}
|
|
|
|
|
2006-03-22 15:01:56 +01:00
|
|
|
static UINT ACTION_RegisterComPlus( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR table[] = { 'C','o','m','p','l','u','s',0 };
|
|
|
|
return msi_unimplemented_action_stub( package, "RegisterComPlus", table );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ACTION_UnregisterComPlus( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR table[] = { 'C','o','m','p','l','u','s',0 };
|
|
|
|
return msi_unimplemented_action_stub( package, "UnregisterComPlus", table );
|
|
|
|
}
|
|
|
|
|
2007-05-07 03:52:14 +02:00
|
|
|
static UINT ACTION_InstallSFPCatalogFile( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR table[] = { 'S','F','P','C','a','t','a','l','o','g',0 };
|
|
|
|
return msi_unimplemented_action_stub( package, "InstallSFPCatalogFile", table );
|
|
|
|
}
|
|
|
|
|
2009-10-15 12:47:48 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const WCHAR *action;
|
|
|
|
UINT (*handler)(MSIPACKAGE *);
|
2011-05-20 12:33:45 +02:00
|
|
|
const WCHAR *action_rollback;
|
2009-10-15 12:47:48 +02:00
|
|
|
}
|
|
|
|
StandardActions[] =
|
|
|
|
{
|
2011-05-20 12:33:45 +02:00
|
|
|
{ szAllocateRegistrySpace, ACTION_AllocateRegistrySpace, NULL },
|
|
|
|
{ szAppSearch, ACTION_AppSearch, NULL },
|
|
|
|
{ szBindImage, ACTION_BindImage, NULL },
|
|
|
|
{ szCCPSearch, ACTION_CCPSearch, NULL },
|
|
|
|
{ szCostFinalize, ACTION_CostFinalize, NULL },
|
|
|
|
{ szCostInitialize, ACTION_CostInitialize, NULL },
|
|
|
|
{ szCreateFolders, ACTION_CreateFolders, szRemoveFolders },
|
|
|
|
{ szCreateShortcuts, ACTION_CreateShortcuts, szRemoveShortcuts },
|
|
|
|
{ szDeleteServices, ACTION_DeleteServices, NULL },
|
|
|
|
{ szDisableRollback, ACTION_DisableRollback, NULL },
|
|
|
|
{ szDuplicateFiles, ACTION_DuplicateFiles, szRemoveDuplicateFiles },
|
|
|
|
{ szExecuteAction, ACTION_ExecuteAction, NULL },
|
|
|
|
{ szFileCost, ACTION_FileCost, NULL },
|
|
|
|
{ szFindRelatedProducts, ACTION_FindRelatedProducts, NULL },
|
|
|
|
{ szForceReboot, ACTION_ForceReboot, NULL },
|
|
|
|
{ szInstallAdminPackage, ACTION_InstallAdminPackage, NULL },
|
|
|
|
{ szInstallExecute, ACTION_InstallExecute, NULL },
|
|
|
|
{ szInstallExecuteAgain, ACTION_InstallExecute, NULL },
|
|
|
|
{ szInstallFiles, ACTION_InstallFiles, NULL },
|
|
|
|
{ szInstallFinalize, ACTION_InstallFinalize, NULL },
|
|
|
|
{ szInstallInitialize, ACTION_InstallInitialize, NULL },
|
|
|
|
{ szInstallSFPCatalogFile, ACTION_InstallSFPCatalogFile, NULL },
|
|
|
|
{ szInstallValidate, ACTION_InstallValidate, NULL },
|
|
|
|
{ szIsolateComponents, ACTION_IsolateComponents, NULL },
|
|
|
|
{ szLaunchConditions, ACTION_LaunchConditions, NULL },
|
|
|
|
{ szMigrateFeatureStates, ACTION_MigrateFeatureStates, NULL },
|
|
|
|
{ szMoveFiles, ACTION_MoveFiles, NULL },
|
|
|
|
{ szMsiPublishAssemblies, ACTION_MsiPublishAssemblies, szMsiUnpublishAssemblies },
|
|
|
|
{ szMsiUnpublishAssemblies, ACTION_MsiUnpublishAssemblies, NULL },
|
|
|
|
{ szInstallODBC, ACTION_InstallODBC, szRemoveODBC },
|
|
|
|
{ szInstallServices, ACTION_InstallServices, szDeleteServices },
|
|
|
|
{ szPatchFiles, ACTION_PatchFiles, NULL },
|
|
|
|
{ szProcessComponents, ACTION_ProcessComponents, NULL },
|
|
|
|
{ szPublishComponents, ACTION_PublishComponents, szUnpublishComponents },
|
|
|
|
{ szPublishFeatures, ACTION_PublishFeatures, szUnpublishFeatures },
|
|
|
|
{ szPublishProduct, ACTION_PublishProduct, NULL },
|
|
|
|
{ szRegisterClassInfo, ACTION_RegisterClassInfo, szUnregisterClassInfo },
|
|
|
|
{ szRegisterComPlus, ACTION_RegisterComPlus, szUnregisterComPlus },
|
|
|
|
{ szRegisterExtensionInfo, ACTION_RegisterExtensionInfo, szUnregisterExtensionInfo },
|
|
|
|
{ szRegisterFonts, ACTION_RegisterFonts, szUnregisterFonts },
|
|
|
|
{ szRegisterMIMEInfo, ACTION_RegisterMIMEInfo, szUnregisterMIMEInfo },
|
|
|
|
{ szRegisterProduct, ACTION_RegisterProduct, NULL },
|
|
|
|
{ szRegisterProgIdInfo, ACTION_RegisterProgIdInfo, szUnregisterProgIdInfo },
|
|
|
|
{ szRegisterTypeLibraries, ACTION_RegisterTypeLibraries, szUnregisterTypeLibraries },
|
|
|
|
{ szRegisterUser, ACTION_RegisterUser, NULL },
|
|
|
|
{ szRemoveDuplicateFiles, ACTION_RemoveDuplicateFiles, NULL },
|
|
|
|
{ szRemoveEnvironmentStrings, ACTION_RemoveEnvironmentStrings, NULL },
|
|
|
|
{ szRemoveExistingProducts, ACTION_RemoveExistingProducts, NULL },
|
|
|
|
{ szRemoveFiles, ACTION_RemoveFiles, NULL },
|
|
|
|
{ szRemoveFolders, ACTION_RemoveFolders, NULL },
|
|
|
|
{ szRemoveIniValues, ACTION_RemoveIniValues, NULL },
|
|
|
|
{ szRemoveODBC, ACTION_RemoveODBC, NULL },
|
|
|
|
{ szRemoveRegistryValues, ACTION_RemoveRegistryValues, NULL },
|
|
|
|
{ szRemoveShortcuts, ACTION_RemoveShortcuts, NULL },
|
|
|
|
{ szResolveSource, ACTION_ResolveSource, NULL },
|
|
|
|
{ szRMCCPSearch, ACTION_RMCCPSearch, NULL },
|
|
|
|
{ szScheduleReboot, ACTION_ScheduleReboot, NULL },
|
|
|
|
{ szSelfRegModules, ACTION_SelfRegModules, szSelfUnregModules },
|
|
|
|
{ szSelfUnregModules, ACTION_SelfUnregModules, NULL },
|
|
|
|
{ szSetODBCFolders, ACTION_SetODBCFolders, NULL },
|
|
|
|
{ szStartServices, ACTION_StartServices, szStopServices },
|
|
|
|
{ szStopServices, ACTION_StopServices, NULL },
|
|
|
|
{ szUnpublishComponents, ACTION_UnpublishComponents, NULL },
|
|
|
|
{ szUnpublishFeatures, ACTION_UnpublishFeatures, NULL },
|
|
|
|
{ szUnregisterClassInfo, ACTION_UnregisterClassInfo, NULL },
|
|
|
|
{ szUnregisterComPlus, ACTION_UnregisterComPlus, NULL },
|
|
|
|
{ szUnregisterExtensionInfo, ACTION_UnregisterExtensionInfo, NULL },
|
|
|
|
{ szUnregisterFonts, ACTION_UnregisterFonts, NULL },
|
|
|
|
{ szUnregisterMIMEInfo, ACTION_UnregisterMIMEInfo, NULL },
|
|
|
|
{ szUnregisterProgIdInfo, ACTION_UnregisterProgIdInfo, NULL },
|
|
|
|
{ szUnregisterTypeLibraries, ACTION_UnregisterTypeLibraries, NULL },
|
|
|
|
{ szValidateProductID, ACTION_ValidateProductID, NULL },
|
|
|
|
{ szWriteEnvironmentStrings, ACTION_WriteEnvironmentStrings, szRemoveEnvironmentStrings },
|
|
|
|
{ szWriteIniValues, ACTION_WriteIniValues, szRemoveIniValues },
|
|
|
|
{ szWriteRegistryValues, ACTION_WriteRegistryValues, szRemoveRegistryValues },
|
|
|
|
{ NULL, NULL, NULL }
|
2005-09-28 20:10:44 +02:00
|
|
|
};
|
2008-04-03 15:50:28 +02:00
|
|
|
|
2010-07-23 09:42:21 +02:00
|
|
|
static BOOL ACTION_HandleStandardAction( MSIPACKAGE *package, LPCWSTR action, UINT *rc )
|
2008-04-03 15:50:28 +02:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2010-07-23 09:42:21 +02:00
|
|
|
UINT i;
|
2008-04-03 15:50:28 +02:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (StandardActions[i].action != NULL)
|
|
|
|
{
|
2010-07-23 09:42:21 +02:00
|
|
|
if (!strcmpW( StandardActions[i].action, action ))
|
2008-04-03 15:50:28 +02:00
|
|
|
{
|
2010-07-23 09:42:21 +02:00
|
|
|
ui_actionstart( package, action );
|
|
|
|
if (StandardActions[i].handler)
|
2008-04-03 15:50:28 +02:00
|
|
|
{
|
2010-07-23 09:42:21 +02:00
|
|
|
ui_actioninfo( package, action, TRUE, 0 );
|
|
|
|
*rc = StandardActions[i].handler( package );
|
|
|
|
ui_actioninfo( package, action, FALSE, *rc );
|
2011-05-20 12:33:45 +02:00
|
|
|
|
|
|
|
if (StandardActions[i].action_rollback &&
|
|
|
|
!msi_get_property_int( package->db, szRollbackDisabled, 0 ))
|
|
|
|
{
|
|
|
|
TRACE("scheduling rollback action\n");
|
|
|
|
msi_schedule_action( package, ROLLBACK_SCRIPT, StandardActions[i].action_rollback );
|
|
|
|
}
|
2008-04-03 15:50:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-23 09:42:21 +02:00
|
|
|
FIXME("unhandled standard action %s\n", debugstr_w(action));
|
|
|
|
*rc = ERROR_SUCCESS;
|
2008-04-03 15:50:28 +02:00
|
|
|
}
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2009-10-15 12:47:48 +02:00
|
|
|
|
2010-07-23 09:42:21 +02:00
|
|
|
UINT ACTION_PerformAction(MSIPACKAGE *package, const WCHAR *action, UINT script)
|
2009-10-15 12:47:48 +02:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
BOOL handled;
|
|
|
|
|
|
|
|
TRACE("Performing action (%s)\n", debugstr_w(action));
|
|
|
|
|
2010-07-23 09:42:21 +02:00
|
|
|
handled = ACTION_HandleStandardAction(package, action, &rc);
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
if (!handled)
|
2010-07-23 09:42:21 +02:00
|
|
|
handled = ACTION_HandleCustomAction(package, action, &rc, script, TRUE);
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
{
|
|
|
|
WARN("unhandled msi action %s\n", debugstr_w(action));
|
|
|
|
rc = ERROR_FUNCTION_NOT_CALLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT ACTION_PerformUIAction(MSIPACKAGE *package, const WCHAR *action, UINT script)
|
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
BOOL handled = FALSE;
|
|
|
|
|
|
|
|
TRACE("Performing action (%s)\n", debugstr_w(action));
|
|
|
|
|
2010-07-23 09:42:21 +02:00
|
|
|
handled = ACTION_HandleStandardAction(package, action, &rc);
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
handled = ACTION_HandleCustomAction(package, action, &rc, script, FALSE);
|
|
|
|
|
|
|
|
if( !handled && ACTION_DialogBox(package, action) == ERROR_SUCCESS )
|
|
|
|
handled = TRUE;
|
|
|
|
|
|
|
|
if (!handled)
|
|
|
|
{
|
|
|
|
WARN("unhandled msi action %s\n", debugstr_w(action));
|
|
|
|
rc = ERROR_FUNCTION_NOT_CALLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-10-15 12:49:10 +02:00
|
|
|
static UINT ACTION_PerformActionSequence(MSIPACKAGE *package, UINT seq)
|
2009-10-15 12:47:48 +02:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
2009-10-15 12:49:10 +02:00
|
|
|
MSIRECORD *row;
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','I','n','s','t','a','l','l','E','x','e','c','u','t','e',
|
|
|
|
'S','e','q','u','e','n','c','e','`',' ', 'W','H','E','R','E',' ',
|
|
|
|
'`','S','e','q','u','e','n','c','e','`',' ', '=',' ','%','i',0};
|
|
|
|
static const WCHAR UISeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','I','n','s','t','a','l','l','U','I','S','e','q','u','e','n','c','e',
|
|
|
|
'`', ' ', 'W','H','E','R','E',' ','`','S','e','q','u','e','n','c','e','`',
|
|
|
|
' ', '=',' ','%','i',0};
|
|
|
|
|
2009-10-15 12:49:10 +02:00
|
|
|
if (needs_ui_sequence(package))
|
2009-10-15 12:47:48 +02:00
|
|
|
row = MSI_QueryGetRecord(package->db, UISeqQuery, seq);
|
|
|
|
else
|
|
|
|
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, seq);
|
|
|
|
|
|
|
|
if (row)
|
|
|
|
{
|
|
|
|
LPCWSTR action, cond;
|
|
|
|
|
|
|
|
TRACE("Running the actions\n");
|
|
|
|
|
|
|
|
/* check conditions */
|
|
|
|
cond = MSI_RecordGetString(row, 2);
|
|
|
|
|
|
|
|
/* this is a hack to skip errors in the condition code */
|
|
|
|
if (MSI_EvaluateConditionW(package, cond) == MSICONDITION_FALSE)
|
2009-10-15 12:49:10 +02:00
|
|
|
{
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
action = MSI_RecordGetString(row, 1);
|
|
|
|
if (!action)
|
|
|
|
{
|
|
|
|
ERR("failed to fetch action\n");
|
2009-10-15 12:49:10 +02:00
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2009-10-15 12:47:48 +02:00
|
|
|
}
|
|
|
|
|
2009-10-15 12:49:10 +02:00
|
|
|
if (needs_ui_sequence(package))
|
2009-10-15 12:47:48 +02:00
|
|
|
rc = ACTION_PerformUIAction(package, action, -1);
|
|
|
|
else
|
2010-07-23 09:42:21 +02:00
|
|
|
rc = ACTION_PerformAction(package, action, -1);
|
2009-10-15 12:49:10 +02:00
|
|
|
|
2009-10-15 12:47:48 +02:00
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************
|
|
|
|
* TOP level entry points
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
UINT MSI_InstallPackage( MSIPACKAGE *package, LPCWSTR szPackagePath,
|
|
|
|
LPCWSTR szCommandLine )
|
|
|
|
{
|
|
|
|
UINT rc;
|
2011-05-24 10:50:28 +02:00
|
|
|
BOOL ui_exists;
|
2011-05-20 12:33:16 +02:00
|
|
|
static const WCHAR szDisableRollback[] = {'D','I','S','A','B','L','E','R','O','L','L','B','A','C','K',0};
|
2009-10-15 12:47:48 +02:00
|
|
|
static const WCHAR szAction[] = {'A','C','T','I','O','N',0};
|
|
|
|
static const WCHAR szInstall[] = {'I','N','S','T','A','L','L',0};
|
|
|
|
|
2010-04-21 11:38:40 +02:00
|
|
|
msi_set_property( package->db, szAction, szInstall );
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
package->script->InWhatSequence = SEQUENCE_INSTALL;
|
|
|
|
|
|
|
|
if (szPackagePath)
|
|
|
|
{
|
|
|
|
LPWSTR p, dir;
|
|
|
|
LPCWSTR file;
|
|
|
|
|
|
|
|
dir = strdupW(szPackagePath);
|
|
|
|
p = strrchrW(dir, '\\');
|
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
*(++p) = 0;
|
|
|
|
file = szPackagePath + (p - dir);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msi_free(dir);
|
|
|
|
dir = msi_alloc(MAX_PATH * sizeof(WCHAR));
|
|
|
|
GetCurrentDirectoryW(MAX_PATH, dir);
|
|
|
|
lstrcatW(dir, szBackSlash);
|
|
|
|
file = szPackagePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
msi_free( package->PackagePath );
|
|
|
|
package->PackagePath = msi_alloc((lstrlenW(dir) + lstrlenW(file) + 1) * sizeof(WCHAR));
|
|
|
|
if (!package->PackagePath)
|
|
|
|
{
|
|
|
|
msi_free(dir);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW(package->PackagePath, dir);
|
|
|
|
lstrcatW(package->PackagePath, file);
|
|
|
|
msi_free(dir);
|
|
|
|
|
|
|
|
msi_set_sourcedir_props(package, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-12-23 17:07:55 +01:00
|
|
|
rc = msi_parse_command_line( package, szCommandLine, FALSE );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
msi_apply_transforms( package );
|
|
|
|
msi_apply_patches( package );
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
if (!szCommandLine && msi_get_property_int( package->db, szInstalled, 0 ))
|
2009-10-15 12:47:48 +02:00
|
|
|
{
|
|
|
|
TRACE("setting reinstall property\n");
|
2010-04-21 11:38:40 +02:00
|
|
|
msi_set_property( package->db, szReinstall, szAll );
|
2009-10-15 12:47:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* properties may have been added by a transform */
|
|
|
|
msi_clone_properties( package );
|
2010-07-22 11:47:13 +02:00
|
|
|
|
|
|
|
msi_parse_command_line( package, szCommandLine, FALSE );
|
2010-09-17 15:19:56 +02:00
|
|
|
msi_adjust_privilege_properties( package );
|
2009-10-15 12:47:48 +02:00
|
|
|
msi_set_context( package );
|
|
|
|
|
2011-05-20 12:33:16 +02:00
|
|
|
if (msi_get_property_int( package->db, szDisableRollback, 0 ))
|
|
|
|
{
|
|
|
|
TRACE("disabling rollback\n");
|
|
|
|
msi_set_property( package->db, szRollbackDisabled, szOne );
|
|
|
|
}
|
|
|
|
|
2009-10-15 12:48:26 +02:00
|
|
|
if (needs_ui_sequence( package))
|
2009-10-15 12:47:48 +02:00
|
|
|
{
|
|
|
|
package->script->InWhatSequence |= SEQUENCE_UI;
|
|
|
|
rc = ACTION_ProcessUISequence(package);
|
|
|
|
ui_exists = ui_sequence_exists(package);
|
|
|
|
if (rc == ERROR_SUCCESS || !ui_exists)
|
|
|
|
{
|
|
|
|
package->script->InWhatSequence |= SEQUENCE_EXEC;
|
|
|
|
rc = ACTION_ProcessExecSequence(package, ui_exists);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = ACTION_ProcessExecSequence(package, FALSE);
|
|
|
|
|
|
|
|
package->script->CurrentlyScripting = FALSE;
|
|
|
|
|
|
|
|
/* process the ending type action */
|
|
|
|
if (rc == ERROR_SUCCESS)
|
2009-10-15 12:49:10 +02:00
|
|
|
ACTION_PerformActionSequence(package, -1);
|
2009-10-15 12:47:48 +02:00
|
|
|
else if (rc == ERROR_INSTALL_USEREXIT)
|
2009-10-15 12:49:10 +02:00
|
|
|
ACTION_PerformActionSequence(package, -2);
|
2009-10-15 12:47:48 +02:00
|
|
|
else if (rc == ERROR_INSTALL_SUSPEND)
|
2009-10-15 12:49:10 +02:00
|
|
|
ACTION_PerformActionSequence(package, -4);
|
2009-10-15 12:47:48 +02:00
|
|
|
else /* failed */
|
2011-05-20 12:34:00 +02:00
|
|
|
{
|
2009-10-15 12:49:10 +02:00
|
|
|
ACTION_PerformActionSequence(package, -3);
|
2011-05-24 10:50:28 +02:00
|
|
|
if (!msi_get_property_int( package->db, szRollbackDisabled, 0 ))
|
|
|
|
{
|
|
|
|
package->need_rollback = TRUE;
|
|
|
|
}
|
2011-05-20 12:34:00 +02:00
|
|
|
}
|
2009-10-15 12:47:48 +02:00
|
|
|
|
|
|
|
/* finish up running custom actions */
|
|
|
|
ACTION_FinishCustomActions(package);
|
|
|
|
|
2011-05-24 10:50:28 +02:00
|
|
|
if (package->need_rollback)
|
2011-05-20 12:34:00 +02:00
|
|
|
{
|
|
|
|
WARN("installation failed, running rollback script\n");
|
|
|
|
msi_set_property( package->db, szRollbackDisabled, NULL );
|
|
|
|
execute_script( package, ROLLBACK_SCRIPT );
|
|
|
|
}
|
|
|
|
|
2009-10-15 12:47:48 +02:00
|
|
|
if (rc == ERROR_SUCCESS && package->need_reboot)
|
|
|
|
return ERROR_SUCCESS_REBOOT_REQUIRED;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|