summaryrefslogtreecommitdiff
path: root/src/format/dex/class.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-06-01 22:53:05 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-06-01 22:53:05 (GMT)
commite72eea33b9967d4169d2c8ffcb4a9e85c4c3ee8c (patch)
treed376a1bded84bcd82ff28d0a1c7fb0c062c9a663 /src/format/dex/class.c
parent6a2287739080535fd9f82ab2453abe916a9bc28d (diff)
Registered all found DEX routines.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@164 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/dex/class.c')
-rw-r--r--src/format/dex/class.c92
1 files changed, 76 insertions, 16 deletions
diff --git a/src/format/dex/class.c b/src/format/dex/class.c
index 03431f0..23e08a0 100644
--- a/src/format/dex/class.c
+++ b/src/format/dex/class.c
@@ -66,6 +66,8 @@ static void g_dex_class_init(GDexClass *);
/* Crée une nouvelle représentation de classe issue de code. */
static GDexClass *g_dex_class_new(const GDexFormat *, off_t);
+/* Inscrit les méthodes d'une classe en tant que routines. */
+static void g_dex_class_register_method(const GDexClass *, GBinFormat *);
@@ -134,6 +136,7 @@ static GDexClass *g_dex_class_new(const GDexFormat *format, off_t offset)
GDexClass *result; /* Composant à retourner */
class_def_item def; /* Définition de la classe */
class_data_item data; /* Contenu de la classe */
+ uleb128_t index; /* Conservation du dernier id */
uleb128_t i; /* Boucle de parcours */
GDexMethod *method; /* Méthode chargée */
@@ -154,9 +157,11 @@ static GDexClass *g_dex_class_new(const GDexFormat *format, off_t offset)
result = g_object_new(G_TYPE_DEX_CLASS, NULL);
+ index = 0;
+
for (i = 0; i < data.direct_methods_size; i++)
{
- method = g_dex_method_new(format, &data.direct_methods[i]);
+ method = g_dex_method_new(format, &data.direct_methods[i], &index);
if (method != NULL)
{
@@ -170,11 +175,11 @@ static GDexClass *g_dex_class_new(const GDexFormat *format, off_t offset)
}
-
+ index = 0;
for (i = 0; i < data.virtual_methods_size; i++)
{
- method = g_dex_method_new(format, &data.virtual_methods[i]);
+ method = g_dex_method_new(format, &data.virtual_methods[i], &index);
if (method != NULL)
{
@@ -197,6 +202,49 @@ static GDexClass *g_dex_class_new(const GDexFormat *format, off_t offset)
/******************************************************************************
* *
+* Paramètres : class = informations chargées à consulter. *
+* format = format binaire à compléter. *
+* *
+* Description : Inscrit les méthodes d'une classe en tant que routines. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_dex_class_register_method(const GDexClass *class, GBinFormat *format)
+{
+ size_t i; /* Boucle de parcours */
+ GBinRoutine *routine; /* Routine à inscrire */
+
+ for (i = 0; i < class->dmethods_count; i++)
+ {
+ routine = g_dex_method_get_routine(class->direct_methods[i]);
+ g_binary_format_add_routine(format, routine);
+
+ printf("routine @ 0x%08llx :: '%s'\n",
+ g_binary_routine_get_address(routine),
+ g_binary_routine_get_name(routine));
+
+ }
+
+ for (i = 0; i < class->vmethods_count; i++)
+ {
+ routine = g_dex_method_get_routine(class->virtual_methods[i]);
+ g_binary_format_add_routine(format, routine);
+
+ printf("routine @ 0x%08llx :: '%s'\n",
+ g_binary_routine_get_address(routine),
+ g_binary_routine_get_name(routine));
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : class = informations chargées à consulter. *
* parts = liste à venir compléter. *
* count = quantité de zones listées. [OUT] *
@@ -244,19 +292,6 @@ GBinPart **g_dex_class_get_parts(const GDexClass *class, GBinPart **parts, size_
-
-
-
-
-
-
-
-
-
-
-
-
-
/******************************************************************************
* *
* Paramètres : format = représentation interne du format DEX à compléter. *
@@ -296,3 +331,28 @@ bool load_all_dex_classes(GDexFormat *format)
return true;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = représentation interne du format DEX à compléter. *
+* *
+* Description : Enregistre toutes les méthodes des classes listées. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void register_all_dex_class_methods(GDexFormat *format)
+{
+ size_t i; /* Boucle de parcours */
+ GBinFormat *bformat; /* Autre version du format */
+
+ bformat = G_BIN_FORMAT(format);
+
+ for (i = 0; i < format->classes_count; i++)
+ g_dex_class_register_method(format->classes[i], bformat);
+
+}