Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does 32bit and 64bit DLLs link to the same C:\system32\kernel32.DLL?

I was sure 64bit DLL cannot link to 32bit DLL.

like image 961
pavelkolodin Avatar asked Feb 08 '12 11:02

pavelkolodin


People also ask

What is the difference between 32-bit and 64 bit DLL?

If the first DLL in the path is 32 bit and your app is 32 bit, then the DLL load will work. If the app is 64 bit, it will fail to load the DLL and the process will abort. If you want two DLLs to coexist on the system path, you need to give them unique file names.

Where do 64 bit DLLs go?

Under 32bit windows, this location is (typically) C:\WINDOWS\SYSTEM32. Under 64bit windows, it is C:\WINDOWS\SYSWOW64. Also under 64bit windows, the 64bit DLL shared location is C:\WINDOWS\SYSTEM32.

In what full path can we find 32-bit libraries on a 64 bit system?

On a 32-bit computer, all 32-bit programs store their files in C:\Program Files, and the system-wide library location is C:\System32. On a 64-bit computer, 64-bit programs store their files in C:\Program Files, and the system-wide C:\Windows\System32 folder contains 64-bit libraries.

Can a 64 bit DLL call a 32-bit DLL?

On 64-bit Windows, a 64-bit process cannot load a 32-bit dynamic-link library (DLL).


1 Answers

Wow64 has a file redirector. It has the same named dlls but are stored in the appropriate location. The concept is explained at http://msdn.microsoft.com/en-us/library/aa384187(v=vs.85).aspx

The %windir%\System32 directory is reserved for 64-bit applications. Most DLL file names were not changed when 64-bit versions of the DLLs were created, so 32-bit versions of the DLLs are stored in a different directory. WOW64 hides this difference using a file system redirector.

In most cases, whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64. Access to %windir%\lastgood\system32 is redirected to %windir%\lastgood\SysWOW64. Access to %windir%\regedit.exe is redirected to %windir%\SysWOW64\regedit.exe.

like image 75
Sania Programmer Avatar answered Oct 16 '22 03:10

Sania Programmer