Use New 64 bit Features On Older 32 bit Windows

By Bill Pytlovany

Use New 64 bit Features On Older 32 bit Windows

One of the challenges for programmers is to continue to support all customers and still take advantage of new features available in operating systems. Instead of managing multiple code bases I’ve learned to support older versions while still taking advantage of new features. Recently, I learned it the hard way.

I thought it would be useful to share an example of code that I currently use that not only supports 64 bit Windows, but uses new functions that aren’t supported by the still popular 32 bit Windows XP.

1. Accessing 32 and 64 bit Registry Locations
In this example, I wanted to use a new function that Microsoft enhanced for 64 bit Windows. To remove registry keys I’ve used the following function.

RegDeleteKey( HKEY, LPCSTR)

The registry in 64 bit Windows has a special tree that is used to store registry values used by 32 bit applications. Many values under the global software registry is automatically redirected to be saved under the following key. See List of Keys

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

Most applications that store options in the registry don’t need to know if their registry calls are redirected. A utility like my WinPatrol absolutely needs to know which registry location is used and when Windows is redirecting values. Using the actual location is crucial for detecting malware or modifying legitimate software which may behave badly.

To allow programmers access to either the normal registry location or Wow6432Node many registry functions have been enhanced to specify the real location instead of being reflected or redirected. One new replacement function is

RegDeleteKeyEx( HKEY, LPCTSTR, REGSAM, DWORD);

The REGSAM value can be either KEY_WOW64_32KEY(0x200) for removing a key in the Wow6432Node tree used by 32 bit applications or KEY_WOW64_64KEY(0x100) which doesn’t get redirected.

Article continued here

This post is excerpted with Bill’s permission from his blog

Stop Responding to Threats.
Prevent Them.

Want to get monthly tips & tricks?

Subscribe to our newsletter to get cybersecurity tips & tricks and stay up to date with the constantly evolving world of cybersecurity.

Related Articles