Blame src/reader/pe_read_import_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>
ff2363
#include "perk_endian_impl.h"
413f56
#include "perk_reader_impl.h"
c0fbae
c0fbae
int pe_read_import_header(const struct pe_import_hdr * p, struct pe_meta_import_hdr * m)
c0fbae
{
a4928b
	m->import_lookup_tbl_rva	= pe_read_long(p->import_lookup_tbl_rva);
a4928b
	m->time_date_stamp		= pe_read_long(p->time_date_stamp);
a4928b
	m->forwarder_chain		= pe_read_long(p->forwarder_chain);
a4928b
	m->name_rva			= pe_read_long(p->name_rva);
a4928b
	m->import_addr_tbl_rva		= pe_read_long(p->import_addr_tbl_rva);
c0fbae
a4928b
	m->name   = 0;
c0fbae
	m->aitems = 0;
c0fbae
c0fbae
	return 0;
b5f7f5
}
c0fbae
c0fbae
int pe_read_import_lookup_item(
7d4d3d
	const union pe_import_lookup_item * p,
c0fbae
	struct pe_meta_import_lookup_item * m,
c0fbae
	uint32_t magic)
c0fbae
{
c0fbae
	switch (magic) {
c0fbae
		case PE_MAGIC_PE32:
7d4d3d
			m->u.import_lookup_entry_64 = pe_read_long(p->import_lookup_entry_32);
c0fbae
			return 0;
c0fbae
c0fbae
		case PE_MAGIC_PE32_PLUS:
7d4d3d
			m->u.import_lookup_entry_64 = pe_read_quad(p->import_lookup_entry_64);
c0fbae
			return 0;
c0fbae
c0fbae
		default:
ff121d
			return PERK_ERR_BAD_IMAGE_TYPE;
c0fbae
	}
b5f7f5
}