微软gflags工具会随时告诉你到底是什么依赖性无法加载和原因。
运行gflags -i your_application.exe +sls
。之后,在调试器下执行应用程序以捕获loader traces。
gflags是Debugging Tools的一部分 - 您可以检查C:\Program Files (x86)\Windows Kits\10\Debuggers\x64
以查看是否已拥有它。您可以将该目录添加到您的路径中,或者仅在cmd.exe中执行该目录中的gflags。
例如,在运行gflags之后,在::LoadLibrary(_T("foo"))
调用中放置一个断点并在您的Visual Studio输出窗口中查找加载器错误时跳过它,例如,
4b00:396c @ 479194074 - LdrpSnapThunk - ERROR: Procedure "[email protected][email protected]@[email protected]" could not be located in DLL "bar.dll"
First-chance exception at 0x0000000077307EF8 (ntdll.dll) in your_application.exe: 0xC0000139: Entry Point Not Found.
4b00:396c @ 479194074 - LdrpGenericExceptionFilter - ERROR: Function LdrpSnapIAT raised exception 0xc0000139
Exception record: .exr 0000000000129070
Context record: .cxr 0000000000128B80
4b00:396c @ 479194074 - LdrpHandleOneOldFormatImportDescriptor - ERROR: Snapping the imports from DLL "C:\test\64Debug\foo.DLL" to DLL "C:\test\64Debug\bar.dll" failed with status 0xc0000139
这意味着foo.dll
负载时,依赖bar.dll
是进口,而进口bar.dll
失败。
的依赖进口失败,因为程序[email protected][email protected]@[email protected]
不见了 - 你可以demangle,为public: void __cdecl vis_DollarMap::SetObject(int,void * __ptr64) __ptr64
。
你可能有依赖的错版 - 也许你需要重建的依赖得到它最新的。
之后运行gflags -i your_application.exe -sls
禁用加载程序跟踪。
也许图书馆里没有`DllMain`?它应该失败`:: LoadLibrary`? – 2010-03-17 17:21:19
如果`DllMain`将'最后一个错误'设置为127,然后返回'FALSE`,那么在':: LoadLibrary`返回之前系统会覆盖'最后一个错误'吗? – 2010-03-17 17:25:29