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
34ee9e
int pe_read_import_header(const struct pe_raw_import_hdr * p, struct pe_meta_import_hdr * m)
c0fbae
{
982672
	m->ih_import_lookup_tbl_rva = pe_read_long(p->ih_import_lookup_tbl_rva);
982672
	m->ih_time_date_stamp       = pe_read_long(p->ih_time_date_stamp);
982672
	m->ih_forwarder_chain       = pe_read_long(p->ih_forwarder_chain);
982672
	m->ih_name_rva              = pe_read_long(p->ih_name_rva);
982672
	m->ih_import_addr_tbl_rva   = pe_read_long(p->ih_import_addr_tbl_rva);
982672
982672
	m->ih_name   = 0;
982672
	m->ih_aitems = 0;
c0fbae
c0fbae
	return 0;
b5f7f5
}
c0fbae
9770d4
int pe_read_import_lookup(
34ee9e
	const union pe_raw_import_lookup * p,
3161de
	struct pe_meta_import_lookup * m,
c0fbae
	uint32_t magic)
c0fbae
{
c0fbae
	switch (magic) {
c0fbae
		case PE_MAGIC_PE32:
f845bd
			m->u.ii_import_lookup_entry_64 = pe_read_long(p->ii_import_lookup_entry_32);
c0fbae
			return 0;
c0fbae
c0fbae
		case PE_MAGIC_PE32_PLUS:
f845bd
			m->u.ii_import_lookup_entry_64 = pe_read_quad(p->ii_import_lookup_entry_64);
c0fbae
			return 0;
c0fbae
c0fbae
		default:
ff121d
			return PERK_ERR_BAD_IMAGE_TYPE;
c0fbae
	}
b5f7f5
}