[WINESYNC] msi: Only delete empty registry keys in delete_key().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 91e418073f64368110a9339d17fad36ad26c1a7f by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
winesync 2022-03-12 16:34:04 +01:00 committed by Mark Jansen
parent cdbd0095f0
commit ba86f76417
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -2988,12 +2988,27 @@ static UINT ACTION_WriteRegistryValues(MSIPACKAGE *package)
return rc;
}
static int is_key_empty(const MSICOMPONENT *comp, HKEY root, const WCHAR *path)
{
DWORD subkeys, values;
HKEY key;
LONG res;
key = open_key(comp, root, path, FALSE, get_registry_view(comp) | KEY_READ);
if (!key) return 0;
res = RegQueryInfoKeyW(key, 0, 0, 0, &subkeys, 0, 0, &values, 0, 0, 0, 0);
RegCloseKey(key);
return !res && !subkeys && !values;
}
static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path )
{
LONG res = ERROR_SUCCESS;
REGSAM access = 0;
WCHAR *subkey, *p;
HKEY hkey;
LONG res;
access |= get_registry_view( comp );
@ -3006,10 +3021,15 @@ static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path )
if (!p[1]) continue; /* trailing backslash */
hkey = open_key( comp, root, subkey, FALSE, access | READ_CONTROL );
if (!hkey) break;
if (!is_key_empty(comp, hkey, p + 1))
{
RegCloseKey(hkey);
break;
}
res = RegDeleteKeyExW( hkey, p + 1, access, 0 );
RegCloseKey( hkey );
}
else
else if (is_key_empty(comp, root, subkey))
res = RegDeleteKeyExW( root, subkey, access, 0 );
if (res)
{
@ -3024,17 +3044,14 @@ static void delete_value( const MSICOMPONENT *comp, HKEY root, const WCHAR *path
{
LONG res;
HKEY hkey;
DWORD num_subkeys, num_values;
if ((hkey = open_key( comp, root, path, FALSE, KEY_SET_VALUE | KEY_QUERY_VALUE )))
{
if ((res = RegDeleteValueW( hkey, value )))
TRACE("failed to delete value %s (%d)\n", debugstr_w(value), res);
res = RegQueryInfoKeyW( hkey, NULL, NULL, NULL, &num_subkeys, NULL, NULL, &num_values,
NULL, NULL, NULL, NULL );
RegCloseKey( hkey );
if (!res && !num_subkeys && !num_values)
if (is_key_empty(comp, root, path))
{
TRACE("removing empty key %s\n", debugstr_w(path));
delete_key( comp, root, path );