Blame src/reader/pe_read_coff_header.c

e2e2c2
/***************************************************************/
e2e2c2
/*  perk: PE Resource Kit                                      */
e2e2c2
/*  Copyright (C) 2015--2016  Z. Gilboa                        */
e2e2c2
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
e2e2c2
/***************************************************************/
e2e2c2
c0fbae
#include <string.h>
c0fbae
c0fbae
#include <perk/perk.h>
01439f
#include "perk_endian_impl.h"
413f56
#include "perk_reader_impl.h"
c0fbae
11fb1c
int pe_read_coff_header(const struct pe_raw_coff_file_hdr * p, struct pe_meta_coff_file_hdr * m)
c0fbae
{
51aab1
	if ((p->signature[0] != 'P') || (p->signature[1] != 'E')
51aab1
			|| p->signature[2] || p->signature[3])
ff121d
		return PERK_ERR_BAD_COFF_HEADER;
c0fbae
c10b3d
	m->signature[0] = p->signature[0];
c10b3d
	m->signature[1] = p->signature[1];
c10b3d
	m->signature[2] = p->signature[2];
c10b3d
	m->signature[3] = p->signature[3];
c0fbae
c10b3d
	m->machine		= pe_read_short(p->machine);
c10b3d
	m->num_of_sections	= pe_read_short(p->num_of_sections);
c0fbae
c10b3d
	m->time_date_stamp	= pe_read_long(p->time_date_stamp);
c10b3d
	m->ptr_to_sym_tbl	= pe_read_long(p->ptr_to_sym_tbl);
c10b3d
	m->num_of_syms		= pe_read_long(p->num_of_syms);
c0fbae
c10b3d
	m->size_of_opt_hdr	= pe_read_short(p->size_of_opt_hdr);
c10b3d
	m->characteristics	= pe_read_short(p->characteristics);
c0fbae
c0fbae
	return 0;
b5f7f5
}