ReactOS 0.4.15-dev-8093-g3285f69
pe.h File Reference
#include "compat.h"
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for pe.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _CoffSymbol
 
struct  _Pe
 
struct  SYMENT
 

Macros

#define E_SYMNMLEN   8
 
#define C_EXT   2
 
#define C_STAT   3
 
#define DT_FCN   0x40
 
#define ANSI_NAME_STRING(s)   ((PANSI_STRING)((s)->Name))
 

Typedefs

typedef struct _IMAGE_SECTION_HEADER PeSect
 
typedef struct _CoffSymbol CoffSymbol
 
typedef struct _Pe Pe
 
typedef struct SYMENTPSYMENT
 

Functions

Pepeopen (const char *name)
 
int loaddisksection (struct _Pe *pe, char *name, struct DwarfBlock *b)
 
int loadmemsection (struct _Pe *pe, char *name, struct DwarfBlock *b)
 
u16int peget2 (const unsigned char *ptr)
 
u32int peget4 (const unsigned char *ptr)
 
u64int peget8 (const unsigned char *ptr)
 
void pefree (struct _Pe *pe)
 
ulong pefindrva (struct _IMAGE_SECTION_HEADER *SectionHeader, int NumberOfSections, ulong TargetPhysical)
 
int GetStrnlen (const char *string, int maxlen)
 

Macro Definition Documentation

◆ ANSI_NAME_STRING

#define ANSI_NAME_STRING (   s)    ((PANSI_STRING)((s)->Name))

Definition at line 59 of file pe.h.

◆ C_EXT

#define C_EXT   2

Definition at line 45 of file pe.h.

◆ C_STAT

#define C_STAT   3

Definition at line 46 of file pe.h.

◆ DT_FCN

#define DT_FCN   0x40

Definition at line 47 of file pe.h.

◆ E_SYMNMLEN

#define E_SYMNMLEN   8

Definition at line 27 of file pe.h.

Typedef Documentation

◆ CoffSymbol

◆ Pe

typedef struct _Pe Pe

◆ PeSect

Definition at line 7 of file pe.h.

◆ PSYMENT

typedef struct SYMENT * PSYMENT

Function Documentation

◆ GetStrnlen()

int GetStrnlen ( const char string,
int  maxlen 
)

Definition at line 103 of file pe.c.

103 {
104 int i;
105 for (i = 0; i < maxlen && string[i]; i++);
106 return i;
107}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

◆ loaddisksection()

int loaddisksection ( struct _Pe pe,
char name,
struct DwarfBlock b 
)

Definition at line 72 of file pe.c.

73{
74 PeSect *s;
75 if((s = pesection(pe, name)) == nil)
76 return -1;
77 return readblock(pe->fd, b, s->PointerToRawData, s->SizeOfRawData);
78}
GLdouble s
Definition: gl.h:2039
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
PeSect * pesection(Pe *pe, const char *name)
Definition: pe.c:15
static int readblock(void *fd, DwarfBlock *b, ulong off, ulong len)
Definition: pe.c:57
#define nil
Definition: compat.h:23
void * fd
Definition: pe.h:15
Definition: name.c:39

◆ loadmemsection()

int loadmemsection ( struct _Pe pe,
char name,
struct DwarfBlock b 
)

Definition at line 81 of file pe.c.

82{
83 PeSect *s;
84
85 if((s = pesection(pe, name)) == nil)
86 return -1;
87 DPRINT("Loading section %s (ImageBase %x RVA %x)\n", name, pe->fd, s->VirtualAddress);
88 b->data = RosSymAllocMem(s->SizeOfRawData);
89 b->len = s->SizeOfRawData;
90 PCHAR DataSource = ((char *)pe->fd) + s->VirtualAddress;
91 DPRINT("Copying to %x from %x (%x)\n", DataSource, b->data, b->len);
92 RtlCopyMemory(b->data, DataSource, s->SizeOfRawData);
93
94 return s->SizeOfRawData;
95}
#define RosSymAllocMem(Size)
Definition: rossympriv.h:14
#define DPRINT
Definition: sndvol32.h:73
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
char * PCHAR
Definition: typedefs.h:51

Referenced by RosSymCreateFromMem().

◆ pefindrva()

ulong pefindrva ( struct _IMAGE_SECTION_HEADER SectionHeader,
int  NumberOfSections,
ulong  TargetPhysical 
)

Definition at line 126 of file pe.c.

126 {
127 int i;
128 DPRINT("Finding RVA for Physical %x\n", TargetPhysical);
129 for (i = 0; i < NumberOfSections; i++) {
130 DPRINT("Section %d name %s Raw %x Virt %x\n",
131 i,
132 ANSI_NAME_STRING(&SectionHeaders[i])->Buffer,
133 SectionHeaders[i].PointerToRawData,
134 SectionHeaders[i].VirtualAddress);
135 if (TargetPhysical >= SectionHeaders[i].PointerToRawData &&
136 TargetPhysical < SectionHeaders[i].PointerToRawData + SectionHeaders[i].SizeOfRawData) {
137 DPRINT("RVA %x\n", TargetPhysical - SectionHeaders[i].PointerToRawData + SectionHeaders[i].VirtualAddress);
138 return TargetPhysical - SectionHeaders[i].PointerToRawData + SectionHeaders[i].VirtualAddress;
139 }
140 }
141 return nil;
142}
Definition: bufpool.h:45
#define ANSI_NAME_STRING(s)
Definition: pe.h:59
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress

◆ pefree()

void pefree ( struct _Pe pe)

Definition at line 109 of file pe.c.

109 {
110 int i;
111 for (i = 0; i < pe->nsections; i++) {
113 }
114 for (i = 0; i < pe->nsymbols; i++) {
115 free(pe->symtab[i].name);
116 }
117 free(pe->symtab);
118 free(pe->sect);
119 free(pe);
120}
#define free
Definition: debug_ros.c:5
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
char * name
Definition: pe.h:11
struct _IMAGE_SECTION_HEADER * sect
Definition: pe.h:24
CoffSymbol * symtab
Definition: pe.h:21
ulong nsymbols
Definition: pe.h:20
int nsections
Definition: pe.h:23

◆ peget2()

u16int peget2 ( const unsigned char ptr)

Definition at line 35 of file pe.c.

35 {
36 return *((u16int*)ptr);
37}
static PVOID ptr
Definition: dispmode.c:27
unsigned short u16int
Definition: compat.h:11

◆ peget4()

u32int peget4 ( const unsigned char ptr)

Definition at line 39 of file pe.c.

39 {
40 return *((u32int*)ptr);
41}
unsigned int u32int
Definition: compat.h:13

◆ peget8()

u64int peget8 ( const unsigned char ptr)

Definition at line 43 of file pe.c.

43 {
44 return *((u64int*)ptr);
45}
unsigned long long u64int
Definition: compat.h:15

◆ peopen()

Pe * peopen ( const char name)

Referenced by main().