diff options
author | Zoltan Varga <vargaz@gmail.com> | 2015-11-18 14:24:11 +0300 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2015-11-18 14:24:11 +0300 |
commit | 323eeecdf13c39527c53efa5f6c8487765ee42c0 (patch) | |
tree | 137b4154b5e1da5ac18bfb04011cd9f1efb2e6e8 | |
parent | d6db90d6780d5cdb37ef97ec36d0cb452ac70e9e (diff) |
Add --assemblyref and --moduleref options to dump the AssemblyRef/ModuleRef metadata tables.
-rw-r--r-- | Program.cs | 2 | ||||
-rw-r--r-- | TableDumper.cs | 42 |
2 files changed, 43 insertions, 1 deletions
@@ -47,6 +47,8 @@ namespace Ildasm { "help", v => printUsage = true }, { "out", v => outputFile = v }, { "assembly", v =>tableToDump = MetadataTableIndex.Assembly }, + { "assemblyref", v =>tableToDump = MetadataTableIndex.AssemblyRef }, + { "moduleref", v =>tableToDump = MetadataTableIndex.ModuleRef }, }; args = p.Parse (args).ToArray (); if (printUsage) { diff --git a/TableDumper.cs b/TableDumper.cs index d919ca0..0599ed3 100644 --- a/TableDumper.cs +++ b/TableDumper.cs @@ -31,7 +31,9 @@ using IKVM.Reflection; namespace Ildasm { enum MetadataTableIndex { + ModuleRef = 0x1a, Assembly = 0x20, + AssemblyRef = 0x23, } class TableDumper @@ -62,6 +64,12 @@ namespace Ildasm case MetadataTableIndex.Assembly: DumpAssemblyTable (w); break; + case MetadataTableIndex.AssemblyRef: + DumpAssemblyRefTable (w); + break; + case MetadataTableIndex.ModuleRef: + DumpModuleRefTable (w); + break; default: throw new NotImplementedException (); } @@ -71,7 +79,7 @@ namespace Ildasm for (int i = 0; i < len; ++i) { if ((i % 16) == 0) w.Write (String.Format ("\n0x{0:x08}: ", i)); - w.Write (String.Format ("{0:x02} ", bytes [i])); + w.Write (String.Format ("{0:X02} ", bytes [i])); } } @@ -98,5 +106,37 @@ namespace Ildasm w.WriteLine (); } } + + void DumpAssemblyRefTable (TextWriter w) { + var t = module.AssemblyRef; + w.WriteLine ("AssemblyRef Table"); + int rowIndex = 1; + foreach (var r in t.records) { + w.WriteLine (String.Format ("{0}: Version={1}.{2}.{3}.{4}", rowIndex, r.MajorVersion, r.MinorVersion, r.BuildNumber, r.RevisionNumber)); + w.WriteLine (String.Format ("\tName={0}", module.GetString (r.Name))); + w.WriteLine (String.Format ("\tFlags=0x{0:x08}", r.Flags)); + var blob = module.GetBlob (r.PublicKeyOrToken); + if (blob.Length == 0) { + w.WriteLine ("\tZero sized public key"); + } else { + w.Write ("\tPublic Key:"); + byte[] bytes = blob.ReadBytes (blob.Length); + HexDump (w, bytes, bytes.Length); + w.WriteLine (); + } + w.WriteLine (); + rowIndex ++; + } + } + + void DumpModuleRefTable (TextWriter w) { + var t = module.ModuleRef; + w.WriteLine ("ModuleRef Table (1.." + t.RowCount + ")"); + int rowIndex = 1; + foreach (var r in t.records) { + w.WriteLine (String.Format ("{0}: {1}", rowIndex, module.GetString (r))); + rowIndex ++; + } + } } } |