diff options
Diffstat (limited to 'plugins/dex/format.c')
-rwxr-xr-x | plugins/dex/format.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/plugins/dex/format.c b/plugins/dex/format.c index 1fa5a7d..b9b6ca9 100755 --- a/plugins/dex/format.c +++ b/plugins/dex/format.c @@ -55,6 +55,9 @@ static void g_dex_format_finalize(GDexFormat *); /* Indique la désignation interne du format. */ static const char *g_dex_format_get_name(const GDexFormat *); +/* Fournit une description humaine du format. */ +static const char *g_dex_format_get_description(const GDexFormat *); + /* Assure l'interprétation d'un format en différé. */ static bool g_dex_format_analyze(GDexFormat *, wgroup_id_t, GtkStatusStack *); @@ -90,6 +93,39 @@ static void g_dex_format_decompile(const GDexFormat *, void/*GCodeBuffer*/ *, co + + + +/****************************************************************************** +* * +* Paramètres : content = contenu binaire à traiter. * +* * +* Description : Valide un contenu comme étant un format Dex. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool check_dex_format(const GBinContent *content) +{ + bool result; /* Bilan à faire remonter */ + vmpa2t addr; /* Tête de lecture initiale */ + char magic[DEX_FILE_MAGIC_LEN]; /* Idenfiant standard */ + + init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); + + result = g_binary_content_read_raw(content, &addr, DEX_FILE_MAGIC_LEN, (bin_t *)magic); + + if (result) + result = (memcmp(magic, DEX_FILE_MAGIC, DEX_FILE_MAGIC_LEN) == 0); + + 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); @@ -120,6 +156,7 @@ 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->get_desc = (format_get_desc_fc)g_dex_format_get_description; fmt->analyze = (format_analyze_fc)g_dex_format_analyze; fmt->get_endian = (format_get_endian_fc)g_dex_format_get_endianness; @@ -216,6 +253,9 @@ GExeFormat *g_dex_format_new(GBinContent *content) { GDexFormat *result; /* Structure à retourner */ + if (!check_dex_format(content)) + return NULL; + result = g_object_new(G_TYPE_DEX_FORMAT, NULL); g_binary_format_set_content(G_BIN_FORMAT(result), content); @@ -250,6 +290,29 @@ static const char *g_dex_format_get_name(const GDexFormat *format) /****************************************************************************** * * +* Paramètres : format = description de l'exécutable à consulter. * +* * +* Description : Fournit une description humaine du format. * +* * +* Retour : Description du format. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const char *g_dex_format_get_description(const GDexFormat *format) +{ + const char *result; /* Désignation à retourner */ + + result = "Dalvik Executable format (version '035')"; + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : format = format chargé dont l'analyse est lancée. * * gid = groupe de travail dédié. * * status = barre de statut à tenir informée. * |