Blame src/reader/pe_read_section_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>
8d8242
#include "perk_endian_impl.h"
413f56
#include "perk_reader_impl.h"
c0fbae
c0fbae
int pe_read_section_header(const struct pe_sec_hdr * p, struct pe_meta_sec_hdr * m)
c0fbae
{
c0fbae
	/* name: meta struct conveniently contains null termination */
c0fbae
	memset(m,0,sizeof(m->name));
c0fbae
	memcpy(m,p,sizeof(p->name));
c0fbae
4d1375
	m->long_name		= 0;
4d1375
	m->virtual_size		= pe_read_long(p->virtual_size);
4d1375
	m->virtual_addr		= pe_read_long(p->virtual_addr);
4d1375
	m->size_of_raw_data	= pe_read_long(p->size_of_raw_data);
4d1375
	m->ptr_to_raw_data	= pe_read_long(p->ptr_to_raw_data);
4d1375
	m->ptr_to_relocs	= pe_read_long(p->ptr_to_relocs);
4d1375
	m->ptr_to_line_nums	= pe_read_long(p->ptr_to_line_nums);
4d1375
4d1375
	m->num_of_relocs	= pe_read_short(p->num_of_relocs);
4d1375
	m->num_of_line_nums	= pe_read_short(p->num_of_line_nums);
4d1375
4d1375
	m->characteristics	= pe_read_long(p->characteristics);
c0fbae
c0fbae
	return 0;
b5f7f5
}