diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 18:43:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-24 18:43:55 (GMT) |
commit | 156d2e2f6beda2302552ac79678494d914fda05b (patch) | |
tree | 021825960b7ac3315a336fc085a4f1d07c05df39 /src/format/elf/strings.c | |
parent | 21537636cd8318cf5a720211619ad3c3023b52e9 (diff) |
Replaced all remaining raw accesses to binary contents with the GBinContent wrapper in binary formats.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@555 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/strings.c')
-rw-r--r-- | src/format/elf/strings.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/format/elf/strings.c b/src/format/elf/strings.c index 6832f5b..4d8a32e 100644 --- a/src/format/elf/strings.c +++ b/src/format/elf/strings.c @@ -37,7 +37,7 @@ /* Enregistre toutes les chaînes de caractères trouvées. */ -bool parse_elf_string_data(GElfFormat *, off_t, off_t, vmpa_t); +bool parse_elf_string_data(GElfFormat *, phys_t, phys_t, virt_t); @@ -56,14 +56,14 @@ bool parse_elf_string_data(GElfFormat *, off_t, off_t, vmpa_t); bool find_all_elf_strings(GElfFormat *format) { bool got_string; /* Indique un remplissage */ - off_t str_start; /* Début de section */ - off_t str_size; /* Taille de section */ - vmpa_t str_addr; /* Adresse virtuelle associée */ + phys_t str_start; /* Début de section */ + phys_t str_size; /* Taille de section */ + virt_t str_addr; /* Adresse virtuelle associée */ elf_shdr *sections; /* Groupe de sections trouvées */ size_t count; /* Quantité de données */ size_t i; /* Boucle de parcours #1 */ - off_t length; /* Taille totale du contenu */ - off_t iter; /* Boucle de parcours #2 */ + phys_t max; /* Borne à ne pas dépasser */ + phys_t iter; /* Boucle de parcours #2 */ elf_phdr phdr; /* En-tête de programme ELF */ got_string = false; @@ -109,10 +109,10 @@ bool find_all_elf_strings(GElfFormat *format) if (!got_string) { - length = G_BIN_FORMAT(format)->length; - length = MIN(length, ELF_HDR(format, format->header, e_phnum) * ELF_SIZEOF_PHDR(format)); + max = ELF_HDR(format, format->header, e_phoff) + + ELF_HDR(format, format->header, e_phnum) * ELF_SIZEOF_PHDR(format); - for (iter = ELF_HDR(format, format->header, e_phoff); iter < length; iter += ELF_SIZEOF_PHDR(format)) + for (iter = ELF_HDR(format, format->header, e_phoff); iter < max; iter += ELF_SIZEOF_PHDR(format)) { if (!read_elf_program_header(format, iter, &phdr)) continue; @@ -148,7 +148,7 @@ bool find_all_elf_strings(GElfFormat *format) * * ******************************************************************************/ -bool parse_elf_string_data(GElfFormat *format, off_t start, off_t size, vmpa_t address) +bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t address) { bool result; /* Bilan à faire remonter */ GBinContent *content; /* Contenu binaire à lire */ @@ -167,7 +167,7 @@ bool parse_elf_string_data(GElfFormat *format, off_t start, off_t size, vmpa_t a /* Préparation des accès */ - content = g_binary_format_get_conten_(G_BIN_FORMAT(format)); + content = g_binary_format_get_content(G_BIN_FORMAT(format)); data = (char *)malloc(size * sizeof(char)); @@ -194,7 +194,7 @@ bool parse_elf_string_data(GElfFormat *format, off_t start, off_t size, vmpa_t a init_vmpa(&pos, start + i, address + i); - instr = g_raw_instruction_new_array(G_BIN_FORMAT(format)->conten_, MDS_8_BITS, + instr = g_raw_instruction_new_array(G_BIN_FORMAT(format)->content, MDS_8_BITS, end - i, &pos, format->endian); g_raw_instruction_mark_as_string(G_RAW_INSTRUCTION(instr), true); @@ -227,6 +227,8 @@ bool parse_elf_string_data(GElfFormat *format, off_t start, off_t size, vmpa_t a pesd_error: + g_object_unref(G_OBJECT(content)); + free(data); return result; |