FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH32 cannot read 64bit Registry Keys
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 01:34 PM

As subject.

To do so, you need to add the KEY_WOW64_64KEY flag to RegOpenKeyEx while now it only uses KEY_ALL_ACCESS in \source\winapi\regedit.c
Please see http://msdn.microsoft.com/en-us/library ... 85%29.aspx

I suggest adding a 4th optional parameter to RegOpenKey() to pass the desired additional flags when accessing the registry (so that the program CAN enable KEY_WOW64_64KEY if IsWow64() - the function I posted yesterday)

Thanks,
Davide

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 03:05 PM

Davide,

We will be back in our offices in just few days as we are having a (very short) holidays :-)

As soon as we get back we will review it, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 05:09 PM
Antonio,
Antonio Linares wrote:As soon as we get back we will review it, thanks

ok, no problem.
The same problem is in reg32.prg too.

Have a nice holiday.
Davide
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 05:51 PM
Davide wrote:The same problem is in reg32.prg too.

and perhaphs some top definitions are wrong in that prg:
Code (fw): Select all Collapse
***
*** Not sure how to handle the &'s and ~'s
***

#define KEY_READ        25 // ((STANDARD_RIGHTS_READ +  KEY_QUERY_VALUE + KEY_ENUMERATE_SUB_KEYS +  KEY_NOTIFY) & (~SYNCHRONIZE))
#define KEY_WRITE        6 // ((STANDARD_RIGHTS_WRITE +  KEY_SET_VALUE +  KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE))
#define KEY_EXECUTE     25 // ((KEY_READ) & (~SYNCHRONIZE))
#define KEY_ALL_ACCESS  63 // ((STANDARD_RIGHTS_ALL +  KEY_QUERY_VALUE +  KEY_SET_VALUE +  KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS +  KEY_NOTIFY +  KEY_CREATE_LINK) & (~SYNCHRONIZE))


For example KEY_ALL_ACCESS is 0xF003F, which is 983103, not 63 : Math calc. explained at http://www.the-mindseye.co.uk/DllBinder ... ents.shtml

Hi,
Davide
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 06:29 PM
Davide

Try this way


Code (fw): Select all Collapse
#define KEY_READ        nAnd( nOr( STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS,  KEY_NOTIFY ), nNot( SYNCHRONIZE ) )
#define KEY_WRITE       nAnd( nOr( STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY ), nNot( SYNCHRONIZE ) )
#define KEY_EXECUTE     nAnd( KEY_READ, nNot( SYNCHRONIZE ) )
#define KEY_ALL_ACCESS  nAnd( nOr( STANDARD_RIGHTS_ALL, KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY, KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, KEY_CREATE_LINK ), nNot( SYNCHRONIZE ) )
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 07:06 PM
Dear Daniel,
Daniel Garcia-Gil wrote:Try this way

looks like it works, thanks.

Please find below a modified Treg32 class handling 64bit registry entries (by a 4th parameter "l64bit" in method New() that, if enabled, adds the KEY_WOW64_64KEY to the flags).

Functions in regedit.c still needs similar fixes.

Hi,
Davide
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 08:05 PM

Thanks Davide

we will check yours modifies very soon...

the source code posted by you in last thread was suppressed, we can not to publish a entire class, only show partial code to modify

Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sat Aug 14, 2010 09:29 PM
Dear Daniel,
Daniel Garcia-Gil wrote:the source code posted by you in last thread was suppressed, we can not to publish a entire class, only show partial code to modify

oh, ok! I'll keep it in mind in future.

Hi,
Davide
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Sun Aug 15, 2010 07:04 PM
Davide...

Now, fallow your purpose with new function to detect 64bit OS and try maintain support in 32Bit applications running under 64Bit OS it are changes:

before define CLASS TReg32

Code (fw): Select all Collapse
#ifndef _WIN64
#define KEY_WOW64_64KEY If( IsWin64(), 256, 0 )  
#else
#define KEY_WOW64_64KEY 0  
#endif /*_WIN64*/


and change all call to
Code (fw): Select all Collapse
RegOpenKeyEx( nKey, cRegKey, KEY_ALL_ACCESS, @nHandle )


for this
Code (fw): Select all Collapse
RegOpenKeyEx( nKey, cRegKey, KEY_ALL_ACCESS + KEY_WOW64_64KEY, @nHandle )
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Mon Aug 16, 2010 09:14 AM

Daniel,

in my modified class I addedd a 4th parameter in method new() because if FWH32 is running on WIN64, you MAY want to access the 32bit mirrored registry entries (like it does now), or you MAY want to access the 64bit ones (installed programs may have different values in 64/32 bit registries). Both things are possible only by adding a parameter to manage programmatically.

Hi,
Davide

Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Mon Aug 16, 2010 10:29 AM

Please see also to this topic when code of Treg is to modified:

viewtopic.php?f=3t=19331

&

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Mon Aug 16, 2010 11:08 AM
Davide wrote:Daniel,

in my modified class I addedd a 4th parameter in method new() because if FWH32 is running on WIN64, you MAY want to access the 32bit mirrored registry entries (like it does now), or you MAY want to access the 64bit ones (installed programs may have different values in 64/32 bit registries). Both things are possible only by adding a parameter to manage programmatically.

Hi,
Davide


What version do you use...??

one year ago the class and function was modified
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM

Re: FWH32 cannot read 64bit Registry Keys

Posted: Tue Aug 17, 2010 12:53 AM
Daniel,
Daniel Garcia-Gil wrote:What version do you use...??
one year ago the class and function was modified

I'm still on FWH905 but, unless you've already provided that optional flag, the need is independent by the programming language/version.

As you can see at http://msdn.microsoft.com/en-us/library ... 85%29.aspx By default, a 32-bit application running on WOW64 accesses the 32-bit registry view and a 64-bit application accesses the 64-bit registry view.

The problem is that, for example the HKLM/Software tree is DIFFERENT on the 2 registries, and actually FWH32 can read just the 32bit one (a 64bit-only program installed on Win64 cannot be found in the 32bit registry tree, even though the FWH32 program could shellexecute it without problems). That's why I modified Treg32 to read EVEN the 64bit registry (if you specifically want to do it in the New() clause)

Hi,
Davide

P.S.: The same additional parameter is needed even in the registry functions included in \source\winapi\regedit.c

Continue the discussion