How to determine what DLL’s a binary depends on using programmatic methods?
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).
Take a look at the
IMAGE_LOAD_FUNCTIONAPI. It will return a pointer to aLOADED_IMAGEstructure, 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.
Update:
I just downloaded the source code for the article. If you open up
EXEDUMP.CPPand take a look atDumpImportsSectionit should have the code you need.