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.c401
1 files changed, 299 insertions, 102 deletions
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index 90c991b..6905c3b 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -41,9 +41,155 @@
+/* Table des ressources pour format Dex (instance) */
+struct _GDexPool
+{
+ GObject parent; /* A laisser en premier */
+
+ GDexFormat *format; /* Format de rattachement */
+
+ GBinSymbol **strings; /* Symboles pour les chaînes */
+ GDataType **types; /* Types partagés pour Dalvik */
+ GBinVariable **fields; /* Champs de données partagés */
+ GDexMethod **methods; /* Méthodes déclarées */
+ GDexClass **classes; /* Classes retrouvées */
+
+};
+
+/* Table des ressources pour format Dex (classe) */
+struct _GDexPoolClass
+{
+ GObjectClass parent; /* A laisser en premier */
+
+};
+
+
+/* Procède à l'initialisation des tables de ressources pour Dex. */
+static void g_dex_pool_class_init(GDexPoolClass *);
+
+/* Procède à l'initialisation d'une table de ressources Dex. */
+static void g_dex_pool_init(GDexPool *);
+
+/* Supprime toutes les références externes. */
+static void g_dex_pool_dispose(GDexPool *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_dex_pool_finalize(GDexPool *);
+
+
+
+/* Détermine le type d'une table des ressources pour format Dex. */
+G_DEFINE_TYPE(GDexPool, g_dex_pool, G_TYPE_OBJECT);
+
+
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à compléter. *
+* Paramètres : class = classe de composant GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation des tables de ressources pour Dex.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_pool_class_init(GDexPoolClass *class)
+{
+ GObjectClass *object; /* Autre version de la classe */
+
+ object = G_OBJECT_CLASS(class);
+
+ object->dispose = (GObjectFinalizeFunc/* ! */)g_dex_pool_dispose;
+ object->finalize = (GObjectFinalizeFunc)g_dex_pool_finalize;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pool = composant GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation d'une table de ressources Dex. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_pool_init(GDexPool *pool)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pool = instance d'objet GLib à traiter. *
+* *
+* Description : Supprime toutes les références externes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_pool_dispose(GDexPool *pool)
+{
+ G_OBJECT_CLASS(g_dex_pool_parent_class)->dispose(G_OBJECT(pool));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pool = instance d'objet GLib à traiter. *
+* *
+* Description : Procède à la libération totale de la mémoire. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_pool_finalize(GDexPool *pool)
+{
+ G_OBJECT_CLASS(g_dex_pool_parent_class)->finalize(G_OBJECT(pool));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format Dex à consulter. *
+* *
+* Description : Crée une nouvelle table de ressources pour format Dex. *
+* *
+* Retour : Composant GLib créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDexPool *g_dex_pool_new(GDexFormat *format)
+{
+ GDexPool *result; /* Composant à retourner */
+
+ result = g_object_new(G_TYPE_DEX_POOL, NULL);
+
+ result->format = format;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pool = table de ressources pour format Dex à compléter. *
* gid = groupe de travail impliqué. *
status = barre de statut à tenir informée. *
* *
@@ -55,7 +201,7 @@
* *
******************************************************************************/
-bool load_all_dex_string_symbols(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+bool g_dex_pool_load_all_string_symbols(GDexPool *pool, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
uint32_t count; /* Nombre d'éléments présents */
@@ -72,9 +218,9 @@ bool load_all_dex_string_symbols(GDexFormat *format, wgroup_id_t gid, GtkStatusS
/* Préparation du réceptacle */
- count = count_strings_in_dex_pool(format);
+ count = g_dex_pool_count_strings(pool);
- format->strings = (GBinSymbol **)calloc(count, sizeof(GBinSymbol *));
+ pool->strings = calloc(count, sizeof(GBinSymbol *));
/* Lancement des chargements */
@@ -93,8 +239,8 @@ bool load_all_dex_string_symbols(GDexFormat *format, wgroup_id_t gid, GtkStatusS
else
end = begin + run_size;
- loading = g_dex_loading_new(format, begin, end, msg,
- (dex_loading_cb)get_string_symbol_from_dex_pool, &result);
+ loading = g_dex_loading_new(G_OBJECT(pool), begin, end, msg,
+ (dex_loading_cb)g_dex_pool_get_string_symbol, &result);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(loading), gid);
@@ -111,7 +257,7 @@ bool load_all_dex_string_symbols(GDexFormat *format, wgroup_id_t gid, GtkStatusS
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
* *
* Description : Compte le nombre de chaînes de caractères dans une table DEX.*
* *
@@ -121,11 +267,11 @@ bool load_all_dex_string_symbols(GDexFormat *format, wgroup_id_t gid, GtkStatusS
* *
******************************************************************************/
-uint32_t count_strings_in_dex_pool(const GDexFormat *format)
+uint32_t g_dex_pool_count_strings(const GDexPool *pool)
{
uint32_t result; /* Quantité à retourner */
- result = format->header.string_ids_size;
+ result = pool->format->header.string_ids_size;
return result;
@@ -134,9 +280,9 @@ uint32_t count_strings_in_dex_pool(const GDexFormat *format)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index de la chaîne recherchée. *
-* range = éventuelle couverture à renseigner ou NULL. [OUT] *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la chaîne recherchée. *
+* range = éventuelle couverture à renseigner ou NULL. [OUT] *
* *
* Description : Extrait une chaîne de caractères d'une table DEX. *
* *
@@ -146,9 +292,10 @@ uint32_t count_strings_in_dex_pool(const GDexFormat *format)
* *
******************************************************************************/
-const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, mrange_t *range)
+const char *g_dex_pool_get_string(const GDexPool *pool, uint32_t index, mrange_t *range)
{
uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
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 */
@@ -156,11 +303,13 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
string_data_item str_data; /* Description de chaîne */
phys_t diff; /* Avancée de tête de lecture */
- count = count_strings_in_dex_pool(format);
+ count = g_dex_pool_count_strings(pool);
if (index >= count)
return NULL;
+ format = pool->format;
+
pos = format->header.string_ids_off + index * sizeof(string_id_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
@@ -188,8 +337,8 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index de la chaîne recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la chaîne recherchée. *
* *
* Description : Extrait un symbole de chaîne d'une table DEX. *
* *
@@ -199,7 +348,7 @@ const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index, m
* *
******************************************************************************/
-GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
+GBinSymbol *g_dex_pool_get_string_symbol(GDexPool *pool, uint32_t index)
{
GBinSymbol *result; /* Instance à retourner */
uint32_t count; /* Nombre d'éléments présents */
@@ -211,17 +360,17 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
result = NULL;
- count = count_strings_in_dex_pool(format);
+ count = g_dex_pool_count_strings(pool);
if (index >= count)
goto gssfdp_error;
- if (format->strings[index] == NULL)
+ if (pool->strings[index] == NULL)
{
- string = get_string_from_dex_pool(format, index, &range);
+ string = g_dex_pool_get_string(pool, index, &range);
if (string == NULL) goto gssfdp_error;
- base = G_BIN_FORMAT(format);
+ base = G_BIN_FORMAT(pool->format);
new = g_string_symbol_new_read_only(base, &range, SET_MUTF_8);
@@ -231,14 +380,14 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
inserted = g_binary_format_add_symbol(base, new);
if (inserted)
- format->strings[index] = new;
+ pool->strings[index] = new;
else
g_object_unref(G_OBJECT(new));
}
- result = format->strings[index];
+ result = pool->strings[index];
if (result != NULL)
g_object_ref(G_OBJECT(result));
@@ -252,7 +401,7 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à compléter. *
+* Paramètres : pool = table de ressources pour format Dex à compléter. *
* gid = groupe de travail impliqué. *
status = barre de statut à tenir informée. *
* *
@@ -264,7 +413,7 @@ GBinSymbol *get_string_symbol_from_dex_pool(GDexFormat *format, uint32_t index)
* *
******************************************************************************/
-bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+bool g_dex_pool_load_all_types(GDexPool *pool, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
uint32_t count; /* Nombre d'éléments présents */
@@ -281,9 +430,9 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
/* Préparation du réceptacle */
- count = count_types_in_dex_pool(format);
+ count = g_dex_pool_count_types(pool);
- format->types = (GDataType **)calloc(count, sizeof(GDataType *));
+ pool->types = calloc(count, sizeof(GDataType *));
/* Lancement des chargements */
@@ -302,8 +451,8 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
else
end = begin + run_size;
- loading = g_dex_loading_new(format, begin, end, msg,
- (dex_loading_cb)get_type_from_dex_pool, &result);
+ loading = g_dex_loading_new(G_OBJECT(pool), begin, end, msg,
+ (dex_loading_cb)g_dex_pool_get_type_, &result);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(loading), gid);
@@ -320,7 +469,7 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
* *
* Description : Compte le nombre de types dans une table DEX. *
* *
@@ -330,11 +479,11 @@ bool load_all_dex_types(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *sta
* *
******************************************************************************/
-uint32_t count_types_in_dex_pool(const GDexFormat *format)
+uint32_t g_dex_pool_count_types(const GDexPool *pool)
{
uint32_t result; /* Quantité à retourner */
- result = format->header.type_ids_size;
+ result = pool->format->header.type_ids_size;
return result;
@@ -343,8 +492,8 @@ uint32_t count_types_in_dex_pool(const GDexFormat *format)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index du type recherché. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du type recherché. *
* *
* Description : Extrait une représentation de type d'une table DEX. *
* *
@@ -354,10 +503,11 @@ uint32_t count_types_in_dex_pool(const GDexFormat *format)
* *
******************************************************************************/
-GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
+GDataType *g_dex_pool_get_type_(GDexPool *pool, uint32_t index)
{
GDataType *result; /* Instance à retourner */
uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
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 */
@@ -366,13 +516,15 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
result = NULL;
- count = count_types_in_dex_pool(format);
+ count = g_dex_pool_count_types(pool);
if (index >= count)
goto gtfdp_error;
- if (format->types[index] == NULL)
+ if (pool->types[index] == NULL)
{
+ format = pool->format;
+
pos = format->header.type_ids_off + index * sizeof(type_id_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
@@ -391,11 +543,11 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
if (!read_dex_string_data_item(format, &addr, NULL, &str_data))
goto gtfdp_error;
- format->types[index] = g_binary_format_decode_type(G_BIN_FORMAT(format), (char *)str_data.data);
+ pool->types[index] = g_binary_format_decode_type(G_BIN_FORMAT(format), (char *)str_data.data);
}
- result = format->types[index];
+ result = pool->types[index];
if (result != NULL)
g_object_ref(G_OBJECT(result));
@@ -409,7 +561,7 @@ GDataType *get_type_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = description de l'exécutable à compléter. *
+* Paramètres : pool = table de ressources pour format Dex à compléter. *
* gid = groupe de travail impliqué. *
* status = barre de statut à tenir informée. *
* *
@@ -421,7 +573,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 g_dex_pool_load_all_fields(GDexPool *pool, wgroup_id_t gid, GtkStatusStack *status)
{
bool result; /* Bilan à retourner */
uint32_t count; /* Nombre d'éléments présents */
@@ -438,9 +590,9 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
/* Préparation du réceptacle */
- count = count_fields_in_dex_pool(format);
+ count = g_dex_pool_count_fields(pool);
- format->fields = (GBinVariable **)calloc(count, sizeof(GBinVariable *));
+ pool->fields = calloc(count, sizeof(GBinVariable *));
/* Lancement des chargements */
@@ -460,8 +612,8 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
else
end = begin + run_size;
- loading = g_dex_loading_new(format, begin, end, msg,
- (dex_loading_cb)get_field_from_dex_pool, &result);
+ loading = g_dex_loading_new(G_OBJECT(pool), begin, end, msg,
+ (dex_loading_cb)g_dex_pool_get_field, &result);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(loading), gid);
@@ -478,7 +630,7 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
* *
* Description : Compte le nombre de champs dans une table DEX. *
* *
@@ -488,11 +640,11 @@ bool load_all_dex_fields(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *st
* *
******************************************************************************/
-uint32_t count_fields_in_dex_pool(const GDexFormat *format)
+uint32_t g_dex_pool_count_fields(const GDexPool *pool)
{
uint32_t result; /* Quantité à retourner */
- result = format->header.field_ids_size;
+ result = pool->format->header.field_ids_size;
return result;
@@ -501,8 +653,8 @@ uint32_t count_fields_in_dex_pool(const GDexFormat *format)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index du champ recherché. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du champ recherché. *
* *
* Description : Extrait une représentation de champ d'une table DEX. *
* *
@@ -512,10 +664,11 @@ uint32_t count_fields_in_dex_pool(const GDexFormat *format)
* *
******************************************************************************/
-GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
+GBinVariable *g_dex_pool_get_field(GDexPool *pool, uint32_t index)
{
GBinVariable *result; /* Instance à retourner */
uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
field_id_item field_id; /* Description du champ */
@@ -526,23 +679,25 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
result = NULL;
- count = count_fields_in_dex_pool(format);
+ count = g_dex_pool_count_fields(pool);
if (index >= count)
goto gffdp_error;
- if (format->fields[index] == NULL)
+ if (pool->fields[index] == NULL)
{
+ format = pool->format;
+
pos = format->header.field_ids_off + index * sizeof(field_id_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
if (!read_dex_field_id_item(format, &addr, &field_id))
goto gffdp_error;
- type = get_type_from_dex_pool(format, field_id.type_idx);
+ type = g_dex_pool_get_type_(pool, field_id.type_idx);
if (type == NULL) goto gffdp_error;
- name = get_string_from_dex_pool(format, field_id.name_idx, NULL);
+ name = g_dex_pool_get_string(pool, field_id.name_idx, NULL);
if (name == NULL) goto gffdp_bad_name;
field = g_binary_variable_new(type);
@@ -550,18 +705,18 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
if (field_id.class_idx != NO_INDEX)
{
- owner = get_type_from_dex_pool(format, field_id.class_idx);
+ owner = g_dex_pool_get_type_(pool, field_id.class_idx);
if (owner == NULL) goto gffdp_bad_owner;
g_binary_variable_set_owner(field, owner);
}
- format->fields[index] = field;
+ pool->fields[index] = field;
}
- result = format->fields[index];
+ result = pool->fields[index];
if (result != NULL)
g_object_ref(G_OBJECT(result));
@@ -585,7 +740,7 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
* *
* Description : Compte le nombre de prototypes dans une table DEX. *
* *
@@ -595,11 +750,11 @@ GBinVariable *get_field_from_dex_pool(GDexFormat *format, uint32_t index)
* *
******************************************************************************/
-uint32_t count_prototypes_in_dex_pool(const GDexFormat *format)
+uint32_t g_dex_pool_count_prototypes(const GDexPool *pool)
{
uint32_t result; /* Quantité à retourner */
- result = format->header.proto_ids_size;
+ result = pool->format->header.proto_ids_size;
return result;
@@ -608,8 +763,8 @@ uint32_t count_prototypes_in_dex_pool(const GDexFormat *format)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index de la routine recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la routine recherchée. *
* *
* Description : Extrait une représentation de routine d'une table DEX. *
* *
@@ -619,10 +774,11 @@ uint32_t count_prototypes_in_dex_pool(const GDexFormat *format)
* *
******************************************************************************/
-GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
+GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
{
GBinRoutine *result; /* Instance à retourner */
uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
proto_id_item proto_id; /* Prototype de routine */
@@ -639,11 +795,13 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
* les autres éléments de la table des constantes.
*/
- count = count_prototypes_in_dex_pool(format);
+ count = g_dex_pool_count_prototypes(pool);
if (index >= count)
goto grfdp_error;
+ format = pool->format;
+
pos = format->header.proto_ids_off + index * sizeof(proto_id_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
@@ -658,7 +816,7 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
/* Type de retour */
- type = get_type_from_dex_pool(format, proto_id.return_type_idx);
+ type = g_dex_pool_get_type_(pool, proto_id.return_type_idx);
if (type == NULL) goto grfdp_error;
result = G_BIN_ROUTINE(g_dex_routine_new());
@@ -678,7 +836,7 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
for (i = 0; i < args.size; i++)
{
- type = get_type_from_dex_pool(format, args.list[i].type_idx);
+ type = g_dex_pool_get_type_(pool, args.list[i].type_idx);
if (type == NULL) goto grfdp_error;
arg = g_binary_variable_new(type);
@@ -702,7 +860,7 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à compléter. *
+* Paramètres : pool = table de ressources pour format Dex à compléter. *
* gid = groupe de travail impliqué. *
status = barre de statut à tenir informée. *
* *
@@ -714,9 +872,10 @@ GBinRoutine *get_prototype_from_dex_pool(GDexFormat *format, uint32_t index)
* *
******************************************************************************/
-bool load_all_dex_methods(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+bool g_dex_pool_load_all_methods(GDexPool *pool, 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 */
@@ -749,28 +908,29 @@ bool load_all_dex_methods(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
/* Préparation du réceptacle */
- format->methods = (GDexMethod **)calloc(format->header.method_ids_size, sizeof(GDexMethod *));
+ count = pool->format->header.method_ids_size;
+
+ pool->methods = calloc(count, sizeof(GDexMethod *));
/* Lancement des chargements */
- run_size = compute_run_size(format->header.method_ids_size, &runs_count);
+ run_size = compute_run_size(count, &runs_count);
queue = get_work_queue();
- msg = gtk_status_stack_add_activity(status, _("Loading all methods from the Dex pool..."),
- format->header.method_ids_size);
+ msg = gtk_status_stack_add_activity(status, _("Loading all methods from the Dex pool..."), count);
for (i = 0; i < runs_count; i++)
{
begin = i * run_size;
if ((i + 1) == runs_count)
- end = format->header.method_ids_size;
+ end = count;
else
end = begin + run_size;
- loading = g_dex_loading_new(format, begin, end, msg,
- (dex_loading_cb)get_method_from_dex_pool, &result);
+ loading = g_dex_loading_new(G_OBJECT(pool), begin, end, msg,
+ (dex_loading_cb)g_dex_pool_get_method, &result);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(loading), gid);
@@ -787,7 +947,7 @@ bool load_all_dex_methods(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
* *
* Description : Compte le nombre de méthodes dans une table DEX. *
* *
@@ -797,11 +957,11 @@ bool load_all_dex_methods(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
* *
******************************************************************************/
-uint32_t count_methods_in_dex_pool(const GDexFormat *format)
+uint32_t g_dex_pool_count_methods(const GDexPool *pool)
{
uint32_t result; /* Quantité à retourner */
- result = format->header.method_ids_size;
+ result = pool->format->header.method_ids_size;
return result;
@@ -810,8 +970,8 @@ uint32_t count_methods_in_dex_pool(const GDexFormat *format)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index de la méthode recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la méthode recherchée. *
* *
* Description : Extrait une représentation de méthode d'une table DEX. *
* *
@@ -821,31 +981,37 @@ uint32_t count_methods_in_dex_pool(const GDexFormat *format)
* *
******************************************************************************/
-GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)
+GDexMethod *g_dex_pool_get_method(GDexPool *pool, uint32_t index)
{
GDexMethod *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
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 = g_dex_pool_count_methods(pool);
+
+ if (index >= count)
goto gmfdp_error;
- if (format->methods[index] == NULL)
+ if (pool->methods[index] == NULL)
{
+ format = pool->format;
+
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_callable(format, &method_id);
+ pool->methods[index] = g_dex_method_new_callable(format, &method_id);
}
- result = format->methods[index];
+ result = pool->methods[index];
if (result != NULL)
g_object_ref(G_OBJECT(result));
@@ -859,7 +1025,7 @@ GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à compléter. *
+* Paramètres : pool = table de ressources pour format Dex à compléter. *
* gid = groupe de travail impliqué. *
status = barre de statut à tenir informée. *
* *
@@ -871,9 +1037,10 @@ GDexMethod *get_method_from_dex_pool(GDexFormat *format, uint32_t index)
* *
******************************************************************************/
-bool load_all_dex_classes(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status)
+bool g_dex_pool_load_all_classes(GDexPool *pool, 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 */
@@ -887,28 +1054,29 @@ bool load_all_dex_classes(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
/* Préparation du réceptacle */
- format->classes = (GDexClass **)calloc(format->header.class_defs_size, sizeof(GDexClass *));
+ count = pool->format->header.class_defs_size;
+
+ pool->classes = calloc(count, sizeof(GDexClass *));
/* Lancement des chargements */
- run_size = compute_run_size(format->header.class_defs_size, &runs_count);
+ run_size = compute_run_size(count, &runs_count);
queue = get_work_queue();
- msg = gtk_status_stack_add_activity(status, _("Loading all classes from the Dex pool..."),
- format->header.class_defs_size);
+ msg = gtk_status_stack_add_activity(status, _("Loading all classes from the Dex pool..."), count);
for (i = 0; i < runs_count; i++)
{
begin = i * run_size;
if ((i + 1) == runs_count)
- end = format->header.class_defs_size;
+ end = count;
else
end = begin + run_size;
- loading = g_dex_loading_new(format, begin, end, msg,
- (dex_loading_cb)get_class_from_dex_pool, &result);
+ loading = g_dex_loading_new(G_OBJECT(pool), begin, end, msg,
+ (dex_loading_cb)g_dex_pool_get_class, &result);
g_work_queue_schedule_work(queue, G_DELAYED_WORK(loading), gid);
@@ -925,8 +1093,31 @@ bool load_all_dex_classes(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter. *
-* index = index de la classe recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* *
+* Description : Dénombre le nombre de classes trouvées. *
+* *
+* Retour : Valeur positive ou nulle. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+uint32_t g_dex_pool_count_classes(const GDexPool *pool)
+{
+ uint32_t result; /* Quantité à retourner */
+
+ result = pool->format->header.class_defs_size;
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la classe recherchée. *
* *
* Description : Extrait une représentation de classe d'une table DEX. *
* *
@@ -936,31 +1127,37 @@ bool load_all_dex_classes(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *s
* *
******************************************************************************/
-GDexClass *get_class_from_dex_pool(GDexFormat *format, uint32_t index)
+GDexClass *g_dex_pool_get_class(GDexPool *pool, uint32_t index)
{
GDexClass *result; /* Instance à retourner */
+ uint32_t count; /* Nombre d'éléments présents */
+ GDexFormat *format; /* Format associé à la table */
phys_t pos; /* Tête de lecture */
vmpa2t addr; /* Tête de lecture générique */
class_def_item class_def; /* Définition de la classe */
result = NULL;
- if (index >= format->header.class_defs_size)
+ count = g_dex_pool_count_classes(pool);
+
+ if (index >= count)
goto gcfdp_error;
- if (format->classes[index] == NULL)
+ if (pool->classes[index] == NULL)
{
+ format = pool->format;
+
pos = format->header.class_defs_off + index * sizeof(class_def_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
if (!read_dex_class_def_item(format, &addr, &class_def))
goto gcfdp_error;
- format->classes[index] = g_dex_class_new(format, &class_def);
+ pool->classes[index] = g_dex_class_new(format, &class_def);
}
- result = format->classes[index];
+ result = pool->classes[index];
if (result != NULL)
g_object_ref(G_OBJECT(result));