ReactOS 0.4.15-dev-8102-g108db8f
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#else
36#ifdef _MSC_VER
37#define strcasecmp _stricmp
38#endif
39#endif
40
42
44{
46};
47
48static const char builtin_signature[] = "Wine builtin DLL";
49
50static void* pe_map_full(struct image_file_map* fmap, IMAGE_NT_HEADERS** nth)
51{
52 if (!fmap->u.pe.full_map)
53 {
54 fmap->u.pe.full_map = MapViewOfFile(fmap->u.pe.hMap, FILE_MAP_READ, 0, 0, 0);
55 }
56 if (fmap->u.pe.full_map)
57 {
58 if (nth) *nth = RtlImageNtHeader(fmap->u.pe.full_map);
59 fmap->u.pe.full_count++;
60 return fmap->u.pe.full_map;
61 }
62 return NULL;
63}
64
65static void pe_unmap_full(struct image_file_map* fmap)
66{
67 if (fmap->u.pe.full_count && !--fmap->u.pe.full_count)
68 {
69 UnmapViewOfFile(fmap->u.pe.full_map);
70 fmap->u.pe.full_map = NULL;
71 }
72}
73
74/******************************************************************
75 * pe_map_section
76 *
77 * Maps a single section into memory from an PE file
78 */
79static const char* pe_map_section(struct image_section_map* ism)
80{
81 void* mapping;
82 struct pe_file_map* fmap = &ism->fmap->u.pe;
83
84 if (ism->sidx >= 0 && ism->sidx < fmap->ntheader.FileHeader.NumberOfSections &&
85 fmap->sect[ism->sidx].mapped == IMAGE_NO_MAP)
86 {
88
89 if (fmap->sect[ism->sidx].shdr.Misc.VirtualSize > fmap->sect[ism->sidx].shdr.SizeOfRawData)
90 {
91 FIXME("Section %ld: virtual (0x%x) > raw (0x%x) size - not supported\n",
92 ism->sidx, fmap->sect[ism->sidx].shdr.Misc.VirtualSize,
93 fmap->sect[ism->sidx].shdr.SizeOfRawData);
94 return IMAGE_NO_MAP;
95 }
96 /* FIXME: that's rather drastic, but that will do for now
97 * that's ok if the full file map exists, but we could be less aggressive otherwise and
98 * only map the relevant section
99 */
100 if ((mapping = pe_map_full(ism->fmap, &nth)))
101 {
102 fmap->sect[ism->sidx].mapped = RtlImageRvaToVa(nth, mapping,
103 fmap->sect[ism->sidx].shdr.VirtualAddress,
104 NULL);
105 return fmap->sect[ism->sidx].mapped;
106 }
107 }
108 return IMAGE_NO_MAP;
109}
110
111/******************************************************************
112 * pe_find_section
113 *
114 * Finds a section by name (and type) into memory from an PE file
115 * or its alternate if any
116 */
117static BOOL pe_find_section(struct image_file_map* fmap, const char* name,
118 struct image_section_map* ism)
119{
120 const char* sectname;
121 unsigned i;
122 char tmp[IMAGE_SIZEOF_SHORT_NAME + 1];
123
124 for (i = 0; i < fmap->u.pe.ntheader.FileHeader.NumberOfSections; i++)
125 {
126 sectname = (const char*)fmap->u.pe.sect[i].shdr.Name;
127 /* long section names start with a '/' (at least on MinGW32) */
128 if (sectname[0] == '/' && fmap->u.pe.strtable)
129 sectname = fmap->u.pe.strtable + atoi(sectname + 1);
130 else
131 {
132 /* the section name may not be null terminated */
133 sectname = memcpy(tmp, sectname, IMAGE_SIZEOF_SHORT_NAME);
134 tmp[IMAGE_SIZEOF_SHORT_NAME] = '\0';
135 }
136 if (!stricmp(sectname, name))
137 {
138 ism->fmap = fmap;
139 ism->sidx = i;
140 return TRUE;
141 }
142 }
143 ism->fmap = NULL;
144 ism->sidx = -1;
145
146 return FALSE;
147}
148
149/******************************************************************
150 * pe_unmap_section
151 *
152 * Unmaps a single section from memory
153 */
154static void pe_unmap_section(struct image_section_map* ism)
155{
156 if (ism->sidx >= 0 && ism->sidx < ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections &&
157 ism->fmap->u.pe.sect[ism->sidx].mapped != IMAGE_NO_MAP)
158 {
159 pe_unmap_full(ism->fmap);
160 ism->fmap->u.pe.sect[ism->sidx].mapped = IMAGE_NO_MAP;
161 }
162}
163
164/******************************************************************
165 * pe_get_map_rva
166 *
167 * Get the RVA of an PE section
168 */
170{
171 if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
172 return 0;
173 return ism->fmap->u.pe.sect[ism->sidx].shdr.VirtualAddress;
174}
175
176/******************************************************************
177 * pe_get_map_size
178 *
179 * Get the size of a PE section
180 */
181static unsigned pe_get_map_size(const struct image_section_map* ism)
182{
183 if (ism->sidx < 0 || ism->sidx >= ism->fmap->u.pe.ntheader.FileHeader.NumberOfSections)
184 return 0;
185 return ism->fmap->u.pe.sect[ism->sidx].shdr.Misc.VirtualSize;
186}
187
188/******************************************************************
189 * pe_unmap_file
190 *
191 * Unmaps an PE file from memory (previously mapped with pe_map_file)
192 */
193static void pe_unmap_file(struct image_file_map* fmap)
194{
195 if (fmap->u.pe.hMap != 0)
196 {
197 struct image_section_map ism;
198 ism.fmap = fmap;
199 for (ism.sidx = 0; ism.sidx < fmap->u.pe.ntheader.FileHeader.NumberOfSections; ism.sidx++)
200 {
201 pe_unmap_section(&ism);
202 }
203 while (fmap->u.pe.full_count) pe_unmap_full(fmap);
204 HeapFree(GetProcessHeap(), 0, fmap->u.pe.sect);
205 HeapFree(GetProcessHeap(), 0, (void*)fmap->u.pe.strtable); /* FIXME ugly (see pe_map_file) */
206 CloseHandle(fmap->u.pe.hMap);
207 fmap->u.pe.hMap = NULL;
208 }
209}
210
212{
219};
220
221/******************************************************************
222 * pe_is_valid_pointer_table
223 *
224 * Checks whether the PointerToSymbolTable and NumberOfSymbols in file_header contain
225 * valid information.
226 */
227static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS* nthdr, const void* mapping, DWORD64 sz)
228{
230
231 /* is the iSym table inside file size ? (including first DWORD of string table, which is its size) */
234 if (offset + sizeof(DWORD) > sz) return FALSE;
235 /* is string table (following iSym table) inside file size ? */
236 offset += *(DWORD*)((const char*)mapping + offset);
237 return offset <= sz;
238}
239
240/******************************************************************
241 * pe_map_file
242 *
243 * Maps an PE file into memory (and checks it's a real PE file)
244 */
246{
247 void* mapping;
248
249 fmap->modtype = mt;
250 fmap->ops = &pe_file_map_ops;
251 fmap->alternate = NULL;
252 fmap->u.pe.hMap = CreateFileMappingW(file, NULL, PAGE_READONLY, 0, 0, NULL);
253 if (fmap->u.pe.hMap == 0) return FALSE;
254 fmap->u.pe.full_count = 0;
255 fmap->u.pe.full_map = NULL;
256 if (!(mapping = pe_map_full(fmap, NULL))) goto error;
257
258 switch (mt)
259 {
260 case DMT_PE:
261 {
262 IMAGE_NT_HEADERS* nthdr;
264 unsigned i;
265
266 if (!(nthdr = RtlImageNtHeader(mapping))) goto error;
267 memcpy(&fmap->u.pe.ntheader, nthdr, sizeof(fmap->u.pe.ntheader));
268 switch (nthdr->OptionalHeader.Magic)
269 {
270 case 0x10b: fmap->addr_size = 32; break;
271 case 0x20b: fmap->addr_size = 64; break;
272 default: return FALSE;
273 }
274
275 fmap->u.pe.builtin = !memcmp((const IMAGE_DOS_HEADER*)mapping + 1, builtin_signature, sizeof(builtin_signature));
277 ((char*)&nthdr->OptionalHeader + nthdr->FileHeader.SizeOfOptionalHeader);
278 fmap->u.pe.sect = HeapAlloc(GetProcessHeap(), 0,
279 nthdr->FileHeader.NumberOfSections * sizeof(fmap->u.pe.sect[0]));
280 if (!fmap->u.pe.sect) goto error;
281 for (i = 0; i < nthdr->FileHeader.NumberOfSections; i++)
282 {
283 memcpy(&fmap->u.pe.sect[i].shdr, section + i, sizeof(IMAGE_SECTION_HEADER));
284 fmap->u.pe.sect[i].mapped = IMAGE_NO_MAP;
285 }
287 {
289
291 {
292 /* FIXME ugly: should rather map the relevant content instead of copying it */
293 const char* src = (const char*)mapping +
295 nthdr->FileHeader.NumberOfSymbols * sizeof(IMAGE_SYMBOL);
296 char* dst;
297 DWORD sz = *(DWORD*)src;
298
299 if ((dst = HeapAlloc(GetProcessHeap(), 0, sz)))
300 memcpy(dst, src, sz);
301 fmap->u.pe.strtable = dst;
302 }
303 else
304 {
305 WARN("Bad coff table... wipping out\n");
306 /* we have bad information here, wipe it out */
307 fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable = 0;
308 fmap->u.pe.ntheader.FileHeader.NumberOfSymbols = 0;
309 fmap->u.pe.strtable = NULL;
310 }
311 }
312 else fmap->u.pe.strtable = NULL;
313 }
314 break;
315 default: assert(0); goto error;
316 }
317 pe_unmap_full(fmap);
318
319 return TRUE;
320error:
321 pe_unmap_full(fmap);
322 CloseHandle(fmap->u.pe.hMap);
323 return FALSE;
324}
325
326/******************************************************************
327 * pe_map_directory
328 *
329 * Maps a directory content out of a PE file
330 */
331const char* pe_map_directory(struct module* module, int dirno, DWORD* size)
332{
333 IMAGE_NT_HEADERS* nth;
334 void* mapping;
335
336 if (module->type != DMT_PE || !module->format_info[DFI_PE]) return NULL;
338 !(mapping = pe_map_full(&module->format_info[DFI_PE]->u.pe_info->fmap, &nth)))
339 return NULL;
340 if (size) *size = nth->OptionalHeader.DataDirectory[dirno].Size;
341 return RtlImageRvaToVa(nth, mapping,
343}
344
345static void pe_module_remove(struct process* pcs, struct module_format* modfmt)
346{
347 image_unmap_file(&modfmt->u.pe_info->fmap);
348 HeapFree(GetProcessHeap(), 0, modfmt);
349}
350
351/******************************************************************
352 * pe_locate_with_coff_symbol_table
353 *
354 * Use the COFF symbol table (if any) from the IMAGE_FILE_HEADER to set the absolute address
355 * of global symbols.
356 * Mingw32 requires this for stabs debug information as address for global variables isn't filled in
357 * (this is similar to what is done in elf_module.c when using the .symtab ELF section)
358 */
360{
361 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
362 const IMAGE_SYMBOL* isym;
363 int i, numsym, naux;
364 char tmp[9];
365 const char* name;
366 struct hash_table_iter hti;
367 void* ptr;
368 struct symt_data* sym;
369 const char* mapping;
370
371 numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
372 if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
373 return TRUE;
374 if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
375 isym = (const IMAGE_SYMBOL*)(mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
376
377 for (i = 0; i < numsym; i+= naux, isym += naux)
378 {
380 isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
381 {
382 if (isym->N.Name.Short)
383 {
384 name = memcpy(tmp, isym->N.ShortName, 8);
385 tmp[8] = '\0';
386 }
387 else name = fmap->u.pe.strtable + isym->N.Name.Long;
388 if (name[0] == '_') name++;
390 while ((ptr = hash_table_iter_up(&hti)))
391 {
392 sym = CONTAINING_RECORD(ptr, struct symt_data, hash_elt);
393 if (sym->symt.tag == SymTagData &&
394 (sym->kind == DataIsGlobal || sym->kind == DataIsFileStatic) &&
395 sym->u.var.kind == loc_absolute &&
396 !strcmp(sym->hash_elt.name, name))
397 {
398 TRACE("Changing absolute address for %d.%s: %lx -> %s\n",
399 isym->SectionNumber, name, sym->u.var.offset,
401 fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress +
402 isym->Value));
403 sym->u.var.offset = module->module.BaseOfImage +
404 fmap->u.pe.sect[isym->SectionNumber - 1].shdr.VirtualAddress + isym->Value;
405 break;
406 }
407 }
408 }
409 naux = isym->NumberOfAuxSymbols + 1;
410 }
411 pe_unmap_full(fmap);
412 return TRUE;
413}
414
415/******************************************************************
416 * pe_load_coff_symbol_table
417 *
418 * Load public symbols out of the COFF symbol table (if any).
419 */
421{
422 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
423 const IMAGE_SYMBOL* isym;
424 int i, numsym, naux;
425 const char* strtable;
426 char tmp[9];
427 const char* name;
428 const char* lastfilename = NULL;
429 struct symt_compiland* compiland = NULL;
430 const IMAGE_SECTION_HEADER* sect;
431 const char* mapping;
432
433 numsym = fmap->u.pe.ntheader.FileHeader.NumberOfSymbols;
434 if (!fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable || !numsym)
435 return TRUE;
436 if (!(mapping = pe_map_full(fmap, NULL))) return FALSE;
437 isym = (const IMAGE_SYMBOL*)((const char*)mapping + fmap->u.pe.ntheader.FileHeader.PointerToSymbolTable);
438 /* FIXME: no way to get strtable size */
439 strtable = (const char*)&isym[numsym];
441
442 for (i = 0; i < numsym; i+= naux, isym += naux)
443 {
445 {
446 lastfilename = (const char*)(isym + 1);
447 compiland = NULL;
448 }
450 isym->SectionNumber > 0 && isym->SectionNumber <= fmap->u.pe.ntheader.FileHeader.NumberOfSections)
451 {
452 if (isym->N.Name.Short)
453 {
454 name = memcpy(tmp, isym->N.ShortName, 8);
455 tmp[8] = '\0';
456 }
457 else name = strtable + isym->N.Name.Long;
458 if (name[0] == '_') name++;
459
460 if (!compiland && lastfilename)
461 compiland = symt_new_compiland(module, 0,
462 source_new(module, NULL, lastfilename));
463
465 symt_new_public(module, compiland, name, FALSE,
467 isym->Value,
468 1);
469 }
470 naux = isym->NumberOfAuxSymbols + 1;
471 }
478 pe_unmap_full(fmap);
479
480 return TRUE;
481}
482
483/******************************************************************
484 * pe_load_stabs
485 *
486 * look for stabs information in PE header (it's how the mingw compiler provides
487 * its debugging information)
488 */
489static BOOL pe_load_stabs(const struct process* pcs, struct module* module)
490{
491 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
492 struct image_section_map sect_stabs, sect_stabstr;
493 BOOL ret = FALSE;
494
495 if (pe_find_section(fmap, ".stab", &sect_stabs) && pe_find_section(fmap, ".stabstr", &sect_stabstr))
496 {
497 const char* stab;
498 const char* stabstr;
499
500 stab = image_map_section(&sect_stabs);
501 stabstr = image_map_section(&sect_stabstr);
502 if (stab != IMAGE_NO_MAP && stabstr != IMAGE_NO_MAP)
503 {
505 module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
506 stab, image_get_map_size(&sect_stabs) / sizeof(struct stab_nlist), sizeof(struct stab_nlist),
507 stabstr, image_get_map_size(&sect_stabstr),
508 NULL, NULL);
509 }
510 image_unmap_section(&sect_stabs);
511 image_unmap_section(&sect_stabstr);
513 }
514 TRACE("%s the STABS debug info\n", ret ? "successfully loaded" : "failed to load");
515
516 return ret;
517}
518
519/******************************************************************
520 * pe_load_dwarf
521 *
522 * look for dwarf information in PE header (it's also a way for the mingw compiler
523 * to provide its debugging information)
524 */
526{
527 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
528 BOOL ret;
529
531 module->module.BaseOfImage - fmap->u.pe.ntheader.OptionalHeader.ImageBase,
532 NULL, /* FIXME: some thunks to deal with ? */
533 fmap);
534 TRACE("%s the DWARF debug info\n", ret ? "successfully loaded" : "failed to load");
535
536 return ret;
537}
538
539#ifndef DBGHELP_STATIC_LIB
540/******************************************************************
541 * pe_load_rsym
542 *
543 * look for ReactOS's own rsym format
544 */
546{
547 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
548 struct image_section_map sect_rsym;
549 BOOL ret = FALSE;
550
551 if (pe_find_section(fmap, ".rossym", &sect_rsym))
552 {
553 const char* rsym = image_map_section(&sect_rsym);
554 if (rsym != IMAGE_NO_MAP)
555 {
557 rsym, image_get_map_size(&sect_rsym));
558 }
559 image_unmap_section(&sect_rsym);
560 }
561 TRACE("%s the RSYM debug info\n", ret ? "successfully loaded" : "failed to load");
562
563 return ret;
564}
565
566/******************************************************************
567 * pe_load_dbg_file
568 *
569 * loads a .dbg file
570 */
571static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
572 const char* dbg_name, DWORD timestamp)
573{
574 WCHAR tmp[MAX_PATH];
576 const BYTE* dbg_mapping = NULL;
577 BOOL ret = FALSE;
578
579 TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
580
581 if (path_find_symbol_file(pcs, module, dbg_name, DMT_DBG, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
584 ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
585 ((dbg_mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL))
586 {
588 const IMAGE_SECTION_HEADER* sectp;
589 const IMAGE_DEBUG_DIRECTORY* dbg;
590
591 hdr = (const IMAGE_SEPARATE_DEBUG_HEADER*)dbg_mapping;
592 /* section headers come immediately after debug header */
593 sectp = (const IMAGE_SECTION_HEADER*)(hdr + 1);
594 /* and after that and the exported names comes the debug directory */
595 dbg = (const IMAGE_DEBUG_DIRECTORY*)
596 (dbg_mapping + sizeof(*hdr) +
597 hdr->NumberOfSections * sizeof(IMAGE_SECTION_HEADER) +
598 hdr->ExportedNamesSize);
599
600 ret = pe_load_debug_directory(pcs, module, dbg_mapping, sectp,
601 hdr->NumberOfSections, dbg,
602 hdr->DebugDirectorySize / sizeof(*dbg));
603 }
604 else
605 ERR("Couldn't find .DBG file %s (%s)\n", debugstr_a(dbg_name), debugstr_w(tmp));
606
607 if (dbg_mapping) UnmapViewOfFile(dbg_mapping);
608 if (hMap) CloseHandle(hMap);
610 return ret;
611}
612
613/******************************************************************
614 * pe_load_msc_debug_info
615 *
616 * Process MSC debug information in PE file.
617 */
618static BOOL pe_load_msc_debug_info(const struct process* pcs, struct module* module)
619{
620 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
621 BOOL ret = FALSE;
622 const IMAGE_DEBUG_DIRECTORY*dbg;
623 ULONG nDbg;
624 void* mapping;
625 IMAGE_NT_HEADERS* nth;
626
627 if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
628 /* Read in debug directory */
630 if (!dbg || !(nDbg /= sizeof(IMAGE_DEBUG_DIRECTORY))) goto done;
631
632 /* Parse debug directory */
634 {
635 /* Debug info is stripped to .DBG file */
636 const IMAGE_DEBUG_MISC* misc = (const IMAGE_DEBUG_MISC*)
637 ((const char*)mapping + dbg->PointerToRawData);
638
639 if (nDbg != 1 || dbg->Type != IMAGE_DEBUG_TYPE_MISC ||
641 {
642 ERR("-Debug info stripped, but no .DBG file in module %s\n",
644 }
645 else
646 {
647 ret = pe_load_dbg_file(pcs, module, (const char*)misc->Data, nth->FileHeader.TimeDateStamp);
648 }
649 }
650 else
651 {
652 const IMAGE_SECTION_HEADER *sectp = (const IMAGE_SECTION_HEADER*)((const char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
653 /* Debug info is embedded into PE module */
655 nth->FileHeader.NumberOfSections, dbg, nDbg);
656 }
657done:
658 pe_unmap_full(fmap);
659 return ret;
660}
661#endif /* DBGHELP_STATIC_LIB */
662
663/***********************************************************************
664 * pe_load_export_debug_info
665 */
666static BOOL pe_load_export_debug_info(const struct process* pcs, struct module* module)
667{
668 struct image_file_map* fmap = &module->format_info[DFI_PE]->u.pe_info->fmap;
669 unsigned int i;
670 const IMAGE_EXPORT_DIRECTORY* exports;
672 DWORD size;
673 IMAGE_NT_HEADERS* nth;
674 void* mapping;
675
677
678 if (!(mapping = pe_map_full(fmap, &nth))) return FALSE;
679#if 0
680 /* Add start of DLL (better use the (yet unimplemented) Exe SymTag for this) */
681 /* FIXME: module.ModuleName isn't correctly set yet if it's passed in SymLoadModule */
683#endif
684
685 /* Add entry point */
686 symt_new_public(module, NULL, "EntryPoint", FALSE,
688#if 0
689 /* FIXME: we'd better store addresses linked to sections rather than
690 absolute values */
692 /* Add start of sections */
694 ((char*)&nth->OptionalHeader + nth->FileHeader.SizeOfOptionalHeader);
695 for (i = 0; i < nth->FileHeader.NumberOfSections; i++, section++)
696 {
698 RtlImageRvaToVa(nth, mapping, section->VirtualAddress, NULL), 1);
699 }
700#endif
701
702 /* Add exported functions */
705 {
706 const WORD* ordinals = NULL;
707 const DWORD_PTR* functions = NULL;
708 const DWORD* names = NULL;
709 unsigned int j;
710 char buffer[16];
711
712 functions = RtlImageRvaToVa(nth, mapping, exports->AddressOfFunctions, NULL);
713 ordinals = RtlImageRvaToVa(nth, mapping, exports->AddressOfNameOrdinals, NULL);
715
716 if (functions && ordinals && names)
717 {
718 for (i = 0; i < exports->NumberOfNames; i++)
719 {
720 if (!names[i]) continue;
723 FALSE,
724 base + functions[ordinals[i]], 1);
725 }
726
727 for (i = 0; i < exports->NumberOfFunctions; i++)
728 {
729 if (!functions[i]) continue;
730 /* Check if we already added it with a name */
731 for (j = 0; j < exports->NumberOfNames; j++)
732 if ((ordinals[j] == i) && names[j]) break;
733 if (j < exports->NumberOfNames) continue;
734 snprintf(buffer, sizeof(buffer), "%d", i + exports->Base);
735 symt_new_public(module, NULL, buffer, FALSE, base + (DWORD)functions[i], 1);
736 }
737 }
738 }
739 /* no real debug info, only entry points */
742 pe_unmap_full(fmap);
743
744 return TRUE;
745}
746
747/******************************************************************
748 * pe_load_debug_info
749 *
750 */
751BOOL pe_load_debug_info(const struct process* pcs, struct module* module)
752{
753 BOOL ret = FALSE;
754
756 {
758 ret = pe_load_stabs(pcs, module) || ret;
760 #ifndef DBGHELP_STATIC_LIB
763 #endif
764
765 ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
766 /* if we still have no debug info (we could only get SymExport at this
767 * point), then do the SymExport except if we have an ELF container,
768 * in which case we'll rely on the export's on the ELF side
769 */
770 }
771 /* FIXME shouldn't we check that? if (!module_get_debug(pcs, module)) */
773 ret = TRUE;
774
775 return ret;
776}
777
778#ifndef __REACTOS__
780{
783};
784
786{
787 struct builtin_search *search = param;
788 size_t size;
789
790 if (!pe_map_file(handle, &search->fmap, DMT_PE)) return FALSE;
791
792 size = (lstrlenW(path) + 1) * sizeof(WCHAR);
793 if ((search->path = heap_alloc(size)))
794 memcpy(search->path, path, size);
795 return TRUE;
796}
797#endif
798
799/******************************************************************
800 * pe_load_native_module
801 *
802 */
803struct module* pe_load_native_module(struct process* pcs, const WCHAR* name,
805{
806 struct module* module = NULL;
807 BOOL opened = FALSE;
808 struct module_format* modfmt;
809 WCHAR loaded_name[MAX_PATH];
810
811 loaded_name[0] = '\0';
812 if (!hFile)
813 {
814 assert(name);
815
816 if ((hFile = FindExecutableImageExW(name, pcs->search_path, loaded_name, NULL, NULL)) == NULL)
817 return NULL;
818 opened = TRUE;
819 }
820 else if (name) lstrcpyW(loaded_name, name);
822 FIXME("Trouble ahead (no module name passed in deferred mode)\n");
823 if (!(modfmt = HeapAlloc(GetProcessHeap(), 0, sizeof(struct module_format) + sizeof(struct pe_module_info))))
824 return NULL;
825 modfmt->u.pe_info = (struct pe_module_info*)(modfmt + 1);
826 if (pe_map_file(hFile, &modfmt->u.pe_info->fmap, DMT_PE))
827 {
828#ifndef __REACTOS__
829 struct builtin_search builtin = { NULL };
830 if (modfmt->u.pe_info->fmap.u.pe.builtin && search_dll_path(pcs, loaded_name, search_builtin_pe, &builtin))
831 {
832 TRACE("reloaded %s from %s\n", debugstr_w(loaded_name), debugstr_w(builtin.path));
833 image_unmap_file(&modfmt->u.pe_info->fmap);
834 modfmt->u.pe_info->fmap = builtin.fmap;
835 }
836#endif
837 if (!base) base = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
838 if (!size) size = modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.SizeOfImage;
839
840 module = module_new(pcs, loaded_name, DMT_PE, FALSE, base, size,
841 modfmt->u.pe_info->fmap.u.pe.ntheader.FileHeader.TimeDateStamp,
842 modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.CheckSum);
843 if (module)
844 {
845#ifdef __REACTOS__
847#else
848 module->real_path = builtin.path;
849#endif
850 modfmt->module = module;
851 modfmt->remove = pe_module_remove;
852 modfmt->loc_compute = NULL;
853
854 module->format_info[DFI_PE] = modfmt;
857 else
859 module->reloc_delta = base - modfmt->u.pe_info->fmap.u.pe.ntheader.OptionalHeader.ImageBase;
860 }
861 else
862 {
863 ERR("could not load the module '%s'\n", debugstr_w(loaded_name));
864#ifndef __REACTOS__
865 heap_free(builtin.path);
866#endif
867 image_unmap_file(&modfmt->u.pe_info->fmap);
868 }
869 }
870 if (!module) HeapFree(GetProcessHeap(), 0, modfmt);
871
872 if (opened) CloseHandle(hFile);
873
874 return module;
875}
876
877/******************************************************************
878 * pe_load_nt_header
879 *
880 */
882{
884
885 return ReadProcessMemory(hProc, (char*)(DWORD_PTR)base, &dos, sizeof(dos), NULL) &&
887 ReadProcessMemory(hProc, (char*)(DWORD_PTR)(base + dos.e_lfanew),
888 nth, sizeof(*nth), NULL) &&
890}
891
892/******************************************************************
893 * pe_load_builtin_module
894 *
895 */
896struct module* pe_load_builtin_module(struct process* pcs, const WCHAR* name,
898{
899 struct module* module = NULL;
900
901 if (base && pcs->dbg_hdr_addr)
902 {
904
905 if (pe_load_nt_header(pcs->handle, base, &nth))
906 {
911 }
912 }
913 return module;
914}
915
916/***********************************************************************
917 * ImageDirectoryEntryToDataEx (DBGHELP.@)
918 *
919 * Search for specified directory in PE image
920 *
921 * PARAMS
922 *
923 * base [in] Image base address
924 * image [in] TRUE - image has been loaded by loader, FALSE - raw file image
925 * dir [in] Target directory index
926 * size [out] Receives directory size
927 * section [out] Receives pointer to section header of section containing directory data
928 *
929 * RETURNS
930 * Success: pointer to directory data
931 * Failure: NULL
932 *
933 */
935{
936 const IMAGE_NT_HEADERS *nt;
937 DWORD addr;
938
939 *size = 0;
940 if (section) *section = NULL;
941
942 if (!(nt = RtlImageNtHeader( base ))) return NULL;
944 {
945 const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt;
946
947 if (dir >= nt64->OptionalHeader.NumberOfRvaAndSizes) return NULL;
948 if (!(addr = nt64->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
950 if (image || addr < nt64->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
951 }
953 {
954 const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt;
955
956 if (dir >= nt32->OptionalHeader.NumberOfRvaAndSizes) return NULL;
957 if (!(addr = nt32->OptionalHeader.DataDirectory[dir].VirtualAddress)) return NULL;
959 if (image || addr < nt32->OptionalHeader.SizeOfHeaders) return (char *)base + addr;
960 }
961 else return NULL;
962
963 return RtlImageRvaToVa( nt, base, addr, section );
964}
965
966/***********************************************************************
967 * ImageDirectoryEntryToData (DBGHELP.@)
968 *
969 * NOTES
970 * See ImageDirectoryEntryToDataEx
971 */
973{
975}
unsigned char BOOLEAN
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
unsigned int dir
Definition: maze.c:112
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
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
BOOL search_dll_path(const struct process *process, const WCHAR *name, BOOL(*match)(void *, HANDLE, const WCHAR *), void *param) DECLSPEC_HIDDEN
Definition: path.c:697
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
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
BOOL rsym_parse(struct module *module, unsigned long load_offset, const void *rsym, int rsymlen) DECLSPEC_HIDDEN
Definition: rsym.c:79
unsigned source_new(struct module *module, const char *basedir, const char *source) DECLSPEC_HIDDEN
Definition: source.c:66
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
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
@ DFI_PE
void hash_table_iter_init(const struct hash_table *ht, struct hash_table_iter *hti, const char *name) DECLSPEC_HIDDEN
Definition: storage.c:405
void * hash_table_iter_up(struct hash_table_iter *hti) DECLSPEC_HIDDEN
Definition: storage.c:422
struct symt_compiland * symt_new_compiland(struct module *module, ULONG_PTR address, unsigned src_idx) DECLSPEC_HIDDEN
Definition: symbol.c:207
@ loc_absolute
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
module_type
@ DMT_DBG
@ DMT_PE
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define GetProcessHeap()
Definition: compat.h:736
#define PAGE_READONLY
Definition: compat.h:138
#define SYMOPT_NO_PUBLICS
Definition: compat.h:993
@ SymDeferred
Definition: compat.h:1061
@ SymExport
Definition: compat.h:1060
@ SymCoff
Definition: compat.h:1057
#define UnmapViewOfFile
Definition: compat.h:746
#define IMAGE_SYM_CLASS_EXTERNAL
Definition: compat.h:149
#define IMAGE_DIRECTORY_ENTRY_DEBUG
Definition: compat.h:152
#define FindExecutableImageExW
Definition: compat.h:1141
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:744
#define SYMOPT_PUBLICS_ONLY
Definition: compat.h:992
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
#define GENERIC_READ
Definition: compat.h:135
@ SymTagData
Definition: compat.h:1588
#define IMAGE_DEBUG_MISC_EXENAME
Definition: compat.h:154
#define RtlImageRvaToVa
Definition: compat.h:807
#define stricmp(_String1, _String2)
Definition: compat.h:24
#define RtlImageNtHeader
Definition: compat.h:806
#define IMAGE_DEBUG_TYPE_MISC
Definition: compat.h:144
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define SYMOPT_DEFERRED_LOADS
Definition: compat.h:989
#define CreateFileW
Definition: compat.h:741
#define FILE_MAP_READ
Definition: compat.h:776
@ DataIsGlobal
Definition: compat.h:1654
@ DataIsFileStatic
Definition: compat.h:1653
#define GetFileSizeEx
Definition: compat.h:757
#define IMAGE_SYM_CLASS_FILE
Definition: compat.h:150
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define lstrcpyW
Definition: compat.h:749
#define MapViewOfFile
Definition: compat.h:745
#define FILE_SHARE_READ
Definition: compat.h:136
#define lstrlenW
Definition: compat.h:750
unsigned dbghelp_options
Definition: dbghelp.c:73
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES
Definition: ntddk_ex.h:135
unsigned short WORD
Definition: ntddk_ex.h:93
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLuint GLuint * names
Definition: glext.h:11545
GLuint buffer
Definition: glext.h:5915
GLenum GLenum dst
Definition: glext.h:6340
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
GLfloat param
Definition: glext.h:5796
GLintptr offset
Definition: glext.h:5920
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
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_NO_MAP
Definition: image_private.h:24
static void image_unmap_section(struct image_section_map *ism)
static const char * image_map_section(struct image_section_map *ism)
BOOL image_check_alternate(struct image_file_map *fmap, const struct module *module) DECLSPEC_HIDDEN
Definition: module.c:701
static void image_unmap_file(struct image_file_map *fmap)
static unsigned image_get_map_size(const struct image_section_map *ism)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
char hdr[14]
Definition: iptest.cpp:33
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
IMAGE_NT_HEADERS nt
Definition: module.c:50
IMAGE_DOS_HEADER dos
Definition: module.c:49
static short search(int val, const short *table, int size)
Definition: msg711.c:255
_In_ HANDLE hFile
Definition: mswsock.h:90
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: ntimage.h:376
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: ntimage.h:377
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
static BOOL pe_load_coff_symbol_table(struct module *module)
Definition: pe_module.c:420
PVOID WINAPI ImageDirectoryEntryToData(PVOID base, BOOLEAN image, USHORT dir, PULONG size)
Definition: pe_module.c:972
static const struct image_file_map_ops pe_file_map_ops
Definition: pe_module.c:211
const char * pe_map_directory(struct module *module, int dirno, DWORD *size)
Definition: pe_module.c:331
static BOOL pe_locate_with_coff_symbol_table(struct module *module)
Definition: pe_module.c:359
static DWORD_PTR pe_get_map_rva(const struct image_section_map *ism)
Definition: pe_module.c:169
struct module * pe_load_builtin_module(struct process *pcs, const WCHAR *name, DWORD64 base, DWORD64 size)
Definition: pe_module.c:896
BOOL pe_map_file(HANDLE file, struct image_file_map *fmap, enum module_type mt)
Definition: pe_module.c:245
BOOL pe_load_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:751
static void pe_module_remove(struct process *pcs, struct module_format *modfmt)
Definition: pe_module.c:345
static BOOL search_builtin_pe(void *param, HANDLE handle, const WCHAR *path)
Definition: pe_module.c:785
static BOOL pe_load_dwarf(struct module *module)
Definition: pe_module.c:525
static BOOL pe_load_rsym(struct module *module)
Definition: pe_module.c:545
PVOID WINAPI ImageDirectoryEntryToDataEx(PVOID base, BOOLEAN image, USHORT dir, PULONG size, PIMAGE_SECTION_HEADER *section)
Definition: pe_module.c:934
static BOOL pe_load_export_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:666
static unsigned pe_get_map_size(const struct image_section_map *ism)
Definition: pe_module.c:181
static const char * pe_map_section(struct image_section_map *ism)
Definition: pe_module.c:79
static BOOL pe_load_msc_debug_info(const struct process *pcs, struct module *module)
Definition: pe_module.c:618
BOOL pe_load_nt_header(HANDLE hProc, DWORD64 base, IMAGE_NT_HEADERS *nth)
Definition: pe_module.c:881
struct module * pe_load_native_module(struct process *pcs, const WCHAR *name, HANDLE hFile, DWORD64 base, DWORD size)
Definition: pe_module.c:803
static void pe_unmap_section(struct image_section_map *ism)
Definition: pe_module.c:154
static void * pe_map_full(struct image_file_map *fmap, IMAGE_NT_HEADERS **nth)
Definition: pe_module.c:50
static void pe_unmap_full(struct image_file_map *fmap)
Definition: pe_module.c:65
static BOOL pe_load_dbg_file(const struct process *pcs, struct module *module, const char *dbg_name, DWORD timestamp)
Definition: pe_module.c:571
static const char builtin_signature[]
Definition: pe_module.c:48
static BOOL pe_find_section(struct image_file_map *fmap, const char *name, struct image_section_map *ism)
Definition: pe_module.c:117
static BOOL pe_is_valid_pointer_table(const IMAGE_NT_HEADERS *nthdr, const void *mapping, DWORD64 sz)
Definition: pe_module.c:227
static void pe_unmap_file(struct image_file_map *fmap)
Definition: pe_module.c:193
static BOOL pe_load_stabs(const struct process *pcs, struct module *module)
Definition: pe_module.c:489
struct _IMAGE_SYMBOL IMAGE_SYMBOL
#define IMAGE_FILE_DEBUG_STRIPPED
Definition: pedump.c:165
#define IMAGE_NT_SIGNATURE
Definition: pedump.c:93
#define IMAGE_SIZEOF_SHORT_NAME
Definition: pedump.c:277
unsigned short USHORT
Definition: pedump.c:61
#define IMAGE_DOS_SIGNATURE
Definition: pedump.c:89
struct _IMAGE_SECTION_HEADER IMAGE_SECTION_HEADER
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR ModuleName[32]
Definition: compat.h:1076
DWORD64 BaseOfImage
Definition: compat.h:1070
SYM_TYPE SymType
Definition: compat.h:1075
DWORD DataType
Definition: compat.h:170
BYTE Data[1]
Definition: compat.h:174
DWORD AddressOfNameOrdinals
Definition: compat.h:167
DWORD NumberOfSymbols
Definition: ntddk_ex.h:126
DWORD PointerToSymbolTable
Definition: ntddk_ex.h:125
WORD SizeOfOptionalHeader
Definition: ntddk_ex.h:127
IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: ntimage.h:396
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntimage.h:370
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]
Definition: ntddk_ex.h:178
BYTE NumberOfAuxSymbols
Definition: pecoff.h:256
union _IMAGE_SYMBOL::@2295 N
DWORD Value
Definition: pecoff.h:252
BYTE StorageClass
Definition: pecoff.h:255
struct _IMAGE_SYMBOL::@2295::@2296 Name
BYTE ShortName[8]
Definition: pecoff.h:245
SHORT SectionNumber
Definition: pecoff.h:253
WCHAR * path
Definition: pe_module.c:781
struct image_file_map fmap
Definition: pe_module.c:782
Definition: fci.c:127
enum module_type modtype
const char * strtable
struct image_file_map::@387::pe_file_map pe
unsigned addr_size
struct image_file_map * alternate
union image_file_map::@387 u
const struct image_file_map_ops * ops
struct macho_section section
struct image_file_map * fmap
struct module * module
struct pe_module_info * pe_info
void(* loc_compute)(struct process *pcs, const struct module_format *modfmt, const struct symt_function *func, struct location *loc)
void(* remove)(struct process *pcs, struct module_format *modfmt)
union module_format::@376 u
DWORD64 reloc_delta
IMAGEHLP_MODULEW64 module
struct module_format * format_info[DFI_LAST]
struct hash_table ht_symbols
enum module_type type
WCHAR * real_path
Definition: name.c:39
struct image_file_map fmap
Definition: pe_module.c:45
HANDLE handle
ULONG_PTR dbg_hdr_addr
WCHAR * search_path
Definition: parser.c:56
struct symt symt
union symt_data::@374 u
struct hash_table_elt hash_elt
struct location var
enum DataKind kind
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint64_t DWORD64
Definition: typedefs.h:67
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
LONGLONG QuadPart
Definition: typedefs.h:114
int ret
#define WINAPI
Definition: msvc.h:6
#define snprintf
Definition: wintirpc.h:48
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193