summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-14 22:45:44 -0500
committermidipix <writeonce@midipix.org>2016-11-14 22:58:52 -0500
commit6aec968c10e0d0c4509cf7d6930e3715175fae67 (patch)
treeb2827dff4dd55687c068e07b5c81a5e733856967 /src
parenta9703089dc298372a20c2ccbc9ad7639557ad1f6 (diff)
downloadperk-6aec968c10e0d0c4509cf7d6930e3715175fae67.tar.bz2
perk-6aec968c10e0d0c4509cf7d6930e3715175fae67.tar.xz
info api: pe_get_image_subtype(): initial implementation.
Diffstat (limited to 'src')
-rw-r--r--src/logic/pe_get_image_subtype.c35
1 files changed, 35 insertions, 0 deletions
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;
+}