summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-11-02 21:39:26 -0500
committermidipix <writeonce@midipix.org>2018-11-20 20:25:14 -0500
commitaec459048d46959149a4ca11756fc11992c3ca7f (patch)
tree4daaaa304374ac857e33c339cd1f3a8a6e878a98
parent1808909e9661994eee2471126c15d9e2365ad117 (diff)
downloadperk-aec459048d46959149a4ca11756fc11992c3ca7f.tar.bz2
perk-aec459048d46959149a4ca11756fc11992c3ca7f.tar.xz
pe_get_image_meta(), pe_get_image_subtype(): init/use the .m_subtype member.
-rw-r--r--src/info/pe_get_image_subtype.c10
-rw-r--r--src/logic/pe_get_image_meta.c17
2 files changed, 19 insertions, 8 deletions
diff --git a/src/info/pe_get_image_subtype.c b/src/info/pe_get_image_subtype.c
index 69b6569..94fd081 100644
--- a/src/info/pe_get_image_subtype.c
+++ b/src/info/pe_get_image_subtype.c
@@ -22,14 +22,8 @@ int pe_get_image_subtype(const struct pe_image_meta * m, struct pe_info_string *
{
int subtype;
- if (m->r_obj)
- subtype = PE_SUBTYPE_OBJ;
-
- else if (m->m_coff.cfh_characteristics & PE_IMAGE_FILE_DLL)
- subtype = PE_SUBTYPE_DLL;
-
- else
- subtype = PE_SUBTYPE_EXE;
+ if (((subtype = m->m_subtype) < 0) || (subtype >= PE_SUBTYPE_CAP))
+ subtype = PE_SUBTYPE_UNRECOGNIZED;
if (infostr)
strcpy(infostr->buffer,pe_subtype_str[subtype]);
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 826b36b..d47b922 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -209,6 +209,22 @@ static void pe_detect_image_abi(struct pe_image_meta * m)
m->m_abi = abi;
}
+static void pe_detect_image_subtype(struct pe_image_meta * m)
+{
+ int subtype;
+
+ if (m->r_obj)
+ subtype = PE_SUBTYPE_OBJ;
+
+ else if (m->m_coff.cfh_characteristics & PE_IMAGE_FILE_DLL)
+ subtype = PE_SUBTYPE_DLL;
+
+ else
+ subtype = PE_SUBTYPE_EXE;
+
+ m->m_subtype = subtype;
+}
+
int pe_get_image_meta(
const struct pe_driver_ctx * dctx,
const struct pe_raw_image * image,
@@ -428,6 +444,7 @@ int pe_get_image_meta(
/* info */
pe_detect_image_abi(m);
+ pe_detect_image_subtype(m);
/* mdso abi */
if (m->h_dsometa || m->h_dsosyms)