summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-12-13 09:55:14 -0500
committermidipix <writeonce@midipix.org>2017-12-13 11:24:14 -0500
commit25e3c0b994fe1cb59ac601dacbded5a3ea953b6e (patch)
treef1cb1b576b90424156ce321d77ccca7d2859e83d
parent58ced9c919a0fae75e98c937ac55f8e30fc01c6f (diff)
downloadperk-25e3c0b994fe1cb59ac601dacbded5a3ea953b6e.tar.bz2
perk-25e3c0b994fe1cb59ac601dacbded5a3ea953b6e.tar.xz
refactor: struct pe_image_meta: meta section header members are now h-prefixed.
-rw-r--r--include/perk/perk.h4
-rw-r--r--src/logic/pe_get_image_meta.c26
-rw-r--r--src/output/pe_output_export_symbols.c4
3 files changed, 17 insertions, 17 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index b207390..e1b0dc9 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -99,8 +99,8 @@ struct pe_image_meta {
struct pe_meta_export_hdr m_edata;
struct pe_meta_import_hdr * m_idata;
- struct pe_meta_sec_hdr * hedata;
- struct pe_meta_sec_hdr * hidata;
+ struct pe_meta_sec_hdr * h_edata;
+ struct pe_meta_sec_hdr * h_idata;
struct pe_raw_image image;
struct pe_raw_image_dos_hdr * ados;
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 0bfc393..7a6d952 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -115,10 +115,10 @@ int pe_get_expsym_by_name(
const char * sym;
unsigned i;
- if (m->aobj || !m->hedata)
+ if (m->aobj || !m->h_edata)
return -1;
- offset = m->hedata->sh_virtual_addr - m->hedata->sh_ptr_to_raw_data;
+ offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
symrva = (uint32_t *)((uintptr_t)m->image.addr + (m->m_edata.eh_name_ptr_rva - offset));
for (i=0; i<m->m_edata.eh_num_of_name_ptrs; i++) {
@@ -155,7 +155,7 @@ int pe_get_expsym_by_index(
return -1;
if (expsym) {
- offset = m->hedata->sh_virtual_addr - m->hedata->sh_ptr_to_raw_data;
+ offset = m->h_edata->sh_virtual_addr - m->h_edata->sh_ptr_to_raw_data;
symrva = (uint32_t *)((uintptr_t)m->image.addr + (m->m_edata.eh_name_ptr_rva - offset));
symaddr = (uintptr_t)m->image.addr + symrva[index] - offset;
@@ -249,11 +249,11 @@ int pe_get_image_meta(
m,PERK_CUSTOM_ERROR(dctx,PERK_ERR_IMAGE_MALFORMED));
if (s >= 0) {
- m->hedata = &m->m_sectbl[s];
+ m->h_edata = &m->m_sectbl[s];
m->aedata = (struct pe_raw_export_hdr *)(base + m->m_sectbl[s].sh_ptr_to_raw_data
+ m->m_opt.oh_dirs.coh_export_tbl.dh_rva - m->m_sectbl[s].sh_virtual_addr);
} else if (i >= 0) {
- m->hedata = &m->m_sectbl[i];
+ m->h_edata = &m->m_sectbl[i];
m->aedata = (struct pe_raw_export_hdr *)(base + m->m_sectbl[i].sh_ptr_to_raw_data);
}
@@ -274,11 +274,11 @@ int pe_get_image_meta(
m,PERK_CUSTOM_ERROR(dctx,PERK_ERR_IMAGE_MALFORMED));
if (s >= 0) {
- m->hidata = &m->m_sectbl[s];
+ m->h_idata = &m->m_sectbl[s];
m->aidata = (struct pe_raw_import_hdr *)(base + m->m_sectbl[s].sh_ptr_to_raw_data
+ m->m_opt.oh_dirs.coh_import_tbl.dh_rva - m->m_sectbl[s].sh_virtual_addr);
} else if (i >= 0) {
- m->hidata = &m->m_sectbl[i];
+ m->h_idata = &m->m_sectbl[i];
m->aidata = (struct pe_raw_import_hdr *)(base + m->m_sectbl[i].sh_ptr_to_raw_data);
}
@@ -295,14 +295,14 @@ int pe_get_image_meta(
for (i=0; i<m->m_stats.nimplibs; i++) {
pe_read_import_header(&m->aidata[i],&m->m_idata[i]);
- m->m_idata[i].ih_name = base + m->hidata->sh_ptr_to_raw_data
+ m->m_idata[i].ih_name = base + m->h_idata->sh_ptr_to_raw_data
+ m->m_idata[i].ih_name_rva
- - m->hidata->sh_virtual_addr;
+ - m->h_idata->sh_virtual_addr;
if (m->m_idata[i].ih_import_lookup_tbl_rva)
- m->m_idata[i].ih_aitems = (union pe_raw_import_lookup *)(base + m->hidata->sh_ptr_to_raw_data
+ m->m_idata[i].ih_aitems = (union pe_raw_import_lookup *)(base + m->h_idata->sh_ptr_to_raw_data
+ m->m_idata[i].ih_import_lookup_tbl_rva
- - m->hidata->sh_virtual_addr);
+ - m->h_idata->sh_virtual_addr);
/* items */
uint32_t * hint;
@@ -340,8 +340,8 @@ int pe_get_image_meta(
if (!m->m_idata[i].ih_items[j].ii_flags) {
struct pe_raw_hint_name_entry * pentry =
- (struct pe_raw_hint_name_entry *)(base + m->hidata->sh_ptr_to_raw_data
- + m->m_idata[i].ih_items[j].u.ii_hint_name_tbl_rva - m->hidata->sh_virtual_addr);
+ (struct pe_raw_hint_name_entry *)(base + m->h_idata->sh_ptr_to_raw_data
+ + m->m_idata[i].ih_items[j].u.ii_hint_name_tbl_rva - m->h_idata->sh_virtual_addr);
m->m_idata[i].ih_items[j].ii_name = (char *)pentry->ii_name;
}
diff --git a/src/output/pe_output_export_symbols.c b/src/output/pe_output_export_symbols.c
index 46ed9f9..c8a6de3 100644
--- a/src/output/pe_output_export_symbols.c
+++ b/src/output/pe_output_export_symbols.c
@@ -42,7 +42,7 @@ int pe_output_export_symbols(
unsigned i;
const struct pe_common_ctx * cctx = dctx->cctx;
- if (!m->hedata)
+ if (!m->h_edata)
return 0;
if (!fout)
@@ -52,7 +52,7 @@ int pe_output_export_symbols(
return PERK_FILE_ERROR(dctx);
mark = m->image.addr;
- offset = m->hedata->sh_virtual_addr - m->hedata->sh_ptr_to_raw_data;
+ 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);
for (i=0; i<m->m_edata.eh_num_of_name_ptrs; i++)