xref: /reactos/sdk/lib/rossym/pe.h (revision b09b5584)
1 #ifndef _LIBMACH_PE_H_
2 #define _LIBMACH_PE_H_
3 
4 #include "compat.h"
5 
6 struct DwarfBlock;
7 typedef struct _IMAGE_SECTION_HEADER PeSect;
8 
9 typedef struct _CoffSymbol {
10 	ulong address;
11 	char *name;
12 } CoffSymbol;
13 
14 typedef struct _Pe {
15 	void *fd;
16 	u16int (*e2)(const unsigned char *data);
17 	u32int (*e4)(const unsigned char *data);
18 	u64int (*e8)(const unsigned char *data);
19 	ulong imagebase, imagesize, loadbase;
20 	ulong nsymbols;
21 	CoffSymbol *symtab;
22 	int (*loadsection)(struct _Pe *pe, char *name, struct DwarfBlock *b);
23 	int nsections;
24 	struct _IMAGE_SECTION_HEADER *sect;
25 } Pe;
26 
27 #define E_SYMNMLEN 8
28 #include <pshpack1.h>
29 typedef struct {
30 	union {
31 		char e_name[E_SYMNMLEN];
32 		struct {
33 			unsigned long e_zeroes;
34 			unsigned long e_offset;
35 		} e;
36 	} e;
37 	unsigned long e_value;
38 	short e_scnum;
39 	unsigned short e_type;
40 	unsigned char e_sclass;
41 	unsigned char e_numaux;
42 } SYMENT, *PSYMENT;
43 #include <poppack.h>
44 
45 #define C_EXT 2
46 #define C_STAT 3
47 #define DT_FCN 0x40
48 
49 Pe *peopen(const char *name);
50 int loaddisksection(struct _Pe *pe, char *name, struct DwarfBlock *b);
51 int loadmemsection(struct _Pe *pe, char *name, struct DwarfBlock *b);
52 u16int peget2(const unsigned char *ptr);
53 u32int peget4(const unsigned char *ptr);
54 u64int peget8(const unsigned char *ptr);
55 void pefree(struct _Pe *pe);
56 ulong pefindrva(struct _IMAGE_SECTION_HEADER *SectionHeader, int NumberOfSections, ulong TargetPhysical);
57 int GetStrnlen(const char *string, int maxlen);
58 
59 #define ANSI_NAME_STRING(s) ((PANSI_STRING)((s)->Name))
60 
61 #endif/*_LIBMACH_PE_H_*/
62