summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-12-13 10:51:31 -0500
committermidipix <writeonce@midipix.org>2017-12-13 11:24:14 -0500
commited06fbad97e24dea20e4240054f1cfeb15b15e92 (patch)
treea4c35a4c8beb782ebe56748e963066f62aa63eb5
parent068b8d92e7dbbda4dac003ef47d45b8beb4b5ad8 (diff)
downloadperk-ed06fbad97e24dea20e4240054f1cfeb15b15e92.tar.bz2
perk-ed06fbad97e24dea20e4240054f1cfeb15b15e92.tar.xz
refactor: struct pe_raw_image: members are now map-prefixed.
-rw-r--r--include/perk/perk.h4
-rw-r--r--src/logic/pe_get_image_meta.c14
-rw-r--r--src/logic/pe_map_raw_image.c8
-rw-r--r--src/output/pe_output_export_symbols.c2
-rw-r--r--src/output/pe_output_image_strings.c2
-rw-r--r--src/output/pe_output_image_symbols.c4
6 files changed, 17 insertions, 17 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index e7c8b21..ccf8d7e 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -65,8 +65,8 @@ enum pe_custom_error {
};
struct pe_raw_image {
- void * addr;
- size_t size;
+ void * map_addr;
+ size_t map_size;
};
struct pe_expsym {
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index c6d8f98..12a2658 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -119,10 +119,10 @@ int pe_get_expsym_by_name(
return -1;
offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
- symrva = (uint32_t *)((uintptr_t)m->r_image.addr + (m->m_edata.eh_name_ptr_rva - offset));
+ symrva = (uint32_t *)((uintptr_t)m->r_image.map_addr + (m->m_edata.eh_name_ptr_rva - offset));
for (i=0; i<m->m_edata.eh_num_of_name_ptrs; i++) {
- sym = (const char *)m->r_image.addr + symrva[i] - offset;
+ sym = (const char *)m->r_image.map_addr + symrva[i] - offset;
if (!(strcmp(sym,name))) {
if (expsym) {
@@ -156,8 +156,8 @@ int pe_get_expsym_by_index(
if (expsym) {
offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
- symrva = (uint32_t *)((uintptr_t)m->r_image.addr + (m->m_edata.eh_name_ptr_rva - offset));
- symaddr = (uintptr_t)m->r_image.addr + symrva[index] - offset;
+ symrva = (uint32_t *)((uintptr_t)m->r_image.map_addr + (m->m_edata.eh_name_ptr_rva - offset));
+ symaddr = (uintptr_t)m->r_image.map_addr + symrva[index] - offset;
expsym->name = (const char *)symaddr;
expsym->eaddr = 0;
@@ -181,7 +181,7 @@ int pe_get_image_meta(
struct pe_image_meta * m;
char * base;
- base = image->addr;
+ base = image->map_addr;
if (!(m = calloc(1,sizeof(*m))))
return PERK_SYSTEM_ERROR(dctx);
@@ -350,8 +350,8 @@ int pe_get_image_meta(
}
/* image */
- m->r_image.addr = image->addr;
- m->r_image.size = image->size;
+ m->r_image.map_addr = image->map_addr;
+ m->r_image.map_size = image->map_size;
/* all done */
*meta = m;
diff --git a/src/logic/pe_map_raw_image.c b/src/logic/pe_map_raw_image.c
index 1719e83..8334aa0 100644
--- a/src/logic/pe_map_raw_image.c
+++ b/src/logic/pe_map_raw_image.c
@@ -45,18 +45,18 @@ int pe_map_raw_image(
return PERK_CUSTOM_ERROR(
dctx,PERK_ERR_IMAGE_SIZE_ZERO);
- map->size = st.st_size;
- map->addr = mmap(0,map->size,prot,MAP_PRIVATE,fd,0);
+ map->map_size = st.st_size;
+ map->map_addr = mmap(0,map->map_size,prot,MAP_PRIVATE,fd,0);
if (fnew)
close(fd);
- return (map->addr == MAP_FAILED)
+ return (map->map_addr == MAP_FAILED)
? PERK_SYSTEM_ERROR(dctx)
: 0;
}
int pe_unmap_raw_image(struct pe_raw_image * map)
{
- return munmap(map->addr,map->size);
+ return munmap(map->map_addr,map->map_size);
}
diff --git a/src/output/pe_output_export_symbols.c b/src/output/pe_output_export_symbols.c
index 1ddef14..700822c 100644
--- a/src/output/pe_output_export_symbols.c
+++ b/src/output/pe_output_export_symbols.c
@@ -51,7 +51,7 @@ int pe_output_export_symbols(
if ((pretty_header(cctx,fout)) < 0)
return PERK_FILE_ERROR(dctx);
- mark = m->r_image.addr;
+ mark = m->r_image.map_addr;
offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
symrva = (uint32_t *)(mark + m->m_edata.eh_name_ptr_rva - offset);
diff --git a/src/output/pe_output_image_strings.c b/src/output/pe_output_image_strings.c
index 58fdeaa..51c7ef9 100644
--- a/src/output/pe_output_image_strings.c
+++ b/src/output/pe_output_image_strings.c
@@ -32,7 +32,7 @@ int pe_output_image_strings(
dash = "- ";
}
- mark = (char *)meta->r_image.addr;
+ mark = (char *)meta->r_image.map_addr;
mark += meta->m_coff.cfh_ptr_to_str_tbl;
cap = mark + meta->m_coff.cfh_size_of_str_tbl;
diff --git a/src/output/pe_output_image_symbols.c b/src/output/pe_output_image_symbols.c
index 7a71b27..6919e5a 100644
--- a/src/output/pe_output_image_symbols.c
+++ b/src/output/pe_output_image_symbols.c
@@ -33,13 +33,13 @@ int pe_output_image_symbols(
dash = "- ";
}
- mark = (char *)meta->r_image.addr;
+ mark = (char *)meta->r_image.map_addr;
symtbl = (struct pe_raw_coff_symbol *)(mark + meta->m_coff.cfh_ptr_to_sym_tbl);
for (i=0; i<meta->m_coff.cfh_num_of_syms; i++) {
pe_read_coff_symbol(
&symtbl[i],&symrec,
- &meta->m_coff,meta->r_image.addr);
+ &meta->m_coff,meta->r_image.map_addr);
if (fprintf(fout,"%s%s\n",
dash,