diff options
Diffstat (limited to 'plugins/dex/format.c')
-rw-r--r-- | plugins/dex/format.c | 95 |
1 files changed, 41 insertions, 54 deletions
diff --git a/plugins/dex/format.c b/plugins/dex/format.c index 44e8ba3..53cdc29 100644 --- a/plugins/dex/format.c +++ b/plugins/dex/format.c @@ -205,6 +205,8 @@ static void g_dex_format_init(GDexFormat *format) static void g_dex_format_dispose(GDexFormat *format) { + g_clear_object(&format->pool); + G_OBJECT_CLASS(g_dex_format_parent_class)->dispose(G_OBJECT(format)); } @@ -252,6 +254,8 @@ GExeFormat *g_dex_format_new(GBinContent *content) g_binary_format_set_content(G_BIN_FORMAT(result), content); + result->pool = g_dex_pool_new(result); + return G_EXE_FORMAT(result); } @@ -326,6 +330,7 @@ static bool g_dex_format_analyze(GDexFormat *format, wgroup_id_t gid, GtkStatusS phys_t size; /* Taille du binaire */ VMPA_BUFFER(size_str); /* Conversion en chaîne */ uint32_t max; /* Nombre maximal d'éléments */ + GDexPool *pool; /* Table de ressources */ result = false; @@ -388,30 +393,36 @@ static bool g_dex_format_analyze(GDexFormat *format, wgroup_id_t gid, GtkStatusS /* TODO : vérifier que les *_id ne se chevauchent pas */ - if (!load_all_dex_string_symbols(format, gid, status)) - goto gdfa_error; + pool = g_dex_format_get_pool(format); - if (!load_all_dex_types(format, gid, status)) - goto gdfa_error; + if (!g_dex_pool_load_all_string_symbols(pool, gid, status)) + goto pool_error; - if (!load_all_dex_fields(format, gid, status)) - goto gdfa_error; + if (!g_dex_pool_load_all_types(pool, gid, status)) + goto pool_error; - if (!load_all_dex_methods(format, gid, status)) - goto gdfa_error; + if (!g_dex_pool_load_all_fields(pool, gid, status)) + goto pool_error; - if (!load_all_dex_classes(format, gid, status)) - goto gdfa_error; + if (!g_dex_pool_load_all_methods(pool, gid, status)) + goto pool_error; + + if (!g_dex_pool_load_all_classes(pool, gid, status)) + goto pool_error; preload_binary_format(PGA_FORMAT_PRELOAD, base, base->info, status); g_executable_format_setup_portions(exe, status); if (!g_executable_format_complete_loading(exe, gid, status)) - goto gdfa_error; + goto pool_error; result = true; + pool_error: + + g_object_unref(G_OBJECT(pool)); + gdfa_error: return result; @@ -475,13 +486,23 @@ static void g_dex_format_refine_portions(GDexFormat *format) GExeFormat *exe_format; /* Autre version du format */ size_t max; /* Nombre d'itérations prévues */ size_t i; /* Boucle de parcours */ + GDexClass *class; /* Classe du format Dex */ exe_format = G_EXE_FORMAT(format); - max = g_dex_format_count_classes(format); + max = g_dex_pool_count_classes(format->pool); for (i = 0; i < max; i++) - g_dex_class_include_as_portion(format->classes[i], exe_format); + { + class = g_dex_pool_get_class(format->pool, i); + + if (class != NULL) + { + g_dex_class_include_as_portion(class, exe_format); + g_object_unref(G_OBJECT(class)); + } + + } } @@ -574,61 +595,27 @@ const dex_header *g_dex_format_get_header(const GDexFormat *format) } - - - /****************************************************************************** * * -* Paramètres : format = description de l'exécutable à consulter. * -* * -* Description : Dénombre le nombre de classes trouvées. * -* * -* Retour : Quantité de classes présentes. * -* * -* Remarques : - * -* * -******************************************************************************/ - -size_t g_dex_format_count_classes(const GDexFormat *format) -{ - return format->header.class_defs_size; - -} - - -/****************************************************************************** -* * -* Paramètres : format = description de l'exécutable à consulter. * -* index = indice de la classe visée. * +* Paramètres : format = informations chargées à consulter. * * * -* Description : Fournit une classe du format chargée en mémoire. * +* Description : Fournit la table des ressources associée au format Dex. * * * -* Retour : Instance représentant une classe chargée. * +* Retour : Table de ressources mise en place ou NULL si aucune. * * * * Remarques : - * * * ******************************************************************************/ -GDexClass *g_dex_format_get_class(const GDexFormat *format, size_t index) +GDexPool *g_dex_format_get_pool(const GDexFormat *format) { - GDexClass *result; /* Classe trouvée à retourner */ + GDexPool *result; /* Instance à retourner */ - assert(index < format->header.class_defs_size); + result = format->pool; - if (index < format->header.class_defs_size) - { - result = format->classes[index]; + if (result != NULL) g_object_ref(G_OBJECT(result)); - } - - else - result = NULL; return result; } - - - - - |