diff options
author | midipix <writeonce@midipix.org> | 2018-11-11 22:31:47 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-11-20 20:25:15 -0500 |
commit | 71ed2fda0285acf148a38f443490435350df6b4e (patch) | |
tree | 55e629a0b4beba1f3dc794885127cb60a9698dd6 /src/hdrdump | |
parent | b73ae8503fd4afff6821e3bed84d408e1f8a3f0c (diff) | |
download | perk-71ed2fda0285acf148a38f443490435350df6b4e.tar.bz2 perk-71ed2fda0285acf148a38f443490435350df6b4e.tar.xz |
output: header dump: added pe_hdrdump_image_dos_hdr().
Diffstat (limited to 'src/hdrdump')
-rw-r--r-- | src/hdrdump/pe_hdrdump_image_dos_hdr.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/hdrdump/pe_hdrdump_image_dos_hdr.c b/src/hdrdump/pe_hdrdump_image_dos_hdr.c new file mode 100644 index 0000000..b413565 --- /dev/null +++ b/src/hdrdump/pe_hdrdump_image_dos_hdr.c @@ -0,0 +1,74 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2017 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include <stdio.h> + +#include <perk/perk.h> +#include <perk/perk_output.h> +#include "perk_driver_impl.h" +#include "perk_hdrdump_impl.h" +#include "perk_dprintf_impl.h" +#include "perk_errinfo_impl.h" + +#define PE_ADDR meta->r_dos +#define PE_RAW_STRUCT image_dos_hdr +#define PE_OUTPUT(x) PE_OUTPUT_TABLE(x) + +int pe_hdrdump_image_dos_hdr( + const struct pe_driver_ctx * dctx, + const struct pe_image_meta * meta) +{ + int bits; + uint64_t faddr; + uint64_t vaddr; + char * ch; + char buf[8192]; + + if (!PE_ADDR) + return 0; + + if ((bits = pe_image_bits(meta)) < 0) + return PERK_CUSTOM_ERROR( + dctx,PERK_ERR_UNSUPPORTED_ABI); + + faddr = 0; + vaddr = meta->m_opt.oh_mem.coh_image_base; + + ch = buf; + ch += pe_output_hex_header( + ch, + "struct pe_raw_image_dos_hdr", + faddr,vaddr,bits); + + ch += PE_OUTPUT(dos_magic); + ch += PE_OUTPUT(dos_cblp); + ch += PE_OUTPUT(dos_cp); + ch += PE_OUTPUT(dos_crlc); + ch += PE_OUTPUT(dos_cparhdr); + ch += PE_OUTPUT(dos_minalloc); + ch += PE_OUTPUT(dos_maxalloc); + ch += PE_OUTPUT(dos_ss); + ch += PE_OUTPUT(dos_sp); + ch += PE_OUTPUT(dos_csum); + ch += PE_OUTPUT(dos_ip); + ch += PE_OUTPUT(dos_cs); + ch += PE_OUTPUT(dos_lfarlc); + ch += PE_OUTPUT(dos_ovno); + ch += PE_OUTPUT(dos_res); + ch += PE_OUTPUT(dos_oemid); + ch += PE_OUTPUT(dos_oeminfo); + ch += PE_OUTPUT(dos_res2); + ch += PE_OUTPUT(dos_lfanew); + + ch += pe_output_hex_footer(ch); + + *ch = 0; + + if (pe_dprintf(pe_driver_fdout(dctx),"%s",buf) < 0) + return PERK_FILE_ERROR(dctx); + + return 0; +} |