Arve
Arve

Reputation: 7506

A library for analyzing executables

There are tools like Dependency Walker, dumpbin, ildasm for looking into DLLs/EXE files on Windows. I would like to analyze DLLs from code, especially dependencies both managed and unmanaged. Are there any (.NET) libraries out there for analyzing with similar functionality?

I want to use this to verify that we am deploying the right DLLs in setup program my company are creating. We have more than 200 DLLs.

Upvotes: 3

Views: 237

Answers (4)

Jb Evain
Jb Evain

Reputation: 17499

You can use the Cecil library to analyze managed executables. And you can use Gendarme that uses Cecil if you want a rule engine to check your application.

Upvotes: 3

Patrick from NDepend team
Patrick from NDepend team

Reputation: 13842

NDepend is indeed the tool you are looking for but you should also consider decreasing the number of assemblies as explained here: Advices on partitioning code through .NET assemblies

Upvotes: 3

wj32
wj32

Reputation: 8393

I hope this doesn't break any rules, but you might want to look into a library I've developed which can see image imports and exports among a heap of other things. Download the source code from here: https://sourceforge.net/projects/processhacker/files. Extract ProcessHacker.Common and ProcessHacker.Native, include them in your solution, and reference them.

Here's how to use it:

using ProcessHacker.Native.Image;

MappedImage image = new MappedImage("file.exe");

for (int i = 0; i < image.Imports.Count; i++)
{
    Console.WriteLine("Imports for " + image.Imports[i].Name + ":");

    for (int j = 0; j < image.Imports[i].Count; j++)
        Console.WriteLine(image.Imports[i][j].Name);
}

I don't know how to deal with .NET references though.

Upvotes: 1

Eilon
Eilon

Reputation: 25704

If you want to do your own dependency checking you can write Code Analysis (FxCop) plugins for Visual Studio for managed code assemblies.

Tutorial on writing your own Code Analysis rule

If you want pre-built tools you can use:

  1. The built in Code Analysis (FxCop) tool in Visual Studio.
  2. NDepend

Upvotes: 1

Related Questions