Improved logging by including registry path for packages found.

This commit is contained in:
László Valkó 2022-11-09 00:49:55 +01:00
parent 0f9795bf86
commit 2c0cdab529

View file

@ -836,13 +836,14 @@ sub read_pkg_patches ($$$)
}
}
sub read_packages ($$$$)
sub read_packages ($$$$$)
{
my ($packages, $registry, $wow6432, $userdata) = @_;
my ($packages, $key, $registry, $wow6432, $userdata) = @_;
foreach my $name ($registry->SubKeyNames) {
my $sub = $registry->{$name};
next unless defined $sub;
my $regname = $key.$name;
if ($userdata) {
$sub = $sub->{'InstallProperties'};
next unless defined $sub;
@ -867,7 +868,8 @@ sub read_packages ($$$$)
$winid = $8.$7.$6.$5.$4.$3.$2.$1.$12.$11.$10.$9.$16.$15.$14.$13.$18.$17.$20.$19.$22.$21.$24.$23.$26.$25.$28.$27.$30.$29.$32.$31;
}
my $inst = {
Name => $name,
Name => $name,
RegName => $regname,
WinID => $winid,
Publisher => $pub,
DisplayName => $dispname,
@ -948,32 +950,38 @@ sub read_installed_packages ($)
delete $$db{Changed};
my $packages = {};
my $uninst = $Registry->Open('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\', { Access => 'KEY_READ' });
my $key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\';
my $uninst = $Registry->Open($key, { Access => 'KEY_READ' });
if (! defined $uninst) {
print_log('global', ERROR, 'Cannot find registry entry: %s', 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall');
return undef;
}
read_packages($packages, $uninst, 0, 0);
$uninst = $Registry->Open('HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\', { Access => 'KEY_READ' });
read_packages($packages, $key, $uninst, 0, 0);
$key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\';
$uninst = $Registry->Open($key, { Access => 'KEY_READ' });
if (defined $uninst) {
read_packages($packages, $uninst, 1, 0);
read_packages($packages, $key, $uninst, 1, 0);
}
$uninst = $Registry->Open('HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\', { Access => 'KEY_READ' });
$key = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\';
$uninst = $Registry->Open($key, { Access => 'KEY_READ' });
if (defined $uninst) {
read_packages($packages, $uninst, 0, 0);
read_packages($packages, $key, $uninst, 0, 0);
}
$uninst = $Registry->Open('HKEY_CURRENT_USER\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\', { Access => 'KEY_READ' });
$key = 'HKEY_CURRENT_USER\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\';
$uninst = $Registry->Open($key, { Access => 'KEY_READ' });
if (defined $uninst) {
read_packages($packages, $uninst, 1, 0);
read_packages($packages, $key, $uninst, 1, 0);
}
my $specpackages = {};
my $products = $Registry->Open('HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\', { Access => 'KEY_READ' });
$key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\';
my $products = $Registry->Open($key, { Access => 'KEY_READ' });
if (defined $products) {
read_packages($specpackages, $products, 0, 1);
read_packages($specpackages, $key, $products, 0, 1);
}
$products = $Registry->Open('HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\', { Access => 'KEY_READ' });
$key = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\';
$products = $Registry->Open($key, { Access => 'KEY_READ' });
if (defined $products) {
read_packages($specpackages, $products, 1, 1);
read_packages($specpackages, $key, $products, 1, 1);
}
$$db{Installed} = $packages;
$$db{InstalledSpec} = $specpackages;
@ -1491,11 +1499,13 @@ sub match_package_def ($$$)
my $dispver = $$inst{DisplayVersion};
$dispver = defined $dispver && $dispver ne '' ? ' ('.$dispver.')' : '';
print_log('global', DEBUG4, 'Trying to match package %s%s%s%s to definition %s',
print_log('global', DEBUG4, 'Trying definition %s for package %s%s%s%s at %s',
$$def{description},
$dispname,
defined $$inst{SystemComponent} ? ' SC='.$$inst{SystemComponent} : '',
defined $$inst{WindowsInstaller} ? ' WI='.$$inst{WindowsInstaller} : '',
$dispver, $$def{description});
$dispver,
$$inst{RegName});
my $matchlist = $$def{'match'};
foreach my $matchentry (@$matchlist) {
my $expression = $$matchentry{expression};