ReactOS  0.4.13-dev-961-g238ea69
image_private.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  image_file_map
 
struct  image_section_map
 

Macros

#define DT_NUM   24
 
#define IMAGE_NO_MAP   ((void*)-1)
 
#define SHT_NULL   0
 

Functions

BOOL elf_find_section (struct image_file_map *fmap, const char *name, unsigned sht, struct image_section_map *ism) DECLSPEC_HIDDEN
 
const charelf_map_section (struct image_section_map *ism) DECLSPEC_HIDDEN
 
void elf_unmap_section (struct image_section_map *ism) DECLSPEC_HIDDEN
 
DWORD_PTR elf_get_map_rva (const struct image_section_map *ism) DECLSPEC_HIDDEN
 
unsigned elf_get_map_size (const struct image_section_map *ism) DECLSPEC_HIDDEN
 
BOOL macho_find_section (struct image_file_map *ifm, const char *segname, const char *sectname, struct image_section_map *ism) DECLSPEC_HIDDEN
 
const charmacho_map_section (struct image_section_map *ism) DECLSPEC_HIDDEN
 
void macho_unmap_section (struct image_section_map *ism) DECLSPEC_HIDDEN
 
DWORD_PTR macho_get_map_rva (const struct image_section_map *ism) DECLSPEC_HIDDEN
 
unsigned macho_get_map_size (const struct image_section_map *ism) DECLSPEC_HIDDEN
 
BOOL pe_find_section (struct image_file_map *fmap, const char *name, struct image_section_map *ism) DECLSPEC_HIDDEN
 
const charpe_map_section (struct image_section_map *psm) DECLSPEC_HIDDEN
 
void pe_unmap_section (struct image_section_map *psm) DECLSPEC_HIDDEN
 
DWORD_PTR pe_get_map_rva (const struct image_section_map *psm) DECLSPEC_HIDDEN
 
unsigned pe_get_map_size (const struct image_section_map *psm) DECLSPEC_HIDDEN
 
static BOOL image_find_section (struct image_file_map *fmap, const char *name, struct image_section_map *ism)
 
static const charimage_map_section (struct image_section_map *ism)
 
static void image_unmap_section (struct image_section_map *ism)
 
static DWORD_PTR image_get_map_rva (const struct image_section_map *ism)
 
static unsigned image_get_map_size (const struct image_section_map *ism)
 

Macro Definition Documentation

◆ DT_NUM

#define DT_NUM   24

Definition at line 38 of file image_private.h.

◆ IMAGE_NO_MAP

#define IMAGE_NO_MAP   ((void*)-1)

Definition at line 59 of file image_private.h.

◆ SHT_NULL

#define SHT_NULL   0

Definition at line 80 of file image_private.h.

Function Documentation

◆ elf_find_section()

BOOL elf_find_section ( struct image_file_map fmap,
const char name,
unsigned  sht,
struct image_section_map ism 
)

Definition at line 1785 of file elf_module.c.

1787 {
1788  return FALSE;
1789 }

Referenced by image_find_section().

◆ elf_get_map_rva()

DWORD_PTR elf_get_map_rva ( const struct image_section_map ism)

Definition at line 1804 of file elf_module.c.

1805 {
1806  return 0;
1807 }

Referenced by image_get_map_rva().

◆ elf_get_map_size()

unsigned elf_get_map_size ( const struct image_section_map ism)

Definition at line 1799 of file elf_module.c.

1800 {
1801  return 0;
1802 }

Referenced by image_get_map_size().

◆ elf_map_section()

const char* elf_map_section ( struct image_section_map ism)

Definition at line 1791 of file elf_module.c.

1792 {
1793  return NULL;
1794 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by image_map_section().

◆ elf_unmap_section()

void elf_unmap_section ( struct image_section_map ism)

Definition at line 1796 of file elf_module.c.

1797 {}

Referenced by image_unmap_section().

◆ image_find_section()

static BOOL image_find_section ( struct image_file_map fmap,
const char name,
struct image_section_map ism 
)
inlinestatic

Definition at line 178 of file image_private.h.

180 {
181  switch (fmap->modtype)
182  {
183 #ifndef DBGHELP_STATIC_LIB
184  case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism);
185  case DMT_MACHO: return macho_find_section(fmap, NULL, name, ism);
186 #endif
187  case DMT_PE: return pe_find_section(fmap, name, ism);
188  default: assert(0); return FALSE;
189  }
190 }
enum module_type modtype
Definition: image_private.h:89
#define SHT_NULL
Definition: image_private.h:80
BOOL macho_find_section(struct image_file_map *ifm, const char *segname, const char *sectname, struct image_section_map *ism) DECLSPEC_HIDDEN
BOOL elf_find_section(struct image_file_map *fmap, const char *name, unsigned sht, struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: elf_module.c:1785
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: pe_module.c:113
Definition: name.c:36

Referenced by dwarf2_init_section().

◆ image_get_map_rva()

static DWORD_PTR image_get_map_rva ( const struct image_section_map ism)
inlinestatic

Definition at line 220 of file image_private.h.

221 {
222  if (!ism->fmap) return 0;
223  switch (ism->fmap->modtype)
224  {
225 #ifndef DBGHELP_STATIC_LIB
226  case DMT_ELF: return elf_get_map_rva(ism);
227  case DMT_MACHO: return macho_get_map_rva(ism);
228 #endif
229  case DMT_PE: return pe_get_map_rva(ism);
230  default: assert(0); return 0;
231  }
232 }
struct image_file_map * fmap
#define assert(x)
Definition: debug.h:53
DWORD_PTR elf_get_map_rva(const struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: elf_module.c:1804
DWORD_PTR pe_get_map_rva(const struct image_section_map *psm) DECLSPEC_HIDDEN
Definition: pe_module.c:165
DWORD_PTR macho_get_map_rva(const struct image_section_map *ism) DECLSPEC_HIDDEN

Referenced by dwarf2_init_section().

◆ image_get_map_size()

static unsigned image_get_map_size ( const struct image_section_map ism)
inlinestatic

Definition at line 234 of file image_private.h.

235 {
236  if (!ism->fmap) return 0;
237  switch (ism->fmap->modtype)
238  {
239 #ifndef DBGHELP_STATIC_LIB
240  case DMT_ELF: return elf_get_map_size(ism);
241  case DMT_MACHO: return macho_get_map_size(ism);
242 #endif
243  case DMT_PE: return pe_get_map_size(ism);
244  default: assert(0); return 0;
245  }
246 }
struct image_file_map * fmap
#define assert(x)
Definition: debug.h:53
unsigned pe_get_map_size(const struct image_section_map *psm) DECLSPEC_HIDDEN
Definition: pe_module.c:177
unsigned elf_get_map_size(const struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: elf_module.c:1799
unsigned macho_get_map_size(const struct image_section_map *ism) DECLSPEC_HIDDEN

Referenced by dwarf2_init_section(), pe_load_rsym(), and pe_load_stabs().

◆ image_map_section()

static const char* image_map_section ( struct image_section_map ism)
inlinestatic

Definition at line 192 of file image_private.h.

193 {
194  if (!ism->fmap) return NULL;
195  switch (ism->fmap->modtype)
196  {
197 #ifndef DBGHELP_STATIC_LIB
198  case DMT_ELF: return elf_map_section(ism);
199  case DMT_MACHO: return macho_map_section(ism);
200 #endif
201  case DMT_PE: return pe_map_section(ism);
202  default: assert(0); return NULL;
203  }
204 }
const char * macho_map_section(struct image_section_map *ism) DECLSPEC_HIDDEN
struct image_file_map * fmap
#define assert(x)
Definition: debug.h:53
const char * elf_map_section(struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: elf_module.c:1791
smooth NULL
Definition: ftsmooth.c:416
const char * pe_map_section(struct image_section_map *psm) DECLSPEC_HIDDEN
Definition: pe_module.c:75

Referenced by dwarf2_init_section(), pe_load_rsym(), and pe_load_stabs().

◆ image_unmap_section()

static void image_unmap_section ( struct image_section_map ism)
inlinestatic

Definition at line 206 of file image_private.h.

207 {
208  if (!ism->fmap) return;
209  switch (ism->fmap->modtype)
210  {
211 #ifndef DBGHELP_STATIC_LIB
212  case DMT_ELF: elf_unmap_section(ism); break;
213  case DMT_MACHO: macho_unmap_section(ism); break;
214 #endif
215  case DMT_PE: pe_unmap_section(ism); break;
216  default: assert(0); return;
217  }
218 }
struct image_file_map * fmap
#define assert(x)
Definition: debug.h:53
void macho_unmap_section(struct image_section_map *ism) DECLSPEC_HIDDEN
void elf_unmap_section(struct image_section_map *ism) DECLSPEC_HIDDEN
Definition: elf_module.c:1796
void pe_unmap_section(struct image_section_map *psm) DECLSPEC_HIDDEN
Definition: pe_module.c:150

Referenced by dwarf2_parse(), pe_load_rsym(), and pe_load_stabs().

◆ macho_find_section()

BOOL macho_find_section ( struct image_file_map ifm,
const char segname,
const char sectname,
struct image_section_map ism 
)

Definition at line 1880 of file macho_module.c.

1881 {
1882  return FALSE;
1883 }

Referenced by image_find_section().

◆ macho_get_map_rva()

DWORD_PTR macho_get_map_rva ( const struct image_section_map ism)

Definition at line 1894 of file macho_module.c.

1895 {
1896  return 0;
1897 }

Referenced by image_get_map_rva().

◆ macho_get_map_size()

unsigned macho_get_map_size ( const struct image_section_map ism)

Definition at line 1899 of file macho_module.c.

1900 {
1901  return 0;
1902 }

Referenced by image_get_map_size().

◆ macho_map_section()

const char* macho_map_section ( struct image_section_map ism)

Definition at line 1885 of file macho_module.c.

1886 {
1887  return NULL;
1888 }
smooth NULL
Definition: ftsmooth.c:416

Referenced by image_map_section().

◆ macho_unmap_section()

void macho_unmap_section ( struct image_section_map ism)

Definition at line 1890 of file macho_module.c.

1891 {
1892 }

Referenced by image_unmap_section().

◆ pe_find_section()

BOOL pe_find_section ( struct image_file_map fmap,
const char name,
struct image_section_map ism 
)

Definition at line 113 of file pe_module.c.

115 {
116  const char* sectname;
117  unsigned i;
118  char tmp[IMAGE_SIZEOF_SHORT_NAME + 1];
119 
120  for (i = 0; i < fmap->u.pe.ntheader.FileHeader.NumberOfSections; i++)
121  {
122  sectname = (const char*)fmap->u.pe.sect[i].shdr.Name;
123  /* long section names start with a '/' (at least on MinGW32) */
124  if (sectname[0] == '/' && fmap->u.pe.strtable)
125  sectname = fmap->u.pe.strtable + atoi(sectname + 1);
126  else
127  {
128  /* the section name may not be null terminated */
129  sectname = memcpy(tmp, sectname, IMAGE_SIZEOF_SHORT_NAME);
130  tmp[IMAGE_SIZEOF_SHORT_NAME] = '\0';
131  }
132  if (!strcasecmp(sectname, name))
133  {
134  ism->fmap = fmap;
135  ism->sidx = i;
136  return TRUE;
137  }
138  }
139  ism->fmap = NULL;
140  ism->sidx = -1;
141 
142  return FALSE;
143 }
union image_file_map::@363 u
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
struct image_file_map * fmap
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
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct image_file_map::@363::pe_file_map pe
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:36

Referenced by image_find_section(), pe_load_rsym(), and pe_load_stabs().

◆ pe_get_map_rva()

DWORD_PTR pe_get_map_rva ( const struct image_section_map psm)

Definition at line 165 of file pe_module.c.

166 {
167  if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
168  return 0;
169  return ism->fmap->u.pe.sect[ism->sidx].shdr.VirtualAddress;
170 }

Referenced by image_get_map_rva().

◆ pe_get_map_size()

unsigned pe_get_map_size ( const struct image_section_map psm)

Definition at line 177 of file pe_module.c.

178 {
179  if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
180  return 0;
181  return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize;
182 }

Referenced by image_get_map_size().

◆ pe_map_section()

const char* pe_map_section ( struct image_section_map psm)

Definition at line 75 of file pe_module.c.

76 {
77  void* mapping;
78  struct pe_file_map* fmap = &ism->fmap->u.pe;
79 
80  if (ism->sidx >= 0 && ism->sidx < fmap->ntheader.FileHeader.NumberOfSections &&
81  fmap->sect[ism->sidx].mapped == IMAGE_NO_MAP)
82  {
83  IMAGE_NT_HEADERS* nth;
84 
85  if (fmap->sect[ism->sidx].shdr.Misc.VirtualSize > fmap->sect[ism->sidx].shdr.SizeOfRawData)
86  {
87  FIXME("Section %ld: virtual (0x%x) > raw (0x%x) size - not supported\n",
88  ism->sidx, fmap->sect[ism->sidx].shdr.Misc.VirtualSize,
89  fmap->sect[ism->sidx].shdr.SizeOfRawData);
90  return IMAGE_NO_MAP;
91  }
92  /* FIXME: that's rather drastic, but that will do for now
93  * that's ok if the full file map exists, but we could be less aggressive otherwise and
94  * only map the relevant section
95  */
96  if ((mapping = pe_map_full(ism->fmap, &nth)))
97  {
98  fmap->sect[ism->sidx].mapped = RtlImageRvaToVa(nth, mapping,
99  fmap->sect[ism->sidx].shdr.VirtualAddress,
100  NULL);
101  return fmap->sect[ism->sidx].mapped;
102  }
103  }
104  return IMAGE_NO_MAP;
105 }
#define RtlImageRvaToVa
Definition: compat.h:458
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
#define IMAGE_NO_MAP
Definition: image_private.h:59
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031

Referenced by image_map_section().

◆ pe_unmap_section()

void pe_unmap_section ( struct image_section_map psm)

Definition at line 150 of file pe_module.c.

151 {
152  if (ism->sidx >= 0 && ism->sidx < ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections &&
153  ism->fmap->u.pe.sect[ism->sidx].mapped != IMAGE_NO_MAP)
154  {
155  pe_unmap_full(ism->fmap);
156  ism->fmap->u.pe.sect[ism->sidx].mapped = IMAGE_NO_MAP;
157  }
158 }
#define IMAGE_NO_MAP
Definition: image_private.h:59
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:61

Referenced by image_unmap_section(), and pe_unmap_file().