summaryrefslogtreecommitdiff
path: root/plugins/dex
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-05-07 21:53:40 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-05-07 21:53:40 (GMT)
commitdd2b41538e20de5472cd8c888c530327a1351866 (patch)
tree7f9a24a32ecd33aacb98a5d1ec4234011c1364a6 /plugins/dex
parentb92a5e56de9198c08956ce486cd12712d7034731 (diff)
Read raw Dex items by extending the API.
Diffstat (limited to 'plugins/dex')
-rw-r--r--plugins/dex/method.c34
-rw-r--r--plugins/dex/method.h3
-rw-r--r--plugins/dex/pool.c339
-rw-r--r--plugins/dex/pool.h15
-rw-r--r--plugins/dex/python/format.c75
-rw-r--r--plugins/dex/python/method.c45
-rw-r--r--plugins/dex/python/pool.c330
-rw-r--r--plugins/dex/python/translate.c246
-rw-r--r--plugins/dex/python/translate.h15
9 files changed, 1004 insertions, 98 deletions
diff --git a/plugins/dex/method.c b/plugins/dex/method.c
index f35858e..75293b7 100644
--- a/plugins/dex/method.c
+++ b/plugins/dex/method.c
@@ -54,6 +54,7 @@ struct _GDexMethod
bool already_defined; /* Vérification d'unicité */
#endif
+ method_id_item id_item; /* Définition de la méthode */
encoded_method info; /* Propriétés de la méthode */
bool has_body; /* Indication de présence */
code_item body; /* Corps de la méthode */
@@ -257,8 +258,8 @@ GDexMethod *g_dex_method_new_defined(GDexFormat *format, const encoded_method *s
/******************************************************************************
* *
-* Paramètres : format = représentation interne du format DEX à consulter.*
-* method_id = informations de base quant à la méthode. *
+* Paramètres : format = représentation interne du format DEX à consulter.*
+* id_item = informations de base quant à la méthode. *
* *
* Description : Crée une nouvelle représentation de methode vide. *
* *
@@ -268,7 +269,7 @@ GDexMethod *g_dex_method_new_defined(GDexFormat *format, const encoded_method *s
* *
******************************************************************************/
-GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *method_id)
+GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *id_item)
{
GDexMethod *result; /* Composant à retourner */
GDexPool *pool; /* Table de ressources */
@@ -280,12 +281,12 @@ GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *
pool = g_dex_format_get_pool(format);
- ns = g_dex_pool_get_type_(pool, method_id->class_idx);
+ ns = g_dex_pool_get_type_(pool, id_item->class_idx);
- name = g_dex_pool_get_string(pool, method_id->name_idx, NULL);
+ name = g_dex_pool_get_string(pool, id_item->name_idx, NULL);
if (name == NULL) goto gdmne_exit;
- routine = g_dex_pool_get_prototype(pool, method_id->proto_idx);
+ routine = g_dex_pool_get_prototype(pool, id_item->proto_idx);
if (routine == NULL) goto gdmne_exit;
if (ns != NULL)
@@ -299,6 +300,8 @@ GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *
g_dex_routine_attach_method(G_DEX_ROUTINE(routine), result);
+ result->id_item = *id_item;
+
gdmne_exit:
g_object_unref(G_OBJECT(pool));
@@ -312,6 +315,25 @@ GDexMethod *g_dex_method_new_callable(GDexFormat *format, const method_id_item *
* *
* Paramètres : method = représentation interne de la méthode à consulter. *
* *
+* Description : Fournit les identifiants Dex concernant la méthode. *
+* *
+* Retour : Données brutes du binaire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const method_id_item *g_dex_method_get_dex_id_item(const GDexMethod *method)
+{
+ return &method->id_item;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : method = représentation interne de la méthode à consulter. *
+* *
* Description : Fournit les indications Dex concernant la méthode. *
* *
* Retour : Données brutes du binaire. *
diff --git a/plugins/dex/method.h b/plugins/dex/method.h
index e567832..acb6b5b 100644
--- a/plugins/dex/method.h
+++ b/plugins/dex/method.h
@@ -75,6 +75,9 @@ GDexMethod *g_dex_method_new_defined(GDexFormat *, const encoded_method *, uleb1
/* Crée une nouvelle représentation de methode vide. */
GDexMethod *g_dex_method_new_callable(GDexFormat *, const method_id_item *);
+/* Fournit les identifiants Dex concernant la méthode. */
+const method_id_item *g_dex_method_get_dex_id_item(const GDexMethod *);
+
/* Fournit les indications Dex concernant la méthode. */
const encoded_method *g_dex_method_get_dex_info(const GDexMethod *);
diff --git a/plugins/dex/pool.c b/plugins/dex/pool.c
index 6905c3b..e7dd205 100644
--- a/plugins/dex/pool.c
+++ b/plugins/dex/pool.c
@@ -492,6 +492,48 @@ uint32_t g_dex_pool_count_types(const GDexPool *pool)
/******************************************************************************
* *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du type recherché. *
+* type_id = élément ciblé à constituer. [OUT] *
+* *
+* Description : Reconstitue les éléments bruts d'un type Dex. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_dex_pool_get_raw_type(GDexPool *pool, uint32_t index, type_id_item *type_id)
+{
+ bool result; /* Bilan à 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 */
+
+ result = false;
+
+ count = g_dex_pool_count_types(pool);
+
+ if (index < count)
+ {
+ format = pool->format;
+
+ pos = format->header.type_ids_off + index * sizeof(type_id_item);
+ init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
+
+ result = read_dex_type_id_item(format, &addr, type_id);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : pool = table de resources pour format Dex à consulter. *
* index = index du type recherché. *
* *
@@ -506,42 +548,33 @@ uint32_t g_dex_pool_count_types(const GDexPool *pool)
GDataType *g_dex_pool_get_type_(GDexPool *pool, uint32_t index)
{
GDataType *result; /* Instance à retourner */
- uint32_t count; /* Nombre d'éléments présents */
+ type_id_item type_id; /* Définition de la classe */
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 */
string_id_item str_id; /* Identifiant de chaîne */
string_data_item str_data; /* Description de chaîne */
result = NULL;
- count = g_dex_pool_count_types(pool);
-
- if (index >= count)
- goto gtfdp_error;
-
if (pool->types[index] == NULL)
{
- format = pool->format;
+ if (!g_dex_pool_get_raw_type(pool, index, &type_id))
+ goto no_type_id;
- pos = format->header.type_ids_off + index * sizeof(type_id_item);
- init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
-
- if (!read_dex_type_id_item(format, &addr, &type_id))
- goto gtfdp_error;
+ format = pool->format;
pos = format->header.string_ids_off + type_id.descriptor_idx * sizeof(string_id_item);
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
if (!read_dex_string_id_item(format, &addr, &str_id))
- goto gtfdp_error;
+ goto type_error;
pos = str_id.string_data_off;
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
if (!read_dex_string_data_item(format, &addr, NULL, &str_data))
- goto gtfdp_error;
+ goto type_error;
pool->types[index] = g_binary_format_decode_type(G_BIN_FORMAT(format), (char *)str_data.data);
@@ -552,7 +585,9 @@ GDataType *g_dex_pool_get_type_(GDexPool *pool, uint32_t index)
if (result != NULL)
g_object_ref(G_OBJECT(result));
- gtfdp_error:
+ type_error:
+
+ no_type_id:
return result;
@@ -653,6 +688,48 @@ uint32_t g_dex_pool_count_fields(const GDexPool *pool)
/******************************************************************************
* *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du type recherché. *
+* field_id = élément ciblé à constituer. [OUT] *
+* *
+* Description : Reconstitue les éléments bruts d'un champ Dex. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_dex_pool_get_raw_field(GDexPool *pool, uint32_t index, field_id_item *field_id)
+{
+ bool result; /* Bilan à 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 */
+
+ result = false;
+
+ count = g_dex_pool_count_fields(pool);
+
+ if (index < count)
+ {
+ format = pool->format;
+
+ pos = format->header.field_ids_off + index * sizeof(field_id_item);
+ init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
+
+ result = read_dex_field_id_item(format, &addr, field_id);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : pool = table de resources pour format Dex à consulter. *
* index = index du champ recherché. *
* *
@@ -667,10 +744,6 @@ uint32_t g_dex_pool_count_fields(const GDexPool *pool)
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 */
GDataType *type; /* Type du champ */
const char *name; /* Désignation humaine */
@@ -679,26 +752,16 @@ GBinVariable *g_dex_pool_get_field(GDexPool *pool, uint32_t index)
result = NULL;
- count = g_dex_pool_count_fields(pool);
-
- if (index >= count)
- goto gffdp_error;
-
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;
+ if (!g_dex_pool_get_raw_field(pool, index, &field_id))
+ goto no_field_id;
type = g_dex_pool_get_type_(pool, field_id.type_idx);
- if (type == NULL) goto gffdp_error;
+ if (type == NULL) goto type_error;
name = g_dex_pool_get_string(pool, field_id.name_idx, NULL);
- if (name == NULL) goto gffdp_bad_name;
+ if (name == NULL) goto bad_name;
field = g_binary_variable_new(type);
g_binary_variable_set_name(field, name);
@@ -706,7 +769,7 @@ GBinVariable *g_dex_pool_get_field(GDexPool *pool, uint32_t index)
if (field_id.class_idx != NO_INDEX)
{
owner = g_dex_pool_get_type_(pool, field_id.class_idx);
- if (owner == NULL) goto gffdp_bad_owner;
+ if (owner == NULL) goto bad_owner;
g_binary_variable_set_owner(field, owner);
@@ -721,15 +784,17 @@ GBinVariable *g_dex_pool_get_field(GDexPool *pool, uint32_t index)
if (result != NULL)
g_object_ref(G_OBJECT(result));
- gffdp_error:
+ type_error:
+
+ no_field_id:
return result;
- gffdp_bad_owner:
+ bad_owner:
g_object_unref(G_OBJECT(field));
- gffdp_bad_name:
+ bad_name:
g_object_unref(G_OBJECT(type));
@@ -763,6 +828,48 @@ uint32_t g_dex_pool_count_prototypes(const GDexPool *pool)
/******************************************************************************
* *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index de la routine recherchée. *
+* proto_id = élément ciblé à constituer. [OUT] *
+* *
+* Description : Reconstitue les éléments bruts d'une routine Dex. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_dex_pool_get_raw_prototype(GDexPool *pool, uint32_t index, proto_id_item *proto_id)
+{
+ bool result; /* Bilan à 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 */
+
+ result = false;
+
+ count = g_dex_pool_count_prototypes(pool);
+
+ if (index < count)
+ {
+ format = pool->format;
+
+ pos = format->header.proto_ids_off + index * sizeof(proto_id_item);
+ init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
+
+ result = read_dex_proto_id_item(format, &addr, proto_id);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : pool = table de resources pour format Dex à consulter. *
* index = index de la routine recherchée. *
* *
@@ -777,12 +884,10 @@ uint32_t g_dex_pool_count_prototypes(const GDexPool *pool)
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 */
GDataType *type; /* Type de retour */
+ phys_t pos; /* Tête de lecture */
+ vmpa2t addr; /* Tête de lecture générique */
type_list args; /* Liste des arguments */
uint32_t i; /* Boucle de parcours */
GBinVariable *arg; /* Argument reconstitué */
@@ -795,21 +900,11 @@ GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
* les autres éléments de la table des constantes.
*/
- 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);
-
- if (!read_dex_proto_id_item(format, &addr, &proto_id))
- goto grfdp_error;
+ if (!g_dex_pool_get_raw_prototype(pool, index, &proto_id))
+ goto no_proto_id;
/**
- * On choisit d'ignore le champ proto_id.shorty_idx : c'est un descripteur
+ * On choisit d'ignorer le champ proto_id.shorty_idx : c'est un descripteur
* qui doit correspondre au retour et aux paramètres précisés avec les
* autres champs de la structure, donc l'information paraît redondante.
*/
@@ -817,7 +912,7 @@ GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
/* Type de retour */
type = g_dex_pool_get_type_(pool, proto_id.return_type_idx);
- if (type == NULL) goto grfdp_error;
+ if (type == NULL) goto type_error;
result = G_BIN_ROUTINE(g_dex_routine_new());
@@ -831,13 +926,13 @@ GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
{
init_vmpa(&addr, pos, VMPA_NO_VIRTUAL);
- if (!read_dex_type_list(format, &addr, &args))
- goto grfdp_error;
+ if (!read_dex_type_list(pool->format, &addr, &args))
+ goto arg_error;
for (i = 0; i < args.size; i++)
{
type = g_dex_pool_get_type_(pool, args.list[i].type_idx);
- if (type == NULL) goto grfdp_error;
+ if (type == NULL) goto arg_error;
arg = g_binary_variable_new(type);
g_binary_routine_add_arg(result, arg);
@@ -848,11 +943,15 @@ GBinRoutine *g_dex_pool_get_prototype(GDexPool *pool, uint32_t index)
return result;
- grfdp_error:
+ arg_error:
if (result != NULL)
g_object_unref(G_OBJECT(result));
+ type_error:
+
+ no_proto_id:
+
return NULL;
}
@@ -970,44 +1069,72 @@ uint32_t g_dex_pool_count_methods(const GDexPool *pool)
/******************************************************************************
* *
-* Paramètres : pool = table de resources pour format Dex à consulter. *
-* index = index de la méthode recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du type recherché. *
+* field_id = élément ciblé à constituer. [OUT] *
* *
-* Description : Extrait une représentation de méthode d'une table DEX. *
+* Description : Reconstitue les éléments bruts d'une méthode Dex. *
* *
-* Retour : Composant GLib créé. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GDexMethod *g_dex_pool_get_method(GDexPool *pool, uint32_t index)
+bool g_dex_pool_get_raw_method(GDexPool *pool, uint32_t index, method_id_item *method_id)
{
- GDexMethod *result; /* Instance à retourner */
+ bool result; /* Bilan à 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;
+ result = false;
count = g_dex_pool_count_methods(pool);
- if (index >= count)
- goto gmfdp_error;
-
- if (pool->methods[index] == NULL)
+ if (index < count)
{
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;
+ result = read_dex_method_id_item(format, &addr, method_id);
- pool->methods[index] = g_dex_method_new_callable(format, &method_id);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* 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. *
+* *
+* Retour : Composant GLib créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDexMethod *g_dex_pool_get_method(GDexPool *pool, uint32_t index)
+{
+ GDexMethod *result; /* Instance à retourner */
+ method_id_item method_id; /* Définition de la méthode */
+
+ result = NULL;
+
+ if (pool->methods[index] == NULL)
+ {
+ if (!g_dex_pool_get_raw_method(pool, index, &method_id))
+ goto no_method_id;
+
+ pool->methods[index] = g_dex_method_new_callable(pool->format, &method_id);
}
@@ -1016,7 +1143,7 @@ GDexMethod *g_dex_pool_get_method(GDexPool *pool, uint32_t index)
if (result != NULL)
g_object_ref(G_OBJECT(result));
- gmfdp_error:
+ no_method_id:
return result;
@@ -1116,44 +1243,72 @@ uint32_t g_dex_pool_count_classes(const GDexPool *pool)
/******************************************************************************
* *
-* Paramètres : pool = table de resources pour format Dex à consulter. *
-* index = index de la classe recherchée. *
+* Paramètres : pool = table de resources pour format Dex à consulter. *
+* index = index du type recherché. *
+* class_def = élément ciblé à constituer. [OUT] *
* *
-* Description : Extrait une représentation de classe d'une table DEX. *
+* Description : Reconstitue les éléments bruts d'une classe Dex. *
* *
-* Retour : Composant GLib créé. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GDexClass *g_dex_pool_get_class(GDexPool *pool, uint32_t index)
+bool g_dex_pool_get_raw_class(GDexPool *pool, uint32_t index, class_def_item *class_def)
{
- GDexClass *result; /* Instance à retourner */
+ bool result; /* Bilan à 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;
+ result = false;
count = g_dex_pool_count_classes(pool);
- if (index >= count)
- goto gcfdp_error;
-
- if (pool->classes[index] == NULL)
+ if (index < count)
{
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;
+ result = read_dex_class_def_item(format, &addr, class_def);
+
+ }
+
+ 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. *
+* *
+* Retour : Composant GLib créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDexClass *g_dex_pool_get_class(GDexPool *pool, uint32_t index)
+{
+ GDexClass *result; /* Instance à retourner */
+ class_def_item class_def; /* Définition de la classe */
+
+ result = NULL;
+
+ if (pool->classes[index] == NULL)
+ {
+ if (!g_dex_pool_get_raw_class(pool, index, &class_def))
+ goto no_class_def;
- pool->classes[index] = g_dex_class_new(format, &class_def);
+ pool->classes[index] = g_dex_class_new(pool->format, &class_def);
}
@@ -1162,7 +1317,7 @@ GDexClass *g_dex_pool_get_class(GDexPool *pool, uint32_t index)
if (result != NULL)
g_object_ref(G_OBJECT(result));
- gcfdp_error:
+ no_class_def:
return result;
diff --git a/plugins/dex/pool.h b/plugins/dex/pool.h
index 26c11d6..c8f9b01 100644
--- a/plugins/dex/pool.h
+++ b/plugins/dex/pool.h
@@ -74,6 +74,9 @@ bool g_dex_pool_load_all_types(GDexPool *, wgroup_id_t, GtkStatusStack *);
/* Compte le nombre de types dans une table DEX. */
uint32_t g_dex_pool_count_types(const GDexPool *);
+/* Reconstitue les éléments bruts d'un type Dex. */
+bool g_dex_pool_get_raw_type(GDexPool *, uint32_t, type_id_item *);
+
/* Extrait une représentation de type d'une table DEX. */
GDataType *g_dex_pool_get_type_(GDexPool *, uint32_t);
@@ -83,12 +86,18 @@ bool g_dex_pool_load_all_fields(GDexPool *, wgroup_id_t, GtkStatusStack *);
/* Compte le nombre de champs dans une table DEX. */
uint32_t g_dex_pool_count_fields(const GDexPool *);
+/* Reconstitue les éléments bruts d'un champ Dex. */
+bool g_dex_pool_get_raw_field(GDexPool *, uint32_t, field_id_item *);
+
/* Extrait une représentation de champ d'une table DEX. */
GBinVariable *g_dex_pool_get_field(GDexPool *, uint32_t);
/* Compte le nombre de prototypes dans une table DEX. */
uint32_t g_dex_pool_count_prototypes(const GDexPool *);
+/* Reconstitue les éléments bruts d'une routine Dex. */
+bool g_dex_pool_get_raw_prototype(GDexPool *, uint32_t, proto_id_item *);
+
/* Extrait une représentation de routine d'une table DEX. */
GBinRoutine *g_dex_pool_get_prototype(GDexPool *, uint32_t);
@@ -98,6 +107,9 @@ bool g_dex_pool_load_all_methods(GDexPool *, wgroup_id_t, GtkStatusStack *);
/* Compte le nombre de méthodes dans une table DEX. */
uint32_t g_dex_pool_count_methods(const GDexPool *);
+/* Reconstitue les éléments bruts d'une méthode Dex. */
+bool g_dex_pool_get_raw_method(GDexPool *, uint32_t, method_id_item *);
+
/* Extrait une représentation de méthode d'une table DEX. */
GDexMethod *g_dex_pool_get_method(GDexPool *, uint32_t);
@@ -107,6 +119,9 @@ bool g_dex_pool_load_all_classes(GDexPool *, wgroup_id_t, GtkStatusStack *);
/* Dénombre le nombre de classes trouvées. */
uint32_t g_dex_pool_count_classes(const GDexPool *);
+/* Reconstitue les éléments bruts d'une classe Dex. */
+bool g_dex_pool_get_raw_class(GDexPool *, uint32_t, class_def_item *);
+
/* Extrait une représentation de classe d'une table DEX. */
GDexClass *g_dex_pool_get_class(GDexPool *, uint32_t);
diff --git a/plugins/dex/python/format.c b/plugins/dex/python/format.c
index 77ebef6..9bbbfbd 100644
--- a/plugins/dex/python/format.c
+++ b/plugins/dex/python/format.c
@@ -37,7 +37,9 @@
#include "constants.h"
+#include "translate.h"
#include "../class.h"
+#include "../dex-int.h"
#include "../format.h"
@@ -98,6 +100,78 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject
/******************************************************************************
* *
+* Paramètres : self = objet représentant un format de fichier Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Procède à la lecture d'une liste de types DEX. *
+* *
+* Retour : Instance mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_format_read_type_list(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int offset; /* Position de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexFormat *format; /* Format de fichier Dex */
+ vmpa2t addr; /* Tête de lecture générique */
+ type_list list; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+ uint32_t i; /* Boucle de parcours */
+
+#define DEX_POOL_READ_TYPE_LIST_METHOD PYTHON_METHOD_DEF \
+( \
+ "read_type_list", "$self, offset, /", \
+ METH_VARARGS, py_dex_format_read_type_list, \
+ "Provide the raw data of a given type list as an array of pychrysalide.PyStructObject" \
+ " instances." \
+ "\n" \
+ "All the items are fields extracted from the Dex *type_list* structure:\n" \
+ "* type_idx: index into the *type_ids* list.\n" \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &offset);
+ if (!ret) return NULL;
+
+ format = G_DEX_FORMAT(pygobject_get(self));
+
+ init_vmpa(&addr, offset, VMPA_NO_VIRTUAL);
+
+ status = read_dex_type_list(format, &addr, &list);
+
+ if (status)
+ {
+ result = PyTuple_New(list.size);
+
+ for (i = 0; i < list.size; i++)
+ {
+#ifndef NDEBUG
+ ret = PyTuple_SetItem(result, i, translate_dex_type_item_to_python(&list.list[i]));
+ assert(ret == 0);
+#else
+ PyTuple_SetItem(result, i, translate_dex_type_item_to_python(&list.list[i]));
+#endif
+ }
+
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
@@ -149,6 +223,7 @@ static PyObject *py_dex_format_get_pool(PyObject *self, void *closure)
PyTypeObject *get_python_dex_format_type(void)
{
static PyMethodDef py_dex_format_methods[] = {
+ DEX_POOL_READ_TYPE_LIST_METHOD,
{ NULL }
};
diff --git a/plugins/dex/python/method.c b/plugins/dex/python/method.c
index 5a06403..1bffbff 100644
--- a/plugins/dex/python/method.c
+++ b/plugins/dex/python/method.c
@@ -36,6 +36,9 @@
+/* Fournit les identifiants Dex concernant la méthode. */
+static PyObject *py_dex_method_get_id_item(PyObject *, void *);
+
/* Fournit les indications Dex concernant la méthode. */
static PyObject *py_dex_method_get_encoded(PyObject *, void *);
@@ -52,6 +55,47 @@ static PyObject *py_dex_method_get_routine(PyObject *, void *);
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
+* Description : Fournit les identifiants Dex concernant la méthode. *
+* *
+* Retour : Données brutes issues du binaire chargé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_method_get_id_item(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GDexMethod *method; /* Version native */
+ const method_id_item *id_item; /* Elément à traiter */
+
+#define DEX_METHOD_ID_ITEM_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ id_item, py_dex_method, \
+ "pychrysalide.PyStructObject instance of identifiers used by the method.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *method_id_item* structure:\n" \
+ "* class_idx: index into the *type_ids* list for the definer of the method ;\n" \
+ "* proto_idx: index into the *proto_ids* list for the prototype of the method ;\n" \
+ "* name_idx: index into the *string_ids* list for the name of the method." \
+)
+
+ method = G_DEX_METHOD(pygobject_get(self));
+
+ id_item = g_dex_method_get_dex_id_item(method);
+
+ result = translate_dex_method_id_to_python(id_item);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
* Description : Fournit les indications Dex concernant la méthode. *
* *
* Retour : Données brutes issues du binaire chargé. *
@@ -165,6 +209,7 @@ PyTypeObject *get_python_dex_method_type(void)
};
static PyGetSetDef py_dex_method_getseters[] = {
+ DEX_METHOD_ID_ITEM_ATTRIB,
{
"encoded", py_dex_method_get_encoded, NULL,
"Encoded information about the Dex method.", NULL
diff --git a/plugins/dex/python/pool.c b/plugins/dex/python/pool.c
index eae1e86..695e07f 100644
--- a/plugins/dex/python/pool.c
+++ b/plugins/dex/python/pool.c
@@ -36,6 +36,21 @@
+/* Reconstitue les éléments bruts d'un type Dex. */
+static PyObject *py_dex_pool_get_raw_type(PyObject *, PyObject *);
+
+/* Reconstitue les éléments bruts d'un champ Dex. */
+static PyObject *py_dex_pool_get_raw_field(PyObject *, PyObject *);
+
+/* Reconstitue les éléments bruts d'une routine Dex. */
+static PyObject *py_dex_pool_get_raw_prototype(PyObject *, PyObject *);
+
+/* Reconstitue les éléments bruts d'une méthode Dex. */
+static PyObject *py_dex_pool_get_raw_method(PyObject *, PyObject *);
+
+/* Reconstitue les éléments bruts d'une classe Dex. */
+static PyObject *py_dex_pool_get_raw_class(PyObject *, PyObject *);
+
/* Fournit la liste de toutes les chaînes de la table globale. */
static PyObject *py_dex_pool_get_strings(PyObject *, void *);
@@ -65,6 +80,316 @@ static PyObject *py_dex_pool_get_classes(PyObject *, void *);
/******************************************************************************
* *
+* Paramètres : self = objet représentant une table de ressources Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Reconstitue les éléments bruts d'un type Dex. *
+* *
+* Retour : Instance mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_pool_get_raw_type(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int index; /* Indice de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexPool *pool; /* Table de ressources Dex */
+ type_id_item type_id; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+
+#define DEX_POOL_GET_RAW_TYPE_METHOD PYTHON_METHOD_DEF \
+( \
+ "get_raw_type", "$self, index, /", \
+ METH_VARARGS, py_dex_pool_get_raw_type, \
+ "Provide the raw data of a given type in the Dex pool as a pychrysalide.PyStructObject" \
+ " instance." \
+ "\n" \
+ "Indexes start at 0.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *type_id_item* structure:\n" \
+ "* descriptor_idx: index into the string_ids list for the descriptor string.\n" \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &index);
+ if (!ret) return NULL;
+
+ pool = G_DEX_POOL(pygobject_get(self));
+
+ status = g_dex_pool_get_raw_type(pool, index, &type_id);
+
+ if (status)
+ result = translate_dex_type_id_to_python(&type_id);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet représentant une table de ressources Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Reconstitue les éléments bruts d'un champ Dex. *
+* *
+* Retour : Instance mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_pool_get_raw_field(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int index; /* Indice de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexPool *pool; /* Table de ressources Dex */
+ field_id_item field_id; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+
+#define DEX_POOL_GET_RAW_FIELD_METHOD PYTHON_METHOD_DEF \
+( \
+ "get_raw_field", "$self, index, /", \
+ METH_VARARGS, py_dex_pool_get_raw_field, \
+ "Provide the raw data of a given field in the Dex pool as a pychrysalide.PyStructObject" \
+ " instance." \
+ "\n" \
+ "Indexes start at 0.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *field_id_item* structure:\n" \
+ "* class_idx: index into the type_ids list for the definer of the field ;\n" \
+ "* type_idx: index into the type_ids list for the type of the field ;\n" \
+ "* name_idx: index into the string_ids list for the name of the field.\n" \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &index);
+ if (!ret) return NULL;
+
+ pool = G_DEX_POOL(pygobject_get(self));
+
+ status = g_dex_pool_get_raw_field(pool, index, &field_id);
+
+ if (status)
+ result = translate_dex_field_id_to_python(&field_id);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet représentant une table de ressources Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Reconstitue les éléments bruts d'une routine Dex. *
+* *
+* Retour : Instance mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_pool_get_raw_prototype(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int index; /* Indice de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexPool *pool; /* Table de ressources Dex */
+ proto_id_item proto_id; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+
+#define DEX_POOL_GET_RAW_PROTOTYPE_METHOD PYTHON_METHOD_DEF \
+( \
+ "get_raw_prototype", "$self, index, /", \
+ METH_VARARGS, py_dex_pool_get_raw_prototype, \
+ "Provide the raw data of a given prototype in the Dex pool as a pychrysalide.PyStructObject" \
+ " instance." \
+ "\n" \
+ "Indexes start at 0.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *proto_id_item* structure:\n" \
+ "* shorty_idx: index into the *string_ids* list for the short-form descriptor string ;\n" \
+ "* return_type_idx: index into the *type_ids* list for the return type ;\n" \
+ "* parameters_off: offset from the start of the Dex file to the list of parameter types." \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &index);
+ if (!ret) return NULL;
+
+ pool = G_DEX_POOL(pygobject_get(self));
+
+ status = g_dex_pool_get_raw_prototype(pool, index, &proto_id);
+
+ if (status)
+ result = translate_dex_proto_id_to_python(&proto_id);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet représentant une table de ressources Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Reconstitue les éléments bruts d'une méthode Dex. *
+* *
+* Retour : Instance mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_pool_get_raw_method(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int index; /* Indice de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexPool *pool; /* Table de ressources Dex */
+ method_id_item method_id; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+
+#define DEX_POOL_GET_RAW_METHOD_METHOD PYTHON_METHOD_DEF \
+( \
+ "get_raw_method", "$self, index, /", \
+ METH_VARARGS, py_dex_pool_get_raw_method, \
+ "Provide the raw data of a given method in the Dex pool as a pychrysalide.PyStructObject" \
+ " instance." \
+ "\n" \
+ "Indexes start at 0.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *method_id_item* structure:\n" \
+ "* class_idx: index into the type_ids list for the definer of the method ;\n" \
+ "* proto_idx: index into the proto_ids list for the prototype of the method ;\n" \
+ "* name_idx: index into the string_ids list for the name of the method.\n" \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &index);
+ if (!ret) return NULL;
+
+ pool = G_DEX_POOL(pygobject_get(self));
+
+ status = g_dex_pool_get_raw_method(pool, index, &method_id);
+
+ if (status)
+ result = translate_dex_method_id_to_python(&method_id);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet représentant une table de ressources Dex. *
+* args = arguments fournis pour l'opération. *
+* *
+* Description : Reconstitue les éléments bruts d'une classe Dex. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_dex_pool_get_raw_class(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+ unsigned int index; /* Indice de l'élément visé */
+ int ret; /* Bilan de lecture des args. */
+ GDexPool *pool; /* Table de ressources Dex */
+ class_def_item class_def; /* Elément à transmettre */
+ bool status; /* Bilan de l'opération */
+
+#define DEX_POOL_GET_RAW_CLASS_METHOD PYTHON_METHOD_DEF \
+( \
+ "get_raw_class", "$self, index, /", \
+ METH_VARARGS, py_dex_pool_get_raw_class, \
+ "Provide the raw data of a given class in the Dex pool as a pychrysalide.PyStructObject" \
+ " instance." \
+ "\n" \
+ "Indexes start at 0.\n" \
+ "\n" \
+ "All the fields are extracted from the Dex *class_def_item* structure:\n" \
+ "* class_idx: index into the type_ids list for this class ;\n" \
+ "* access_flags: access flags for the class (public, final, etc.) ;\n" \
+ "* superclass_idx: index into the type_ids list for the superclass, or the constant value" \
+ " NO_INDEX if the class has no superclass ;\n" \
+ "* interfaces_off: offset from the start of the file to the list of interfaces, or 0" \
+ " if there are none ;\n" \
+ "* source_file_idx: index into the string_ids list for the name of the file containing" \
+ " the original source for (at least most of) this class, or the special value NO_INDEX to" \
+ " represent a lack of this information ;\n" \
+ "* annotations_off: offset from the start of the file to the annotations structure, or 0" \
+ " if there are no annotation ;\n" \
+ "* class_data_off: offset from the start of the file to the associated class data, or 0" \
+ " if there is no class data ;\n" \
+ "* static_values_off: offset from the start of the file to the list of initial values" \
+ " for static fields, or 0 if there are none.\n" \
+ "\n" \
+ "In case of error, the function returns None." \
+)
+
+ ret = PyArg_ParseTuple(args, "I", &index);
+ if (!ret) return NULL;
+
+ pool = G_DEX_POOL(pygobject_get(self));
+
+ status = g_dex_pool_get_raw_class(pool, index, &class_def);
+
+ if (status)
+ result = translate_dex_class_definition_to_python(&class_def);
+
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
@@ -437,6 +762,11 @@ static PyObject *py_dex_pool_get_classes(PyObject *self, void *closure)
PyTypeObject *get_python_dex_pool_type(void)
{
static PyMethodDef py_dex_pool_methods[] = {
+ DEX_POOL_GET_RAW_TYPE_METHOD,
+ DEX_POOL_GET_RAW_FIELD_METHOD,
+ DEX_POOL_GET_RAW_PROTOTYPE_METHOD,
+ DEX_POOL_GET_RAW_METHOD_METHOD,
+ DEX_POOL_GET_RAW_CLASS_METHOD,
{ NULL }
};
diff --git a/plugins/dex/python/translate.c b/plugins/dex/python/translate.c
index eb80c43..3d73616 100644
--- a/plugins/dex/python/translate.c
+++ b/plugins/dex/python/translate.c
@@ -39,6 +39,152 @@
* *
* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
* *
+* Description : Traduit des informations de type Dex en Python. *
+* *
+* Retour : Structure mise en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *translate_dex_type_id_to_python(const type_id_item *info)
+{
+ PyObject *result; /* Construction à retourner */
+ PyTypeObject *base; /* Modèle d'objet à créer */
+ PyObject *attrib; /* Attribut à constituer */
+ int ret; /* Bilan d'une mise en place */
+
+ base = get_python_py_struct_type();
+
+ result = PyObject_CallFunction((PyObject *)base, NULL);
+ assert(result != NULL);
+
+ /* Champs réguliers */
+
+#define TRANSLATE_ENCODED_TYPE_PROP(_f) \
+ do \
+ { \
+ attrib = PyLong_FromUnsignedLongLong(info->_f); \
+ ret = PyDict_SetItemString(result, #_f, attrib); \
+ if (ret != 0) goto tdcdtp_failed; \
+ } \
+ while (0);
+
+ TRANSLATE_ENCODED_TYPE_PROP(descriptor_idx);
+
+ return result;
+
+ tdcdtp_failed:
+
+ Py_DECREF(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
+* *
+* Description : Traduit des informations de type Dex en Python. *
+* *
+* Retour : Structure mise en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *translate_dex_type_item_to_python(const type_item *info)
+{
+ PyObject *result; /* Construction à retourner */
+ PyTypeObject *base; /* Modèle d'objet à créer */
+ PyObject *attrib; /* Attribut à constituer */
+ int ret; /* Bilan d'une mise en place */
+
+ base = get_python_py_struct_type();
+
+ result = PyObject_CallFunction((PyObject *)base, NULL);
+ assert(result != NULL);
+
+ /* Champs réguliers */
+
+#define TRANSLATE_ENCODED_TYPE_PROP(_f) \
+ do \
+ { \
+ attrib = PyLong_FromUnsignedLongLong(info->_f); \
+ ret = PyDict_SetItemString(result, #_f, attrib); \
+ if (ret != 0) goto tdcdtp_failed; \
+ } \
+ while (0);
+
+ TRANSLATE_ENCODED_TYPE_PROP(type_idx);
+
+ return result;
+
+ tdcdtp_failed:
+
+ Py_DECREF(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
+* *
+* Description : Traduit des informations de champ Dex en Python. *
+* *
+* Retour : Structure mise en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *translate_dex_field_id_to_python(const field_id_item *info)
+{
+ PyObject *result; /* Construction à retourner */
+ PyTypeObject *base; /* Modèle d'objet à créer */
+ PyObject *attrib; /* Attribut à constituer */
+ int ret; /* Bilan d'une mise en place */
+
+ base = get_python_py_struct_type();
+
+ result = PyObject_CallFunction((PyObject *)base, NULL);
+ assert(result != NULL);
+
+ /* Champs réguliers */
+
+#define TRANSLATE_ENCODED_FIELD_PROP(_f) \
+ do \
+ { \
+ attrib = PyLong_FromUnsignedLongLong(info->_f); \
+ ret = PyDict_SetItemString(result, #_f, attrib); \
+ if (ret != 0) goto tdcdtp_failed; \
+ } \
+ while (0);
+
+ TRANSLATE_ENCODED_FIELD_PROP(class_idx);
+ TRANSLATE_ENCODED_FIELD_PROP(type_idx);
+ TRANSLATE_ENCODED_FIELD_PROP(name_idx);
+
+ return result;
+
+ tdcdtp_failed:
+
+ Py_DECREF(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
+* *
* Description : Traduit des informations de champ de classe Dex en Python. *
* *
* Retour : Structure mise en place ou NULL en cas d'erreur. *
@@ -88,6 +234,106 @@ PyObject *translate_dex_field_info_to_python(const encoded_field *info)
* *
* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
* *
+* Description : Traduit des identifiants de prototype Dex en Python. *
+* *
+* Retour : Structure mise en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *translate_dex_proto_id_to_python(const proto_id_item *info)
+{
+ PyObject *result; /* Construction à retourner */
+ PyTypeObject *base; /* Modèle d'objet à créer */
+ PyObject *attrib; /* Attribut à constituer */
+ int ret; /* Bilan d'une mise en place */
+
+ base = get_python_py_struct_type();
+
+ result = PyObject_CallFunction((PyObject *)base, NULL);
+ assert(result != NULL);
+
+ /* Champs réguliers */
+
+#define TRANSLATE_ID_PROTO_PROP(_f) \
+ do \
+ { \
+ attrib = PyLong_FromUnsignedLongLong(info->_f); \
+ ret = PyDict_SetItemString(result, #_f, attrib); \
+ if (ret != 0) goto failed; \
+ } \
+ while (0);
+
+ TRANSLATE_ID_PROTO_PROP(shorty_idx);
+ TRANSLATE_ID_PROTO_PROP(return_type_idx);
+ TRANSLATE_ID_PROTO_PROP(parameters_off);
+
+ return result;
+
+ failed:
+
+ Py_DECREF(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
+* *
+* Description : Traduit des identifiants de méthode Dex en Python. *
+* *
+* Retour : Structure mise en place ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *translate_dex_method_id_to_python(const method_id_item *info)
+{
+ PyObject *result; /* Construction à retourner */
+ PyTypeObject *base; /* Modèle d'objet à créer */
+ PyObject *attrib; /* Attribut à constituer */
+ int ret; /* Bilan d'une mise en place */
+
+ base = get_python_py_struct_type();
+
+ result = PyObject_CallFunction((PyObject *)base, NULL);
+ assert(result != NULL);
+
+ /* Champs réguliers */
+
+#define TRANSLATE_ID_METHOD_PROP(_f) \
+ do \
+ { \
+ attrib = PyLong_FromUnsignedLongLong(info->_f); \
+ ret = PyDict_SetItemString(result, #_f, attrib); \
+ if (ret != 0) goto tdcdtp_failed; \
+ } \
+ while (0);
+
+ TRANSLATE_ID_METHOD_PROP(class_idx);
+ TRANSLATE_ID_METHOD_PROP(proto_idx);
+ TRANSLATE_ID_METHOD_PROP(name_idx);
+
+ return result;
+
+ tdcdtp_failed:
+
+ Py_DECREF(result);
+
+ return NULL;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : info = ensemble d'informations Dex à décrire en Python. *
+* *
* Description : Traduit des informations de méthode Dex en Python. *
* *
* Retour : Structure mise en place ou NULL en cas d'erreur. *
diff --git a/plugins/dex/python/translate.h b/plugins/dex/python/translate.h
index 29a0155..b360618 100644
--- a/plugins/dex/python/translate.h
+++ b/plugins/dex/python/translate.h
@@ -33,9 +33,24 @@
+/* Traduit des informations de type Dex en Python. */
+PyObject *translate_dex_type_id_to_python(const type_id_item *);
+
+/* Traduit des informations de type Dex en Python. */
+PyObject *translate_dex_type_item_to_python(const type_item *);
+
+/* Traduit des informations de champ Dex en Python. */
+PyObject *translate_dex_field_id_to_python(const field_id_item *);
+
/* Traduit des informations de champ de classe Dex en Python. */
PyObject *translate_dex_field_info_to_python(const encoded_field *);
+/* Traduit des identifiants de prototype Dex en Python. */
+PyObject *translate_dex_proto_id_to_python(const proto_id_item *);
+
+/* Traduit des identifiants de méthode Dex en Python. */
+PyObject *translate_dex_method_id_to_python(const method_id_item *);
+
/* Traduit des informations de méthode Dex en Python. */
PyObject *translate_dex_method_info_to_python(const encoded_method *);