diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-04-05 22:59:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-04-05 23:11:48 (GMT) |
commit | b0347ca45a08ac63bc6dd6f244b046c6d19a6cdd (patch) | |
tree | 9af1ec9901ddcf696bd3297633faf9fb46712396 /plugins/pe/section.c | |
parent | cf0b5d5f07e8102f2c9a04012bf29cabda9d85e4 (diff) |
Build a partial working support for the PE format.
Diffstat (limited to 'plugins/pe/section.c')
-rw-r--r-- | plugins/pe/section.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/plugins/pe/section.c b/plugins/pe/section.c index f4cdaf3..732b35c 100644 --- a/plugins/pe/section.c +++ b/plugins/pe/section.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * section.h - prototypes pour la gestion des sections d'un PE * - * Copyright (C) 2010-2017 Cyrille Bagard + * Copyright (C) 2010-2021 Cyrille Bagard * * This file is part of Chrysalide. * @@ -25,7 +25,6 @@ #include <malloc.h> -#include <string.h> #include "pe-int.h" @@ -34,26 +33,41 @@ /****************************************************************************** * * -* Paramètres : format = description de l'exécutable à consulter. * -* index = indice de la section recherchée. * -* section = ensemble d'informations à faire remonter. [OUT] * +* Paramètres : format = description de l'exécutable à consulter. * +* pos = tête de lecture positionnée. [OUT] * * * * Description : Recherche une section donnée au sein de binaire par indice. * * * -* Retour : Bilan de l'opération. * +* Retour : Liste de sections reconstituées ou NULL en cas d'échec. * * * * Remarques : - * * * ******************************************************************************/ -bool find_pe_section_by_index(const GPeFormat *format, uint16_t index, image_section_header *section) +image_section_header *read_all_pe_sections(const GPeFormat *format, vmpa2t *pos) { - off_t offset; /* Emplacement à venir lire */ + image_section_header *result; /* Liste à retourner */ + uint16_t count; /* Quantité de sections */ + uint16_t i; /* Boucle de parcours */ + bool status; /* Bilan d'une lecture */ - if (index >= format->nt_headers.file_header.number_of_sections) return false; + count = format->nt_headers.file_header.number_of_sections; - offset = format->section_offset + sizeof(image_section_header) * index; + result = malloc(count * sizeof(image_section_header)); - return read_pe_image_section_header(format, &offset, section); + for (i = 0; i < count; i++) + { + status = read_pe_image_section_header(format, pos, &result[i]); + + if (!status) + { + free(result); + result = NULL; + break; + } + + } + + return result; } |