Created
April 20, 2015 19:14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void Decompile(MethodDefinition m) | |
{ | |
try { | |
Formatter.WriteMethodBody(Console.Out, m); | |
var lang = CSharp.GetLanguage(CSharpVersion.V3); | |
var writer = lang.GetWriter(new PlainTextFormatter(Console.Out)); | |
writer.Write(m); | |
} catch (Exception e) { | |
Console.WriteLine(m.FullName); | |
Console.WriteLine(e.Message); | |
} | |
} | |
private static void DumpAssembly(string path) | |
{ | |
var assembly = AssemblyDefinition.ReadAssembly(path); | |
var pdbpath = Path.ChangeExtension (path, ".pdb"); | |
var provider = new PdbReaderProvider(); | |
var reader = provider.GetSymbolReader(assembly.MainModule, pdbpath); | |
assembly.MainModule.ReadSymbols(reader); | |
assembly.MainModule.Types.SelectMany(x => x.Methods).ToList().ForEach(Decompile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment