From d2434891f37ef9592fa2e6b606d4a4411500d94b Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 30 May 2025 22:45:18 +0000 Subject: library api: _info_ (image abi and framework info) namespace overhaul. --- src/info/pe_get_image_abi.c | 30 -------------------- src/info/pe_get_image_framework.c | 40 -------------------------- src/info/pe_get_image_subsystem.c | 51 ---------------------------------- src/info/pe_get_image_subtype.c | 33 ---------------------- src/info/pe_info_get_image_abi.c | 30 ++++++++++++++++++++ src/info/pe_info_get_image_framework.c | 40 ++++++++++++++++++++++++++ src/info/pe_info_get_image_subsystem.c | 51 ++++++++++++++++++++++++++++++++++ src/info/pe_info_get_image_subtype.c | 33 ++++++++++++++++++++++ src/output/pe_output_image_category.c | 8 +++--- src/output/pe_output_mdso_libraries.c | 2 +- 10 files changed, 159 insertions(+), 159 deletions(-) delete mode 100644 src/info/pe_get_image_abi.c delete mode 100644 src/info/pe_get_image_framework.c delete mode 100644 src/info/pe_get_image_subsystem.c delete mode 100644 src/info/pe_get_image_subtype.c create mode 100644 src/info/pe_info_get_image_abi.c create mode 100644 src/info/pe_info_get_image_framework.c create mode 100644 src/info/pe_info_get_image_subsystem.c create mode 100644 src/info/pe_info_get_image_subtype.c (limited to 'src') diff --git a/src/info/pe_get_image_abi.c b/src/info/pe_get_image_abi.c deleted file mode 100644 index 0bdcbb8..0000000 --- a/src/info/pe_get_image_abi.c +++ /dev/null @@ -1,30 +0,0 @@ -/***************************************************************/ -/* perk: PE Resource Kit */ -/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ -/***************************************************************/ - -#include - -#include -#include -#include - -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; - - if (((abi = m->m_abi) < 0) || (abi >= PE_ABI_CAP)) - abi = PE_ABI_UNSUPPORTED; - - if (infostr) - strcpy(infostr->buffer,pe_abi_str[abi]); - - return abi; -} diff --git a/src/info/pe_get_image_framework.c b/src/info/pe_get_image_framework.c deleted file mode 100644 index 31b6760..0000000 --- a/src/info/pe_get_image_framework.c +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************/ -/* perk: PE Resource Kit */ -/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ -/***************************************************************/ - -#include -#include - -#include -#include -#include - -static const char * const pe_framework_str[PE_FRAMEWORK_CAP] = { - [PE_FRAMEWORK_UNKNOWN] = "unknown", - [PE_FRAMEWORK_FREESTD] = "freestd", - [PE_FRAMEWORK_PSXSCL] = "psxscl", - [PE_FRAMEWORK_MIDIPIX] = "midipix", - [PE_FRAMEWORK_CYGONE] = "cygone", - [PE_FRAMEWORK_CYGWIN] = "cygwin", - [PE_FRAMEWORK_MINGW] = "mingw", - [PE_FRAMEWORK_MSYS] = "msys", - [PE_FRAMEWORK_SUACON] = "suacon", - [PE_FRAMEWORK_WINCON] = "wincon", - [PE_FRAMEWORK_WINCLI] = "wincli", - [PE_FRAMEWORK_WIN32] = "win32", -}; - -int pe_get_image_framework(const struct pe_image_meta * m, struct pe_info_string * infostr) -{ - int framework; - - if (((framework = m->m_framework) < 0) || (framework >= PE_FRAMEWORK_CAP)) - framework = PE_FRAMEWORK_UNKNOWN; - - if (infostr) - strcpy(infostr->buffer,pe_framework_str[framework]); - - return framework; -} diff --git a/src/info/pe_get_image_subsystem.c b/src/info/pe_get_image_subsystem.c deleted file mode 100644 index ac9655e..0000000 --- a/src/info/pe_get_image_subsystem.c +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************/ -/* perk: PE Resource Kit */ -/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ -/***************************************************************/ - -#include - -#include -#include -#include - -static const char * const pe_subsystem_str[0x10] = { - [PE_IMAGE_SUBSYSTEM_UNKNOWN] = "unknown", - [PE_IMAGE_SUBSYSTEM_NATIVE] = "native", - [PE_IMAGE_SUBSYSTEM_WINDOWS_GUI] = "windows", - [PE_IMAGE_SUBSYSTEM_WINDOWS_CUI] = "console", - [PE_IMAGE_SUBSYSTEM_POSIX_CUI] = "posix", - [PE_IMAGE_SUBSYSTEM_WINDOWS_CE_GUI] = "wince", - [PE_IMAGE_SUBSYSTEM_EFI_APPLICATION] = "efi_app", - [PE_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER] = "efi_driver", - [PE_IMAGE_SUBSYSTEM_EFI_ROM] = "efi_rom", - [PE_IMAGE_SUBSYSTEM_XBOX] = "xbox" -}; - -int pe_get_image_subsystem(const struct pe_image_meta * m, struct pe_info_string * infostr) -{ - int subsystem; - - if (m->r_obj) - subsystem = 0; - - else if (m->m_opt.oh_img.coh_subsystem >= 0x10) - subsystem = -1; - - else if (!pe_subsystem_str[m->m_opt.oh_img.coh_subsystem]) - subsystem = -1; - - else - subsystem = m->m_opt.oh_img.coh_subsystem; - - if ((subsystem < 0) && infostr) { - strcpy(infostr->buffer,"INVALID"); - return subsystem; - } - - if (infostr) - strcpy(infostr->buffer,pe_subsystem_str[subsystem]); - - return subsystem; -} diff --git a/src/info/pe_get_image_subtype.c b/src/info/pe_get_image_subtype.c deleted file mode 100644 index 4d7ae5d..0000000 --- a/src/info/pe_get_image_subtype.c +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************/ -/* perk: PE Resource Kit */ -/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ -/***************************************************************/ - -#include - -#include -#include -#include - -/* 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 (((subtype = m->m_subtype) < 0) || (subtype >= PE_SUBTYPE_CAP)) - subtype = PE_SUBTYPE_UNRECOGNIZED; - - if (infostr) - strcpy(infostr->buffer,pe_subtype_str[subtype]); - - return subtype; -} diff --git a/src/info/pe_info_get_image_abi.c b/src/info/pe_info_get_image_abi.c new file mode 100644 index 0000000..faf141b --- /dev/null +++ b/src/info/pe_info_get_image_abi.c @@ -0,0 +1,30 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include + +#include +#include +#include + +static const char * const pe_abi_str[PE_ABI_CAP] = { + [PE_ABI_UNSUPPORTED] = "UNSUPPORTED", + [PE_ABI_PE32] = "PE32", + [PE_ABI_PE64] = "PE64", +}; + +int pe_info_get_image_abi(const struct pe_image_meta * m, struct pe_info_string * infostr) +{ + int abi; + + if (((abi = m->m_abi) < 0) || (abi >= PE_ABI_CAP)) + abi = PE_ABI_UNSUPPORTED; + + if (infostr) + strcpy(infostr->buffer,pe_abi_str[abi]); + + return abi; +} diff --git a/src/info/pe_info_get_image_framework.c b/src/info/pe_info_get_image_framework.c new file mode 100644 index 0000000..b56ae38 --- /dev/null +++ b/src/info/pe_info_get_image_framework.c @@ -0,0 +1,40 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include +#include + +#include +#include +#include + +static const char * const pe_framework_str[PE_FRAMEWORK_CAP] = { + [PE_FRAMEWORK_UNKNOWN] = "unknown", + [PE_FRAMEWORK_FREESTD] = "freestd", + [PE_FRAMEWORK_PSXSCL] = "psxscl", + [PE_FRAMEWORK_MIDIPIX] = "midipix", + [PE_FRAMEWORK_CYGONE] = "cygone", + [PE_FRAMEWORK_CYGWIN] = "cygwin", + [PE_FRAMEWORK_MINGW] = "mingw", + [PE_FRAMEWORK_MSYS] = "msys", + [PE_FRAMEWORK_SUACON] = "suacon", + [PE_FRAMEWORK_WINCON] = "wincon", + [PE_FRAMEWORK_WINCLI] = "wincli", + [PE_FRAMEWORK_WIN32] = "win32", +}; + +int pe_info_get_image_framework(const struct pe_image_meta * m, struct pe_info_string * infostr) +{ + int framework; + + if (((framework = m->m_framework) < 0) || (framework >= PE_FRAMEWORK_CAP)) + framework = PE_FRAMEWORK_UNKNOWN; + + if (infostr) + strcpy(infostr->buffer,pe_framework_str[framework]); + + return framework; +} diff --git a/src/info/pe_info_get_image_subsystem.c b/src/info/pe_info_get_image_subsystem.c new file mode 100644 index 0000000..dfe1b80 --- /dev/null +++ b/src/info/pe_info_get_image_subsystem.c @@ -0,0 +1,51 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include + +#include +#include +#include + +static const char * const pe_subsystem_str[0x10] = { + [PE_IMAGE_SUBSYSTEM_UNKNOWN] = "unknown", + [PE_IMAGE_SUBSYSTEM_NATIVE] = "native", + [PE_IMAGE_SUBSYSTEM_WINDOWS_GUI] = "windows", + [PE_IMAGE_SUBSYSTEM_WINDOWS_CUI] = "console", + [PE_IMAGE_SUBSYSTEM_POSIX_CUI] = "posix", + [PE_IMAGE_SUBSYSTEM_WINDOWS_CE_GUI] = "wince", + [PE_IMAGE_SUBSYSTEM_EFI_APPLICATION] = "efi_app", + [PE_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER] = "efi_driver", + [PE_IMAGE_SUBSYSTEM_EFI_ROM] = "efi_rom", + [PE_IMAGE_SUBSYSTEM_XBOX] = "xbox" +}; + +int pe_info_get_image_subsystem(const struct pe_image_meta * m, struct pe_info_string * infostr) +{ + int subsystem; + + if (m->r_obj) + subsystem = 0; + + else if (m->m_opt.oh_img.coh_subsystem >= 0x10) + subsystem = -1; + + else if (!pe_subsystem_str[m->m_opt.oh_img.coh_subsystem]) + subsystem = -1; + + else + subsystem = m->m_opt.oh_img.coh_subsystem; + + if ((subsystem < 0) && infostr) { + strcpy(infostr->buffer,"INVALID"); + return subsystem; + } + + if (infostr) + strcpy(infostr->buffer,pe_subsystem_str[subsystem]); + + return subsystem; +} diff --git a/src/info/pe_info_get_image_subtype.c b/src/info/pe_info_get_image_subtype.c new file mode 100644 index 0000000..4a2b1da --- /dev/null +++ b/src/info/pe_info_get_image_subtype.c @@ -0,0 +1,33 @@ +/***************************************************************/ +/* perk: PE Resource Kit */ +/* Copyright (C) 2015--2021 SysDeer Technologies, LLC */ +/* Released under GPLv2 and GPLv3; see COPYING.PERK. */ +/***************************************************************/ + +#include + +#include +#include +#include + +/* 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_info_get_image_subtype(const struct pe_image_meta * m, struct pe_info_string * infostr) +{ + int subtype; + + if (((subtype = m->m_subtype) < 0) || (subtype >= PE_SUBTYPE_CAP)) + subtype = PE_SUBTYPE_UNRECOGNIZED; + + if (infostr) + strcpy(infostr->buffer,pe_subtype_str[subtype]); + + return subtype; +} diff --git a/src/output/pe_output_image_category.c b/src/output/pe_output_image_category.c index 863c84f..b3d72df 100644 --- a/src/output/pe_output_image_category.c +++ b/src/output/pe_output_image_category.c @@ -24,10 +24,10 @@ int pe_output_image_category( fdout = pe_driver_fdout(dctx); - pe_get_image_abi (meta,&abi); - pe_get_image_subtype (meta,&subtype); - pe_get_image_subsystem(meta,&subsystem); - pe_get_image_framework(meta,&framework); + pe_info_get_image_abi (meta,&abi); + pe_info_get_image_subtype (meta,&subtype); + pe_info_get_image_subsystem(meta,&subsystem); + pe_info_get_image_framework(meta,&framework); if (dctx->cctx->fmtflags & PERK_PRETTY_YAML) { if (pe_dprintf( diff --git a/src/output/pe_output_mdso_libraries.c b/src/output/pe_output_mdso_libraries.c index c5ee1b4..c668564 100644 --- a/src/output/pe_output_mdso_libraries.c +++ b/src/output/pe_output_mdso_libraries.c @@ -180,7 +180,7 @@ int pe_output_mdso_libraries( if (!m->m_stats.t_ndsolibs) return 0; - if (pe_get_image_abi(m,0) == PE_ABI_UNSUPPORTED) + if (pe_info_get_image_abi(m,0) == PE_ABI_UNSUPPORTED) return PERK_CUSTOM_ERROR( dctx,PERK_ERR_UNSUPPORTED_ABI); -- cgit v1.2.3