2009-07-16 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Thu, 16 Jul 2009 14:26:18 +0000 (14:26 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Thu, 16 Jul 2009 14:26:18 +0000 (14:26 -0000)
* main.c: added new --presources option which prints manifest
resource offsets and names.

* monodis.1: added documentation of the --presources option.

svn path=/trunk/mono/; revision=138037

mono/dis/ChangeLog
mono/dis/main.c
mono/dis/monodis.1

index 870be2c1312591a8147db07b33c16714a33e675f..f02b3d60a83f9962532262c09914150a6a78cd50 100644 (file)
@@ -1,3 +1,10 @@
+2009-07-16  Marek Habersack  <mhabersack@novell.com>
+
+       * main.c: added new --presources option which prints manifest
+       resource offsets and names.
+
+       * monodis.1: added documentation of the --presources option.
+
 2009-06-10  Jb Evain  <jbevain@novell.com>
 
        * main.c: add support for extern types. Fixes #511672.
index 6767a61e6932b6f6f9575c72cef8e629cdd9b2ce..61dc22cd5e1567592f19a50179352d4866f0bdc8 100644 (file)
@@ -1340,8 +1340,7 @@ dis_globals (MonoImage *m)
 
 }
 
-static void
-dis_mresource (MonoImage *m)
+static void dis_resources_worker (MonoImage *m, gboolean just_print)
 {
        MonoTableInfo *t = &m->tables [MONO_TABLE_MANIFESTRESOURCE];
        int i;
@@ -1354,10 +1353,21 @@ dis_mresource (MonoImage *m)
 
                mono_metadata_decode_row (t, i, cols, MONO_MANIFEST_SIZE);
                name = mono_metadata_string_heap (m, cols [MONO_MANIFEST_NAME]);
+
+               if (just_print)
+                       fprintf (output, "%8x: %s", cols [MONO_MANIFEST_OFFSET], name);
                
-               if (! (res = mono_image_get_resource (m, cols [MONO_MANIFEST_OFFSET], &size)))
+               if (! (res = mono_image_get_resource (m, cols [MONO_MANIFEST_OFFSET], &size))) {
+                       if (just_print)
+                               fprintf (output, " (absent from image)\n");
                        continue;       
+               }
 
+               if (just_print) {
+                       fprintf (output, " (size %u)\n", size);
+                       continue;
+               }
+               
                if ( (fp = fopen (name, "ab")) ) {
                        if (ftell (fp) == 0)
                                fwrite (res, size, 1, fp);
@@ -1370,6 +1380,18 @@ dis_mresource (MonoImage *m)
        }               
 }
 
+static void
+dis_mresource (MonoImage *m)
+{
+       dis_resources_worker (m, FALSE);
+}
+
+static void
+dis_presource (MonoImage *m)
+{
+       dis_resources_worker (m, TRUE);
+}
+
 static char *
 exported_type_flags (guint32 flags)
 {
@@ -1570,6 +1592,7 @@ struct {
        { "--moduleref",   MONO_TABLE_MODULEREF,        dump_table_moduleref },
        { "--module",      MONO_TABLE_MODULE,           dump_table_module },
        { "--mresources",  0,   dis_mresource },
+       { "--presources", 0, dis_presource },
        { "--nested",      MONO_TABLE_NESTEDCLASS,      dump_table_nestedclass },
        { "--param",       MONO_TABLE_PARAM,            dump_table_param },
        { "--parconst",    MONO_TABLE_GENERICPARAMCONSTRAINT, dump_table_parconstraint },
index 35d57776ef15a21c6d6978af23dcf1e191b6bd6f..43a1d3c93e4f932668f80e30cb0c8386aa10d2c5 100644 (file)
@@ -37,6 +37,7 @@ monodis \- CIL image content dumper and disassembler.
 [\-\-module]
 [\-\-moduleref]
 [\-\-mresources]
+[\-\-presources]
 [\-\-nested]
 [\-\-param]
 [\-\-parconst]
@@ -145,6 +146,9 @@ Dumps the contents of the ModuleRef table.
 .I "--mresources"
 Dumps the managed resources embedded in the assembly.
 .TP
+.I "--presources"
+Prints offsets and names of manifest resources embedded in the assembly.
+.TP
 .I "--nested"
 Dumps the contents of the NestedClass table.
 .TP