简体   繁体   English

在Win32应用程序中捕获DLL依赖项

[英]Catching DLL dependencies in Win32 application

How can I catch a missing DLL in a dependent DLL? 如何在依赖的DLL中捕获丢失的DLL?

For example: Application is loading a DLL A. 例如:应用程序正在加载DLLA。

DLL A is loading DLL B. DLL A正在加载DLLB。

So if DLL B is not available, application just shows me: DLL A not found. 因此,如果DLL B不可用,则应用程序仅向我显示:找不到DLLA。

Any hints where I could find a solution? 有什么提示可以找到解决方案吗?

At the moment I use dependency-walker to solve this issue, but I need something inside the application, so that the customers must not launch the external tool whenever a DLL is missing. 目前,我使用dependency-walker来解决此问题,但我需要在应用程序内部进行某些操作,以便在缺少DLL时客户不得启动外部工具。

我尚不清楚您的用例在哪里,但是您的应用程序无法在启动“外部工具”之前调用LoadLibrary来检查DLL是否可用,并且如果失败,则报告缺少DLL?

You could explicitly load the DLL. 您可以显式加载DLL。 You'll get an error/exception if you have a missing dependency. 如果缺少依赖项,则会得到一个错误/异常。

Perhaps you can statically compile the code in the DLL so the problem is eliminated? 也许您可以静态地编译DLL中的代码,从而解决问题?

If you're fighting with " DLL Hell " you might also be able to place the DLL's in the file system so windows will load the DLL's you want. 如果要与“ DLL Hell ”作斗争,您也许还可以将DLL放置在文件系统中,以便Windows可以加载所需的DLL。

You can parse IAT and implement an algorithm similar with the one used by LoadLibrary to check if dll wil be found. 您可以解析IAT并实现与LoadLibrary使用算法相似算法,以检查是否会找到dll。 A start in implementing this is ImageNtHeader 开始实现此功能的是ImageNtHeader

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

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