From aec459048d46959149a4ca11756fc11992c3ca7f Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 2 Nov 2018 21:39:26 -0500 Subject: pe_get_image_meta(), pe_get_image_subtype(): init/use the .m_subtype member. --- src/info/pe_get_image_subtype.c | 10 ++-------- src/logic/pe_get_image_meta.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src') 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) -- cgit v1.2.3