Blame src/info/pe_get_image_subtype.c

6aec96
/***************************************************************/
6aec96
/*  perk: PE Resource Kit                                      */
ced38a
/*  Copyright (C) 2015--2017  Z. Gilboa                        */
6aec96
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
6aec96
/***************************************************************/
6aec96
6aec96
#include <string.h>
6aec96
6aec96
#include <perk/perk.h>
d6e02b
#include <perk/perk_consts.h>
6aec96
#include <perk/perk_meta.h>
6aec96
6aec96
/* todo: object, unrecognized */
6aec96
6eeec5
static const char * const pe_subtype_str[PE_SUBTYPE_CAP] = {
6aec96
	[PE_SUBTYPE_UNRECOGNIZED]   = "UNRECOGNIZED",
6aec96
	[PE_SUBTYPE_DLL]            = "dll",
6aec96
	[PE_SUBTYPE_EXE]            = "exe",
6aec96
	[PE_SUBTYPE_OBJ]            = "obj",
6aec96
};
6aec96
6aec96
int pe_get_image_subtype(const struct pe_image_meta * m, struct pe_info_string * infostr)
6aec96
{
6aec96
	int subtype;
6aec96
aec459
	if (((subtype = m->m_subtype) < 0) || (subtype >= PE_SUBTYPE_CAP))
aec459
		subtype = PE_SUBTYPE_UNRECOGNIZED;
6aec96
6aec96
	if (infostr)
6aec96
		strcpy(infostr->buffer,pe_subtype_str[subtype]);
6aec96
6aec96
	return subtype;
6aec96
}