summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/perk/perk.h1
-rw-r--r--include/perk/perk_meta.h8
-rw-r--r--project/common.mk1
-rw-r--r--src/logic/pe_get_image_subtype.c35
4 files changed, 45 insertions, 0 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index af63b33..895e4a8 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -193,6 +193,7 @@ perk_api int pe_get_expsym_by_name (const struct pe_image_meta *, const char *
perk_api int pe_get_expsym_by_index (const struct pe_image_meta *, unsigned index, struct pe_expsym * optional);
/* info api */
+perk_api int pe_get_image_subtype (const struct pe_image_meta *, struct pe_info_string * optional);
perk_api int pe_get_image_subsystem (const struct pe_image_meta *, struct pe_info_string * optional);
perk_api int pe_get_image_framework (const struct pe_image_meta *, struct pe_info_string * optional);
diff --git a/include/perk/perk_meta.h b/include/perk/perk_meta.h
index fc8c268..d39e652 100644
--- a/include/perk/perk_meta.h
+++ b/include/perk/perk_meta.h
@@ -7,6 +7,14 @@ extern "C" {
#include <stdint.h>
+enum pe_subtype {
+ PE_SUBTYPE_UNRECOGNIZED,
+ PE_SUBTYPE_DLL,
+ PE_SUBTYPE_EXE,
+ PE_SUBTYPE_OBJ,
+ PE_SUBTYPE_CAP
+};
+
enum pe_framework {
PE_FRAMEWORK_UNKNOWN,
PE_FRAMEWORK_FREESTD,
diff --git a/project/common.mk b/project/common.mk
index acb07d8..10ae48d 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -5,6 +5,7 @@ API_SRCS = \
src/logic/pe_get_image_framework.c \
src/logic/pe_get_image_meta.c \
src/logic/pe_get_image_subsystem.c \
+ src/logic/pe_get_image_subtype.c \
src/logic/pe_map_raw_image.c \
src/output/pe_output_error.c \
src/output/pe_output_export_symbols.c \
diff --git a/src/logic/pe_get_image_subtype.c b/src/logic/pe_get_image_subtype.c
new file mode 100644
index 0000000..7e19ef1
--- /dev/null
+++ b/src/logic/pe_get_image_subtype.c
@@ -0,0 +1,35 @@
+/***************************************************************/
+/* perk: PE Resource Kit */
+/* Copyright (C) 2015--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
+/***************************************************************/
+
+#include <string.h>
+
+#include <perk/perk.h>
+#include <perk/perk_meta.h>
+
+/* todo: object, unrecognized */
+
+static const char const * pe_subtype_str[PE_SUBTYPE_CAP] = {
+ [PE_SUBTYPE_UNRECOGNIZED] = "UNRECOGNIZED",
+ [PE_SUBTYPE_DLL] = "dll",
+ [PE_SUBTYPE_EXE] = "exe",
+ [PE_SUBTYPE_OBJ] = "obj",
+};
+
+int pe_get_image_subtype(const struct pe_image_meta * m, struct pe_info_string * infostr)
+{
+ int subtype;
+
+ if (m->coff.characteristics & PE_IMAGE_FILE_DLL)
+ subtype = PE_SUBTYPE_DLL;
+
+ else
+ subtype = PE_SUBTYPE_EXE;
+
+ if (infostr)
+ strcpy(infostr->buffer,pe_subtype_str[subtype]);
+
+ return subtype;
+}