summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/headers/pe_get_image_section_tbl_addr.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/headers/pe_get_image_section_tbl_addr.c b/src/headers/pe_get_image_section_tbl_addr.c
index 49b2957..0aac29a 100644
--- a/src/headers/pe_get_image_section_tbl_addr.c
+++ b/src/headers/pe_get_image_section_tbl_addr.c
@@ -30,28 +30,34 @@ struct pe_raw_sec_hdr * pe_get_image_section_tbl_addr(const void * base)
return (struct pe_raw_sec_hdr *)mark;
}
-pe_api
-struct pe_raw_sec_hdr * pe_get_image_named_section_addr (const void * base, const char * name)
+
+struct pe_raw_sec_hdr * pe_get_image_named_section_addr(const void * base, const char * name)
{
- uint16_t count;
- struct pe_raw_sec_hdr * hdr;
- struct pe_raw_coff_file_hdr*coff;
- char * ch;
- uint32_t len;
- uint32_t pos;
- uint64_t sname = 0;
+ uint16_t count;
+ struct pe_raw_sec_hdr * hdr;
+ struct pe_raw_coff_file_hdr * coff;
+ char * ch;
+ uint32_t len;
+ uint32_t pos;
+ uint64_t sname;
if (!(hdr = pe_get_image_section_tbl_addr(base)))
return 0;
- coff = pe_get_image_coff_hdr_addr(base);
- count = *(uint16_t *)coff->num_of_sections;
+ if (!(coff = pe_get_image_coff_hdr_addr(base)))
+ return 0;
+
+ count = coff->num_of_sections[1] << 8;
+ count += coff->num_of_sections[0];
if ((len = pe_impl_strlen_ansi(name)) > 8) {
/* todo: long name support */
return 0;
} else {
- for (pos=0, ch=(char *)&sname; pos<len; pos++)
+ sname = 0;
+ ch = (char *)&sname;
+
+ for (pos=0; pos<len; pos++)
ch[pos] = name[pos];
for (; count; hdr++,count--)