forked from microsoft/dotnet-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
49 lines (44 loc) · 1.45 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using MdDumper.Visualization;
namespace MdDumper
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0 || new[] {"/?", "-?", "-h", "--help"}.Any(x => string.Equals(args[0], x, StringComparison.OrdinalIgnoreCase)))
{
PrintUsage();
return;
}
foreach (var fileName in args)
{
Console.WriteLine(fileName);
Console.WriteLine(new string('*', 80));
try
{
using (var stream = File.OpenRead(fileName))
using (var peFile = new PEReader(stream))
{
var metadataReader = peFile.GetMetadataReader();
var visualizer = new MetadataVisualizer(metadataReader, Console.Out);
visualizer.Visualize();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
private static void PrintUsage()
{
Console.WriteLine("This tool dumps the contents of all tables in a set of PE files.");
Console.WriteLine("usage: mddumper <file>...");
}
}
}