diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-04-23 20:23:33 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-04-23 20:23:33 (GMT) |
commit | 3284ce333cc4b09d9150b59c60005af8e4ddc417 (patch) | |
tree | ff9c6a51e20f3a15654005f1c9e2ee22d91e7b6c /src/format/dex/method.c | |
parent | df4bc1a413561f9de095e1c30c678bd7272c3478 (diff) |
Loaded all Dex methods in a proper way.
Diffstat (limited to 'src/format/dex/method.c')
-rw-r--r-- | src/format/dex/method.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/format/dex/method.c b/src/format/dex/method.c index bc4a063..f91af0d 100644 --- a/src/format/dex/method.c +++ b/src/format/dex/method.c @@ -24,6 +24,7 @@ #include "method.h" +#include <stddef.h> #include <string.h> @@ -174,12 +175,12 @@ static void g_dex_method_finalize(GDexMethod *method) * * ******************************************************************************/ -GDexMethod *g_dex_method_new(GDexFormat *format, const encoded_method *seed, uleb128_t *last) +GDexMethod *g_dex_method_new_defined(GDexFormat *format, const encoded_method *seed, uleb128_t *last) { GDexMethod *result; /* Composant à retourner */ vmpa2t addr; /* Tête de lecture générique */ code_item item; /* Corps de la méthode */ - GBinRoutine *routine; /* Routine représentée */ + phys_t ins_offset; /* Position physique du code */ mrange_t range; /* Emplacement du code associé */ init_vmpa(&addr, seed->code_off, VMPA_NO_VIRTUAL); @@ -188,23 +189,24 @@ GDexMethod *g_dex_method_new(GDexFormat *format, const encoded_method *seed, ule return NULL; *last += seed->method_idx_diff; - routine = get_prototype_from_dex_pool(format, *last); - if (routine == NULL) return NULL; + ins_offset = seed->code_off + offsetof(code_item, insns); - result = g_object_new(G_TYPE_DEX_METHOD, NULL); + if (!g_exe_format_translate_offset_into_vmpa(G_EXE_FORMAT(format), ins_offset, &addr)) + return NULL; + + result = get_method_from_dex_pool(format, *last); + + if (result == NULL) + return NULL; result->info = *seed; result->body = item; - result->offset = seed->code_off + 4 * sizeof(uint16_t) + 2 * sizeof(uint32_t);/* TODO : faire plus propre ! */ + result->offset = ins_offset; - init_vmpa(&addr, result->offset, VMPA_NO_VIRTUAL); init_mrange(&range, &addr, item.insns_size * sizeof(uint16_t)); - - g_binary_routine_set_range(routine, &range); - - result->routine = routine; + g_binary_routine_set_range(result->routine, &range); return result; @@ -224,7 +226,7 @@ GDexMethod *g_dex_method_new(GDexFormat *format, const encoded_method *seed, ule * * ******************************************************************************/ -GDexMethod *g_dex_method_new_empty(GDexFormat *format, const method_id_item *method_id) +GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *method_id) { GDexMethod *result; /* Composant à retourner */ const char *name; /* Nom de la routine finale */ |