summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/perk/perk_meta.h2
-rw-r--r--src/logic/pe_get_image_meta.c19
2 files changed, 19 insertions, 2 deletions
diff --git a/include/perk/perk_meta.h b/include/perk/perk_meta.h
index f20c6ac..882bd86 100644
--- a/include/perk/perk_meta.h
+++ b/include/perk/perk_meta.h
@@ -79,6 +79,8 @@ struct pe_meta_coff_file_hdr {
uint32_t num_of_syms;
uint16_t size_of_opt_hdr;
uint16_t characteristics;
+ uint32_t ptr_to_string_tbl;
+ uint32_t size_of_string_tbl;
};
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 5f31a9a..9fcd157 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -165,7 +165,9 @@ int pe_get_image_meta(
struct pe_image_meta ** meta)
{
int i,s,status;
+ long l;
unsigned j;
+ unsigned char * mark;
struct pe_image_meta * m;
char * base = image->addr;
@@ -184,7 +186,14 @@ int pe_get_image_meta(
return pe_free_image_meta_impl(m,
PERK_CUSTOM_ERROR(dctx,status));
- m->aopt = (union pe_opt_hdr *)((char *)m->acoff + sizeof(m->coff));
+ mark = image->addr + m->coff.ptr_to_sym_tbl;
+ mark += m->coff.num_of_syms * sizeof(struct pe_coff_sym_entry);
+
+ m->coff.ptr_to_string_tbl = m->coff.ptr_to_sym_tbl;
+ m->coff.ptr_to_string_tbl += m->coff.num_of_syms * sizeof(struct pe_coff_sym_entry);
+ m->coff.size_of_string_tbl = pe_read_long(mark);
+
+ m->aopt = (union pe_opt_hdr *)((char *)m->acoff + sizeof(*m->acoff));
if ((status = (pe_read_optional_header(m->aopt,&m->opt))))
return pe_free_image_meta_impl(m,
@@ -196,9 +205,15 @@ int pe_get_image_meta(
return pe_free_image_meta_impl(m,
PERK_SYSTEM_ERROR(dctx));
- for (i=0; i<m->coff.num_of_sections; i++)
+ for (i=0; i<m->coff.num_of_sections; i++) {
pe_read_section_header(&m->asectbl[i],&m->sectbl[i]);
+ if (m->sectbl[i].name[0] == '/')
+ if ((l = strtol(&m->sectbl[i].name[1],0,10)) > 0)
+ if (l < m->coff.size_of_string_tbl)
+ m->sectbl[i].long_name = base + m->coff.ptr_to_string_tbl + l;
+ }
+
/* .edata */
i = pe_get_named_section_index(m,".edata");
s = pe_get_block_section_index(m,&m->opt.dirs.export_tbl);