summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-10-31 12:23:37 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:24 -0500
commit82a0a1649830c8faad13dffcb4c5450f70af50d9 (patch)
treecd2f4392f589cbe74ddc2dac81723206fc4a5f26
parent92cfcee08e475c14d9143a2f0af33720940457ee (diff)
downloadperk-82a0a1649830c8faad13dffcb4c5450f70af50d9.tar.bz2
perk-82a0a1649830c8faad13dffcb4c5450f70af50d9.tar.xz
account for import directory entries with no referenced symbols.
-rw-r--r--src/main/pe_get_image_meta.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/pe_get_image_meta.c b/src/main/pe_get_image_meta.c
index 47ea8fd..350abe3 100644
--- a/src/main/pe_get_image_meta.c
+++ b/src/main/pe_get_image_meta.c
@@ -137,8 +137,9 @@ int pe_get_image_meta (const struct pe_raw_image * image, struct pe_image_meta *
m->idata[i].name = base + m->hidata->ptr_to_raw_data
+ m->idata[i].name_rva - m->hidata->virtual_addr;
- m->idata[i].aitems = (struct pe_import_lookup_item *)(base + m->hidata->ptr_to_raw_data
- + m->idata[i].import_lookup_tbl_rva - m->hidata->virtual_addr);
+ if (m->idata[i].import_lookup_tbl_rva)
+ m->idata[i].aitems = (struct pe_import_lookup_item *)(base + m->hidata->ptr_to_raw_data
+ + m->idata[i].import_lookup_tbl_rva - m->hidata->virtual_addr);
#ifdef PERK_DEVEL
printf("%s\n",m->idata[i].name);
@@ -146,11 +147,13 @@ int pe_get_image_meta (const struct pe_raw_image * image, struct pe_image_meta *
/* items */
m->idata[i].count = 0;
- for (pitem=m->idata[i].aitems; *(uint32_t *)pitem->u.hint_name_tbl_rva; pitem++)
- m->idata[i].count++;
+ if (m->idata[i].import_lookup_tbl_rva) {
+ for (pitem=m->idata[i].aitems; *(uint32_t *)pitem->u.hint_name_tbl_rva; pitem++)
+ m->idata[i].count++;
- if (!(m->idata[i].items = calloc(m->idata[i].count,sizeof(*(m->idata[i].items)))))
- return pe_free_image_meta_impl(m,status);
+ if (!(m->idata[i].items = calloc(m->idata[i].count,sizeof(*(m->idata[i].items)))))
+ return pe_free_image_meta_impl(m,status);
+ }
for (j=0; j<m->idata[i].count; j++) {
if ((status = pe_read_import_lookup_item(