简体   繁体   English

Win32 32位进程加载64位kernel32.dll

[英]Win32 32-bit process loads 64-bit kernel32.dll

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. 我遇到32位Win32控制台应用程序正在一台运行Windows Server 2012 R2 Standard的特定计算机上加载64位版本的kernel32.dll。

Using Dependency Walker with a simple HelloWorld application it looks like this: 使用Dependency Walker和一个简单的HelloWorld应用程序,它看起来像这样:

加载64位版本的kernel32.dll

It correctly loads the 32-bit kernel32 on other machines. 它在其他机器上正确加载32位kernel32。

加载32位版本的kernel32.dll

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. PATH的值似乎不相同,因此至少包括不同机器上完全相同顺序的相关路径。

According to this page from Microsoft, the search order for DLLs is: 根据Microsoft的这个页面 ,DLL的搜索顺序是:

  1. The directory where the executable module for the current process is located. 当前进程的可执行模块所在的目录。
  2. The current directory. 当前目录。
  3. The Windows system directory. Windows系统目录。 The GetSystemDirectory function retrieves the path of this directory. GetSystemDirectory函数检索此目录的路径。
  4. The Windows directory. Windows目录。 The GetWindowsDirectory function retrieves the path of this directory. GetWindowsDirectory函数检索此目录的路径。
  5. The directories listed in the PATH environment variable. PATH环境变量中列出的目录。

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. 我猜测在这个特定的机器上GetSystemDirectory返回Windows/system32而不是Windows/SysWOW64的路径,或者从32位进程的system32SysWOW64的映射不能正常工作,但这些只是合格的猜测。

Any idea what is causing this behaviour? 知道造成这种行为的原因是什么吗?

Dependency Walker is reporting the dependencies incorrectly. Dependency Walker错误地报告了依赖关系。 Its static analysis sometimes gets confused between 32 and 64 bit modules. 它的静态分析有时会在32位和64位模块之间混淆。 Typically this is when you run a 64 bit version of Dependency Walker against a 32 bit target executable, or vice versa. 通常,这是针对32位目标可执行文件运行64位版本的Dependency Walker,反之亦然。

Rest assured that your 32 bit program is loading the 32 bit version of kernel32. 请放心,您的32位程序正在加载32位版本的kernel32。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM