Skip Menu |

This queue is for tickets about the Win32-TieRegistry CPAN distribution.

Report information
The Basics
Id: 45803
Status: open
Priority: 0/
Queue: Win32-TieRegistry

People
Owner: Nobody in particular
Requestors: dave [...] taylorcanyonranch.com
Cc: BOLDRA [...] boldra.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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.

This can happen if you are using 32-bit perl on a 64-bit windows system. http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-admin/3199723 104d97 Show quoted text
> "HKLM" => HKEY_LOCAL_MACHINE,
111,113d103 Show quoted text
> sub KEY_WOW64_64KEY () { 0x0100 } > sub KEY_WOW64_32KEY () { 0x0200 } >
118,119c108 Show quoted text
> KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY, > $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );
--- < KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" ); On Thu May 07 01:43:53 2009, dave@taylorcanyonranch.com wrote: Show quoted text
> I'm using the following simple code to parse through the Windows XP > registry. Although most everything works OK, I get numerous situations
where Show quoted text
> $key = $Registry->{$keyname} does not return a reference pointer
(ref($key) Show quoted text
> 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 Show quoted text
> 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 Show quoted text
> 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 > > } >
I've discovered a problem with this patch: On 32-bit Windows 2000 systems, connecting to a remote registry using the "//hostname/rootkey/..." syntax doesn't work. This includes "//localhost/rootkey/" . This isn't an issue on Windows 2003 or later. I haven't found a satisfactory workaround. On Thu Oct 22 08:44:24 2009, BOLDRA wrote: Show quoted text
> This can happen if you are using 32-bit perl on a 64-bit windows system. > > > http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-admin/3199723 > > 104d97
> > "HKLM" => HKEY_LOCAL_MACHINE,
> 111,113d103
> > sub KEY_WOW64_64KEY () { 0x0100 } > > sub KEY_WOW64_32KEY () { 0x0200 } > >
> 118,119c108
> > KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY, > > $Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );
> --- > < KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls, > "${PACK}::_Roots" ); > > > On Thu May 07 01:43:53 2009, dave@taylorcanyonranch.com wrote:
> > 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 Show quoted text
> > 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 > > > > } > >
> >