How to determine a windows executables DLL dependencies programmatically?(如何以编程方式确定 Windows 可执行文件的 DLL 依赖项?)
问题描述
如何使用编程方法确定哪个 DLL 是二进制文件?
How to determine what DLL's a binary depends on using programmatic methods?
需要明确的是,我不是要确定正在运行的 exec 的 DLL 依赖项,而是要确定任何任意 exec(可能缺少所需的 DLL)的 DLL 依赖项.我正在寻找在 C/C++ 应用程序中实现的解决方案.这是需要由我的应用程序在运行时完成的事情,而不能由第三方应用程序(如 Depends)完成.
To be clear, I am not trying to determine the DLL dependencies of the running exec, but of any arbitrary exec (that may be missing a required DLL). I'm looking for a solution to implement in a C/C++ application. This is something that needs to be done by my application at runtime and can't be done by a third party app (like depends).
推荐答案
查看 IMAGE_LOAD_FUNCTION API.它将返回一个指向 LOADED_IMAGE 结构,您可以使用它来访问 PE 文件的各个部分.
Take a look at the IMAGE_LOAD_FUNCTION API. It will return a pointer to a LOADED_IMAGE structure, which you can use to access the various sections of a PE file.
您可以在此处找到一些描述结构布局的文章 和 此处.您可以在此处下载文章的源代码.
You can find some articles that describe how the structures are laid out here, and here. You can download the source code for the articles here.
我认为这应该给你你需要的一切.
I think this should give you everything you need.
更新:
我刚刚下载了这篇文章的源代码.如果您打开 EXEDUMP.CPP 并查看 DumpImportsSection,它应该有您需要的代码.
I just downloaded the source code for the article. If you open up EXEDUMP.CPP and take a look at DumpImportsSection it should have the code you need.
这篇关于如何以编程方式确定 Windows 可执行文件的 DLL 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何以编程方式确定 Windows 可执行文件的 DLL 依赖项?
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
