为什么 MSVC 2010 32 位项目链接到 64 位 kernel32.dll?

发布于 2024-11-09 10:49:07 字数 315 浏览 0 评论 0原文

我有一个 Win32(32 位)DLL 项目,它的构建和链接没有错误。 DLL 无法加载到 32 位进程中。使用 DependencyWalker,我看到 DLL 是 32 位的,但已与 kernel32、msvcr100d、ws2_32 和 msvcr100 的 64 位库链接。

DependencyWalker 还显示了一个错误

Error: Modules with different CPU types were found.

,我已经对这个问题困惑了几个小时,只是无法理解它 - 有其他人经历过这个并找到解决方案吗?

I have a Win32 (32bit) DLL project which builds and links without error. The DLL fails to load into a 32bit process. Using DependencyWalker, I see that the DLL is 32bit but has been linked with 64bit libraries for kernel32, msvcr100d, ws2_32 and msvcr100.

DependencyWalker also shows an error

Error: Modules with different CPU types were found.

I've puzzled over this problems for a couple of hours now, and just can't fathom it - has anyone else experienced this, and found a solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

狠疯拽 2024-11-16 10:49:07

简短回答:使用Dependency Walker for x86来处理x86内容。

长答案:最初,我在 MS Windows 7 操作系统上使用Dependency Walker for x64,并遇到了您遇到的障碍。然后我按照 MerickOWA 关于更改搜索路径的建议(感谢 MerickOWA)。尽管我仍然有一些依赖项导致“错误:找到具有不同 CPU 类型的模块”。

与其弄清楚如何配置依赖性步行器以搜索奇异的路径中的x86 dll,例如“ C:\ Windows \ Windows \ winsxs \ AMD64_MICROSOFT.WINDOWS.GDIPLUS_6595B644CCF1DF1DF1DF1DF_1DF_1.1.1.1.17511.17514_NONEONE “正确,我使用了 x86 的 Dependency Walker。对我来说就像一个魅力!

Short Answer: Use Dependency Walker for x86 for x86 stuff.

Long Answer: Initially I used Dependency Walker for x64 on the MS Windows 7 OS and ran into the hurdles you did. I then followed MerickOWA's advice about changing the search paths (thanks MerickOWA). Though I still had a handful of dependencies causing "Error: Modules with different CPU types were found".

Instead of figuring out how to configure Dependency Walker to search for the x86 DLLs in bizarre looking paths like "c:\windows\winsxs\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.17514_none_2b24536c71ed437a\GDIPLUS.DLL" correctly, I used the Dependency Walker for x86. Worked like a charm for me!

澉约 2024-11-16 10:49:07

Dependency Walker 不使用与操作系统相同的搜索路径。它有自己的搜索路径来尝试查找 DLL。您可以通过“选项 -> 配置模块搜索顺序...”来查看它,

不幸的是它的搜索路径不包括“C:\Windows\SysWow64”(Kernel32.dll 的 32 位版本的位置

)这就是 Dependency Walker 错误地认为您的应用程序将 x64 DLL 与 x86 应用程序混合的原因。

如果您修复搜索顺序以包括 SysWow64 并删除对 System32 目录的所有引用。这个错误应该消失。

一种更好的方法来检查应用程序运行时 Visual Studio 调试器或 WinDbg 的输出窗口。它将在加载 DLL 时列出它们的完整路径。

Dependency Walker isn't using the same search path as the OS. It has its own search paths to try and find DLLs. You can view this by going to "Options -> Configure Module Search Order..."

Unfortunantly its search paths don't include "C:\Windows\SysWow64" (the location of the 32 bit version for Kernel32.dll)

This is why Dependency Walker incorrectly thinks your application is mixing x64 DLLs with your x86 application.

If you fix up the search order to include SysWow64 and remove all references to the System32 directory. This error should go away.

A better way to check which the output window of Visual Studio debugger or WinDbg when your application is run. It will list out the DLL's full path as they're loaded.

尘曦 2024-11-16 10:49:07

查看依赖网站常见问题解答。 http://www.dependencywalker.com/faq.html

Q.Will Dependency Walker work with 64-bit modules?

您需要使用 x86 版本32 位模块,64 位模块为 x64。这意味着您需要在 64 位操作系统中拥有 2 个副本并相应地使用它们。

您可以使用 Windows 注册表来创建上下文菜单,以节省您的麻烦。

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\dllfile\shell]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\exefile\shell]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\ddeexec]
@="[open(\"%1\")]"

Check out the dependency website FAQ. http://www.dependencywalker.com/faq.html

Q.Will Dependency Walker work with 64-bit modules?

you need use the x86 version for the 32bit modules, x64 for the 64bit modules. It means you need have 2 copy in the 64bit OS and use them accordingly.

you can use the windows registry to create the context menu in order to save your trouble like this.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\dllfile\shell]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)]

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"

[HKEY_CLASSES_ROOT\dllfile\shell\View Dependencies(32bit)\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\exefile\shell]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\depends.exe /dde"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies\ddeexec]
@="[open(\"%1\")]"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)]

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\command]
@="\\\\psf\\Public\\Library\\DEPE~K17\\x86\\depends.exe /dde"

[HKEY_CLASSES_ROOT\exefile\shell\View Dependencies(32bit)\ddeexec]
@="[open(\"%1\")]"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文