diff options
author | midipix <writeonce@midipix.org> | 2018-11-02 21:54:20 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-11-20 20:25:14 -0500 |
commit | c13a6ba2bc291473d5e72d5a33bc9fb8cfc3ce2e (patch) | |
tree | b8cdfc993852a570cd540b4e38b3c418915b08ca /src | |
parent | aec459048d46959149a4ca11756fc11992c3ca7f (diff) | |
download | perk-c13a6ba2bc291473d5e72d5a33bc9fb8cfc3ce2e.tar.bz2 perk-c13a6ba2bc291473d5e72d5a33bc9fb8cfc3ce2e.tar.xz |
pe_get_image_meta(), pe_get_image_framework(): init/use .m_framework member.
Diffstat (limited to 'src')
-rw-r--r-- | src/info/pe_get_image_framework.c | 67 | ||||
-rw-r--r-- | src/logic/pe_get_image_meta.c | 76 |
2 files changed, 77 insertions, 66 deletions
diff --git a/src/info/pe_get_image_framework.c b/src/info/pe_get_image_framework.c index c570371..84d2538 100644 --- a/src/info/pe_get_image_framework.c +++ b/src/info/pe_get_image_framework.c @@ -25,76 +25,11 @@ static const char * const pe_framework_str[PE_FRAMEWORK_CAP] = { [PE_FRAMEWORK_WIN32] = "win32", }; -static bool pe_image_is_psxscl(const struct pe_image_meta * m) -{ - return (!m->m_stats.t_nimplibs - && !pe_get_expsym_by_name(m,"__psx_init",0)); -} - -static bool pe_image_is_cygwin(const struct pe_image_meta * m) -{ - int i; - - for (i=0; i<m->m_stats.t_nimplibs; i++) - if (!(strcmp(m->m_idata[i].ih_name,"cygwin1.dll"))) - return true; - - return false; -} - -static bool pe_image_is_msys(const struct pe_image_meta * m) -{ - int i; - - for (i=0; i<m->m_stats.t_nimplibs; i++) - if (!(strcmp(m->m_idata[i].ih_name,"msys-2.0.dll"))) - return true; - - return false; -} - -static bool pe_image_is_mingw(const struct pe_image_meta * m) -{ - return ((pe_get_named_section_index(m,".CRT") >= 0) - && (pe_get_named_section_index(m,".bss") >= 0) - && (pe_get_named_section_index(m,".tls") >= 0)); -} - int pe_get_image_framework(const struct pe_image_meta * m, struct pe_info_string * infostr) { int framework; - if (pe_get_named_section_index(m,".midipix") >= 0) - framework = PE_FRAMEWORK_MIDIPIX; - - else if (pe_get_named_section_index(m,".freestd") >= 0) - framework = PE_FRAMEWORK_FREESTD; - - else if (pe_get_named_section_index(m,".cygheap") >= 0) - framework = PE_FRAMEWORK_CYGONE; - - else if (pe_image_is_psxscl(m)) - framework = PE_FRAMEWORK_PSXSCL; - - else if (pe_image_is_cygwin(m)) - framework = PE_FRAMEWORK_CYGWIN; - - else if (pe_image_is_msys(m)) - framework = PE_FRAMEWORK_MSYS; - - else if (pe_image_is_mingw(m)) - framework = PE_FRAMEWORK_MINGW; - - else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_POSIX_CUI) - framework = PE_FRAMEWORK_SUACON; - - else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_WINDOWS_CUI) - framework = PE_FRAMEWORK_WINCON; - - else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_WINDOWS_GUI) - framework = PE_FRAMEWORK_WIN32; - - else + if (((framework = m->m_framework) < 0) || (framework >= PE_FRAMEWORK_CAP)) framework = PE_FRAMEWORK_UNKNOWN; if (infostr) diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c index d47b922..4943780 100644 --- a/src/logic/pe_get_image_meta.c +++ b/src/logic/pe_get_image_meta.c @@ -225,6 +225,81 @@ static void pe_detect_image_subtype(struct pe_image_meta * m) m->m_subtype = subtype; } +static bool pe_image_is_psxscl(const struct pe_image_meta * m) +{ + return (!m->m_stats.t_nimplibs + && !pe_get_expsym_by_name(m,"__psx_init",0)); +} + +static bool pe_image_is_cygwin(const struct pe_image_meta * m) +{ + int i; + + for (i=0; i<m->m_stats.t_nimplibs; i++) + if (!(strcmp(m->m_idata[i].ih_name,"cygwin1.dll"))) + return true; + + return false; +} + +static bool pe_image_is_msys(const struct pe_image_meta * m) +{ + int i; + + for (i=0; i<m->m_stats.t_nimplibs; i++) + if (!(strcmp(m->m_idata[i].ih_name,"msys-2.0.dll"))) + return true; + + return false; +} + +static bool pe_image_is_mingw(const struct pe_image_meta * m) +{ + return ((pe_get_named_section_index(m,".CRT") >= 0) + && (pe_get_named_section_index(m,".bss") >= 0) + && (pe_get_named_section_index(m,".tls") >= 0)); +} + +static void pe_detect_image_framework(struct pe_image_meta * m) +{ + int framework; + + if (pe_get_named_section_index(m,".midipix") >= 0) + framework = PE_FRAMEWORK_MIDIPIX; + + else if (pe_get_named_section_index(m,".freestd") >= 0) + framework = PE_FRAMEWORK_FREESTD; + + else if (pe_get_named_section_index(m,".cygheap") >= 0) + framework = PE_FRAMEWORK_CYGONE; + + else if (pe_image_is_psxscl(m)) + framework = PE_FRAMEWORK_PSXSCL; + + else if (pe_image_is_cygwin(m)) + framework = PE_FRAMEWORK_CYGWIN; + + else if (pe_image_is_msys(m)) + framework = PE_FRAMEWORK_MSYS; + + else if (pe_image_is_mingw(m)) + framework = PE_FRAMEWORK_MINGW; + + else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_POSIX_CUI) + framework = PE_FRAMEWORK_SUACON; + + else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_WINDOWS_CUI) + framework = PE_FRAMEWORK_WINCON; + + else if (m->m_opt.oh_img.coh_subsystem == PE_IMAGE_SUBSYSTEM_WINDOWS_GUI) + framework = PE_FRAMEWORK_WIN32; + + else + framework = PE_FRAMEWORK_UNKNOWN; + + m->m_framework = framework; +} + int pe_get_image_meta( const struct pe_driver_ctx * dctx, const struct pe_raw_image * image, @@ -445,6 +520,7 @@ int pe_get_image_meta( /* info */ pe_detect_image_abi(m); pe_detect_image_subtype(m); + pe_detect_image_framework(m); /* mdso abi */ if (m->h_dsometa || m->h_dsosyms) |