ReactOS  0.4.15-dev-1070-ge1a01de
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 968 of file pe_module.c.

969 {
971 }
PVOID WINAPI ImageDirectoryEntryToDataEx(PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section)
Definition: pe_module.c:930
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
GLsizeiptr size
Definition: glext.h:5919

Referenced by GetExportsFromFile().

◆ ImageDirectoryEntryToDataEx()

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

Definition at line 930 of file pe_module.c.

931 {
932  const IMAGE_NT_HEADERS *nt;
933  DWORD addr;
934 
935  *size = 0;
936  if (section) *section = NULL;
937 
938  if (!(nt = RtlImageNtHeader( base ))) return NULL;
940  {
941  const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt;
942 
943  if (dir >= nt64->OptionalHeader.NumberOfRvaAndSizes) return NULL;
944  if (!(addr = nt64->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
946  if (image || addr < nt64->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
947  }
949  {
950  const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt;
951 
952  if (dir >= nt32->OptionalHeader.NumberOfRvaAndSizes) return NULL;
953  if (!(addr = nt32->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
955  if (image || addr < nt32->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
956  }
957  else return NULL;
958 
959  return RtlImageRvaToVa( nt, base, addr, section );
960 }
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
#define RtlImageRvaToVa
Definition: compat.h:555
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
Definition: parser.c:55
IMAGE_NT_HEADERS nt
Definition: module.c:50
smooth NULL
Definition: ftsmooth.c:416
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
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntimage.h:370
#define RtlImageNtHeader
Definition: compat.h:554

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 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 (!stricmp(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::@376 u
struct image_file_map::@376::pe_file_map pe
#define TRUE
Definition: types.h:120
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
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
_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 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 }
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 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 }
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 223 of file pe_module.c.

224 {
225  DWORD64 offset;
226 
227  /* is the iSym table inside file size ? (including first DWORD of string table, which is its size) */
230  if (offset + sizeof(DWORD) > sz) return FALSE;
231  /* is string table (following iSym table) inside file size ? */
232  offset += *(DWORD*)((const char*)mapping + offset);
233  return offset <= sz;
234 }
GLintptr offset
Definition: glext.h:5920
#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
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 892 of file pe_module.c.

894 {
895  struct module* module = NULL;
896 
897  if (base && pcs->dbg_hdr_addr)
898  {
899  IMAGE_NT_HEADERS nth;
900 
901  if (pe_load_nt_header(pcs->handle, base, &nth))
902  {
903  if (!size) size = nth.OptionalHeader.SizeOfImage;
907  }
908  }
909  return module;
910 }
HMODULE module
Definition: main.cpp:47
#define FALSE
Definition: types.h:117
ULONG_PTR dbg_hdr_addr
smooth NULL
Definition: ftsmooth.c:416
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:877
GLsizeiptr size
Definition: glext.h:5919
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
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 416 of file pe_module.c.

417 {
418  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
419  const IMAGE_SYMBOL* isym;
420  int i, numsym, naux;
421  const char* strtable;
422  char tmp[9];
423  const char* name;
424  const char* lastfilename = NULL;
425  struct symt_compiland* compiland = NULL;
426  const IMAGE_SECTION_HEADER* sect;
427  const char* mapping;
428 
429  numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
430  if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
431  return TRUE;
432  if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
433  isym = (const IMAGE_SYMBOL*)((const char*)mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
434  /* FIXME: no way to get strtable size */
435  strtable = (const char*)&isym[numsym];
437 
438  for (i = 0; i < numsym; i+= naux, isym += naux)
439  {
440  if (isym->StorageClass == IMAGE_SYM_CLASS_FILE)
441  {
442  lastfilename = (const char*)(isym + 1);
443  compiland = NULL;
444  }
445  if (isym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL &&
446  isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
447  {
448  if (isym->N.Name.Short)
449  {
450  name = memcpy(tmp, isym->N.ShortName, 8);
451  tmp[8] = '\0';
452  }
453  else name = strtable + isym->N.Name.Long;
454  if (name[0] == '_') name++;
455 
456  if (!compiland && lastfilename)
457  compiland = symt_new_compiland(module, 0,
458  source_new(module, NULL, lastfilename));
459 
461  symt_new_public(module, compiland, name, FALSE,
462  module->module.BaseOfImage + sect[isym->SectionNumber - 1].VirtualAddress +
463  isym->Value,
464  1);
465  }
466  naux = isym->NumberOfAuxSymbols + 1;
467  }
474  pe_unmap_full(fmap);
475 
476  return TRUE;
477 }
union image_file_map::@376 u
struct image_file_map::@376::pe_file_map pe
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:818
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
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 FALSE
Definition: types.h:117
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
smooth NULL
Definition: ftsmooth.c:416
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:61
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define IMAGE_SYM_CLASS_FILE
Definition: compat.h:150
SYM_TYPE SymType
Definition: compat.h:823
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
unsigned dbghelp_options
Definition: dbghelp.c:73
#define RtlImageNtHeader
Definition: compat.h:554
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:741
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 567 of file pe_module.c.

569 {
570  WCHAR tmp[MAX_PATH];
571  HANDLE hFile = INVALID_HANDLE_VALUE, hMap = 0;
572  const BYTE* dbg_mapping = NULL;
573  BOOL ret = FALSE;
574 
575  TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
576 
577  if (path_find_symbol_file(pcs, module, dbg_name, DMT_DBG, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
580  ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
581  ((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
582  {
584  const IMAGE_SECTION_HEADER* sectp;
585  const IMAGE_DEBUG_DIRECTORY* dbg;
586 
587  hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping;
588  /* section headers come immediately after debug header */
589  sectp = (const IMAGE_SECTION_HEADER*)(hdr + 1);
590  /* and after that and the exported names comes the debug directory */
591  dbg = (const IMAGE_DEBUG_DIRECTORY*)
592  (dbg_mapping + sizeof(*hdr) +
593  hdr->NumberOfSections * sizeof(IMAGE_SECTION_HEADER) +
594  hdr->ExportedNamesSize);
595 
596  ret = pe_load_debug_directory(pcs, module, dbg_mapping, sectp,
597  hdr->NumberOfSections, dbg,
598  hdr->DebugDirectorySize / sizeof(*dbg));
599  }
600  else
601  ERR("Couldn't find .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_w(tmp));
602 
603  if (dbg_mapping) UnmapViewOfFile(dbg_mapping);
604  if (hMap) CloseHandle(hMap);
606  return ret;
607 }
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:487
char hdr[14]
Definition: iptest.cpp:33
#define MapViewOfFile
Definition: compat.h:493
struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#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
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:524
#define OPEN_EXISTING
Definition: compat.h:523
#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:492
#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 PAGE_READONLY
Definition: compat.h:138
#define CreateFileW
Definition: compat.h:489
#define UnmapViewOfFile
Definition: compat.h:494
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 747 of file pe_module.c.

748 {
749  BOOL ret = FALSE;
750 
752  {
753  ret = image_check_alternate(&module->format_info[DFI_PE]->u.pe_info->fmap, module);
754  ret = pe_load_stabs(pcs, module) || ret;
755  ret = pe_load_dwarf(module) || ret;
756  #ifndef DBGHELP_STATIC_LIB
758  ret = pe_load_rsym(module) || ret;
759  #endif
760 
761  ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
762  /* if we still have no debug info (we could only get SymExport at this
763  * point), then do the SymExport except if we have an ELF container,
764  * in which case we'll rely on the export's on the ELF side
765  */
766  }
767  /* FIXME shouldn't we check that? if (!module_get_debug(pcs, module)) */
768  if (pe_load_export_debug_info(pcs, module) && !ret)
769  ret = TRUE;
770 
771  return ret;
772 }
#define TRUE
Definition: types.h:120
BOOL image_check_alternate(struct image_file_map *fmap, const struct module *module) DECLSPEC_HIDDEN
Definition: module.c:697
static BOOL pe_load_dwarf(struct module *module)
Definition: pe_module.c:521
#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:662
int ret
static BOOL pe_load_rsym(struct module *module)
Definition: pe_module.c:541
static BOOL pe_load_msc_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:614
static BOOL pe_load_coff_symbol_table(struct module *module)
Definition: pe_module.c:416
unsigned dbghelp_options
Definition: dbghelp.c:73
#define SYMOPT_PUBLICS_ONLY
Definition: compat.h:740
static BOOL pe_load_stabs(const struct process *pcs, struct module *module)
Definition: pe_module.c:485
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 521 of file pe_module.c.

522 {
523  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
524  BOOL ret;
525 
527  module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
528  NULL, /* FIXME: some thunks to deal with ? */
529  fmap);
530  TRACE("%s the DWARF debug info\n", ret ? "successfully loaded" : "failed to load");
531 
532  return ret;
533 }
union image_file_map::@376 u
struct image_file_map::@376::pe_file_map pe
DWORD64 BaseOfImage
Definition: compat.h:818
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#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
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 662 of file pe_module.c.

663 {
664  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
665  unsigned int i;
666  const IMAGE_EXPORT_DIRECTORY* exports;
668  DWORD size;
669  IMAGE_NT_HEADERS* nth;
670  void* mapping;
671 
672  if (dbghelp_options & SYMOPT_NO_PUBLICS) return TRUE;
673 
674  if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
675 #if 0
676  /* Add start of DLL (better use the (yet unimplemented) Exe SymTag for this) */
677  /* FIXME: module.ModuleName isn't correctly set yet if it's passed in SymLoadModule */
679 #endif
680 
681  /* Add entry point */
682  symt_new_public(module, NULL, "EntryPoint", FALSE,
684 #if 0
685  /* FIXME: we'd better store addresses linked to sections rather than
686  absolute values */
688  /* Add start of sections */
690  ((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
691  for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++)
692  {
694  RtlImageRvaToVa(nth, mapping, section->VirtualAddress, NULL), 1);
695  }
696 #endif
697 
698  /* Add exported functions */
701  {
702  const WORD* ordinals = NULL;
703  const DWORD_PTR* functions = NULL;
704  const DWORD* names = NULL;
705  unsigned int j;
706  char buffer[16];
707 
708  functions = RtlImageRvaToVa(nth, mapping, exports->AddressOfFunctions, NULL);
709  ordinals = RtlImageRvaToVa(nth, mapping, exports->AddressOfNameOrdinals, NULL);
710  names = RtlImageRvaToVa(nth, mapping, exports->AddressOfNames, NULL);
711 
712  if (functions && ordinals && names)
713  {
714  for (i = 0; i < exports->NumberOfNames; i++)
715  {
716  if (!names[i]) continue;
719  FALSE,
720  base + functions[ordinals[i]], 1);
721  }
722 
723  for (i = 0; i < exports->NumberOfFunctions; i++)
724  {
725  if (!functions[i]) continue;
726  /* Check if we already added it with a name */
727  for (j = 0; j < exports->NumberOfNames; j++)
728  if ((ordinals[j] == i) && names[j]) break;
729  if (j < exports->NumberOfNames) continue;
730  snprintf(buffer, sizeof(buffer), "%d", i + exports->Base);
731  symt_new_public(module, NULL, buffer, FALSE, base + (DWORD)functions[i], 1);
732  }
733  }
734  }
735  /* no real debug info, only entry points */
738  pe_unmap_full(fmap);
739 
740  return TRUE;
741 }
WCHAR ModuleName[32]
Definition: compat.h:824
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:818
#define RtlImageRvaToVa
Definition: compat.h:555
#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:46
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
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 FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
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:61
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:823
#define RtlImageDirectoryEntryToData
Definition: compat.h:557
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
unsigned dbghelp_options
Definition: dbghelp.c:73
#define SYMOPT_NO_PUBLICS
Definition: compat.h:741
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 614 of file pe_module.c.

615 {
616  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
617  BOOL ret = FALSE;
618  const IMAGE_DEBUG_DIRECTORY*dbg;
619  ULONG nDbg;
620  void* mapping;
621  IMAGE_NT_HEADERS* nth;
622 
623  if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
624  /* Read in debug directory */
626  if (!dbg || !(nDbg /= sizeof(IMAGE_DEBUG_DIRECTORY))) goto done;
627 
628  /* Parse debug directory */
630  {
631  /* Debug info is stripped to .DBG file */
632  const IMAGE_DEBUG_MISC* misc = (const IMAGE_DEBUG_MISC*)
633  ((const char*)mapping + dbg->PointerToRawData);
634 
635  if (nDbg != 1 || dbg->Type != IMAGE_DEBUG_TYPE_MISC ||
637  {
638  ERR("-Debug info stripped, but no .DBG file in module %s\n",
640  }
641  else
642  {
643  ret = pe_load_dbg_file(pcs, module, (const char*)misc->Data, nth->FileHeader.TimeDateStamp);
644  }
645  }
646  else
647  {
648  const IMAGE_SECTION_HEADER *sectp = (const IMAGE_SECTION_HEADER*)((const char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
649  /* Debug info is embedded into PE module */
650  ret = pe_load_debug_directory(pcs, module, mapping, sectp,
651  nth->FileHeader.NumberOfSections, dbg, nDbg);
652  }
653 done:
654  pe_unmap_full(fmap);
655  return ret;
656 }
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:824
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
#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:61
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:567
int ret
#define RtlImageDirectoryEntryToData
Definition: compat.h:557
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 799 of file pe_module.c.

801 {
802  struct module* module = NULL;
803  BOOL opened = FALSE;
804  struct module_format* modfmt;
805  WCHAR loaded_name[MAX_PATH];
806 
807  loaded_name[0] = '\0';
808  if (!hFile)
809  {
810  assert(name);
811 
812  if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL)
813  return NULL;
814  opened = TRUE;
815  }
816  else if (name) lstrcpyW(loaded_name, name);
818  FIXME("Trouble ahead (no module name passed in deferred mode)\n");
819  if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct pe_module_info))))
820  return NULL;
821  modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1);
822  if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE))
823  {
824 #ifndef __REACTOS__
825  struct builtin_search builtin = { NULL };
826  if (modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(pcs, loaded_name, search_builtin_pe, &builtin))
827  {
828  TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path));
829  image_unmap_file(&modfmt->u.pe_info->fmap);
830  modfmt->u.pe_info->fmap = builtin.fmap;
831  }
832 #endif
833  if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
834  if (!size) size = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.SizeOfImage;
835 
836  module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
837  modfmt->u.pe_info->fmap.u.pe.ntheader.FileHeader.TimeDateStamp,
838  modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.CheckSum);
839  if (module)
840  {
841 #ifdef __REACTOS__
842  module->real_path = NULL;
843 #else
844  module->real_path = builtin.path;
845 #endif
846  modfmt->module = module;
847  modfmt->remove = pe_module_remove;
848  modfmt->loc_compute = NULL;
849 
850  module->format_info[DFI_PE] = modfmt;
853  else
855  module->reloc_delta = base - modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
856  }
857  else
858  {
859  ERR("could not load the module '%s'\n", debugstr_w(loaded_name));
860 #ifndef __REACTOS__
861  heap_free(builtin.path);
862 #endif
863  image_unmap_file(&modfmt->u.pe_info->fmap);
864  }
865  }
866  if (!module) HeapFree(GetProcessHeap(), 0, modfmt);
867 
868  if (opened) CloseHandle(hFile);
869 
870  return module;
871 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
WCHAR * search_path
#define CloseHandle
Definition: compat.h:487
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:777
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:737
#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
smooth NULL
Definition: ftsmooth.c:416
BOOL pe_load_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:747
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:484
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:781
#define FindExecutableImageExW
Definition: compat.h:889
#define MAX_PATH
Definition: compat.h:34
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:341
SYM_TYPE SymType
Definition: compat.h:823
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERR(fmt,...)
Definition: debug.h:110
#define lstrcpyW
Definition: compat.h:497
unsigned dbghelp_options
Definition: dbghelp.c:73
struct module * module
struct image_file_map fmap
Definition: pe_module.c:778
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
union module_format::@365 u
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
#define HeapFree(x, y, z)
Definition: compat.h:483
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:241
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 877 of file pe_module.c.

878 {
880 
881  return ReadProcessMemory(hProc, (char*)(DWORD_PTR)base, &dos, sizeof(dos), NULL) &&
883  ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew),
884  nth, sizeof(*nth), NULL) &&
886 }
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:506
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
smooth NULL
Definition: ftsmooth.c:416
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
IMAGE_DOS_HEADER dos
Definition: module.c:49
uint32_t DWORD_PTR
Definition: typedefs.h:65

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 541 of file pe_module.c.

542 {
543  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
544  struct image_section_map sect_rsym;
545  BOOL ret = FALSE;
546 
547  if (pe_find_section(fmap, ".rossym", &sect_rsym))
548  {
549  const char* rsym = image_map_section(&sect_rsym);
550  if (rsym != IMAGE_NO_MAP)
551  {
553  rsym, image_get_map_size(&sect_rsym));
554  }
555  image_unmap_section(&sect_rsym);
556  }
557  TRACE("%s the RSYM debug info\n", ret ? "successfully loaded" : "failed to load");
558 
559  return ret;
560 }
DWORD64 BaseOfImage
Definition: compat.h:818
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:113
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 485 of file pe_module.c.

486 {
487  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
488  struct image_section_map sect_stabs, sect_stabstr;
489  BOOL ret = FALSE;
490 
491  if (pe_find_section(fmap, ".stab", &sect_stabs) && pe_find_section(fmap, ".stabstr", &sect_stabstr))
492  {
493  const char* stab;
494  const char* stabstr;
495 
496  stab = image_map_section(&sect_stabs);
497  stabstr = image_map_section(&sect_stabstr);
498  if (stab != IMAGE_NO_MAP && stabstr != IMAGE_NO_MAP)
499  {
501  module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
502  stab, image_get_map_size(&sect_stabs) / sizeof(struct stab_nlist), sizeof(struct stab_nlist),
503  stabstr, image_get_map_size(&sect_stabstr),
504  NULL, NULL);
505  }
506  image_unmap_section(&sect_stabs);
507  image_unmap_section(&sect_stabstr);
509  }
510  TRACE("%s the STABS debug info\n", ret ? "successfully loaded" : "failed to load");
511 
512  return ret;
513 }
DWORD64 BaseOfImage
Definition: compat.h:818
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:113
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL pe_locate_with_coff_symbol_table(struct module *module)
Definition: pe_module.c:355
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)
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 355 of file pe_module.c.

356 {
357  struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
358  const IMAGE_SYMBOL* isym;
359  int i, numsym, naux;
360  char tmp[9];
361  const char* name;
362  struct hash_table_iter hti;
363  void* ptr;
364  struct symt_data* sym;
365  const char* mapping;
366 
367  numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
368  if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
369  return TRUE;
370  if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
371  isym = (const IMAGE_SYMBOL*)(mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
372 
373  for (i = 0; i < numsym; i+= naux, isym += naux)
374  {
375  if (isym->StorageClass == IMAGE_SYM_CLASS_EXTERNAL &&
376  isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
377  {
378  if (isym->N.Name.Short)
379  {
380  name = memcpy(tmp, isym->N.ShortName, 8);
381  tmp[8] = '\0';
382  }
383  else name = fmap->u.pe.strtable + isym->N.Name.Long;
384  if (name[0] == '_') name++;
386  while ((ptr = hash_table_iter_up(&hti)))
387  {
388  sym = CONTAINING_RECORD(ptr, struct symt_data, hash_elt);
389  if (sym->symt.tag == SymTagData &&
390  (sym->kind == DataIsGlobal || sym->kind == DataIsFileStatic) &&
391  sym->u.var.kind == loc_absolute &&
392  !strcmp(sym->hash_elt.name, name))
393  {
394  TRACE("Changing absolute address for %d.%s: %lx -> %s\n",
395  isym->SectionNumber, name, sym->u.var.offset,
397  fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress +
398  isym->Value));
399  sym->u.var.offset = module->module.BaseOfImage +
400  fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress + isym->Value;
401  break;
402  }
403  }
404  }
405  naux = isym->NumberOfAuxSymbols + 1;
406  }
407  pe_unmap_full(fmap);
408  return TRUE;
409 }
union image_file_map::@376 u
struct image_file_map::@376::pe_file_map pe
union symt_data::@363 u
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:818
struct hash_table ht_symbols
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
enum DataKind kind
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 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
smooth NULL
Definition: ftsmooth.c:416
struct symt symt
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:61
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
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 327 of file pe_module.c.

328 {
329  IMAGE_NT_HEADERS* nth;
330  void* mapping;
331 
332  if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
333  if (dirno >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ||
334  !(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
335  return NULL;
336  if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
337  return RtlImageRvaToVa(nth, mapping,
339 }
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:555
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:46
enum module_type type
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
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 241 of file pe_module.c.

242 {
243  void* mapping;
244 
245  fmap->modtype = mt;
246  fmap->ops = &pe_file_map_ops;
247  fmap->alternate = NULL;
248  fmap->u.pe.hMap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
249  if (fmap->u.pe.hMap == 0) return FALSE;
250  fmap->u.pe.full_count = 0;
251  fmap->u.pe.full_map = NULL;
252  if (!(mapping = pe_map_full(fmap, NULL))) goto error;
253 
254  switch (mt)
255  {
256  case DMT_PE:
257  {
258  IMAGE_NT_HEADERS* nthdr;
260  unsigned i;
261 
262  if (!(nthdr = RtlImageNtHeader(mapping))) goto error;
263  memcpy(&fmap->u.pe.ntheader, nthdr, sizeof(fmap->u.pe.ntheader));
264  switch (nthdr->OptionalHeader.Magic)
265  {
266  case 0x10b: fmap->addr_size = 32; break;
267  case 0x20b: fmap->addr_size = 64; break;
268  default: return FALSE;
269  }
270 
271  fmap->u.pe.builtin = !memcmp((const IMAGE_DOS_HEADER*)mapping + 1, builtin_signature, sizeof(builtin_signature));
273  ((char*)&nthdr->OptionalHeader + nthdr->FileHeader.SizeOfOptionalHeader);
274  fmap->u.pe.sect = HeapAlloc(GetProcessHeap(), 0,
275  nthdr->FileHeader.NumberOfSections * sizeof(fmap->u.pe.sect[0]));
276  if (!fmap->u.pe.sect) goto error;
277  for (i = 0; i < nthdr->FileHeader.NumberOfSections; i++)
278  {
279  memcpy(&fmap->u.pe.sect[i].shdr, section + i, sizeof(IMAGE_SECTION_HEADER));
280  fmap->u.pe.sect[i].mapped = IMAGE_NO_MAP;
281  }
283  {
284  LARGE_INTEGER li;
285 
287  {
288  /* FIXME ugly: should rather map the relevant content instead of copying it */
289  const char* src = (const char*)mapping +
291  nthdr->FileHeader.NumberOfSymbols * sizeof(IMAGE_SYMBOL);
292  char* dst;
293  DWORD sz = *(DWORD*)src;
294 
295  if ((dst = HeapAlloc(GetProcessHeap(), 0, sz)))
296  memcpy(dst, src, sz);
297  fmap->u.pe.strtable = dst;
298  }
299  else
300  {
301  WARN("Bad coff table... wipping out\n");
302  /* we have bad information here, wipe it out */
303  fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable = 0;
304  fmap->u.pe.ntheader.FileHeader.NumberOfSymbols = 0;
305  fmap->u.pe.strtable = NULL;
306  }
307  }
308  else fmap->u.pe.strtable = NULL;
309  }
310  break;
311  default: assert(0); goto error;
312  }
313  pe_unmap_full(fmap);
314 
315  return TRUE;
316 error:
317  pe_unmap_full(fmap);
318  CloseHandle(fmap->u.pe.hMap);
319  return FALSE;
320 }
static const struct image_file_map_ops pe_file_map_ops
Definition: pe_module.c:207
unsigned addr_size
static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS *nthdr, const void *mapping, DWORD64 sz)
Definition: pe_module.c:223
enum module_type modtype
union image_file_map::@376 u
#define CloseHandle
Definition: compat.h:487
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define error(str)
Definition: mkdosfs.c:1605
struct image_file_map::@376::pe_file_map pe
#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:46
Definition: parser.c:55
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
#define IMAGE_NO_MAP
Definition: image_private.h:24
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 FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
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:484
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:61
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:492
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
#define GetFileSizeEx
Definition: compat.h:505
#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
static const char builtin_signature[]
Definition: pe_module.c:44
GLenum GLenum dst
Definition: glext.h:6340
DWORD PointerToSymbolTable
Definition: ntddk_ex.h:125
#define PAGE_READONLY
Definition: compat.h:138
#define RtlImageNtHeader
Definition: compat.h:554
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 46 of file pe_module.c.

47 {
48  if (!fmap->u.pe.full_map)
49  {
50  fmap->u.pe.full_map = MapViewOfFile(fmap->u.pe.hMap, FILE_MAP_READ, 0, 0, 0);
51  }
52  if (fmap->u.pe.full_map)
53  {
54  if (nth) *nth = RtlImageNtHeader(fmap->u.pe.full_map);
55  fmap->u.pe.full_count++;
56  return fmap->u.pe.full_map;
57  }
58  return NULL;
59 }
union image_file_map::@376 u
#define MapViewOfFile
Definition: compat.h:493
struct image_file_map::@376::pe_file_map pe
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:524
#define RtlImageNtHeader
Definition: compat.h:554

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 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:555
struct image_file_map * fmap
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:24
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031

◆ pe_module_remove()

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

Definition at line 341 of file pe_module.c.

342 {
343  image_unmap_file(&modfmt->u.pe_info->fmap);
344  HeapFree(GetProcessHeap(), 0, modfmt);
345 }
#define GetProcessHeap()
Definition: compat.h:484
static void image_unmap_file(struct image_file_map *fmap)
union module_format::@365 u
#define HeapFree(x, y, z)
Definition: compat.h:483
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 189 of file pe_module.c.

190 {
191  if (fmap->u.pe.hMap != 0)
192  {
193  struct image_section_map ism;
194  ism.fmap = fmap;
195  for (ism.sidx = 0; ism.sidx < fmap->u.pe.ntheader.FileHeader.NumberOfSections; ism.sidx++)
196  {
197  pe_unmap_section(&ism);
198  }
199  while (fmap->u.pe.full_count) pe_unmap_full(fmap);
200  HeapFree(GetProcessHeap(), 0, fmap->u.pe.sect);
201  HeapFree(GetProcessHeap(), 0, (void*)fmap->u.pe.strtable); /* FIXME ugly (see pe_map_file) */
202  CloseHandle(fmap->u.pe.hMap);
203  fmap->u.pe.hMap = NULL;
204  }
205 }
union image_file_map::@376 u
#define CloseHandle
Definition: compat.h:487
struct image_file_map::@376::pe_file_map pe
struct image_file_map * fmap
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:150
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:61
#define HeapFree(x, y, z)
Definition: compat.h:483

◆ pe_unmap_full()

static void pe_unmap_full ( struct image_file_map fmap)
static

Definition at line 61 of file pe_module.c.

62 {
63  if (fmap->u.pe.full_count && !--fmap->u.pe.full_count)
64  {
65  UnmapViewOfFile(fmap->u.pe.full_map);
66  fmap->u.pe.full_map = NULL;
67  }
68 }
struct image_file_map * fmap
smooth NULL
Definition: ftsmooth.c:416
#define UnmapViewOfFile
Definition: compat.h:494

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 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 }
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:61

Referenced by pe_unmap_file().

◆ search_builtin_pe()

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

Definition at line 781 of file pe_module.c.

782 {
783  struct builtin_search *search = param;
784  size_t size;
785 
786  if (!pe_map_file(handle, &search->fmap, DMT_PE)) return FALSE;
787 
788  size = (lstrlenW(path) + 1) * sizeof(WCHAR);
789  if ((search->path = heap_alloc(size)))
790  memcpy(search->path, path, size);
791  return TRUE;
792 }
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:498
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:241

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 44 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:189
static BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
Definition: pe_module.c:113
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:150
static DWORD_PTR pe_get_map_rva(const struct image_section_map *ism)
Definition: pe_module.c:165
static unsigned pe_get_map_size(const struct image_section_map *ism)
Definition: pe_module.c:177
static const char * pe_map_section(struct image_section_map *ism)
Definition: pe_module.c:75

Definition at line 207 of file pe_module.c.

Referenced by pe_map_file().