diff options
Diffstat (limited to 'plugins/elf/format.c')
-rw-r--r-- | plugins/elf/format.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/plugins/elf/format.c b/plugins/elf/format.c index 86682a2..9e29a11 100644 --- a/plugins/elf/format.c +++ b/plugins/elf/format.c @@ -63,6 +63,9 @@ static void g_elf_format_finalize(GElfFormat *); /* Indique la désignation interne du format. */ static const char *g_elf_format_get_name(const GElfFormat *); +/* Fournit une description humaine du format. */ +static const char *g_elf_format_get_description(const GElfFormat *); + /* Assure l'interprétation d'un format en différé. */ static bool g_elf_format_analyze(GElfFormat *, wgroup_id_t, GtkStatusStack *); @@ -94,42 +97,28 @@ static bool g_elf_format_get_section_range_by_name(const GElfFormat *, const cha /****************************************************************************** * * -* 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] * +* Paramètres : content = contenu binaire à traiter. * * * -* Description : Indique si le format peut être pris en charge ici. * +* Description : Valide un contenu comme étant un format Elf. * * * -* Retour : Conclusion de haut niveau sur la reconnaissance effectuée. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -FormatMatchStatus elf_is_matching(GBinContent *content, GExeFormat *parent, void *unused, char **key) +bool check_elf_format(const GBinContent *content) { - FormatMatchStatus result; /* Bilan à renvoyer */ + bool result; /* Bilan à faire remonter */ vmpa2t addr; /* Tête de lecture initiale */ - bool status; /* Bilan des accès mémoire */ char magic[4]; /* Idenfiant standard */ - if (parent != NULL) - return FMS_UNKNOWN; - init_vmpa(&addr, 0, VMPA_NO_VIRTUAL); - status = g_binary_content_read_raw(content, &addr, 4, (bin_t *)magic); + result = g_binary_content_read_raw(content, &addr, 4, (bin_t *)magic); - status &= (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0); - - if (status) - { - result = FMS_MATCHED; - *key = strdup("elf"); - } - else - result = FMS_UNKNOWN; + if (result) + result = (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0); return result; @@ -166,6 +155,7 @@ static void g_elf_format_class_init(GElfFormatClass *klass) fmt = G_BIN_FORMAT_CLASS(klass); fmt->get_name = (format_get_name_fc)g_elf_format_get_name; + fmt->get_desc = (format_get_desc_fc)g_elf_format_get_description; fmt->analyze = (format_analyze_fc)g_elf_format_analyze; fmt->get_endian = (format_get_endian_fc)g_elf_format_get_endianness; @@ -257,6 +247,9 @@ GExeFormat *g_elf_format_new(GBinContent *content) { GElfFormat *result; /* Structure à retourner */ + if (!check_elf_format(content)) + return NULL; + result = g_object_new(G_TYPE_ELF_FORMAT, NULL); g_binary_format_set_content(G_BIN_FORMAT(result), content); @@ -291,6 +284,29 @@ static const char *g_elf_format_get_name(const GElfFormat *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_elf_format_get_description(const GElfFormat *format) +{ + const char *result; /* Désignation à retourner */ + + result = "Executable and Linkable Format"; + + 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. * |