CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2005
    Location
    Ontario, Canada
    Posts
    107

    DLL dependency analyzer

    I have a bunch of projects that reference eachother's dll's through the use of import statements. I'm looking for a dependency analyzer tool that will show me these dependencies.

    So far, I've tried Lattix LDM, which shows me the dependencies between h files and c files within a single project but not the inter-project dll dependencies.

    I've dried dll analyzer tools such as Dependency walker, and PE Explorer, but these only show references to system and windows dll's. It does not show the ones referenced by import statements.

    Does anyone know of a good tool? Your help is greatly appreciated.

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: DLL dependency analyzer

    I'm looking for a dependency analyzer tool that will show me these dependencies.
    You can find it in
    • C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\depends.exe
    • dependency walker

    It's the same.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Jul 2005
    Location
    Ontario, Canada
    Posts
    107

    Re: DLL dependency analyzer

    Oh, I didn't know it was part of visual studio. But like I said, dependency walker doesn't show me what I need. Do you know of any other tools that might?

  4. #4
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: DLL dependency analyzer

    If dependency walker does not show it, it means it is not implicitly linked.

    BTW, did you mention, those referenced by #import or #pragma. Just trying to confirm.
    If you did mention #import, then sorry, you are out of luck. #import are used for COM dlls and these are not implicitly linked but loaded at runtime on demand when a CoCreateInstance is done on the class. So, they DO NOT show up as dependencies.

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: DLL dependency analyzer

    Quote Originally Posted by Chris256
    Oh, I didn't know it was part of visual studio. But like I said, dependency walker doesn't show me what I need. Do you know of any other tools that might?
    I apologize. I guess I did not read all your post. What you want is not possible. You want to see the dependencies on DLL loaded with LoadLibrary, right? That's not possible.

    Imagine you write a program an input the name of the DLL that you later load with LoadLibrary(). How can a tool show those names.

    However, if you are desperate about this, you can look into the executable in the data section for strings. Strings passed to LoadLibrary, like
    Code:
    LoadLibrary("mydll.dll");
    will show up in that data section. Perhaps you can identify them. BTW, you can use a PE explorer/viewer to have a better look on your executable sections.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: DLL dependency analyzer

    Quote Originally Posted by cilu
    will show up in that data section. Perhaps you can identify them. BTW, you can use a PE explorer/viewer to have a better look on your executable sections.
    That wouldn't still account for COM dlls loaded via CoCreateInstance.

    To OP. Is there a specific problem you are facing now ?

  7. #7
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: DLL dependency analyzer

    Quote Originally Posted by kirants
    That wouldn't still account for COM dlls loaded via CoCreateInstance.
    Of course. I said for LoadLibrary().
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  8. #8
    Join Date
    Jul 2005
    Location
    Ontario, Canada
    Posts
    107

    Re: DLL dependency analyzer

    Thanks for your help guys, this discussion has been helpful.

    So basically, the impression I'm getting here is the following. I cannot do this with a static code analysis tool. I basically have to text search the code for strings that end with ".dll" and ".exe" or search for import statements. Is this a fair conclusion? Is there anything else I could investigate before resorting to this?

  9. #9
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: DLL dependency analyzer

    Quote Originally Posted by Chris256
    So basically, the impression I'm getting here is the following. I cannot do this with a static code analysis tool.
    Yes.
    I basically have to text search the code for strings that end with ".dll" and ".exe" or
    Fair enough. But not enough. You should rather look for LoadLibrary. Because, the parameter passed to LoadLibrary is what is important and it can come from a variable instead of a hard coded static string like "blahblah.dll".

    search for import statements.
    Fair enough.

    Is this a fair conclusion? Is there anything else I could investigate before resorting to this?
    No. This will only make sure of dlls loaded by your code ( for which you have sources ). There are infinite ways of loading dlls.. some explicitly , some implicitly. But, if you are concerned only about those that are shipped by you, that checklist can probably catch 95% of the cases.

    Anyways, am not clear what you are trying to do. I mean, what is your final goal ?

  10. #10
    Join Date
    Feb 2002
    Posts
    4,640

    Re: DLL dependency analyzer

    Another way might be to attach Developer Studio to the process. The output window should show you all the DLL's currently in use by the process.

    Viggy

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: DLL dependency analyzer

    ...and another one is to enumerate process modules at runtime.

    Unfortunately, there's no fault-proof way to detect all modules you need since some of them may be loaded dynamically and in very, very rare case (for example, platform-dependent APIs).

    BTW, such problem you face with when installer project must be built. And missed modules can be detected only by thorough installer testing procedure.
    Best regards,
    Igor

  12. #12

    Re: DLL dependency analyzer

    Why didnot using dynamic tool?
    Best Api Monitor tool.
    Trace the target program automatically and monitor the parameters of all API and COM interfaces.

    Auto Debug for Windows 4.0
    Auto Debug for .Net
    http://www.autodebug.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured