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>
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
862cb6
	if (m->aobj)
862cb6
		subtype = PE_SUBTYPE_OBJ;
862cb6
862cb6
	else if (m->coff.cfh_characteristics & PE_IMAGE_FILE_DLL)
6aec96
		subtype = PE_SUBTYPE_DLL;
6aec96
6aec96
	else
6aec96
		subtype = PE_SUBTYPE_EXE;
6aec96
6aec96
	if (infostr)
6aec96
		strcpy(infostr->buffer,pe_subtype_str[subtype]);
6aec96
6aec96
	return subtype;
6aec96
}