Subject: | Apparent Bug |
Date: | Wed, 6 May 2009 22:42:58 -0700 |
To: | <bug-Win32-TieRegistry [...] rt.cpan.org> |
From: | "David Taylor" <dave [...] taylorcanyonranch.com> |
I'm using the following simple code to parse through the Windows XP
registry. Although most everything works OK, I get numerous situations where
$key = $Registry->{$keyname} does not return a reference pointer (ref($key)
eq ''). It does not appear this should be happening.
The keys that do not have references appear normal in regedt32.exe, and a
regedit -e dump displays these keys and associated values normally. Just in
case, I ran NCleaner on the registry-which made no difference.
I'd be glad to learn that I am doing something wrong-any ideas?
Dave Taylor
use strict;
use warnings;
use Win32::TieRegistry;
select((select(STDOUT), $|=1)[0]);
select((select(STDERR), $|=1)[0]);
our @reghives = (
'HKEY_CLASSES_ROOT',
'HKEY_CURRENT_USER',
'HKEY_LOCAL_MACHINE',
'HKEY_USERS',
'HKEY_CURRENT_CONFIG'
);
my $separator = '===';
my $regoutfile = "\\cfauditbase\\programs\\dave.txt";
open(REGOUT,">$regoutfile") or die "could not open $regoutfile";
foreach my $hive (@reghives) {getkey($hive)}
close(REGOUT);
exit;
my $getkey_depth = 0;
sub getkey {
my $keyname = shift;
my $key = $Registry->{$keyname};
$getkey_depth++;
CASE: {
if (ref($key) ne 'Win32::TieRegistry') {
print REGOUT "$keyname$separator" . "[invalid key reference]\n";
last CASE;
}
if (!defined $key) {
print REGOUT "$keyname$separator" . "[unaccessable due to
permissions]\n";
last CASE;
}
for (keys %$key) {
CASE2: {
if (m<^\\(.*)$>s) {
my $valuename = $1;
my $hexstr = $key->{$valuename};
if ($hexstr) { # some values are uninitialized...
$hexstr =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg; # convert
value to hex
if ($valuename eq '') {$valuename='Default'} # default
values are blank...
print REGOUT "$keyname\\$valuename$separator$hexstr\n";
}
else {print REGOUT "$keyname\\$valuename$separator" .
"[uninitialized value]\n"}
last CASE;
}
if (m<^(.*)\\>s) {
my $newkey = "$keyname\\$1";
getkey($newkey);
last CASE2;
}
}
}
}
if (++$getkey_depth == 0) {undef $key}
return
}
Message body is not shown because it is too large.