diff options
author | Zoltan Varga <vargaz@gmail.com> | 2017-02-28 01:54:41 +0300 |
---|---|---|
committer | Zoltan Varga <vargaz@gmail.com> | 2017-02-28 01:54:41 +0300 |
commit | 1307bdd36056498ee62e1bc845768ba380964d51 (patch) | |
tree | aacc8817dbf8b36a2f6ebc11ae550267889ce318 | |
parent | e4deabf61c11999f200dcea6f6d6b42474cc2131 (diff) |
[ikdasm] Add --exportedtype option to dump the ExportedType metadata table.
-rw-r--r-- | Program.cs | 2 | ||||
-rw-r--r-- | TableDumper.cs | 34 |
2 files changed, 36 insertions, 0 deletions
@@ -49,6 +49,7 @@ namespace Ildasm { "assembly", v =>tableToDump = MetadataTableIndex.Assembly }, { "assemblyref", v =>tableToDump = MetadataTableIndex.AssemblyRef }, { "moduleref", v =>tableToDump = MetadataTableIndex.ModuleRef }, + { "exported", v =>tableToDump = MetadataTableIndex.ExportedType } }; args = p.Parse (args).ToArray (); if (printUsage) { @@ -200,6 +201,7 @@ namespace Ildasm Console.WriteLine (" -assembly Dumps the contents of the Assembly table"); Console.WriteLine (" -assemblyref Dumps the contents of the AssemblyRef table"); Console.WriteLine (" -moduleref Dumps the contents of the ModuleRef table"); + Console.WriteLine (" -exportedtype Dumps the contents of the ExportedType table"); } else { Console.WriteLine(" /OUT=<file name> Direct output to file rather than to stdout."); Console.WriteLine(" /COMPAT=<version> Match ildasm behavior. (<version> = 2.0 | 4.0 | 4.5)"); diff --git a/TableDumper.cs b/TableDumper.cs index 0599ed3..148868d 100644 --- a/TableDumper.cs +++ b/TableDumper.cs @@ -27,6 +27,7 @@ using System.Linq; using System.Text; using System.IO; using IKVM.Reflection; +using IKVM.Reflection.Metadata; namespace Ildasm { @@ -34,6 +35,7 @@ namespace Ildasm ModuleRef = 0x1a, Assembly = 0x20, AssemblyRef = 0x23, + ExportedType = 0x27, } class TableDumper @@ -70,6 +72,9 @@ namespace Ildasm case MetadataTableIndex.ModuleRef: DumpModuleRefTable (w); break; + case MetadataTableIndex.ExportedType: + DumpExportedTypeTable (w); + break; default: throw new NotImplementedException (); } @@ -138,5 +143,34 @@ namespace Ildasm rowIndex ++; } } + + string GetManifestImpl (int idx) { + if (idx == 0) + return "current module"; + uint table = (uint)idx >> 24; + uint row = (uint)idx & 0xffffff; + switch (table) { + case FileTable.Index: + return "file " + row; + case (uint)AssemblyRefTable.Index: + return "assemblyref " + row; + case (uint)ExportedTypeTable.Index: + return "exportedtype " + row; + default: + return ""; + } + } + + void DumpExportedTypeTable (TextWriter w) { + var t = module.ExportedType; + w.WriteLine ("ExportedType Table (1.." + t.RowCount + ")"); + int rowIndex = 1; + foreach (var r in t.records) { + string name = module.GetString (r.TypeName); + string nspace = module.GetString (r.TypeNamespace); + w.WriteLine (String.Format ("{0}: {1}{2}{3} is in {4}, index={5:x}, flags=0x{6:x}", rowIndex, nspace, nspace != "" ? "." : "", name, GetManifestImpl (r.Implementation), r.TypeDefId, r.Flags)); + rowIndex ++; + } + } } } |