diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-03-07 00:13:16 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-03-07 00:13:16 (GMT) |
commit | 9714ddda44f92f2939299c6b0aa203d549c32b0d (patch) | |
tree | 547465ef4ff7ec447979554de076eb3be66e4d04 /src/arch/dalvik | |
parent | 13bd8d546b2de76b1f5a1d758c9e476f7d859f39 (diff) |
Printed raw types, fields and methods when rendering the disassembled code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@238 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/dalvik')
-rw-r--r-- | src/arch/dalvik/operands/pool.c | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/src/arch/dalvik/operands/pool.c b/src/arch/dalvik/operands/pool.c index 3e0a948..7ec370c 100644 --- a/src/arch/dalvik/operands/pool.c +++ b/src/arch/dalvik/operands/pool.c @@ -27,6 +27,9 @@ #include <string.h> +#include <i18n.h> + + #include "../../operand-int.h" #include "../../../format/dex/pool.h" @@ -176,43 +179,79 @@ GArchOperand *g_dalvik_pool_operand_new(const GDexFormat *format, DalvikPoolType static void g_dalvik_pool_operand_print(const GDalvikPoolOperand *operand, GBufferLine *line, AsmSyntax syntax) { - const char *string; /* Chaîne de caractères */ - - char value[20]; /* Chaîne à imprimer */ - size_t len; /* Taille de l'élément inséré */ + const char *string; /* Chaîne de caractères #1 */ + GOpenidaType *type; /* Type à représenter */ + char *tmp; /* Chaîne de caractères #2 */ + GBinVariable *field; /* Champ à représenter */ + GBinRoutine *routine; /* Routine à représenter */ switch (operand->type) { case DPT_NONE: g_buffer_line_insert_text(line, BLC_ASSEMBLY, "????", 4, RTT_SECTION); break; + case DPT_STRING: g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING); string = get_string_from_dex_pool(operand->format, operand->index); g_buffer_line_insert_text(line, BLC_ASSEMBLY, string, strlen(string), RTT_STRING); g_buffer_line_insert_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING); break; + case DPT_TYPE: - g_buffer_line_insert_text(line, BLC_ASSEMBLY, "type", 4, RTT_SECTION); + type = get_type_from_dex_pool(operand->format, operand->index); + + if (type != NULL) + { + tmp = g_openida_type_to_string(type); + g_object_unref(G_OBJECT(type)); + } + else + tmp = strdup(_("invalid type")); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK); + free(tmp); break; + case DPT_PROTO: - g_buffer_line_insert_text(line, BLC_ASSEMBLY, "proto", 5, RTT_SECTION); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, "proto(/*TODO*/)", 5, RTT_SECTION); break; + case DPT_FIELD: - g_buffer_line_insert_text(line, BLC_ASSEMBLY, "field", 5, RTT_SECTION); + field = get_field_from_dex_pool(operand->format, operand->index); + + if (field != NULL) + { + tmp = g_binary_variable_to_string(field, false); + g_object_unref(G_OBJECT(field)); + } + else + tmp = strdup(_("invalid field")); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK); break; + case DPT_METHOD: - g_buffer_line_insert_text(line, BLC_ASSEMBLY, "method", 6, RTT_SECTION); + routine = get_routine_from_dex_pool(operand->format, operand->index); + + if (routine != NULL) + { + tmp = g_binary_routine_to_string(routine); + g_object_unref(G_OBJECT(routine)); + } + else + tmp = strdup(_("invalid method")); + + g_buffer_line_insert_text(line, BLC_ASSEMBLY, "<", 1, RTT_HOOK); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, tmp, strlen(tmp), RTT_VAR_NAME); + g_buffer_line_insert_text(line, BLC_ASSEMBLY, ">", 1, RTT_HOOK); break; - } - if (operand->type == DPT_STRING) - return; - - g_buffer_line_insert_text(line, BLC_ASSEMBLY, "@", 1, RTT_SIGNS); - - len = snprintf(value, 20, "%d", operand->index); - g_buffer_line_insert_text(line, BLC_ASSEMBLY, value, len, RTT_IMMEDIATE); + } } |