summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-11-14 23:09:50 -0500
committermidipix <writeonce@midipix.org>2016-11-14 23:31:16 -0500
commit8c7b6a92a909c0fa269439ce06335e7b60baa451 (patch)
tree2ed2d8010f5b674b30904321cf401a16c9a90260 /src/logic
parent919d9d87594df2511a4bf81cfb2d6ceccb4ebe33 (diff)
downloadperk-8c7b6a92a909c0fa269439ce06335e7b60baa451.tar.bz2
perk-8c7b6a92a909c0fa269439ce06335e7b60baa451.tar.xz
info api: pe_get_image_abi(): initial implementation.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/pe_get_image_abi.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/logic/pe_get_image_abi.c b/src/logic/pe_get_image_abi.c
new file mode 100644
index 0000000..7219ba3
--- /dev/null
+++ b/src/logic/pe_get_image_abi.c
@@ -0,0 +1,40 @@
+/***************************************************************/
+/* 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>
+
+static const char const * pe_abi_str[PE_ABI_CAP] = {
+ [PE_ABI_UNSUPPORTED] = "UNSUPPORTED",
+ [PE_ABI_PE32] = "PE32",
+ [PE_ABI_PE64] = "PE64",
+};
+
+int pe_get_image_abi(const struct pe_image_meta * m, struct pe_info_string * infostr)
+{
+ int abi;
+
+ switch (m->opt.std.magic) {
+ case PE_MAGIC_PE32:
+ abi = PE_ABI_PE32;
+ break;
+
+ case PE_MAGIC_PE32_PLUS:
+ abi = PE_ABI_PE64;
+ break;
+
+ default:
+ abi = PE_ABI_UNSUPPORTED;
+ break;
+ }
+
+ if (infostr)
+ strcpy(infostr->buffer,pe_abi_str[abi]);
+
+ return abi;
+}