LoadLibrary 在 Win7 32 位上失败,在 Win XP 32 位上成功
我正在尝试将第 3 方 dll(即我没有源代码)加载到我的应用程序中。在 Windows XP 32 位系统上,它可以正常加载,但在 Windows 7 系统上,它无法加载,引用来自 GetLastError() 的错误 #998
我使用 dll 导出查看器来查看 dll 的导入和导出符号,并观察到导入表中列出的除 3 个 dll 之外的所有文件均来自该第 3 方供应商。没有的有:
kernel32.dll
mingwm10.dll
msvcrt.dll
这是我用来执行导入的代码:
SetDllDirectory(L"c:\\dlls");
HMODULE tempDLL = LoadLibrary(L"mydll.dll");
DWORD err = GetLastError();
请问有关如何调试此代码的任何提示?
编辑:感谢大家的回答,这是我迄今为止发现的:
a) 应用程序工具包并没有被证明是那么有用(见下文)
b) 同事 A 可以在他的 win 7 机器上加载 dll,而同事 B 则不能,所以它是零星的
c) 以管理员身份运行没有改变任何东西
I am trying to load a 3rd party dll (i.e. I have no source code) into my application. On a windows xp 32 bit system, it loads fine, but on a windows 7 system it fails to load, citing error #998 from GetLastError()
I used a dll export viewer to view the imported and exported symbols of the dll, and observed that all but 3 dlls listed in the import table came from this 3rd party vendor. The ones that didn't are:
kernel32.dll
mingwm10.dll
msvcrt.dll
Here is the code I am using to do the import:
SetDllDirectory(L"c:\\dlls");
HMODULE tempDLL = LoadLibrary(L"mydll.dll");
DWORD err = GetLastError();
Any tips on how to go about debugging this, please?
Edit: My thanks to everyone for the answers, and this is what I have discovered so far:
a) The application toolkit package did not prove to be that useful (see below)
b) Colleague A can get the dll to load on his win 7 machine and colleague B cannot, so it something sporadic
c) Running as admin did not change anything
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 Microsoft 应用程序兼容性工具包(它是一个免费的工具集)来找出它在 Windows 7 上失败的原因。希望这会有所帮助,它看起来像是一个兼容性问题。
Try to use Microsoft Application Compatibility Toolkit (it is a free toolset) to find out why it fails on Windows 7. Hope this will help, it looks like a compatibility issue.
您是否尝试过禁用数据执行保护 (DEP)?
在 Vista 及以上版本中,此功能通常默认启用,但在 XP 中禁用。如果您的 DLL 有错误导致其执行数据,则可能会在 LoadLibrary 调用期间出现。
Have you tried with Data Execution Prevention (DEP) disabled?
This is normally enabled by default on Vista and above, but disabled on XP. If your DLL has a bug causing it to execute data, this could show up during the LoadLibrary call.