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"
|
2020-04-18 19:50:28 +02:00
|
|
|
#include "winternl.h"
|
2004-06-30 21:38:36 +02:00
|
|
|
#include "shlwapi.h"
|
2005-01-05 18:11:33 +01:00
|
|
|
#include "wingdi.h"
|
2004-06-30 21:38:36 +02:00
|
|
|
#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 "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
|
|
|
|
2018-04-17 17:35:36 +02:00
|
|
|
#include "wine/heap.h"
|
|
|
|
#include "wine/debug.h"
|
2018-09-08 03:17:22 +02:00
|
|
|
#include "wine/exception.h"
|
2018-04-17 17:35:36 +02:00
|
|
|
|
2005-11-15 13:00:13 +01:00
|
|
|
#include "msipriv.h"
|
2018-04-16 03:52:10 +02:00
|
|
|
#include "winemsi.h"
|
2017-06-27 03:28:00 +02:00
|
|
|
#include "resource.h"
|
2005-11-15 13:00:13 +01:00
|
|
|
|
2004-06-30 21:38:36 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2010-02-03 09:20:56 +01:00
|
|
|
static void free_feature( MSIFEATURE *feature )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &feature->Children )
|
|
|
|
{
|
|
|
|
FeatureList *fl = LIST_ENTRY( item, FeatureList, entry );
|
|
|
|
list_remove( &fl->entry );
|
|
|
|
msi_free( fl );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &feature->Components )
|
|
|
|
{
|
|
|
|
ComponentList *cl = LIST_ENTRY( item, ComponentList, entry );
|
|
|
|
list_remove( &cl->entry );
|
|
|
|
msi_free( cl );
|
|
|
|
}
|
|
|
|
msi_free( feature->Feature );
|
|
|
|
msi_free( feature->Feature_Parent );
|
|
|
|
msi_free( feature->Directory );
|
|
|
|
msi_free( feature->Description );
|
|
|
|
msi_free( feature->Title );
|
|
|
|
msi_free( feature );
|
|
|
|
}
|
|
|
|
|
2011-05-02 16:03:55 +02:00
|
|
|
static void free_folder( MSIFOLDER *folder )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &folder->children )
|
|
|
|
{
|
|
|
|
FolderList *fl = LIST_ENTRY( item, FolderList, entry );
|
|
|
|
list_remove( &fl->entry );
|
|
|
|
msi_free( fl );
|
|
|
|
}
|
|
|
|
msi_free( folder->Parent );
|
|
|
|
msi_free( folder->Directory );
|
|
|
|
msi_free( folder->TargetDefault );
|
|
|
|
msi_free( folder->SourceLongPath );
|
|
|
|
msi_free( folder->SourceShortPath );
|
|
|
|
msi_free( folder->ResolvedTarget );
|
|
|
|
msi_free( folder->ResolvedSource );
|
|
|
|
msi_free( folder );
|
|
|
|
}
|
|
|
|
|
2010-02-03 09:20:56 +01:00
|
|
|
static void free_extension( MSIEXTENSION *ext )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &ext->verbs )
|
|
|
|
{
|
|
|
|
MSIVERB *verb = LIST_ENTRY( item, MSIVERB, entry );
|
|
|
|
|
|
|
|
list_remove( &verb->entry );
|
|
|
|
msi_free( verb->Verb );
|
|
|
|
msi_free( verb->Command );
|
|
|
|
msi_free( verb->Argument );
|
|
|
|
msi_free( verb );
|
|
|
|
}
|
|
|
|
|
|
|
|
msi_free( ext->Extension );
|
|
|
|
msi_free( ext->ProgIDText );
|
|
|
|
msi_free( ext );
|
|
|
|
}
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
static void free_assembly( MSIASSEMBLY *assembly )
|
|
|
|
{
|
2011-01-13 15:23:21 +01:00
|
|
|
msi_free( assembly->feature );
|
|
|
|
msi_free( assembly->manifest );
|
|
|
|
msi_free( assembly->application );
|
2010-11-11 10:45:42 +01:00
|
|
|
msi_free( assembly->display_name );
|
|
|
|
if (assembly->tempdir) RemoveDirectoryW( assembly->tempdir );
|
|
|
|
msi_free( assembly->tempdir );
|
|
|
|
msi_free( assembly );
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:17 +02:00
|
|
|
void msi_free_action_script( MSIPACKAGE *package, UINT script )
|
|
|
|
{
|
|
|
|
UINT i;
|
2017-09-19 19:46:53 +02:00
|
|
|
for (i = 0; i < package->script_actions_count[script]; i++)
|
|
|
|
msi_free( package->script_actions[script][i] );
|
2011-05-06 14:39:17 +02:00
|
|
|
|
2017-09-19 19:46:53 +02:00
|
|
|
msi_free( package->script_actions[script] );
|
|
|
|
package->script_actions[script] = NULL;
|
|
|
|
package->script_actions_count[script] = 0;
|
2011-05-06 14:39:17 +02:00
|
|
|
}
|
|
|
|
|
2010-02-03 09:20:56 +01:00
|
|
|
static void free_package_structures( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
struct list *item, *cursor;
|
2017-09-19 19:46:53 +02:00
|
|
|
int i;
|
2010-02-03 09:20:56 +01:00
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->features )
|
|
|
|
{
|
|
|
|
MSIFEATURE *feature = LIST_ENTRY( item, MSIFEATURE, entry );
|
|
|
|
list_remove( &feature->entry );
|
|
|
|
free_feature( feature );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->folders )
|
|
|
|
{
|
|
|
|
MSIFOLDER *folder = LIST_ENTRY( item, MSIFOLDER, entry );
|
|
|
|
list_remove( &folder->entry );
|
2011-05-02 16:03:55 +02:00
|
|
|
free_folder( folder );
|
2010-02-03 09:20:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->files )
|
|
|
|
{
|
|
|
|
MSIFILE *file = LIST_ENTRY( item, MSIFILE, entry );
|
|
|
|
|
|
|
|
list_remove( &file->entry );
|
|
|
|
msi_free( file->File );
|
|
|
|
msi_free( file->FileName );
|
|
|
|
msi_free( file->ShortName );
|
|
|
|
msi_free( file->LongName );
|
|
|
|
msi_free( file->Version );
|
|
|
|
msi_free( file->Language );
|
2015-04-01 12:33:11 +02:00
|
|
|
if (msi_is_global_assembly( file->Component )) DeleteFileW( file->TargetPath );
|
2010-02-03 09:20:56 +01:00
|
|
|
msi_free( file->TargetPath );
|
|
|
|
msi_free( file );
|
|
|
|
}
|
|
|
|
|
2015-04-01 12:33:11 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->components )
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp = LIST_ENTRY( item, MSICOMPONENT, entry );
|
|
|
|
|
|
|
|
list_remove( &comp->entry );
|
|
|
|
msi_free( comp->Component );
|
|
|
|
msi_free( comp->ComponentId );
|
|
|
|
msi_free( comp->Directory );
|
|
|
|
msi_free( comp->Condition );
|
|
|
|
msi_free( comp->KeyPath );
|
|
|
|
msi_free( comp->FullKeypath );
|
|
|
|
if (comp->assembly) free_assembly( comp->assembly );
|
|
|
|
msi_free( comp );
|
|
|
|
}
|
|
|
|
|
2015-04-01 12:32:18 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->filepatches )
|
|
|
|
{
|
|
|
|
MSIFILEPATCH *patch = LIST_ENTRY( item, MSIFILEPATCH, entry );
|
|
|
|
|
|
|
|
list_remove( &patch->entry );
|
|
|
|
msi_free( patch->path );
|
|
|
|
msi_free( patch );
|
|
|
|
}
|
|
|
|
|
2010-02-03 09:20:56 +01:00
|
|
|
/* clean up extension, progid, class and verb structures */
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->classes )
|
|
|
|
{
|
|
|
|
MSICLASS *cls = LIST_ENTRY( item, MSICLASS, entry );
|
|
|
|
|
|
|
|
list_remove( &cls->entry );
|
|
|
|
msi_free( cls->clsid );
|
|
|
|
msi_free( cls->Context );
|
|
|
|
msi_free( cls->Description );
|
|
|
|
msi_free( cls->FileTypeMask );
|
|
|
|
msi_free( cls->IconPath );
|
|
|
|
msi_free( cls->DefInprocHandler );
|
|
|
|
msi_free( cls->DefInprocHandler32 );
|
|
|
|
msi_free( cls->Argument );
|
|
|
|
msi_free( cls->ProgIDText );
|
|
|
|
msi_free( cls );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->extensions )
|
|
|
|
{
|
|
|
|
MSIEXTENSION *ext = LIST_ENTRY( item, MSIEXTENSION, entry );
|
|
|
|
|
|
|
|
list_remove( &ext->entry );
|
|
|
|
free_extension( ext );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->progids )
|
|
|
|
{
|
|
|
|
MSIPROGID *progid = LIST_ENTRY( item, MSIPROGID, entry );
|
|
|
|
|
|
|
|
list_remove( &progid->entry );
|
|
|
|
msi_free( progid->ProgID );
|
|
|
|
msi_free( progid->Description );
|
|
|
|
msi_free( progid->IconPath );
|
|
|
|
msi_free( progid );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->mimes )
|
|
|
|
{
|
|
|
|
MSIMIME *mt = LIST_ENTRY( item, MSIMIME, entry );
|
|
|
|
|
|
|
|
list_remove( &mt->entry );
|
2010-04-29 09:38:08 +02:00
|
|
|
msi_free( mt->suffix );
|
2010-02-03 09:20:56 +01:00
|
|
|
msi_free( mt->clsid );
|
|
|
|
msi_free( mt->ContentType );
|
|
|
|
msi_free( mt );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->appids )
|
|
|
|
{
|
|
|
|
MSIAPPID *appid = LIST_ENTRY( item, MSIAPPID, entry );
|
|
|
|
|
|
|
|
list_remove( &appid->entry );
|
|
|
|
msi_free( appid->AppID );
|
|
|
|
msi_free( appid->RemoteServerName );
|
|
|
|
msi_free( appid->LocalServer );
|
|
|
|
msi_free( appid->ServiceParameters );
|
|
|
|
msi_free( appid->DllSurrogate );
|
|
|
|
msi_free( appid );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_info )
|
|
|
|
{
|
|
|
|
MSISOURCELISTINFO *info = LIST_ENTRY( item, MSISOURCELISTINFO, entry );
|
|
|
|
|
|
|
|
list_remove( &info->entry );
|
|
|
|
msi_free( info->value );
|
|
|
|
msi_free( info );
|
|
|
|
}
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->sourcelist_media )
|
|
|
|
{
|
|
|
|
MSIMEDIADISK *info = LIST_ENTRY( item, MSIMEDIADISK, entry );
|
|
|
|
|
|
|
|
list_remove( &info->entry );
|
|
|
|
msi_free( info->volume_label );
|
|
|
|
msi_free( info->disk_prompt );
|
|
|
|
msi_free( info );
|
|
|
|
}
|
|
|
|
|
2017-09-19 19:46:53 +02:00
|
|
|
for (i = 0; i < SCRIPT_MAX; i++)
|
|
|
|
msi_free_action_script( package, i );
|
2010-02-03 09:20:56 +01:00
|
|
|
|
2017-09-19 19:46:53 +02:00
|
|
|
for (i = 0; i < package->unique_actions_count; i++)
|
|
|
|
msi_free( package->unique_actions[i] );
|
|
|
|
msi_free( package->unique_actions);
|
2010-02-03 09:20:56 +01:00
|
|
|
|
2010-12-02 11:32:26 +01:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->binaries )
|
|
|
|
{
|
|
|
|
MSIBINARY *binary = LIST_ENTRY( item, MSIBINARY, entry );
|
|
|
|
|
|
|
|
list_remove( &binary->entry );
|
|
|
|
if (!DeleteFileW( binary->tmpfile ))
|
|
|
|
ERR("failed to delete %s (%u)\n", debugstr_w(binary->tmpfile), GetLastError());
|
|
|
|
msi_free( binary->source );
|
|
|
|
msi_free( binary->tmpfile );
|
|
|
|
msi_free( binary );
|
|
|
|
}
|
|
|
|
|
2011-04-14 14:41:19 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->cabinet_streams )
|
|
|
|
{
|
|
|
|
MSICABINETSTREAM *cab = LIST_ENTRY( item, MSICABINETSTREAM, entry );
|
|
|
|
|
|
|
|
list_remove( &cab->entry );
|
|
|
|
IStorage_Release( cab->storage );
|
|
|
|
msi_free( cab->stream );
|
|
|
|
msi_free( cab );
|
|
|
|
}
|
|
|
|
|
2011-08-23 14:42:03 +02:00
|
|
|
LIST_FOR_EACH_SAFE( item, cursor, &package->patches )
|
|
|
|
{
|
|
|
|
MSIPATCHINFO *patch = LIST_ENTRY( item, MSIPATCHINFO, entry );
|
|
|
|
|
|
|
|
list_remove( &patch->entry );
|
|
|
|
if (patch->delete_on_close && !DeleteFileW( patch->localfile ))
|
|
|
|
{
|
|
|
|
ERR("failed to delete %s (%u)\n", debugstr_w(patch->localfile), GetLastError());
|
|
|
|
}
|
|
|
|
msi_free_patchinfo( patch );
|
|
|
|
}
|
|
|
|
|
2010-02-03 09:20:56 +01:00
|
|
|
msi_free( package->PackagePath );
|
|
|
|
msi_free( package->ProductCode );
|
|
|
|
msi_free( package->ActionFormat );
|
|
|
|
msi_free( package->LastAction );
|
2017-07-10 20:46:40 +02:00
|
|
|
msi_free( package->LastActionTemplate );
|
2010-09-17 15:20:26 +02:00
|
|
|
msi_free( package->langids );
|
2010-02-03 09:20:56 +01:00
|
|
|
|
|
|
|
/* cleanup control event subscriptions */
|
2013-07-26 17:19:34 +02:00
|
|
|
msi_event_cleanup_all_subscriptions( package );
|
2010-02-03 09:20:56 +01:00
|
|
|
}
|
|
|
|
|
2005-05-31 11:30:28 +02:00
|
|
|
static void MSI_FreePackage( MSIOBJECTHDR *arg)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2011-03-07 12:40:39 +01:00
|
|
|
MSIPACKAGE *package = (MSIPACKAGE *)arg;
|
2004-07-04 02:32:48 +02:00
|
|
|
|
2012-06-12 09:25:09 +02:00
|
|
|
msi_destroy_assembly_caches( package );
|
|
|
|
|
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 );
|
2010-02-03 09:20:56 +01:00
|
|
|
free_package_structures(package);
|
2010-10-26 12:42:34 +02:00
|
|
|
CloseHandle( package->log_file );
|
2018-07-10 12:08:44 +02:00
|
|
|
if (package->rpc_server_started)
|
|
|
|
RpcServerUnregisterIf(s_IWineMsiRemote_v0_0_s_ifspec, NULL, FALSE);
|
2018-07-10 12:08:46 +02:00
|
|
|
if (rpc_handle)
|
|
|
|
RpcBindingFree(&rpc_handle);
|
2018-07-10 12:08:47 +02:00
|
|
|
if (package->custom_server_32_process)
|
|
|
|
custom_stop_server(package->custom_server_32_process, package->custom_server_32_pipe);
|
|
|
|
if (package->custom_server_64_process)
|
|
|
|
custom_stop_server(package->custom_server_64_process, package->custom_server_64_pipe);
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2011-08-23 14:41:43 +02:00
|
|
|
if (package->delete_on_close) DeleteFileW( package->localfile );
|
|
|
|
msi_free( package->localfile );
|
2017-06-27 03:28:01 +02:00
|
|
|
MSI_ProcessMessage(NULL, INSTALLMESSAGE_TERMINATE, 0);
|
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
|
|
|
{
|
2011-07-27 10:53:26 +02:00
|
|
|
MSIQUERY *view;
|
2007-04-21 09:37:51 +02:00
|
|
|
UINT rc;
|
2007-07-12 20:36:43 +02:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, L"CREATE TABLE `_Property` ( `_Property` CHAR(56) NOT NULL TEMPORARY, "
|
|
|
|
L"`Value` CHAR(98) NOT NULL TEMPORARY PRIMARY KEY `_Property`) HOLD", &view);
|
2007-07-12 20:36:43 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
rc = MSI_ViewExecute(view, 0);
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-11-04 10:57:13 +01:00
|
|
|
UINT msi_clone_properties( MSIDATABASE *db )
|
2007-07-12 20:36:43 +02:00
|
|
|
{
|
2011-07-27 10:53:26 +02:00
|
|
|
MSIQUERY *view_select;
|
|
|
|
UINT rc;
|
2007-04-21 09:37:51 +02:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
rc = MSI_DatabaseOpenViewW( db, L"SELECT * FROM `Property`", &view_select );
|
2007-04-21 09:37:51 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-07-22 11:47:13 +02:00
|
|
|
rc = MSI_ViewExecute( view_select, 0 );
|
2007-04-21 09:37:51 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2010-07-22 11:47:13 +02:00
|
|
|
MSI_ViewClose( view_select );
|
|
|
|
msiobj_release( &view_select->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)
|
|
|
|
{
|
2010-07-22 11:47:13 +02:00
|
|
|
MSIQUERY *view_insert, *view_update;
|
|
|
|
MSIRECORD *rec_select;
|
2007-04-21 09:37:51 +02:00
|
|
|
|
2010-07-22 11:47:13 +02:00
|
|
|
rc = MSI_ViewFetch( view_select, &rec_select );
|
2007-04-21 09:37:51 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
rc = MSI_DatabaseOpenViewW( db, L"INSERT INTO `_Property` (`_Property`,`Value`) VALUES (?,?)", &view_insert );
|
2007-12-12 04:46:32 +01:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
2010-07-22 11:47:13 +02:00
|
|
|
msiobj_release( &rec_select->hdr );
|
2007-04-21 09:37:51 +02:00
|
|
|
continue;
|
2007-12-12 04:46:32 +01:00
|
|
|
}
|
2007-04-21 09:37:51 +02:00
|
|
|
|
2010-07-22 11:47:13 +02:00
|
|
|
rc = MSI_ViewExecute( view_insert, rec_select );
|
|
|
|
MSI_ViewClose( view_insert );
|
|
|
|
msiobj_release( &view_insert->hdr );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
MSIRECORD *rec_update;
|
2007-04-21 09:37:51 +02:00
|
|
|
|
2010-07-22 11:47:13 +02:00
|
|
|
TRACE("insert failed, trying update\n");
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
rc = MSI_DatabaseOpenViewW( db, L"UPDATE `_Property` SET `Value` = ? WHERE `_Property` = ?", &view_update );
|
2010-07-22 11:47:13 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("open view failed %u\n", rc);
|
|
|
|
msiobj_release( &rec_select->hdr );
|
|
|
|
continue;
|
|
|
|
}
|
2007-04-21 09:37:51 +02:00
|
|
|
|
2010-07-22 11:47:13 +02:00
|
|
|
rec_update = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordCopyField( rec_select, 1, rec_update, 2 );
|
|
|
|
MSI_RecordCopyField( rec_select, 2, rec_update, 1 );
|
|
|
|
rc = MSI_ViewExecute( view_update, rec_update );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
WARN("update failed %u\n", rc);
|
|
|
|
|
|
|
|
MSI_ViewClose( view_update );
|
|
|
|
msiobj_release( &view_update->hdr );
|
|
|
|
msiobj_release( &rec_update->hdr );
|
|
|
|
}
|
|
|
|
|
|
|
|
msiobj_release( &rec_select->hdr );
|
|
|
|
}
|
|
|
|
|
|
|
|
MSI_ViewClose( view_select );
|
|
|
|
msiobj_release( &view_select->hdr );
|
2007-04-21 09:37:51 +02:00
|
|
|
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 )
|
|
|
|
{
|
2011-03-30 12:32:39 +02:00
|
|
|
HKEY hkey;
|
2005-11-15 13:00:13 +01:00
|
|
|
UINT r;
|
|
|
|
|
2011-03-30 12:32:39 +02:00
|
|
|
if (!package->ProductCode) return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2011-03-30 12:31:04 +02:00
|
|
|
r = MSIREG_OpenUninstallKey( package->ProductCode, package->platform, &hkey, FALSE );
|
2005-11-15 13:00:13 +01:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey( hkey );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"Installed", L"1", -1 );
|
2005-11-15 13:00:13 +01:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
size = 0;
|
2011-09-08 07:51:16 +02:00
|
|
|
GetUserNameW( NULL, &size );
|
2006-12-01 03:15:40 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
r = msi_set_property( package->db, L"UserSID", sid_str, -1 );
|
2006-12-01 03:15:40 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2018-02-06 13:56:16 +01:00
|
|
|
HKEY netsetup, hkey;
|
2007-06-13 01:33:52 +02:00
|
|
|
LONG res;
|
2018-02-06 13:56:16 +01:00
|
|
|
DWORD size, len, type;
|
|
|
|
WCHAR windir[MAX_PATH], path[MAX_PATH], *filename = NULL;
|
2007-06-13 01:33:52 +02:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\NET Framework Setup\\NDP", 0, KEY_CREATE_SUB_KEY,
|
|
|
|
&netsetup);
|
2007-06-13 01:33:52 +02:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!RegCreateKeyExW(netsetup, L"v4\\Client", 0, NULL, 0, KEY_QUERY_VALUE, NULL, &hkey, NULL))
|
2007-06-13 01:33:52 +02:00
|
|
|
{
|
2018-08-20 21:15:43 +02:00
|
|
|
size = ARRAY_SIZE(path);
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!RegQueryValueExW(hkey, L"InstallPath", NULL, &type, (BYTE *)path, &size))
|
2009-03-18 20:31:14 +01:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
len = lstrlenW(path) + lstrlenW(L"fusion.dll") + 2;
|
2018-02-06 13:56:16 +01:00
|
|
|
if (!(filename = msi_alloc(len * sizeof(WCHAR)))) return NULL;
|
2009-03-18 20:31:14 +01:00
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW(filename, path);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcpyW(filename, L"\\");
|
|
|
|
lstrcatW(filename, L"fusion.dll");
|
2018-02-06 13:56:16 +01:00
|
|
|
if (GetFileAttributesW(filename) != INVALID_FILE_ATTRIBUTES)
|
2009-03-18 20:31:14 +01:00
|
|
|
{
|
2018-02-06 13:56:16 +01:00
|
|
|
TRACE( "found %s\n", debugstr_w(filename) );
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
RegCloseKey(netsetup);
|
|
|
|
return filename;
|
2009-03-18 20:31:14 +01:00
|
|
|
}
|
2018-02-06 13:56:16 +01:00
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2009-03-18 20:31:14 +01:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!RegCreateKeyExW(netsetup, L"v2.0.50727", 0, NULL, 0, KEY_QUERY_VALUE, NULL, &hkey, NULL))
|
2018-02-06 13:56:16 +01:00
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
GetWindowsDirectoryW(windir, MAX_PATH);
|
2020-10-28 11:19:48 +01:00
|
|
|
len = lstrlenW(windir) + lstrlenW(L"Microsoft.NET\\Framework\\") + lstrlenW(L"v2.0.50727") +
|
|
|
|
lstrlenW(L"fusion.dll") + 3;
|
2018-02-06 13:56:16 +01:00
|
|
|
if (!(filename = msi_alloc(len * sizeof(WCHAR)))) return NULL;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW(filename, windir);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(filename, L"\\");
|
|
|
|
lstrcatW(filename, L"Microsoft.NET\\Framework\\");
|
|
|
|
lstrcatW(filename, L"v2.0.50727");
|
|
|
|
lstrcatW(filename, L"\\");
|
|
|
|
lstrcatW(filename, L"fusion.dll");
|
2018-02-06 13:56:16 +01:00
|
|
|
if (GetFileAttributesW(filename) != INVALID_FILE_ATTRIBUTES)
|
|
|
|
{
|
|
|
|
TRACE( "found %s\n", debugstr_w(filename) );
|
|
|
|
RegCloseKey(netsetup);
|
|
|
|
return filename;
|
2009-03-18 20:31:14 +01:00
|
|
|
}
|
2007-06-13 01:33:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(netsetup);
|
2018-02-06 13:56:16 +01:00
|
|
|
return filename;
|
2007-06-13 01:33:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
fusion = get_fusion_filename(package);
|
|
|
|
if (!fusion)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = GetFileVersionInfoSizeW(fusion, &handle);
|
2012-11-07 01:05:50 +01:00
|
|
|
if (!size)
|
|
|
|
goto done;
|
2007-06-13 01:33:52 +02:00
|
|
|
|
|
|
|
version = msi_alloc(size);
|
2012-11-07 01:05:50 +01:00
|
|
|
if (!version)
|
|
|
|
goto done;
|
2007-06-13 01:33:52 +02:00
|
|
|
|
|
|
|
if (!GetFileVersionInfoW(fusion, handle, size, version))
|
|
|
|
goto done;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!VerQueryValueW(version, L"\\VarFileInfo\\Translation", (LPVOID *)&translate, &val_len))
|
2007-06-13 01:33:52 +02:00
|
|
|
goto done;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
swprintf(buf, ARRAY_SIZE(buf), L"\\StringFileInfo\\%04x%04x\\ProductVersion", translate[0].wLanguage,
|
|
|
|
translate[0].wCodePage);
|
2007-06-13 01:33:52 +02:00
|
|
|
|
|
|
|
if (!VerQueryValueW(version, buf, (LPVOID *)&verstr, &val_len))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (!val_len || !verstr)
|
|
|
|
goto done;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"MsiNetAssemblySupport", verstr, -1 );
|
2007-06-13 01:33:52 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
msi_free(fusion);
|
|
|
|
msi_free(version);
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static VOID set_installer_properties(MSIPACKAGE *package)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2004-12-22 18:13:26 +01:00
|
|
|
WCHAR *ptr;
|
2020-04-18 19:50:28 +02:00
|
|
|
RTL_OSVERSIONINFOEXW OSVersion;
|
2005-05-04 12:37:05 +02:00
|
|
|
MEMORYSTATUSEX msex;
|
2018-05-02 07:09:24 +02:00
|
|
|
DWORD verval, len, type;
|
2012-07-09 11:08:37 +02:00
|
|
|
WCHAR pth[MAX_PATH], verstr[11], bufstr[22];
|
2005-01-05 18:11:33 +01:00
|
|
|
HDC dc;
|
2006-10-18 20:26:49 +02:00
|
|
|
HKEY hkey;
|
2008-02-19 00:17:24 +01:00
|
|
|
LPWSTR username, companyname;
|
2007-03-05 13:03:20 +01:00
|
|
|
SYSTEM_INFO sys_info;
|
2008-02-17 21:11:07 +01:00
|
|
|
LANGID langid;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2005-11-15 13:00:13 +01:00
|
|
|
/*
|
|
|
|
* Other things that probably should be set:
|
|
|
|
*
|
2011-11-01 11:07:45 +01:00
|
|
|
* VirtualMemory ShellAdvSupport DefaultUIFont PackagecodeChanging
|
|
|
|
* CaptionHeight BorderTop BorderSide TextHeight RedirectedDllSupport
|
2005-11-15 13:00:13 +01:00
|
|
|
*/
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_COMMON_APPDATA, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"CommonAppDataFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_FAVORITES, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"FavoritesFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"FontsFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_SENDTO, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"SendToFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_STARTMENU, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"StartMenuFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_STARTUP, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"StartupFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_TEMPLATES, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"TemplateFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_DESKTOP, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"DesktopFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-24 17:09:38 +02:00
|
|
|
/* FIXME: set to AllUsers profile path if ALLUSERS is set */
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"ProgramMenuFolder", pth, -1 );
|
2004-08-19 01:41:10 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_ADMINTOOLS, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"AdminToolsFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"AppDataFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_SYSTEM, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"SystemFolder", pth, -1 );
|
|
|
|
msi_set_property( package->db, L"System16Folder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"LocalAppDataFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_MYPICTURES, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"MyPicturesFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"PersonalFolder", pth, -1 );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"WindowsFolder", pth, -1 );
|
|
|
|
|
2010-09-24 17:09:38 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_PRINTHOOD, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"PrintHoodFolder", pth, -1 );
|
2010-09-24 17:09:38 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL, CSIDL_NETHOOD, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"NetHoodFolder", pth, -1 );
|
2010-09-24 17:09:38 +02:00
|
|
|
|
|
|
|
SHGetFolderPathW(NULL, CSIDL_RECENT, NULL, 0, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW(pth, L"\\");
|
|
|
|
msi_set_property( package->db, L"RecentFolder", pth, -1 );
|
2010-09-24 17:09:38 +02:00
|
|
|
|
2005-05-04 12:37:05 +02:00
|
|
|
/* Physical Memory is specified in MB. Using total amount. */
|
|
|
|
msex.dwLength = sizeof(msex);
|
|
|
|
GlobalMemoryStatusEx( &msex );
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", (int)(msex.ullTotalPhys / 1024 / 1024) );
|
|
|
|
msi_set_property( package->db, L"PhysicalMemory", bufstr, len );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2010-09-27 12:18:08 +02:00
|
|
|
SHGetFolderPathW(NULL, CSIDL_WINDOWS, NULL, 0, pth);
|
2019-06-13 08:42:35 +02:00
|
|
|
ptr = wcschr(pth,'\\');
|
2010-09-27 12:18:08 +02:00
|
|
|
if (ptr) *(ptr + 1) = 0;
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"WindowsVolume", pth, -1 );
|
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
len = GetTempPathW(MAX_PATH, pth);
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"TempFolder", pth, len );
|
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 */
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"AdminUser", L"1", -1 );
|
|
|
|
msi_set_property( package->db, L"Privileged", L"1", -1 );
|
2020-12-22 14:36:11 +01:00
|
|
|
msi_set_property( package->db, L"MsiRunningElevated", L"1", -1 );
|
2004-07-04 02:36:58 +02:00
|
|
|
|
|
|
|
/* set the os things */
|
2020-04-18 19:50:28 +02:00
|
|
|
OSVersion.dwOSVersionInfoSize = sizeof(OSVersion);
|
|
|
|
RtlGetVersion(&OSVersion);
|
2010-09-27 12:18:08 +02:00
|
|
|
verval = OSVersion.dwMinorVersion + OSVersion.dwMajorVersion * 100;
|
2020-04-18 19:50:28 +02:00
|
|
|
if (verval > 603)
|
|
|
|
{
|
|
|
|
verval = 603;
|
|
|
|
OSVersion.dwBuildNumber = 9600;
|
|
|
|
}
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( verstr, ARRAY_SIZE(verstr), L"%u", verval );
|
2004-07-04 02:36:58 +02:00
|
|
|
switch (OSVersion.dwPlatformId)
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
|
|
|
msi_set_property( package->db, L"Version9X", verstr, len );
|
2004-07-04 02:36:58 +02:00
|
|
|
break;
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"VersionNT", verstr, len );
|
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%u", OSVersion.wProductType );
|
|
|
|
msi_set_property( package->db, L"MsiNTProductType", bufstr, len );
|
2004-07-04 02:36:58 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%u", OSVersion.dwBuildNumber );
|
|
|
|
msi_set_property( package->db, L"WindowsBuild", bufstr, len );
|
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%u", OSVersion.wServicePackMajor );
|
|
|
|
msi_set_property( package->db, L"ServicePackLevel", bufstr, len );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%u.%u", MSI_MAJORVERSION, MSI_MINORVERSION );
|
|
|
|
msi_set_property( package->db, L"VersionMsi", bufstr, len );
|
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%u", MSI_MAJORVERSION * 100 );
|
|
|
|
msi_set_property( package->db, L"VersionDatabase", bufstr, len );
|
2005-01-05 18:11:33 +01:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion", 0,
|
2018-05-02 07:09:24 +02:00
|
|
|
KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hkey);
|
|
|
|
|
2010-10-01 15:39:11 +02:00
|
|
|
GetNativeSystemInfo( &sys_info );
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", sys_info.wProcessorLevel );
|
|
|
|
msi_set_property( package->db, L"Intel", bufstr, len );
|
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
|
|
|
{
|
2010-10-01 15:39:11 +02:00
|
|
|
GetSystemDirectoryW( pth, MAX_PATH );
|
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"SystemFolder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"ProgramFilesDir", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ProgramFilesFolder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"CommonFilesDir", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"CommonFilesFolder", pth, -1 );
|
2005-12-31 13:14:34 +01:00
|
|
|
}
|
2010-09-02 13:20:54 +02:00
|
|
|
else if (sys_info.u.s.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"MsiAMD64", bufstr, -1 );
|
|
|
|
msi_set_property( package->db, L"Msix64", bufstr, -1 );
|
|
|
|
msi_set_property( package->db, L"VersionNT64", verstr, -1 );
|
2010-09-02 13:21:12 +02:00
|
|
|
|
|
|
|
GetSystemDirectoryW( pth, MAX_PATH );
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"System64Folder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
|
|
|
GetSystemWow64DirectoryW( pth, MAX_PATH );
|
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"SystemFolder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"ProgramFilesDir", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ProgramFiles64Folder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"ProgramFilesDir (x86)", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ProgramFilesFolder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"CommonFilesDir", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"CommonFiles64Folder", pth, -1 );
|
2010-10-01 15:39:11 +02:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
len = MAX_PATH;
|
2020-10-28 11:19:48 +01:00
|
|
|
RegQueryValueExW(hkey, L"CommonFilesDir (x86)", 0, &type, (BYTE *)pth, &len);
|
2010-10-01 15:39:11 +02:00
|
|
|
PathAddBackslashW( pth );
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"CommonFilesFolder", pth, -1 );
|
2010-09-02 13:20:54 +02:00
|
|
|
}
|
2005-12-31 13:14:34 +01:00
|
|
|
|
2018-05-02 07:09:24 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2005-01-05 18:11:33 +01:00
|
|
|
/* Screen properties. */
|
|
|
|
dc = GetDC(0);
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", GetDeviceCaps(dc, HORZRES) );
|
|
|
|
msi_set_property( package->db, L"ScreenX", bufstr, len );
|
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", GetDeviceCaps(dc, VERTRES) );
|
|
|
|
msi_set_property( package->db, L"ScreenY", bufstr, len );
|
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", GetDeviceCaps(dc, BITSPIXEL) );
|
|
|
|
msi_set_property( package->db, L"ColorBits", bufstr, len );
|
2005-01-05 18:11:33 +01:00
|
|
|
ReleaseDC(0, dc);
|
2006-10-18 20:26:49 +02:00
|
|
|
|
|
|
|
/* USERNAME and COMPANYNAME */
|
2020-10-28 11:19:48 +01:00
|
|
|
username = msi_dup_property( package->db, L"USERNAME" );
|
|
|
|
companyname = msi_dup_property( package->db, L"COMPANYNAME" );
|
2006-10-18 20:26:49 +02:00
|
|
|
|
2008-02-19 00:17:24 +01:00
|
|
|
if ((!username || !companyname) &&
|
2020-10-28 11:19:48 +01:00
|
|
|
RegOpenKeyW( HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey ) == ERROR_SUCCESS)
|
2006-10-18 20:26:49 +02:00
|
|
|
{
|
2008-02-19 00:17:24 +01:00
|
|
|
if (!username &&
|
2020-10-28 11:19:48 +01:00
|
|
|
(username = msi_reg_get_val_str( hkey, L"DefName" )))
|
|
|
|
msi_set_property( package->db, L"USERNAME", username, -1 );
|
2008-02-19 00:17:24 +01:00
|
|
|
if (!companyname &&
|
2020-10-28 11:19:48 +01:00
|
|
|
(companyname = msi_reg_get_val_str( hkey, L"DefCompany" )))
|
|
|
|
msi_set_property( package->db, L"COMPANYNAME", companyname, -1 );
|
2008-02-19 00:17:24 +01:00
|
|
|
CloseHandle( hkey );
|
2006-10-18 20:26:49 +02:00
|
|
|
}
|
2008-02-19 00:17:24 +01:00
|
|
|
if ((!username || !companyname) &&
|
2020-10-28 11:19:48 +01:00
|
|
|
RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0,
|
|
|
|
KEY_QUERY_VALUE|KEY_WOW64_64KEY, &hkey ) == ERROR_SUCCESS)
|
2006-10-18 20:26:49 +02:00
|
|
|
{
|
2008-02-19 00:17:24 +01:00
|
|
|
if (!username &&
|
2020-10-28 11:19:48 +01:00
|
|
|
(username = msi_reg_get_val_str( hkey, L"RegisteredOwner" )))
|
|
|
|
msi_set_property( package->db, L"USERNAME", username, -1 );
|
2008-02-19 00:17:24 +01:00
|
|
|
if (!companyname &&
|
2020-10-28 11:19:48 +01:00
|
|
|
(companyname = msi_reg_get_val_str( hkey, L"RegisteredOrganization" )))
|
|
|
|
msi_set_property( package->db, L"COMPANYNAME", companyname, -1 );
|
2008-02-19 00:17:24 +01:00
|
|
|
CloseHandle( hkey );
|
2006-10-18 20:26:49 +02:00
|
|
|
}
|
2008-02-19 00:17:24 +01:00
|
|
|
msi_free( username );
|
|
|
|
msi_free( companyname );
|
2006-10-18 20:26:49 +02:00
|
|
|
|
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-06-13 01:33:52 +02:00
|
|
|
set_msi_assembly_prop( package );
|
|
|
|
|
2008-02-17 21:11:07 +01:00
|
|
|
langid = GetUserDefaultLangID();
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", langid );
|
|
|
|
msi_set_property( package->db, L"UserLanguageID", bufstr, len );
|
2009-03-24 10:26:42 +01:00
|
|
|
|
|
|
|
langid = GetSystemDefaultLangID();
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", langid );
|
|
|
|
msi_set_property( package->db, L"SystemLanguageID", bufstr, len );
|
2009-09-11 15:46:12 +02:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( bufstr, ARRAY_SIZE(bufstr), L"%d", MsiQueryProductStateW(package->ProductCode) );
|
|
|
|
msi_set_property( package->db, L"ProductState", bufstr, len );
|
2009-11-17 15:58:45 +01:00
|
|
|
|
|
|
|
len = 0;
|
2011-06-01 14:48:01 +02:00
|
|
|
if (!GetUserNameW( NULL, &len ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
2009-11-17 15:58:45 +01:00
|
|
|
{
|
|
|
|
WCHAR *username;
|
2010-05-20 12:01:50 +02:00
|
|
|
if ((username = msi_alloc( len * sizeof(WCHAR) )))
|
2009-11-17 15:58:45 +01:00
|
|
|
{
|
|
|
|
if (GetUserNameW( username, &len ))
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"LogonUser", username, len - 1 );
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free( username );
|
2009-11-17 15:58:45 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-01 11:07:45 +01:00
|
|
|
len = 0;
|
2011-11-03 11:40:16 +01:00
|
|
|
if (!GetComputerNameW( NULL, &len ) && GetLastError() == ERROR_BUFFER_OVERFLOW)
|
2011-11-01 11:07:45 +01:00
|
|
|
{
|
|
|
|
WCHAR *computername;
|
|
|
|
if ((computername = msi_alloc( len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
if (GetComputerNameW( computername, &len ))
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ComputerName", computername, len );
|
2011-11-01 11:07:45 +01:00
|
|
|
msi_free( computername );
|
|
|
|
}
|
|
|
|
}
|
2004-07-06 21:00:23 +02:00
|
|
|
}
|
2004-06-30 21:38:36 +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 );
|
2011-03-22 20:45:11 +01:00
|
|
|
list_init( &package->filepatches );
|
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 );
|
2010-04-29 09:39:22 +02:00
|
|
|
list_init( &package->patches );
|
2010-12-02 11:32:26 +01:00
|
|
|
list_init( &package->binaries );
|
2011-04-14 14:41:19 +02:00
|
|
|
list_init( &package->cabinet_streams );
|
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;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
r = read_stream_data(package->db->storage, L"AdminProperties", FALSE, &data, &sz);
|
2007-07-16 23:45:29 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
2008-10-30 10:03:07 +01:00
|
|
|
r = msi_parse_command_line(package, (WCHAR *)data, TRUE);
|
2007-07-16 23:45:29 +02:00
|
|
|
|
|
|
|
msi_free(data);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2010-09-17 15:19:56 +02:00
|
|
|
void msi_adjust_privilege_properties( MSIPACKAGE *package )
|
2009-12-17 12:29:41 +01:00
|
|
|
{
|
|
|
|
/* FIXME: this should depend on the user's privileges */
|
2020-10-28 11:19:48 +01:00
|
|
|
if (msi_get_property_int( package->db, L"ALLUSERS", 0 ) == 2)
|
2009-12-17 12:29:41 +01:00
|
|
|
{
|
|
|
|
TRACE("resetting ALLUSERS property from 2 to 1\n");
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ALLUSERS", L"1", -1 );
|
2009-12-17 12:29:41 +01:00
|
|
|
}
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"AdminUser", L"1", -1 );
|
2020-12-22 14:36:11 +01:00
|
|
|
msi_set_property( package->db, L"Privileged", L"1", -1 );
|
|
|
|
msi_set_property( package->db, L"MsiRunningElevated", L"1", -1 );
|
2009-12-17 12:29:41 +01:00
|
|
|
}
|
|
|
|
|
2018-04-18 10:05:46 +02:00
|
|
|
MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db )
|
2006-11-14 06:47:24 +01:00
|
|
|
{
|
|
|
|
MSIPACKAGE *package;
|
2012-03-22 11:02:54 +01:00
|
|
|
WCHAR uilevel[11];
|
2012-10-29 12:15:21 +01:00
|
|
|
int len;
|
2007-12-17 03:24:52 +01:00
|
|
|
UINT r;
|
2006-11-14 06:47:24 +01:00
|
|
|
|
|
|
|
TRACE("%p\n", db);
|
|
|
|
|
|
|
|
package = msi_alloc_package();
|
|
|
|
if (package)
|
|
|
|
{
|
|
|
|
msiobj_addref( &db->hdr );
|
|
|
|
package->db = db;
|
|
|
|
|
2017-07-10 20:46:40 +02:00
|
|
|
package->LastAction = NULL;
|
|
|
|
package->LastActionTemplate = NULL;
|
2017-07-07 16:03:14 +02:00
|
|
|
package->LastActionResult = MSI_NULL_INTEGER;
|
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-08-07 20:37:49 +02:00
|
|
|
|
2007-07-12 20:36:43 +02:00
|
|
|
create_temp_property_table( package );
|
2014-11-04 10:57:13 +01:00
|
|
|
msi_clone_properties( package->db );
|
2010-09-17 15:19:56 +02:00
|
|
|
msi_adjust_privilege_properties( package );
|
2005-11-15 13:00:13 +01:00
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
package->ProductCode = msi_dup_property( package->db, L"ProductCode" );
|
2010-05-05 14:37:55 +02:00
|
|
|
|
2009-09-11 15:46:12 +02:00
|
|
|
set_installer_properties( package );
|
|
|
|
|
2012-04-05 15:12:15 +02:00
|
|
|
package->ui_level = gUILevel;
|
2020-10-28 11:19:48 +01:00
|
|
|
len = swprintf( uilevel, ARRAY_SIZE(uilevel), L"%u", gUILevel & INSTALLUILEVEL_MASK );
|
|
|
|
msi_set_property( package->db, L"UILevel", uilevel, len );
|
2009-09-11 15:46:12 +02:00
|
|
|
|
2015-03-25 14:32:17 +01:00
|
|
|
r = msi_load_suminfo_properties( package );
|
2007-12-17 03:24:52 +01:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-07-16 23:45:29 +02:00
|
|
|
|
2008-07-22 07:54:27 +02:00
|
|
|
if (package->WordCount & msidbSumInfoSourceTypeAdminImage)
|
2007-07-16 23:45:29 +02:00
|
|
|
msi_load_admin_properties( package );
|
2010-10-26 12:42:34 +02:00
|
|
|
|
|
|
|
package->log_file = INVALID_HANDLE_VALUE;
|
2018-06-06 07:59:22 +02:00
|
|
|
package->script = SCRIPT_NONE;
|
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
|
|
|
}
|
|
|
|
|
2009-12-17 12:28:49 +01:00
|
|
|
UINT 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;
|
|
|
|
|
2011-08-02 22:20:32 +02:00
|
|
|
/* call will always fail, because size is 0,
|
2006-07-26 23:54:15 +02:00
|
|
|
* but will return ERROR_FILE_NOT_FOUND first
|
|
|
|
* if the file doesn't exist
|
|
|
|
*/
|
|
|
|
GetUrlCacheEntryInfoW( szUrl, NULL, &size );
|
|
|
|
if ( GetLastError() != ERROR_FILE_NOT_FOUND )
|
|
|
|
{
|
2010-05-20 12:01:50 +02:00
|
|
|
cache_entry = msi_alloc( size );
|
2006-07-26 23:54:15 +02:00
|
|
|
if ( !GetUrlCacheEntryInfoW( szUrl, cache_entry, &size ) )
|
|
|
|
{
|
2009-12-17 12:28:49 +01:00
|
|
|
UINT error = GetLastError();
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free( cache_entry );
|
2009-12-17 12:28:49 +01:00
|
|
|
return error;
|
2006-07-26 23:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW( filename, cache_entry->lpszLocalFileName );
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free( cache_entry );
|
2009-12-17 12:28:49 +01:00
|
|
|
return ERROR_SUCCESS;
|
2006-07-26 23:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = URLDownloadToCacheFileW( NULL, szUrl, filename, MAX_PATH, 0, NULL );
|
|
|
|
if ( FAILED(hr) )
|
2009-12-17 12:28:49 +01:00
|
|
|
{
|
|
|
|
WARN("failed to download %s to cache file\n", debugstr_w(szUrl));
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2006-07-26 23:54:15 +02:00
|
|
|
|
2009-12-17 12:28:49 +01:00
|
|
|
return ERROR_SUCCESS;
|
2006-07-26 23:54:15 +02:00
|
|
|
}
|
|
|
|
|
2011-08-23 14:41:43 +02:00
|
|
|
UINT msi_create_empty_local_file( LPWSTR path, LPCWSTR suffix )
|
2009-10-20 14:09:53 +02:00
|
|
|
{
|
2010-05-04 09:06:42 +02:00
|
|
|
DWORD time, len, i, offset;
|
2009-10-20 14:09:53 +02:00
|
|
|
HANDLE handle;
|
|
|
|
|
|
|
|
time = GetTickCount();
|
|
|
|
GetWindowsDirectoryW( path, MAX_PATH );
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcatW( path, L"\\Installer\\" );
|
2009-10-20 14:09:53 +02:00
|
|
|
CreateDirectoryW( path, NULL );
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
len = lstrlenW(path);
|
2009-10-20 14:09:53 +02:00
|
|
|
for (i = 0; i < 0x10000; i++)
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
offset = swprintf( path + len, MAX_PATH - len, L"%x", (time + i) & 0xffff );
|
2019-06-13 08:42:35 +02:00
|
|
|
memcpy( path + len + offset, suffix, (lstrlenW( suffix ) + 1) * sizeof(WCHAR) );
|
2009-10-20 14:09:53 +02:00
|
|
|
handle = CreateFileW( path, GENERIC_WRITE, 0, NULL,
|
|
|
|
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0 );
|
|
|
|
if (handle != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
CloseHandle(handle);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (GetLastError() != ERROR_FILE_EXISTS &&
|
|
|
|
GetLastError() != ERROR_SHARING_VIOLATION)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2016-07-26 16:51:56 +02:00
|
|
|
static enum platform parse_platform( const WCHAR *str )
|
2013-01-31 15:11:38 +01:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!str[0] || !wcscmp( str, L"Intel" )) return PLATFORM_INTEL;
|
|
|
|
else if (!wcscmp( str, L"Intel64" )) return PLATFORM_INTEL64;
|
|
|
|
else if (!wcscmp( str, L"x64" ) || !wcscmp( str, L"AMD64" )) return PLATFORM_X64;
|
|
|
|
else if (!wcscmp( str, L"Arm" )) return PLATFORM_ARM;
|
|
|
|
else if (!wcscmp( str, L"Arm64" )) return PLATFORM_ARM64;
|
2020-01-31 11:34:15 +01:00
|
|
|
return PLATFORM_UNRECOGNIZED;
|
2013-01-31 15:11:38 +01:00
|
|
|
}
|
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
static UINT parse_suminfo( MSISUMMARYINFO *si, MSIPACKAGE *package )
|
2010-09-17 15:20:26 +02:00
|
|
|
{
|
2013-01-31 15:11:38 +01:00
|
|
|
WCHAR *template, *p, *q, *platform;
|
2010-09-17 15:20:26 +02:00
|
|
|
DWORD i, count;
|
|
|
|
|
2010-10-06 15:44:08 +02:00
|
|
|
package->version = msi_suminfo_get_int32( si, PID_PAGECOUNT );
|
|
|
|
TRACE("version: %d\n", package->version);
|
|
|
|
|
2010-09-17 15:20:26 +02:00
|
|
|
template = msi_suminfo_dup_string( si, PID_TEMPLATE );
|
|
|
|
if (!template)
|
|
|
|
return ERROR_SUCCESS; /* native accepts missing template property */
|
|
|
|
|
|
|
|
TRACE("template: %s\n", debugstr_w(template));
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
p = wcschr( template, ';' );
|
2010-09-17 15:20:26 +02:00
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
WARN("invalid template string %s\n", debugstr_w(template));
|
|
|
|
msi_free( template );
|
|
|
|
return ERROR_PATCH_PACKAGE_INVALID;
|
|
|
|
}
|
|
|
|
*p = 0;
|
2013-01-31 15:11:38 +01:00
|
|
|
platform = template;
|
2019-06-13 08:42:35 +02:00
|
|
|
if ((q = wcschr( platform, ',' ))) *q = 0;
|
2013-01-31 15:11:38 +01:00
|
|
|
package->platform = parse_platform( platform );
|
2020-01-31 11:34:15 +01:00
|
|
|
while (package->platform == PLATFORM_UNRECOGNIZED && q)
|
2013-01-31 15:11:38 +01:00
|
|
|
{
|
|
|
|
platform = q + 1;
|
2019-06-13 08:42:35 +02:00
|
|
|
if ((q = wcschr( platform, ',' ))) *q = 0;
|
2013-01-31 15:11:38 +01:00
|
|
|
package->platform = parse_platform( platform );
|
|
|
|
}
|
2020-01-31 11:34:15 +01:00
|
|
|
if (package->platform == PLATFORM_UNRECOGNIZED)
|
2010-09-17 15:20:26 +02:00
|
|
|
{
|
|
|
|
WARN("unknown platform %s\n", debugstr_w(template));
|
|
|
|
msi_free( template );
|
2010-10-06 15:44:08 +02:00
|
|
|
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
|
2010-09-17 15:20:26 +02:00
|
|
|
}
|
2010-11-17 10:57:40 +01:00
|
|
|
p++;
|
|
|
|
if (!*p)
|
|
|
|
{
|
|
|
|
msi_free( template );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2010-09-17 15:20:26 +02:00
|
|
|
count = 1;
|
2019-06-13 08:42:35 +02:00
|
|
|
for (q = p; (q = wcschr( q, ',' )); q++) count++;
|
2010-09-17 15:20:26 +02:00
|
|
|
|
|
|
|
package->langids = msi_alloc( count * sizeof(LANGID) );
|
|
|
|
if (!package->langids)
|
|
|
|
{
|
|
|
|
msi_free( template );
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (*p)
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
q = wcschr( p, ',' );
|
2010-09-17 15:20:26 +02:00
|
|
|
if (q) *q = 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
package->langids[i] = wcstol( p, NULL, 10 );
|
2010-09-17 15:20:26 +02:00
|
|
|
if (!q) break;
|
|
|
|
p = q + 1;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
package->num_langids = i + 1;
|
|
|
|
|
|
|
|
msi_free( template );
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-06 15:44:08 +02:00
|
|
|
static UINT validate_package( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
2011-09-15 11:48:15 +02:00
|
|
|
if (package->platform == PLATFORM_INTEL64)
|
|
|
|
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
|
2012-03-18 19:26:50 +01:00
|
|
|
#ifndef __arm__
|
|
|
|
if (package->platform == PLATFORM_ARM)
|
|
|
|
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
|
2018-11-10 15:13:47 +01:00
|
|
|
#endif
|
|
|
|
#ifndef __aarch64__
|
|
|
|
if (package->platform == PLATFORM_ARM64)
|
|
|
|
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
|
2012-03-18 19:26:50 +01:00
|
|
|
#endif
|
2010-10-06 15:44:08 +02:00
|
|
|
if (package->platform == PLATFORM_X64)
|
|
|
|
{
|
|
|
|
if (!is_64bit && !is_wow64)
|
|
|
|
return ERROR_INSTALL_PLATFORM_UNSUPPORTED;
|
|
|
|
if (package->version < 200)
|
|
|
|
return ERROR_INSTALL_PACKAGE_INVALID;
|
|
|
|
}
|
|
|
|
if (!package->num_langids)
|
|
|
|
{
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
for (i = 0; i < package->num_langids; i++)
|
|
|
|
{
|
2010-12-06 13:20:02 +01:00
|
|
|
LANGID langid = package->langids[i];
|
|
|
|
|
|
|
|
if (PRIMARYLANGID( langid ) == LANG_NEUTRAL)
|
|
|
|
{
|
|
|
|
langid = MAKELANGID( PRIMARYLANGID( GetSystemDefaultLangID() ), SUBLANGID( langid ) );
|
|
|
|
}
|
|
|
|
if (SUBLANGID( langid ) == SUBLANG_NEUTRAL)
|
|
|
|
{
|
|
|
|
langid = MAKELANGID( PRIMARYLANGID( langid ), SUBLANGID( GetSystemDefaultLangID() ) );
|
|
|
|
}
|
|
|
|
if (IsValidLocale( langid, LCID_INSTALLED ))
|
2010-10-06 15:44:08 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
return ERROR_INSTALL_LANGUAGE_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:48:50 +02:00
|
|
|
static WCHAR *get_property( MSIDATABASE *db, const WCHAR *prop )
|
2011-08-23 14:41:43 +02:00
|
|
|
{
|
2018-06-21 21:48:50 +02:00
|
|
|
WCHAR query[MAX_PATH];
|
2011-08-23 14:41:43 +02:00
|
|
|
MSIQUERY *view;
|
|
|
|
MSIRECORD *rec;
|
|
|
|
WCHAR *ret = NULL;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
swprintf(query, ARRAY_SIZE(query), L"SELECT `Value` FROM `Property` WHERE `Property`='%s'", prop);
|
2011-08-23 14:41:43 +02:00
|
|
|
if (MSI_DatabaseOpenViewW( db, query, &view ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (MSI_ViewExecute( view, 0 ) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
MSI_ViewClose( view );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (MSI_ViewFetch( view, &rec ) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = strdupW( MSI_RecordGetString( rec, 1 ) );
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
}
|
|
|
|
MSI_ViewClose( view );
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:48:50 +02:00
|
|
|
static WCHAR *get_product_code( MSIDATABASE *db )
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
return get_property( db, L"ProductCode" );
|
2018-06-21 21:48:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *get_product_version( MSIDATABASE *db )
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
return get_property( db, L"ProductVersion" );
|
2018-06-21 21:48:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT get_registered_local_package( const WCHAR *product, WCHAR *localfile )
|
2011-08-23 14:41:43 +02:00
|
|
|
{
|
|
|
|
MSIINSTALLCONTEXT context;
|
2018-06-21 21:48:50 +02:00
|
|
|
WCHAR *filename;
|
|
|
|
HKEY props_key;
|
2011-08-23 14:41:43 +02:00
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = msi_locate_product( product, &context );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MSIREG_OpenInstallProps( product, context, NULL, &props_key, FALSE );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return r;
|
|
|
|
|
2018-06-21 21:48:50 +02:00
|
|
|
filename = msi_reg_get_val_str( props_key, INSTALLPROPERTY_LOCALPACKAGEW );
|
2011-08-23 14:41:43 +02:00
|
|
|
RegCloseKey( props_key );
|
2018-06-21 21:48:50 +02:00
|
|
|
if (!filename)
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW( localfile, filename );
|
2018-06-21 21:48:50 +02:00
|
|
|
msi_free( filename );
|
|
|
|
return ERROR_SUCCESS;
|
2011-08-23 14:41:43 +02:00
|
|
|
}
|
|
|
|
|
2018-06-19 12:02:48 +02:00
|
|
|
WCHAR *msi_get_package_code( MSIDATABASE *db )
|
2011-08-23 14:41:43 +02:00
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
MSISUMMARYINFO *si;
|
2015-03-16 10:55:58 +01:00
|
|
|
UINT r;
|
2011-08-23 14:41:43 +02:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = msi_get_suminfo( db->storage, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2011-08-23 14:41:43 +02:00
|
|
|
{
|
2015-03-25 14:31:47 +01:00
|
|
|
r = msi_get_db_suminfo( db, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("failed to load summary info %u\n", r);
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-08-23 14:41:43 +02:00
|
|
|
}
|
|
|
|
ret = msi_suminfo_dup_string( si, PID_REVNUMBER );
|
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:48:50 +02:00
|
|
|
static UINT get_local_package( MSIDATABASE *db, WCHAR *localfile )
|
2011-08-23 14:41:43 +02:00
|
|
|
{
|
2018-06-21 21:48:50 +02:00
|
|
|
WCHAR *product_code;
|
2011-08-23 14:41:43 +02:00
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (!(product_code = get_product_code( db )))
|
|
|
|
return ERROR_INSTALL_PACKAGE_INVALID;
|
2018-06-21 21:48:50 +02:00
|
|
|
r = get_registered_local_package( product_code, localfile );
|
2011-08-23 14:41:43 +02:00
|
|
|
msi_free( product_code );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2013-01-21 16:24:11 +01:00
|
|
|
UINT msi_set_original_database_property( MSIDATABASE *db, const WCHAR *package )
|
|
|
|
{
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if (UrlIsW( package, URLIS_URL ))
|
2020-10-28 11:19:48 +01:00
|
|
|
r = msi_set_property( db, L"OriginalDatabase", package, -1 );
|
2013-01-21 16:24:11 +01:00
|
|
|
else if (package[0] == '#')
|
2020-10-28 11:19:48 +01:00
|
|
|
r = msi_set_property( db, L"OriginalDatabase", db->path, -1 );
|
2013-01-21 16:24:11 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (!(len = GetFullPathNameW( package, 0, NULL, NULL ))) return GetLastError();
|
|
|
|
if (!(path = msi_alloc( len * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
|
|
|
|
len = GetFullPathNameW( package, len, path, NULL );
|
2020-10-28 11:19:48 +01:00
|
|
|
r = msi_set_property( db, L"OriginalDatabase", path, len );
|
2013-01-21 16:24:11 +01:00
|
|
|
msi_free( path );
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
UINT MSI_OpenPackageW(LPCWSTR szPackage, DWORD dwOptions, MSIPACKAGE **pPackage)
|
2005-01-27 12:12:16 +01:00
|
|
|
{
|
2011-08-23 14:41:43 +02:00
|
|
|
MSIDATABASE *db;
|
2005-01-28 13:39:57 +01:00
|
|
|
MSIPACKAGE *package;
|
2005-01-27 12:12:16 +01:00
|
|
|
MSIHANDLE handle;
|
2017-06-27 03:28:02 +02:00
|
|
|
MSIRECORD *data_row, *info_row;
|
2005-09-25 17:14:32 +02:00
|
|
|
UINT r;
|
2011-08-23 14:41:43 +02:00
|
|
|
WCHAR localfile[MAX_PATH], cachefile[MAX_PATH];
|
2006-11-14 04:42:50 +01:00
|
|
|
LPCWSTR file = szPackage;
|
2010-05-05 14:37:55 +02:00
|
|
|
DWORD index = 0;
|
2010-09-17 15:20:26 +02:00
|
|
|
MSISUMMARYINFO *si;
|
2011-08-23 14:41:43 +02:00
|
|
|
BOOL delete_on_close = FALSE;
|
2018-06-18 20:13:14 +02:00
|
|
|
WCHAR *info_template, *productname, *product_code;
|
|
|
|
MSIINSTALLCONTEXT context;
|
2006-09-26 05:03:31 +02:00
|
|
|
|
2005-01-27 12:12:16 +01:00
|
|
|
TRACE("%s %p\n", debugstr_w(szPackage), pPackage);
|
|
|
|
|
2017-06-27 03:28:01 +02:00
|
|
|
MSI_ProcessMessage(NULL, INSTALLMESSAGE_INITIALIZE, 0);
|
|
|
|
|
2011-09-05 11:49:17 +02:00
|
|
|
localfile[0] = 0;
|
2005-01-27 12:12:16 +01:00
|
|
|
if( szPackage[0] == '#' )
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
handle = wcstol(&szPackage[1], NULL, 10);
|
2019-03-26 04:42:06 +01:00
|
|
|
if (!(db = msihandle2msiinfo(handle, MSIHANDLETYPE_DATABASE)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-21 21:48:50 +02:00
|
|
|
WCHAR *product_version = NULL;
|
|
|
|
|
2006-07-26 23:54:15 +02:00
|
|
|
if ( UrlIsW( szPackage, URLIS_URL ) )
|
2006-11-08 00:13:47 +01:00
|
|
|
{
|
2009-12-17 12:28:49 +01:00
|
|
|
r = msi_download_file( szPackage, cachefile );
|
2011-08-23 14:41:43 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
2009-12-17 12:28:49 +01:00
|
|
|
return r;
|
|
|
|
|
2011-08-23 14:41:43 +02:00
|
|
|
file = cachefile;
|
2006-11-08 00:13:47 +01:00
|
|
|
}
|
2018-06-21 21:48:50 +02:00
|
|
|
r = MSI_OpenDatabaseW( file, MSIDBOPEN_READONLY, &db );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (GetFileAttributesW( file ) == INVALID_FILE_ATTRIBUTES)
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
r = get_local_package( db, localfile );
|
2011-08-23 14:41:43 +02:00
|
|
|
if (r != ERROR_SUCCESS || GetFileAttributesW( localfile ) == INVALID_FILE_ATTRIBUTES)
|
2009-12-17 12:28:49 +01:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
r = msi_create_empty_local_file( localfile, L".msi" );
|
2011-08-23 14:41:43 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
2018-06-21 21:48:50 +02:00
|
|
|
{
|
|
|
|
msiobj_release( &db->hdr );
|
2009-12-17 12:28:49 +01:00
|
|
|
return r;
|
2018-06-21 21:48:50 +02:00
|
|
|
}
|
2009-12-17 12:28:49 +01:00
|
|
|
|
2011-08-23 14:41:43 +02:00
|
|
|
if (!CopyFileW( file, localfile, FALSE ))
|
|
|
|
{
|
|
|
|
r = GetLastError();
|
|
|
|
WARN("unable to copy package %s to %s (%u)\n", debugstr_w(file), debugstr_w(localfile), r);
|
|
|
|
DeleteFileW( localfile );
|
2018-06-21 21:48:50 +02:00
|
|
|
msiobj_release( &db->hdr );
|
2011-08-23 14:41:43 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
delete_on_close = TRUE;
|
2009-12-17 12:28:49 +01:00
|
|
|
}
|
2018-06-21 21:48:56 +02:00
|
|
|
else if (dwOptions & WINE_OPENPACKAGEFLAGS_RECACHE)
|
|
|
|
{
|
|
|
|
if (!CopyFileW( file, localfile, FALSE ))
|
|
|
|
{
|
|
|
|
r = GetLastError();
|
|
|
|
WARN("unable to update cached package (%u)\n", r);
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 21:48:50 +02:00
|
|
|
else
|
|
|
|
product_version = get_product_version( db );
|
|
|
|
msiobj_release( &db->hdr );
|
2011-08-23 14:41:43 +02:00
|
|
|
TRACE("opening package %s\n", debugstr_w( localfile ));
|
|
|
|
r = MSI_OpenDatabaseW( localfile, MSIDBOPEN_TRANSACT, &db );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2005-01-28 13:39:57 +01:00
|
|
|
return r;
|
2018-06-21 21:48:50 +02:00
|
|
|
|
|
|
|
if (product_version)
|
|
|
|
{
|
|
|
|
WCHAR *cache_version = get_product_version( db );
|
|
|
|
if (!product_version != !cache_version ||
|
2019-06-13 08:42:35 +02:00
|
|
|
(product_version && wcscmp(product_version, cache_version)))
|
2018-06-21 21:48:50 +02:00
|
|
|
{
|
|
|
|
msiobj_release( &db->hdr );
|
|
|
|
msi_free(product_version);
|
|
|
|
msi_free(cache_version);
|
|
|
|
return ERROR_PRODUCT_VERSION;
|
|
|
|
}
|
|
|
|
msi_free(product_version);
|
|
|
|
msi_free(cache_version);
|
|
|
|
}
|
2005-01-27 12:12:16 +01:00
|
|
|
}
|
2018-04-18 10:05:46 +02:00
|
|
|
package = MSI_CreatePackage( db );
|
2005-01-28 13:39:57 +01:00
|
|
|
msiobj_release( &db->hdr );
|
2011-08-23 14:41:43 +02:00
|
|
|
if (!package) return ERROR_INSTALL_PACKAGE_INVALID;
|
2011-06-30 12:15:37 +02:00
|
|
|
package->localfile = strdupW( localfile );
|
2011-08-23 14:41:43 +02:00
|
|
|
package->delete_on_close = delete_on_close;
|
2005-01-27 12:12:16 +01:00
|
|
|
|
2015-03-16 10:55:58 +01:00
|
|
|
r = msi_get_suminfo( db->storage, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
2010-09-17 15:20:26 +02:00
|
|
|
{
|
2015-03-25 14:31:47 +01:00
|
|
|
r = msi_get_db_suminfo( db, 0, &si );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("failed to load summary info\n");
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_INSTALL_PACKAGE_INVALID;
|
|
|
|
}
|
2010-09-17 15:20:26 +02:00
|
|
|
}
|
2015-03-16 10:55:58 +01:00
|
|
|
r = parse_suminfo( si, package );
|
2010-09-17 15:20:26 +02:00
|
|
|
msiobj_release( &si->hdr );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("failed to parse summary info %u\n", r);
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
2010-10-06 15:44:08 +02:00
|
|
|
r = validate_package( package );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"DATABASE", db->path, -1 );
|
2014-07-21 14:48:13 +02:00
|
|
|
set_installed_prop( package );
|
2010-05-05 14:37:55 +02:00
|
|
|
msi_set_context( package );
|
|
|
|
|
2018-06-18 20:13:14 +02:00
|
|
|
product_code = get_product_code( db );
|
|
|
|
if (msi_locate_product( product_code, &context ) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
TRACE("product already registered\n");
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_set_property( package->db, L"ProductToBeRegistered", L"1", -1 );
|
2018-06-18 20:13:14 +02:00
|
|
|
}
|
|
|
|
msi_free(product_code);
|
|
|
|
|
2010-05-05 14:37:55 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
WCHAR patch_code[GUID_SIZE];
|
|
|
|
r = MsiEnumPatchesExW( package->ProductCode, NULL, package->Context,
|
|
|
|
MSIPATCHSTATE_APPLIED, index, patch_code, NULL, NULL, NULL, NULL );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
TRACE("found registered patch %s\n", debugstr_w(patch_code));
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2011-06-30 12:15:37 +02:00
|
|
|
r = msi_apply_registered_patch( package, patch_code );
|
2010-05-05 14:37:55 +02:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("registered patch failed to apply %u\n", r);
|
2010-09-17 15:20:26 +02:00
|
|
|
msiobj_release( &package->hdr );
|
2010-05-05 14:37:55 +02:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
2014-11-04 10:57:40 +01:00
|
|
|
if (index) msi_adjust_privilege_properties( package );
|
|
|
|
|
2013-01-21 16:24:11 +01:00
|
|
|
r = msi_set_original_database_property( package->db, szPackage );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return r;
|
|
|
|
}
|
2010-10-26 12:42:34 +02:00
|
|
|
if (gszLogFile)
|
|
|
|
package->log_file = CreateFileW( gszLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
2017-06-27 03:28:02 +02:00
|
|
|
|
2019-03-20 09:43:44 +01:00
|
|
|
if (!msi_init_assembly_caches( package ))
|
|
|
|
{
|
|
|
|
ERR("can't initialize assembly caches\n");
|
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2017-06-27 03:28:02 +02:00
|
|
|
/* FIXME: when should these messages be sent? */
|
|
|
|
data_row = MSI_CreateRecord(3);
|
|
|
|
if (!data_row)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_RecordSetStringW(data_row, 0, NULL);
|
2017-06-27 03:28:02 +02:00
|
|
|
MSI_RecordSetInteger(data_row, 1, 0);
|
|
|
|
MSI_RecordSetInteger(data_row, 2, package->num_langids ? package->langids[0] : 0);
|
|
|
|
MSI_RecordSetInteger(data_row, 3, msi_get_string_table_codepage(package->db->strings));
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_ProcessMessageVerbatim(package, INSTALLMESSAGE_COMMONDATA, data_row);
|
2017-06-27 03:28:02 +02:00
|
|
|
|
|
|
|
info_row = MSI_CreateRecord(0);
|
|
|
|
if (!info_row)
|
|
|
|
{
|
|
|
|
msiobj_release(&data_row->hdr);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2017-07-23 22:50:54 +02:00
|
|
|
info_template = msi_get_error_message(package->db, MSIERR_INFO_LOGGINGSTART);
|
2017-07-23 22:50:55 +02:00
|
|
|
MSI_RecordSetStringW(info_row, 0, info_template);
|
2017-07-23 22:50:54 +02:00
|
|
|
msi_free(info_template);
|
2017-06-27 03:28:02 +02:00
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_INFO|MB_ICONHAND, info_row);
|
|
|
|
|
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_COMMONDATA, data_row);
|
|
|
|
|
|
|
|
productname = msi_dup_property(package->db, INSTALLPROPERTY_PRODUCTNAMEW);
|
|
|
|
MSI_RecordSetInteger(data_row, 1, 1);
|
|
|
|
MSI_RecordSetStringW(data_row, 2, productname);
|
|
|
|
MSI_RecordSetStringW(data_row, 3, NULL);
|
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_COMMONDATA, data_row);
|
|
|
|
|
|
|
|
msi_free(productname);
|
|
|
|
msiobj_release(&info_row->hdr);
|
|
|
|
msiobj_release(&data_row->hdr);
|
|
|
|
|
2010-05-05 14:37:55 +02:00
|
|
|
*pPackage = package;
|
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
|
|
|
|
2007-12-17 03:23:27 +01:00
|
|
|
if( !szPackage || !phPackage )
|
2006-04-17 11:17:52 +02:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2007-12-17 03:23:27 +01:00
|
|
|
if ( !*szPackage )
|
|
|
|
{
|
2007-12-18 09:47:22 +01:00
|
|
|
FIXME("Should create an empty database and package\n");
|
2007-12-17 03:23:27 +01:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-06-21 21:48:56 +02:00
|
|
|
ret = MSI_OpenPackageW( szPackage, 0, &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 );
|
|
|
|
}
|
2017-06-27 03:28:01 +02:00
|
|
|
else
|
|
|
|
MSI_ProcessMessage(NULL, INSTALLMESSAGE_TERMINATE, 0);
|
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;
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2009-01-04 14:14:15 +01:00
|
|
|
TRACE("(%d)\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 );
|
|
|
|
}
|
2018-04-16 03:52:10 +02:00
|
|
|
else if ((remote = msi_get_remote(hInstall)))
|
2007-07-03 05:16:04 +02:00
|
|
|
{
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
2018-09-18 07:59:35 +02:00
|
|
|
handle = remote_GetActiveDatabase(remote);
|
2018-09-08 03:17:22 +02:00
|
|
|
handle = alloc_msi_remote_handle(handle);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
handle = 0;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
2007-07-03 05:16:04 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2017-07-06 06:31:52 +02:00
|
|
|
static INT internal_ui_handler(MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIRECORD *record, LPCWSTR message)
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2017-07-06 06:31:52 +02:00
|
|
|
if (!package || (package->ui_level & INSTALLUILEVEL_MASK) == INSTALLUILEVEL_NONE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* todo: check if message needs additional styles (topmost/foreground/modality?) */
|
|
|
|
|
|
|
|
switch (eMessageType & 0xff000000)
|
|
|
|
{
|
|
|
|
case INSTALLMESSAGE_FATALEXIT:
|
|
|
|
case INSTALLMESSAGE_ERROR:
|
|
|
|
case INSTALLMESSAGE_OUTOFDISKSPACE:
|
|
|
|
if (package->ui_level & INSTALLUILEVEL_PROGRESSONLY) return 0;
|
|
|
|
if (!(eMessageType & MB_ICONMASK))
|
|
|
|
eMessageType |= MB_ICONEXCLAMATION;
|
2020-10-28 11:19:48 +01:00
|
|
|
return MessageBoxW(gUIhwnd, message, L"Windows Installer", eMessageType & 0x00ffffff);
|
2017-07-06 06:31:52 +02:00
|
|
|
case INSTALLMESSAGE_WARNING:
|
|
|
|
if (package->ui_level & INSTALLUILEVEL_PROGRESSONLY) return 0;
|
|
|
|
if (!(eMessageType & MB_ICONMASK))
|
|
|
|
eMessageType |= MB_ICONASTERISK;
|
2020-10-28 11:19:48 +01:00
|
|
|
return MessageBoxW(gUIhwnd, message, L"Windows Installer", eMessageType & 0x00ffffff);
|
2017-07-06 06:31:52 +02:00
|
|
|
case INSTALLMESSAGE_USER:
|
|
|
|
if (package->ui_level & INSTALLUILEVEL_PROGRESSONLY) return 0;
|
|
|
|
if (!(eMessageType & MB_ICONMASK))
|
|
|
|
eMessageType |= MB_USERICON;
|
2020-10-28 11:19:48 +01:00
|
|
|
return MessageBoxW(gUIhwnd, message, L"Windows Installer", eMessageType & 0x00ffffff);
|
2017-07-06 06:31:52 +02:00
|
|
|
case INSTALLMESSAGE_INFO:
|
|
|
|
case INSTALLMESSAGE_INITIALIZE:
|
|
|
|
case INSTALLMESSAGE_TERMINATE:
|
2017-09-14 08:03:53 +02:00
|
|
|
case INSTALLMESSAGE_INSTALLSTART:
|
|
|
|
case INSTALLMESSAGE_INSTALLEND:
|
2017-07-06 06:31:52 +02:00
|
|
|
return 0;
|
2017-07-07 05:42:00 +02:00
|
|
|
case INSTALLMESSAGE_SHOWDIALOG:
|
|
|
|
{
|
|
|
|
LPWSTR dialog = msi_dup_record_field(record, 0);
|
2017-07-23 22:50:56 +02:00
|
|
|
INT rc = ACTION_DialogBox(package, dialog);
|
2017-07-07 05:42:00 +02:00
|
|
|
msi_free(dialog);
|
2017-07-23 22:50:56 +02:00
|
|
|
return rc;
|
2017-07-07 05:42:00 +02:00
|
|
|
}
|
2017-07-06 06:31:52 +02:00
|
|
|
case INSTALLMESSAGE_ACTIONSTART:
|
|
|
|
{
|
|
|
|
LPWSTR deformatted;
|
|
|
|
MSIRECORD *uirow = MSI_CreateRecord(1);
|
|
|
|
if (!uirow) return -1;
|
|
|
|
deformat_string(package, MSI_RecordGetString(record, 2), &deformatted);
|
|
|
|
MSI_RecordSetStringW(uirow, 1, deformatted);
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_event_fire(package, L"ActionText", uirow);
|
2017-07-06 06:31:52 +02:00
|
|
|
|
|
|
|
msi_free(deformatted);
|
|
|
|
msiobj_release(&uirow->hdr);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case INSTALLMESSAGE_ACTIONDATA:
|
|
|
|
{
|
|
|
|
MSIRECORD *uirow = MSI_CreateRecord(1);
|
|
|
|
if (!uirow) return -1;
|
|
|
|
MSI_RecordSetStringW(uirow, 1, message);
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_event_fire(package, L"ActionData", uirow);
|
2017-07-06 06:31:52 +02:00
|
|
|
msiobj_release(&uirow->hdr);
|
|
|
|
|
|
|
|
if (package->action_progress_increment)
|
|
|
|
{
|
|
|
|
uirow = MSI_CreateRecord(2);
|
|
|
|
if (!uirow) return -1;
|
|
|
|
MSI_RecordSetInteger(uirow, 1, 2);
|
|
|
|
MSI_RecordSetInteger(uirow, 2, package->action_progress_increment);
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_event_fire(package, L"SetProgress", uirow);
|
2017-07-06 06:31:52 +02:00
|
|
|
msiobj_release(&uirow->hdr);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case INSTALLMESSAGE_PROGRESS:
|
2020-10-28 11:19:48 +01:00
|
|
|
msi_event_fire(package, L"SetProgress", record);
|
2017-07-06 06:31:52 +02:00
|
|
|
return 1;
|
|
|
|
case INSTALLMESSAGE_COMMONDATA:
|
|
|
|
switch (MSI_RecordGetInteger(record, 1))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
/* do nothing */
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
/* fall through */
|
|
|
|
;
|
|
|
|
}
|
|
|
|
default:
|
2017-07-22 12:21:55 +02:00
|
|
|
FIXME("internal UI not implemented for message 0x%08x (UI level = %x)\n", eMessageType, package->ui_level);
|
2017-07-06 06:31:52 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-23 22:50:53 +02:00
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
const WCHAR *text;
|
|
|
|
}
|
|
|
|
internal_errors[] =
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
{2726, L"DEBUG: Error [1]: Action not found: [2]"},
|
2017-07-23 22:50:53 +02:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static LPCWSTR get_internal_error_message(int error)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (internal_errors[i].id != 0)
|
|
|
|
{
|
|
|
|
if (internal_errors[i].id == error)
|
|
|
|
return internal_errors[i].text;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("missing error message %d\n", error);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returned string must be freed */
|
2017-07-23 22:50:54 +02:00
|
|
|
LPWSTR msi_get_error_message(MSIDATABASE *db, int error)
|
2017-07-23 22:50:53 +02:00
|
|
|
{
|
|
|
|
MSIRECORD *record;
|
|
|
|
LPWSTR ret = NULL;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
if ((record = MSI_QueryGetRecord(db, L"SELECT `Message` FROM `Error` WHERE `Error` = %d", error)))
|
2017-07-23 22:50:53 +02:00
|
|
|
{
|
|
|
|
ret = msi_dup_record_field(record, 1);
|
|
|
|
msiobj_release(&record->hdr);
|
|
|
|
}
|
|
|
|
else if (error < 2000)
|
|
|
|
{
|
|
|
|
int len = LoadStringW(msi_hInstance, IDS_ERROR_BASE + error, (LPWSTR) &ret, 0);
|
|
|
|
if (len)
|
|
|
|
{
|
|
|
|
ret = msi_alloc((len + 1) * sizeof(WCHAR));
|
|
|
|
LoadStringW(msi_hInstance, IDS_ERROR_BASE + error, ret, len + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-10 20:46:40 +02:00
|
|
|
INT MSI_ProcessMessageVerbatim(MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIRECORD *record)
|
2017-07-06 06:31:52 +02:00
|
|
|
{
|
|
|
|
LPWSTR message = {0};
|
2017-09-13 03:51:17 +02:00
|
|
|
DWORD len;
|
|
|
|
DWORD log_type = 1 << (eMessageType >> 24);
|
2017-06-27 03:28:00 +02:00
|
|
|
UINT res;
|
2011-03-31 11:57:47 +02:00
|
|
|
INT rc = 0;
|
2004-07-10 00:25:34 +02:00
|
|
|
char *msg;
|
2004-07-09 21:26:30 +02:00
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("%x\n", eMessageType);
|
2017-07-11 07:18:32 +02:00
|
|
|
if (TRACE_ON(msi)) dump_record(record);
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2017-06-27 03:28:01 +02:00
|
|
|
if (!package || !record)
|
|
|
|
message = NULL;
|
|
|
|
else {
|
|
|
|
res = MSI_FormatRecordW(package, record, message, &len);
|
|
|
|
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
|
|
|
|
return res;
|
|
|
|
len++;
|
|
|
|
message = msi_alloc(len * sizeof(WCHAR));
|
|
|
|
if (!message) return ERROR_OUTOFMEMORY;
|
|
|
|
MSI_FormatRecordW(package, record, message, &len);
|
|
|
|
}
|
2017-06-27 03:28:00 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
/* convert it to ASCII */
|
2009-11-02 10:03:14 +01:00
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, message, -1, NULL, 0, NULL, NULL );
|
2005-09-20 13:57:19 +02:00
|
|
|
msg = msi_alloc( len );
|
2009-11-02 10:03:14 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, message, -1, msg, len, NULL, NULL );
|
2004-07-04 02:31:17 +02:00
|
|
|
|
2017-06-19 04:53:28 +02:00
|
|
|
if (gUIHandlerRecord && (gUIFilterRecord & log_type))
|
2009-11-02 10:04:05 +01:00
|
|
|
{
|
2017-06-19 04:53:30 +02:00
|
|
|
MSIHANDLE rec = alloc_msihandle(&record->hdr);
|
2017-06-19 04:53:28 +02:00
|
|
|
TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, hRecord=%u)\n",
|
|
|
|
gUIHandlerRecord, gUIContextRecord, eMessageType, rec);
|
|
|
|
rc = gUIHandlerRecord( gUIContextRecord, eMessageType, rec );
|
2009-11-02 10:04:05 +01:00
|
|
|
MsiCloseHandle( rec );
|
|
|
|
}
|
2017-06-19 04:53:27 +02:00
|
|
|
if (!rc && gUIHandlerW && (gUIFilter & log_type))
|
|
|
|
{
|
2017-06-19 04:53:28 +02:00
|
|
|
TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
|
|
|
|
gUIHandlerW, gUIContext, eMessageType, debugstr_w(message));
|
2017-06-19 04:53:27 +02:00
|
|
|
rc = gUIHandlerW( gUIContext, eMessageType, message );
|
|
|
|
}
|
|
|
|
else if (!rc && gUIHandlerA && (gUIFilter & log_type))
|
|
|
|
{
|
2017-06-19 04:53:28 +02:00
|
|
|
TRACE("Calling UI handler %p(pvContext=%p, iMessageType=%08x, szMessage=%s)\n",
|
|
|
|
gUIHandlerA, gUIContext, eMessageType, debugstr_a(msg));
|
2017-06-19 04:53:27 +02:00
|
|
|
rc = gUIHandlerA( gUIContext, eMessageType, msg );
|
|
|
|
}
|
2004-07-09 21:26:30 +02:00
|
|
|
|
2017-07-06 06:31:52 +02:00
|
|
|
if (!rc)
|
|
|
|
rc = internal_ui_handler(package, eMessageType, record, message);
|
|
|
|
|
2017-06-27 03:28:01 +02:00
|
|
|
if (!rc && package && package->log_file != INVALID_HANDLE_VALUE &&
|
2010-10-26 12:42:34 +02:00
|
|
|
(eMessageType & 0xff000000) != INSTALLMESSAGE_PROGRESS)
|
2004-07-09 21:26:30 +02:00
|
|
|
{
|
2010-10-26 12:42:34 +02:00
|
|
|
DWORD written;
|
|
|
|
WriteFile( package->log_file, msg, len - 1, &written, NULL );
|
|
|
|
WriteFile( package->log_file, "\n", 1, &written, NULL );
|
2004-07-09 21:26:30 +02:00
|
|
|
}
|
2005-09-20 13:57:19 +02:00
|
|
|
msi_free( msg );
|
2009-11-02 10:03:14 +01:00
|
|
|
msi_free( message );
|
2006-01-23 17:30:31 +01:00
|
|
|
|
2017-06-19 04:53:27 +02:00
|
|
|
return rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
}
|
|
|
|
|
2017-07-10 20:46:40 +02:00
|
|
|
INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType, MSIRECORD *record )
|
|
|
|
{
|
|
|
|
switch (eMessageType & 0xff000000)
|
|
|
|
{
|
|
|
|
case INSTALLMESSAGE_FATALEXIT:
|
|
|
|
case INSTALLMESSAGE_ERROR:
|
|
|
|
case INSTALLMESSAGE_WARNING:
|
|
|
|
case INSTALLMESSAGE_USER:
|
|
|
|
case INSTALLMESSAGE_INFO:
|
|
|
|
case INSTALLMESSAGE_OUTOFDISKSPACE:
|
|
|
|
if (MSI_RecordGetInteger(record, 1) != MSI_NULL_INTEGER)
|
|
|
|
{
|
2017-07-23 22:50:53 +02:00
|
|
|
/* error message */
|
|
|
|
|
|
|
|
LPWSTR template;
|
|
|
|
LPWSTR template_rec = NULL, template_prefix = NULL;
|
|
|
|
int error = MSI_RecordGetInteger(record, 1);
|
2017-07-10 20:46:40 +02:00
|
|
|
|
|
|
|
if (MSI_RecordIsNull(record, 0))
|
|
|
|
{
|
2017-07-23 22:50:53 +02:00
|
|
|
if (error >= 32)
|
|
|
|
{
|
|
|
|
template_rec = msi_get_error_message(package->db, error);
|
|
|
|
|
|
|
|
if (!template_rec && error >= 2000)
|
|
|
|
{
|
|
|
|
/* internal error, not localized */
|
|
|
|
if ((template_rec = (LPWSTR) get_internal_error_message(error)))
|
|
|
|
{
|
|
|
|
MSI_RecordSetStringW(record, 0, template_rec);
|
|
|
|
MSI_ProcessMessageVerbatim(package, INSTALLMESSAGE_INFO, record);
|
|
|
|
}
|
|
|
|
template_rec = msi_get_error_message(package->db, MSIERR_INSTALLERROR);
|
|
|
|
MSI_RecordSetStringW(record, 0, template_rec);
|
|
|
|
MSI_ProcessMessageVerbatim(package, eMessageType, record);
|
|
|
|
msi_free(template_rec);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2017-07-10 20:46:40 +02:00
|
|
|
}
|
2017-07-23 22:50:53 +02:00
|
|
|
else
|
|
|
|
template_rec = msi_dup_record_field(record, 0);
|
2017-07-10 20:46:40 +02:00
|
|
|
|
2017-07-23 22:50:53 +02:00
|
|
|
template_prefix = msi_get_error_message(package->db, eMessageType >> 24);
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!template_prefix) template_prefix = strdupW(L"");
|
2017-07-10 20:46:40 +02:00
|
|
|
|
2017-07-23 22:50:53 +02:00
|
|
|
if (!template_rec)
|
2017-07-10 20:46:40 +02:00
|
|
|
{
|
2017-07-23 22:50:53 +02:00
|
|
|
/* always returns 0 */
|
|
|
|
MSI_RecordSetStringW(record, 0, template_prefix);
|
|
|
|
MSI_ProcessMessageVerbatim(package, eMessageType, record);
|
|
|
|
msi_free(template_prefix);
|
|
|
|
return 0;
|
2017-07-10 20:46:40 +02:00
|
|
|
}
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
template = msi_alloc((lstrlenW(template_rec) + lstrlenW(template_prefix) + 1) * sizeof(WCHAR));
|
2017-07-10 20:46:40 +02:00
|
|
|
if (!template) return ERROR_OUTOFMEMORY;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW(template, template_prefix);
|
|
|
|
lstrcatW(template, template_rec);
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_RecordSetStringW(record, 0, template);
|
|
|
|
|
2017-07-23 22:50:53 +02:00
|
|
|
msi_free(template_prefix);
|
2017-07-10 20:46:40 +02:00
|
|
|
msi_free(template_rec);
|
|
|
|
msi_free(template);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INSTALLMESSAGE_ACTIONSTART:
|
|
|
|
{
|
2017-07-23 22:50:55 +02:00
|
|
|
WCHAR *template = msi_get_error_message(package->db, MSIERR_ACTIONSTART);
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_RecordSetStringW(record, 0, template);
|
2017-07-23 22:50:54 +02:00
|
|
|
msi_free(template);
|
2017-07-10 20:46:40 +02:00
|
|
|
|
|
|
|
msi_free(package->LastAction);
|
|
|
|
msi_free(package->LastActionTemplate);
|
|
|
|
package->LastAction = msi_dup_record_field(record, 1);
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!package->LastAction) package->LastAction = strdupW(L"");
|
2017-07-10 20:46:40 +02:00
|
|
|
package->LastActionTemplate = msi_dup_record_field(record, 3);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INSTALLMESSAGE_ACTIONDATA:
|
|
|
|
if (package->LastAction && package->LastActionTemplate)
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
size_t len = lstrlenW(package->LastAction) + lstrlenW(package->LastActionTemplate) + 7;
|
|
|
|
WCHAR *template = msi_alloc(len * sizeof(WCHAR));
|
2017-07-10 20:46:40 +02:00
|
|
|
if (!template) return ERROR_OUTOFMEMORY;
|
2020-10-28 11:19:48 +01:00
|
|
|
swprintf(template, len, L"{{%s: }}%s", package->LastAction, package->LastActionTemplate);
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_RecordSetStringW(record, 0, template);
|
|
|
|
msi_free(template);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INSTALLMESSAGE_COMMONDATA:
|
|
|
|
{
|
2017-07-23 22:50:54 +02:00
|
|
|
WCHAR *template = msi_get_error_message(package->db, MSIERR_COMMONDATA);
|
2017-07-10 20:46:40 +02:00
|
|
|
MSI_RecordSetStringW(record, 0, template);
|
2017-07-23 22:50:54 +02:00
|
|
|
msi_free(template);
|
2017-07-10 20:46:40 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MSI_ProcessMessageVerbatim(package, eMessageType, record);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2017-06-27 03:28:01 +02:00
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_INITIALIZE ||
|
|
|
|
(eMessageType & 0xff000000) == INSTALLMESSAGE_TERMINATE)
|
|
|
|
return -1;
|
|
|
|
|
2017-07-06 06:31:52 +02:00
|
|
|
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_COMMONDATA &&
|
2017-06-27 03:28:02 +02:00
|
|
|
MsiRecordGetInteger(hRecord, 1) != 2)
|
|
|
|
return -1;
|
|
|
|
|
2018-04-18 02:11:29 +02:00
|
|
|
record = msihandle2msiinfo(hRecord, MSIHANDLETYPE_RECORD);
|
|
|
|
if (!record)
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
|
|
|
|
if( !package )
|
2007-07-04 04:13:45 +02:00
|
|
|
{
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-07-04 04:13:45 +02:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hInstall)))
|
2007-07-04 04:13:45 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_ProcessMessage(remote, eMessageType, (struct wire_record *)&record->count);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
2007-07-04 04:13:45 +02:00
|
|
|
|
2018-04-18 02:11:29 +02:00
|
|
|
msiobj_release(&record->hdr);
|
|
|
|
return ret;
|
2007-07-04 04:13:45 +02:00
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
|
|
|
|
ret = MSI_ProcessMessage( package, eMessageType, record );
|
|
|
|
|
2018-10-01 17:01:48 +02:00
|
|
|
msiobj_release( &record->hdr );
|
2005-03-10 12:15:40 +01:00
|
|
|
msiobj_release( &package->hdr );
|
2004-07-10 00:25:34 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-10-10 16:14:28 +02:00
|
|
|
void msi_reset_source_folders( MSIPACKAGE *package )
|
2010-02-22 12:24:45 +01:00
|
|
|
{
|
|
|
|
MSIFOLDER *folder;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( folder, &package->folders, MSIFOLDER, entry )
|
|
|
|
{
|
2018-10-10 16:14:28 +02:00
|
|
|
msi_free( folder->ResolvedSource );
|
|
|
|
folder->ResolvedSource = NULL;
|
2010-02-22 12:24:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
UINT msi_set_property( MSIDATABASE *db, const WCHAR *name, const WCHAR *value, int len )
|
2004-06-30 21:38:36 +02:00
|
|
|
{
|
2011-07-27 10:53:26 +02:00
|
|
|
MSIQUERY *view;
|
|
|
|
MSIRECORD *row = NULL;
|
|
|
|
DWORD sz = 0;
|
|
|
|
WCHAR query[1024];
|
|
|
|
UINT rc;
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
TRACE("%p %s %s %d\n", db, debugstr_w(name), debugstr_wn(value, len), len);
|
2005-10-31 15:07:37 +01:00
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
if (!name)
|
2005-10-31 15:07:37 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
2005-11-10 12:39:07 +01:00
|
|
|
/* this one is weird... */
|
2012-10-29 12:15:21 +01:00
|
|
|
if (!name[0])
|
|
|
|
return value ? ERROR_FUNCTION_FAILED : ERROR_SUCCESS;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
if (value && len < 0) len = lstrlenW( value );
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
rc = msi_get_property( db, name, 0, &sz );
|
|
|
|
if (!value || (!*value && !len))
|
2007-04-21 09:37:51 +02:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
swprintf( query, ARRAY_SIZE(query), L"DELETE FROM `_Property` WHERE `_Property` = '%s'", name );
|
2007-04-21 09:37:51 +02:00
|
|
|
}
|
|
|
|
else if (rc == ERROR_MORE_DATA || rc == ERROR_SUCCESS)
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
swprintf( query, ARRAY_SIZE(query), L"UPDATE `_Property` SET `Value` = ? WHERE `_Property` = '%s'", name );
|
2007-04-21 09:37:51 +02:00
|
|
|
row = MSI_CreateRecord(1);
|
2012-10-29 12:15:21 +01:00
|
|
|
msi_record_set_string( row, 1, value, len );
|
2007-04-21 09:37:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
lstrcpyW( query, L"INSERT INTO `_Property` (`_Property`,`Value`) VALUES (?,?)" );
|
2007-04-21 09:37:51 +02:00
|
|
|
row = MSI_CreateRecord(2);
|
2012-10-29 12:15:21 +01:00
|
|
|
msi_record_set_string( row, 1, name, -1 );
|
|
|
|
msi_record_set_string( row, 2, value, len );
|
2007-04-21 09:37:51 +02:00
|
|
|
}
|
2004-06-30 21:38:36 +02:00
|
|
|
|
2011-07-27 10:53:26 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(db, query, &view);
|
2007-04-21 09:37:51 +02:00
|
|
|
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
|
|
|
}
|
2011-07-27 10:53:26 +02:00
|
|
|
if (row) msiobj_release(&row->hdr);
|
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
|
|
|
{
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2007-07-03 05:17:04 +02:00
|
|
|
|
2018-04-16 03:52:10 +02:00
|
|
|
if (!(remote = msi_get_remote(hInstall)))
|
2007-07-03 05:17:04 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
ret = remote_SetProperty(remote, szName, szValue);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
ret = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
|
|
|
return ret;
|
2007-07-03 05:17:04 +02:00
|
|
|
}
|
|
|
|
|
2012-10-29 12:15:21 +01:00
|
|
|
ret = msi_set_property( package->db, szName, szValue, -1 );
|
2020-10-28 11:19:48 +01:00
|
|
|
if (ret == ERROR_SUCCESS && !wcscmp( szName, L"SourceDir" ))
|
2018-10-10 16:14:28 +02:00
|
|
|
msi_reset_source_folders( package );
|
2010-04-21 11:38:17 +02:00
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
msiobj_release( &package->hdr );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-21 11:38:40 +02:00
|
|
|
static MSIRECORD *msi_get_property_row( MSIDATABASE *db, LPCWSTR name )
|
2007-04-21 09:37:51 +02:00
|
|
|
{
|
2011-07-27 10:53:26 +02:00
|
|
|
MSIRECORD *rec, *row = NULL;
|
|
|
|
MSIQUERY *view;
|
|
|
|
UINT r;
|
2017-07-23 22:50:55 +02:00
|
|
|
WCHAR *buffer;
|
|
|
|
int length;
|
|
|
|
|
2007-04-21 09:37:51 +02:00
|
|
|
if (!name || !*name)
|
|
|
|
return NULL;
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
if (!wcscmp(name, L"Date"))
|
2017-07-23 22:50:55 +02:00
|
|
|
{
|
|
|
|
length = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, NULL, 0);
|
|
|
|
if (!length)
|
|
|
|
return NULL;
|
|
|
|
buffer = msi_alloc(length * sizeof(WCHAR));
|
2017-09-19 19:37:48 +02:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, buffer, length);
|
2017-07-23 22:50:55 +02:00
|
|
|
|
|
|
|
row = MSI_CreateRecord(1);
|
|
|
|
if (!row)
|
2017-10-21 11:48:30 +02:00
|
|
|
{
|
|
|
|
msi_free(buffer);
|
2017-07-23 22:50:55 +02:00
|
|
|
return NULL;
|
2017-10-21 11:48:30 +02:00
|
|
|
}
|
2017-07-23 22:50:55 +02:00
|
|
|
MSI_RecordSetStringW(row, 1, buffer);
|
|
|
|
msi_free(buffer);
|
|
|
|
return row;
|
|
|
|
}
|
2020-10-28 11:19:48 +01:00
|
|
|
else if (!wcscmp(name, L"Time"))
|
2017-07-23 22:50:55 +02:00
|
|
|
{
|
|
|
|
length = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER, NULL, NULL, NULL, 0);
|
|
|
|
if (!length)
|
|
|
|
return NULL;
|
|
|
|
buffer = msi_alloc(length * sizeof(WCHAR));
|
2017-09-19 19:37:48 +02:00
|
|
|
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER, NULL, NULL, buffer, length);
|
2017-07-23 22:50:55 +02:00
|
|
|
|
|
|
|
row = MSI_CreateRecord(1);
|
|
|
|
if (!row)
|
2017-10-21 11:48:30 +02:00
|
|
|
{
|
|
|
|
msi_free(buffer);
|
2017-07-23 22:50:55 +02:00
|
|
|
return NULL;
|
2017-10-21 11:48:30 +02:00
|
|
|
}
|
2017-07-23 22:50:55 +02:00
|
|
|
MSI_RecordSetStringW(row, 1, buffer);
|
|
|
|
msi_free(buffer);
|
|
|
|
return row;
|
|
|
|
}
|
|
|
|
|
2009-03-02 11:33:56 +01:00
|
|
|
rec = MSI_CreateRecord(1);
|
|
|
|
if (!rec)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
MSI_RecordSetStringW(rec, 1, name);
|
|
|
|
|
2020-10-28 11:19:48 +01:00
|
|
|
r = MSI_DatabaseOpenViewW(db, L"SELECT `Value` FROM `_Property` WHERE `_Property`=?", &view);
|
2009-03-02 11:33:56 +01:00
|
|
|
if (r == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
MSI_ViewExecute(view, rec);
|
|
|
|
MSI_ViewFetch(view, &row);
|
|
|
|
MSI_ViewClose(view);
|
|
|
|
msiobj_release(&view->hdr);
|
|
|
|
}
|
|
|
|
msiobj_release(&rec->hdr);
|
|
|
|
return row;
|
2007-04-21 09:37:51 +02:00
|
|
|
}
|
|
|
|
|
2005-10-31 15:07:37 +01:00
|
|
|
/* internal function, not compatible with MsiGetPropertyW */
|
2010-04-21 11:38:40 +02:00
|
|
|
UINT msi_get_property( MSIDATABASE *db, 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;
|
|
|
|
|
2015-10-06 12:10:41 +02:00
|
|
|
TRACE("%p %s %p %p\n", db, debugstr_w(szName), szValueBuf, pchValueBuf);
|
|
|
|
|
2010-04-21 11:38:40 +02:00
|
|
|
row = msi_get_property_row( db, 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)
|
2012-10-29 12:14:19 +01:00
|
|
|
TRACE("returning %s for property %s\n", debugstr_wn(szValueBuf, *pchValueBuf),
|
2007-04-21 09:37:51 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
LPWSTR msi_dup_property(MSIDATABASE *db, 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;
|
|
|
|
|
2010-04-21 11:38:40 +02:00
|
|
|
r = msi_get_property(db, prop, NULL, &sz);
|
2007-04-21 09:37:51 +02:00
|
|
|
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));
|
2010-04-21 11:38:40 +02:00
|
|
|
r = msi_get_property(db, prop, str, &sz);
|
2007-04-21 09:37:51 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-04-21 11:37:54 +02:00
|
|
|
int msi_get_property_int( MSIDATABASE *db, LPCWSTR prop, int def )
|
2006-08-25 10:58:50 +02:00
|
|
|
{
|
2010-04-21 11:37:54 +02:00
|
|
|
LPWSTR str = msi_dup_property( db, prop );
|
2019-06-13 08:42:35 +02:00
|
|
|
int val = str ? wcstol(str, NULL, 10) : def;
|
2007-04-21 09:37:51 +02:00
|
|
|
msi_free(str);
|
|
|
|
return val;
|
2006-08-25 10:58:50 +02:00
|
|
|
}
|
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz)
|
2004-11-28 15:53:46 +01:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
const WCHAR *value = L"";
|
2004-11-28 15:53:46 +01:00
|
|
|
MSIPACKAGE *package;
|
2018-05-16 06:03:36 +02:00
|
|
|
MSIRECORD *row;
|
|
|
|
WCHAR *nameW;
|
|
|
|
int len = 0;
|
|
|
|
UINT r;
|
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
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
if (!(nameW = strdupAtoW(name)))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
|
2004-11-28 15:53:46 +01:00
|
|
|
if (!package)
|
2007-07-03 05:16:33 +02:00
|
|
|
{
|
2018-05-16 06:03:36 +02:00
|
|
|
WCHAR *value = NULL, *tmp;
|
2018-04-16 03:52:10 +02:00
|
|
|
MSIHANDLE remote;
|
2018-05-16 06:03:36 +02:00
|
|
|
DWORD len;
|
2007-07-03 05:16:33 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
if (!(remote = msi_get_remote(hinst)))
|
2018-05-17 17:48:15 +02:00
|
|
|
{
|
|
|
|
heap_free(nameW);
|
2007-07-03 05:16:33 +02:00
|
|
|
return ERROR_INVALID_HANDLE;
|
2018-05-17 17:48:15 +02:00
|
|
|
}
|
2007-07-03 05:16:33 +02:00
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_GetProperty(remote, nameW, &value, &len);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-05-17 17:48:15 +02:00
|
|
|
heap_free(nameW);
|
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
if (!r)
|
2007-07-03 05:16:33 +02:00
|
|
|
{
|
2018-05-16 06:03:36 +02:00
|
|
|
/* String might contain embedded nulls.
|
|
|
|
* Native returns the correct size but truncates the string. */
|
|
|
|
tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!tmp)
|
|
|
|
{
|
|
|
|
midl_user_free(value);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW(tmp, value);
|
2007-07-18 02:50:15 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE);
|
2007-07-03 05:16:33 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
heap_free(tmp);
|
|
|
|
}
|
2018-04-17 17:35:36 +02:00
|
|
|
midl_user_free(value);
|
2007-07-03 05:16:33 +02:00
|
|
|
return r;
|
|
|
|
}
|
2005-01-27 11:42:45 +01:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
row = msi_get_property_row(package->db, nameW);
|
2007-04-21 09:37:51 +02:00
|
|
|
if (row)
|
2018-05-16 06:03:36 +02:00
|
|
|
value = msi_record_get_string(row, 1, &len);
|
2005-10-31 15:07:37 +01:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
r = msi_strncpyWtoA(value, len, buf, sz, FALSE);
|
2005-10-31 15:07:37 +01:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
heap_free(nameW);
|
|
|
|
if (row) msiobj_release(&row->hdr);
|
|
|
|
msiobj_release(&package->hdr);
|
2005-10-31 15:07:37 +01:00
|
|
|
return r;
|
2004-11-28 15:53:46 +01:00
|
|
|
}
|
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
UINT WINAPI MsiGetPropertyW(MSIHANDLE hinst, const WCHAR *name, WCHAR *buf, DWORD *sz)
|
2004-07-10 00:25:34 +02:00
|
|
|
{
|
2020-10-28 11:19:48 +01:00
|
|
|
const WCHAR *value = L"";
|
2018-05-16 06:03:35 +02:00
|
|
|
MSIPACKAGE *package;
|
2018-05-16 06:03:36 +02:00
|
|
|
MSIRECORD *row;
|
|
|
|
int len = 0;
|
2005-10-31 15:07:37 +01:00
|
|
|
UINT r;
|
2005-08-25 11:51:03 +02:00
|
|
|
|
2018-05-16 06:03:35 +02:00
|
|
|
if (!name)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
2004-11-28 15:53:46 +01:00
|
|
|
|
2018-05-16 06:03:35 +02:00
|
|
|
package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
|
|
|
|
if (!package)
|
|
|
|
{
|
|
|
|
WCHAR *value = NULL, *tmp;
|
|
|
|
MSIHANDLE remote;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
if (!(remote = msi_get_remote(hinst)))
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
2018-09-08 03:17:22 +02:00
|
|
|
__TRY
|
|
|
|
{
|
|
|
|
r = remote_GetProperty(remote, name, &value, &len);
|
|
|
|
}
|
|
|
|
__EXCEPT(rpc_filter)
|
|
|
|
{
|
|
|
|
r = GetExceptionCode();
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2018-05-16 06:03:35 +02:00
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
/* String might contain embedded nulls.
|
|
|
|
* Native returns the correct size but truncates the string. */
|
|
|
|
tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR));
|
|
|
|
if (!tmp)
|
|
|
|
{
|
|
|
|
midl_user_free(value);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcpyW(tmp, value);
|
2018-05-16 06:03:35 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
r = msi_strncpyW(tmp, len, buf, sz);
|
2018-05-16 06:03:35 +02:00
|
|
|
|
|
|
|
heap_free(tmp);
|
|
|
|
}
|
|
|
|
midl_user_free(value);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
row = msi_get_property_row(package->db, name);
|
|
|
|
if (row)
|
|
|
|
value = msi_record_get_string(row, 1, &len);
|
2018-05-16 06:03:35 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
r = msi_strncpyW(value, len, buf, sz);
|
2018-05-16 06:03:35 +02:00
|
|
|
|
2018-05-16 06:03:36 +02:00
|
|
|
if (row) msiobj_release(&row->hdr);
|
2018-05-16 06:03:35 +02:00
|
|
|
msiobj_release(&package->hdr);
|
2005-10-31 15:07:37 +01:00
|
|
|
return r;
|
|
|
|
}
|
2006-08-25 10:54:29 +02:00
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
MSIHANDLE __cdecl s_remote_GetActiveDatabase(MSIHANDLE hinst)
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
2018-04-19 01:40:02 +02:00
|
|
|
return MsiGetActiveDatabase(hinst);
|
2007-07-03 05:15:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetProperty(MSIHANDLE hinst, LPCWSTR property, LPWSTR *value, DWORD *size)
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
2018-04-17 17:35:36 +02:00
|
|
|
WCHAR empty[1];
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
*size = 0;
|
|
|
|
r = MsiGetPropertyW(hinst, property, empty, size);
|
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
++*size;
|
|
|
|
*value = midl_user_allocate(*size * sizeof(WCHAR));
|
|
|
|
if (!*value)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
r = MsiGetPropertyW(hinst, property, *value, size);
|
|
|
|
}
|
|
|
|
return r;
|
2007-07-03 05:15:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetProperty(MSIHANDLE hinst, LPCWSTR property, LPCWSTR value)
|
2007-07-03 05:15:01 +02:00
|
|
|
{
|
2018-04-17 17:35:37 +02:00
|
|
|
return MsiSetPropertyW(hinst, property, value);
|
2007-07-03 05:15:01 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
int __cdecl s_remote_ProcessMessage(MSIHANDLE hinst, INSTALLMESSAGE message, struct wire_record *remote_rec)
|
2007-07-04 04:13:45 +02:00
|
|
|
{
|
2018-04-18 02:11:29 +02:00
|
|
|
MSIHANDLE rec;
|
|
|
|
int ret;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if ((r = unmarshal_record(remote_rec, &rec)))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
ret = MsiProcessMessage(hinst, message, rec);
|
|
|
|
|
|
|
|
MsiCloseHandle(rec);
|
|
|
|
return ret;
|
2007-07-04 04:13:45 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_DoAction(MSIHANDLE hinst, LPCWSTR action)
|
2007-07-04 04:14:37 +02:00
|
|
|
{
|
2018-04-22 02:33:43 +02:00
|
|
|
return MsiDoActionW(hinst, action);
|
2007-07-04 04:14:37 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_Sequence(MSIHANDLE hinst, LPCWSTR table, int sequence)
|
2007-07-04 04:15:06 +02:00
|
|
|
{
|
2018-04-22 02:33:44 +02:00
|
|
|
return MsiSequenceW(hinst, table, sequence);
|
2007-07-04 04:15:06 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetTargetPath(MSIHANDLE hinst, LPCWSTR folder, LPWSTR *value)
|
2007-07-04 04:15:36 +02:00
|
|
|
{
|
2018-04-22 02:33:45 +02:00
|
|
|
WCHAR empty[1];
|
|
|
|
DWORD size = 0;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MsiGetTargetPathW(hinst, folder, empty, &size);
|
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
*value = midl_user_allocate(++size * sizeof(WCHAR));
|
|
|
|
if (!*value)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
r = MsiGetTargetPathW(hinst, folder, *value, &size);
|
|
|
|
}
|
|
|
|
return r;
|
2007-07-04 04:15:36 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetTargetPath(MSIHANDLE hinst, LPCWSTR folder, LPCWSTR value)
|
2007-07-04 04:16:54 +02:00
|
|
|
{
|
2018-04-22 02:33:46 +02:00
|
|
|
return MsiSetTargetPathW(hinst, folder, value);
|
2007-07-04 04:16:54 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetSourcePath(MSIHANDLE hinst, LPCWSTR folder, LPWSTR *value)
|
2007-07-04 04:16:15 +02:00
|
|
|
{
|
2018-04-22 02:33:47 +02:00
|
|
|
WCHAR empty[1];
|
|
|
|
DWORD size = 1;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
r = MsiGetSourcePathW(hinst, folder, empty, &size);
|
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
*value = midl_user_allocate(++size * sizeof(WCHAR));
|
|
|
|
if (!*value)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
r = MsiGetSourcePathW(hinst, folder, *value, &size);
|
|
|
|
}
|
|
|
|
return r;
|
2007-07-04 04:16:15 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
BOOL __cdecl s_remote_GetMode(MSIHANDLE hinst, MSIRUNMODE mode)
|
2007-07-04 04:17:26 +02:00
|
|
|
{
|
2018-04-24 06:18:13 +02:00
|
|
|
return MsiGetMode(hinst, mode);
|
2007-07-04 04:17:26 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL state)
|
2010-02-18 12:46:58 +01:00
|
|
|
{
|
2018-04-24 06:18:14 +02:00
|
|
|
return MsiSetMode(hinst, mode, state);
|
2010-02-18 12:46:58 +01:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetFeatureState(MSIHANDLE hinst, LPCWSTR feature,
|
2018-04-16 03:52:10 +02:00
|
|
|
INSTALLSTATE *installed, INSTALLSTATE *action)
|
2007-07-04 04:18:44 +02:00
|
|
|
{
|
2018-04-24 06:18:15 +02:00
|
|
|
return MsiGetFeatureStateW(hinst, feature, installed, action);
|
2007-07-04 04:18:44 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetFeatureState(MSIHANDLE hinst, LPCWSTR feature, INSTALLSTATE state)
|
2007-07-04 04:18:04 +02:00
|
|
|
{
|
2018-04-24 06:18:16 +02:00
|
|
|
return MsiSetFeatureStateW(hinst, feature, state);
|
2007-07-04 04:18:04 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetComponentState(MSIHANDLE hinst, LPCWSTR component,
|
2018-04-16 03:52:10 +02:00
|
|
|
INSTALLSTATE *installed, INSTALLSTATE *action)
|
2007-07-04 04:19:16 +02:00
|
|
|
{
|
2018-04-24 06:18:17 +02:00
|
|
|
return MsiGetComponentStateW(hinst, component, installed, action);
|
2007-07-04 04:19:16 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetComponentState(MSIHANDLE hinst, LPCWSTR component, INSTALLSTATE state)
|
2007-07-04 04:19:44 +02:00
|
|
|
{
|
2018-04-24 06:18:18 +02:00
|
|
|
return MsiSetComponentStateW(hinst, component, state);
|
2007-07-04 04:19:44 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
LANGID __cdecl s_remote_GetLanguage(MSIHANDLE hinst)
|
2007-07-04 04:20:17 +02:00
|
|
|
{
|
2018-04-25 05:27:37 +02:00
|
|
|
return MsiGetLanguage(hinst);
|
2007-07-04 04:20:17 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_SetInstallLevel(MSIHANDLE hinst, int level)
|
2007-07-04 04:20:48 +02:00
|
|
|
{
|
2018-04-25 05:27:38 +02:00
|
|
|
return MsiSetInstallLevel(hinst, level);
|
2007-07-04 04:20:48 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_FormatRecord(MSIHANDLE hinst, struct wire_record *remote_rec, LPWSTR *value)
|
2007-07-06 02:48:43 +02:00
|
|
|
{
|
2018-04-25 05:27:39 +02:00
|
|
|
WCHAR empty[1];
|
2008-04-16 18:22:52 +02:00
|
|
|
DWORD size = 0;
|
2018-04-25 05:27:39 +02:00
|
|
|
MSIHANDLE rec;
|
|
|
|
UINT r;
|
|
|
|
|
|
|
|
if ((r = unmarshal_record(remote_rec, &rec)))
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = MsiFormatRecordW(hinst, rec, empty, &size);
|
|
|
|
if (r == ERROR_MORE_DATA)
|
2008-04-16 18:22:52 +02:00
|
|
|
{
|
2018-04-25 05:27:39 +02:00
|
|
|
*value = midl_user_allocate(++size * sizeof(WCHAR));
|
2008-04-16 18:22:52 +02:00
|
|
|
if (!*value)
|
2018-10-01 17:01:48 +02:00
|
|
|
{
|
|
|
|
MsiCloseHandle(rec);
|
2018-04-25 05:27:39 +02:00
|
|
|
return ERROR_OUTOFMEMORY;
|
2018-10-01 17:01:48 +02:00
|
|
|
}
|
2018-04-25 05:27:39 +02:00
|
|
|
r = MsiFormatRecordW(hinst, rec, *value, &size);
|
2008-04-16 18:22:52 +02:00
|
|
|
}
|
2018-04-25 05:27:39 +02:00
|
|
|
|
|
|
|
MsiCloseHandle(rec);
|
|
|
|
return r;
|
2007-07-06 02:48:43 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
MSICONDITION __cdecl s_remote_EvaluateCondition(MSIHANDLE hinst, LPCWSTR condition)
|
2007-07-06 02:53:03 +02:00
|
|
|
{
|
2018-04-25 05:27:40 +02:00
|
|
|
return MsiEvaluateConditionW(hinst, condition);
|
2007-07-06 02:53:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_GetFeatureCost(MSIHANDLE hinst, LPCWSTR feature,
|
2018-04-25 05:27:42 +02:00
|
|
|
MSICOSTTREE cost_tree, INSTALLSTATE state, INT *cost)
|
2009-11-08 13:34:43 +01:00
|
|
|
{
|
2018-04-25 05:27:42 +02:00
|
|
|
return MsiGetFeatureCostW(hinst, feature, cost_tree, state, cost);
|
2009-11-08 13:34:43 +01:00
|
|
|
}
|
|
|
|
|
2018-04-26 03:54:40 +02:00
|
|
|
UINT __cdecl s_remote_EnumComponentCosts(MSIHANDLE hinst, LPCWSTR component,
|
2018-04-26 03:54:38 +02:00
|
|
|
DWORD index, INSTALLSTATE state, LPWSTR drive, INT *cost, INT *temp)
|
2011-05-02 16:02:40 +02:00
|
|
|
{
|
2018-04-26 03:54:38 +02:00
|
|
|
DWORD size = 3;
|
|
|
|
return MsiEnumComponentCostsW(hinst, component, index, state, drive, &size, cost, temp);
|
2011-05-02 16:02:40 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2011-03-07 12:40:20 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( info, &package->sourcelist_info, MSISOURCELISTINFO, entry )
|
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
if (!wcscmp( info->value, value )) return ERROR_SUCCESS;
|
2011-03-07 12:40:20 +01:00
|
|
|
}
|
|
|
|
|
2007-07-03 05:20:20 +02:00
|
|
|
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;
|
|
|
|
|
2011-03-07 12:40:20 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( disk, &package->sourcelist_media, MSIMEDIADISK, entry )
|
|
|
|
{
|
|
|
|
if (disk->disk_id == disk_id) return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-07-03 05:20:20 +02:00
|
|
|
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;
|
|
|
|
}
|