0

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.

nobody
  • 19,814
  • 17
  • 56
  • 77

3 Answers3

1

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?

  • This is how I would do it too. Same as Jay's answer basically, but the call to LoadLibrary() is the key. [See here, you'll get a NULL from LoadLibrary if A fails to load B.](http://msdn.microsoft.com/en-us/library/ms684175(v=vs.85).aspx) – Chris A. May 06 '11 at 21:18
0

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.

Jay
  • 13,803
  • 4
  • 42
  • 69
  • 1
    `you might also be able to place the DLL's in the file system` -- excuse me, where _else_ do you keep them? – sehe May 06 '11 at 20:35
0

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

cprogrammer
  • 5,503
  • 3
  • 36
  • 56