2010-11-11 10:45:42 +01:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2010 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2011-01-24 15:22:11 +01:00
|
|
|
#include "winreg.h"
|
2010-11-11 10:45:42 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
static BOOL load_fusion_dlls( MSIPACKAGE *package )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
2019-02-26 13:27:50 +01:00
|
|
|
HRESULT (WINAPI *pLoadLibraryShim)( const WCHAR *, const WCHAR *, void *, HMODULE * );
|
2012-06-12 09:24:58 +02:00
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
DWORD len = GetSystemDirectoryW( path, MAX_PATH );
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
lstrcpyW( path + len, L"\\mscoree.dll" );
|
2019-02-26 13:27:50 +01:00
|
|
|
if (package->hmscoree || !(package->hmscoree = LoadLibraryW( path ))) return TRUE;
|
|
|
|
if (!(pLoadLibraryShim = (void *)GetProcAddress( package->hmscoree, "LoadLibraryShim" )))
|
2012-06-12 09:24:45 +02:00
|
|
|
{
|
2019-02-26 13:27:50 +01:00
|
|
|
FreeLibrary( package->hmscoree );
|
|
|
|
package->hmscoree = NULL;
|
2012-06-12 09:24:45 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2011-05-06 14:40:33 +02:00
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 );
|
|
|
|
pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 );
|
|
|
|
pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 );
|
|
|
|
pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 );
|
2011-03-07 12:40:39 +01:00
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
BOOL msi_init_assembly_caches( MSIPACKAGE *package )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
2019-02-26 13:27:50 +01:00
|
|
|
HRESULT (WINAPI *pCreateAssemblyCache)( IAssemblyCache **, DWORD );
|
2019-02-15 10:32:30 +01:00
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
if (package->cache_sxs) return TRUE;
|
2019-02-15 10:32:31 +01:00
|
|
|
if (CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE;
|
2019-02-15 10:32:30 +01:00
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
if (!load_fusion_dlls( package )) return FALSE;
|
|
|
|
package->pGetFileVersion = (void *)GetProcAddress( package->hmscoree, "GetFileVersion" ); /* missing from v1.0.3705 */
|
|
|
|
|
|
|
|
if (package->hfusion10)
|
|
|
|
{
|
|
|
|
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion10, "CreateAssemblyCache" );
|
|
|
|
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V10], 0 );
|
|
|
|
}
|
|
|
|
if (package->hfusion11)
|
|
|
|
{
|
|
|
|
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion11, "CreateAssemblyCache" );
|
|
|
|
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V11], 0 );
|
|
|
|
}
|
|
|
|
if (package->hfusion20)
|
|
|
|
{
|
|
|
|
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion20, "CreateAssemblyCache" );
|
|
|
|
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V20], 0 );
|
|
|
|
}
|
|
|
|
if (package->hfusion40)
|
|
|
|
{
|
|
|
|
pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyCache" );
|
|
|
|
pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V40], 0 );
|
|
|
|
package->pCreateAssemblyNameObject = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyNameObject" );
|
|
|
|
package->pCreateAssemblyEnum = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyEnum" );
|
|
|
|
}
|
|
|
|
|
2012-06-12 09:24:45 +02:00
|
|
|
return TRUE;
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
void msi_destroy_assembly_caches( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
|
2012-06-12 09:25:09 +02:00
|
|
|
if (package->cache_sxs)
|
|
|
|
{
|
|
|
|
IAssemblyCache_Release( package->cache_sxs );
|
|
|
|
package->cache_sxs = NULL;
|
|
|
|
}
|
2011-05-06 14:39:58 +02:00
|
|
|
for (i = 0; i < CLR_VERSION_MAX; i++)
|
|
|
|
{
|
|
|
|
if (package->cache_net[i])
|
|
|
|
{
|
|
|
|
IAssemblyCache_Release( package->cache_net[i] );
|
|
|
|
package->cache_net[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2019-02-26 13:27:50 +01:00
|
|
|
package->pGetFileVersion = NULL;
|
|
|
|
package->pCreateAssemblyNameObject = NULL;
|
|
|
|
package->pCreateAssemblyEnum = NULL;
|
|
|
|
FreeLibrary( package->hfusion10 );
|
|
|
|
FreeLibrary( package->hfusion11 );
|
|
|
|
FreeLibrary( package->hfusion20 );
|
|
|
|
FreeLibrary( package->hfusion40 );
|
|
|
|
FreeLibrary( package->hmscoree );
|
|
|
|
package->hfusion10 = NULL;
|
|
|
|
package->hfusion11 = NULL;
|
|
|
|
package->hfusion20 = NULL;
|
|
|
|
package->hfusion40 = NULL;
|
|
|
|
package->hmscoree = NULL;
|
2011-05-06 14:39:58 +02:00
|
|
|
}
|
|
|
|
|
2011-03-16 08:32:32 +01:00
|
|
|
static MSIRECORD *get_assembly_record( MSIPACKAGE *package, const WCHAR *comp )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
|
|
|
MSIQUERY *view;
|
|
|
|
MSIRECORD *rec;
|
|
|
|
UINT r;
|
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
r = MSI_OpenQuery( package->db, &view, L"SELECT * FROM `MsiAssembly` WHERE `Component_` = '%s'", comp );
|
2010-11-11 10:45:42 +01:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
r = MSI_ViewExecute( view, NULL );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
r = MSI_ViewFetch( view, &rec );
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!MSI_RecordGetString( rec, 4 ))
|
|
|
|
TRACE("component is a global assembly\n");
|
|
|
|
|
|
|
|
msiobj_release( &view->hdr );
|
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct assembly_name
|
|
|
|
{
|
2011-01-24 15:21:45 +01:00
|
|
|
UINT count;
|
|
|
|
UINT index;
|
|
|
|
WCHAR **attrs;
|
2010-11-11 10:45:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static UINT get_assembly_name_attribute( MSIRECORD *rec, LPVOID param )
|
|
|
|
{
|
|
|
|
struct assembly_name *name = param;
|
|
|
|
const WCHAR *attr = MSI_RecordGetString( rec, 2 );
|
2011-01-24 15:21:45 +01:00
|
|
|
const WCHAR *value = MSI_RecordGetString( rec, 3 );
|
2020-10-29 11:47:14 +01:00
|
|
|
int len = lstrlenW( L"%s=\"%s\"" ) + lstrlenW( attr ) + lstrlenW( value );
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2011-01-24 15:21:45 +01:00
|
|
|
if (!(name->attrs[name->index] = msi_alloc( len * sizeof(WCHAR) )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
if (!wcsicmp( attr, L"name" )) lstrcpyW( name->attrs[name->index++], value );
|
|
|
|
else swprintf( name->attrs[name->index++], len, L"%s=\"%s\"", attr, value );
|
2010-11-11 10:45:42 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *get_assembly_display_name( MSIDATABASE *db, const WCHAR *comp, MSIASSEMBLY *assembly )
|
|
|
|
{
|
|
|
|
struct assembly_name name;
|
|
|
|
WCHAR *display_name = NULL;
|
|
|
|
MSIQUERY *view;
|
2011-01-24 15:21:45 +01:00
|
|
|
UINT i, r;
|
2010-11-11 10:45:42 +01:00
|
|
|
int len;
|
|
|
|
|
2020-10-29 11:47:14 +01:00
|
|
|
r = MSI_OpenQuery( db, &view, L"SELECT * FROM `MsiAssemblyName` WHERE `Component_` = '%s'", comp );
|
2010-11-11 10:45:42 +01:00
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
2011-01-24 15:21:45 +01:00
|
|
|
name.count = 0;
|
|
|
|
name.index = 0;
|
|
|
|
name.attrs = NULL;
|
|
|
|
MSI_IterateRecords( view, &name.count, NULL, NULL );
|
|
|
|
if (!name.count) goto done;
|
|
|
|
|
|
|
|
name.attrs = msi_alloc( name.count * sizeof(WCHAR *) );
|
|
|
|
if (!name.attrs) goto done;
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
MSI_IterateRecords( view, NULL, get_assembly_name_attribute, &name );
|
|
|
|
|
2011-01-24 15:21:45 +01:00
|
|
|
len = 0;
|
2019-06-13 08:42:35 +02:00
|
|
|
for (i = 0; i < name.count; i++) len += lstrlenW( name.attrs[i] ) + 1;
|
2011-01-24 15:21:45 +01:00
|
|
|
|
|
|
|
display_name = msi_alloc( (len + 1) * sizeof(WCHAR) );
|
|
|
|
if (display_name)
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
2011-01-24 15:21:45 +01:00
|
|
|
display_name[0] = 0;
|
|
|
|
for (i = 0; i < name.count; i++)
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
2019-06-13 08:42:35 +02:00
|
|
|
lstrcatW( display_name, name.attrs[i] );
|
2020-10-29 11:47:14 +01:00
|
|
|
if (i < name.count - 1) lstrcatW( display_name, L"," );
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2011-01-24 15:21:45 +01:00
|
|
|
msiobj_release( &view->hdr );
|
2011-07-07 09:22:59 +02:00
|
|
|
if (name.attrs)
|
|
|
|
{
|
|
|
|
for (i = 0; i < name.count; i++) msi_free( name.attrs[i] );
|
|
|
|
msi_free( name.attrs );
|
|
|
|
}
|
2010-11-11 10:45:42 +01:00
|
|
|
return display_name;
|
|
|
|
}
|
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
static BOOL is_assembly_installed( IAssemblyCache *cache, const WCHAR *display_name )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2011-03-07 12:40:39 +01:00
|
|
|
ASSEMBLY_INFO info;
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2012-06-12 09:24:45 +02:00
|
|
|
if (!cache) return FALSE;
|
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
memset( &info, 0, sizeof(info) );
|
|
|
|
info.cbAssemblyInfo = sizeof(info);
|
2012-03-30 10:22:05 +02:00
|
|
|
hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, display_name, &info );
|
2014-10-08 06:27:49 +02:00
|
|
|
if (hr == S_OK /* sxs version */ || hr == E_NOT_SUFFICIENT_BUFFER)
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
2012-03-30 10:22:05 +02:00
|
|
|
return (info.dwAssemblyFlags == ASSEMBLYINFO_FLAG_INSTALLED);
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
2012-03-30 10:22:05 +02:00
|
|
|
TRACE("QueryAssemblyInfo returned 0x%08x\n", hr);
|
|
|
|
return FALSE;
|
2011-03-07 12:40:39 +01:00
|
|
|
}
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2015-04-10 12:59:01 +02:00
|
|
|
WCHAR *msi_get_assembly_path( MSIPACKAGE *package, const WCHAR *displayname )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
ASSEMBLY_INFO info;
|
|
|
|
IAssemblyCache *cache = package->cache_net[CLR_VERSION_V40];
|
|
|
|
|
|
|
|
if (!cache) return NULL;
|
|
|
|
|
|
|
|
memset( &info, 0, sizeof(info) );
|
|
|
|
info.cbAssemblyInfo = sizeof(info);
|
|
|
|
hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
|
|
|
|
if (hr != E_NOT_SUFFICIENT_BUFFER) return NULL;
|
|
|
|
|
|
|
|
if (!(info.pszCurrentAssemblyPathBuf = msi_alloc( info.cchBuf * sizeof(WCHAR) ))) return NULL;
|
|
|
|
|
|
|
|
hr = IAssemblyCache_QueryAssemblyInfo( cache, 0, displayname, &info );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
{
|
|
|
|
msi_free( info.pszCurrentAssemblyPathBuf );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
TRACE("returning %s\n", debugstr_w(info.pszCurrentAssemblyPathBuf));
|
|
|
|
return info.pszCurrentAssemblyPathBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
IAssemblyEnum *msi_create_assembly_enum( MSIPACKAGE *package, const WCHAR *displayname )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IAssemblyName *name;
|
|
|
|
IAssemblyEnum *ret;
|
|
|
|
WCHAR *str;
|
|
|
|
UINT len = 0;
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
if (!package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum) return NULL;
|
2015-04-10 12:59:01 +02:00
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
hr = package->pCreateAssemblyNameObject( &name, displayname, CANOF_PARSE_DISPLAY_NAME, NULL );
|
2015-04-10 12:59:01 +02:00
|
|
|
if (FAILED( hr )) return NULL;
|
|
|
|
|
|
|
|
hr = IAssemblyName_GetName( name, &len, NULL );
|
|
|
|
if (hr != E_NOT_SUFFICIENT_BUFFER || !(str = msi_alloc( len * sizeof(WCHAR) )))
|
|
|
|
{
|
|
|
|
IAssemblyName_Release( name );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IAssemblyName_GetName( name, &len, str );
|
|
|
|
IAssemblyName_Release( name );
|
|
|
|
if (FAILED( hr ))
|
|
|
|
{
|
|
|
|
msi_free( str );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
hr = package->pCreateAssemblyNameObject( &name, str, 0, NULL );
|
2015-04-10 12:59:01 +02:00
|
|
|
msi_free( str );
|
|
|
|
if (FAILED( hr )) return NULL;
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
hr = package->pCreateAssemblyEnum( &ret, NULL, name, ASM_CACHE_GAC, NULL );
|
2015-04-10 12:59:01 +02:00
|
|
|
IAssemblyName_Release( name );
|
|
|
|
if (FAILED( hr )) return NULL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
static const WCHAR *clr_version[] =
|
|
|
|
{
|
2020-10-29 11:47:14 +01:00
|
|
|
L"v1.0.3705",
|
|
|
|
L"v1.2.4322",
|
|
|
|
L"v2.0.50727",
|
|
|
|
L"v4.0.30319"
|
2011-03-07 12:40:39 +01:00
|
|
|
};
|
2010-11-11 10:45:42 +01:00
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
static const WCHAR *get_clr_version_str( enum clr_version version )
|
|
|
|
{
|
2020-10-29 11:47:14 +01:00
|
|
|
if (version >= ARRAY_SIZE( clr_version )) return L"unknown";
|
2011-03-07 12:40:39 +01:00
|
|
|
return clr_version[version];
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
/* assembly caches must be initialized */
|
|
|
|
MSIASSEMBLY *msi_load_assembly( MSIPACKAGE *package, MSICOMPONENT *comp )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
|
|
|
MSIRECORD *rec;
|
|
|
|
MSIASSEMBLY *a;
|
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
if (!(rec = get_assembly_record( package, comp->Component ))) return NULL;
|
2010-11-11 10:45:42 +01:00
|
|
|
if (!(a = msi_alloc_zero( sizeof(MSIASSEMBLY) )))
|
|
|
|
{
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
a->feature = strdupW( MSI_RecordGetString( rec, 2 ) );
|
|
|
|
TRACE("feature %s\n", debugstr_w(a->feature));
|
|
|
|
|
|
|
|
a->manifest = strdupW( MSI_RecordGetString( rec, 3 ) );
|
|
|
|
TRACE("manifest %s\n", debugstr_w(a->manifest));
|
|
|
|
|
|
|
|
a->application = strdupW( MSI_RecordGetString( rec, 4 ) );
|
|
|
|
TRACE("application %s\n", debugstr_w(a->application));
|
|
|
|
|
|
|
|
a->attributes = MSI_RecordGetInteger( rec, 5 );
|
|
|
|
TRACE("attributes %u\n", a->attributes);
|
|
|
|
|
|
|
|
if (!(a->display_name = get_assembly_display_name( package->db, comp->Component, a )))
|
|
|
|
{
|
|
|
|
WARN("can't get display name\n");
|
|
|
|
msiobj_release( &rec->hdr );
|
2011-01-18 09:16:28 +01:00
|
|
|
msi_free( a->feature );
|
|
|
|
msi_free( a->manifest );
|
|
|
|
msi_free( a->application );
|
2010-11-11 10:45:42 +01:00
|
|
|
msi_free( a );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
TRACE("display name %s\n", debugstr_w(a->display_name));
|
|
|
|
|
2011-03-07 12:40:39 +01:00
|
|
|
if (a->application)
|
|
|
|
{
|
2011-03-16 09:22:59 +01:00
|
|
|
/* We can't check the manifest here because the target path may still change.
|
|
|
|
So we assume that the assembly is not installed and lean on the InstallFiles
|
|
|
|
action to determine which files need to be installed.
|
|
|
|
*/
|
|
|
|
a->installed = FALSE;
|
2011-03-07 12:40:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (a->attributes == msidbAssemblyAttributesWin32)
|
|
|
|
a->installed = is_assembly_installed( package->cache_sxs, a->display_name );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
for (i = 0; i < CLR_VERSION_MAX; i++)
|
|
|
|
{
|
|
|
|
a->clr_version[i] = is_assembly_installed( package->cache_net[i], a->display_name );
|
|
|
|
if (a->clr_version[i])
|
|
|
|
{
|
|
|
|
TRACE("runtime version %s\n", debugstr_w(get_clr_version_str( i )));
|
|
|
|
a->installed = TRUE;
|
2012-05-17 10:17:16 +02:00
|
|
|
break;
|
2011-03-07 12:40:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-11-11 10:45:42 +01:00
|
|
|
TRACE("assembly is %s\n", a->installed ? "installed" : "not installed");
|
|
|
|
msiobj_release( &rec->hdr );
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
static enum clr_version get_clr_version( MSIPACKAGE *package, const WCHAR *filename )
|
2011-03-07 12:40:39 +01:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
HRESULT hr;
|
|
|
|
enum clr_version version = CLR_VERSION_V11;
|
|
|
|
WCHAR *strW;
|
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
if (!package->pGetFileVersion) return CLR_VERSION_V10;
|
2011-05-06 14:40:33 +02:00
|
|
|
|
2019-02-26 13:27:50 +01:00
|
|
|
hr = package->pGetFileVersion( filename, NULL, 0, &len );
|
2014-10-08 06:27:49 +02:00
|
|
|
if (hr != E_NOT_SUFFICIENT_BUFFER) return CLR_VERSION_V11;
|
2011-03-07 12:40:39 +01:00
|
|
|
if ((strW = msi_alloc( len * sizeof(WCHAR) )))
|
|
|
|
{
|
2019-02-26 13:27:50 +01:00
|
|
|
hr = package->pGetFileVersion( filename, strW, len, &len );
|
2011-03-07 12:40:39 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
for (i = 0; i < CLR_VERSION_MAX; i++)
|
2019-06-13 08:42:35 +02:00
|
|
|
if (!wcscmp( strW, clr_version[i] )) version = i;
|
2011-03-07 12:40:39 +01:00
|
|
|
}
|
|
|
|
msi_free( strW );
|
|
|
|
}
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2011-05-06 14:39:58 +02:00
|
|
|
UINT msi_install_assembly( MSIPACKAGE *package, MSICOMPONENT *comp )
|
2010-11-11 10:45:42 +01:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
const WCHAR *manifest;
|
|
|
|
IAssemblyCache *cache;
|
|
|
|
MSIASSEMBLY *assembly = comp->assembly;
|
|
|
|
MSIFEATURE *feature = NULL;
|
|
|
|
|
|
|
|
if (comp->assembly->feature)
|
2011-05-06 14:39:17 +02:00
|
|
|
feature = msi_get_loaded_feature( package, comp->assembly->feature );
|
2010-11-11 10:45:42 +01:00
|
|
|
|
|
|
|
if (assembly->application)
|
|
|
|
{
|
|
|
|
if (feature) feature->Action = INSTALLSTATE_LOCAL;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
if (assembly->attributes == msidbAssemblyAttributesWin32)
|
|
|
|
{
|
|
|
|
if (!assembly->manifest)
|
|
|
|
{
|
|
|
|
WARN("no manifest\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
2011-05-06 14:39:17 +02:00
|
|
|
manifest = msi_get_loaded_file( package, assembly->manifest )->TargetPath;
|
2010-11-11 10:45:42 +01:00
|
|
|
cache = package->cache_sxs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
manifest = msi_get_loaded_file( package, comp->KeyPath )->TargetPath;
|
2019-02-26 13:27:50 +01:00
|
|
|
cache = package->cache_net[get_clr_version( package, manifest )];
|
2012-06-12 09:24:45 +02:00
|
|
|
if (!cache) return ERROR_SUCCESS;
|
2010-11-11 10:45:42 +01:00
|
|
|
}
|
|
|
|
TRACE("installing assembly %s\n", debugstr_w(manifest));
|
|
|
|
|
|
|
|
hr = IAssemblyCache_InstallAssembly( cache, 0, manifest, NULL );
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
ERR("Failed to install assembly %s (0x%08x)\n", debugstr_w(manifest), hr);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
if (feature) feature->Action = INSTALLSTATE_LOCAL;
|
|
|
|
assembly->installed = TRUE;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-04-30 09:35:25 +02:00
|
|
|
UINT msi_uninstall_assembly( MSIPACKAGE *package, MSICOMPONENT *comp )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IAssemblyCache *cache;
|
|
|
|
MSIASSEMBLY *assembly = comp->assembly;
|
|
|
|
MSIFEATURE *feature = NULL;
|
|
|
|
|
|
|
|
if (comp->assembly->feature)
|
|
|
|
feature = msi_get_loaded_feature( package, comp->assembly->feature );
|
|
|
|
|
|
|
|
if (assembly->application)
|
|
|
|
{
|
|
|
|
if (feature) feature->Action = INSTALLSTATE_ABSENT;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
TRACE("removing %s\n", debugstr_w(assembly->display_name));
|
|
|
|
|
|
|
|
if (assembly->attributes == msidbAssemblyAttributesWin32)
|
|
|
|
{
|
|
|
|
cache = package->cache_sxs;
|
|
|
|
hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
|
|
|
|
if (FAILED( hr )) WARN("failed to uninstall assembly 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < CLR_VERSION_MAX; i++)
|
|
|
|
{
|
|
|
|
if (!assembly->clr_version[i]) continue;
|
|
|
|
cache = package->cache_net[i];
|
2012-06-12 09:24:45 +02:00
|
|
|
if (cache)
|
|
|
|
{
|
|
|
|
hr = IAssemblyCache_UninstallAssembly( cache, 0, assembly->display_name, NULL, NULL );
|
|
|
|
if (FAILED( hr )) WARN("failed to uninstall assembly 0x%08x\n", hr);
|
|
|
|
}
|
2012-04-30 09:35:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (feature) feature->Action = INSTALLSTATE_ABSENT;
|
|
|
|
assembly->installed = FALSE;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-01-24 15:22:11 +01:00
|
|
|
static WCHAR *build_local_assembly_path( const WCHAR *filename )
|
|
|
|
{
|
|
|
|
UINT i;
|
|
|
|
WCHAR *ret;
|
|
|
|
|
2019-06-13 08:42:35 +02:00
|
|
|
if (!(ret = msi_alloc( (lstrlenW( filename ) + 1) * sizeof(WCHAR) )))
|
2011-01-24 15:22:11 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (i = 0; filename[i]; i++)
|
|
|
|
{
|
|
|
|
if (filename[i] == '\\' || filename[i] == '/') ret[i] = '|';
|
|
|
|
else ret[i] = filename[i];
|
|
|
|
}
|
|
|
|
ret[i] = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG open_assemblies_key( UINT context, BOOL win32, HKEY *hkey )
|
|
|
|
{
|
|
|
|
HKEY root;
|
|
|
|
const WCHAR *path;
|
|
|
|
|
|
|
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
root = HKEY_CLASSES_ROOT;
|
2020-10-29 11:47:14 +01:00
|
|
|
if (win32) path = L"Installer\\Win32Assemblies\\";
|
|
|
|
else path = L"Installer\\Assemblies\\";
|
2011-01-24 15:22:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root = HKEY_CURRENT_USER;
|
2020-10-29 11:47:14 +01:00
|
|
|
if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\";
|
|
|
|
else path = L"Software\\Microsoft\\Installer\\Assemblies\\";
|
2011-01-24 15:22:11 +01:00
|
|
|
}
|
|
|
|
return RegCreateKeyW( root, path, hkey );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG open_local_assembly_key( UINT context, BOOL win32, const WCHAR *filename, HKEY *hkey )
|
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
HKEY root;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (!(path = build_local_assembly_path( filename )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if ((res = open_assemblies_key( context, win32, &root )))
|
|
|
|
{
|
|
|
|
msi_free( path );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
res = RegCreateKeyW( root, path, hkey );
|
|
|
|
RegCloseKey( root );
|
|
|
|
msi_free( path );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG delete_local_assembly_key( UINT context, BOOL win32, const WCHAR *filename )
|
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
HKEY root;
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (!(path = build_local_assembly_path( filename )))
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if ((res = open_assemblies_key( context, win32, &root )))
|
|
|
|
{
|
|
|
|
msi_free( path );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
res = RegDeleteKeyW( root, path );
|
|
|
|
RegCloseKey( root );
|
|
|
|
msi_free( path );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG open_global_assembly_key( UINT context, BOOL win32, HKEY *hkey )
|
|
|
|
{
|
|
|
|
HKEY root;
|
|
|
|
const WCHAR *path;
|
|
|
|
|
|
|
|
if (context == MSIINSTALLCONTEXT_MACHINE)
|
|
|
|
{
|
|
|
|
root = HKEY_CLASSES_ROOT;
|
2020-10-29 11:47:14 +01:00
|
|
|
if (win32) path = L"Installer\\Win32Assemblies\\Global";
|
|
|
|
else path = L"Installer\\Assemblies\\Global";
|
2011-01-24 15:22:11 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
root = HKEY_CURRENT_USER;
|
2020-10-29 11:47:14 +01:00
|
|
|
if (win32) path = L"Software\\Microsoft\\Installer\\Win32Assemblies\\Global";
|
|
|
|
else path = L"Software\\Microsoft\\Installer\\Assemblies\\Global";
|
2011-01-24 15:22:11 +01:00
|
|
|
}
|
|
|
|
return RegCreateKeyW( root, path, hkey );
|
|
|
|
}
|
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
UINT ACTION_MsiPublishAssemblies( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
2018-07-30 04:16:20 +02:00
|
|
|
if (package->script == SCRIPT_NONE)
|
2020-10-29 11:47:14 +01:00
|
|
|
return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiPublishAssemblies");
|
2018-07-30 04:16:20 +02:00
|
|
|
|
2010-11-11 10:45:42 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(comp, &package->components, MSICOMPONENT, entry)
|
|
|
|
{
|
2011-01-24 15:22:11 +01:00
|
|
|
LONG res;
|
|
|
|
HKEY hkey;
|
|
|
|
GUID guid;
|
|
|
|
DWORD size;
|
|
|
|
WCHAR buffer[43];
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
MSIASSEMBLY *assembly = comp->assembly;
|
|
|
|
BOOL win32;
|
|
|
|
|
|
|
|
if (!assembly || !comp->ComponentId) continue;
|
|
|
|
|
2011-05-25 10:39:11 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_LOCAL)
|
2011-01-24 15:22:11 +01:00
|
|
|
{
|
2011-05-25 10:39:11 +02:00
|
|
|
TRACE("component not scheduled for installation %s\n", debugstr_w(comp->Component));
|
2011-01-24 15:22:11 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
TRACE("publishing %s\n", debugstr_w(comp->Component));
|
|
|
|
|
|
|
|
CLSIDFromString( package->ProductCode, &guid );
|
|
|
|
encode_base85_guid( &guid, buffer );
|
|
|
|
buffer[20] = '>';
|
|
|
|
CLSIDFromString( comp->ComponentId, &guid );
|
|
|
|
encode_base85_guid( &guid, buffer + 21 );
|
|
|
|
buffer[42] = 0;
|
|
|
|
|
|
|
|
win32 = assembly->attributes & msidbAssemblyAttributesWin32;
|
|
|
|
if (assembly->application)
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
MSIFILE *file = msi_get_loaded_file( package, assembly->application );
|
2018-09-04 02:17:56 +02:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-24 15:22:11 +01:00
|
|
|
if ((res = open_local_assembly_key( package->Context, win32, file->TargetPath, &hkey )))
|
|
|
|
{
|
|
|
|
WARN("failed to open local assembly key %d\n", res);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
|
|
|
|
{
|
|
|
|
WARN("failed to open global assembly key %d\n", res);
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size = sizeof(buffer);
|
|
|
|
if ((res = RegSetValueExW( hkey, assembly->display_name, 0, REG_MULTI_SZ, (const BYTE *)buffer, size )))
|
|
|
|
{
|
|
|
|
WARN("failed to set assembly value %d\n", res);
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
|
|
|
MSI_RecordSetStringW( uirow, 2, assembly->display_name );
|
2017-07-07 16:03:15 +02:00
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
|
2011-01-24 15:22:11 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT ACTION_MsiUnpublishAssemblies( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
MSICOMPONENT *comp;
|
|
|
|
|
2018-07-30 04:16:20 +02:00
|
|
|
if (package->script == SCRIPT_NONE)
|
2020-10-29 11:47:14 +01:00
|
|
|
return msi_schedule_action(package, SCRIPT_INSTALL, L"MsiUnpublishAssemblies");
|
2018-07-30 04:16:20 +02:00
|
|
|
|
2011-01-24 15:22:11 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(comp, &package->components, MSICOMPONENT, entry)
|
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
MSIASSEMBLY *assembly = comp->assembly;
|
|
|
|
BOOL win32;
|
|
|
|
|
|
|
|
if (!assembly || !comp->ComponentId) continue;
|
|
|
|
|
2011-05-25 10:39:11 +02:00
|
|
|
comp->Action = msi_get_component_action( package, comp );
|
|
|
|
if (comp->Action != INSTALLSTATE_ABSENT)
|
2011-01-24 15:22:11 +01:00
|
|
|
{
|
2011-05-25 10:39:11 +02:00
|
|
|
TRACE("component not scheduled for removal %s\n", debugstr_w(comp->Component));
|
2010-11-11 10:45:42 +01:00
|
|
|
continue;
|
2011-01-24 15:22:11 +01:00
|
|
|
}
|
|
|
|
TRACE("unpublishing %s\n", debugstr_w(comp->Component));
|
|
|
|
|
|
|
|
win32 = assembly->attributes & msidbAssemblyAttributesWin32;
|
|
|
|
if (assembly->application)
|
|
|
|
{
|
2011-05-06 14:39:17 +02:00
|
|
|
MSIFILE *file = msi_get_loaded_file( package, assembly->application );
|
2018-09-04 02:17:56 +02:00
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
WARN("no matching file %s for local assembly\n", debugstr_w(assembly->application));
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-24 15:22:11 +01:00
|
|
|
if ((res = delete_local_assembly_key( package->Context, win32, file->TargetPath )))
|
|
|
|
WARN("failed to delete local assembly key %d\n", res);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
if ((res = open_global_assembly_key( package->Context, win32, &hkey )))
|
|
|
|
WARN("failed to delete global assembly key %d\n", res);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((res = RegDeleteValueW( hkey, assembly->display_name )))
|
|
|
|
WARN("failed to delete global assembly value %d\n", res);
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
}
|
2010-11-11 10:45:42 +01:00
|
|
|
|
|
|
|
uirow = MSI_CreateRecord( 2 );
|
2011-01-24 15:22:11 +01:00
|
|
|
MSI_RecordSetStringW( uirow, 2, assembly->display_name );
|
2017-07-07 16:03:15 +02:00
|
|
|
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
|
2010-11-11 10:45:42 +01:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
}
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|