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)的依赖关系.我正在寻找在 C/C++ 应用程序中实现的解决方案.这是我的应用程序需要在运行时完成的事情,而第三方应用程序(如依赖)无法完成.
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.
您可以在这里找到一些描述结构布局的文章a>,以及此处.您可以在这里下载文章的源代码.
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 依赖项?
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
