summaryrefslogtreecommitdiff
path: root/src/format/dex/pool.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-04-23 20:23:33 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-04-23 20:23:33 (GMT)
commit3284ce333cc4b09d9150b59c60005af8e4ddc417 (patch)
treeff9c6a51e20f3a15654005f1c9e2ee22d91e7b6c /src/format/dex/pool.c
parentdf4bc1a413561f9de095e1c30c678bd7272c3478 (diff)
Loaded all Dex methods in a proper way.
Diffstat (limited to 'src/format/dex/pool.c')
-rw-r--r--src/format/dex/pool.c66
1 files changed, 15 insertions, 51 deletions
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index 056443e..3842aa9 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -443,44 +443,6 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à compléter. *
-* *
-* Description : Charge toutes les méthodes listées dans le contenu binaire. *
-* *
-* Retour : Bilan de l'opération. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-bool load_all_dex_methods(GDexFormat *format)
-{
- bool result; /* Bilan à retourner */
- uint32_t i; /* Boucle de parcours */
- GDexMethod *method; /* Méthode récupérée */
-
- result = true;
-
- format->methods = (GDexMethod **)calloc(format->header.method_ids_size, sizeof(GDexMethod *));
-
- for (i = 0; i < format->header.method_ids_size && result; i++)
- {
- method = get_method_from_dex_pool(format, i);
-
- if (method != NULL)
- g_object_unref(G_OBJECT(method));
- else
- result = false;
-
- }
-
- return result;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index de la classe recherchée. *
* *
@@ -504,22 +466,24 @@ GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)
if (index >= format->header.method_ids_size)
goto gmfdp_error;
- if (format->methods[index] == NULL)
- {
- pos = format->header.method_ids_off + index * sizeof(method_id_item);
- init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
-
- if (!read_dex_method_id_item(format, &addr, &method_id))
- goto gmfdp_error;
-
- format->methods[index] = g_dex_method_new_empty(format, &method_id);
+ /**
+ * On charge ici une méthode à partir de la définition de 'method_id_item'.
+ *
+ * C'est l'élément 'encoded_method' qui référence cette cette définition et qui
+ * applique ensuite les attributs finaux de la méthode. La classe parente est
+ * précisée en outre bien en amont.
+ *
+ * Comme une même définition peut donc servir à plusieurs instances,
+ * on ne peut pas conserver un tableau d'allocations communes.
+ */
- }
+ pos = format->header.method_ids_off + index * sizeof(method_id_item);
+ init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
- result = format->methods[index];
+ if (!read_dex_method_id_item(format, &addr, &method_id))
+ goto gmfdp_error;
- if (result != NULL)
- g_object_ref(G_OBJECT(result));
+ result = g_dex_method_new_callable(format, &method_id);
gmfdp_error: