From d9d700f3328f00ec419571df0e02cef208fa1e7b Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Thu, 2 Feb 2023 12:05:20 +0100 Subject: [PATCH] msi: Perform late initialization of the assembly caches. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51345 --- dlls/msi/assembly.c | 42 ++++++++++++++++++++++-------------------- dlls/msi/msipriv.h | 1 - dlls/msi/package.c | 7 ------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/dlls/msi/assembly.c b/dlls/msi/assembly.c index 586521342b6..47e8071502c 100644 --- a/dlls/msi/assembly.c +++ b/dlls/msi/assembly.c @@ -30,55 +30,52 @@ WINE_DEFAULT_DEBUG_CHANNEL(msi); -static BOOL load_fusion_dlls( MSIPACKAGE *package ) +static void load_fusion_dlls( MSIPACKAGE *package ) { HRESULT (WINAPI *pLoadLibraryShim)( const WCHAR *, const WCHAR *, void *, HMODULE * ); WCHAR path[MAX_PATH]; DWORD len = GetSystemDirectoryW( path, MAX_PATH ); lstrcpyW( path + len, L"\\mscoree.dll" ); - if (package->hmscoree || !(package->hmscoree = LoadLibraryW( path ))) return TRUE; + if (!package->hmscoree && !(package->hmscoree = LoadLibraryW( path ))) return; if (!(pLoadLibraryShim = (void *)GetProcAddress( package->hmscoree, "LoadLibraryShim" ))) { FreeLibrary( package->hmscoree ); package->hmscoree = NULL; - return TRUE; + return; } - 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 ); - - return TRUE; + if (!package->hfusion10) pLoadLibraryShim( L"fusion.dll", L"v1.0.3705", NULL, &package->hfusion10 ); + if (!package->hfusion11) pLoadLibraryShim( L"fusion.dll", L"v1.1.4322", NULL, &package->hfusion11 ); + if (!package->hfusion20) pLoadLibraryShim( L"fusion.dll", L"v2.0.50727", NULL, &package->hfusion20 ); + if (!package->hfusion40) pLoadLibraryShim( L"fusion.dll", L"v4.0.30319", NULL, &package->hfusion40 ); } -BOOL msi_init_assembly_caches( MSIPACKAGE *package ) +static BOOL init_assembly_caches( MSIPACKAGE *package ) { HRESULT (WINAPI *pCreateAssemblyCache)( IAssemblyCache **, DWORD ); - if (package->cache_sxs) return TRUE; - if (CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE; + if (!package->cache_sxs && CreateAssemblyCache( &package->cache_sxs, 0 ) != S_OK) return FALSE; - if (!load_fusion_dlls( package )) return FALSE; + load_fusion_dlls( package ); package->pGetFileVersion = (void *)GetProcAddress( package->hmscoree, "GetFileVersion" ); /* missing from v1.0.3705 */ - if (package->hfusion10) + if (package->hfusion10 && !package->cache_net[CLR_VERSION_V10]) { pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion10, "CreateAssemblyCache" ); pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V10], 0 ); } - if (package->hfusion11) + if (package->hfusion11 && !package->cache_net[CLR_VERSION_V11]) { pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion11, "CreateAssemblyCache" ); pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V11], 0 ); } - if (package->hfusion20) + if (package->hfusion20 && !package->cache_net[CLR_VERSION_V20]) { pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion20, "CreateAssemblyCache" ); pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V20], 0 ); } - if (package->hfusion40) + if (package->hfusion40 && !package->cache_net[CLR_VERSION_V40]) { pCreateAssemblyCache = (void *)GetProcAddress( package->hfusion40, "CreateAssemblyCache" ); pCreateAssemblyCache( &package->cache_net[CLR_VERSION_V40], 0 ); @@ -223,9 +220,9 @@ WCHAR *msi_get_assembly_path( MSIPACKAGE *package, const WCHAR *displayname ) { HRESULT hr; ASSEMBLY_INFO info; - IAssemblyCache *cache = package->cache_net[CLR_VERSION_V40]; + IAssemblyCache *cache; - if (!cache) return NULL; + if (!init_assembly_caches( package ) || !(cache = package->cache_net[CLR_VERSION_V40])) return NULL; memset( &info, 0, sizeof(info) ); info.cbAssemblyInfo = sizeof(info); @@ -252,7 +249,8 @@ IAssemblyEnum *msi_create_assembly_enum( MSIPACKAGE *package, const WCHAR *displ WCHAR *str; DWORD len = 0; - if (!package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum) return NULL; + if (!init_assembly_caches( package ) || !package->pCreateAssemblyNameObject || !package->pCreateAssemblyEnum) + return NULL; hr = package->pCreateAssemblyNameObject( &name, displayname, CANOF_PARSE_DISPLAY_NAME, NULL ); if (FAILED( hr )) return NULL; @@ -363,6 +361,8 @@ UINT msi_install_assembly( MSIPACKAGE *package, MSICOMPONENT *comp ) MSIASSEMBLY *assembly = comp->assembly; MSIFEATURE *feature = NULL; + if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED; + if (comp->assembly->feature) feature = msi_get_loaded_feature( package, comp->assembly->feature ); @@ -406,6 +406,8 @@ UINT msi_uninstall_assembly( MSIPACKAGE *package, MSICOMPONENT *comp ) MSIASSEMBLY *assembly = comp->assembly; MSIFEATURE *feature = NULL; + if (!init_assembly_caches( package )) return ERROR_FUNCTION_FAILED; + if (comp->assembly->feature) feature = msi_get_loaded_feature( package, comp->assembly->feature ); diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 902dd01205c..92c406b8ec5 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -1052,7 +1052,6 @@ extern UINT msi_set_sourcedir_props(MSIPACKAGE *package, BOOL replace) DECLSPEC_ extern MSIASSEMBLY *msi_load_assembly(MSIPACKAGE *, MSICOMPONENT *) DECLSPEC_HIDDEN; extern UINT msi_install_assembly(MSIPACKAGE *, MSICOMPONENT *) DECLSPEC_HIDDEN; extern UINT msi_uninstall_assembly(MSIPACKAGE *, MSICOMPONENT *) DECLSPEC_HIDDEN; -extern BOOL msi_init_assembly_caches(MSIPACKAGE *) DECLSPEC_HIDDEN; extern void msi_destroy_assembly_caches(MSIPACKAGE *) DECLSPEC_HIDDEN; extern BOOL msi_is_global_assembly(MSICOMPONENT *) DECLSPEC_HIDDEN; extern IAssemblyEnum *msi_create_assembly_enum(MSIPACKAGE *, const WCHAR *) DECLSPEC_HIDDEN; diff --git a/dlls/msi/package.c b/dlls/msi/package.c index bfbbaadae1b..f09d0c6fc92 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -1502,13 +1502,6 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, DWORD dwOptions, MSIPACKAGE **pPackage) package->log_file = CreateFileW( gszLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - if (!msi_init_assembly_caches( package )) - { - ERR("can't initialize assembly caches\n"); - msiobj_release( &package->hdr ); - return ERROR_FUNCTION_FAILED; - } - /* FIXME: when should these messages be sent? */ data_row = MSI_CreateRecord(3); if (!data_row)