diff --git a/include/perk/perk_meta.h b/include/perk/perk_meta.h index 55d5fc4..b743196 100644 --- a/include/perk/perk_meta.h +++ b/include/perk/perk_meta.h @@ -236,15 +236,15 @@ struct pe_meta_import_lookup { /* image: import directory table entry */ struct pe_meta_import_hdr { - uint32_t import_lookup_tbl_rva; - uint32_t time_date_stamp; - uint32_t forwarder_chain; - uint32_t name_rva; - uint32_t import_addr_tbl_rva; - uint32_t count; - char * name; - struct pe_meta_import_lookup * items; - union pe_raw_import_lookup * aitems; + uint32_t ih_import_lookup_tbl_rva; + uint32_t ih_time_date_stamp; + uint32_t ih_forwarder_chain; + uint32_t ih_name_rva; + uint32_t ih_import_addr_tbl_rva; + uint32_t ih_count; + char * ih_name; + struct pe_meta_import_lookup * ih_items; + union pe_raw_import_lookup * ih_aitems; }; diff --git a/include/perk/perk_structs.h b/include/perk/perk_structs.h index deb3adb..8835b87 100644 --- a/include/perk/perk_structs.h +++ b/include/perk/perk_structs.h @@ -273,11 +273,11 @@ union pe_raw_import_lookup { struct pe_raw_import_hdr { - unsigned char import_lookup_tbl_rva [0x04]; /* 0x00 */ - unsigned char time_date_stamp [0x04]; /* 0x04 */ - unsigned char forwarder_chain [0x04]; /* 0x08 */ - unsigned char name_rva [0x04]; /* 0x0c */ - unsigned char import_addr_tbl_rva [0x04]; /* 0x10 */ + unsigned char ih_import_lookup_tbl_rva [0x04]; /* 0x00 */ + unsigned char ih_time_date_stamp [0x04]; /* 0x04 */ + unsigned char ih_forwarder_chain [0x04]; /* 0x08 */ + unsigned char ih_name_rva [0x04]; /* 0x0c */ + unsigned char ih_import_addr_tbl_rva [0x04]; /* 0x10 */ }; diff --git a/src/info/pe_get_image_framework.c b/src/info/pe_get_image_framework.c index fd90a50..2267817 100644 --- a/src/info/pe_get_image_framework.c +++ b/src/info/pe_get_image_framework.c @@ -36,7 +36,7 @@ static bool pe_image_is_cygwin(const struct pe_image_meta * m) int i; for (i=0; isummary.nimplibs; i++) - if (!(strcmp(m->idata[i].name,"cygwin1.dll"))) + if (!(strcmp(m->idata[i].ih_name,"cygwin1.dll"))) return true; return false; @@ -47,7 +47,7 @@ static bool pe_image_is_msys(const struct pe_image_meta * m) int i; for (i=0; isummary.nimplibs; i++) - if (!(strcmp(m->idata[i].name,"msys-2.0.dll"))) + if (!(strcmp(m->idata[i].ih_name,"msys-2.0.dll"))) return true; return false; diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c index 7e0bbf2..ac3f114 100644 --- a/src/logic/pe_get_image_meta.c +++ b/src/logic/pe_get_image_meta.c @@ -19,7 +19,7 @@ static int pe_free_image_meta_impl(struct pe_image_meta * meta, int ret) if (meta) { for (i=0; isummary.nimplibs; i++) - free(meta->idata[i].items); + free(meta->idata[i].ih_items); free(meta->idata); free(meta->sectbl); @@ -263,7 +263,7 @@ int pe_get_image_meta( if (m->aidata) { /* num of implibs */ - for (pidata=m->aidata; pidata->name_rva[0]; pidata++) + for (pidata=m->aidata; pidata->ih_name_rva[0]; pidata++) m->summary.nimplibs++; /* import headers */ @@ -274,53 +274,55 @@ int pe_get_image_meta( for (i=0; isummary.nimplibs; i++) { pe_read_import_header(&m->aidata[i],&m->idata[i]); - m->idata[i].name = base + m->hidata->sh_ptr_to_raw_data - + m->idata[i].name_rva - m->hidata->sh_virtual_addr; + m->idata[i].ih_name = base + m->hidata->sh_ptr_to_raw_data + + m->idata[i].ih_name_rva + - m->hidata->sh_virtual_addr; - if (m->idata[i].import_lookup_tbl_rva) - m->idata[i].aitems = (union pe_raw_import_lookup *)(base + m->hidata->sh_ptr_to_raw_data - + m->idata[i].import_lookup_tbl_rva - m->hidata->sh_virtual_addr); + if (m->idata[i].ih_import_lookup_tbl_rva) + m->idata[i].ih_aitems = (union pe_raw_import_lookup *)(base + m->hidata->sh_ptr_to_raw_data + + m->idata[i].ih_import_lookup_tbl_rva + - m->hidata->sh_virtual_addr); /* items */ uint32_t * hint; - m->idata[i].count = 0; + m->idata[i].ih_count = 0; - if (m->idata[i].import_lookup_tbl_rva) { - pitem = m->idata[i].aitems; + if (m->idata[i].ih_import_lookup_tbl_rva) { + pitem = m->idata[i].ih_aitems; hint = (uint32_t *)pitem->ii_hint_name_tbl_rva; for (; *hint; hint=(uint32_t *)((++pitem)->ii_hint_name_tbl_rva)) - m->idata[i].count++; + m->idata[i].ih_count++; - if (!(m->idata[i].items = calloc(m->idata[i].count,sizeof(*(m->idata[i].items))))) + if (!(m->idata[i].ih_items = calloc(m->idata[i].ih_count,sizeof(*(m->idata[i].ih_items))))) return pe_free_image_meta_impl( m,PERK_SYSTEM_ERROR(dctx)); } - for (j=0; jidata[i].count; j++) { + for (j=0; jidata[i].ih_count; j++) { if ((ret = pe_read_import_lookup( - &(m->idata[i].aitems[j]), - &(m->idata[i].items[j]), + &(m->idata[i].ih_aitems[j]), + &(m->idata[i].ih_items[j]), m->opt.oh_std.coh_magic))) return pe_free_image_meta_impl( m,PERK_CUSTOM_ERROR(dctx,ret)); switch (m->opt.oh_std.coh_magic) { case PE_MAGIC_PE32: - m->idata[i].items[j].ii_flags = m->idata[i].items[j].u.ii_import_lookup_entry_32; + m->idata[i].ih_items[j].ii_flags = m->idata[i].ih_items[j].u.ii_import_lookup_entry_32; break; case PE_MAGIC_PE32_PLUS: - m->idata[i].items[j].ii_flags = (m->idata[i].items[j].u.ii_import_lookup_entry_64 >> 32); + m->idata[i].ih_items[j].ii_flags = (m->idata[i].ih_items[j].u.ii_import_lookup_entry_64 >> 32); break; } - if (!m->idata[i].items[j].ii_flags) { + if (!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->idata[i].items[j].u.ii_hint_name_tbl_rva - m->hidata->sh_virtual_addr); + + m->idata[i].ih_items[j].u.ii_hint_name_tbl_rva - m->hidata->sh_virtual_addr); - m->idata[i].items[j].ii_name = (char *)pentry->name; + m->idata[i].ih_items[j].ii_name = (char *)pentry->name; } } } diff --git a/src/output/pe_output_import_libraries.c b/src/output/pe_output_import_libraries.c index cf96005..b308a75 100644 --- a/src/output/pe_output_import_libraries.c +++ b/src/output/pe_output_import_libraries.c @@ -60,15 +60,15 @@ int pe_output_import_libraries( return PERK_FILE_ERROR(dctx); for (i=0; isummary.nimplibs; i++) { - if ((pretty_implib_header(cctx,m->idata[i].name,fout)) < 0) + if ((pretty_implib_header(cctx,m->idata[i].ih_name,fout)) < 0) return PERK_FILE_ERROR(dctx); if (cctx->fmtflags & PERK_OUTPUT_IMPORT_SYMS) - for (j=0; jidata[i].count; j++) - if (m->idata[i].items[j].ii_name) + for (j=0; jidata[i].ih_count; j++) + if (m->idata[i].ih_items[j].ii_name) if ((pretty_implib_item( cctx, - m->idata[i].items[j].ii_name, + m->idata[i].ih_items[j].ii_name, fout)) < 0) return PERK_FILE_ERROR(dctx); } diff --git a/src/reader/pe_read_import_header.c b/src/reader/pe_read_import_header.c index ef2a4f1..3689bc4 100644 --- a/src/reader/pe_read_import_header.c +++ b/src/reader/pe_read_import_header.c @@ -12,14 +12,14 @@ int pe_read_import_header(const struct pe_raw_import_hdr * p, struct pe_meta_import_hdr * m) { - m->import_lookup_tbl_rva = pe_read_long(p->import_lookup_tbl_rva); - m->time_date_stamp = pe_read_long(p->time_date_stamp); - m->forwarder_chain = pe_read_long(p->forwarder_chain); - m->name_rva = pe_read_long(p->name_rva); - m->import_addr_tbl_rva = pe_read_long(p->import_addr_tbl_rva); - - m->name = 0; - m->aitems = 0; + m->ih_import_lookup_tbl_rva = pe_read_long(p->ih_import_lookup_tbl_rva); + m->ih_time_date_stamp = pe_read_long(p->ih_time_date_stamp); + m->ih_forwarder_chain = pe_read_long(p->ih_forwarder_chain); + m->ih_name_rva = pe_read_long(p->ih_name_rva); + m->ih_import_addr_tbl_rva = pe_read_long(p->ih_import_addr_tbl_rva); + + m->ih_name = 0; + m->ih_aitems = 0; return 0; }