summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-11-17 22:05:06 -0500
committermidipix <writeonce@midipix.org>2018-11-20 20:25:17 -0500
commit0a52ca80ff2bdaae33fb7e3774956af5ee5adb1a (patch)
tree8add219a4e29a3ded79bd89ecb631c02560d71b2
parent4b8f0434515ec0ad9f24347e1da08fa092f12e37 (diff)
downloadperk-0a52ca80ff2bdaae33fb7e3774956af5ee5adb1a.tar.bz2
perk-0a52ca80ff2bdaae33fb7e3774956af5ee5adb1a.tar.xz
output: header dump: pe_hdrdump_import_tbl(): output the import library name.
-rw-r--r--src/hdrdump/pe_hdrdump_import_tbl.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/hdrdump/pe_hdrdump_import_tbl.c b/src/hdrdump/pe_hdrdump_import_tbl.c
index a6d872e..0a7f8d2 100644
--- a/src/hdrdump/pe_hdrdump_import_tbl.c
+++ b/src/hdrdump/pe_hdrdump_import_tbl.c
@@ -20,7 +20,7 @@
static int pe_hdrdump_import_hdr_impl(
const struct pe_driver_ctx * dctx,
const struct pe_image_meta * meta,
- uint32_t idx)
+ int32_t idx)
{
int bits;
uint64_t faddr;
@@ -33,6 +33,7 @@ static int pe_hdrdump_import_hdr_impl(
return PERK_CUSTOM_ERROR(
dctx,PERK_ERR_UNSUPPORTED_ABI);
+ /* import header */
sprintf(
hdr,
"struct pe_raw_import_hdr [%d]",
@@ -54,8 +55,35 @@ static int pe_hdrdump_import_hdr_impl(
ch += pe_output_hex_footer(ch);
+ /* import name for all but the null header */
+ if (idx == meta->m_stats.t_nimplibs) {
+ (void)0;
+
+ } else if (meta->m_idata[idx].ih_name_rva) {
+ sprintf(
+ hdr,
+ "struct pe_raw_import_name [%d]",
+ idx);
+
+ faddr = meta->m_idata[idx].ih_name - (char *)meta->r_image.map_addr;
+ vaddr = meta->m_idata[idx].ih_name_rva;
+
+ ch += pe_output_hex_header(
+ ch,hdr,
+ faddr,vaddr,bits);
+
+ ch += pe_output_raw_element(
+ ch,
+ meta->m_idata[idx].ih_name,
+ "ih_name",0,
+ strlen(meta->m_idata[idx].ih_name) + 1);
+
+ ch += pe_output_hex_footer(ch);
+ }
+
*ch = 0;
+ /* fdout */
if (pe_dprintf(pe_driver_fdout(dctx),"%s",buf) < 0)
return PERK_FILE_ERROR(dctx);
@@ -68,7 +96,7 @@ int pe_hdrdump_import_tbl(
{
int idx;
- for (idx=0; idx<meta->m_stats.t_nimplibs; idx++)
+ for (idx=0; idx<=meta->m_stats.t_nimplibs; idx++)
if (pe_hdrdump_import_hdr_impl(dctx,meta,idx) < 0)
return PERK_NESTED_ERROR(dctx);