summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-08-15 19:43:49 +0000
committermidipix <writeonce@midipix.org>2019-08-15 19:52:19 +0000
commitd6e02b8ff5da79d895197a3a1c4839e1047d6c57 (patch)
tree7dadfe592ed4d5cf1880768ab9a9fbedaf97a55d
parentef6791a9a90b6ac5e08b253dc3091bf322efda7d (diff)
downloadperk-d6e02b8ff5da79d895197a3a1c4839e1047d6c57.tar.bz2
perk-d6e02b8ff5da79d895197a3a1c4839e1047d6c57.tar.xz
perk.h: eliminate #include's of referential headers.
The primary purpose of this commit is to eliminate the pulling in of definitions not strictly needed by perk.h. In particular, perk.h does not require any of the PE constants to be defined, and only refers to the raw PE structs by pointer. The secondary purpose of this commit is to allow for inclusion of perk.h by software that already comes with its own set of PE const and struct definitions.
-rw-r--r--include/perk/perk.h13
-rw-r--r--src/hdrdump/pe_hdrdump_coff_image_hdr.c2
-rw-r--r--src/hdrdump/pe_hdrdump_coff_object_hdr.c2
-rw-r--r--src/hdrdump/pe_hdrdump_export_hdr.c2
-rw-r--r--src/hdrdump/pe_hdrdump_image_dos_hdr.c2
-rw-r--r--src/hdrdump/pe_hdrdump_import_tbl.c2
-rw-r--r--src/hdrdump/pe_hdrdump_opt_hdr.c2
-rw-r--r--src/hdrdump/pe_hdrdump_sec_tbl.c2
-rw-r--r--src/info/pe_get_image_abi.c1
-rw-r--r--src/info/pe_get_image_framework.c1
-rw-r--r--src/info/pe_get_image_subsystem.c1
-rw-r--r--src/info/pe_get_image_subtype.c1
-rw-r--r--src/internal/perk_hdrdump_impl.c2
-rw-r--r--src/logic/pe_get_image_meta.c2
-rw-r--r--src/output/pe_output_image_symbols.c1
-rw-r--r--src/output/pe_output_mdso_libraries.c1
-rw-r--r--src/reader/pe_read_coff_header.c2
-rw-r--r--src/reader/pe_read_coff_symbol.c2
-rw-r--r--src/reader/pe_read_dos_header.c2
-rw-r--r--src/reader/pe_read_export_header.c2
-rw-r--r--src/reader/pe_read_import_header.c2
-rw-r--r--src/reader/pe_read_optional_header.c2
-rw-r--r--src/reader/pe_read_section_header.c2
23 files changed, 49 insertions, 2 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index e8a4a18..4c444d8 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -5,8 +5,6 @@
#include <stdio.h>
#include "perk_api.h"
-#include "perk_consts.h"
-#include "perk_structs.h"
#include "perk_meta.h"
#ifdef __cplusplus
@@ -21,6 +19,7 @@ extern "C" {
#endif
#endif
+
/* status codes */
#define PERK_OK 0x00
#define PERK_USAGE 0x01
@@ -65,6 +64,16 @@ enum pe_custom_error {
PERK_ERR_CAP,
};
+struct pe_raw_image;
+struct pe_raw_image_dos_hdr;
+struct pe_raw_coff_image_hdr;
+struct pe_raw_coff_object_hdr;
+union pe_raw_opt_hdr;
+struct pe_raw_sec_hdr;
+struct pe_raw_export_hdr;
+struct pe_raw_import_hdr;
+struct pe_raw_coff_symbol;
+
struct pe_raw_image {
void * map_addr;
size_t map_size;
diff --git a/src/hdrdump/pe_hdrdump_coff_image_hdr.c b/src/hdrdump/pe_hdrdump_coff_image_hdr.c
index 04b47f7..d5c6e51 100644
--- a/src/hdrdump/pe_hdrdump_coff_image_hdr.c
+++ b/src/hdrdump/pe_hdrdump_coff_image_hdr.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_coff_object_hdr.c b/src/hdrdump/pe_hdrdump_coff_object_hdr.c
index ee3b870..b008456 100644
--- a/src/hdrdump/pe_hdrdump_coff_object_hdr.c
+++ b/src/hdrdump/pe_hdrdump_coff_object_hdr.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_export_hdr.c b/src/hdrdump/pe_hdrdump_export_hdr.c
index 4f96640..eae87f2 100644
--- a/src/hdrdump/pe_hdrdump_export_hdr.c
+++ b/src/hdrdump/pe_hdrdump_export_hdr.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_image_dos_hdr.c b/src/hdrdump/pe_hdrdump_image_dos_hdr.c
index b413565..5d6fe77 100644
--- a/src/hdrdump/pe_hdrdump_image_dos_hdr.c
+++ b/src/hdrdump/pe_hdrdump_image_dos_hdr.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_import_tbl.c b/src/hdrdump/pe_hdrdump_import_tbl.c
index 0a7f8d2..252352c 100644
--- a/src/hdrdump/pe_hdrdump_import_tbl.c
+++ b/src/hdrdump/pe_hdrdump_import_tbl.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_opt_hdr.c b/src/hdrdump/pe_hdrdump_opt_hdr.c
index 4df3315..566fd0f 100644
--- a/src/hdrdump/pe_hdrdump_opt_hdr.c
+++ b/src/hdrdump/pe_hdrdump_opt_hdr.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/hdrdump/pe_hdrdump_sec_tbl.c b/src/hdrdump/pe_hdrdump_sec_tbl.c
index 1254258..99e7f58 100644
--- a/src/hdrdump/pe_hdrdump_sec_tbl.c
+++ b/src/hdrdump/pe_hdrdump_sec_tbl.c
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_driver_impl.h"
#include "perk_hdrdump_impl.h"
diff --git a/src/info/pe_get_image_abi.c b/src/info/pe_get_image_abi.c
index f135fea..68feb8d 100644
--- a/src/info/pe_get_image_abi.c
+++ b/src/info/pe_get_image_abi.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
#include <perk/perk_meta.h>
static const char * const pe_abi_str[PE_ABI_CAP] = {
diff --git a/src/info/pe_get_image_framework.c b/src/info/pe_get_image_framework.c
index 84d2538..4154612 100644
--- a/src/info/pe_get_image_framework.c
+++ b/src/info/pe_get_image_framework.c
@@ -8,6 +8,7 @@
#include <stdbool.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
#include <perk/perk_meta.h>
static const char * const pe_framework_str[PE_FRAMEWORK_CAP] = {
diff --git a/src/info/pe_get_image_subsystem.c b/src/info/pe_get_image_subsystem.c
index bb7c9a3..9bd9ea8 100644
--- a/src/info/pe_get_image_subsystem.c
+++ b/src/info/pe_get_image_subsystem.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
#include <perk/perk_meta.h>
static const char * const pe_subsystem_str[0x10] = {
diff --git a/src/info/pe_get_image_subtype.c b/src/info/pe_get_image_subtype.c
index 94fd081..062535f 100644
--- a/src/info/pe_get_image_subtype.c
+++ b/src/info/pe_get_image_subtype.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
#include <perk/perk_meta.h>
/* todo: object, unrecognized */
diff --git a/src/internal/perk_hdrdump_impl.c b/src/internal/perk_hdrdump_impl.c
index eadd725..13ff786 100644
--- a/src/internal/perk_hdrdump_impl.c
+++ b/src/internal/perk_hdrdump_impl.c
@@ -8,6 +8,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_hdrdump_impl.h"
#define PE_TABWIDTH 8
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 1ab5eb8..3285ef4 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -13,6 +13,8 @@
#include <mdso/mdso_structs.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_reader_impl.h"
#include "perk_errinfo_impl.h"
diff --git a/src/output/pe_output_image_symbols.c b/src/output/pe_output_image_symbols.c
index b03ba8a..f1ec2e8 100644
--- a/src/output/pe_output_image_symbols.c
+++ b/src/output/pe_output_image_symbols.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_structs.h>
#include <perk/perk_output.h>
#include "perk_reader_impl.h"
#include "perk_driver_impl.h"
diff --git a/src/output/pe_output_mdso_libraries.c b/src/output/pe_output_mdso_libraries.c
index 9dda96b..86fa40c 100644
--- a/src/output/pe_output_mdso_libraries.c
+++ b/src/output/pe_output_mdso_libraries.c
@@ -14,6 +14,7 @@
#include <mdso/mdso_structs.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
#include <perk/perk_output.h>
#include "perk_reader_impl.h"
#include "perk_driver_impl.h"
diff --git a/src/reader/pe_read_coff_header.c b/src/reader/pe_read_coff_header.c
index d431191..e6b97f8 100644
--- a/src/reader/pe_read_coff_header.c
+++ b/src/reader/pe_read_coff_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_coff_symbol.c b/src/reader/pe_read_coff_symbol.c
index 0bb8897..3394a26 100644
--- a/src/reader/pe_read_coff_symbol.c
+++ b/src/reader/pe_read_coff_symbol.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_dos_header.c b/src/reader/pe_read_dos_header.c
index f9864be..ac5054b 100644
--- a/src/reader/pe_read_dos_header.c
+++ b/src/reader/pe_read_dos_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_export_header.c b/src/reader/pe_read_export_header.c
index bea1493..221c9cb 100644
--- a/src/reader/pe_read_export_header.c
+++ b/src/reader/pe_read_export_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_import_header.c b/src/reader/pe_read_import_header.c
index 08d1130..720b30a 100644
--- a/src/reader/pe_read_import_header.c
+++ b/src/reader/pe_read_import_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_optional_header.c b/src/reader/pe_read_optional_header.c
index feab0ab..ab6a7d5 100644
--- a/src/reader/pe_read_optional_header.c
+++ b/src/reader/pe_read_optional_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"
diff --git a/src/reader/pe_read_section_header.c b/src/reader/pe_read_section_header.c
index 3c90d7e..00bc034 100644
--- a/src/reader/pe_read_section_header.c
+++ b/src/reader/pe_read_section_header.c
@@ -7,6 +7,8 @@
#include <string.h>
#include <perk/perk.h>
+#include <perk/perk_consts.h>
+#include <perk/perk_structs.h>
#include "perk_endian_impl.h"
#include "perk_reader_impl.h"