Blame src/reader/pe_read_section_header.c

e2e2c2
/***************************************************************/
e2e2c2
/*  perk: PE Resource Kit                                      */
425fb8
/*  Copyright (C) 2015--2021  SysDeer Technologies, LLC        */
e2e2c2
/*  Released under GPLv2 and GPLv3; see COPYING.PERK.          */
e2e2c2
/***************************************************************/
e2e2c2
c0fbae
#include <string.h>
c0fbae
c0fbae
#include <perk/perk.h>
d6e02b
#include <perk/perk_consts.h>
d6e02b
#include <perk/perk_structs.h>
8d8242
#include "perk_endian_impl.h"
413f56
#include "perk_reader_impl.h"
c0fbae
a09b56
int pe_read_section_header(const struct pe_raw_sec_hdr * p, struct pe_meta_sec_hdr * m)
c0fbae
{
c0fbae
	/* name: meta struct conveniently contains null termination */
9740a3
	memset(m,0,sizeof(m->sh_name));
9740a3
	memcpy(m,p,sizeof(p->sh_name));
c0fbae
9740a3
	m->sh_long_name         = 0;
9740a3
	m->sh_virtual_size      = pe_read_long(p->sh_virtual_size);
9740a3
	m->sh_virtual_addr      = pe_read_long(p->sh_virtual_addr);
9740a3
	m->sh_size_of_raw_data  = pe_read_long(p->sh_size_of_raw_data);
9740a3
	m->sh_ptr_to_raw_data   = pe_read_long(p->sh_ptr_to_raw_data);
9740a3
	m->sh_ptr_to_relocs     = pe_read_long(p->sh_ptr_to_relocs);
9740a3
	m->sh_ptr_to_line_nums  = pe_read_long(p->sh_ptr_to_line_nums);
4d1375
9740a3
	m->sh_num_of_relocs     = pe_read_short(p->sh_num_of_relocs);
9740a3
	m->sh_num_of_line_nums  = pe_read_short(p->sh_num_of_line_nums);
4d1375
9740a3
	m->sh_characteristics   = pe_read_long(p->sh_characteristics);
c0fbae
c0fbae
	return 0;
b5f7f5
}