2004-06-30 21:38:36 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2004 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-30 21:38:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
2006-01-13 13:53:16 +01:00
|
|
|
#define NONAMELESSSTRUCT
|
2007-07-03 05:15:01 +02:00
|
|
|
#define COBJMACROS
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "shlwapi.h"
|
2005-01-05 18:11:33 +01:00
|
|
|
#include "wingdi.h"
|
2004-06-30 21:38:36 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "wincrypt.h"
|
|
|
|
#include "winuser.h"
|
2006-07-26 23:54:15 +02:00
|
|
|
#include "wininet.h"
|
2007-06-13 01:33:52 +02:00
|
|
|
#include "winver.h"
|
2006-07-26 23:54:15 +02:00
|
|
|
#include "urlmon.h"
|
2004-06-30 21:38:36 +02:00
|
|
|
#include "shlobj.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "objbase.h"
|
2006-08-07 20:37:49 +02:00
|
|
|
#include "msidefs.h"
|
2006-12-01 03:15:40 +01:00
|
|
|
#include "sddl.h"
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-11-15 13:00:13 +01:00
|
|
|
#include "msipriv.h"
|
2007-07-03 05:15:01 +02:00
|
|
|
#include "msiserver.h"
|
2005-11-15 13:00:13 +01:00
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2005-05-31 11:30:28 +02:00
|
|
|
static void MSI_FreePackage( MSIOBJECTHDR *arg)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIPACKAGE *package= (MSIPACKAGE*) arg;
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2005-02-02 10:55:51 +01:00
|
|
|
if( package->dialog )
|
|
|
|
msi_dialog_destroy( package->dialog );
|
2006-08-25 10:54:29 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &package->db->hdr );
|
2006-11-14 04:42:50 +01:00
|
|
|
ACTION_free_package_structures(package);
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2007-07-12 20:36:43 +02:00
|
|
|
static UINT create_temp_property_table(MSIPACKAGE *package)
|
2006-11-27 09:48:10 +01:00
|
|
|
{
|
2007-07-12 20:36:43 +02:00
|
|
|
MSIQUERY *view = NULL;
|
2007-04-21 09:37:51 +02:00
|
|
|
UINT rc;
|
2007-07-12 20:36:43 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
static const WCHAR CreateSql[] = {
|
|
|
|
'C','R','E','A','T','E',' ','T','A','B','L','E',' ','`','_','P','r','o',
|
|
|
|
'p','e','r','t','y','`',' ','(',' ','`','_','P','r','o','p','e','r','t',
|
|
|
|
'y','`',' ','C','H','A','R','(','5','6',')',' ','N','O','T',' ','N','U',
|
2007-04-24 13:32:22 +02:00
|
|
|
'L','L',' ','T','E','M','P','O','R','A','R','Y',',',' ','`','V','a','l',
|
|
|
|
'u','e','`',' ','C','H','A','R','(','9','8',')',' ','N','O','T',' ','N',
|
|
|
|
'U','L','L',' ','T','E','M','P','O','R','A','R','Y',' ','P','R','I','M',
|
|
|
|
'A','R','Y',' ','K','E','Y',' ','`','_','P','r','o','p','e','r','t','y',
|
|
|
|
'`',')',0};
|
2007-07-12 20:36:43 +02:00
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, CreateSql, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = MSI_ViewExecute(view, 0);
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT msi_clone_properties(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
MSIQUERY *view = NULL;
|
|
|
|
UINT rc;
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
static const WCHAR Query[] = {
|
|
|
|
'S','E','L','E','C','T',' ','*',' ',
|
|
|
|
'F','R','O','M',' ','`','P','r','o','p','e','r','t','y','`',0};
|
|
|
|
static const WCHAR Insert[] = {
|
|
|
|
'I','N','S','E','R','T',' ','i','n','t','o',' ',
|
|
|
|
'`','_','P','r','o','p','e','r','t','y','`',' ',
|
|
|
|
'(','`','_','P','r','o','p','e','r','t','y','`',',',
|
|
|
|
'`','V','a','l','u','e','`',')',' ',
|
|
|
|
'V','A','L','U','E','S',' ','(','?',',','?',')',0};
|
|
|
|
|
|
|
|
/* clone the existing properties */
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
rc = MSI_ViewExecute(view, 0);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
MSI_ViewClose(view);
|
2006-08-25 10:54:29 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2007-04-21 09:37:51 +02:00
|
|
|
return rc;
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
2007-04-21 09:37:51 +02:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
MSIRECORD *row;
|
|
|
|
MSIQUERY *view2;
|
|
|
|
|
|
|
|
rc = MSI_ViewFetch(view, &row);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Insert, &view2);
|
|
|
|
if (rc!= ERROR_SUCCESS)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rc = MSI_ViewExecute(view2, row);
|
|
|
|
MSI_ViewClose(view2);
|
|
|
|
msiobj_release(&view2->hdr);
|
|
|
|
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
}
|
|
|
|
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
|
|
|
|
return rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2005-11-15 13:00:13 +01:00
|
|
|
/*
|
|
|
|
* set_installed_prop
|
|
|
|
*
|
|
|
|
* Sets the "Installed" property to indicate that
|
|
|
|
* the product is installed for the current user.
|
|
|
|
*/
|
|
|
|
static UINT set_installed_prop( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
static const WCHAR szInstalled[] = {
|
|
|
|
'I','n','s','t','a','l','l','e','d',0 };
|
|
|
|
WCHAR val[2] = { '1', 0 };
|
|
|
|
HKEY hkey = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MSIREG_OpenUninstallKey( package->ProductCode, &hkey, FALSE );
|
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
MSI_SetPropertyW( package, szInstalled, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2006-12-01 03:15:40 +01:00
|
|
|
static UINT set_user_sid_prop( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
SID_NAME_USE use;
|
|
|
|
LPWSTR user_name;
|
2006-12-05 12:43:31 +01:00
|
|
|
LPWSTR sid_str = NULL, dom = NULL;
|
2006-12-01 03:15:40 +01:00
|
|
|
DWORD size, dom_size;
|
|
|
|
PSID psid = NULL;
|
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
static const WCHAR user_sid[] = {'U','s','e','r','S','I','D',0};
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
GetUserNameW( NULL, &size );
|
|
|
|
|
|
|
|
user_name = msi_alloc( (size + 1) * sizeof(WCHAR) );
|
|
|
|
if (!user_name)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (!GetUserNameW( user_name, &size ))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
dom_size = 0;
|
|
|
|
LookupAccountNameW( NULL, user_name, NULL, &size, NULL, &dom_size, &use );
|
|
|
|
|
|
|
|
psid = msi_alloc( size );
|
2007-01-25 15:05:19 +01:00
|
|
|
dom = msi_alloc( dom_size*sizeof (WCHAR) );
|
2006-12-01 03:15:40 +01:00
|
|
|
if (!psid || !dom)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!LookupAccountNameW( NULL, user_name, psid, &size, dom, &dom_size, &use ))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!ConvertSidToStringSidW( psid, &sid_str ))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = MSI_SetPropertyW( package, user_sid, sid_str );
|
|
|
|
|
|
|
|
done:
|
|
|
|
LocalFree( sid_str );
|
|
|
|
msi_free( dom );
|
|
|
|
msi_free( psid );
|
|
|
|
msi_free( user_name );
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-06-13 01:33:52 +02:00
|
|
|
static LPWSTR get_fusion_filename(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
HKEY netsetup;
|
|
|
|
LONG res;
|
|
|
|
LPWSTR file;
|
|
|
|
DWORD index = 0, size;
|
|
|
|
WCHAR ver[MAX_PATH];
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
WCHAR windir[MAX_PATH];
|
|
|
|
|
|
|
|
static const WCHAR backslash[] = {'\\',0};
|
|
|
|
static const WCHAR fusion[] = {'f','u','s','i','o','n','.','d','l','l',0};
|
|
|
|
static const WCHAR sub[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'N','E','T',' ','F','r','a','m','e','w','o','r','k',' ','S','e','t','u','p','\\',
|
|
|
|
'N','D','P',0
|
|
|
|
};
|
|
|
|
static const WCHAR subdir[] = {
|
|
|
|
'M','i','c','r','o','s','o','f','t','.','N','E','T','\\',
|
|
|
|
'F','r','a','m','e','w','o','r','k','\\',0
|
|
|
|
};
|
|
|
|
|
|
|
|
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub, 0, KEY_ENUMERATE_SUB_KEYS, &netsetup);
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ver[0] = '\0';
|
|
|
|
size = MAX_PATH;
|
|
|
|
while (RegEnumKeyExW(netsetup, index, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
index++;
|
|
|
|
if (lstrcmpW(ver, name) < 0)
|
|
|
|
lstrcpyW(ver, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(netsetup);
|
|
|
|
|
|
|
|
if (!index)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
GetWindowsDirectoryW(windir, MAX_PATH);
|
|
|
|
|
|
|
|
size = lstrlenW(windir) + lstrlenW(subdir) + lstrlenW(ver) +lstrlenW(fusion) + 3;
|
|
|
|
file = msi_alloc(size * sizeof(WCHAR));
|
|
|
|
if (!file)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
lstrcpyW(file, windir);
|
|
|
|
lstrcatW(file, backslash);
|
|
|
|
lstrcatW(file, subdir);
|
|
|
|
lstrcatW(file, ver);
|
|
|
|
lstrcatW(file, backslash);
|
|
|
|
lstrcatW(file, fusion);
|
|
|
|
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct tagLANGANDCODEPAGE
|
|
|
|
{
|
|
|
|
WORD wLanguage;
|
|
|
|
WORD wCodePage;
|
|
|
|
} LANGANDCODEPAGE;
|
|
|
|
|
|
|
|
static void set_msi_assembly_prop(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT val_len;
|
|
|
|
DWORD size, handle;
|
|
|
|
LPVOID version = NULL;
|
|
|
|
WCHAR buf[MAX_PATH];
|
|
|
|
LPWSTR fusion, verstr;
|
|
|
|
LANGANDCODEPAGE *translate;
|
|
|
|
|
|
|
|
static const WCHAR netasm[] = {
|
|
|
|
'M','s','i','N','e','t','A','s','s','e','m','b','l','y','S','u','p','p','o','r','t',0
|
|
|
|
};
|
|
|
|
static const WCHAR translation[] = {
|
|
|
|
'\\','V','a','r','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','T','r','a','n','s','l','a','t','i','o','n',0
|
|
|
|
};
|
|
|
|
static const WCHAR verfmt[] = {
|
|
|
|
'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
|
|
|
|
'\\','%','0','4','x','%','0','4','x',
|
|
|
|
'\\','P','r','o','d','u','c','t','V','e','r','s','i','o','n',0
|
|
|
|
};
|
|
|
|
|
|
|
|
fusion = get_fusion_filename(package);
|
|
|
|
if (!fusion)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = GetFileVersionInfoSizeW(fusion, &handle);
|
|
|
|
if (!size) return;
|
|
|
|
|
|
|
|
version = msi_alloc(size);
|
|
|
|
if (!version) return;
|
|
|
|
|
|
|
|
if (!GetFileVersionInfoW(fusion, handle, size, version))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!VerQueryValueW(version, translation, (LPVOID *)&translate, &val_len))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
sprintfW(buf, verfmt, translate[0].wLanguage, translate[0].wCodePage);
|
|
|
|
|
|
|
|
if (!VerQueryValueW(version, buf, (LPVOID *)&verstr, &val_len))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!val_len || !verstr)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
MSI_SetPropertyW(package, netasm, verstr);
|
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(fusion);
|
|
|
|
msi_free(version);
|
|
|
|
}
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
/*
|
|
|
|
* There are a whole slew of these we need to set
|
|
|
|
*
|
|
|
|
*
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/properties.asp
|
|
|
|
*/
|
2004-07-10 00:25:34 +02:00
|
|
|
static VOID set_installer_properties(MSIPACKAGE *package)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
|
|
|
WCHAR pth[MAX_PATH];
|
2004-12-22 18:13:26 +01:00
|
|
|
WCHAR *ptr;
|
2007-05-29 23:13:59 +02:00
|
|
|
OSVERSIONINFOEXW OSVersion;
|
2005-05-04 12:37:05 +02:00
|
|
|
MEMORYSTATUSEX msex;
|
2004-07-04 02:36:58 +02:00
|
|
|
DWORD verval;
|
2005-01-05 18:11:33 +01:00
|
|
|
WCHAR verstr[10], bufstr[20];
|
|
|
|
HDC dc;
|
2006-10-18 20:26:49 +02:00
|
|
|
LPWSTR check;
|
|
|
|
HKEY hkey;
|
|
|
|
LONG res;
|
2007-03-05 13:03:20 +01:00
|
|
|
SYSTEM_INFO sys_info;
|
|
|
|
SYSTEMTIME systemtime;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
static const WCHAR cszbs[]={'\\',0};
|
|
|
|
static const WCHAR CFF[] =
|
|
|
|
{'C','o','m','m','o','n','F','i','l','e','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR PFF[] =
|
|
|
|
{'P','r','o','g','r','a','m','F','i','l','e','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR CADF[] =
|
|
|
|
{'C','o','m','m','o','n','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
|
2004-08-19 01:41:10 +02:00
|
|
|
static const WCHAR FaF[] =
|
|
|
|
{'F','a','v','o','r','i','t','e','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR FoF[] =
|
|
|
|
{'F','o','n','t','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR SendTF[] =
|
|
|
|
{'S','e','n','d','T','o','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR SMF[] =
|
|
|
|
{'S','t','a','r','t','M','e','n','u','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR StF[] =
|
|
|
|
{'S','t','a','r','t','u','p','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR TemplF[] =
|
|
|
|
{'T','e','m','p','l','a','t','e','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR DF[] =
|
|
|
|
{'D','e','s','k','t','o','p','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR PMF[] =
|
|
|
|
{'P','r','o','g','r','a','m','M','e','n','u','F','o','l','d','e','r',0};
|
2004-06-30 21:38:36 +02:00
|
|
|
static const WCHAR ATF[] =
|
|
|
|
{'A','d','m','i','n','T','o','o','l','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR ADF[] =
|
|
|
|
{'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR SF[] =
|
|
|
|
{'S','y','s','t','e','m','F','o','l','d','e','r',0};
|
2004-12-27 18:43:37 +01:00
|
|
|
static const WCHAR SF16[] =
|
|
|
|
{'S','y','s','t','e','m','1','6','F','o','l','d','e','r',0};
|
2004-06-30 21:38:36 +02:00
|
|
|
static const WCHAR LADF[] =
|
|
|
|
{'L','o','c','a','l','A','p','p','D','a','t','a','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR MPF[] =
|
|
|
|
{'M','y','P','i','c','t','u','r','e','s','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR PF[] =
|
|
|
|
{'P','e','r','s','o','n','a','l','F','o','l','d','e','r',0};
|
|
|
|
static const WCHAR WF[] =
|
|
|
|
{'W','i','n','d','o','w','s','F','o','l','d','e','r',0};
|
2004-12-22 18:13:26 +01:00
|
|
|
static const WCHAR WV[] =
|
|
|
|
{'W','i','n','d','o','w','s','V','o','l','u','m','e',0};
|
2004-06-30 21:38:36 +02:00
|
|
|
static const WCHAR TF[]=
|
|
|
|
{'T','e','m','p','F','o','l','d','e','r',0};
|
2004-07-10 00:25:34 +02:00
|
|
|
static const WCHAR szAdminUser[] =
|
|
|
|
{'A','d','m','i','n','U','s','e','r',0};
|
|
|
|
static const WCHAR szPriv[] =
|
|
|
|
{'P','r','i','v','i','l','e','g','e','d',0};
|
|
|
|
static const WCHAR szOne[] =
|
|
|
|
{'1',0};
|
|
|
|
static const WCHAR v9x[] = { 'V','e','r','s','i','o','n','9','X',0 };
|
|
|
|
static const WCHAR vNT[] = { 'V','e','r','s','i','o','n','N','T',0 };
|
2007-05-29 23:13:59 +02:00
|
|
|
static const WCHAR szMsiNTProductType[] = { 'M','s','i','N','T','P','r','o','d','u','c','t','T','y','p','e',0 };
|
2004-07-10 00:25:34 +02:00
|
|
|
static const WCHAR szFormat[] = {'%','l','i',0};
|
|
|
|
static const WCHAR szWinBuild[] =
|
|
|
|
{'W','i','n','d','o','w','s','B','u','i','l','d', 0 };
|
|
|
|
static const WCHAR szSPL[] =
|
|
|
|
{'S','e','r','v','i','c','e','P','a','c','k','L','e','v','e','l',0 };
|
|
|
|
static const WCHAR szSix[] = {'6',0 };
|
|
|
|
|
2004-07-19 23:49:15 +02:00
|
|
|
static const WCHAR szVersionMsi[] = { 'V','e','r','s','i','o','n','M','s','i',0 };
|
2007-03-05 13:03:20 +01:00
|
|
|
static const WCHAR szVersionDatabase[] = { 'V','e','r','s','i','o','n','D','a','t','a','b','a','s','e',0 };
|
2005-05-04 12:37:05 +02:00
|
|
|
static const WCHAR szPhysicalMemory[] = { 'P','h','y','s','i','c','a','l','M','e','m','o','r','y',0 };
|
2004-07-19 23:49:15 +02:00
|
|
|
static const WCHAR szFormat2[] = {'%','l','i','.','%','l','i',0};
|
2004-12-16 15:31:59 +01:00
|
|
|
/* Screen properties */
|
|
|
|
static const WCHAR szScreenX[] = {'S','c','r','e','e','n','X',0};
|
|
|
|
static const WCHAR szScreenY[] = {'S','c','r','e','e','n','Y',0};
|
|
|
|
static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0};
|
|
|
|
static const WCHAR szScreenFormat[] = {'%','d',0};
|
2005-12-31 13:14:34 +01:00
|
|
|
static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
|
2006-08-25 15:35:29 +02:00
|
|
|
static const WCHAR szAllUsers[] = { 'A','L','L','U','S','E','R','S',0 };
|
2006-10-18 20:26:49 +02:00
|
|
|
static const WCHAR szCurrentVersion[] = {
|
|
|
|
'S','O','F','T','W','A','R','E','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szRegisteredUser[] = {'R','e','g','i','s','t','e','r','e','d','O','w','n','e','r',0};
|
|
|
|
static const WCHAR szRegisteredOrg[] = {
|
|
|
|
'R','e','g','i','s','t','e','r','e','d','O','r','g','a','n','i','z','a','t','i','o','n',0
|
|
|
|
};
|
|
|
|
static const WCHAR szUSERNAME[] = {'U','S','E','R','N','A','M','E',0};
|
|
|
|
static const WCHAR szCOMPANYNAME[] = {'C','O','M','P','A','N','Y','N','A','M','E',0};
|
2007-03-05 13:03:20 +01:00
|
|
|
static const WCHAR szDate[] = {'D','a','t','e',0};
|
|
|
|
static const WCHAR szTime[] = {'T','i','m','e',0};
|
2004-07-19 23:49:15 +02:00
|
|
|
|
2005-11-15 13:00:13 +01:00
|
|
|
/*
|
|
|
|
* Other things that probably should be set:
|
|
|
|
*
|
|
|
|
* SystemLanguageID ComputerName UserLanguageID LogonUser VirtualMemory
|
2007-03-05 13:03:20 +01:00
|
|
|
* ShellAdvSupport DefaultUIFont PackagecodeChanging
|
2005-11-15 13:00:13 +01:00
|
|
|
* ProductState CaptionHeight BorderTop BorderSide TextHeight
|
2007-03-05 13:03:20 +01:00
|
|
|
* RedirectedDllSupport
|
2005-11-15 13:00:13 +01:00
|
|
|
*/
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES_COMMON,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, CFF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_PROGRAM_FILES,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, PFF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_COMMON_APPDATA,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, CADF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2004-08-19 01:41:10 +02:00
|
|
|
SHGetFolderPathW(NULL,CSIDL_FAVORITES,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, FaF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_FONTS,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, FoF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_SENDTO,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, SendTF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_STARTMENU,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, SMF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_STARTUP,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, StF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_TEMPLATES,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, TemplF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_DESKTOP,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, DF, pth);
|
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_PROGRAMS,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
|
|
|
MSI_SetPropertyW(package, PMF, pth);
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
SHGetFolderPathW(NULL,CSIDL_ADMINTOOLS,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, ATF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_APPDATA,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, ADF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_SYSTEM,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, SF, pth);
|
2004-12-27 18:43:37 +01:00
|
|
|
MSI_SetPropertyW(package, SF16, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_LOCAL_APPDATA,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, LADF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_MYPICTURES,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, MPF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_PERSONAL,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, PF, pth);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
|
|
|
|
strcatW(pth,cszbs);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, WF, pth);
|
2005-05-04 12:37:05 +02:00
|
|
|
|
|
|
|
/* Physical Memory is specified in MB. Using total amount. */
|
|
|
|
msex.dwLength = sizeof(msex);
|
|
|
|
GlobalMemoryStatusEx( &msex );
|
|
|
|
sprintfW( bufstr, szScreenFormat, (int)(msex.ullTotalPhys/1024/1024));
|
|
|
|
MSI_SetPropertyW(package, szPhysicalMemory, bufstr);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2004-12-22 18:13:26 +01:00
|
|
|
SHGetFolderPathW(NULL,CSIDL_WINDOWS,NULL,0,pth);
|
|
|
|
ptr = strchrW(pth,'\\');
|
|
|
|
if (ptr)
|
2004-12-22 19:17:15 +01:00
|
|
|
*(ptr+1) = 0;
|
2004-12-22 18:13:26 +01:00
|
|
|
MSI_SetPropertyW(package, WV, pth);
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
GetTempPathW(MAX_PATH,pth);
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package, TF, pth);
|
2004-07-04 02:36:58 +02:00
|
|
|
|
2004-07-06 21:00:23 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
/* in a wine environment the user is always admin and privileged */
|
|
|
|
MSI_SetPropertyW(package,szAdminUser,szOne);
|
|
|
|
MSI_SetPropertyW(package,szPriv,szOne);
|
2006-08-25 15:35:29 +02:00
|
|
|
MSI_SetPropertyW(package, szAllUsers, szOne);
|
2004-07-04 02:36:58 +02:00
|
|
|
|
|
|
|
/* set the os things */
|
2007-05-29 23:13:59 +02:00
|
|
|
OSVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
|
|
|
GetVersionExW((OSVERSIONINFOW *)&OSVersion);
|
2004-07-04 02:36:58 +02:00
|
|
|
verval = OSVersion.dwMinorVersion+OSVersion.dwMajorVersion*100;
|
2004-07-10 00:25:34 +02:00
|
|
|
sprintfW(verstr,szFormat,verval);
|
2004-07-04 02:36:58 +02:00
|
|
|
switch (OSVersion.dwPlatformId)
|
|
|
|
{
|
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package,v9x,verstr);
|
2004-07-04 02:36:58 +02:00
|
|
|
break;
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package,vNT,verstr);
|
2007-05-29 23:13:59 +02:00
|
|
|
sprintfW(verstr,szFormat,OSVersion.wProductType);
|
|
|
|
MSI_SetPropertyW(package,szMsiNTProductType,verstr);
|
2004-07-04 02:36:58 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
sprintfW(verstr,szFormat,OSVersion.dwBuildNumber);
|
|
|
|
MSI_SetPropertyW(package,szWinBuild,verstr);
|
2004-07-04 02:36:58 +02:00
|
|
|
/* just fudge this */
|
2004-07-10 00:25:34 +02:00
|
|
|
MSI_SetPropertyW(package,szSPL,szSix);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-01-05 18:11:33 +01:00
|
|
|
sprintfW( bufstr, szFormat2, MSI_MAJORVERSION, MSI_MINORVERSION);
|
|
|
|
MSI_SetPropertyW( package, szVersionMsi, bufstr );
|
2007-03-05 13:03:20 +01:00
|
|
|
sprintfW( bufstr, szFormat, MSI_MAJORVERSION * 100);
|
|
|
|
MSI_SetPropertyW( package, szVersionDatabase, bufstr );
|
2005-01-05 18:11:33 +01:00
|
|
|
|
2005-12-31 13:14:34 +01:00
|
|
|
GetSystemInfo( &sys_info );
|
2006-01-13 13:53:16 +01:00
|
|
|
if (sys_info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
|
2005-12-31 13:14:34 +01:00
|
|
|
{
|
|
|
|
sprintfW( bufstr, szScreenFormat, sys_info.wProcessorLevel );
|
|
|
|
MSI_SetPropertyW( package, szIntel, bufstr );
|
|
|
|
}
|
|
|
|
|
2005-01-05 18:11:33 +01:00
|
|
|
/* Screen properties. */
|
|
|
|
dc = GetDC(0);
|
|
|
|
sprintfW( bufstr, szScreenFormat, GetDeviceCaps( dc, HORZRES ) );
|
|
|
|
MSI_SetPropertyW( package, szScreenX, bufstr );
|
|
|
|
sprintfW( bufstr, szScreenFormat, GetDeviceCaps( dc, VERTRES ));
|
|
|
|
MSI_SetPropertyW( package, szScreenY, bufstr );
|
|
|
|
sprintfW( bufstr, szScreenFormat, GetDeviceCaps( dc, BITSPIXEL ));
|
|
|
|
MSI_SetPropertyW( package, szColorBits, bufstr );
|
|
|
|
ReleaseDC(0, dc);
|
2006-10-18 20:26:49 +02:00
|
|
|
|
|
|
|
/* USERNAME and COMPANYNAME */
|
|
|
|
res = RegOpenKeyW( HKEY_LOCAL_MACHINE, szCurrentVersion, &hkey );
|
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
check = msi_dup_property( package, szUSERNAME );
|
|
|
|
if (!check)
|
|
|
|
{
|
|
|
|
LPWSTR user = msi_reg_get_val_str( hkey, szRegisteredUser );
|
|
|
|
MSI_SetPropertyW( package, szUSERNAME, user );
|
|
|
|
msi_free( user );
|
|
|
|
}
|
|
|
|
|
|
|
|
msi_free( check );
|
|
|
|
|
|
|
|
check = msi_dup_property( package, szCOMPANYNAME );
|
|
|
|
if (!check)
|
|
|
|
{
|
|
|
|
LPWSTR company = msi_reg_get_val_str( hkey, szRegisteredOrg );
|
|
|
|
MSI_SetPropertyW( package, szCOMPANYNAME, company );
|
|
|
|
msi_free( company );
|
|
|
|
}
|
|
|
|
|
2006-12-01 03:15:40 +01:00
|
|
|
if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
|
|
|
|
ERR("Failed to set the UserSID property\n");
|
|
|
|
|
2007-03-05 13:03:20 +01:00
|
|
|
/* Date and time properties */
|
|
|
|
GetSystemTime( &systemtime );
|
|
|
|
if (GetDateFormatW( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systemtime,
|
|
|
|
NULL, bufstr, sizeof(bufstr)/sizeof(bufstr[0]) ))
|
|
|
|
MSI_SetPropertyW( package, szDate, bufstr );
|
|
|
|
else
|
|
|
|
ERR("Couldn't set Date property: GetDateFormat failed with error %d\n", GetLastError());
|
|
|
|
|
|
|
|
if (GetTimeFormatW( LOCALE_USER_DEFAULT,
|
|
|
|
TIME_FORCE24HOURFORMAT | TIME_NOTIMEMARKER,
|
|
|
|
&systemtime, NULL, bufstr,
|
|
|
|
sizeof(bufstr)/sizeof(bufstr[0]) ))
|
|
|
|
MSI_SetPropertyW( package, szTime, bufstr );
|
|
|
|
else
|
|
|
|
ERR("Couldn't set Time property: GetTimeFormat failed with error %d\n", GetLastError());
|
|
|
|
|
2007-06-13 01:33:52 +02:00
|
|
|
set_msi_assembly_prop( package );
|
|
|
|
|
2006-10-18 20:26:49 +02:00
|
|
|
msi_free( check );
|
|
|
|
CloseHandle( hkey );
|
2004-07-06 21:00:23 +02:00
|
|
|
}
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-03-05 13:04:41 +01:00
|
|
|
static UINT msi_load_summary_properties( MSIPACKAGE *package )
|
2006-08-07 20:37:49 +02:00
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIHANDLE suminfo;
|
|
|
|
MSIHANDLE hdb = alloc_msihandle( &package->db->hdr );
|
2007-03-05 13:04:41 +01:00
|
|
|
INT word_count;
|
|
|
|
DWORD len;
|
|
|
|
LPWSTR package_code;
|
|
|
|
static const WCHAR szPackageCode[] = {
|
|
|
|
'P','a','c','k','a','g','e','C','o','d','e',0};
|
2006-08-07 20:37:49 +02:00
|
|
|
|
2006-08-28 18:44:35 +02:00
|
|
|
if (!hdb) {
|
|
|
|
ERR("Unable to allocate handle\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2006-08-07 20:37:49 +02:00
|
|
|
rc = MsiGetSummaryInformationW( hdb, NULL, 0, &suminfo );
|
|
|
|
MsiCloseHandle(hdb);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Unable to open Summary Information\n");
|
2007-03-05 13:04:41 +01:00
|
|
|
return rc;
|
2006-08-07 20:37:49 +02:00
|
|
|
}
|
|
|
|
|
2007-03-05 13:04:41 +01:00
|
|
|
/* load package attributes */
|
2006-08-07 20:37:49 +02:00
|
|
|
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_WORDCOUNT, NULL,
|
|
|
|
&word_count, NULL, NULL, NULL );
|
2007-03-05 13:04:41 +01:00
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
package->WordCount = word_count;
|
|
|
|
else
|
|
|
|
WARN("Unable to query word count\n");
|
|
|
|
|
|
|
|
/* load package code property */
|
|
|
|
len = 0;
|
|
|
|
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
|
|
|
|
NULL, NULL, NULL, &len );
|
|
|
|
if (rc == ERROR_MORE_DATA)
|
2006-08-07 20:37:49 +02:00
|
|
|
{
|
2007-03-05 13:04:41 +01:00
|
|
|
len++;
|
|
|
|
package_code = msi_alloc( len * sizeof(WCHAR) );
|
|
|
|
rc = MsiSummaryInfoGetPropertyW( suminfo, PID_REVNUMBER, NULL,
|
|
|
|
NULL, NULL, package_code, &len );
|
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
MSI_SetPropertyW( package, szPackageCode, package_code );
|
|
|
|
else
|
|
|
|
WARN("Unable to query rev number, %d\n", rc);
|
|
|
|
msi_free( package_code );
|
2006-08-07 20:37:49 +02:00
|
|
|
}
|
2007-03-05 13:04:41 +01:00
|
|
|
else
|
|
|
|
WARN("Unable to query rev number, %d\n", rc);
|
2006-08-07 20:37:49 +02:00
|
|
|
|
|
|
|
MsiCloseHandle(suminfo);
|
2007-03-05 13:04:41 +01:00
|
|
|
return ERROR_SUCCESS;
|
2006-08-07 20:37:49 +02:00
|
|
|
}
|
|
|
|
|
2006-11-14 06:47:24 +01:00
|
|
|
static MSIPACKAGE *msi_alloc_package( void )
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2006-11-14 06:47:24 +01:00
|
|
|
MSIPACKAGE *package;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
package = alloc_msiobject( MSIHANDLETYPE_PACKAGE, sizeof (MSIPACKAGE),
|
|
|
|
MSI_FreePackage );
|
2005-01-27 12:12:16 +01:00
|
|
|
if( package )
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2005-08-22 11:15:23 +02:00
|
|
|
list_init( &package->components );
|
2005-08-23 20:15:44 +02:00
|
|
|
list_init( &package->features );
|
2005-08-23 12:03:17 +02:00
|
|
|
list_init( &package->files );
|
2005-09-07 13:25:18 +02:00
|
|
|
list_init( &package->tempfiles );
|
2005-08-23 20:15:44 +02:00
|
|
|
list_init( &package->folders );
|
2005-06-06 17:40:15 +02:00
|
|
|
list_init( &package->subscriptions );
|
2005-08-24 11:45:18 +02:00
|
|
|
list_init( &package->appids );
|
2005-08-25 12:22:32 +02:00
|
|
|
list_init( &package->classes );
|
2005-08-26 10:47:31 +02:00
|
|
|
list_init( &package->mimes );
|
2005-08-29 11:38:39 +02:00
|
|
|
list_init( &package->extensions );
|
2005-09-06 11:26:18 +02:00
|
|
|
list_init( &package->progids );
|
2005-09-08 14:42:07 +02:00
|
|
|
list_init( &package->RunningActions );
|
2007-07-03 05:20:20 +02:00
|
|
|
list_init( &package->sourcelist_info );
|
|
|
|
list_init( &package->sourcelist_media );
|
2004-07-10 00:25:34 +02:00
|
|
|
|
2006-11-14 06:47:24 +01:00
|
|
|
package->ActionFormat = NULL;
|
|
|
|
package->LastAction = NULL;
|
|
|
|
package->dialog = NULL;
|
|
|
|
package->next_dialog = NULL;
|
2007-06-25 21:47:38 +02:00
|
|
|
package->scheduled_action_running = FALSE;
|
|
|
|
package->commit_action_running = FALSE;
|
|
|
|
package->rollback_action_running = FALSE;
|
2006-11-14 06:47:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return package;
|
|
|
|
}
|
|
|
|
|
2007-07-16 23:45:29 +02:00
|
|
|
static UINT msi_load_admin_properties(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
BYTE *data;
|
|
|
|
UINT r, sz;
|
|
|
|
|
|
|
|
static const WCHAR stmname[] = {'A','d','m','i','n','P','r','o','p','e','r','t','i','e','s',0};
|
|
|
|
|
|
|
|
r = read_stream_data(package->db->storage, stmname, FALSE, &data, &sz);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = msi_parse_command_line(package, (WCHAR *)data);
|
|
|
|
|
|
|
|
msi_free(data);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2007-06-05 19:53:43 +02:00
|
|
|
MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
|
2006-11-14 06:47:24 +01:00
|
|
|
{
|
|
|
|
static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
|
|
|
|
static const WCHAR szpi[] = {'%','i',0};
|
|
|
|
static const WCHAR szProductCode[] = {
|
|
|
|
'P','r','o','d','u','c','t','C','o','d','e',0};
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
WCHAR uilevel[10];
|
|
|
|
|
|
|
|
TRACE("%p\n", db);
|
|
|
|
|
|
|
|
package = msi_alloc_package();
|
|
|
|
if (package)
|
|
|
|
{
|
|
|
|
msiobj_addref( &db->hdr );
|
|
|
|
package->db = db;
|
|
|
|
|
2007-03-05 13:04:41 +01:00
|
|
|
package->WordCount = 0;
|
2006-10-10 22:39:50 +02:00
|
|
|
package->PackagePath = strdupW( db->path );
|
2006-11-08 00:13:47 +01:00
|
|
|
package->BaseURL = strdupW( base_url );
|
2006-08-07 20:37:49 +02:00
|
|
|
|
2007-07-12 20:36:43 +02:00
|
|
|
create_temp_property_table( package );
|
|
|
|
msi_clone_properties( package );
|
2004-07-10 00:25:34 +02:00
|
|
|
set_installer_properties(package);
|
|
|
|
sprintfW(uilevel,szpi,gUILevel);
|
|
|
|
MSI_SetPropertyW(package, szLevel, uilevel);
|
2005-11-15 13:00:13 +01:00
|
|
|
|
|
|
|
package->ProductCode = msi_dup_property( package, szProductCode );
|
|
|
|
set_installed_prop( package );
|
2007-03-05 13:04:41 +01:00
|
|
|
msi_load_summary_properties( package );
|
2007-07-16 23:45:29 +02:00
|
|
|
|
|
|
|
if (package->WordCount & MSIWORDCOUNT_ADMINISTRATIVE)
|
|
|
|
msi_load_admin_properties( package );
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
return package;
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
|
|
|
|
2005-09-25 17:14:32 +02:00
|
|
|
/*
|
|
|
|
* copy_package_to_temp [internal]
|
|
|
|
*
|
|
|
|
* copy the msi file to a temp file to prevent locking a CD
|
|
|
|
* with a multi disc install
|
|
|
|
*
|
|
|
|
* FIXME: I think this is wrong, and instead of copying the package,
|
|
|
|
* we should read all the tables to memory, then open the
|
|
|
|
* database to read binary streams on demand.
|
|
|
|
*/
|
|
|
|
static LPCWSTR copy_package_to_temp( LPCWSTR szPackage, LPWSTR filename )
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
2006-11-14 04:43:04 +01:00
|
|
|
static const WCHAR szMSI[] = {'m','s','i',0};
|
2005-09-25 17:14:32 +02:00
|
|
|
|
|
|
|
GetTempPathW( MAX_PATH, path );
|
|
|
|
GetTempFileNameW( path, szMSI, 0, filename );
|
|
|
|
|
|
|
|
if( !CopyFileW( szPackage, filename, FALSE ) )
|
|
|
|
{
|
2006-11-14 04:43:04 +01:00
|
|
|
DeleteFileW( filename );
|
2006-04-26 07:14:48 +02:00
|
|
|
ERR("failed to copy package %s\n", debugstr_w(szPackage) );
|
2005-09-25 17:14:32 +02:00
|
|
|
return szPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Opening relocated package %s\n", debugstr_w( filename ));
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2006-08-10 00:02:49 +02:00
|
|
|
LPCWSTR msi_download_file( LPCWSTR szUrl, LPWSTR filename )
|
2006-07-26 23:54:15 +02:00
|
|
|
{
|
|
|
|
LPINTERNET_CACHE_ENTRY_INFOW cache_entry;
|
|
|
|
DWORD size = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* call will always fail, becase size is 0,
|
|
|
|
* but will return ERROR_FILE_NOT_FOUND first
|
|
|
|
* if the file doesn't exist
|
|
|
|
*/
|
|
|
|
GetUrlCacheEntryInfoW( szUrl, NULL, &size );
|
|
|
|
if ( GetLastError() != ERROR_FILE_NOT_FOUND )
|
|
|
|
{
|
|
|
|
cache_entry = HeapAlloc( GetProcessHeap(), 0, size );
|
|
|
|
if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) )
|
|
|
|
{
|
|
|
|
HeapFree( GetProcessHeap(), 0, cache_entry );
|
|
|
|
return szUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW( filename, cache_entry->lpszLocalFileName );
|
|
|
|
HeapFree( GetProcessHeap(), 0, cache_entry );
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL );
|
|
|
|
if ( FAILED(hr) )
|
|
|
|
return szUrl;
|
|
|
|
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
|
|
|
|
{
|
2006-11-14 04:42:50 +01:00
|
|
|
static const WCHAR OriginalDatabase[] =
|
|
|
|
{'O','r','i','g','i','n','a','l','D','a','t','a','b','a','s','e',0};
|
|
|
|
static const WCHAR Database[] = {'D','A','T','A','B','A','S','E',0};
|
2005-01-27 12:12:16 +01:00
|
|
|
MSIDATABASE *db = NULL;
|
2005-01-28 13:39:57 +01:00
|
|
|
MSIPACKAGE *package;
|
2005-01-27 12:12:16 +01:00
|
|
|
MSIHANDLE handle;
|
2006-11-08 00:13:47 +01:00
|
|
|
LPWSTR ptr, base_url = NULL;
|
2005-09-25 17:14:32 +02:00
|
|
|
UINT r;
|
2006-11-14 04:42:50 +01:00
|
|
|
WCHAR temppath[MAX_PATH];
|
|
|
|
LPCWSTR file = szPackage;
|
2006-09-26 05:03:31 +02:00
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
|
|
|
|
|
|
|
|
if( szPackage[0] == '#' )
|
|
|
|
{
|
|
|
|
handle = atoiW(&szPackage[1]);
|
|
|
|
db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
|
|
|
|
if( !db )
|
2007-11-12 01:13:08 +01:00
|
|
|
{
|
|
|
|
IWineMsiRemoteDatabase *remote_database;
|
|
|
|
|
|
|
|
remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
|
|
|
|
if ( !remote_database )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
IWineMsiRemoteDatabase_Release( remote_database );
|
|
|
|
WARN("MsiOpenPackage not allowed during a custom action!\n");
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-26 23:54:15 +02:00
|
|
|
if ( UrlIsW( szPackage, URLIS_URL ) )
|
2006-11-08 00:13:47 +01:00
|
|
|
{
|
2006-08-10 00:02:49 +02:00
|
|
|
file = msi_download_file( szPackage, temppath );
|
2006-11-08 00:13:47 +01:00
|
|
|
|
|
|
|
base_url = strdupW( szPackage );
|
|
|
|
if ( !base_url )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ptr = strrchrW( base_url, '/' );
|
|
|
|
if (ptr) *(ptr + 1) = '\0';
|
|
|
|
}
|
2006-07-26 23:54:15 +02:00
|
|
|
else
|
|
|
|
file = copy_package_to_temp( szPackage, temppath );
|
2005-09-25 17:14:32 +02:00
|
|
|
|
|
|
|
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY, &db );
|
2005-01-28 13:39:57 +01:00
|
|
|
if( r != ERROR_SUCCESS )
|
2006-08-24 21:34:51 +02:00
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_FILE_NOT_FOUND)
|
|
|
|
msi_ui_error( 4, MB_OK | MB_ICONWARNING );
|
2006-11-14 04:42:50 +01:00
|
|
|
if (file != szPackage)
|
|
|
|
DeleteFileW( file );
|
2006-08-24 21:34:51 +02:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
return r;
|
2006-08-24 21:34:51 +02:00
|
|
|
}
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
|
|
|
|
2006-11-08 00:13:47 +01:00
|
|
|
package = MSI_CreatePackage( db, base_url );
|
|
|
|
msi_free( base_url );
|
2005-01-28 13:39:57 +01:00
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
if( !package )
|
2006-11-14 04:42:50 +01:00
|
|
|
{
|
|
|
|
if (file != szPackage)
|
|
|
|
DeleteFileW( file );
|
2005-01-28 13:39:57 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2006-11-14 04:42:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if( file != szPackage )
|
|
|
|
track_tempfile( package, file );
|
2005-01-27 12:12:16 +01:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
if( szPackage[0] != '#' )
|
2005-01-27 12:12:16 +01:00
|
|
|
{
|
2005-01-28 13:39:57 +01:00
|
|
|
MSI_SetPropertyW( package, OriginalDatabase, szPackage );
|
|
|
|
MSI_SetPropertyW( package, Database, szPackage );
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
2006-09-26 05:03:31 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
MSI_SetPropertyW( package, OriginalDatabase, db->path );
|
|
|
|
MSI_SetPropertyW( package, Database, db->path );
|
|
|
|
}
|
2005-01-27 12:12:16 +01:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
*pPackage = package;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-01-28 13:39:57 +01:00
|
|
|
return ERROR_SUCCESS;
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
UINT WINAPI MsiOpenPackageExW(LPCWSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
|
|
|
MSIPACKAGE *package = NULL;
|
|
|
|
UINT ret;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("%s %08x %p\n", debugstr_w(szPackage), dwOptions, phPackage );
|
2005-01-27 12:12:16 +01:00
|
|
|
|
2006-04-17 11:17:52 +02:00
|
|
|
if( szPackage == NULL )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
if( dwOptions )
|
2006-10-05 06:41:22 +02:00
|
|
|
FIXME("dwOptions %08x not supported\n", dwOptions);
|
2005-01-27 12:12:16 +01:00
|
|
|
|
2005-09-25 17:14:32 +02:00
|
|
|
ret = MSI_OpenPackageW( szPackage, &package );
|
2004-07-10 00:25:34 +02:00
|
|
|
if( ret == ERROR_SUCCESS )
|
|
|
|
{
|
|
|
|
*phPackage = alloc_msihandle( &package->hdr );
|
2006-08-28 18:44:35 +02:00
|
|
|
if (! *phPackage)
|
|
|
|
ret = ERROR_NOT_ENOUGH_MEMORY;
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
}
|
2005-06-28 21:14:30 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
return ret;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
UINT WINAPI MsiOpenPackageW(LPCWSTR szPackage, MSIHANDLE *phPackage)
|
|
|
|
{
|
|
|
|
return MsiOpenPackageExW( szPackage, 0, phPackage );
|
|
|
|
}
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
UINT WINAPI MsiOpenPackageExA(LPCSTR szPackage, DWORD dwOptions, MSIHANDLE *phPackage)
|
|
|
|
{
|
2005-01-27 12:12:16 +01:00
|
|
|
LPWSTR szwPack = NULL;
|
2005-03-24 20:04:06 +01:00
|
|
|
UINT ret;
|
2005-01-27 12:12:16 +01:00
|
|
|
|
|
|
|
if( szPackage )
|
|
|
|
{
|
2005-03-24 20:04:06 +01:00
|
|
|
szwPack = strdupAtoW( szPackage );
|
|
|
|
if( !szwPack )
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = MsiOpenPackageExW( szwPack, dwOptions, phPackage );
|
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( szwPack );
|
2005-01-27 12:12:16 +01:00
|
|
|
|
|
|
|
return ret;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
UINT WINAPI MsiOpenPackageA(LPCSTR szPackage, MSIHANDLE *phPackage)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2005-01-27 12:12:16 +01:00
|
|
|
return MsiOpenPackageExA( szPackage, 0, phPackage );
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIHANDLE handle = 0;
|
2007-07-03 05:16:04 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2004-07-04 02:25:00 +02:00
|
|
|
TRACE("(%ld)\n",hInstall);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
|
2004-07-10 00:25:34 +02:00
|
|
|
if( package)
|
|
|
|
{
|
|
|
|
handle = alloc_msihandle( &package->db->hdr );
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
}
|
2007-07-03 05:16:04 +02:00
|
|
|
else if ((remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall )))
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
|
|
|
}
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
return handle;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
|
|
|
|
MSIRECORD *record)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2006-01-23 17:30:31 +01:00
|
|
|
static const WCHAR szActionData[] =
|
|
|
|
{'A','c','t','i','o','n','D','a','t','a',0};
|
|
|
|
static const WCHAR szSetProgress[] =
|
|
|
|
{'S','e','t','P','r','o','g','r','e','s','s',0};
|
|
|
|
static const WCHAR szActionText[] =
|
|
|
|
{'A','c','t','i','o','n','T','e','x','t',0};
|
2004-07-04 02:31:17 +02:00
|
|
|
DWORD log_type = 0;
|
2004-07-10 00:25:34 +02:00
|
|
|
LPWSTR message;
|
2004-07-04 02:31:17 +02:00
|
|
|
DWORD sz;
|
2004-07-04 02:32:48 +02:00
|
|
|
DWORD total_size = 0;
|
|
|
|
INT i;
|
2004-07-09 21:26:30 +02:00
|
|
|
INT rc;
|
2004-07-10 00:25:34 +02:00
|
|
|
char *msg;
|
|
|
|
int len;
|
2004-07-09 21:26:30 +02:00
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("%x\n", eMessageType);
|
2004-07-09 21:26:30 +02:00
|
|
|
rc = 0;
|
2004-07-04 02:31:17 +02:00
|
|
|
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR)
|
|
|
|
log_type |= INSTALLLOGMODE_ERROR;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_WARNING)
|
|
|
|
log_type |= INSTALLLOGMODE_WARNING;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_USER)
|
|
|
|
log_type |= INSTALLLOGMODE_USER;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INFO)
|
|
|
|
log_type |= INSTALLLOGMODE_INFO;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_COMMONDATA)
|
|
|
|
log_type |= INSTALLLOGMODE_COMMONDATA;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
|
|
|
|
log_type |= INSTALLLOGMODE_ACTIONSTART;
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONDATA)
|
|
|
|
log_type |= INSTALLLOGMODE_ACTIONDATA;
|
2004-07-04 02:36:58 +02:00
|
|
|
/* just a guess */
|
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_PROGRESS)
|
|
|
|
log_type |= 0x800;
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2006-01-23 17:30:31 +01:00
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ACTIONSTART)
|
|
|
|
{
|
|
|
|
static const WCHAR template_s[]=
|
2006-03-22 13:39:36 +01:00
|
|
|
{'A','c','t','i','o','n',' ','%','s',':',' ','%','s','.',' ',0};
|
2006-01-23 17:30:31 +01:00
|
|
|
static const WCHAR format[] =
|
|
|
|
{'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
|
|
|
|
WCHAR timet[0x100];
|
2006-03-22 13:39:36 +01:00
|
|
|
LPCWSTR action_text, action;
|
|
|
|
LPWSTR deformatted = NULL;
|
2006-01-23 17:30:31 +01:00
|
|
|
|
|
|
|
GetTimeFormatW(LOCALE_USER_DEFAULT, 0, NULL, format, timet, 0x100);
|
|
|
|
|
|
|
|
action = MSI_RecordGetString(record, 1);
|
|
|
|
action_text = MSI_RecordGetString(record, 2);
|
2006-08-01 22:15:34 +02:00
|
|
|
|
|
|
|
if (!action || !action_text)
|
|
|
|
return IDOK;
|
|
|
|
|
2006-03-22 13:39:36 +01:00
|
|
|
deformat_string(package, action_text, &deformatted);
|
|
|
|
|
|
|
|
len = strlenW(timet) + strlenW(action) + strlenW(template_s);
|
|
|
|
if (deformatted)
|
|
|
|
len += strlenW(deformatted);
|
|
|
|
message = msi_alloc(len*sizeof(WCHAR));
|
|
|
|
sprintfW(message, template_s, timet, action);
|
|
|
|
if (deformatted)
|
|
|
|
strcatW(message, deformatted);
|
|
|
|
msi_free(deformatted);
|
2006-01-23 17:30:31 +01:00
|
|
|
}
|
|
|
|
else
|
2004-07-04 02:32:48 +02:00
|
|
|
{
|
2006-01-23 17:30:31 +01:00
|
|
|
INT msg_field=1;
|
|
|
|
message = msi_alloc(1*sizeof (WCHAR));
|
|
|
|
message[0]=0;
|
|
|
|
msg_field = MSI_RecordGetFieldCount(record);
|
|
|
|
for (i = 1; i <= msg_field; i++)
|
2004-07-04 02:32:48 +02:00
|
|
|
{
|
2006-01-23 17:30:31 +01:00
|
|
|
LPWSTR tmp;
|
|
|
|
WCHAR number[3];
|
|
|
|
static const WCHAR format[] = { '%','i',':',' ',0};
|
|
|
|
static const WCHAR space[] = { ' ',0};
|
|
|
|
sz = 0;
|
|
|
|
MSI_RecordGetStringW(record,i,NULL,&sz);
|
|
|
|
sz+=4;
|
|
|
|
total_size+=sz*sizeof(WCHAR);
|
|
|
|
tmp = msi_alloc(sz*sizeof(WCHAR));
|
|
|
|
message = msi_realloc(message,total_size*sizeof (WCHAR));
|
|
|
|
|
|
|
|
MSI_RecordGetStringW(record,i,tmp,&sz);
|
|
|
|
|
|
|
|
if (msg_field > 1)
|
|
|
|
{
|
|
|
|
sprintfW(number,format,i);
|
|
|
|
strcatW(message,number);
|
|
|
|
}
|
|
|
|
strcatW(message,tmp);
|
|
|
|
if (msg_field > 1)
|
|
|
|
strcatW(message,space);
|
|
|
|
|
|
|
|
msi_free(tmp);
|
2004-07-04 02:32:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-05 06:41:22 +02:00
|
|
|
TRACE("(%p %x %x %s)\n", gUIHandlerA, gUIFilter, log_type,
|
2004-07-10 00:25:34 +02:00
|
|
|
debugstr_w(message));
|
|
|
|
|
|
|
|
/* convert it to ASCII */
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, message, -1,
|
|
|
|
NULL, 0, NULL, NULL );
|
2005-09-20 13:57:19 +02:00
|
|
|
msg = msi_alloc( len );
|
2004-07-10 00:25:34 +02:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, message, -1,
|
|
|
|
msg, len, NULL, NULL );
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2005-01-24 13:55:31 +01:00
|
|
|
if (gUIHandlerA && (gUIFilter & log_type))
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2005-01-24 13:55:31 +01:00
|
|
|
rc = gUIHandlerA(gUIContext,eMessageType,msg);
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
2004-07-09 21:26:30 +02:00
|
|
|
|
|
|
|
if ((!rc) && (gszLogFile[0]) && !((eMessageType & 0xff000000) ==
|
|
|
|
INSTALLMESSAGE_PROGRESS))
|
|
|
|
{
|
|
|
|
DWORD write;
|
|
|
|
HANDLE log_file = CreateFileW(gszLogFile,GENERIC_WRITE, 0, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2004-07-09 21:26:30 +02:00
|
|
|
if (log_file != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
SetFilePointer(log_file,0, NULL, FILE_END);
|
2004-07-10 00:25:34 +02:00
|
|
|
WriteFile(log_file,msg,strlen(msg),&write,NULL);
|
2004-07-09 21:26:30 +02:00
|
|
|
WriteFile(log_file,"\n",1,&write,NULL);
|
|
|
|
CloseHandle(log_file);
|
|
|
|
}
|
|
|
|
}
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( msg );
|
2006-01-23 17:30:31 +01:00
|
|
|
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( message);
|
2006-01-23 17:30:31 +01:00
|
|
|
|
|
|
|
switch (eMessageType & 0xff000000)
|
|
|
|
{
|
|
|
|
case INSTALLMESSAGE_ACTIONDATA:
|
|
|
|
/* FIXME: format record here instead of in ui_actiondata to get the
|
|
|
|
* correct action data for external scripts */
|
|
|
|
ControlEvent_FireSubscribedEvent(package, szActionData, record);
|
|
|
|
break;
|
|
|
|
case INSTALLMESSAGE_ACTIONSTART:
|
|
|
|
{
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
LPWSTR deformated;
|
|
|
|
LPCWSTR action_text = MSI_RecordGetString(record, 2);
|
|
|
|
|
|
|
|
deformat_string(package, action_text, &deformated);
|
|
|
|
uirow = MSI_CreateRecord(1);
|
|
|
|
MSI_RecordSetStringW(uirow, 1, deformated);
|
|
|
|
TRACE("INSTALLMESSAGE_ACTIONSTART: %s\n", debugstr_w(deformated));
|
|
|
|
msi_free(deformated);
|
|
|
|
|
|
|
|
ControlEvent_FireSubscribedEvent(package, szActionText, uirow);
|
|
|
|
|
|
|
|
msiobj_release(&uirow->hdr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INSTALLMESSAGE_PROGRESS:
|
|
|
|
ControlEvent_FireSubscribedEvent(package, szSetProgress, record);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
|
|
|
|
MSIHANDLE hRecord)
|
|
|
|
{
|
|
|
|
UINT ret = ERROR_INVALID_HANDLE;
|
|
|
|
MSIPACKAGE *package = NULL;
|
|
|
|
MSIRECORD *record = NULL;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if( !package )
|
2007-07-04 04:13:45 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
hr = IWineMsiRemotePackage_ProcessMessage( remote_package, eMessageType, hRecord );
|
|
|
|
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
|
|
|
|
record = msihandle2msiinfo( hRecord, MSIHANDLETYPE_RECORD );
|
|
|
|
if( !record )
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = MSI_ProcessMessage( package, eMessageType, record );
|
|
|
|
|
|
|
|
out:
|
2005-03-10 12:15:40 +01:00
|
|
|
msiobj_release( &package->hdr );
|
2004-07-10 00:25:34 +02:00
|
|
|
if( record )
|
|
|
|
msiobj_release( &record->hdr );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
/* property code */
|
2006-08-25 10:54:29 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT WINAPI MsiSetPropertyA( MSIHANDLE hInstall, LPCSTR szName, LPCSTR szValue )
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
|
|
|
LPWSTR szwName = NULL, szwValue = NULL;
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT r = ERROR_OUTOFMEMORY;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
szwName = strdupAtoW( szName );
|
|
|
|
if( szName && !szwName )
|
|
|
|
goto end;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
szwValue = strdupAtoW( szValue );
|
|
|
|
if( szValue && !szwValue )
|
|
|
|
goto end;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
r = MsiSetPropertyW( hInstall, szwName, szwValue);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
|
|
|
end:
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( szwName );
|
|
|
|
msi_free( szwValue );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
return r;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT MSI_SetPropertyW( MSIPACKAGE *package, LPCWSTR szName, LPCWSTR szValue)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
MSIQUERY *view;
|
|
|
|
MSIRECORD *row = NULL;
|
|
|
|
UINT rc;
|
|
|
|
DWORD sz = 0;
|
|
|
|
WCHAR Query[1024];
|
|
|
|
|
|
|
|
static const WCHAR Insert[] = {
|
|
|
|
'I','N','S','E','R','T',' ','i','n','t','o',' ',
|
|
|
|
'`','_','P','r','o','p','e','r','t','y','`',' ','(',
|
|
|
|
'`','_','P','r','o','p','e','r','t','y','`',',',
|
|
|
|
'`','V','a','l','u','e','`',')',' ','V','A','L','U','E','S'
|
|
|
|
,' ','(','?',',','?',')',0};
|
|
|
|
static const WCHAR Update[] = {
|
|
|
|
'U','P','D','A','T','E',' ','`','_','P','r','o','p','e','r','t','y','`',
|
|
|
|
' ','s','e','t',' ','`','V','a','l','u','e','`',' ','=',' ','?',' ',
|
|
|
|
'w','h','e','r','e',' ','`','_','P','r','o','p','e','r','t','y','`',
|
|
|
|
' ','=',' ','\'','%','s','\'',0};
|
|
|
|
static const WCHAR Delete[] = {
|
|
|
|
'D','E','L','E','T','E',' ','F','R','O','M',' ',
|
|
|
|
'`','_','P','r','o','p','e','r','t','y','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','_','P','r','o','p','e','r','t','y','`',' ','=',' ','\'','%','s','\'',0};
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
TRACE("%p %s %s\n", package, debugstr_w(szName), debugstr_w(szValue));
|
|
|
|
|
|
|
|
if (!szName)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-11-10 12:39:07 +01:00
|
|
|
/* this one is weird... */
|
2005-10-31 15:07:37 +01:00
|
|
|
if (!szName[0])
|
|
|
|
return szValue ? ERROR_FUNCTION_FAILED : ERROR_SUCCESS;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
rc = MSI_GetPropertyW(package, szName, 0, &sz);
|
|
|
|
if (!szValue || !*szValue)
|
|
|
|
{
|
|
|
|
sprintfW(Query, Delete, szName);
|
|
|
|
}
|
|
|
|
else if (rc == ERROR_MORE_DATA || rc == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
sprintfW(Query, Update, szName);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
row = MSI_CreateRecord(1);
|
|
|
|
MSI_RecordSetStringW(row, 1, szValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpyW(Query, Insert);
|
|
|
|
|
|
|
|
row = MSI_CreateRecord(2);
|
|
|
|
MSI_RecordSetStringW(row, 1, szName);
|
|
|
|
MSI_RecordSetStringW(row, 2, szValue);
|
|
|
|
}
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, Query, &view);
|
|
|
|
if (rc == ERROR_SUCCESS)
|
2004-07-04 02:31:17 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
rc = MSI_ViewExecute(view, row);
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
2005-09-26 12:55:18 +02:00
|
|
|
}
|
2007-05-07 03:43:37 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
msiobj_release(&row->hdr);
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
return rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue)
|
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
|
2005-03-24 20:04:06 +01:00
|
|
|
if( !package )
|
2007-07-03 05:17:04 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR name, value;
|
2007-07-03 05:17:04 +02:00
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
name = SysAllocString( szName );
|
|
|
|
value = SysAllocString( szValue );
|
|
|
|
if (!name || !value)
|
|
|
|
{
|
|
|
|
SysFreeString( name );
|
|
|
|
SysFreeString( value );
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2007-07-03 05:17:04 +02:00
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
hr = IWineMsiRemotePackage_SetProperty( remote_package, name, value );
|
|
|
|
|
|
|
|
SysFreeString( name );
|
|
|
|
SysFreeString( value );
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
2007-07-03 05:17:04 +02:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
ret = MSI_SetPropertyW( package, szName, szValue);
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
static MSIRECORD *MSI_GetPropertyRow( MSIPACKAGE *package, LPCWSTR name )
|
|
|
|
{
|
|
|
|
static const WCHAR query[]= {
|
|
|
|
'S','E','L','E','C','T',' ','`','V','a','l','u','e','`',' ',
|
|
|
|
'F','R','O','M',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
|
|
|
|
' ','W','H','E','R','E',' ' ,'`','_','P','r','o','p','e','r','t','y','`',
|
|
|
|
'=','\'','%','s','\'',0};
|
|
|
|
|
|
|
|
if (!name || !*name)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return MSI_QueryGetRecord( package->db, query, name );
|
|
|
|
}
|
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
/* internal function, not compatible with MsiGetPropertyW */
|
|
|
|
UINT MSI_GetPropertyW( MSIPACKAGE *package, LPCWSTR szName,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR szValueBuf, LPDWORD pchValueBuf )
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
MSIRECORD *row;
|
|
|
|
UINT rc = ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
row = MSI_GetPropertyRow( package, szName );
|
2004-12-22 19:47:54 +01:00
|
|
|
|
|
|
|
if (*pchValueBuf > 0)
|
|
|
|
szValueBuf[0] = 0;
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
if (row)
|
2004-11-28 15:53:46 +01:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
rc = MSI_RecordGetStringW(row, 1, szValueBuf, pchValueBuf);
|
|
|
|
msiobj_release(&row->hdr);
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
if (rc == ERROR_SUCCESS)
|
|
|
|
TRACE("returning %s for property %s\n", debugstr_w(szValueBuf),
|
|
|
|
debugstr_w(szName));
|
|
|
|
else if (rc == ERROR_MORE_DATA)
|
|
|
|
TRACE("need %d sized buffer for %s\n", *pchValueBuf,
|
|
|
|
debugstr_w(szName));
|
2004-11-28 15:53:46 +01:00
|
|
|
else
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
*pchValueBuf = 0;
|
|
|
|
TRACE("property %s not found\n", debugstr_w(szName));
|
2006-08-25 10:54:29 +02:00
|
|
|
}
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
return rc;
|
2004-11-28 15:53:46 +01:00
|
|
|
}
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
LPWSTR msi_dup_property(MSIPACKAGE *package, LPCWSTR prop)
|
2006-08-25 10:58:50 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
DWORD sz = 0;
|
|
|
|
LPWSTR str;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MSI_GetPropertyW(package, prop, NULL, &sz);
|
|
|
|
if (r != ERROR_SUCCESS && r != ERROR_MORE_DATA)
|
|
|
|
return NULL;
|
2006-08-25 10:58:50 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
sz++;
|
|
|
|
str = msi_alloc(sz * sizeof(WCHAR));
|
|
|
|
r = MSI_GetPropertyW(package, prop, str, &sz);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free(str);
|
|
|
|
str = NULL;
|
|
|
|
}
|
2006-08-25 10:58:50 +02:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
return str;
|
2006-08-25 10:58:50 +02:00
|
|
|
}
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
int msi_get_property_int(MSIPACKAGE *package, LPCWSTR prop, int def)
|
2006-08-25 10:58:50 +02:00
|
|
|
{
|
2007-04-21 09:37:51 +02:00
|
|
|
LPWSTR str = msi_dup_property(package, prop);
|
|
|
|
int val = str ? atoiW(str) : def;
|
|
|
|
msi_free(str);
|
|
|
|
return val;
|
2006-08-25 10:58:50 +02:00
|
|
|
}
|
|
|
|
|
2006-08-25 10:54:29 +02:00
|
|
|
static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
|
2007-08-09 10:41:41 +02:00
|
|
|
awstring *szValueBuf, LPDWORD pchValueBuf )
|
2004-11-28 15:53:46 +01:00
|
|
|
{
|
2005-10-31 15:07:37 +01:00
|
|
|
static const WCHAR empty[] = {0};
|
2004-11-28 15:53:46 +01:00
|
|
|
MSIPACKAGE *package;
|
2007-04-21 09:37:51 +02:00
|
|
|
MSIRECORD *row = NULL;
|
2007-07-03 05:16:33 +02:00
|
|
|
UINT r = ERROR_FUNCTION_FAILED;
|
2005-10-31 15:07:37 +01:00
|
|
|
LPCWSTR val = NULL;
|
2004-11-28 15:53:46 +01:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
TRACE("%lu %s %p %p\n", handle, debugstr_w(name),
|
|
|
|
szValueBuf->str.w, pchValueBuf );
|
2004-11-28 15:53:46 +01:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
if (!name)
|
2004-11-28 15:53:46 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
2005-07-11 16:22:13 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
|
2004-11-28 15:53:46 +01:00
|
|
|
if (!package)
|
2007-07-03 05:16:33 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IWineMsiRemotePackage *remote_package;
|
|
|
|
LPWSTR value = NULL;
|
2007-07-06 02:48:08 +02:00
|
|
|
BSTR bname;
|
2007-07-03 05:16:33 +02:00
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle );
|
|
|
|
if (!remote_package)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
bname = SysAllocString( name );
|
|
|
|
if (!bname)
|
|
|
|
{
|
|
|
|
IWineMsiRemotePackage_Release( remote_package );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2007-07-03 05:16:33 +02:00
|
|
|
len = 0;
|
2007-07-06 02:48:08 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, NULL, &len );
|
2007-07-03 05:16:33 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
len++;
|
|
|
|
value = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
r = ERROR_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, (BSTR *)value, &len );
|
2007-07-03 05:16:33 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
r = msi_strcpy_to_awstring( value, szValueBuf, pchValueBuf );
|
2007-07-18 02:50:15 +02:00
|
|
|
|
|
|
|
/* Bug required by Adobe installers */
|
2007-10-16 05:25:16 +02:00
|
|
|
if (!szValueBuf->unicode && !szValueBuf->str.a)
|
2007-07-18 02:50:15 +02:00
|
|
|
*pchValueBuf *= sizeof(WCHAR);
|
2007-07-03 05:16:33 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
IWineMsiRemotePackage_Release(remote_package);
|
2007-07-06 02:48:08 +02:00
|
|
|
SysFreeString(bname);
|
2007-07-03 05:16:33 +02:00
|
|
|
msi_free(value);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
|
|
|
|
return HRESULT_CODE(hr);
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2005-01-27 11:42:45 +01:00
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
row = MSI_GetPropertyRow( package, name );
|
|
|
|
if (row)
|
|
|
|
val = MSI_RecordGetString( row, 1 );
|
2005-08-25 11:51:03 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
if (!val)
|
|
|
|
val = empty;
|
|
|
|
|
|
|
|
r = msi_strcpy_to_awstring( val, szValueBuf, pchValueBuf );
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
if (row)
|
|
|
|
msiobj_release( &row->hdr );
|
2005-10-31 15:07:37 +01:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
|
|
|
|
return r;
|
2004-11-28 15:53:46 +01:00
|
|
|
}
|
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT WINAPI MsiGetPropertyA( MSIHANDLE hInstall, LPCSTR szName,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPSTR szValueBuf, LPDWORD pchValueBuf )
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2005-10-31 15:07:37 +01:00
|
|
|
awstring val;
|
|
|
|
LPWSTR name;
|
|
|
|
UINT r;
|
2005-08-25 11:51:03 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
val.unicode = FALSE;
|
|
|
|
val.str.a = szValueBuf;
|
2004-11-28 15:53:46 +01:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
name = strdupAtoW( szName );
|
|
|
|
if (szName && !name)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2005-07-11 16:22:13 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
r = MSI_GetProperty( hInstall, name, &val, pchValueBuf );
|
|
|
|
msi_free( name );
|
|
|
|
return r;
|
|
|
|
}
|
2006-08-25 10:54:29 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName,
|
2007-08-09 10:41:41 +02:00
|
|
|
LPWSTR szValueBuf, LPDWORD pchValueBuf )
|
2005-10-31 15:07:37 +01:00
|
|
|
{
|
|
|
|
awstring val;
|
2005-01-27 11:42:45 +01:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
val.unicode = TRUE;
|
|
|
|
val.str.w = szValueBuf;
|
2005-08-25 11:51:03 +02:00
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
|
2004-07-10 00:25:34 +02:00
|
|
|
}
|
2007-07-03 05:15:01 +02:00
|
|
|
|
|
|
|
typedef struct _msi_remote_package_impl {
|
|
|
|
const IWineMsiRemotePackageVtbl *lpVtbl;
|
|
|
|
MSIHANDLE package;
|
|
|
|
LONG refs;
|
|
|
|
} msi_remote_package_impl;
|
|
|
|
|
|
|
|
static inline msi_remote_package_impl* mrp_from_IWineMsiRemotePackage( IWineMsiRemotePackage* iface )
|
|
|
|
{
|
|
|
|
return (msi_remote_package_impl*) iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mrp_QueryInterface( IWineMsiRemotePackage *iface,
|
|
|
|
REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
|
|
|
if( IsEqualCLSID( riid, &IID_IUnknown ) ||
|
|
|
|
IsEqualCLSID( riid, &IID_IWineMsiRemotePackage ) )
|
|
|
|
{
|
|
|
|
IUnknown_AddRef( iface );
|
|
|
|
*ppobj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mrp_AddRef( IWineMsiRemotePackage *iface )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
|
|
|
|
return InterlockedIncrement( &This->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI mrp_Release( IWineMsiRemotePackage *iface )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
ULONG r;
|
|
|
|
|
|
|
|
r = InterlockedDecrement( &This->refs );
|
|
|
|
if (r == 0)
|
|
|
|
{
|
|
|
|
MsiCloseHandle( This->package );
|
|
|
|
msi_free( This );
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI mrp_SetMsiHandle( IWineMsiRemotePackage *iface, MSIHANDLE handle )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
This->package = handle;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, MSIHANDLE *handle )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
2007-11-12 01:13:08 +01:00
|
|
|
IWineMsiRemoteDatabase *rdb = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
MSIHANDLE hdb;
|
|
|
|
|
|
|
|
hr = create_msi_remote_database( NULL, (LPVOID *)&rdb );
|
|
|
|
if (FAILED(hr) || !rdb)
|
|
|
|
{
|
|
|
|
ERR("Failed to create remote database\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hdb = MsiGetActiveDatabase(This->package);
|
|
|
|
|
|
|
|
hr = IWineMsiRemoteDatabase_SetMsiHandle( rdb, hdb );
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to set the database handle\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*handle = alloc_msi_remote_handle( (IUnknown *)rdb );
|
2007-07-03 05:15:01 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR *value, DWORD *size )
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MsiGetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value, size);
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value )
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiSetPropertyW(This->package, (LPWSTR)property, (LPWSTR)value);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:13:45 +02:00
|
|
|
HRESULT WINAPI mrp_ProcessMessage( IWineMsiRemotePackage *iface, INSTALLMESSAGE message, MSIHANDLE record )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiProcessMessage(This->package, message, record);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR action )
|
2007-07-04 04:14:37 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiDoActionW(This->package, (LPWSTR)action);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR table, int sequence )
|
2007-07-04 04:15:06 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiSequenceW(This->package, (LPWSTR)table, sequence);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
|
2007-07-04 04:15:36 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiGetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value)
|
2007-07-04 04:16:54 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiSetTargetPathW(This->package, (LPWSTR)folder, (LPWSTR)value);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR folder, BSTR *value, DWORD *size )
|
2007-07-04 04:16:15 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiGetSourcePathW(This->package, (LPWSTR)folder, (LPWSTR)value, size);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:17:26 +02:00
|
|
|
HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL *ret )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
*ret = MsiGetMode(This->package, mode);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
|
2007-07-04 04:18:44 +02:00
|
|
|
INSTALLSTATE *installed, INSTALLSTATE *action )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiGetFeatureStateW(This->package, (LPWSTR)feature, installed, action);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE state )
|
2007-07-04 04:18:04 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiSetFeatureStateW(This->package, (LPWSTR)feature, state);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR component,
|
2007-07-04 04:19:16 +02:00
|
|
|
INSTALLSTATE *installed, INSTALLSTATE *action )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiGetComponentStateW(This->package, (LPWSTR)component, installed, action);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:08 +02:00
|
|
|
HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR component, INSTALLSTATE state )
|
2007-07-04 04:19:44 +02:00
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
2007-07-12 20:35:57 +02:00
|
|
|
UINT r = MsiSetComponentStateW(This->package, (LPWSTR)component, state);
|
2007-07-04 04:19:44 +02:00
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:20:17 +02:00
|
|
|
HRESULT WINAPI mrp_GetLanguage( IWineMsiRemotePackage *iface, LANGID *language )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
*language = MsiGetLanguage(This->package);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-04 04:20:48 +02:00
|
|
|
HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int level )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiSetInstallLevel(This->package, level);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:48:43 +02:00
|
|
|
HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
|
|
|
|
BSTR value, DWORD *size )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiFormatRecordW(This->package, record, (LPWSTR)value, size);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-06 02:53:03 +02:00
|
|
|
HRESULT WINAPI mrp_EvaluateCondition( IWineMsiRemotePackage *iface, BSTR condition )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
|
|
|
|
UINT r = MsiEvaluateConditionW(This->package, (LPWSTR)condition);
|
|
|
|
return HRESULT_FROM_WIN32(r);
|
|
|
|
}
|
|
|
|
|
2007-07-03 05:15:01 +02:00
|
|
|
static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
|
|
|
|
{
|
|
|
|
mrp_QueryInterface,
|
|
|
|
mrp_AddRef,
|
|
|
|
mrp_Release,
|
|
|
|
mrp_SetMsiHandle,
|
|
|
|
mrp_GetActiveDatabase,
|
|
|
|
mrp_GetProperty,
|
|
|
|
mrp_SetProperty,
|
2007-07-04 04:13:45 +02:00
|
|
|
mrp_ProcessMessage,
|
2007-07-04 04:14:37 +02:00
|
|
|
mrp_DoAction,
|
2007-07-04 04:15:06 +02:00
|
|
|
mrp_Sequence,
|
2007-07-04 04:15:36 +02:00
|
|
|
mrp_GetTargetPath,
|
2007-07-04 04:16:54 +02:00
|
|
|
mrp_SetTargetPath,
|
2007-07-04 04:16:15 +02:00
|
|
|
mrp_GetSourcePath,
|
2007-07-04 04:17:26 +02:00
|
|
|
mrp_GetMode,
|
2007-07-04 04:18:44 +02:00
|
|
|
mrp_GetFeatureState,
|
2007-07-04 04:18:04 +02:00
|
|
|
mrp_SetFeatureState,
|
2007-07-04 04:19:16 +02:00
|
|
|
mrp_GetComponentState,
|
2007-07-04 04:19:44 +02:00
|
|
|
mrp_SetComponentState,
|
2007-07-04 04:20:17 +02:00
|
|
|
mrp_GetLanguage,
|
2007-07-04 04:20:48 +02:00
|
|
|
mrp_SetInstallLevel,
|
2007-07-06 02:48:43 +02:00
|
|
|
mrp_FormatRecord,
|
2007-07-06 02:53:03 +02:00
|
|
|
mrp_EvaluateCondition,
|
2007-07-03 05:15:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_msi_remote_package( IUnknown *pOuter, LPVOID *ppObj )
|
|
|
|
{
|
|
|
|
msi_remote_package_impl* This;
|
|
|
|
|
|
|
|
This = msi_alloc( sizeof *This );
|
|
|
|
if (!This)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->lpVtbl = &msi_remote_package_vtbl;
|
|
|
|
This->package = 0;
|
|
|
|
This->refs = 1;
|
|
|
|
|
|
|
|
*ppObj = This;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-07-03 05:20:20 +02:00
|
|
|
|
|
|
|
UINT msi_package_add_info(MSIPACKAGE *package, DWORD context, DWORD options,
|
|
|
|
LPCWSTR property, LPWSTR value)
|
|
|
|
{
|
|
|
|
MSISOURCELISTINFO *info;
|
|
|
|
|
|
|
|
info = msi_alloc(sizeof(MSISOURCELISTINFO));
|
|
|
|
if (!info)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
info->context = context;
|
|
|
|
info->options = options;
|
|
|
|
info->property = property;
|
|
|
|
info->value = strdupW(value);
|
|
|
|
list_add_head(&package->sourcelist_info, &info->entry);
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT msi_package_add_media_disk(MSIPACKAGE *package, DWORD context, DWORD options,
|
|
|
|
DWORD disk_id, LPWSTR volume_label, LPWSTR disk_prompt)
|
|
|
|
{
|
|
|
|
MSIMEDIADISK *disk;
|
|
|
|
|
|
|
|
disk = msi_alloc(sizeof(MSIMEDIADISK));
|
|
|
|
if (!disk)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
disk->context = context;
|
|
|
|
disk->options = options;
|
|
|
|
disk->disk_id = disk_id;
|
|
|
|
disk->volume_label = strdupW(volume_label);
|
|
|
|
disk->disk_prompt = strdupW(disk_prompt);
|
|
|
|
list_add_head(&package->sourcelist_media, &disk->entry);
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|