| Store | Cart

TieRegistry and 64 bit registry (x64)

From: Paul Jansen <vla...@yahoo.com.au>
Wed, 19 Jul 2006 01:28:26 +1000 (EST)
(sorry about the double post. I posted this same
message with an incorrect subject. Hopefully a more
relevant subject will make it easier for people when
searching the archives in future).

I'm trying to access a 64 bit registry path on a Win64
box and I came across this message while seaching the
archives.
It's from Jan 26 2006.
I've had a look through CPAN and I can't see any 
reference to KEY_WOW64_64KEY in the version of
Win32::TieRegistry that I find up there (0.25) even
though it was last updates in March 2006.
Is there an update somewhere else that I'm missing?

Thanks,
PJ

* * * * *

Anthony Okusanya wrote:

>  Hi all>        I have a utility I wrote using ActivePerl. It
is used to install 
applications and hotfixes on Windows servers. I am
trying to modify this 
to work with the 64bit version of Windows 2003. The
problem is that due to 
the registry re-direction that 64it uses to maintain
32bit compatibility, 
my script is not reading the registry keys properly.
>  Here is a sample of my script. the CHKPATCH
subroutine is used to test 
for the existence of a patch
>  e.g to determine if KB896424 is installed I simply
call 
CHKPATCH("KB896424").
>  On 64bit, this utility does not read the registry
key listed below 
because its running in 32 bit mode 
>  even though I can see the key when I run Regedit
from the server.
>  >  use Win32::TieRegistry(Delimiter=>"/");>  .......>  sub CHKPATCH>  {>      my $hotfix;>      if($hotfix
=$Registry->{"LMachine/SOFTWARE/Microsoft/Windows 
NT/CurrentVersion/HotFix/$_[0]"})
>      {>          return 1;>      }>      else>      {>        return 0;>      } >  >  }>  >  Sorry for Rambling on and on but if anyone has any
ideas I would be most 
appreciative 

**********
In my search for a solution to the problem I was
having accessing 64bit 
registry view on a 64bit Windows OS
I reviewed Microsoft's information on accessing an
alternate registry view 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win64/win64/accessing_an_a
lternate_registry_view.asp)
Microsoft's 64bit registry access now defines the
following constants

KEY_WOW64_64KEY 0x0100 Access a 64-bit key from either
a 32-bit or 64-bit 
application. 
KEY_WOW64_32KEY 0x0200 Access a 32-bit key from either
a 32-bit or 64-bit 
application. 

I also reviewed the documentation of Tye McQueen's
Win32::TieRegistry 
module and
added the following lines of code to the
TieRegistry.pm file  to use the 
above constants

sub KEY_WOW64_64KEY () { 0x0100}
sub KEY_WOW64_32KEY () { 0x0200}

Finally I changed the following code in TieRegistry.pm
to include 64bit 
registry access by Oring (|) the above constants with
KEY_READ

=======Original=================
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS
FLAGS ROOTS )}= (
    "NONE", "", [], "\\", "\\",
    KEY_READ|KEY_WRITE, $Flag_HexDWord|$Flag_FixNulls,
"${PACK}::_Roots" 
);
=================================

=======Updated===========
# Basic master Registry object:
$RegObj= {};
@$RegObj{qw( HANDLE MACHINE PATH DELIM OS_DELIM ACCESS
FLAGS ROOTS )}= (
    "NONE", "", [], "\\", "\\",
   
KEY_READ|KEY_WRITE|KEY_WOW64_64KEY|KEY_WOW64_32KEY, 
$Flag_HexDWord|$Flag_FixNulls, "${PACK}::_Roots" );

I know this probably isnt the best way to make these
changes and but it 
did the trick
I am able to use this script on both Win32 and x64
windows systems to 
access the registry.
I am copying Tye on this email. I hope an updated
version of the module 
will be released soon

Thanks everyone for the many replies on this problem

Tony B. Okusanya
Distributed Technology Group
"Live Life By Design And Not From Crisis to Crisis"



		
____________________________________________________ 
On Yahoo!7 
360 new features: Blog polls, visitor stats custom themes and more!
http://www.yahoo7.com.au/360

Recent Messages in this Thread
Paul Jansen Jul 18, 2006 03:28 pm