summaryrefslogtreecommitdiffhomepage
path: root/src/internal/perk_hdrdump_impl.h
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-11-03 23:20:41 -0400
committermidipix <writeonce@midipix.org>2018-11-20 20:25:15 -0500
commitb73ae8503fd4afff6821e3bed84d408e1f8a3f0c (patch)
tree166c49bbdce0804e0e6469fe0e43a81c1df80e40 /src/internal/perk_hdrdump_impl.h
parentc13a6ba2bc291473d5e72d5a33bc9fb8cfc3ce2e (diff)
downloadperk-b73ae8503fd4afff6821e3bed84d408e1f8a3f0c.tar.bz2
perk-b73ae8503fd4afff6821e3bed84d408e1f8a3f0c.tar.xz
internals: added pe_output_hex_{header|footer}(), pe_output_raw_element().
Diffstat (limited to 'src/internal/perk_hdrdump_impl.h')
-rw-r--r--src/internal/perk_hdrdump_impl.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/internal/perk_hdrdump_impl.h b/src/internal/perk_hdrdump_impl.h
new file mode 100644
index 0000000..41528ad
--- /dev/null
+++ b/src/internal/perk_hdrdump_impl.h
@@ -0,0 +1,49 @@
+/***************************************************************/
+/* perk: PE Resource Kit */
+/* Copyright (C) 2015--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
+/***************************************************************/
+
+#ifndef PERK_HDRDUMP_IMPL_H
+#define PERK_HDRDUMP_IMPL_H
+
+#include <stddef.h>
+
+#define PE_QUOTE(s) #s
+#define PE_STRING(s) PE_QUOTE(s)
+#define PE_TYPE(t) struct pe_raw_ ## t
+#define PE_OFFSET(t,x) offsetof(PE_TYPE(t),x)
+#define PE_SIZE(p,x) sizeof((p)->x)
+
+#define PE_OUTPUT_RAW_ELEMENT_TABLE(ch,p,t,x) \
+ pe_output_raw_element( \
+ ch,p, \
+ PE_STRING(x), \
+ PE_OFFSET(t,x), \
+ PE_SIZE(p,x))
+
+#define PE_OUTPUT_TABLE(x) \
+ PE_OUTPUT_RAW_ELEMENT_TABLE( \
+ ch, \
+ PE_ADDR, \
+ PE_RAW_STRUCT, \
+ x)
+
+size_t pe_output_hex_header(
+ char * buf,
+ const char * sname,
+ uint64_t faddr,
+ uint64_t vaddr,
+ int bits);
+
+size_t pe_output_hex_footer(
+ char * buf);
+
+size_t pe_output_raw_element(
+ char * ch,
+ const void * rdata,
+ const char * mname,
+ uint32_t moffset,
+ uint32_t msize);
+
+#endif