How to access 64-bit registry from a 32-bit process?

983 views Asked by At

I have a program that integrates with explorer context menu. It works properly in Win32 but not in Win64. I've compiled the shell extension to Win64 but now I want to register that

The DLL file from the main program is 32 bit and I also want to keep the main program as 32 bit.

I want to access the CLSID key under in Wow6432Node under HKEY_CLASS_ROOT. I used RegDisableRef but it doesn't work

1

There are 1 answers

0
phuclv On

Just like how files are redirected by WoW64, registry accesses are also redirected

The registry redirector isolates 32-bit and 64-bit applications by providing separate logical views of certain portions of the registry on WOW64. The registry redirector intercepts 32-bit and 64-bit registry calls to their respective logical registry views and maps them to the corresponding physical registry location. The redirection process is transparent to the application. Therefore, a 32-bit application can access registry data as if it were running on 32-bit Windows even if the data is stored in a different location on 64-bit Windows.

Registry Redirector

You need to specify KEY_WOW64_64KEY on the samDesired parameter when accessing 64-bit registry keys with RegCreateKeyEx, RegDeleteKeyEx or RegOpenKeyEx

The following flags enable 32-bit applications to access redirected keys in the 64-bit registry view and 64-bit applications to access redirected keys in the 32-bit registry view. These flags have no effect on shared registry keys. For more information, see Registry Keys Affected by WOW64.

Flag name Value Description
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.
Windows 10 on ARM: This refers to the 32-bit ARM registry view for 32-bit ARM processes and the 32-bit x86 registry view for 32-bit x86 and 64-bit ARM64 processes.

Accessing an Alternate Registry View

However I think compiling the program in separate 32 and 64-bit versions will be easier. Most programs don't need to change when recompile. Moreover you'll still have to recompile the shell extension because 64-bit processes can't load 32-bit DLLs