Blame src/info/pe_get_image_abi.c

8c7b6a
/***************************************************************/
8c7b6a
/*  perk: PE Resource Kit                                      */
8c7b6a
/*  Copyright (C) 2015--2016  Z. Gilboa                        */
8c7b6a
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
8c7b6a
/***************************************************************/
8c7b6a
8c7b6a
#include <string.h>
8c7b6a
8c7b6a
#include <perk/perk.h>
8c7b6a
#include <perk/perk_meta.h>
8c7b6a
461c11
static const char * const pe_abi_str[PE_ABI_CAP] = {
8c7b6a
	[PE_ABI_UNSUPPORTED]    = "UNSUPPORTED",
8c7b6a
	[PE_ABI_PE32]           = "PE32",
8c7b6a
	[PE_ABI_PE64]           = "PE64",
8c7b6a
};
8c7b6a
8c7b6a
int pe_get_image_abi(const struct pe_image_meta * m, struct pe_info_string * infostr)
8c7b6a
{
8c7b6a
	int abi;
8c7b6a
8c7b6a
	switch (m->opt.std.magic) {
8c7b6a
		case PE_MAGIC_PE32:
8c7b6a
			abi = PE_ABI_PE32;
8c7b6a
			break;
8c7b6a
8c7b6a
		case PE_MAGIC_PE32_PLUS:
8c7b6a
			abi = PE_ABI_PE64;
8c7b6a
			break;
8c7b6a
8c7b6a
		default:
8c7b6a
			abi = PE_ABI_UNSUPPORTED;
8c7b6a
			break;
8c7b6a
	}
8c7b6a
8c7b6a
	if (infostr)
8c7b6a
		strcpy(infostr->buffer,pe_abi_str[abi]);
8c7b6a
8c7b6a
	return abi;
8c7b6a
}