diff options
author | midipix <writeonce@midipix.org> | 2024-04-14 15:27:39 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2024-04-14 15:27:39 +0000 |
commit | 78dcfd86c8c7d917cd81b0b042e308e73c274888 (patch) | |
tree | 0f78ee95792562a272dee90686492576cd3c686d /src/hdrdump | |
parent | d628c4a6278d098cfc65e92a7860b8083e072113 (diff) | |
download | perk-78dcfd86c8c7d917cd81b0b042e308e73c274888.tar.bz2 perk-78dcfd86c8c7d917cd81b0b042e308e73c274888.tar.xz |
pe_hdrdump_coff_opt_hdr(): refactor: avoid cast, properly support 32-bit hosts.
Diffstat (limited to 'src/hdrdump')
-rw-r--r-- | src/hdrdump/pe_hdrdump_coff_opt_hdr.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/hdrdump/pe_hdrdump_coff_opt_hdr.c b/src/hdrdump/pe_hdrdump_coff_opt_hdr.c index 959c9c8..fbec549 100644 --- a/src/hdrdump/pe_hdrdump_coff_opt_hdr.c +++ b/src/hdrdump/pe_hdrdump_coff_opt_hdr.c @@ -23,15 +23,19 @@ static int pe_hdrdump_opt_hdr_32( const struct pe_driver_ctx * dctx, const struct pe_image_meta * meta) { - uint64_t faddr; - uint64_t vaddr; + void * uaddr; + const char * haddr; + const char * maddr; + uintptr_t faddr; + uintptr_t vaddr; char * ch; char buf[8192]; - if (!PE_ADDR) - return 0; + uaddr = &meta->r_opt->opt_hdr_32; + maddr = meta->r_image.map_addr; - faddr = (char *)(PE_ADDR) - (char *)meta->r_image.map_addr; + haddr = uaddr; + faddr = haddr - maddr; vaddr = meta->m_opt.oh_mem.coh_image_base + faddr; ch = buf; @@ -109,15 +113,19 @@ static int pe_hdrdump_opt_hdr_64( const struct pe_driver_ctx * dctx, const struct pe_image_meta * meta) { - uint64_t faddr; - uint64_t vaddr; + void * uaddr; + const char * haddr; + const char * maddr; + uintptr_t faddr; + uintptr_t vaddr; char * ch; char buf[8192]; - if (!PE_ADDR) - return 0; + uaddr = PE_ADDR; + maddr = meta->r_image.map_addr; - faddr = (char *)(PE_ADDR) - (char *)meta->r_image.map_addr; + haddr = uaddr; + faddr = haddr - maddr; vaddr = meta->m_opt.oh_mem.coh_image_base + faddr; ch = buf; @@ -186,6 +194,9 @@ int pe_hdrdump_coff_opt_hdr( const struct pe_driver_ctx * dctx, const struct pe_image_meta * meta) { + if (!meta->r_opt) + return 0; + switch (pe_image_bits(meta)) { case 32: return pe_hdrdump_opt_hdr_32(dctx,meta); |