summaryrefslogtreecommitdiff
path: root/plugins/dex/pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dex/pool.c')
-rw-r--r--plugins/dex/pool.c180
1 files changed, 154 insertions, 26 deletions
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index 9f3d55d..bfc463a 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -53,6 +53,7 @@
bool find_all_dex_strings(GDexFormat *format)
{
GBinFormat *base; /* Autre version du format */
+ uint32_t count; /* Nombre d'éléments présents */
uint32_t i; /* Boucle de parcours */
mrange_t range; /* Couverture associée */
const char *text; /* Texte issu du binaire */
@@ -61,7 +62,9 @@ bool find_all_dex_strings(GDexFormat *format)
base = G_BIN_FORMAT(format);
- for (i = 0; i < format->header.string_ids_size; i++)
+ count = count_strings_in_dex_pool(format);
+
+ for (i = 0; i < count; i++)
{
text = get_string_from_dex_pool(format, i, &range);
if (text == NULL) continue;
@@ -86,6 +89,29 @@ bool find_all_dex_strings(GDexFormat *format)
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
+* *
+* Description : Compte le nombre de chaînes de caractères dans une table DEX.*
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t count_strings_in_dex_pool(const GDexFormat *format)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = format->header.string_ids_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du type recherchée. *
* range = éventuelle couverture à renseigner ou NULL. [OUT] *
* *
@@ -99,6 +125,7 @@ bool find_all_dex_strings(GDexFormat *format)
const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, mrange_t *range)
{
+ uint32_t count; /* Nombre d'éléments présents */
off_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
string_id_item str_id; /* Identifiant de chaîne */
@@ -106,7 +133,9 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
vmpa2t start; /* Début de la chaîne */
phys_t diff; /* Avancée de tête de lecture */
- if (index >= format->header.string_ids_size)
+ count = count_strings_in_dex_pool(format);
+
+ if (index >= count)
return NULL;
pos = format->header.string_ids_off + index * sizeof(string_id_item);
@@ -135,16 +164,6 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
}
-
-
-
-
-
-
-
-
-
-
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à compléter. *
@@ -162,6 +181,7 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
guint runs_count; /* Qté d'exécutions parallèles */
uint32_t run_size; /* Volume réparti par exécution*/
GWorkQueue *queue; /* Gestionnaire de différés */
@@ -175,25 +195,26 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
/* Préparation du réceptacle */
- format->types = (GDataType **)calloc(format->header.type_ids_size, sizeof(GDataType *));
+ count = count_types_in_dex_pool(format);
+
+ format->types = (GDataType **)calloc(count, sizeof(GDataType *));
/* Lancement des chargements */
runs_count = g_get_num_processors();
- run_size = format->header.type_ids_size / runs_count;
+ run_size = count / runs_count;
queue = get_work_queue();
- msg = gtk_status_stack_add_activity(status, _("Loading all types from the Dex pool..."),
- format->header.type_ids_size);
+ msg = gtk_status_stack_add_activity(status, _("Loading all types from the Dex pool..."), count);
for (i = 0; i < runs_count; i++)
{
begin = i * run_size;
if ((i + 1) == runs_count)
- end = format->header.type_ids_size;
+ end = count;
else
end = begin + run_size;
@@ -216,6 +237,29 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
+* *
+* Description : Compte le nombre de types dans une table DEX. *
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t count_types_in_dex_pool(const GDexFormat *format)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = format->header.type_ids_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du type recherchée. *
* *
* Description : Extrait une représentation de type d'une table DEX. *
@@ -229,6 +273,7 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
{
GDataType *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
type_id_item type_id; /* Définition de la classe */
@@ -238,7 +283,9 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
result = NULL;
- if (index >= format->header.type_ids_size)
+ count = count_types_in_dex_pool(format);
+
+ if (index >= count)
goto gtfdp_error;
if (format->types[index] == NULL)
@@ -295,6 +342,7 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
guint runs_count; /* Qté d'exécutions parallèles */
uint32_t run_size; /* Volume réparti par exécution*/
GWorkQueue *queue; /* Gestionnaire de différés */
@@ -308,25 +356,27 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
/* Préparation du réceptacle */
- format->fields = (GBinVariable **)calloc(format->header.field_ids_size, sizeof(GBinVariable *));
+ count = count_fields_in_dex_pool(format);
+
+ format->fields = (GBinVariable **)calloc(count, sizeof(GBinVariable *));
/* Lancement des chargements */
runs_count = g_get_num_processors();
- run_size = format->header.field_ids_size / runs_count;
+ run_size = count / runs_count;
queue = get_work_queue();
msg = gtk_status_stack_add_activity(status, _("Loading all fields from the Dex pool..."),
- format->header.field_ids_size);
+ count);
for (i = 0; i < runs_count; i++)
{
begin = i * run_size;
if ((i + 1) == runs_count)
- end = format->header.field_ids_size;
+ end = count;
else
end = begin + run_size;
@@ -349,6 +399,29 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
+* *
+* Description : Compte le nombre de champs dans une table DEX. *
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t count_fields_in_dex_pool(const GDexFormat *format)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = format->header.field_ids_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du champ recherché. *
* *
* Description : Extrait une représentation de champ d'une table DEX. *
@@ -362,6 +435,7 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
{
GBinVariable *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
field_id_item field_id; /* Description du champ */
@@ -372,7 +446,9 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
result = NULL;
- if (index >= format->header.field_ids_size)
+ count = count_fields_in_dex_pool(format);
+
+ if (index >= count)
goto gffdp_error;
if (format->fields[index] == NULL)
@@ -430,6 +506,29 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
+* *
+* Description : Compte le nombre de prototypes dans une table DEX. *
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t count_prototypes_in_dex_pool(const GDexFormat *format)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = format->header.proto_ids_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index de la routine recherchée. *
* *
* Description : Extrait une représentation de routine d'une table DEX. *
@@ -443,6 +542,7 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
{
GBinRoutine *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
proto_id_item proto_id; /* Prototype de routine */
@@ -460,7 +560,9 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
* les autres éléments de la table des constantes.
*/
- if (index >= format->header.proto_ids_size)
+ count = count_prototypes_in_dex_pool(format);
+
+ if (index >= count)
goto grfdp_error;
pos = format->header.proto_ids_off + index * sizeof(proto_id_item);
@@ -499,7 +601,7 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
///////result = demangle_routine(G_TYPE_DEX_DEMANGLER, name);
- g_binary_routine_set_name(result, strdup("..."));
+ //g_binary_routine_set_name(result, strdup("..."));
#if 1
if (result != NULL)///////////////////////
@@ -521,6 +623,29 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à consulter. *
+* *
+* Description : Compte le nombre de méthodes dans une table DEX. *
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t count_methods_in_dex_pool(const GDexFormat *format)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = format->header.method_ids_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index de la classe recherchée. *
* *
* Description : Extrait une représentation de méthode d'une table DEX. *
@@ -534,13 +659,16 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)
{
GDexMethod *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
method_id_item method_id; /* Définition de la méthode */
result = NULL;
- if (index >= format->header.method_ids_size)
+ count = count_methods_in_dex_pool(format);
+
+ if (index >= count)
goto gmfdp_error;
/**