summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-19 19:16:54 -0500
committermidipix <writeonce@midipix.org>2016-11-19 19:16:54 -0500
commita2cf44f27c9ab9eaf84a7f59a8a1d74ebc2fa9c2 (patch)
treed3610ee058ff4da73c33c2faf9fbc36266386f54
parent94b22868dee3c023a836727d587d0e16a842a8d6 (diff)
downloadpemagine-a2cf44f27c9ab9eaf84a7f59a8a1d74ebc2fa9c2.tar.bz2
pemagine-a2cf44f27c9ab9eaf84a7f59a8a1d74ebc2fa9c2.tar.xz
pe_get_image_section_tbl_addr(): code maintenance.
-rw-r--r--src/headers/pe_get_image_section_tbl_addr.c11
1 files 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 <pemagine/pemagine.h>
#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