diff options
Diffstat (limited to 'src/format/dex/class.c')
-rw-r--r-- | src/format/dex/class.c | 92 |
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); + +} |