}
}
-static map_t visibility_map [] = {
+static void
+dis_directive_module (MonoImage *m)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_MODULE];
+ int i;
+
+ for (i = 0; i < t->rows; i++){
+ guint32 cols [MONO_MODULE_SIZE];
+ const char *name;
+ char *guid, *ename;
+
+ mono_metadata_decode_row (t, i, cols, MONO_MODULE_SIZE);
+
+ name = mono_metadata_string_heap (m, cols [MONO_MODULE_NAME]);
+ ename = get_escaped_name (name);
+ guid = get_guid (m, cols [MONO_MODULE_MVID]);
+ fprintf (output, ".module %s // GUID = %s\n\n", ename, guid);
+ g_free (ename);
+
+ dump_cattrs (m, MONO_TOKEN_MODULE | (i + 1), "");
+ }
+}
+
+static void
+dis_directive_moduleref (MonoImage *m)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_MODULEREF];
+ int i;
+
+ for (i = 0; i < t->rows; i++){
+ guint32 cols [MONO_MODULEREF_SIZE];
+ const char *name;
+
+ mono_metadata_decode_row (t, i, cols, MONO_MODULEREF_SIZE);
+
+ name = mono_metadata_string_heap (m, cols [MONO_MODULEREF_NAME]);
+ fprintf (output, ".module extern %s\n", name);
+ }
+
+}
+
+static void
+dis_directive_file (MonoImage *m)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_FILE];
+ int i, j, len;
+ guint32 entry_point;
+
+ entry_point = mono_image_get_entry_point (m);
+
+ for (i = 0; i < t->rows; i++){
+ guint32 cols [MONO_FILE_SIZE];
+ const char *name, *hash;
+ guint32 token;
+
+ mono_metadata_decode_row (t, i, cols, MONO_FILE_SIZE);
+
+ name = mono_metadata_string_heap (m, cols [MONO_FILE_NAME]);
+
+ hash = mono_metadata_blob_heap (m, cols [MONO_FILE_HASH_VALUE]);
+ len = mono_metadata_decode_blob_size (hash, &hash);
+
+ fprintf (output, ".file %s%s .hash = (", name,
+ cols [MONO_FILE_FLAGS] & FILE_CONTAINS_NO_METADATA ? " nometadata" : "");
+
+ for (j = 0; j < len; ++j)
+ fprintf (output, " %02X", hash [j] & 0xff);
+
+ token = mono_metadata_make_token (MONO_TABLE_FILE, i + 1);
+ fprintf (output, " )%s\n", (token == entry_point) ? " .entrypoint" : "");
+ }
+
+}
+
+static dis_map_t visibility_map [] = {
{ TYPE_ATTRIBUTE_NOT_PUBLIC, "private " },
{ TYPE_ATTRIBUTE_PUBLIC, "public " },
- { TYPE_ATTRIBUTE_NESTED_PUBLIC, "nested-public " },
- { TYPE_ATTRIBUTE_NESTED_PRIVATE, "nested-private " },
- { TYPE_ATTRIBUTE_NESTED_FAMILY, "family " },
- { TYPE_ATTRIBUTE_NESTED_ASSEMBLY, "nested-assembly" },
- { TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM, "nested-fam-and-assembly" },
- { TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM, "nested-fam-or-assembly" },
+ { TYPE_ATTRIBUTE_NESTED_PUBLIC, "nested public " },
+ { TYPE_ATTRIBUTE_NESTED_PRIVATE, "nested private " },
+ { TYPE_ATTRIBUTE_NESTED_FAMILY, "nested family " },
+ { TYPE_ATTRIBUTE_NESTED_ASSEMBLY, "nested assembly" },
+ { TYPE_ATTRIBUTE_NESTED_FAM_AND_ASSEM, "nested famandassem" },
+ { TYPE_ATTRIBUTE_NESTED_FAM_OR_ASSEM, "nested famorassem" },
{ 0, NULL }
};
-static map_t layout_map [] = {
+static dis_map_t layout_map [] = {
{ TYPE_ATTRIBUTE_AUTO_LAYOUT, "auto " },
{ TYPE_ATTRIBUTE_SEQUENTIAL_LAYOUT, "sequential " },
{ TYPE_ATTRIBUTE_EXPLICIT_LAYOUT, "explicit " },
{ 0, NULL }
};
-static map_t format_map [] = {
+static dis_map_t format_map [] = {
{ TYPE_ATTRIBUTE_ANSI_CLASS, "ansi " },
{ TYPE_ATTRIBUTE_UNICODE_CLASS, "unicode " },
{ TYPE_ATTRIBUTE_AUTO_CLASS, "auto " },
{
MonoTableInfo *t = &m->tables [MONO_TABLE_FIELD];
guint32 cols [MONO_FIELD_SIZE];
+ char *esname;
char rva_desc [32];
guint32 rva;
int i;
mono_metadata_field_info (m, i, &field_offset, NULL, NULL);
if (field_offset != -1)
attrs = g_strdup_printf ("[%d]", field_offset);
+ esname = get_escaped_name (mono_metadata_string_heap (m, cols [MONO_FIELD_NAME]));
if (cols [MONO_FIELD_FLAGS] & FIELD_ATTRIBUTE_LITERAL){
char *lit;
guint32 const_cols [MONO_CONSTANT_SIZE];
guint32 crow;
- if ((crow = mono_metadata_get_constant_index (m, MONO_TOKEN_FIELD_DEF | (i+1)))) {
+ if ((crow = mono_metadata_get_constant_index (m, MONO_TOKEN_FIELD_DEF | (i+1), 0))) {
mono_metadata_decode_row (&m->tables [MONO_TABLE_CONSTANT], crow-1, const_cols, MONO_CONSTANT_SIZE);
lit = get_constant (m, const_cols [MONO_CONSTANT_TYPE], const_cols [MONO_CONSTANT_VALUE]);
} else {
lit = g_strdup ("not found");
}
+
fprintf (output, " .field %s %s %s = ",
- flags, sig,
- mono_metadata_string_heap (m, cols [MONO_FIELD_NAME]));
+ flags, sig, esname);
fprintf (output, "%s\n", lit);
g_free (lit);
} else
fprintf (output, " .field %s %s %s %s%s\n",
- attrs? attrs: "", flags, sig,
- mono_metadata_string_heap (m, cols [MONO_FIELD_NAME]), rva_desc);
+ attrs? attrs: "", flags, sig, esname, rva_desc);
g_free (attrs);
g_free (flags);
g_free (sig);
+ g_free (esname);
dump_cattrs (m, MONO_TOKEN_FIELD_DEF | (i + 1), " ");
}
}
-static map_t method_access_map [] = {
+static dis_map_t method_access_map [] = {
{ METHOD_ATTRIBUTE_COMPILER_CONTROLLED, "compilercontrolled " },
- { METHOD_ATTRIBUTE_PRIVATE, "private" },
- { METHOD_ATTRIBUTE_FAM_AND_ASSEM, "famandassem" },
+ { METHOD_ATTRIBUTE_PRIVATE, "private " },
+ { METHOD_ATTRIBUTE_FAM_AND_ASSEM, "famandassem " },
{ METHOD_ATTRIBUTE_ASSEM, "assembly " },
{ METHOD_ATTRIBUTE_FAMILY, "family " },
{ METHOD_ATTRIBUTE_FAM_OR_ASSEM, "famorassem " },
{ 0, NULL }
};
-static map_t method_flags_map [] = {
+static dis_map_t method_flags_map [] = {
{ METHOD_ATTRIBUTE_STATIC, "static " },
{ METHOD_ATTRIBUTE_FINAL, "final " },
{ METHOD_ATTRIBUTE_VIRTUAL, "virtual " },
return s;
}
-static map_t pinvoke_flags_map [] = {
+static dis_map_t pinvoke_flags_map [] = {
{ PINVOKE_ATTRIBUTE_NO_MANGLE , "nomangle " },
{ PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR, "lasterr " },
{ 0, NULL }
};
-static map_t pinvoke_call_conv_map [] = {
+static dis_map_t pinvoke_call_conv_map [] = {
{ PINVOKE_ATTRIBUTE_CALL_CONV_WINAPI, "winapi " },
{ PINVOKE_ATTRIBUTE_CALL_CONV_CDECL, "cdecl " },
{ PINVOKE_ATTRIBUTE_CALL_CONV_STDCALL, "stdcall " },
{ 0, NULL }
};
-static map_t pinvoke_char_set_map [] = {
+static dis_map_t pinvoke_char_set_map [] = {
{ PINVOKE_ATTRIBUTE_CHAR_SET_NOT_SPEC, "" },
{ PINVOKE_ATTRIBUTE_CHAR_SET_ANSI, "ansi " },
{ PINVOKE_ATTRIBUTE_CHAR_SET_UNICODE , "unicode " },
return s;
}
-static map_t method_impl_map [] = {
+static dis_map_t method_impl_map [] = {
{ METHOD_IMPL_ATTRIBUTE_IL, "cil " },
{ METHOD_IMPL_ATTRIBUTE_NATIVE, "native " },
{ METHOD_IMPL_ATTRIBUTE_OPTIL, "optil " },
{ 0, NULL }
};
-static map_t managed_type_map [] = {
+static dis_map_t managed_type_map [] = {
{ METHOD_IMPL_ATTRIBUTE_UNMANAGED, "unmanaged " },
{ METHOD_IMPL_ATTRIBUTE_MANAGED, "managed " },
{ 0, NULL }
};
-static map_t managed_impl_flags [] = {
+static dis_map_t managed_impl_flags [] = {
{ METHOD_IMPL_ATTRIBUTE_FORWARD_REF, "fwdref " },
{ METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG, "preservesig " },
{ METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL, "internalcall " },
scope = mono_metadata_string_heap (m, mr_cols [MONO_MODULEREF_NAME]);
- return g_strdup_printf ("(%s as %s %s)", scope, import,
+ return g_strdup_printf ("(\"%s\" as \"%s\" %s)", scope, import,
flags);
g_free (flags);
}
return NULL;
}
+static void
+cattrs_for_method (MonoImage *m, guint32 midx, MonoMethodSignature *sig) {
+ MonoTableInfo *methodt;
+ MonoTableInfo *paramt;
+ guint param_index, lastp, i, pid;
+
+ methodt = &m->tables [MONO_TABLE_METHOD];
+ paramt = &m->tables [MONO_TABLE_PARAM];
+ param_index = mono_metadata_decode_row_col (methodt, midx, MONO_METHOD_PARAMLIST);
+ if (midx + 1 < methodt->rows)
+ lastp = mono_metadata_decode_row_col (methodt, midx + 1, MONO_METHOD_PARAMLIST);
+ else
+ lastp = paramt->rows + 1;
+ for (i = param_index; i < lastp; ++i) {
+ pid = mono_metadata_decode_row_col (paramt, i - 1, MONO_PARAM_SEQUENCE);
+ fprintf (output, "\t.param [%d]\n", pid);
+ dump_cattrs (m, MONO_TOKEN_PARAM_DEF | i, "\t");
+ }
+}
+
/**
* dis_method_list:
* @m: metadata context
* This routine displays the methods in the Method Table from @start to @end
*/
static void
-dis_method_list (MonoImage *m, guint32 start, guint32 end)
+dis_method_list (const char *klass_name, MonoImage *m, guint32 start, guint32 end)
{
MonoTableInfo *t = &m->tables [MONO_TABLE_METHOD];
guint32 cols [MONO_METHOD_SIZE];
sig = mono_metadata_blob_heap (m, cols [MONO_METHOD_SIGNATURE]);
mono_metadata_decode_blob_size (sig, &sig);
- ms = mono_metadata_parse_method_signature (m, 1, sig, &sig);
- sig_str = dis_stringify_method_signature (m, ms, i + 1);
-
+ ms = mono_metadata_parse_method_signature (m, i + 1, sig, &sig);
+ sig_str = dis_stringify_method_signature (m, ms, i + 1, FALSE);
+
fprintf (output, " // method line %d\n", i + 1);
fprintf (output, " .method %s", flags);
- if (cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL)
- fprintf (output, "%s", pinvoke_info (m, i));
+ if ((cols [MONO_METHOD_FLAGS] & METHOD_ATTRIBUTE_PINVOKE_IMPL) && (cols [MONO_METHOD_RVA] == 0)) {
+ gchar *pi = pinvoke_info (m, i);
+ if (pi) {
+ fprintf (output, "%s", pi);
+ g_free (pi);
+ }
+ }
fprintf (output, "\n %s", sig_str);
fprintf (output, " %s\n", impl_flags);
fprintf (output, " {\n");
dump_cattrs (m, MONO_TOKEN_METHOD_DEF | (i + 1), " ");
+ cattrs_for_method (m, i, ms);
/* FIXME: need to sump also param custom attributes */
fprintf (output, " // Method begins at RVA 0x%x\n", cols [MONO_METHOD_RVA]);
- dis_code (m, cols [MONO_METHOD_RVA]);
- fprintf (output, " } // end of method %s\n\n", sig_str);
+ if (cols [MONO_METHOD_IMPLFLAGS] & METHOD_IMPL_ATTRIBUTE_NATIVE)
+ fprintf (output, " // Disassembly of native methods is not supported\n");
+ else
+ dis_code (m, cols [MONO_METHOD_RVA]);
+ fprintf (output, " } // end of method %s::%s\n\n", klass_name, sig_str);
mono_metadata_free_method_signature (ms);
g_free (sig_str);
}
start = mono_metadata_methods_from_property (m, prop, &end);
while (start < end) {
mono_metadata_decode_row (msemt, start, cols, MONO_METHOD_SEMA_SIZE);
- sig = dis_stringify_method_signature (m, NULL, cols [MONO_METHOD_SEMA_METHOD]);
+ sig = dis_stringify_method_signature (m, NULL, cols [MONO_METHOD_SEMA_METHOD], TRUE);
fprintf (output, "\t\t%s %s\n", type [cols [MONO_METHOD_SEMA_SEMANTICS]], sig);
g_free (sig);
++start;
type = mono_metadata_parse_type (m, MONO_PARSE_TYPE, 0, ptr, &ptr);
blurb = dis_stringify_type (m, type);
if (prop_flags & 0x0200)
- g_string_append (res, "special ");
+ g_string_append (res, "specialname ");
if (prop_flags & 0x0400)
- g_string_append (res, "runtime ");
- if (prop_flags & 0x1000)
- g_string_append (res, "hasdefault ");
+ g_string_append (res, "rtspecialname ");
g_string_sprintfa (res, "%s %s (", blurb, name);
g_free (blurb);
mono_metadata_free_type (type);
dis_event_signature (MonoImage *m, guint32 event_idx)
{
MonoTableInfo *et = &m->tables [MONO_TABLE_EVENT];
- const char *name;
- char *type, *res;
+ char *type, *res, *esname;
guint32 cols [MONO_EVENT_SIZE];
mono_metadata_decode_row (et, event_idx, cols, MONO_EVENT_SIZE);
- name = mono_metadata_string_heap (m, cols [MONO_EVENT_NAME]);
+ esname = get_escaped_name (mono_metadata_string_heap (m, cols [MONO_EVENT_NAME]));
type = get_typedef_or_ref (m, cols [MONO_EVENT_TYPE]);
- res = g_strdup_printf ("%s %s", type, name);
+ res = g_strdup_printf ("%s %s", type, esname);
g_free (type);
+ g_free (esname);
return res;
}
MonoTableInfo *msemt = &m->tables [MONO_TABLE_METHODSEMANTICS];
guint32 cols [MONO_METHOD_SEMA_SIZE];
char *sig;
- const char *type;
+ const char *type = "";
start = mono_metadata_methods_from_event (m, event, &end);
while (start < end) {
mono_metadata_decode_row (msemt, start, cols, MONO_METHOD_SEMA_SIZE);
- sig = dis_stringify_method_signature (m, NULL, cols [MONO_METHOD_SEMA_METHOD]);
+ sig = dis_stringify_method_signature (m, NULL, cols [MONO_METHOD_SEMA_METHOD], TRUE);
switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
case METHOD_SEMANTIC_OTHER:
type = ".other"; break;
{
plocator_t loc;
guint start;
+ gboolean first_interface = 1;
guint32 cols [MONO_INTERFACEIMPL_SIZE];
char *intf;
MonoTableInfo *table = &m->tables [MONO_TABLE_INTERFACEIMPL];
if (cols [MONO_INTERFACEIMPL_CLASS] != loc.idx)
break;
intf = get_typedef_or_ref (m, cols [MONO_INTERFACEIMPL_INTERFACE]);
- fprintf (output, " \timplements %s\n", intf);
+ if (first_interface) {
+ fprintf (output, " \timplements %s", intf);
+ first_interface = 0;
+ } else {
+ fprintf (output, ", %s", intf);
+ }
g_free (intf);
++start;
}
}
+/**
+ * dis_generic_param_and_constraints:
+ * @m: metadata context
+ * @table_type: Type of table (0 for typedef, 1 for methoddef)
+ * @row: Row in table
+ *
+ * Dissasembles the generic parameters for this type or method, also
+ * returns an allocated GString containing the generic constraints NULL
+ * if their are no generic constraints.
+ */
+static GString*
+dis_generic_param_and_constraints (MonoImage *m, int table_type, guint32 typedef_row)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_GENERICPARAM];
+ MonoTableInfo *ct = &m->tables [MONO_TABLE_GENERICPARAMCONSTRAINT];
+ GString* cnst_block = NULL;
+ guint32 cols [MONO_GENERICPARAM_SIZE];
+ guint32 ccols [MONO_GENPARCONSTRAINT_SIZE];
+ int i, own_tok, table, idx, found_count, cnst_start, cnst_ind;
+
+ g_assert (table_type != MONO_TYPEORMETHOD_TYPE || table_type != MONO_TYPEORMETHOD_METHOD);
+
+ found_count = cnst_start = 0;
+ for (i = 1; i <= t->rows; i++) {
+ mono_metadata_decode_row (t, i-1, cols, MONO_GENERICPARAM_SIZE);
+ own_tok = cols [MONO_GENERICPARAM_OWNER];
+ table = own_tok & MONO_TYPEORMETHOD_MASK;
+ idx = own_tok >> MONO_TYPEORMETHOD_BITS;
+
+ if (table != table_type || idx != typedef_row)
+ continue;
+
+ if (found_count == 0)
+ fprintf (output, "<%s", mono_metadata_string_heap (m, cols [MONO_GENERICPARAM_NAME]));
+ else
+ fprintf (output, ", %s", mono_metadata_string_heap (m, cols [MONO_GENERICPARAM_NAME]));
+
+ for (cnst_ind = cnst_start; cnst_ind < ct->rows; cnst_ind++) {
+ char *sig;
+ mono_metadata_decode_row (ct, cnst_ind, ccols, MONO_GENPARCONSTRAINT_SIZE);
+ if (ccols [MONO_GENPARCONSTRAINT_GENERICPAR] != i)
+ continue;
+ if (cnst_block == NULL)
+ cnst_block = g_string_new ("");
+ sig = get_typedef_or_ref (m, ccols [MONO_GENPARCONSTRAINT_CONSTRAINT]);
+ g_string_append_printf (cnst_block, " .constraint !%d is %s\n",
+ cols [MONO_GENERICPARAM_NUMBER], sig);
+ g_free (sig);
+ cnst_start = cnst_ind;
+ }
+
+ found_count++;
+ }
+
+ if (found_count)
+ fprintf (output, ">");
+
+ return cnst_block;
+}
+
/**
* dis_type:
* @m: metadata context
dis_type (MonoImage *m, int n)
{
MonoTableInfo *t = &m->tables [MONO_TABLE_TYPEDEF];
+ GString *cnst_block = NULL;
guint32 cols [MONO_TYPEDEF_SIZE];
guint32 cols_next [MONO_TYPEDEF_SIZE];
const char *name, *nspace;
+ char *esname;
guint32 packing_size, class_size;
gboolean next_is_valid, last;
-
+ guint32 nested;
+
mono_metadata_decode_row (t, n, cols, MONO_TYPEDEF_SIZE);
if (t->rows > n + 1) {
} else
next_is_valid = 0;
+ name = mono_metadata_string_heap (m, cols [MONO_TYPEDEF_NAME]);
nspace = mono_metadata_string_heap (m, cols [MONO_TYPEDEF_NAMESPACE]);
if (*nspace)
fprintf (output, ".namespace %s\n{\n", nspace);
- name = mono_metadata_string_heap (m, cols [MONO_TYPEDEF_NAME]);
+ esname = get_escaped_name (name);
if ((cols [MONO_TYPEDEF_FLAGS] & TYPE_ATTRIBUTE_CLASS_SEMANTIC_MASK) == TYPE_ATTRIBUTE_CLASS){
- fprintf (output, " .class %s%s\n", typedef_flags (cols [MONO_TYPEDEF_FLAGS]), name);
+ fprintf (output, " .class %s%s", typedef_flags (cols [MONO_TYPEDEF_FLAGS]), esname);
+
+ cnst_block = dis_generic_param_and_constraints (m, MONO_TYPEORMETHOD_TYPE, n+1);
+ fprintf (output, "\n");
if (cols [MONO_TYPEDEF_EXTENDS]) {
char *base = get_typedef_or_ref (m, cols [MONO_TYPEDEF_EXTENDS]);
fprintf (output, " \textends %s\n", base);
g_free (base);
}
} else
- fprintf (output, " .class interface %s%s\n", typedef_flags (cols [MONO_TYPEDEF_FLAGS]), name);
-
+ fprintf (output, " .class interface %s%s\n", typedef_flags (cols [MONO_TYPEDEF_FLAGS]), esname);
+ g_free (esname);
dis_interfaces (m, n + 1);
fprintf (output, " {\n");
+ if (cnst_block) {
+ fprintf (output, "%s", cnst_block->str);
+ g_string_free (cnst_block, TRUE);
+ }
dump_cattrs (m, MONO_TOKEN_TYPE_DEF | (n + 1), " ");
if (mono_metadata_packing_from_typedef (m, n + 1, &packing_size, &class_size)) {
last = m->tables [MONO_TABLE_METHOD].rows;
if (cols [MONO_TYPEDEF_METHOD_LIST] && cols [MONO_TYPEDEF_METHOD_LIST] <= m->tables [MONO_TABLE_METHOD].rows)
- dis_method_list (m, cols [MONO_TYPEDEF_METHOD_LIST] - 1, last);
+ dis_method_list (name, m, cols [MONO_TYPEDEF_METHOD_LIST] - 1, last);
dis_property_list (m, n);
dis_event_list (m, n);
+ t = &m->tables [MONO_TABLE_NESTEDCLASS];
+ nested = mono_metadata_nesting_typedef (m, n + 1, 1);
+ while (nested) {
+ dis_type (m, mono_metadata_decode_row_col (t, nested - 1, MONO_NESTED_CLASS_NESTED) - 1);
+ nested = mono_metadata_nesting_typedef (m, n + 1, nested + 1);
+ }
+
fprintf (output, " } // end of type %s%s%s\n", nspace, *nspace? ".": "", name);
if (*nspace)
fprintf (output, "}\n");
fprintf (output, "\n");
}
+
+/**
+ * dis_globals
+ * @m: metadata context
+ *
+ * disassembles all the global fields and methods
+ */
+static void
+dis_globals (MonoImage *m)
+{
+ MonoTableInfo *t = &m->tables [MONO_TABLE_TYPEDEF];
+ guint32 cols [MONO_TYPEDEF_SIZE];
+ guint32 cols_next [MONO_TYPEDEF_SIZE];
+ gboolean next_is_valid, last;
+ gchar *name;
+
+ name = g_strdup ("<Module>");
+
+ mono_metadata_decode_row (t, 0, cols, MONO_TYPEDEF_SIZE);
+
+ if (t->rows > 1) {
+ mono_metadata_decode_row (t, 1, cols_next, MONO_TYPEDEF_SIZE);
+ next_is_valid = 1;
+ } else
+ next_is_valid = 0;
+
+ /*
+ * The value in the table is always valid, we know we have fields
+ * if the value stored is different than the next record.
+ */
+
+ if (next_is_valid)
+ last = cols_next [MONO_TYPEDEF_FIELD_LIST] - 1;
+ else
+ last = m->tables [MONO_TABLE_FIELD].rows;
+
+ if (cols [MONO_TYPEDEF_FIELD_LIST] && cols [MONO_TYPEDEF_FIELD_LIST] <= m->tables [MONO_TABLE_FIELD].rows)
+ dis_field_list (m, cols [MONO_TYPEDEF_FIELD_LIST] - 1, last);
+ fprintf (output, "\n");
+
+ if (next_is_valid)
+ last = cols_next [MONO_TYPEDEF_METHOD_LIST] - 1;
+ else
+ last = m->tables [MONO_TABLE_METHOD].rows;
+
+ if (cols [MONO_TYPEDEF_METHOD_LIST] && cols [MONO_TYPEDEF_METHOD_LIST] <= m->tables [MONO_TABLE_METHOD].rows)
+ dis_method_list (name, m, cols [MONO_TYPEDEF_METHOD_LIST] - 1, last);
+
+}
+
/**
* dis_types:
* @m: metadata context
{
MonoTableInfo *t = &m->tables [MONO_TABLE_TYPEDEF];
int i;
-
- for (i = 1; i < t->rows; i++)
- dis_type (m, i);
+ guint32 flags;
+
+ dis_globals (m);
+
+ for (i = 1; i < t->rows; i++) {
+ flags = mono_metadata_decode_row_col (t, i, MONO_TYPEDEF_FLAGS);
+ flags &= TYPE_ATTRIBUTE_VISIBILITY_MASK;
+ if (flags == TYPE_ATTRIBUTE_PUBLIC || flags == TYPE_ATTRIBUTE_NOT_PUBLIC)
+ dis_type (m, i);
+ }
}
/**
g_assert (*sig == 0x06);
type = mono_metadata_parse_field_type (m, 0, sig + 1, &sig);
mono_class_init (mono_class_from_mono_type (type));
- size = mono_class_value_size (mono_class_from_mono_type (type), &align);
+ size = mono_type_size (type, &align);
fprintf (output, ".data D_%08x = bytearray (", cols [MONO_FIELD_RVA_RVA]);
for (b = 0; b < size; ++b) {
if (!(b % 16))
fprintf (output, "\n\t");
- fprintf (output, " %02x", rva [b] & 0xff);
+ fprintf (output, " %02X", rva [b] & 0xff);
}
fprintf (output, ") // size: %d\n", size);
}
int table;
void (*dumper) (MonoImage *m);
} table_list [] = {
- { "--assembly", MONO_TABLE_ASSEMBLY, dump_table_assembly },
- { "--assemblyref", MONO_TABLE_ASSEMBLYREF, dump_table_assemblyref },
- { "--fields", MONO_TABLE_FIELD, dump_table_field },
- { "--marshal", MONO_TABLE_FIELDMARSHAL, dump_table_field_marshal },
- { "--memberref", MONO_TABLE_MEMBERREF, dump_table_memberref },
- { "--param", MONO_TABLE_PARAM, dump_table_param },
- { "--typedef", MONO_TABLE_TYPEDEF, dump_table_typedef },
- { "--typeref", MONO_TABLE_TYPEREF, dump_table_typeref },
+ { "--assembly", MONO_TABLE_ASSEMBLY, dump_table_assembly },
+ { "--assemblyref", MONO_TABLE_ASSEMBLYREF, dump_table_assemblyref },
+ { "--classlayout", MONO_TABLE_CLASSLAYOUT, dump_table_class_layout },
+ { "--constant", MONO_TABLE_CONSTANT, dump_table_constant },
+ { "--customattr", MONO_TABLE_CUSTOMATTRIBUTE, dump_table_customattr },
+ { "--declsec", MONO_TABLE_DECLSECURITY, dump_table_declsec },
+ { "--event", MONO_TABLE_EVENT, dump_table_event },
{ "--exported", MONO_TABLE_EXPORTEDTYPE, dump_table_exported },
- { "--nested", MONO_TABLE_NESTEDCLASS, dump_table_nestedclass },
- { "--interface", MONO_TABLE_INTERFACEIMPL, dump_table_interfaceimpl },
- { "--classlayout", MONO_TABLE_CLASSLAYOUT, dump_table_class_layout },
- { "--constant", MONO_TABLE_CONSTANT, dump_table_constant },
- { "--customattr", MONO_TABLE_CUSTOMATTRIBUTE, dump_table_customattr },
- { "--declsec", MONO_TABLE_DECLSECURITY, dump_table_declsec },
- { "--property", MONO_TABLE_PROPERTY, dump_table_property },
- { "--propertymap", MONO_TABLE_PROPERTYMAP, dump_table_property_map },
- { "--event", MONO_TABLE_EVENT, dump_table_event },
- { "--file", MONO_TABLE_FILE, dump_table_file },
- { "--moduleref", MONO_TABLE_MODULEREF, dump_table_moduleref },
- { "--module", MONO_TABLE_MODULE, dump_table_module },
- { "--method", MONO_TABLE_METHOD, dump_table_method },
- { "--methodimpl", MONO_TABLE_METHODIMPL, dump_table_methodimpl },
- { "--methodsem", MONO_TABLE_METHODSEMANTICS, dump_table_methodsem },
- { "--manifest", MONO_TABLE_MANIFESTRESOURCE, dump_table_manifest },
+ { "--fields", MONO_TABLE_FIELD, dump_table_field },
+ { "--file", MONO_TABLE_FILE, dump_table_file },
+ { "--genericpar", MONO_TABLE_GENERICPARAM, dump_table_genericpar },
+ { "--interface", MONO_TABLE_INTERFACEIMPL, dump_table_interfaceimpl },
+ { "--manifest", MONO_TABLE_MANIFESTRESOURCE, dump_table_manifest },
+ { "--marshal", MONO_TABLE_FIELDMARSHAL, dump_table_field_marshal },
+ { "--memberref", MONO_TABLE_MEMBERREF, dump_table_memberref },
+ { "--method", MONO_TABLE_METHOD, dump_table_method },
+ { "--methodimpl", MONO_TABLE_METHODIMPL, dump_table_methodimpl },
+ { "--methodsem", MONO_TABLE_METHODSEMANTICS, dump_table_methodsem },
+ { "--methodspec", MONO_TABLE_METHODSPEC, dump_table_methodspec },
+ { "--moduleref", MONO_TABLE_MODULEREF, dump_table_moduleref },
+ { "--module", MONO_TABLE_MODULE, dump_table_module },
+ { "--nested", MONO_TABLE_NESTEDCLASS, dump_table_nestedclass },
+ { "--param", MONO_TABLE_PARAM, dump_table_param },
+ { "--parconst", MONO_TABLE_GENERICPARAMCONSTRAINT, dump_table_parconstraint },
+ { "--property", MONO_TABLE_PROPERTY, dump_table_property },
+ { "--propertymap", MONO_TABLE_PROPERTYMAP, dump_table_property_map },
+ { "--typedef", MONO_TABLE_TYPEDEF, dump_table_typedef },
+ { "--typeref", MONO_TABLE_TYPEREF, dump_table_typeref },
+ { "--typespec", MONO_TABLE_TYPESPEC, dump_table_typespec },
+ { "--implmap", MONO_TABLE_IMPLMAP, dump_table_implmap },
+ { "--blob", NULL, dump_stream_blob },
{ NULL, -1 }
};
dis_directive_assemblyref (img);
dis_directive_assembly (img);
+ dis_directive_file (img);
+ dis_directive_module (img);
+ dis_directive_moduleref (img);
dis_types (img);
dis_data (img);
}
static void
usage (void)
{
- GString *args = g_string_new ("[--output=filename] [--help] [--mscorlib] ");
+ GString *args = g_string_new ("[--output=filename] [--help] [--mscorlib]\n");
int i;
for (i = 0; table_list [i].name != NULL; i++){
int i, j;
output = stdout;
+ init_key_table ();
for (i = 1; i < argc; i++){
if (argv [i][0] == '-'){
if (argv [i][1] == 'h')
else if (strcmp (argv [i], "--mscorlib") == 0) {
substitute_with_mscorlib_p = TRUE;
continue;
+ } else if (strcmp (argv [i], "--show-method-tokens") == 0) {
+ show_method_tokens = TRUE;
+ continue;
+ } else if (strcmp (argv [i], "--show-tokens") == 0) {
+ show_tokens = TRUE;
+ continue;
} else if (strncmp (argv [i], "--output=", 9) == 0) {
output = fopen (argv [i]+9, "w");
if (output == NULL) {