Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikdasm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2017-02-28 01:54:41 +0300
committerZoltan Varga <vargaz@gmail.com>2017-02-28 01:54:41 +0300
commit1307bdd36056498ee62e1bc845768ba380964d51 (patch)
treeaacc8817dbf8b36a2f6ebc11ae550267889ce318
parente4deabf61c11999f200dcea6f6d6b42474cc2131 (diff)
[ikdasm] Add --exportedtype option to dump the ExportedType metadata table.
-rw-r--r--Program.cs2
-rw-r--r--TableDumper.cs34
2 files changed, 36 insertions, 0 deletions
diff --git a/Program.cs b/Program.cs
index 8d3f279..045ac5f 100644
--- a/Program.cs
+++ b/Program.cs
@@ -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 ++;
+ }
+ }
}
}