Escolar Documentos
Profissional Documentos
Cultura Documentos
Volume I, Issue 12
With the introduction of the Windows 64-bit operating system, some changes are
expected in regard to COM. For example, a ported library can run natively and be used
from any 64-bit application. However, with a 32-bit COM library, the operating system
must follow a set of rules to avoid mixing 32-bit and 64-bit code in the same process
space. Cross-platform dependencies are not permitted when using in-process
communication. There are many technical reasons for this situation, the most important
being:
Page Size and Exception Handling. There are a series of differences between
32-bit and 64-bit code exception handling. Also, a 32-bit Dynamic Link Library
(DLL) expects 4 KB pages and x86-style exception handling. On Itanium
Processor Family (IPF), the native page size is 8K, and WOW64 simulates 4 K
pages with assistance from the kernel memory manager and the processor.
But what about 32-bit COM libraries in Windows 64-bit, can they still be used?
Any person with COM experience knows that problems occasionally occur when a newer
version of a COM library that has been installed on a computer overwrites an older,
incompatible version (this happens enough that the
“ Registry redirection is the problem has become known as “DLL hell”). The problem
secret behind making it arises when the newer version has the same global unique
possible to have both a 32- identifier GUID and name as the previous one and, as a
bit and a 64-bit version of consequence, (in some cases) the application might try to
the same library registered load the wrong version of the library— with unpredictable
with COM.” results. You can register two libraries with the same
GUID and name, but the two target different platform
architectures— a situation that causes much confusion.
Registry redirection is the secret behind making it possible to have both a 32-bit and a
64-bit version of the same library registered with COM. Registry redirection is a feature
of WOW64 and makes sure that applications running under WOW64 always see the 32-
bit version of HKEY_LOCAL_MACHINE\Software that is stored under the
Wow6432node. Figure 2 demonstrates how the registry is structured to
separate information between 32-bit and 64-bit applications.
The registry redirector also helps locate the correct application and sets up inter-process
communications with an out-of-process library when a 32-bit application makes a COM
call to invoke a 64-bit library, or vice versa. However, it is not as simple as just dividing
32-bit and 64-bit COM calls and redirecting during registration/activation. There are a
series of rules that help prevent compatibility issues and enforce the already well-known
limitations regarding 32-bit and 64-bit code interoperation. These rules (listed below)
affect the HKEY_CLASSES_ROOT\CLSID branch of the registry, which is where COM
class identifiers and their handler DLLs are registered.
The values for InProcServer32 and InProcHandler32 are not reflected. This
rule helps prevent attempts to load a DLL of a different architecture into an
incompatible process type. For example, the rule prevents loading 32-bit DLLs
into a 64-bit process, and vice versa. These are the in-process libraries that we
observed previously with COMDemoProject.dll.
Note: The WOW64 registry reflector might change keys and values during the
reflection process to ensure they are correct. Therefore, 32-bit and 64-bit contents
can differ.
By using these rules, COM registry entries can be shared between 32-bit and 64-bit
applications without incurring the problems that result when attempts are made to mix
code that targets different platform architecture within the same process space.
o If yes, then the library can be used in-process, and you only need to re-
reference the new library and verify that no changes took place on the
interface.
o If yes, check with your independent software vendor (ISV) to see if it can
provide a 64-bit version of the library.
3. Was the COM library developed in-house and can you perform an immediate
migration to 64-bit? For example, enough time, money, and resources.
If you answered yes to any of these questions then, you will be able to continue using
your COM library in-process right away or as soon as it has been ported to 64-bit.
However, if you can ’t use your library in-process, there are several ways that you can use
it out-of-process. For example:
Providing more information about these techniques falls outside the immediate scope of
this newsletter, but you can learn more at: www.64advantage.com
Summary
There are many commercial and scientific applications that use COM, and it would be
unacceptable to introduce a new platform that required one to discard all existing
applications.