[WINESYNC] msi: Take architecture into account when accessing the shared dll reference count.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 5b6bf621cdc0b67528e2f0312d0a89d7cdfce5a7 by Hans Leidekker <hans@codeweavers.com>
This commit is contained in:
winesync 2022-03-13 01:23:58 +01:00 committed by Mark Jansen
parent 92a82b2faa
commit 4d61fb5224
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -3324,66 +3324,48 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp )
return NULL; return NULL;
} }
static HKEY openSharedDLLsKey(void) static HKEY open_shared_dlls_key( MSICOMPONENT *comp, BOOL create, REGSAM access )
{ {
HKEY hkey=0;
static const WCHAR path[] = static const WCHAR path[] =
{'S','o','f','t','w','a','r','e','\\', {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'W','i','n','d','o','w','s','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'S','h','a','r','e','d','D','L','L','s',0}; 'S','h','a','r','e','d','D','L','L','s',0};
return open_key( comp, HKEY_LOCAL_MACHINE, path, create, access );
RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey);
return hkey;
} }
static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll) static UINT get_shared_dlls_count( MSICOMPONENT *comp )
{ {
HKEY hkey; DWORD count, type, sz = sizeof(count);
DWORD count=0; HKEY hkey = open_shared_dlls_key( comp, FALSE, KEY_READ );
DWORD type; if (RegQueryValueExW( hkey, comp->FullKeypath, NULL, &type, (BYTE *)&count, &sz )) count = 0;
DWORD sz = sizeof(count); RegCloseKey( hkey );
DWORD rc;
hkey = openSharedDLLsKey();
rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz);
if (rc != ERROR_SUCCESS)
count = 0;
RegCloseKey(hkey);
return count; return count;
} }
static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count) static void write_shared_dlls_count( MSICOMPONENT *comp, const WCHAR *path, INT count )
{ {
HKEY hkey; HKEY hkey = open_shared_dlls_key( comp, TRUE, KEY_SET_VALUE );
hkey = openSharedDLLsKey();
if (count > 0) if (count > 0)
msi_reg_set_val_dword( hkey, path, count ); msi_reg_set_val_dword( hkey, path, count );
else else
RegDeleteValueW(hkey,path); RegDeleteValueW( hkey, path );
RegCloseKey(hkey); RegCloseKey(hkey);
return count;
} }
static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) static void refcount_component( MSIPACKAGE *package, MSICOMPONENT *comp )
{ {
MSIFEATURE *feature; MSIFEATURE *feature;
INT count = 0; INT count = 0;
BOOL write = FALSE; BOOL write = FALSE;
/* only refcount DLLs */ /* only refcount DLLs */
if (comp->KeyPath == NULL || if (!comp->KeyPath || comp->assembly || comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
comp->assembly ||
comp->Attributes & msidbComponentAttributesRegistryKeyPath ||
comp->Attributes & msidbComponentAttributesODBCDataSource) comp->Attributes & msidbComponentAttributesODBCDataSource)
write = FALSE; write = FALSE;
else else
{ {
count = ACTION_GetSharedDLLsCount( comp->FullKeypath); count = get_shared_dlls_count( comp );
write = (count > 0); write = (count > 0);
if (comp->Attributes & msidbComponentAttributesSharedDllRefCount) if (comp->Attributes & msidbComponentAttributesSharedDllRefCount)
write = TRUE; write = TRUE;
} }
@ -3426,18 +3408,18 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp )
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry ) LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
{ {
if (file->Component == comp) if (file->Component == comp)
ACTION_WriteSharedDLLsCount( file->TargetPath, count ); write_shared_dlls_count( comp, file->TargetPath, count );
} }
} }
/* add a count for permanent */ /* add a count for permanent */
if (comp->Attributes & msidbComponentAttributesPermanent) if (comp->Attributes & msidbComponentAttributesPermanent)
count ++; count ++;
comp->RefCount = count; comp->RefCount = count;
if (write) if (write)
ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount ); write_shared_dlls_count( comp, comp->FullKeypath, comp->RefCount );
} }
static WCHAR *build_full_keypath( MSIPACKAGE *package, MSICOMPONENT *comp ) static WCHAR *build_full_keypath( MSIPACKAGE *package, MSICOMPONENT *comp )
@ -3487,7 +3469,7 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
msi_free( comp->FullKeypath ); msi_free( comp->FullKeypath );
comp->FullKeypath = build_full_keypath( package, comp ); comp->FullKeypath = build_full_keypath( package, comp );
ACTION_RefCountComponent( package, comp ); refcount_component( package, comp );
if (package->need_rollback) action = comp->Installed; if (package->need_rollback) action = comp->Installed;
else action = comp->ActionRequest; else action = comp->ActionRequest;