diff options
Diffstat (limited to 'plugins/dex/class.c')
-rw-r--r-- | plugins/dex/class.c | 143 |
1 files changed, 97 insertions, 46 deletions
diff --git a/plugins/dex/class.c b/plugins/dex/class.c index dafa984..d549014 100644 --- a/plugins/dex/class.c +++ b/plugins/dex/class.c @@ -222,11 +222,7 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def) uleb128_t index; /* Conservation du dernier id */ uleb128_t i; /* Boucle de parcours */ GDexField *field; /* Champ chargé */ - GDexPool *pool; /* Table de ressources */ - GDataType *ctype; /* Type créé par la classe */ - GBinFormat *base; /* Autre version du format */ GDexMethod *method; /* Méthode chargée */ - GBinRoutine *routine; /* Version interne de méthode */ result = g_object_new(G_TYPE_DEX_CLASS, NULL); @@ -292,16 +288,6 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def) * Chargement des méthodes de classe. */ - pool = g_dex_format_get_pool(format); - - ctype = g_dex_pool_get_type_(pool, def->class_idx); - - g_object_unref(G_OBJECT(pool)); - - if (ctype == NULL) goto gdcn_unknown_type; - - base = G_BIN_FORMAT(format); - index = 0; result->dmethods_count = data.direct_methods_size; @@ -314,18 +300,6 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def) result->direct_methods[i] = method; - /* Ajout à la liste des symboles */ - if (g_dex_method_has_dex_body(method)) - { - routine = g_dex_method_get_routine(method); - - g_object_ref(G_OBJECT(ctype)); - g_binary_routine_set_namespace(routine, ctype, strdup(".")); - - g_binary_format_add_symbol(base, G_BIN_SYMBOL(routine)); - - } - } index = 0; @@ -340,32 +314,14 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def) result->virtual_methods[i] = method; - /* Ajout à la liste des symboles */ - if (g_dex_method_has_dex_body(method)) - { - routine = g_dex_method_get_routine(method); - - g_object_ref(G_OBJECT(ctype)); - g_binary_routine_set_namespace(routine, ctype, strdup(".")); - - g_binary_format_add_symbol(base, G_BIN_SYMBOL(routine)); - - } - } - g_object_unref(G_OBJECT(ctype)); - gdcn_done: return result; gdcn_bad_method: - g_object_unref(G_OBJECT(ctype)); - - gdcn_unknown_type: - gdcn_bad_field: gdcn_bad_item: @@ -379,7 +335,7 @@ GDexClass *g_dex_class_new(GDexFormat *format, const class_def_item *def) /****************************************************************************** * * -* Paramètres : class = informations chargées à consulter. * +* Paramètres : class = informations chargées à consulter. * * * * Description : Fournit la définition brute d'une classe. * * * @@ -398,7 +354,7 @@ const class_def_item *g_dex_class_get_definition(const GDexClass *class) /****************************************************************************** * * -* Paramètres : class = informations chargées à consulter. * +* Paramètres : class = informations chargées à consulter. * * * * Description : Fournit la définition brute des données d'une classe. * * * @@ -660,6 +616,101 @@ GDexMethod *g_dex_class_get_method(const GDexClass *class, bool virtual, size_t /****************************************************************************** * * +* Paramètres : class = informations chargées à consulter. * +* symbols = liste de symboles complétée. [OUT] * +* count = taille de cette liste. [OUT] * +* * +* Description : Etablit une liste de tous les symboles d'une classe. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_dex_class_get_collect_symbols(const GDexClass *class, GBinSymbol ***symbols, size_t *count) +{ + bool result; /* Bilan à retourner */ + GDexPool *pool; /* Table de ressources */ + GDataType *ctype; /* Type créé par la classe */ + size_t slots_used; /* Compteur d'utilisations */ + size_t i; /* Boucle de parcours */ + GDexMethod *method; /* Méthode chargée */ + GBinRoutine *routine; /* Version interne de méthode */ + + result = false; + + /* Contexte des méthodes */ + + pool = g_dex_format_get_pool(class->format); + + ctype = g_dex_pool_get_type_(pool, class->definition.class_idx); + + g_object_unref(G_OBJECT(pool)); + + if (ctype == NULL) goto unknown_type; + + /* Intégration des méthodes */ + + *symbols = realloc(*symbols, (*count + class->dmethods_count + class->vmethods_count) * sizeof(GBinSymbol *)); + + result = true; + + slots_used = 0; + + for (i = 0; i < class->dmethods_count; i++) + { + method = class->direct_methods[i]; + + if (g_dex_method_has_dex_body(method)) + { + routine = g_dex_method_get_routine(method); + + g_object_ref(G_OBJECT(ctype)); + g_binary_routine_set_namespace(routine, ctype, strdup(".")); + + (*symbols)[*count + slots_used] = G_BIN_SYMBOL(routine); + slots_used++; + + } + + } + + *count += slots_used; + + slots_used = 0; + + for (i = 0; i < class->vmethods_count; i++) + { + method = class->virtual_methods[i]; + + if (g_dex_method_has_dex_body(method)) + { + routine = g_dex_method_get_routine(method); + + g_object_ref(G_OBJECT(ctype)); + g_binary_routine_set_namespace(routine, ctype, strdup(".")); + + (*symbols)[*count + slots_used] = G_BIN_SYMBOL(routine); + slots_used++; + + } + + } + + *count += slots_used; + + g_object_unref(G_OBJECT(ctype)); + + unknown_type: + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : class = informations chargées à consulter. * * format = format permettant d'obtenir une adresse complète. * * * |