|
|
049a18 |
/***************************************************************/
|
|
|
049a18 |
/* perk: PE Resource Kit */
|
|
|
ced38a |
/* Copyright (C) 2015--2017 Z. Gilboa */
|
|
|
049a18 |
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
|
|
|
049a18 |
/***************************************************************/
|
|
|
049a18 |
|
|
|
049a18 |
#include <string.h>
|
|
|
049a18 |
|
|
|
049a18 |
#include <perk/perk.h>
|
|
|
049a18 |
#include <perk/perk_meta.h>
|
|
|
049a18 |
|
|
|
4b9f6c |
static const char * const pe_subsystem_str[0x10] = {
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_UNKNOWN] = "unknown",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_NATIVE] = "native",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_WINDOWS_GUI] = "windows",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_WINDOWS_CUI] = "console",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_POSIX_CUI] = "posix",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_WINDOWS_CE_GUI] = "wince",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_EFI_APPLICATION] = "efi_app",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER] = "efi_driver",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_EFI_ROM] = "efi_rom",
|
|
|
049a18 |
[PE_IMAGE_SUBSYSTEM_XBOX] = "xbox"
|
|
|
049a18 |
};
|
|
|
049a18 |
|
|
|
049a18 |
int pe_get_image_subsystem(const struct pe_image_meta * m, struct pe_info_string * infostr)
|
|
|
049a18 |
{
|
|
|
049a18 |
int subsystem;
|
|
|
049a18 |
|
|
|
f3d26e |
if (m->r_obj)
|
|
|
862cb6 |
subsystem = 0;
|
|
|
862cb6 |
|
|
|
58ced9 |
else if (m->m_opt.oh_img.coh_subsystem >= 0x10)
|
|
|
049a18 |
subsystem = -1;
|
|
|
049a18 |
|
|
|
58ced9 |
else if (!pe_subsystem_str[m->m_opt.oh_img.coh_subsystem])
|
|
|
049a18 |
subsystem = -1;
|
|
|
049a18 |
|
|
|
049a18 |
else
|
|
|
58ced9 |
subsystem = m->m_opt.oh_img.coh_subsystem;
|
|
|
049a18 |
|
|
|
049a18 |
if ((subsystem < 0) && infostr) {
|
|
|
049a18 |
strcpy(infostr->buffer,"INVALID");
|
|
|
049a18 |
return subsystem;
|
|
|
049a18 |
}
|
|
|
049a18 |
|
|
|
049a18 |
if (infostr)
|
|
|
049a18 |
strcpy(infostr->buffer,pe_subsystem_str[subsystem]);
|
|
|
049a18 |
|
|
|
049a18 |
return subsystem;
|
|
|
049a18 |
}
|