summaryrefslogtreecommitdiffhomepage
path: root/src/headers/pe_get_image_opt_hdr_addr.c
blob: 7fcd0ad939e2c77bc6a8d716d9f9a756c47fc534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*****************************************************************************/
/*  pemagination: a (virtual) tour into portable bits and executable bytes   */
/*  Copyright (C) 2013,2014,2015  Z. Gilboa                                  */
/*  Released under GPLv2 and GPLv3; see COPYING.PEMAGINE.                    */
/*****************************************************************************/

#include <psxtypes/psxtypes.h>
#include <pemagine/pe_structs.h>
#include <pemagine/pemagine.h>

pe_api
union pe_raw_opt_hdr * pe_get_image_opt_hdr_addr(const void * base)
{
	struct pe_raw_coff_file_hdr *	coff;
	void *				addr;

	if (!(coff = pe_get_image_coff_hdr_addr(base)))
		return 0;

	addr = pe_va_from_rva(coff,sizeof(*coff));
	return (union pe_raw_opt_hdr *)addr;
}