ReactOS  0.4.15-dev-1207-g698a8e6
pe_module.c
Go to the documentation of this file.
1 /*
2  * File pe_module.c - handle PE module information
3  *
4  * Copyright (C) 1996, Eric Youngdale.
5  * Copyright (C) 1999-2000, Ulrich Weigand.
6  * Copyright (C) 2004-2007, Eric Pouech.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  */
23 
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27 #include <assert.h>
28 
29 #include "dbghelp_private.h"
30 #include "image_private.h"
31 #ifndef DBGHELP_STATIC_LIB
32 #include "winternl.h"
33 #include "wine/debug.h"
34 #include "wine/heap.h"
35 #endif
36 
38 
40 {
42 };
43 
44 static const char builtin_signature[] = "Wine builtin DLL";
45 
46 static void* pe_map_full(struct image_file_map* fmap, IMAGE_NT_HEADERS** nth)
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 }
60 
61 static void pe_unmap_full(struct image_file_map* fmap)
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 }
69 
70 /******************************************************************
71  * pe_map_section
72  *
73  * Maps a single section into memory from an PE file
74  */
75 static const char* pe_map_section(struct image_section_map* ism)
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 }
106 
107 /******************************************************************
108  * pe_find_section
109  *
110  * Finds a section by name (and type) into memory from an PE file
111  * or its alternate if any
112  */
113 static BOOL pe_find_section(struct image_file_map* fmap, const char* name,
114  struct image_section_map* ism)
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 }
144 
145 /******************************************************************
146  * pe_unmap_section
147  *
148  * Unmaps a single section from memory
149  */
150 static void pe_unmap_section(struct image_section_map* ism)
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 }
159 
160 /******************************************************************
161  * pe_get_map_rva
162  *
163  * Get the RVA of an PE section
164  */
165 static DWORD_PTR pe_get_map_rva(const struct image_section_map* ism)
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 }
171 
172 /******************************************************************
173  * pe_get_map_size
174  *
175  * Get the size of a PE section
176  */
177 static unsigned pe_get_map_size(const struct image_section_map* ism)
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 }
183 
184 /******************************************************************
185  * pe_unmap_file
186  *
187  * Unmaps an PE file from memory (previously mapped with pe_map_file)
188  */
189 static void pe_unmap_file(struct image_file_map* fmap)
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 }
206 
207 static const struct image_file_map_ops pe_file_map_ops =
208 {
215 };
216 
217 /******************************************************************
218  * pe_is_valid_pointer_table
219  *
220  * Checks whether the PointerToSymbolTable and NumberOfSymbols in file_header contain
221  * valid information.
222  */
223 static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS* nthdr, const void* mapping, DWORD64 sz)
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 }
235 
236 /******************************************************************
237  * pe_map_file
238  *
239  * Maps an PE file into memory (and checks it's a real PE file)
240  */
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 }
321 
322 /******************************************************************
323  * pe_map_directory
324  *
325  * Maps a directory content out of a PE file
326  */
327 const char* pe_map_directory(struct module* module, int dirno, DWORD* size)
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 }
340 
341 static void pe_module_remove(struct process* pcs, struct module_format* modfmt)
342 {
343  image_unmap_file(&modfmt->u.pe_info->fmap);
344  HeapFree(GetProcessHeap(), 0, modfmt);
345 }
346 
347 /******************************************************************
348  * pe_locate_with_coff_symbol_table
349  *
350  * Use the COFF symbol table (if any) from the IMAGE_FILE_HEADER to set the absolute address
351  * of global symbols.
352  * Mingw32 requires this for stabs debug information as address for global variables isn't filled in
353  * (this is similar to what is done in elf_module.c when using the .symtab ELF section)
354  */
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 }
410 
411 /******************************************************************
412  * pe_load_coff_symbol_table
413  *
414  * Load public symbols out of the COFF symbol table (if any).
415  */
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 }
478 
479 /******************************************************************
480  * pe_load_stabs
481  *
482  * look for stabs information in PE header (it's how the mingw compiler provides
483  * its debugging information)
484  */
485 static BOOL pe_load_stabs(const struct process* pcs, struct module* module)
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 }
514 
515 /******************************************************************
516  * pe_load_dwarf
517  *
518  * look for dwarf information in PE header (it's also a way for the mingw compiler
519  * to provide its debugging information)
520  */
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 }
534 
535 #ifndef DBGHELP_STATIC_LIB
536 /******************************************************************
537  * pe_load_rsym
538  *
539  * look for ReactOS's own rsym format
540  */
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 }
561 
562 /******************************************************************
563  * pe_load_dbg_file
564  *
565  * loads a .dbg file
566  */
567 static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
568  const char* dbg_name, DWORD timestamp)
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 }
608 
609 /******************************************************************
610  * pe_load_msc_debug_info
611  *
612  * Process MSC debug information in PE file.
613  */
614 static BOOL pe_load_msc_debug_info(const struct process* pcs, struct module* module)
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 }
657 #endif /* DBGHELP_STATIC_LIB */
658 
659 /***********************************************************************
660  * pe_load_export_debug_info
661  */
662 static BOOL pe_load_export_debug_info(const struct process* pcs, struct module* module)
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 }
742 
743 /******************************************************************
744  * pe_load_debug_info
745  *
746  */
747 BOOL pe_load_debug_info(const struct process* pcs, struct module* module)
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 }
773 
774 #ifndef __REACTOS__
776 {
779 };
780 
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 }
793 #endif
794 
795 /******************************************************************
796  * pe_load_native_module
797  *
798  */
799 struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
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 }
872 
873 /******************************************************************
874  * pe_load_nt_header
875  *
876  */
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 }
887 
888 /******************************************************************
889  * pe_load_builtin_module
890  *
891  */
892 struct module* pe_load_builtin_module(struct process* pcs, const WCHAR* name,
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 }
911 
912 /***********************************************************************
913  * ImageDirectoryEntryToDataEx (DBGHELP.@)
914  *
915  * Search for specified directory in PE image
916  *
917  * PARAMS
918  *
919  * base [in] Image base address
920  * image [in] TRUE - image has been loaded by loader, FALSE - raw file image
921  * dir [in] Target directory index
922  * size [out] Receives directory size
923  * section [out] Receives pointer to section header of section containing directory data
924  *
925  * RETURNS
926  * Success: pointer to directory data
927  * Failure: NULL
928  *
929  */
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 }
961 
962 /***********************************************************************
963  * ImageDirectoryEntryToData (DBGHELP.@)
964  *
965  * NOTES
966  * See ImageDirectoryEntryToDataEx
967  */
969 {
971 }
void(* remove)(struct process *pcs, struct module_format *modfmt)
static const struct image_file_map_ops pe_file_map_ops
Definition: pe_module.c:207
static short search(int val, const short *table, int size)
Definition: msg711.c:255
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
PVOID WINAPI ImageDirectoryEntryToDataEx(PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section)
Definition: pe_module.c:930
enum module_type modtype
union image_file_map::@376 u
WCHAR * search_path
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:598
HMODULE module
Definition: main.cpp:47
char hdr[14]
Definition: iptest.cpp:33
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
WCHAR * real_path
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MapViewOfFile
Definition: compat.h:604
#define error(str)
Definition: mkdosfs.c:1605
WCHAR ModuleName[32]
Definition: compat.h:935
struct image_file_map::@376::pe_file_map pe
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES
Definition: ntddk_ex.h:135
union symt_data::@363 u
#define TRUE
Definition: types.h:120
DWORD64 BaseOfImage
Definition: compat.h:929
struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER
struct hash_table ht_symbols
BOOL image_check_alternate(struct image_file_map *fmap, const struct module *module) DECLSPEC_HIDDEN
Definition: module.c:697
#define WARN(fmt,...)
Definition: debug.h:112
#define RtlImageRvaToVa
Definition: compat.h:666
GLintptr offset
Definition: glext.h:5920
struct image_file_map * fmap
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 IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
#define snprintf
Definition: wintirpc.h:48
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define assert(x)
Definition: debug.h:53
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
enum DataKind kind
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:617
Definition: parser.c:55
static void pe_unmap_file(struct image_file_map *fmap)
Definition: pe_module.c:189
#define lstrlenW
Definition: compat.h:609
IMAGE_NT_HEADERS nt
Definition: module.c:50
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define FILE_SHARE_READ
Definition: compat.h:136
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
WCHAR * path
Definition: pe_module.c:777
DWORD AddressOfNameOrdinals
Definition: compat.h:167
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:848
enum module_type type
#define IMAGE_NO_MAP
Definition: image_private.h:24
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
GLuint GLuint * names
Definition: glext.h:11545
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp)
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 module * pe_load_builtin_module(struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size)
Definition: pe_module.c:892
static BOOL pe_load_dwarf(struct module *module)
Definition: pe_module.c:521
#define FALSE
Definition: types.h:117
DWORD DataType
Definition: compat.h:170
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
ULONG_PTR dbg_hdr_addr
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
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
static PVOID ptr
Definition: dispmode.c:27
struct module * pe_load_native_module(struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size)
Definition: pe_module.c:799
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:150
void hash_table_iter_init(const struct hash_table *ht, struct hash_table_iter *hti, const char *name) DECLSPEC_HIDDEN
Definition: storage.c:405
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct symt symt
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
#define IMAGE_DEBUG_MISC_EXENAME
Definition: compat.h:154
#define FILE_MAP_READ
Definition: compat.h:635
unsigned int dir
Definition: maze.c:112
BOOL pe_load_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:747
#define IMAGE_FILE_DEBUG_STRIPPED
Definition: pedump.c:165
IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: ntimage.h:396
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
#define OPEN_EXISTING
Definition: compat.h:634
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
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
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
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
BOOL rsym_parse(struct module *module, unsigned long load_offset, const void *rsym, int rsymlen) DECLSPEC_HIDDEN
Definition: rsym.c:79
BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth)
Definition: pe_module.c:877
struct _IMAGE_SYMBOL IMAGE_SYMBOL
#define TRACE(s)
Definition: solgame.cpp:4
struct image_file_map * alternate
GLsizeiptr size
Definition: glext.h:5919
DWORD64 reloc_delta
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
DWORD NumberOfSymbols
Definition: ntddk_ex.h:126
if(!(yy_init))
Definition: macro.lex.yy.c:714
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:61
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
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
#define debugstr_a
Definition: kernel32.h:31
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:603
static BOOL search_builtin_pe(void *param, HANDLE handle, const WCHAR *path)
Definition: pe_module.c:781
static BOOL pe_load_export_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:662
#define FindExecutableImageExW
Definition: compat.h:1000
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
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
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
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)
static BOOL pe_load_dbg_file(const struct process *pcs, struct module *module, const char *dbg_name, DWORD timestamp)
Definition: pe_module.c:567
static void image_unmap_file(struct image_file_map *fmap)
#define GetFileSizeEx
Definition: compat.h:616
int ret
static void pe_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: pe_module.c:341
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define IMAGE_SYM_CLASS_FILE
Definition: compat.h:150
IMAGE_DOS_HEADER dos
Definition: module.c:49
SYM_TYPE SymType
Definition: compat.h:934
GLenum const GLvoid * addr
Definition: glext.h:9621
struct location var
#define RtlImageDirectoryEntryToData
Definition: compat.h:668
static void image_unmap_section(struct image_section_map *ism)
static DWORD_PTR pe_get_map_rva(const struct image_section_map *ism)
Definition: pe_module.c:165
struct image_file_map fmap
Definition: pe_module.c:41
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
void * hash_table_iter_up(struct hash_table_iter *hti) DECLSPEC_HIDDEN
Definition: storage.c:422
#define GENERIC_READ
Definition: compat.h:135
module_type
PVOID WINAPI ImageDirectoryEntryToData(PVOID base, BOOLEAN image, USHORT dir, PULONG size)
Definition: pe_module.c:968
GLenum src
Definition: glext.h:6340
uint32_t DWORD_PTR
Definition: typedefs.h:65
_In_ HANDLE hFile
Definition: mswsock.h:90
static const char * image_map_section(struct image_section_map *ism)
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
unsigned char BYTE
Definition: xxhash.c:193
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
const struct image_file_map_ops * ops
#define ERR(fmt,...)
Definition: debug.h:110
static BOOL pe_load_rsym(struct module *module)
Definition: pe_module.c:541
uint64_t DWORD64
Definition: typedefs.h:67
#define lstrcpyW
Definition: compat.h:608
static const char builtin_signature[]
Definition: pe_module.c:44
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
unsigned short USHORT
Definition: pedump.c:61
#define IMAGE_DIRECTORY_ENTRY_DEBUG
Definition: compat.h:152
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
GLenum GLenum dst
Definition: glext.h:6340
DWORD PointerToSymbolTable
Definition: ntddk_ex.h:125
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
unsigned int * PULONG
Definition: retypes.h:1
unsigned dbghelp_options
Definition: dbghelp.c:73
#define PAGE_READONLY
Definition: compat.h:138
struct hash_table_elt hash_elt
struct module * module
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntimage.h:370
#define RtlImageNtHeader
Definition: compat.h:665
#define CreateFileW
Definition: compat.h:600
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
struct image_file_map fmap
Definition: pe_module.c:778
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:38
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
#define SYMOPT_PUBLICS_ONLY
Definition: compat.h:851
unsigned int ULONG
Definition: retypes.h:1
HANDLE handle
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
#define IMAGE_DEBUG_TYPE_MISC
Definition: compat.h:144
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
static unsigned pe_get_map_size(const struct image_section_map *ism)
Definition: pe_module.c:177
static BOOL pe_load_stabs(const struct process *pcs, struct module *module)
Definition: pe_module.c:485
#define SYMOPT_NO_PUBLICS
Definition: compat.h:852
const char * strtable
#define UnmapViewOfFile
Definition: compat.h:605
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
static const char * pe_map_section(struct image_section_map *ism)
Definition: pe_module.c:75
#define HeapFree(x, y, z)
Definition: compat.h:594
BYTE Data[1]
Definition: compat.h:174
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:241
#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
const char * pe_map_directory(struct module *module, int dirno, DWORD *size)
Definition: pe_module.c:327
LONGLONG QuadPart
Definition: typedefs.h:114
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
struct pe_module_info * pe_info
Definition: fci.c:126
GLuint const GLchar * name
Definition: glext.h:6031