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