From a2cf44f27c9ab9eaf84a7f59a8a1d74ebc2fa9c2 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 19 Nov 2016 19:16:54 -0500 Subject: pe_get_image_section_tbl_addr(): code maintenance. --- src/headers/pe_get_image_section_tbl_addr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/headers/pe_get_image_section_tbl_addr.c b/src/headers/pe_get_image_section_tbl_addr.c index 3dad1f5..49b2957 100644 --- a/src/headers/pe_get_image_section_tbl_addr.c +++ b/src/headers/pe_get_image_section_tbl_addr.c @@ -10,11 +10,12 @@ #include #include "pe_impl.h" -pe_api -struct pe_raw_sec_hdr * pe_get_image_section_tbl_addr (const void * base) + +struct pe_raw_sec_hdr * pe_get_image_section_tbl_addr(const void * base) { struct pe_raw_coff_file_hdr * coff; union pe_raw_opt_hdr * opt; + unsigned char * mark; if (!(coff = pe_get_image_coff_hdr_addr(base))) return 0; @@ -22,7 +23,11 @@ struct pe_raw_sec_hdr * pe_get_image_section_tbl_addr (const void * base) if (!(opt = pe_get_image_opt_hdr_addr(base))) return 0; - return (struct pe_raw_sec_hdr *)((char *)opt + *(uint16_t *)coff->size_of_opt_hdr); + mark = opt->opt_hdr_32.magic; + mark += coff->size_of_opt_hdr[1] << 8; + mark += coff->size_of_opt_hdr[0]; + + return (struct pe_raw_sec_hdr *)mark; } pe_api -- cgit v1.2.3