Fred110506
Fred110506

Reputation: 1

Catching DLL dependencies in Win32 application

How can I catch a missing DLL in a dependent DLL?

For example: Application is loading a DLL A.

DLL A is loading DLL B.

So if DLL B is not available, application just shows me: DLL A not found.

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.

Upvotes: 0

Views: 1500

Answers (3)

cprogrammer
cprogrammer

Reputation: 5675

You can parse IAT and implement an algorithm similar with the one used by LoadLibrary to check if dll wil be found. A start in implementing this is ImageNtHeader

Upvotes: 0

Jay
Jay

Reputation: 14471

You could explicitly load the 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?

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.

Upvotes: 0

user2100815
user2100815

Reputation:

I'm not entirely clear what your use case is here, but can't your application call LoadLibrary to check if the DLLs are available before launching the "external tool", and if it fails report that the DLL(s) are missing?

Upvotes: 1

Related Questions