summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-12 22:23:08 -0500
committermidipix <writeonce@midipix.org>2016-11-12 22:23:08 -0500
commitc7ca52f4ec6005315ac2a2374f4f05fb1ae62ad2 (patch)
tree0a47b264a987c41620f76fb8d71823e20bbaa274 /src/logic
parenta5cc53c9e31a213da5ef8779ebca4de034e3b96f (diff)
downloadperk-c7ca52f4ec6005315ac2a2374f4f05fb1ae62ad2.tar.bz2
perk-c7ca52f4ec6005315ac2a2374f4f05fb1ae62ad2.tar.xz
logic: added pe_get_expsym_by_name(), pe_get_expsym_by_index().
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/pe_get_image_meta.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 6302f70..b4b21d3 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -59,6 +59,46 @@ int pe_get_block_section_index(const struct pe_image_meta * m, const struct pe_b
return -1;
}
+const char * pe_get_expsym_by_name(
+ const struct pe_image_meta * m,
+ const char * name)
+{
+ uint32_t offset;
+ uint32_t * symrva;
+ const char * sym;
+ unsigned i;
+
+ offset = m->hedata->virtual_addr - m->hedata->ptr_to_raw_data;
+ symrva = (uint32_t *)((uintptr_t)m->image.addr + (m->edata.name_ptr_rva - offset));
+
+ for (i=0; i<m->edata.num_of_name_ptrs; i++) {
+ sym = (const char *)m->image.addr + symrva[i] - offset;
+
+ if (!(strcmp(sym,name)))
+ return sym;
+ }
+
+ return 0;
+}
+
+const char * pe_get_expsym_by_index(
+ const struct pe_image_meta * m,
+ unsigned index)
+{
+ uint32_t offset;
+ uint32_t * symrva;
+ uintptr_t addr;
+
+ if (index >= m->edata.num_of_name_ptrs)
+ return 0;
+
+ offset = m->hedata->virtual_addr - m->hedata->ptr_to_raw_data;
+ symrva = (uint32_t *)((uintptr_t)m->image.addr + (m->edata.name_ptr_rva - offset));
+ addr = (uintptr_t)m->image.addr + symrva[index] - offset;
+
+ return (const char *)addr;
+}
+
int pe_get_image_meta(
const struct pe_driver_ctx * dctx,
const struct pe_raw_image * image,