ReactOS 0.4.15-dev-7887-g64a59a1
pe.h File Reference
#include "compat.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  _Pe
 

Macros

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

Typedefs

typedef struct _IMAGE_SECTION_HEADER PeSect
 
typedef struct _Pe Pe
 

Functions

Pepeopen (const char *name)
 
int loaddisksection (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 30 of file pe.h.

Typedef Documentation

◆ Pe

typedef struct _Pe Pe

◆ PeSect

Definition at line 7 of file pe.h.

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

Referenced by RosSymCreateFromFile(), and RosSymCreateFromMem().

◆ 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

Referenced by RosSymCreateFromFile().

◆ 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
#define DPRINT
Definition: sndvol32.h:71
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress

Referenced by RosSymCreateFromMem().

◆ 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

Referenced by dwarfclose().

◆ 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

Referenced by RosSymCreateFromFile(), and RosSymCreateFromMem().

◆ 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

Referenced by RosSymCreateFromFile(), and RosSymCreateFromMem().

◆ 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

Referenced by RosSymCreateFromFile(), and RosSymCreateFromMem().

◆ peopen()

Pe * peopen ( const char name)