diff options
Diffstat (limited to 'plugins/dex/format.c')
-rwxr-xr-x | plugins/dex/format.c | 150 |
1 files changed, 76 insertions, 74 deletions
diff --git a/plugins/dex/format.c b/plugins/dex/format.c index f4cfdc9..d3e18da 100755 --- a/plugins/dex/format.c +++ b/plugins/dex/format.c @@ -51,6 +51,12 @@ static void g_dex_format_dispose(GDexFormat *); /* Procède à la libération totale de la mémoire. */ static void g_dex_format_finalize(GDexFormat *); +/* Indique la désignation interne du format. */ +static const char *g_dex_format_get_name(const GDexFormat *); + +/* Assure l'interprétation d'un format en différé. */ +static bool g_dex_format_analyze(GDexFormat *, wgroup_id_t, GtkStatusStack *); + /* Informe quant au boutisme utilisé. */ static SourceEndian g_dex_format_get_endianness(const GDexFormat *); @@ -83,52 +89,6 @@ static void g_dex_format_decompile(const GDexFormat *, void/*GCodeBuffer*/ *, co -/****************************************************************************** -* * -* Paramètres : content = contenu binaire à parcourir. * -* parent = éventuel format exécutable déjà chargé. * -* unused = adresse non utilisée ici. * -* key = identifiant de format trouvé ou NULL. [OUT] * -* * -* Description : Indique si le format peut être pris en charge ici. * -* * -* Retour : Conclusion de haut niveau sur la reconnaissance effectuée. * -* * -* Remarques : - * -* * -******************************************************************************/ - -FormatMatchStatus dex_is_matching(GBinContent *content, GExeFormat *parent, void *unused, char **key) -{ - FormatMatchStatus result; /* Bilan à renvoyer */ - vmpa2t addr; /* Tête de lecture initiale */ - bool status; /* Bilan des accès mémoire */ - char magic[DEX_FILE_MAGIC_LEN]; /* Idenfiant standard */ - - - /* REMME */ - if (parent != NULL) return FMS_UNKNOWN; - - - init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); - - status = g_binary_content_read_raw(content, &addr, DEX_FILE_MAGIC_LEN, (bin_t *)magic); - - status &= (memcmp(magic, DEX_FILE_MAGIC, DEX_FILE_MAGIC_LEN) == 0); - - if (status) - { - result = FMS_MATCHED; - *key = strdup(parent == NULL ? "dex" : "dexdbg"); - } - else - result = FMS_UNKNOWN; - - return result; - -} - - /* Indique le type défini pour un format d'exécutable DEX. */ G_DEFINE_TYPE(GDexFormat, g_dex_format, G_TYPE_EXE_FORMAT); @@ -158,6 +118,8 @@ static void g_dex_format_class_init(GDexFormatClass *klass) fmt = G_BIN_FORMAT_CLASS(klass); + fmt->get_name = (format_get_name_fc)g_dex_format_get_name; + fmt->analyze = (format_analyze_fc)g_dex_format_analyze; fmt->get_endian = (format_get_endian_fc)g_dex_format_get_endianness; exe = G_EXE_FORMAT_CLASS(klass); @@ -240,8 +202,6 @@ static void g_dex_format_finalize(GDexFormat *format) /****************************************************************************** * * * Paramètres : content = contenu binaire à parcourir. * -* parent = éventuel format exécutable déjà chargé. * - status = barre de statut à tenir informée. * * * * Description : Prend en charge un nouveau format Dex. * * * @@ -251,54 +211,96 @@ static void g_dex_format_finalize(GDexFormat *format) * * ******************************************************************************/ -GBinFormat *g_dex_format_new(GBinContent *content, GExeFormat *parent, GtkStatusStack *status) +GExeFormat *g_dex_format_new(GBinContent *content) { GDexFormat *result; /* Structure à retourner */ - GBinFormat *base; /* Version basique du format */ - GExeFormat *exe_format; /* Autre version du format */ - vmpa2t pos; /* Position de tête de lecture */ - wgroup_id_t gid; /* Identifiant pour les tâches */ result = g_object_new(G_TYPE_DEX_FORMAT, NULL); - base = G_BIN_FORMAT(result); - exe_format = G_EXE_FORMAT(result); + g_binary_format_set_content(G_BIN_FORMAT(result), content); - g_binary_format_set_content(base, content); + return G_EXE_FORMAT(result); - init_vmpa(&pos, 0, VMPA_NO_VIRTUAL); +} - if (!read_dex_header(result, &pos, &result->header)) - goto gdfn_error; +/****************************************************************************** +* * +* Paramètres : format = description de l'exécutable à consulter. * +* * +* Description : Indique la désignation interne du format. * +* * +* Retour : Description du format. * +* * +* Remarques : - * +* * +******************************************************************************/ +static const char *g_dex_format_get_name(const GDexFormat *format) +{ + const char *result; /* Désignation à retourner */ - /* TODO : vérifier que les *_id ne se chevauchent pas */ + result = "dex"; + return result; - gid = g_work_queue_define_work_group(get_work_queue()); +} - if (!load_all_dex_types(result, gid, status)) - goto gdfn_error; - if (!load_all_dex_fields(result, gid, status)) - goto gdfn_error; +/****************************************************************************** +* * +* Paramètres : format = format chargé dont l'analyse est lancée. * +* gid = groupe de travail dédié. * +* status = barre de statut à tenir informée. * +* * +* Description : Assure l'interprétation d'un format en différé. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ - if (!load_all_dex_classes(result, gid, status)) - goto gdfn_error; +static bool g_dex_format_analyze(GDexFormat *format, wgroup_id_t gid, GtkStatusStack *status) +{ + bool result; /* Bilan à retourner */ + GBinFormat *base; /* Version basique du format */ + GExeFormat *exe; /* Autre version du format */ + vmpa2t pos; /* Position de tête de lecture */ - preload_binary_format(PGA_FORMAT_PRELOAD, base, base->info, status); + result = false; - if (!g_executable_format_complete_loading(exe_format, status)) - goto gdfn_error; + base = G_BIN_FORMAT(format); + exe = G_EXE_FORMAT(format); - return base; + init_vmpa(&pos, 0, VMPA_NO_VIRTUAL); - gdfn_error: + if (!read_dex_header(format, &pos, &format->header)) + goto gdfa_error; - g_object_unref(G_OBJECT(result)); - return NULL; + /* TODO : vérifier que les *_id ne se chevauchent pas */ + + + if (!load_all_dex_types(format, gid, status)) + goto gdfa_error; + + if (!load_all_dex_fields(format, gid, status)) + goto gdfa_error; + + if (!load_all_dex_classes(format, gid, status)) + goto gdfa_error; + + preload_binary_format(PGA_FORMAT_PRELOAD, base, base->info, status); + + if (!g_executable_format_complete_loading(exe, status)) + goto gdfa_error; + + result = true; + + gdfa_error: + + return result; } |