Access to 64-bit registry from Haskell

I have a windows program in Haskell (hence the 32-bit version). I want to access a 64-bit registry view. The Windows API says to use RegOpenKeyExOR in KEY_WOW64_64KEY( 0x200). (I use the standard Haskell bindings to the Windows APIs that come with the Haskell platform.)

In my program, this ends:

  import qualified System.Win32.Registry as W32
  import qualified System.Win32.Types    as W32
  ...
      let kEY_WOW64_64KEY = 0x200 -- has no binding in the library currently
      let regSam = kEY_WOW64_64KEY .|. ... other flags
      bracket (W32.regOpenKeyEx rootCode kname regSam) W32.regCloseKey $ \k -> ...

However i get an exception RegOpenKeyEx: invalid argument (The system cannot find the file specified.)

Call verification in Process Monitor displays the following output: enter image description here

The API call somehow ended up dropping the flag and moving into a subtree Wow6432Node. Also illustrated, even though the event referencing to RegOpenKey, I think it actually fires RegOpenKeyEx, as shown in the event stack (and the binding error message).

?

!

+4
1

:

KEY_WOW64_64KEY 0x0100  
KEY_WOW64_32KEY 0x0200  

:

let kEY_WOW64_64KEY = 0x200

, 32- . :

let kEY_WOW64_64KEY = 0x100
+5

Source: https://habr.com/ru/post/1540291/


All Articles