summaryrefslogtreecommitdiffhomepage
path: root/src/logic/pe_get_image_subtype.c
blob: 7e19ef1642bfb47f30e273e2944990f12d307d64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/***************************************************************/
/*  perk: PE Resource Kit                                      */
/*  Copyright (C) 2015--2016  Z. Gilboa                        */
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
/***************************************************************/

#include <string.h>

#include <perk/perk.h>
#include <perk/perk_meta.h>

/* 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 (m->coff.characteristics & PE_IMAGE_FILE_DLL)
		subtype = PE_SUBTYPE_DLL;

	else
		subtype = PE_SUBTYPE_EXE;

	if (infostr)
		strcpy(infostr->buffer,pe_subtype_str[subtype]);

	return subtype;
}