Sunday, January 24, 2010

D3D .dlls, and system32 vs. syswow64

This is nerdy, but i bet i'm not the only one who thinks this is going to be useful to dig up later. if you have questions, post them and i'll try to answer. time constraints limit me from cleaning this up right now. (TODO: cleanup post).

windows\system32 vs. windows\syswow64

WOW = windows on windows. on 64 bit systems, 32 bit .dlls go into the syswow64 directory. its for emulation of 32bit functionality on a 64 bit system and includes some other windows glue to make this happen, like on a 64 bit x86 microprocessor it switches it between 32 bit and 64 bit mode when needed.

for d3d11ref.dll: if you are running an x86 (32 bit) binary, it will look in the syswow46 directory for the 32 bit .dll. if its not there, IT DOES NOT LOAD
THE ONE IN system32. this was verified by actually moving the working 32 bit d3d11ref.dll into system32, watching the .dlls that were loaded into the application in visual studio, it did not grab the .dll when it was moved. a 32 bit system will load from syswow64. if its not there it does not look for a 32 bit version in system32.

when running a 64 bit build of the same binary, the d3d11ref.dll was loaded in from sys32, and it would not load the one in from syswow64 even if it didn't have one in sys32.

syswow64 is part of the search path for 32bit systems, system32 is part of the search path for dlls for 64 bit systems. you will not pull in a same named file, even the right d3d11ref.dll binary from the wrong directory. this can be verified by watching the load modules window in visual studio as your application starts up.

the naming convention (system32 vs. syswow64) is done for compatibility reasons, and my specifics are related to figuring out search paths for d3d .dlls. did not verify this was a general rule of thumb for all .dlls.


Unknown said...

Hello Adam,

Like your article. I do have a question/sitution though..

I have a 64 bit system with 32 bit binaries of an application. My question is:

1. How does the system know that this binaries are 32 bit and have to look for dlls in Syswow64?

2. cmd.exe lies both in system32 as well as Syswow64? Does system automatically determines that which one to use to execute?

cialis online said...

Excellent point of view but later refined the period to two years. It is often incorrectly quoted as a doubling of transistors every 18 months.

pharmacy said...

Excellent thanks for the tips, I was having problems with the system since i change to the 64 bits version.