Professional Documents
Culture Documents
Volume I, Issue 11
Binary Compatibility
WOW64 provides a set of 32-bit system binaries in a directory called SysWOW64. This
directory contains DLLs, EXEs, OCXs (Object Linking and Embedding custom
controls), and other files that 32-bit applications expect to find. Most of these binaries
are identical to their counterparts on 32-bit Windows and do not talk directly to the
kernel.
Some of these binaries require specific knowledge
of WOW64 because they need to share memory
with 64-bit areas of the operating system. As a
result, they were modified slightly from their 32-bit
Windows counterpart. Among these modified
libraries are kernel32.dll, ntdll.dll, user32.dll,
imm32.dll, gdi32.dll, and rpcrt4.dll.
To prevent 32-bit applications from linking with 64-bit applications, WOW64 intercepts
all file system accesses and redirects any that are made to the system32 directory. This
process works very well because every call will be intercepted, so even hardcoded
references to DLLs will be redirected to the correct 32-bit library.
Similarly, though using a different technique, 32-bit applications and 64-bit applications
are installed by default to different versions of the Program Files directory. 64-bit
Issues 5 and 6 of the 64-bit Insider newsletter discuss file system redirection in more
detail.
Registry Redirection
The registry contains information about many
aspects of the operating system. In particular,
the registry contains lists of all the COM
objects registered with the operating system.
WOW64 separates the 32-bit and 64-bit COM
registrations by maintaining two distinct
branches of some registry parts. However,
because some COM objects can be loaded out-
of-process, registry accesses must be carefully redirected.
Registry redirection happens when a 32-bit application tries to load a COM object in-
process. If there is no registered 32-bit version of the COM object, the application is
told that no such object exists— even if a 64-bit version is available. The same thing
happens when a 64-bit application tries to load a COM
object. During registration, the COM object will be
“ Registry redirection registered in the correct branch of the registry, depending
happens when a 32-bit on whether it is a 32-bit or 64-bit COM object.
application tries to load a
COM object in-process. If Registry redirection is not enough when out-of-process
there is not a registered COM objects have been registered or loaded by an
32-bit version of the COM application. An out-of-process COM object can be loaded
object, the application is by any application, regardless of whether it is 32-bit or
told that no such object 64-bit. A 32-bit application can safely load a 64-bit COM
exists— even if a 64-bit object out-of-process because, now, all communication is
version is available.” through remote procedure calls. Branches can now be
copied between the 32-bit and 64-bit branches as
required. Issue 7 of this newsletter discusses he clever
logic that makes this copying possible when we talk
about how COM works in 64-bit Windows.
Special flags inside the assembly of .NET applications indicate the following:
If the application contains any native code.
If the application loads any 32-bit libraries.
If the application needs to run as a 32-bit application.
If the assembly does not explicitly (through the flags mentioned here) or implicitly
(through the format of the executable) specify which runtime it needs, then the
operating system will assume that the assembly is not aware of 64-bit Windows and will
load it into the 32-bit runtime. Many assemblies that were compiled with older versions
of the .NET compilers did so. With newer compilers, the assembly is run in 64-bit
runtime unless it is marked explicitly as requiring the 32-bit runtime.
The Global Assembly Cache (GAC) is aware of the differences between 32-bit and 64-
bit assemblies. Consequently, the GAC allows you to have two DLLs that have the
same name and the same GUID, but have been compiled for different architectures.
When you load an assembly from the GAC, it will use the most suitable DLL depending
on the architecture of the client application.
Summary
WOW64 provides a transparent layer between 32-bit Windows applications and the 64-
bit operating system. This layer allows 32-bit applications to run seamlessly in 64-bit
Windows. WOW64 provides special system libraries so that the 32-bit applications can
run, and also provides alternative sections, both in the registry and in the file system, to
keep 32-bit and 64-bit applications working without conflicts.