blob: 04a4942c9abf35fca65082b8a28361b3e10fc1b0 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
using System;
using System.IO;
using Mono.PEToolkit;
using Mono.PEToolkit.Metadata;
public sealed class MDDump {
private MDDump() {}
public static uint Dump (string peFile)
{
using (Image pe = new Image (peFile)) {
pe.Open ();
pe.ReadHeaders ();
Console.WriteLine (pe);
if (pe.IsCLI) {
pe.DumpStreamHeader("#~");
pe.DumpStreamHeader("#-");
pe.DumpStreamHeader("#Strings");
pe.DumpStreamHeader("#US");
pe.DumpStreamHeader("#GUID");
pe.DumpStreamHeader("#Blob");
Console.WriteLine("CLI image detected, dumping metadata tables.");
TablesHeap tabs = pe.MetaDataRoot.TablesHeap;
foreach (MDTable t in tabs.Tables) {
t.Dump (Console.Out);
}
/*
MethodIL il = pe.MetaDataRoot.GetMethodBody(1);
Console.WriteLine(il);
il.DumpHexBytecode(Console.Out);
*/
}
FileStream out_file = new FileStream ("out.dll", FileMode.Create);
BinaryWriter binary_writer = new BinaryWriter (out_file);
pe.WriteHeaders (binary_writer);
out_file.Close ();
}
return 0;
}
public static void Main (string [] args) {
if (args.Length == 0) {
Console.WriteLine ("mddump <PE file>");
} else {
Dump (args [0]);
}
}
}
|