summaryrefslogtreecommitdiff
path: root/src/format/dex/pool.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-05-17 00:28:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-05-17 00:28:23 (GMT)
commit7adb4243ad629554e496de173977721a8a5d0110 (patch)
tree18f50fcdab35e057b3a1a10e7e0c1f141e89eb39 /src/format/dex/pool.c
parent118a668adbf6ca9d4c549618e54f58330f46ce58 (diff)
Given more details for each operand relative to one DEX pool.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@156 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/dex/pool.c')
-rw-r--r--src/format/dex/pool.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/format/dex/pool.c b/src/format/dex/pool.c
index 0a8bed3..dbcee52 100644
--- a/src/format/dex/pool.c
+++ b/src/format/dex/pool.c
@@ -34,6 +34,45 @@
* Paramètres : format = représentation interne du format DEX à consulter. *
* index = index du type recherchée. *
* *
+* Description : Extrait une chaîne de caractères d'une table DEX. *
+* *
+* Retour : Chaîne de caractères trouvées ou NULL en cas d'erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+const char *get_string_from_dex_pool(const GDexFormat *format, uint32_t index)
+{
+ off_t pos; /* Tête de lecture */
+ string_id_item str_id; /* Identifiant de chaîne */
+ string_data_item str_data; /* Description de chaîne */
+
+ pos = format->header.string_ids_off + index * sizeof(string_id_item);
+
+ if (!read_dex_string_id_item(format, &pos, &str_id))
+ return NULL;
+
+ pos = str_id.string_data_off;
+
+ if (!read_dex_string_data_item(format, &pos, &str_data))
+ return NULL;
+
+ return (const char *)str_data.data;
+
+}
+
+
+
+
+
+
+
+/******************************************************************************
+* *
+* 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. *
* *
* Retour : Composant GLib créé. *
@@ -119,6 +158,64 @@ GOpenidaType *get_class_from_dex_pool(const GDexFormat *format, uint16_t index)
+/******************************************************************************
+* *
+* 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. *
+* *
+* Retour : Composant GLib créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBinVariable *get_field_from_dex_pool(const GDexFormat *format, uint32_t index)
+{
+ GBinVariable *result; /* Instance à retourner */
+ off_t pos; /* Tête de lecture */
+ field_id_item field_id; /* Description du champ */
+ GOpenidaType *type; /* Type du champ */
+ const char *name; /* Désignation humaine */
+ GOpenidaType *owner; /* Propriétaire du champ */
+
+ pos = format->header.field_ids_off + index * sizeof(field_id_item);
+
+ if (!read_dex_field_id_item(format, &pos, &field_id))
+ return NULL;
+
+ type = get_type_from_dex_pool(format, field_id.type_idx);
+
+ name = get_string_from_dex_pool(format, field_id.name_idx);
+ if (name == NULL) goto bad_name;
+
+ result = g_binary_variable_new(type);
+ g_binary_variable_set_name(result, name);
+
+ if (field_id.class_idx != NO_INDEX)
+ {
+ owner = get_type_from_dex_pool(format, field_id.class_idx);
+ if (owner == NULL) goto bad_owner;
+
+ g_binary_variable_set_owner(result, owner);
+
+ }
+
+ return result;
+
+ bad_owner:
+
+ g_object_ref(G_OBJECT(type));
+ g_object_unref(G_OBJECT(result));
+
+ bad_name:
+
+ g_object_unref(G_OBJECT(type));
+
+ return NULL;
+
+}
/******************************************************************************