|
|
049a18 |
/***************************************************************/
|
|
|
049a18 |
/* perk: PE Resource Kit */
|
|
|
049a18 |
/* Copyright (C) 2015--2016 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 |
|
|
|
c6ac1a |
if (m->opt.oh_img.coh_subsystem >= 0x10)
|
|
|
049a18 |
subsystem = -1;
|
|
|
049a18 |
|
|
|
c6ac1a |
else if (!pe_subsystem_str[m->opt.oh_img.coh_subsystem])
|
|
|
049a18 |
subsystem = -1;
|
|
|
049a18 |
|
|
|
049a18 |
else
|
|
|
c6ac1a |
subsystem = 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 |
}
|