ReactOS  0.4.15-dev-5606-gf34e425
pe_module.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "dbghelp_private.h"
#include "image_private.h"
#include "winternl.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for pe_module.c:

Go to the source code of this file.

Classes

struct  pe_module_info
 
struct  builtin_search
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dbghelp)
 
static voidpe_map_full (struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
 
static void pe_unmap_full (struct image_file_map *fmap)
 
static const charpe_map_section (struct image_section_map *ism)
 
static BOOL pe_find_section (struct image_file_map *fmap, const char *name, struct image_section_map *ism)
 
static void pe_unmap_section (struct image_section_map *ism)
 
static DWORD_PTR pe_get_map_rva (const struct image_section_map *ism)
 
static unsigned pe_get_map_size (const struct image_section_map *ism)
 
static void pe_unmap_file (struct image_file_map *fmap)
 
static BOOL pe_is_valid_pointer_table (const IMAGE_NT_HEADERS *nthdr, const void *mapping, DWORD64 sz)
 
BOOL pe_map_file (HANDLE file, struct image_file_map *fmap, enum module_type mt)
 
const charpe_map_directory (struct module *module, int dirno, DWORD *size)
 
static void pe_module_remove (struct process *pcs, struct module_format *modfmt)
 
static BOOL pe_locate_with_coff_symbol_table (struct module *module)
 
static BOOL pe_load_coff_symbol_table (struct module *module)
 
static BOOL pe_load_stabs (const struct process *pcs, struct module *module)
 
static BOOL pe_load_dwarf (struct module *module)
 
static BOOL pe_load_rsym (struct module *module)
 
static BOOL pe_load_dbg_file (const struct process *pcs, struct module *module, const char *dbg_name, DWORD timestamp)
 
static BOOL pe_load_msc_debug_info (const struct process *pcs, struct module *module)
 
static BOOL pe_load_export_debug_info (const struct process *pcs, struct module *module)
 
BOOL pe_load_debug_info (const struct process *pcs, struct module *module)
 
static BOOL search_builtin_pe (void *param, HANDLE handle, const WCHAR *path)
 
struct modulepe_load_native_module (struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size)
 
BOOL pe_load_nt_header (HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth)
 
struct modulepe_load_builtin_module (struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size)
 
PVOID WINAPI ImageDirectoryEntryToDataEx (PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section)
 
PVOID WINAPI ImageDirectoryEntryToData (PVOID base, BOOLEAN image, USHORT dir, PULONG size)
 

Variables

static const char builtin_signature [] = "Wine builtin DLL"
 
static const struct image_file_map_ops pe_file_map_ops
 

Function Documentation

◆ ImageDirectoryEntryToData()

PVOID WINAPI ImageDirectoryEntryToData ( PVOID  base,
BOOLEAN  image,
USHORT  dir,
PULONG  size 
)

Definition at line 972 of file pe_module.c.

973 {
975 }
PVOID WINAPI ImageDirectoryEntryToDataEx(PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section)
Definition: pe_module.c:934
unsigned int dir
Definition: maze.c:112
GLsizeiptr size
Definition: glext.h:5919
#define NULL
Definition: types.h:112

Referenced by GetExportsFromFile().

◆ ImageDirectoryEntryToDataEx()

PVOID WINAPI ImageDirectoryEntryToDataEx ( PVOID  base,
BOOLEAN  image,
USHORT  dir,
PULONG  size,
PIMAGE_SECTION_HEADER section 
)

Definition at line 934 of file pe_module.c.

935 {
936  const IMAGE_NT_HEADERS *nt;
937  DWORD addr;
938 
939  *size = 0;
940  if (section) *section = NULL;
941 
942  if (!(nt = RtlImageNtHeader( base ))) return NULL;
944  {
945  const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt;
946 
947  if (dir >= nt64->OptionalHeader.NumberOfRvaAndSizes) return NULL;
948  if (!(addr = nt64->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
950  if (image || addr < nt64->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
951  }
953  {
954  const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt;
955 
956  if (dir >= nt32->OptionalHeader.NumberOfRvaAndSizes) return NULL;
957  if (!(addr = nt32->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
959  if (image || addr < nt32->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
960  }
961  else return NULL;
962 
963  return RtlImageRvaToVa( nt, base, addr, section );
964 }
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
#define RtlImageRvaToVa
Definition: compat.h:807
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
Definition: parser.c:55
IMAGE_NT_HEADERS nt
Definition: module.c:50
unsigned int dir
Definition: maze.c:112
IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: ntimage.h:396
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
GLenum const GLvoid * addr
Definition: glext.h:9621
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define NULL
Definition: types.h:112
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntimage.h:370
#define RtlImageNtHeader
Definition: compat.h:806

Referenced by ImageDirectoryEntryToData().

◆ pe_find_section()

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

Definition at line 117 of file pe_module.c.

119 {
120  const char* sectname;
121  unsigned i;
122  char tmp[IMAGE_SIZEOF_SHORT_NAME + 1];
123 
124  for (i = 0; i < fmap->u.pe.ntheader.FileHeader.NumberOfSections; i++)
125  {
126  sectname = (const char*)fmap->u.pe.sect[i].shdr.Name;
127  /* long section names start with a '/' (at least on MinGW32) */
128  if (sectname[0] == '/' && fmap->u.pe.strtable)
129  sectname = fmap->u.pe.strtable + atoi(sectname + 1);
130  else
131  {
132  /* the section name may not be null terminated */
133  sectname = memcpy(tmp, sectname, IMAGE_SIZEOF_SHORT_NAME);
134  tmp[IMAGE_SIZEOF_SHORT_NAME] = '\0';
135  }
136  if (!stricmp(sectname, name))
137  {
138  ism->fmap = fmap;
139  ism->sidx = i;
140  return TRUE;
141  }
142  }
143  ism->fmap = NULL;
144  ism->sidx = -1;
145 
146  return FALSE;
147 }
#define TRUE
Definition: types.h:120
struct image_file_map * fmap
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define FALSE
Definition: types.h:117
union image_file_map::@373 u
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
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
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:38

Referenced by pe_load_rsym(), and pe_load_stabs().

◆ pe_get_map_rva()

static DWORD_PTR pe_get_map_rva ( const struct image_section_map ism)
static

Definition at line 169 of file pe_module.c.

170 {
171  if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
172  return 0;
173  return ism->fmap->u.pe.sect[ism->sidx].shdr.VirtualAddress;
174 }
struct image_file_map * fmap

◆ pe_get_map_size()

static unsigned pe_get_map_size ( const struct image_section_map ism)
static

Definition at line 181 of file pe_module.c.

182 {
183  if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
184  return 0;
185  return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize;
186 }
struct image_file_map * fmap

◆ pe_is_valid_pointer_table()

static BOOL pe_is_valid_pointer_table ( const IMAGE_NT_HEADERS nthdr,
const void mapping,
DWORD64  sz 
)
static

Definition at line 227 of file pe_module.c.

228 {
229  DWORD64 offset;
230 
231  /* is the iSym table inside file size ? (including first DWORD of string table, which is its size) */
234  if (offset + sizeof(DWORD) > sz) return FALSE;
235  /* is string table (following iSym table) inside file size ? */
236  offset += *(DWORD*)((const char*)mapping + offset);
237  return offset <= sz;
238 }
#define FALSE
Definition: types.h:117
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
struct _IMAGE_SYMBOL IMAGE_SYMBOL
DWORD NumberOfSymbols
Definition: ntddk_ex.h:126
GLintptr offset
Definition: glext.h:5920
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
uint64_t DWORD64
Definition: typedefs.h:67
DWORD PointerToSymbolTable
Definition: ntddk_ex.h:125

Referenced by pe_map_file().

◆ pe_load_builtin_module()

struct module* pe_load_builtin_module ( struct process pcs,
const WCHAR name,
DWORD64  base,
DWORD64  size 
)

Definition at line 896 of file pe_module.c.

898 {
899  struct module* module = NULL;
900 
901  if (base && pcs->dbg_hdr_addr)
902  {
903  IMAGE_NT_HEADERS nth;
904 
905  if (pe_load_nt_header(pcs->handle, base, &nth))
906  {
907  if (!size) size = nth.OptionalHeader.SizeOfImage;
911  }
912  }
913  return module;
914 }
HMODULE module
Definition: main.cpp:47
#define FALSE
Definition: types.h:117
ULONG_PTR dbg_hdr_addr
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth)
Definition: pe_module.c:881
GLsizeiptr size
Definition: glext.h:5919
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define NULL
Definition: types.h:112
Definition: name.c:38
HANDLE handle
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN
Definition: module.c:198

Referenced by SymLoadModuleExW().

◆ pe_load_coff_symbol_table()

static BOOL pe_load_coff_symbol_table ( struct module module)
static

Definition at line 420 of file pe_module.c.

421 {
422  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
423  const IMAGE_SYMBOL* isym;
424  int i, numsym, naux;
425  const char* strtable;
426  char tmp[9];
427  const char* name;
428  const char* lastfilename = NULL;
429  struct symt_compiland* compiland = NULL;
430  const IMAGE_SECTION_HEADER* sect;
431  const char* mapping;
432 
433  numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
434  if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
435  return TRUE;
436  if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
437  isym = (const IMAGE_SYMBOL*)((const char*)mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
438  /* FIXME: no way to get strtable size */
439  strtable = (const char*)&isym[numsym];
441 
442  for (i = 0; i < numsym; i+= naux, isym += naux)
443  {
444  if (isym->StorageClass == IMAGE_SYM_CLASS_FILE)
445  {
446  lastfilename = (const char*)(isym + 1);
447  compiland = NULL;
448  }
449  if (isym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL &&
450  isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
451  {
452  if (isym->N.Name.Short)
453  {
454  name = memcpy(tmp, isym->N.ShortName, 8);
455  tmp[8] = '\0';
456  }
457  else name = strtable + isym->N.Name.Long;
458  if (name[0] == '_') name++;
459 
460  if (!compiland && lastfilename)
461  compiland = symt_new_compiland(module, 0,
462  source_new(module, NULL, lastfilename));
463 
465  symt_new_public(module, compiland, name, FALSE,
466  module->module.BaseOfImage + sect[isym->SectionNumber - 1].VirtualAddress +
467  isym->Value,
468  1);
469  }
470  naux = isym->NumberOfAuxSymbols + 1;
471  }
478  pe_unmap_full(fmap);
479 
480  return TRUE;
481 }
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:1070
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
#define FALSE
Definition: types.h:117
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
union image_file_map::@373 u
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define IMAGE_SYM_CLASS_FILE
Definition: compat.h:150
SYM_TYPE SymType
Definition: compat.h:1075
struct symt_public * symt_new_public(struct module *module, struct symt_compiland *parent, const char *typename, BOOL is_function, ULONG_PTR address, unsigned size) DECLSPEC_HIDDEN
Definition: symbol.c:224
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
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
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
unsigned dbghelp_options
Definition: dbghelp.c:73
#define RtlImageNtHeader
Definition: compat.h:806
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
Definition: name.c:38
#define SYMOPT_NO_PUBLICS
Definition: compat.h:993
const char * strtable
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
#define IMAGE_SYM_CLASS_EXTERNAL
Definition: compat.h:149
struct symt_compiland * symt_new_compiland(struct module *module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN
Definition: symbol.c:207
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by pe_load_debug_info().

◆ pe_load_dbg_file()

static BOOL pe_load_dbg_file ( const struct process pcs,
struct module module,
const char dbg_name,
DWORD  timestamp 
)
static

Definition at line 571 of file pe_module.c.

573 {
574  WCHAR tmp[MAX_PATH];
575  HANDLE hFile = INVALID_HANDLE_VALUE, hMap = 0;
576  const BYTE* dbg_mapping = NULL;
577  BOOL ret = FALSE;
578 
579  TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
580 
581  if (path_find_symbol_file(pcs, module, dbg_name, DMT_DBG, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
584  ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
585  ((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
586  {
588  const IMAGE_SECTION_HEADER* sectp;
589  const IMAGE_DEBUG_DIRECTORY* dbg;
590 
591  hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping;
592  /* section headers come immediately after debug header */
593  sectp = (const IMAGE_SECTION_HEADER*)(hdr + 1);
594  /* and after that and the exported names comes the debug directory */
595  dbg = (const IMAGE_DEBUG_DIRECTORY*)
596  (dbg_mapping + sizeof(*hdr) +
597  hdr->NumberOfSections * sizeof(IMAGE_SECTION_HEADER) +
598  hdr->ExportedNamesSize);
599 
600  ret = pe_load_debug_directory(pcs, module, dbg_mapping, sectp,
601  hdr->NumberOfSections, dbg,
602  hdr->DebugDirectorySize / sizeof(*dbg));
603  }
604  else
605  ERR("Couldn't find .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_w(tmp));
606 
607  if (dbg_mapping) UnmapViewOfFile(dbg_mapping);
608  if (hMap) CloseHandle(hMap);
610  return ret;
611 }
BOOL pe_load_debug_directory(const struct process *pcs, struct module *module, const BYTE *mapping, const IMAGE_SECTION_HEADER *sectp, DWORD nsect, const IMAGE_DEBUG_DIRECTORY *dbg, int nDbg) DECLSPEC_HIDDEN
Definition: msc.c:3391
#define CloseHandle
Definition: compat.h:739
char hdr[14]
Definition: iptest.cpp:33
#define MapViewOfFile
Definition: compat.h:745
struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FILE_SHARE_READ
Definition: compat.h:136
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FILE_MAP_READ
Definition: compat.h:776
#define OPEN_EXISTING
Definition: compat.h:775
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define MAX_PATH
Definition: compat.h:34
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
_In_ HANDLE hFile
Definition: mswsock.h:90
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
BOOL path_find_symbol_file(const struct process *pcs, const struct module *module, PCSTR full_path, enum module_type type, const GUID *guid, DWORD dw1, DWORD dw2, WCHAR *buffer, BOOL *is_unmatched) DECLSPEC_HIDDEN
Definition: path.c:596
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
#define CreateFileW
Definition: compat.h:741
#define UnmapViewOfFile
Definition: compat.h:746
IMAGEHLP_MODULEW64 module

Referenced by pe_load_msc_debug_info().

◆ pe_load_debug_info()

BOOL pe_load_debug_info ( const struct process pcs,
struct module module 
)

Definition at line 751 of file pe_module.c.

752 {
753  BOOL ret = FALSE;
754 
756  {
757  ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module);
758  ret = pe_load_stabs(pcs, module) || ret;
759  ret = pe_load_dwarf(module) || ret;
760  #ifndef DBGHELP_STATIC_LIB
762  ret = pe_load_rsym(module) || ret;
763  #endif
764 
765  ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
766  /* if we still have no debug info (we could only get SymExport at this
767  * point), then do the SymExport except if we have an ELF container,
768  * in which case we'll rely on the export's on the ELF side
769  */
770  }
771  /* FIXME shouldn't we check that? if (!module_get_debug(pcs, module)) */
772  if (pe_load_export_debug_info(pcs, module) && !ret)
773  ret = TRUE;
774 
775  return ret;
776 }
#define TRUE
Definition: types.h:120
BOOL image_check_alternate(struct image_file_map *fmap, const struct module *module) DECLSPEC_HIDDEN
Definition: module.c:701
static BOOL pe_load_dwarf(struct module *module)
Definition: pe_module.c:525
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL pe_load_export_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:666
int ret
static BOOL pe_load_rsym(struct module *module)
Definition: pe_module.c:545
static BOOL pe_load_msc_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:618
static BOOL pe_load_coff_symbol_table(struct module *module)
Definition: pe_module.c:420
unsigned dbghelp_options
Definition: dbghelp.c:73
#define SYMOPT_PUBLICS_ONLY
Definition: compat.h:992
static BOOL pe_load_stabs(const struct process *pcs, struct module *module)
Definition: pe_module.c:489
struct module_format * format_info[DFI_LAST]

Referenced by module_get_debug(), and pe_load_native_module().

◆ pe_load_dwarf()

static BOOL pe_load_dwarf ( struct module module)
static

Definition at line 525 of file pe_module.c.

526 {
527  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
528  BOOL ret;
529 
531  module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
532  NULL, /* FIXME: some thunks to deal with ? */
533  fmap);
534  TRACE("%s the DWARF debug info\n", ret ? "successfully loaded" : "failed to load");
535 
536  return ret;
537 }
DWORD64 BaseOfImage
Definition: compat.h:1070
unsigned int BOOL
Definition: ntddk_ex.h:94
union image_file_map::@373 u
#define TRACE(s)
Definition: solgame.cpp:4
BOOL dwarf2_parse(struct module *module, ULONG_PTR load_offset, const struct elf_thunk_area *thunks, struct image_file_map *fmap) DECLSPEC_HIDDEN
Definition: dwarf.c:3509
int ret
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]

Referenced by pe_load_debug_info().

◆ pe_load_export_debug_info()

static BOOL pe_load_export_debug_info ( const struct process pcs,
struct module module 
)
static

Definition at line 666 of file pe_module.c.

667 {
668  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
669  unsigned int i;
670  const IMAGE_EXPORT_DIRECTORY* exports;
672  DWORD size;
673  IMAGE_NT_HEADERS* nth;
674  void* mapping;
675 
676  if (dbghelp_options & SYMOPT_NO_PUBLICS) return TRUE;
677 
678  if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
679 #if 0
680  /* Add start of DLL (better use the (yet unimplemented) Exe SymTag for this) */
681  /* FIXME: module.ModuleName isn't correctly set yet if it's passed in SymLoadModule */
683 #endif
684 
685  /* Add entry point */
686  symt_new_public(module, NULL, "EntryPoint", FALSE,
688 #if 0
689  /* FIXME: we'd better store addresses linked to sections rather than
690  absolute values */
692  /* Add start of sections */
694  ((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
695  for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++)
696  {
698  RtlImageRvaToVa(nth, mapping, section->VirtualAddress, NULL), 1);
699  }
700 #endif
701 
702  /* Add exported functions */
705  {
706  const WORD* ordinals = NULL;
707  const DWORD_PTR* functions = NULL;
708  const DWORD* names = NULL;
709  unsigned int j;
710  char buffer[16];
711 
712  functions = RtlImageRvaToVa(nth, mapping, exports->AddressOfFunctions, NULL);
713  ordinals = RtlImageRvaToVa(nth, mapping, exports->AddressOfNameOrdinals, NULL);
714  names = RtlImageRvaToVa(nth, mapping, exports->AddressOfNames, NULL);
715 
716  if (functions && ordinals && names)
717  {
718  for (i = 0; i < exports->NumberOfNames; i++)
719  {
720  if (!names[i]) continue;
723  FALSE,
724  base + functions[ordinals[i]], 1);
725  }
726 
727  for (i = 0; i < exports->NumberOfFunctions; i++)
728  {
729  if (!functions[i]) continue;
730  /* Check if we already added it with a name */
731  for (j = 0; j < exports->NumberOfNames; j++)
732  if ((ordinals[j] == i) && names[j]) break;
733  if (j < exports->NumberOfNames) continue;
734  snprintf(buffer, sizeof(buffer), "%d", i + exports->Base);
735  symt_new_public(module, NULL, buffer, FALSE, base + (DWORD)functions[i], 1);
736  }
737  }
738  }
739  /* no real debug info, only entry points */
742  pe_unmap_full(fmap);
743 
744  return TRUE;
745 }
WCHAR ModuleName[32]
Definition: compat.h:1076
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:1070
#define RtlImageRvaToVa
Definition: compat.h:807
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
DWORD AddressOfNameOrdinals
Definition: compat.h:167
GLuint GLuint * names
Definition: glext.h:11545
#define FALSE
Definition: types.h:117
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
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 GLint GLint j
Definition: glfuncs.h:250
GLsizeiptr size
Definition: glext.h:5919
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
SYM_TYPE SymType
Definition: compat.h:1075
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
struct symt_public * symt_new_public(struct module *module, struct symt_compiland *parent, const char *typename, BOOL is_function, ULONG_PTR address, unsigned size) DECLSPEC_HIDDEN
Definition: symbol.c:224
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
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
#define NULL
Definition: types.h:112
unsigned dbghelp_options
Definition: dbghelp.c:73
#define SYMOPT_NO_PUBLICS
Definition: compat.h:993
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]

Referenced by pe_load_debug_info().

◆ pe_load_msc_debug_info()

static BOOL pe_load_msc_debug_info ( const struct process pcs,
struct module module 
)
static

Definition at line 618 of file pe_module.c.

619 {
620  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
621  BOOL ret = FALSE;
622  const IMAGE_DEBUG_DIRECTORY*dbg;
623  ULONG nDbg;
624  void* mapping;
625  IMAGE_NT_HEADERS* nth;
626 
627  if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
628  /* Read in debug directory */
630  if (!dbg || !(nDbg /= sizeof(IMAGE_DEBUG_DIRECTORY))) goto done;
631 
632  /* Parse debug directory */
634  {
635  /* Debug info is stripped to .DBG file */
636  const IMAGE_DEBUG_MISC* misc = (const IMAGE_DEBUG_MISC*)
637  ((const char*)mapping + dbg->PointerToRawData);
638 
639  if (nDbg != 1 || dbg->Type != IMAGE_DEBUG_TYPE_MISC ||
641  {
642  ERR("-Debug info stripped, but no .DBG file in module %s\n",
644  }
645  else
646  {
647  ret = pe_load_dbg_file(pcs, module, (const char*)misc->Data, nth->FileHeader.TimeDateStamp);
648  }
649  }
650  else
651  {
652  const IMAGE_SECTION_HEADER *sectp = (const IMAGE_SECTION_HEADER*)((const char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
653  /* Debug info is embedded into PE module */
654  ret = pe_load_debug_directory(pcs, module, mapping, sectp,
655  nth->FileHeader.NumberOfSections, dbg, nDbg);
656  }
657 done:
658  pe_unmap_full(fmap);
659  return ret;
660 }
BOOL pe_load_debug_directory(const struct process *pcs, struct module *module, const BYTE *mapping, const IMAGE_SECTION_HEADER *sectp, DWORD nsect, const IMAGE_DEBUG_DIRECTORY *dbg, int nDbg) DECLSPEC_HIDDEN
Definition: msc.c:3391
WCHAR ModuleName[32]
Definition: compat.h:1076
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
#define FALSE
Definition: types.h:117
DWORD DataType
Definition: compat.h:170
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
#define IMAGE_DEBUG_MISC_EXENAME
Definition: compat.h:154
#define IMAGE_FILE_DEBUG_STRIPPED
Definition: pedump.c:165
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static BOOL pe_load_dbg_file(const struct process *pcs, struct module *module, const char *dbg_name, DWORD timestamp)
Definition: pe_module.c:571
int ret
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define ERR(fmt,...)
Definition: debug.h:110
#define IMAGE_DIRECTORY_ENTRY_DEBUG
Definition: compat.h:152
unsigned int ULONG
Definition: retypes.h:1
#define IMAGE_DEBUG_TYPE_MISC
Definition: compat.h:144
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
BYTE Data[1]
Definition: compat.h:174

Referenced by pe_load_debug_info().

◆ pe_load_native_module()

struct module* pe_load_native_module ( struct process pcs,
const WCHAR name,
HANDLE  hFile,
DWORD64  base,
DWORD  size 
)

Definition at line 803 of file pe_module.c.

805 {
806  struct module* module = NULL;
807  BOOL opened = FALSE;
808  struct module_format* modfmt;
809  WCHAR loaded_name[MAX_PATH];
810 
811  loaded_name[0] = '\0';
812  if (!hFile)
813  {
814  assert(name);
815 
816  if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL)
817  return NULL;
818  opened = TRUE;
819  }
820  else if (name) lstrcpyW(loaded_name, name);
822  FIXME("Trouble ahead (no module name passed in deferred mode)\n");
823  if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct pe_module_info))))
824  return NULL;
825  modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1);
826  if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE))
827  {
828 #ifndef __REACTOS__
829  struct builtin_search builtin = { NULL };
830  if (modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(pcs, loaded_name, search_builtin_pe, &builtin))
831  {
832  TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path));
833  image_unmap_file(&modfmt->u.pe_info->fmap);
834  modfmt->u.pe_info->fmap = builtin.fmap;
835  }
836 #endif
837  if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
838  if (!size) size = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.SizeOfImage;
839 
840  module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
841  modfmt->u.pe_info->fmap.u.pe.ntheader.FileHeader.TimeDateStamp,
842  modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.CheckSum);
843  if (module)
844  {
845 #ifdef __REACTOS__
846  module->real_path = NULL;
847 #else
848  module->real_path = builtin.path;
849 #endif
850  modfmt->module = module;
851  modfmt->remove = pe_module_remove;
852  modfmt->loc_compute = NULL;
853 
854  module->format_info[DFI_PE] = modfmt;
857  else
859  module->reloc_delta = base - modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
860  }
861  else
862  {
863  ERR("could not load the module '%s'\n", debugstr_w(loaded_name));
864 #ifndef __REACTOS__
865  heap_free(builtin.path);
866 #endif
867  image_unmap_file(&modfmt->u.pe_info->fmap);
868  }
869  }
870  if (!module) HeapFree(GetProcessHeap(), 0, modfmt);
871 
872  if (opened) CloseHandle(hFile);
873 
874  return module;
875 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
WCHAR * search_path
#define CloseHandle
Definition: compat.h:739
HMODULE module
Definition: main.cpp:47
WCHAR * real_path
#define TRUE
Definition: types.h:120
BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL(*match)(void *, HANDLE, const WCHAR *), void *param) DECLSPEC_HIDDEN
Definition: path.c:695
#define assert(x)
Definition: debug.h:53
WCHAR * path
Definition: pe_module.c:781
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:989
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
BOOL pe_load_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:751
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL search_builtin_pe(void *param, HANDLE handle, const WCHAR *path)
Definition: pe_module.c:785
#define FindExecutableImageExW
Definition: compat.h:1141
#define MAX_PATH
Definition: compat.h:34
union module_format::@362 u
static void image_unmap_file(struct image_file_map *fmap)
static void pe_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: pe_module.c:345
SYM_TYPE SymType
Definition: compat.h:1075
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERR(fmt,...)
Definition: debug.h:110
#define lstrcpyW
Definition: compat.h:749
#define NULL
Definition: types.h:112
unsigned dbghelp_options
Definition: dbghelp.c:73
struct module * module
struct image_file_map fmap
Definition: pe_module.c:782
Definition: name.c:38
struct module * module_new(struct process *pcs, const WCHAR *name, enum module_type type, BOOL virtual, DWORD64 addr, DWORD64 size, ULONG_PTR stamp, ULONG_PTR checksum) DECLSPEC_HIDDEN
Definition: module.c:198
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:245
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
struct pe_module_info * pe_info

Referenced by SymLoadModuleExW().

◆ pe_load_nt_header()

BOOL pe_load_nt_header ( HANDLE  hProc,
DWORD64  base,
IMAGE_NT_HEADERS nth 
)

Definition at line 881 of file pe_module.c.

882 {
884 
885  return ReadProcessMemory(hProc, (char*)(DWORD_PTR)base, &dos, sizeof(dos), NULL) &&
887  ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew),
888  nth, sizeof(*nth), NULL) &&
890 }
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
IMAGE_DOS_HEADER dos
Definition: module.c:49
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define NULL
Definition: types.h:112

Referenced by fetch_pe_module_info_cb(), and pe_load_builtin_module().

◆ pe_load_rsym()

static BOOL pe_load_rsym ( struct module module)
static

Definition at line 545 of file pe_module.c.

546 {
547  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
548  struct image_section_map sect_rsym;
549  BOOL ret = FALSE;
550 
551  if (pe_find_section(fmap, ".rossym", &sect_rsym))
552  {
553  const char* rsym = image_map_section(&sect_rsym);
554  if (rsym != IMAGE_NO_MAP)
555  {
557  rsym, image_get_map_size(&sect_rsym));
558  }
559  image_unmap_section(&sect_rsym);
560  }
561  TRACE("%s the RSYM debug info\n", ret ? "successfully loaded" : "failed to load");
562 
563  return ret;
564 }
DWORD64 BaseOfImage
Definition: compat.h:1070
struct image_file_map * fmap
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
Definition: pe_module.c:117
BOOL rsym_parse(struct module *module, unsigned long load_offset, const void *rsym, int rsymlen) DECLSPEC_HIDDEN
Definition: rsym.c:79
#define TRACE(s)
Definition: solgame.cpp:4
static unsigned image_get_map_size(const struct image_section_map *ism)
int ret
static void image_unmap_section(struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]

Referenced by pe_load_debug_info().

◆ pe_load_stabs()

static BOOL pe_load_stabs ( const struct process pcs,
struct module module 
)
static

Definition at line 489 of file pe_module.c.

490 {
491  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
492  struct image_section_map sect_stabs, sect_stabstr;
493  BOOL ret = FALSE;
494 
495  if (pe_find_section(fmap, ".stab", &sect_stabs) && pe_find_section(fmap, ".stabstr", &sect_stabstr))
496  {
497  const char* stab;
498  const char* stabstr;
499 
500  stab = image_map_section(&sect_stabs);
501  stabstr = image_map_section(&sect_stabstr);
502  if (stab != IMAGE_NO_MAP && stabstr != IMAGE_NO_MAP)
503  {
505  module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
506  stab, image_get_map_size(&sect_stabs) / sizeof(struct stab_nlist), sizeof(struct stab_nlist),
507  stabstr, image_get_map_size(&sect_stabstr),
508  NULL, NULL);
509  }
510  image_unmap_section(&sect_stabs);
511  image_unmap_section(&sect_stabstr);
513  }
514  TRACE("%s the STABS debug info\n", ret ? "successfully loaded" : "failed to load");
515 
516  return ret;
517 }
DWORD64 BaseOfImage
Definition: compat.h:1070
struct image_file_map * fmap
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
Definition: pe_module.c:117
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL pe_locate_with_coff_symbol_table(struct module *module)
Definition: pe_module.c:359
static unsigned image_get_map_size(const struct image_section_map *ism)
int ret
static void image_unmap_section(struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
#define NULL
Definition: types.h:112
BOOL stabs_parse(struct module *module, ULONG_PTR load_offset, const char *stabs, size_t nstab, size_t stabsize, const char *strs, int strtablen, stabs_def_cb callback, void *user) DECLSPEC_HIDDEN
Definition: stabs.c:1241
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]

Referenced by pe_load_debug_info().

◆ pe_locate_with_coff_symbol_table()

static BOOL pe_locate_with_coff_symbol_table ( struct module module)
static

Definition at line 359 of file pe_module.c.

360 {
361  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
362  const IMAGE_SYMBOL* isym;
363  int i, numsym, naux;
364  char tmp[9];
365  const char* name;
366  struct hash_table_iter hti;
367  void* ptr;
368  struct symt_data* sym;
369  const char* mapping;
370 
371  numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
372  if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
373  return TRUE;
374  if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
375  isym = (const IMAGE_SYMBOL*)(mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
376 
377  for (i = 0; i < numsym; i+= naux, isym += naux)
378  {
379  if (isym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL &&
380  isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
381  {
382  if (isym->N.Name.Short)
383  {
384  name = memcpy(tmp, isym->N.ShortName, 8);
385  tmp[8] = '\0';
386  }
387  else name = fmap->u.pe.strtable + isym->N.Name.Long;
388  if (name[0] == '_') name++;
390  while ((ptr = hash_table_iter_up(&hti)))
391  {
392  sym = CONTAINING_RECORD(ptr, struct symt_data, hash_elt);
393  if (sym->symt.tag == SymTagData &&
394  (sym->kind == DataIsGlobal || sym->kind == DataIsFileStatic) &&
395  sym->u.var.kind == loc_absolute &&
396  !strcmp(sym->hash_elt.name, name))
397  {
398  TRACE("Changing absolute address for %d.%s: %lx -> %s\n",
399  isym->SectionNumber, name, sym->u.var.offset,
401  fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress +
402  isym->Value));
403  sym->u.var.offset = module->module.BaseOfImage +
404  fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress + isym->Value;
405  break;
406  }
407  }
408  }
409  naux = isym->NumberOfAuxSymbols + 1;
410  }
411  pe_unmap_full(fmap);
412  return TRUE;
413 }
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:1070
union symt_data::@360 u
struct hash_table ht_symbols
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
enum DataKind kind
#define FALSE
Definition: types.h:117
static PVOID ptr
Definition: dispmode.c:27
void hash_table_iter_init(const struct hash_table *ht, struct hash_table_iter *hti, const char *name) DECLSPEC_HIDDEN
Definition: storage.c:405
struct symt symt
union image_file_map::@373 u
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TRACE(s)
Definition: solgame.cpp:4
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
struct location var
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void * hash_table_iter_up(struct hash_table_iter *hti) DECLSPEC_HIDDEN
Definition: storage.c:422
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
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
struct hash_table_elt hash_elt
Definition: name.c:38
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
#define IMAGE_SYM_CLASS_EXTERNAL
Definition: compat.h:149
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by pe_load_stabs().

◆ pe_map_directory()

const char* pe_map_directory ( struct module module,
int  dirno,
DWORD size 
)

Definition at line 331 of file pe_module.c.

332 {
333  IMAGE_NT_HEADERS* nth;
334  void* mapping;
335 
336  if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
337  if (dirno >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ||
338  !(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
339  return NULL;
340  if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
341  return RtlImageRvaToVa(nth, mapping,
343 }
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES
Definition: ntddk_ex.h:135
#define RtlImageRvaToVa
Definition: compat.h:807
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
enum module_type type
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define NULL
Definition: types.h:112
struct module_format * format_info[DFI_LAST]

Referenced by x86_64_fetch_minidump_module(), and x86_64_find_runtime_function().

◆ pe_map_file()

BOOL pe_map_file ( HANDLE  file,
struct image_file_map fmap,
enum module_type  mt 
)

Definition at line 245 of file pe_module.c.

246 {
247  void* mapping;
248 
249  fmap->modtype = mt;
250  fmap->ops = &pe_file_map_ops;
251  fmap->alternate = NULL;
252  fmap->u.pe.hMap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
253  if (fmap->u.pe.hMap == 0) return FALSE;
254  fmap->u.pe.full_count = 0;
255  fmap->u.pe.full_map = NULL;
256  if (!(mapping = pe_map_full(fmap, NULL))) goto error;
257 
258  switch (mt)
259  {
260  case DMT_PE:
261  {
262  IMAGE_NT_HEADERS* nthdr;
264  unsigned i;
265 
266  if (!(nthdr = RtlImageNtHeader(mapping))) goto error;
267  memcpy(&fmap->u.pe.ntheader, nthdr, sizeof(fmap->u.pe.ntheader));
268  switch (nthdr->OptionalHeader.Magic)
269  {
270  case 0x10b: fmap->addr_size = 32; break;
271  case 0x20b: fmap->addr_size = 64; break;
272  default: return FALSE;
273  }
274 
275  fmap->u.pe.builtin = !memcmp((const IMAGE_DOS_HEADER*)mapping + 1, builtin_signature, sizeof(builtin_signature));
277  ((char*)&nthdr->OptionalHeader + nthdr->FileHeader.SizeOfOptionalHeader);
278  fmap->u.pe.sect = HeapAlloc(GetProcessHeap(), 0,
279  nthdr->FileHeader.NumberOfSections * sizeof(fmap->u.pe.sect[0]));
280  if (!fmap->u.pe.sect) goto error;
281  for (i = 0; i < nthdr->FileHeader.NumberOfSections; i++)
282  {
283  memcpy(&fmap->u.pe.sect[i].shdr, section + i, sizeof(IMAGE_SECTION_HEADER));
284  fmap->u.pe.sect[i].mapped = IMAGE_NO_MAP;
285  }
287  {
289 
291  {
292  /* FIXME ugly: should rather map the relevant content instead of copying it */
293  const char* src = (const char*)mapping +
295  nthdr->FileHeader.NumberOfSymbols * sizeof(IMAGE_SYMBOL);
296  char* dst;
297  DWORD sz = *(DWORD*)src;
298 
299  if ((dst = HeapAlloc(GetProcessHeap(), 0, sz)))
300  memcpy(dst, src, sz);
301  fmap->u.pe.strtable = dst;
302  }
303  else
304  {
305  WARN("Bad coff table... wipping out\n");
306  /* we have bad information here, wipe it out */
307  fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable = 0;
308  fmap->u.pe.ntheader.FileHeader.NumberOfSymbols = 0;
309  fmap->u.pe.strtable = NULL;
310  }
311  }
312  else fmap->u.pe.strtable = NULL;
313  }
314  break;
315  default: assert(0); goto error;
316  }
317  pe_unmap_full(fmap);
318 
319  return TRUE;
320 error:
321  pe_unmap_full(fmap);
322  CloseHandle(fmap->u.pe.hMap);
323  return FALSE;
324 }
static const struct image_file_map_ops pe_file_map_ops
Definition: pe_module.c:211
unsigned addr_size
static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS *nthdr, const void *mapping, DWORD64 sz)
Definition: pe_module.c:227
enum module_type modtype
#define CloseHandle
Definition: compat.h:739
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define error(str)
Definition: mkdosfs.c:1605
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define assert(x)
Definition: debug.h:53
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define FALSE
Definition: types.h:117
union image_file_map::@373 u
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
struct image_file_map * alternate
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD NumberOfSymbols
Definition: ntddk_ex.h:126
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define GetFileSizeEx
Definition: compat.h:757
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
const struct image_file_map_ops * ops
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
static const char builtin_signature[]
Definition: pe_module.c:48
GLenum GLenum dst
Definition: glext.h:6340
DWORD PointerToSymbolTable
Definition: ntddk_ex.h:125
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
#define PAGE_READONLY
Definition: compat.h:138
#define RtlImageNtHeader
Definition: compat.h:806
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
LONGLONG QuadPart
Definition: typedefs.h:114
Definition: fci.c:126

Referenced by image_check_debug_link(), pe_load_native_module(), and search_builtin_pe().

◆ pe_map_full()

static void* pe_map_full ( struct image_file_map fmap,
IMAGE_NT_HEADERS **  nth 
)
static

Definition at line 50 of file pe_module.c.

51 {
52  if (!fmap->u.pe.full_map)
53  {
54  fmap->u.pe.full_map = MapViewOfFile(fmap->u.pe.hMap, FILE_MAP_READ, 0, 0, 0);
55  }
56  if (fmap->u.pe.full_map)
57  {
58  if (nth) *nth = RtlImageNtHeader(fmap->u.pe.full_map);
59  fmap->u.pe.full_count++;
60  return fmap->u.pe.full_map;
61  }
62  return NULL;
63 }
#define MapViewOfFile
Definition: compat.h:745
union image_file_map::@373 u
#define FILE_MAP_READ
Definition: compat.h:776
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
#define RtlImageNtHeader
Definition: compat.h:806

Referenced by pe_load_coff_symbol_table(), pe_load_export_debug_info(), pe_load_msc_debug_info(), pe_locate_with_coff_symbol_table(), pe_map_directory(), pe_map_file(), and pe_map_section().

◆ pe_map_section()

static const char* pe_map_section ( struct image_section_map ism)
static

Definition at line 79 of file pe_module.c.

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

◆ pe_module_remove()

static void pe_module_remove ( struct process pcs,
struct module_format modfmt 
)
static

Definition at line 345 of file pe_module.c.

346 {
347  image_unmap_file(&modfmt->u.pe_info->fmap);
348  HeapFree(GetProcessHeap(), 0, modfmt);
349 }
#define GetProcessHeap()
Definition: compat.h:736
union module_format::@362 u
static void image_unmap_file(struct image_file_map *fmap)
#define HeapFree(x, y, z)
Definition: compat.h:735
struct pe_module_info * pe_info

Referenced by pe_load_native_module().

◆ pe_unmap_file()

static void pe_unmap_file ( struct image_file_map fmap)
static

Definition at line 193 of file pe_module.c.

194 {
195  if (fmap->u.pe.hMap != 0)
196  {
197  struct image_section_map ism;
198  ism.fmap = fmap;
199  for (ism.sidx = 0; ism.sidx < fmap->u.pe.ntheader.FileHeader.NumberOfSections; ism.sidx++)
200  {
201  pe_unmap_section(&ism);
202  }
203  while (fmap->u.pe.full_count) pe_unmap_full(fmap);
204  HeapFree(GetProcessHeap(), 0, fmap->u.pe.sect);
205  HeapFree(GetProcessHeap(), 0, (void*)fmap->u.pe.strtable); /* FIXME ugly (see pe_map_file) */
206  CloseHandle(fmap->u.pe.hMap);
207  fmap->u.pe.hMap = NULL;
208  }
209 }
#define CloseHandle
Definition: compat.h:739
struct image_file_map * fmap
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:154
union image_file_map::@373 u
#define GetProcessHeap()
Definition: compat.h:736
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
struct image_file_map::@373::pe_file_map pe
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ pe_unmap_full()

static void pe_unmap_full ( struct image_file_map fmap)
static

Definition at line 65 of file pe_module.c.

66 {
67  if (fmap->u.pe.full_count && !--fmap->u.pe.full_count)
68  {
69  UnmapViewOfFile(fmap->u.pe.full_map);
70  fmap->u.pe.full_map = NULL;
71  }
72 }
struct image_file_map * fmap
#define NULL
Definition: types.h:112
#define UnmapViewOfFile
Definition: compat.h:746

Referenced by pe_load_coff_symbol_table(), pe_load_export_debug_info(), pe_load_msc_debug_info(), pe_locate_with_coff_symbol_table(), pe_map_file(), pe_unmap_file(), and pe_unmap_section().

◆ pe_unmap_section()

static void pe_unmap_section ( struct image_section_map ism)
static

Definition at line 154 of file pe_module.c.

155 {
156  if (ism->sidx >= 0 && ism->sidx < ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections &&
157  ism->fmap->u.pe.sect[ism->sidx].mapped != IMAGE_NO_MAP)
158  {
159  pe_unmap_full(ism->fmap);
160  ism->fmap->u.pe.sect[ism->sidx].mapped = IMAGE_NO_MAP;
161  }
162 }
struct image_file_map * fmap
#define IMAGE_NO_MAP
Definition: image_private.h:24
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65

Referenced by pe_unmap_file().

◆ search_builtin_pe()

static BOOL search_builtin_pe ( void param,
HANDLE  handle,
const WCHAR path 
)
static

Definition at line 785 of file pe_module.c.

786 {
787  struct builtin_search *search = param;
788  size_t size;
789 
790  if (!pe_map_file(handle, &search->fmap, DMT_PE)) return FALSE;
791 
792  size = (lstrlenW(path) + 1) * sizeof(WCHAR);
793  if ((search->path = heap_alloc(size)))
794  memcpy(search->path, path, size);
795  return TRUE;
796 }
static short search(int val, const short *table, int size)
Definition: msg711.c:255
#define TRUE
Definition: types.h:120
#define lstrlenW
Definition: compat.h:750
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FALSE
Definition: types.h:117
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLfloat param
Definition: glext.h:5796
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:245

Referenced by pe_load_native_module().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dbghelp  )

Variable Documentation

◆ builtin_signature

const char builtin_signature[] = "Wine builtin DLL"
static

Definition at line 48 of file pe_module.c.

Referenced by pe_map_file().

◆ pe_file_map_ops

const struct image_file_map_ops pe_file_map_ops
static
Initial value:
=
{
}
static void pe_unmap_file(struct image_file_map *fmap)
Definition: pe_module.c:193
static BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
Definition: pe_module.c:117
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:154
static DWORD_PTR pe_get_map_rva(const struct image_section_map *ism)
Definition: pe_module.c:169
static unsigned pe_get_map_size(const struct image_section_map *ism)
Definition: pe_module.c:181
static const char * pe_map_section(struct image_section_map *ism)
Definition: pe_module.c:79

Definition at line 211 of file pe_module.c.

Referenced by pe_map_file().