How Windows 7 / Vista 64 Support 32 bit Applications

 
Introduction

This article provides an overview of the Windows on Windows 64 (WOW64) sub-system and associated techniques that support 32 bit applications under Windows 7 / Vista 64.

The Enterprise, Ultimate and Professional versions of 64 bit Windows 7 also support a 32 bit Windows XP virtual machine, which is available as optional download. Your PC must support hardware level virtualisation to use this facility.

The purpose of this add on, generally referred to as XPM, is to provide an environment that will support legacy hardware and software that will not work under Windows 7. Having tested XPM, I would advise that you only use it as a last resort. It will provide legacy support if you have no other options but, compared to other virtualisation products, performance is disappointing and the default configuration raises a number of security issues.

Discussion

Under Windows 7 / Vista 64, 32-bit applications run on top of an emulation of a 32 bit operating system that is called Windows on Windows 64, or WOW64 for short.  WOW64 intercepts all operating system calls made by a 32 bit application.

For each operating system call made, WOW64 generates native 64 bit system calls, converting 32 bit data structures into 64 bit aligned structures. The appropriate native 64 bit system call is passed to the operating system kernel, and any output data from the 64 bit system call is converted into a format appropriate for the calling application before being passed back.

Like 32 bit applications, WOW64 runs in user mode so any errors that occur in translating an operating system call will only occur at that level. The 64 bit operating system kernel cannot be affected.

Since WOW64 runs in user mode, all 32 bit application code must also run in user mode. This explains why 32 bit kernel mode device drivers and applications that rely on them, will not work under Windows 7 / Vista 64.

The WOW64 emulator consists of the following DLLs:

  • Wow64.dll. This provides the core emulation infrastructure and the links to the Ntoskrnl.exe entry-point functions.
  • Wow64Win.dll provides links to the Win32k.sys entry-point functions.

Along with the 64-bit version of Ntdll.dll, these are the only 64-bit binaries that can be loaded into a 32-bit process.

At startup, Wow64.dll loads the 32 bit version of Ntdll.dll and runs its initialization code, which loads all necessary 32 bit DLLs. Almost all 32 bit DLLs are unmodified copies of the original 32 bit Windows binaries. However, some of these DLLs have been modified to behave differently on WOW64 than they do on 32 bit Windows. This is usually because they share memory with 64 bit system components.

In addition to handling operating system calls, the WOW64 interface needs to ensure that files and registry settings for 32 bit applications are kept apart from those for 64 bit applications. To achieve this two mechanisms are used, File and Registry Redirection.

File Redirection

This ensures that there are separate folders for program and operating system files for 32 and 64 bit applications.

32 bit applications files are installed into

C:\Program Files(x86)

32 bit system files are installed into

C:\WINDOWS\SysWOW64

For 64 bit applications, files are installed to

C:\Program Files

and

C:\WINDOWS\SYSTEM32

The WOW64 file redirector ensures that requests from 32 bit applications to open files in C:\Program Files or C:\WINDOWS\SYSTEM32 are redirected to the appropriate 32 bit directories.

There is one issue with file redirection that users and developers should be aware of.

Many 64 bit applications still use 32 bit installation routines. To ensure that an application is installed correctly, i.e. to C:\Program Files, the installation routine should make an operating system call to temporarily suspend the WOW64 file redirector. After installation another operating system call needs to be made to re-enable the redirector. If this approach isn't followed then the application will be installed to C:\Program Files (x86). A classic example of this is the 64 bit development version of Firefox 3.5, codenamed Shiretoko, which is installed to C:\Program Files(x86)\Shiretoko. Firefox still functions correctly, the only thing you can't do is change the icon for the application.

Registry Redirection

Registry keys specific to 32-bit applications are redirected from

HKEY_LOCAL_MACHINE\Software

to

HKEY_LOCAL_MACHINE\Software\WOW6432Node

You may also occasionally see Registry entries under

HKEY_CURRENT_USER\Software\WOW6432Node

although this is unusual.

This approach allows both the 32 bit and 64 bit versions of an application to be installed side-by-side without overwriting each other’s settings.

Some redirected keys and/or values are also reflected. This means that if a 32 bit application makes a change to the redirected section of the registry, that change is also made to the 64 bit part of the registry, and vice-versa. Key reflection uses a policy of last writer wins. For example, if I:

  1. Install a 32 bit application that associates itself with the file extension XYZ.
     
  2. Install the 64 bit version of this application that associates itself with the file extension XYZ.
     
  3. Install another 32 bit application that associates itself with the file extension XYZ.

Double-clicking on a file with the extension XYZ in Explorer would load the application installed in step 3, as it was the last one to associate itself with this extension.

All of this is done transparently for 32 bit applications by WOW64, which, in intercepting calls to the operating system, detects references to file paths and registry keys and maps them accordingly.

Code Injection

Code injection is used to add functionality to existing applications. The majority of shell extensions rely on this technique to add themselves to Explorer.

Under 64 bit Windows it is not possible to inject 32 bit code into a 64 bit process, nor is it possible to inject 64 bit code into a 32 bit process. This explains why most 32 bit shell extensions do not work under Windows 7 / Vista 64.

Summary

Most 32 bit applications will run quite happily under Windows 7 / Vista 64. The main exceptions are:

  1. 32 bit device drivers.
     
  2. Applications that cannot function without the 32 bit device drivers that they use. Prime examples are antivirus, antimalware and firewall applications.
     
  3. Application extensions that rely on code injection into, for example, Explorer.

Some applications may work with reduced functionality. These include uninstallers, registry cleaners and tweaking programs, amongst others, since they only have access to that part of the Registry made visible to them by WOW64.

Related Links
32 bit and 64 bit explained
Best Free Windows 7 / Vista 64 bit Software
Microsoft Developer Network - Disabling the WOW64 File System Redirector
Microsoft Developer Network - Running 32 bit Applications under 64 bit Windows
Have Your Say

There are five ways to send feedback: registered users can contact me directly here or in the forum under Contact Info. Registered users may also post in the forum. Anyone can post a comment at the bottom of this page. Finally, please help us by rating this article.

This article is maintained by volunteer editor Rik Mayell.

Tags

Windows on Windows 64, WOW64, 32 Applications under 64 bit Windows, 64 bit Windows Vista, 64 bit Windows 7

Back to the top of the article.

 

4.61111
Average: 4.6 (36 votes)
Your rating: None

Just one error in the otherwise fantastic article - the windows XP virtual machine is available to Professional also, not just Enterprise/Ultimate.

I say "Enterprise/Ultimate" since they have the exact same feature set, Enterprise is just able to be activated from an in-house activation server instead of Microsoft's, and is only available in volume license form.

Many thanks for pointing out the error which has been corrected.

Rik Mayell - Article Editor

Are there any disadvantages to 64bit other than price?

In my opinion, the most typical disadvantage is the compatibility or ability to run 32 bit applications, until such time that most applications are developed to fully support 64 bits.

Even with the support of hardware virtualisation, some applications are still not working well on a 64-bit machine, as noted by the editor.

Well, I think most major reputable software has a 64bit version, doesn't it?

Avira AntiVir, Comodo firewall, Firefox...

Comodo Internet Security is available as a native 64 bit application. Avira is a hybrid application, most of the code is still 32 bit, only the kernel mode device driver has been ported to 64 bit and, as required by Windows 7 / Vista, is digitally signed (as mentioned by Peter.) 64 bit Firefox is still under development and, for a number of reasons beyond the control of the developers, is not suitable for day to day use. The same applies to Thunderbird.

Some applications, such as SuperAntiSpyware, are still completely 32 bit, although a hybrid version may be made available later this year.

For details of 64 bit freeware refer to our review Best Free Windows 7 / Vista 64 bit Software.

Rik Mayell - Article Editor

Although much reputable sware has versions that run in 64-bit mode, very few are true 64-bit versions. There's also the problem of legacy hardware support, & "signed" drivers.

Another shining example of the Microsoft logic :


"32 bit system files are installed into
C:\WINDOWS\SysWOW64
[...]
For 64 bit applications, files are installed to
C:\WINDOWS\SYSTEM32"

...just like the idea of clicking on the start button to stop windows.

I've read many articles, forum and blog posts about this issue yet never come across anything that really sold the idea to me. Piecing together some common bits, I've arrived at an explanation that I'm happy to live with, but I'm not assuming it's correct.

Despite requests from Microsoft, many independent software vendors have hard coded \WINDOWS\SYSTEM32 into their applications despite the fact that there is no need to. I assume Microsoft felt that this was likely to still be the case for applications ported to 64 bit. I've checked, and one of the commercial 64 bit applications I use still contains this hard coded path.

In an ideal world we would have had 32 bit operating system code stored in

C:\WINDOWS\SYSTEM32

and 64 bit code in, say,

C:\WINDOWS\SYSTEM64

If this were the case, to handle 64 bit applications with references to SYSTEM32, some sort of file redirector would have been required. Unlike the WOW64 file redirector, which runs in user mode, the 64 bit redirector would have needed to be kernel based to handle references in drivers, etc. Naturally, if a fault were to occur in this hypothetical 64 bit file redirector, a security hole or BSOD could result.

Presumably Microsoft decided that the strange naming convention was preferable to exposing the kernel to any additional risk.

Who knows?

If anyone does know the correct reason, please post a comment, along with your name and I'll add the details to the article citing you as the source.

Rik Mayell - Article Editor

In the Sun world 32 bit goes into unlabled directories (/usr/lib) and 64bit into specific directories (/usr/lib64). There are exceptions, thanks Oracle, that for the 64 bit version reverse this ($ORACLE_HOME/lib and $ORACLE_HOME/lib32).

To my mind the Sun method is the one to use since most apps are still 32 bit so they don't need to change anything between 32 bit and 64 bit operating systems. If you want to build 64 bit version it's upto you to drop your files in the right place and use the correct versions of libraries.

The general model in UNIX land also seems better. The 64 bit OS installs both 64 and 32 bit libraries and so can run both 32 and 64 bit apps. You still need some matching though (64 bit Firefox needs 64 bit Java). Why can't MS do the same?

Further to my previous answer, I to find it bizarre that Microsoft did not lay down firm rules when they released the Software Development Kit for 64 bit XP. It would have been easy to specify that 64 bit system binaries 'live' in \WINDOWS\SYSTEM64 and 32 bit in \WINDOWS\SYSTEM32. If as a result your 64 bit application didn't work, tough.

Some might argue that they didn't want to annoy ISVs. Frankly, that didn't bother them when they made huge changes between the XP and Vista kernels, so why should this?

Unfortunately, nothing has changed with the arrival of Windows 7 so this appears to have been a missed opportunity that we will have to learn to live with.

Rik Mayell -Article Editor

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • Lines and paragraphs break automatically.
  • [node:123] - insert full text (themed by theme('node'))
    [node:123 body] - insert node's body
    [node:123 teaser] - insert node's teaser
    [node:123 link] - insert link to node
    [node:123 collapsed] - insert collapsed node's body
  • You may use [view:viewname] tags to display listings of nodes.

More information about formatting options