I am experiencing that 32-bit Win32 console applications are loading the 64-bit version of kernel32.dll on one specific machine which is running Windows Server 2012 R2 Standard.
Using Dependency Walker with a simple HelloWorld application it looks like this:
It correctly loads the 32-bit kernel32 on other machines.
The value of PATH seems to be if not identical so at least including the relevant paths in exactly the same order on the different machines.
According to this page from Microsoft, the search order for DLLs is:
- The directory where the executable module for the current process is located.
- The current directory.
- The Windows system directory. The
GetSystemDirectoryfunction retrieves the path of this directory. - The Windows directory. The
GetWindowsDirectoryfunction retrieves the path of this directory. - The directories listed in the
PATHenvironment variable.
I am guessing that on this specific machine GetSystemDirectory returns the path to Windows/system32 instead of Windows/SysWOW64 or that the mapping from system32 to SysWOW64 for 32-bit processes are not working properly but these are only qualified guesses.
Any idea what is causing this behaviour?


\KnownDlls32\kernel32.dllsection. it will be used - RbMm