2 * File module.c - module handling for the wine debugger
4 * Copyright (C) 1993, Eric Youngdale.
5 * 2000-2007, Eric Pouech
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "dbghelp_private.h"
28 #include "image_private.h"
31 #include "wine/debug.h"
32 #include "wine/heap.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp
);
36 #define NOTE_GNU_BUILD_ID 3
38 const WCHAR S_ElfW
[] = {'<','e','l','f','>','\0'};
39 const WCHAR S_WineLoaderW
[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'};
40 static const WCHAR S_DotSoW
[] = {'.','s','o','\0'};
41 const WCHAR S_SlashW
[] = {'/','\0'};
43 static const WCHAR S_AcmW
[] = {'.','a','c','m','\0'};
44 static const WCHAR S_DllW
[] = {'.','d','l','l','\0'};
45 static const WCHAR S_DrvW
[] = {'.','d','r','v','\0'};
46 static const WCHAR S_ExeW
[] = {'.','e','x','e','\0'};
47 static const WCHAR S_OcxW
[] = {'.','o','c','x','\0'};
48 static const WCHAR S_VxdW
[] = {'.','v','x','d','\0'};
49 static const WCHAR
* const ext
[] = {S_AcmW
, S_DllW
, S_DrvW
, S_ExeW
, S_OcxW
, S_VxdW
, NULL
};
51 static int match_ext(const WCHAR
* ptr
, size_t len
)
53 const WCHAR
* const *e
;
56 for (e
= ext
; *e
; e
++)
59 if (l
>= len
) return 0;
60 if (wcsnicmp(&ptr
[len
- l
], *e
, l
)) continue;
66 static const WCHAR
* get_filename(const WCHAR
* name
, const WCHAR
* endptr
)
70 if (!endptr
) endptr
= name
+ lstrlenW(name
);
71 for (ptr
= endptr
- 1; ptr
>= name
; ptr
--)
73 if (*ptr
== '/' || *ptr
== '\\') break;
78 static BOOL
is_wine_loader(const WCHAR
*module
)
80 static const WCHAR wineW
[] = {'w','i','n','e',0};
81 static const WCHAR suffixW
[] = {'6','4',0};
82 const WCHAR
*filename
= get_filename(module
, NULL
);
88 if ((ptr
= getenv("WINELOADER")))
90 ptr
= file_nameA(ptr
);
91 len
= 2 + MultiByteToWideChar( CP_UNIXCP
, 0, ptr
, -1, NULL
, 0 );
92 buffer
= heap_alloc( len
* sizeof(WCHAR
) );
93 MultiByteToWideChar( CP_UNIXCP
, 0, ptr
, -1, buffer
, len
);
97 buffer
= heap_alloc( sizeof(wineW
) + 2 * sizeof(WCHAR
) );
98 lstrcpyW( buffer
, wineW
);
101 if (!wcscmp( filename
, buffer
))
104 lstrcatW( buffer
, suffixW
);
105 if (!wcscmp( filename
, buffer
))
112 static void module_fill_module(const WCHAR
* in
, WCHAR
* out
, size_t size
)
114 const WCHAR
*ptr
, *endptr
;
117 ptr
= get_filename(in
, endptr
= in
+ lstrlenW(in
));
118 len
= min(endptr
- ptr
, size
- 1);
119 memcpy(out
, ptr
, len
* sizeof(WCHAR
));
121 if (len
> 4 && (l
= match_ext(out
, len
)))
123 else if (is_wine_loader(out
))
124 lstrcpynW(out
, S_WineLoaderW
, size
);
127 if (len
> 3 && !wcsicmp(&out
[len
- 3], S_DotSoW
) &&
128 (l
= match_ext(out
, len
- 3)))
129 lstrcpyW(&out
[len
- l
- 3], S_ElfW
);
131 while ((*out
= towlower(*out
))) out
++;
134 void module_set_module(struct module
* module
, const WCHAR
* name
)
136 module_fill_module(name
, module
->module
.ModuleName
, ARRAY_SIZE(module
->module
.ModuleName
));
137 module_fill_module(name
, module
->modulename
, ARRAY_SIZE(module
->modulename
));
140 /* Returned string must be freed by caller */
141 const WCHAR
*get_wine_loader_name(struct process
*pcs
)
143 const WCHAR
*name
= process_getenv(pcs
, L
"WINELOADER");
144 if (!name
) name
= pcs
->is_64bit
? L
"wine64" : L
"wine";
145 TRACE("returning %s\n", debugstr_w(name
));
149 static const char* get_module_type(enum module_type type
, BOOL
virtual)
153 case DMT_ELF
: return virtual ? "Virtual ELF" : "ELF";
154 case DMT_PE
: return virtual ? "Virtual PE" : "PE";
155 case DMT_MACHO
: return virtual ? "Virtual Mach-O" : "Mach-O";
156 default: return "---";
160 /***********************************************************************
161 * Creates and links a new module to a process
163 struct module
* module_new(struct process
* pcs
, const WCHAR
* name
,
164 enum module_type type
, BOOL
virtual,
165 DWORD64 mod_addr
, DWORD64 size
,
166 ULONG_PTR stamp
, ULONG_PTR checksum
)
168 struct module
* module
;
171 assert(type
== DMT_ELF
|| type
== DMT_PE
|| type
== DMT_MACHO
);
172 if (!(module
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*module
))))
175 module
->next
= pcs
->lmodules
;
176 pcs
->lmodules
= module
;
178 TRACE("=> %s %s-%s %s\n",
179 get_module_type(type
, virtual),
180 wine_dbgstr_longlong(mod_addr
), wine_dbgstr_longlong(mod_addr
+ size
),
183 pool_init(&module
->pool
, 65536);
185 module
->process
= pcs
;
186 module
->module
.SizeOfStruct
= sizeof(module
->module
);
187 module
->module
.BaseOfImage
= mod_addr
;
188 module
->module
.ImageSize
= size
;
189 module_set_module(module
, name
);
190 module
->module
.ImageName
[0] = '\0';
191 lstrcpynW(module
->module
.LoadedImageName
, name
, ARRAY_SIZE(module
->module
.LoadedImageName
));
192 module
->module
.SymType
= SymNone
;
193 module
->module
.NumSyms
= 0;
194 module
->module
.TimeDateStamp
= stamp
;
195 module
->module
.CheckSum
= checksum
;
197 memset(module
->module
.LoadedPdbName
, 0, sizeof(module
->module
.LoadedPdbName
));
198 module
->module
.CVSig
= 0;
199 memset(module
->module
.CVData
, 0, sizeof(module
->module
.CVData
));
200 module
->module
.PdbSig
= 0;
201 memset(&module
->module
.PdbSig70
, 0, sizeof(module
->module
.PdbSig70
));
202 module
->module
.PdbAge
= 0;
203 module
->module
.PdbUnmatched
= FALSE
;
204 module
->module
.DbgUnmatched
= FALSE
;
205 module
->module
.LineNumbers
= FALSE
;
206 module
->module
.GlobalSymbols
= FALSE
;
207 module
->module
.TypeInfo
= FALSE
;
208 module
->module
.SourceIndexed
= FALSE
;
209 module
->module
.Publics
= FALSE
;
210 module
->module
.MachineType
= 0;
211 module
->module
.Reserved
= 0;
213 module
->reloc_delta
= 0;
215 module
->is_virtual
= virtual;
216 for (i
= 0; i
< DFI_LAST
; i
++) module
->format_info
[i
] = NULL
;
217 module
->sortlist_valid
= FALSE
;
218 module
->sorttab_size
= 0;
219 module
->addr_sorttab
= NULL
;
220 module
->num_sorttab
= 0;
221 module
->num_symbols
= 0;
223 vector_init(&module
->vsymt
, sizeof(struct symt
*), 128);
224 /* FIXME: this seems a bit too high (on a per module basis)
225 * need some statistics about this
227 hash_table_init(&module
->pool
, &module
->ht_symbols
, 4096);
228 hash_table_init(&module
->pool
, &module
->ht_types
, 4096);
229 vector_init(&module
->vtypes
, sizeof(struct symt
*), 32);
231 module
->sources_used
= 0;
232 module
->sources_alloc
= 0;
234 wine_rb_init(&module
->sources_offsets_tree
, source_rb_compare
);
239 /***********************************************************************
240 * module_find_by_nameW
243 struct module
* module_find_by_nameW(const struct process
* pcs
, const WCHAR
* name
)
245 struct module
* module
;
247 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
249 if (!wcsicmp(name
, module
->module
.ModuleName
)) return module
;
251 SetLastError(ERROR_INVALID_NAME
);
255 struct module
* module_find_by_nameA(const struct process
* pcs
, const char* name
)
257 WCHAR wname
[MAX_PATH
];
259 MultiByteToWideChar(CP_ACP
, 0, name
, -1, wname
, ARRAY_SIZE(wname
));
260 return module_find_by_nameW(pcs
, wname
);
263 /***********************************************************************
264 * module_is_already_loaded
267 struct module
* module_is_already_loaded(const struct process
* pcs
, const WCHAR
* name
)
269 struct module
* module
;
270 const WCHAR
* filename
;
272 /* first compare the loaded image name... */
273 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
275 if (!wcsicmp(name
, module
->module
.LoadedImageName
))
278 /* then compare the standard filenames (without the path) ... */
279 filename
= get_filename(name
, NULL
);
280 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
282 if (!wcsicmp(filename
, get_filename(module
->module
.LoadedImageName
, NULL
)))
285 SetLastError(ERROR_INVALID_NAME
);
289 /***********************************************************************
290 * module_get_container
293 static struct module
* module_get_container(const struct process
* pcs
,
294 const struct module
* inner
)
296 struct module
* module
;
298 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
300 if (module
!= inner
&&
301 module
->module
.BaseOfImage
<= inner
->module
.BaseOfImage
&&
302 module
->module
.BaseOfImage
+ module
->module
.ImageSize
>=
303 inner
->module
.BaseOfImage
+ inner
->module
.ImageSize
)
309 /***********************************************************************
310 * module_get_containee
313 struct module
* module_get_containee(const struct process
* pcs
, const struct module
* outer
)
315 struct module
* module
;
317 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
319 if (module
!= outer
&&
320 outer
->module
.BaseOfImage
<= module
->module
.BaseOfImage
&&
321 outer
->module
.BaseOfImage
+ outer
->module
.ImageSize
>=
322 module
->module
.BaseOfImage
+ module
->module
.ImageSize
)
328 /******************************************************************
331 * get the debug information from a module:
332 * - if the module's type is deferred, then force loading of debug info (and return
334 * - if the module has no debug info and has an ELF container, then return the ELF
335 * container (and also force the ELF container's debug info loading if deferred)
336 * - otherwise return the module itself if it has some debug info
338 BOOL
module_get_debug(struct module_pair
* pair
)
340 IMAGEHLP_DEFERRED_SYMBOL_LOADW64 idslW64
;
342 if (!pair
->requested
) return FALSE
;
343 /* for a PE builtin, always get info from container */
344 if (!(pair
->effective
= module_get_container(pair
->pcs
, pair
->requested
)))
345 pair
->effective
= pair
->requested
;
346 /* if deferred, force loading */
347 if (pair
->effective
->module
.SymType
== SymDeferred
)
351 if (pair
->effective
->is_virtual
) ret
= FALSE
;
352 else if (pair
->effective
->type
== DMT_PE
)
354 idslW64
.SizeOfStruct
= sizeof(idslW64
);
355 idslW64
.BaseOfImage
= pair
->effective
->module
.BaseOfImage
;
356 idslW64
.CheckSum
= pair
->effective
->module
.CheckSum
;
357 idslW64
.TimeDateStamp
= pair
->effective
->module
.TimeDateStamp
;
358 memcpy(idslW64
.FileName
, pair
->effective
->module
.ImageName
,
359 sizeof(pair
->effective
->module
.ImageName
));
360 idslW64
.Reparse
= FALSE
;
361 idslW64
.hFile
= INVALID_HANDLE_VALUE
;
363 pcs_callback(pair
->pcs
, CBA_DEFERRED_SYMBOL_LOAD_START
, &idslW64
);
364 ret
= pe_load_debug_info(pair
->pcs
, pair
->effective
);
365 pcs_callback(pair
->pcs
,
366 ret
? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE
: CBA_DEFERRED_SYMBOL_LOAD_FAILURE
,
369 else ret
= pair
->pcs
->loader
->load_debug_info(pair
->pcs
, pair
->effective
);
371 if (!ret
) pair
->effective
->module
.SymType
= SymNone
;
372 assert(pair
->effective
->module
.SymType
!= SymDeferred
);
373 pair
->effective
->module
.NumSyms
= pair
->effective
->ht_symbols
.num_elts
;
375 return pair
->effective
->module
.SymType
!= SymNone
;
378 /***********************************************************************
379 * module_find_by_addr
381 * either the addr where module is loaded, or any address inside the
384 struct module
* module_find_by_addr(const struct process
* pcs
, DWORD64 addr
,
385 enum module_type type
)
387 struct module
* module
;
389 if (type
== DMT_UNKNOWN
)
391 if ((module
= module_find_by_addr(pcs
, addr
, DMT_PE
)) ||
392 (module
= module_find_by_addr(pcs
, addr
, DMT_ELF
)) ||
393 (module
= module_find_by_addr(pcs
, addr
, DMT_MACHO
)))
398 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
400 if (type
== module
->type
&& addr
>= module
->module
.BaseOfImage
&&
401 addr
< module
->module
.BaseOfImage
+ module
->module
.ImageSize
)
405 SetLastError(ERROR_MOD_NOT_FOUND
);
409 /******************************************************************
410 * module_is_container_loaded
412 * checks whether the native container, for a (supposed) PE builtin is
415 static BOOL
module_is_container_loaded(const struct process
* pcs
,
416 const WCHAR
* ImageName
, DWORD64 base
)
419 struct module
* module
;
420 PCWSTR filename
, modname
;
422 if (!base
) return FALSE
;
423 filename
= get_filename(ImageName
, NULL
);
424 len
= lstrlenW(filename
);
426 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
428 if ((module
->type
== DMT_ELF
|| module
->type
== DMT_MACHO
) &&
429 base
>= module
->module
.BaseOfImage
&&
430 base
< module
->module
.BaseOfImage
+ module
->module
.ImageSize
)
432 modname
= get_filename(module
->module
.LoadedImageName
, NULL
);
433 if (!wcsnicmp(modname
, filename
, len
) &&
434 !memcmp(modname
+ len
, S_DotSoW
, 3 * sizeof(WCHAR
)))
440 /* likely a native PE module */
441 WARN("Couldn't find container for %s\n", debugstr_w(ImageName
));
445 static BOOL
image_check_debug_link(const WCHAR
* file
, struct image_file_map
* fmap
, DWORD link_crc
)
453 path
= get_dos_file_name(file
);
454 handle
= CreateFileW(path
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, NULL
);
456 if (handle
== INVALID_HANDLE_VALUE
) return FALSE
;
460 DWORD crc
= calc_crc32(handle
);
463 WARN("Bad CRC for file %s (got %08x while expecting %08x)\n", debugstr_w(file
), crc
, link_crc
);
469 SetFilePointer(handle
, 0, 0, FILE_BEGIN
);
470 if (ReadFile(handle
, &magic
, sizeof(magic
), &read_bytes
, NULL
) && magic
== IMAGE_DOS_SIGNATURE
)
471 ret
= pe_map_file(handle
, fmap
, DMT_PE
);
473 ret
= elf_map_handle(handle
, fmap
);
478 /******************************************************************
479 * image_locate_debug_link
481 * Locate a filename from a .gnu_debuglink section, using the same
483 * "If the full name of the directory containing the executable is
484 * execdir, and the executable has a debug link that specifies the
485 * name debugfile, then GDB will automatically search for the
486 * debugging information file in three places:
487 * - the directory containing the executable file (that is, it
488 * will look for a file named `execdir/debugfile',
489 * - a subdirectory of that directory named `.debug' (that is, the
490 * file `execdir/.debug/debugfile', and
491 * - a subdirectory of the global debug file directory that includes
492 * the executable's full path, and the name from the link (that is,
493 * the file `globaldebugdir/execdir/debugfile', where globaldebugdir
494 * is the global debug file directory, and execdir has been turned
495 * into a relative path)." (from GDB manual)
497 static BOOL
image_locate_debug_link(const struct module
* module
, struct image_file_map
* fmap
, const char* filename
, DWORD crc
)
499 static const WCHAR globalDebugDirW
[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
500 static const WCHAR dotDebugW
[] = {'.','d','e','b','u','g','/'};
501 const size_t globalDebugDirLen
= ARRAY_SIZE(globalDebugDirW
);
502 size_t filename_len
, path_len
;
506 struct image_file_map
* fmap_link
= NULL
;
508 fmap_link
= HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link
));
509 if (!fmap_link
) return FALSE
;
511 filename_len
= MultiByteToWideChar(CP_UNIXCP
, 0, filename
, -1, NULL
, 0);
512 path_len
= lstrlenW(module
->module
.LoadedImageName
);
513 if (module
->real_path
) path_len
= max(path_len
, lstrlenW(module
->real_path
));
514 p
= HeapAlloc(GetProcessHeap(), 0,
515 (globalDebugDirLen
+ path_len
+ 6 + 1 + filename_len
+ 1) * sizeof(WCHAR
));
518 /* we prebuild the string with "execdir" */
519 lstrcpyW(p
, module
->module
.LoadedImageName
);
521 if ((slash2
= wcsrchr(slash
, '/'))) slash
= slash2
+ 1;
522 if ((slash2
= wcsrchr(slash
, '\\'))) slash
= slash2
+ 1;
524 /* testing execdir/filename */
525 MultiByteToWideChar(CP_UNIXCP
, 0, filename
, -1, slash
, filename_len
);
526 if (image_check_debug_link(p
, fmap_link
, crc
)) goto found
;
528 /* testing execdir/.debug/filename */
529 memcpy(slash
, dotDebugW
, sizeof(dotDebugW
));
530 MultiByteToWideChar(CP_UNIXCP
, 0, filename
, -1, slash
+ ARRAY_SIZE(dotDebugW
), filename_len
);
531 if (image_check_debug_link(p
, fmap_link
, crc
)) goto found
;
533 if (module
->real_path
)
535 lstrcpyW(p
, module
->real_path
);
537 if ((slash2
= wcsrchr(slash
, '/'))) slash
= slash2
+ 1;
538 if ((slash2
= wcsrchr(slash
, '\\'))) slash
= slash2
+ 1;
539 MultiByteToWideChar(CP_UNIXCP
, 0, filename
, -1, slash
, filename_len
);
540 if (image_check_debug_link(p
, fmap_link
, crc
)) goto found
;
543 /* testing globaldebugdir/execdir/filename */
544 memmove(p
+ globalDebugDirLen
, p
, (slash
- p
) * sizeof(WCHAR
));
545 memcpy(p
, globalDebugDirW
, globalDebugDirLen
* sizeof(WCHAR
));
546 slash
+= globalDebugDirLen
;
547 MultiByteToWideChar(CP_UNIXCP
, 0, filename
, -1, slash
, filename_len
);
548 if (image_check_debug_link(p
, fmap_link
, crc
)) goto found
;
550 /* finally testing filename */
551 if (image_check_debug_link(slash
, fmap_link
, crc
)) goto found
;
554 WARN("Couldn't locate or map %s\n", filename
);
555 HeapFree(GetProcessHeap(), 0, p
);
556 HeapFree(GetProcessHeap(), 0, fmap_link
);
560 TRACE("Located debug information file %s at %s\n", filename
, debugstr_w(p
));
561 HeapFree(GetProcessHeap(), 0, p
);
562 fmap
->alternate
= fmap_link
;
566 /******************************************************************
567 * image_locate_build_id_target
569 * Try to find the .so file containing the debug info out of the build-id note information
571 static BOOL
image_locate_build_id_target(struct image_file_map
* fmap
, const BYTE
* id
, unsigned idlen
)
573 static const WCHAR globalDebugDirW
[] = {'/','u','s','r','/','l','i','b','/','d','e','b','u','g','/'};
574 static const WCHAR buildidW
[] = {'.','b','u','i','l','d','-','i','d','/'};
575 static const WCHAR dotDebug0W
[] = {'.','d','e','b','u','g',0};
576 struct image_file_map
* fmap_link
= NULL
;
579 const BYTE
* idend
= id
+ idlen
;
581 fmap_link
= HeapAlloc(GetProcessHeap(), 0, sizeof(*fmap_link
));
582 if (!fmap_link
) return FALSE
;
584 p
= HeapAlloc(GetProcessHeap(), 0,
585 sizeof(globalDebugDirW
) + sizeof(buildidW
) +
586 (idlen
* 2 + 1) * sizeof(WCHAR
) + sizeof(dotDebug0W
));
588 memcpy(z
, globalDebugDirW
, sizeof(globalDebugDirW
));
589 z
+= ARRAY_SIZE(globalDebugDirW
);
590 memcpy(z
, buildidW
, sizeof(buildidW
));
591 z
+= ARRAY_SIZE(buildidW
);
595 *z
++ = "0123456789abcdef"[*id
>> 4 ];
596 *z
++ = "0123456789abcdef"[*id
& 0x0F];
603 *z
++ = "0123456789abcdef"[*id
>> 4 ];
604 *z
++ = "0123456789abcdef"[*id
& 0x0F];
607 memcpy(z
, dotDebug0W
, sizeof(dotDebug0W
));
608 TRACE("checking %s\n", wine_dbgstr_w(p
));
610 if (image_check_debug_link(p
, fmap_link
, 0))
612 struct image_section_map buildid_sect
;
613 if (image_find_section(fmap_link
, ".note.gnu.build-id", &buildid_sect
))
617 note
= (const UINT32
*)image_map_section(&buildid_sect
);
618 if (note
!= IMAGE_NO_MAP
)
620 /* the usual ELF note structure: name-size desc-size type <name> <desc> */
621 if (note
[2] == NOTE_GNU_BUILD_ID
)
623 if (note
[1] == idlen
&&
624 !memcmp(note
+ 3 + ((note
[0] + 3) >> 2), idend
- idlen
, idlen
))
626 TRACE("Located debug information file at %s\n", debugstr_w(p
));
627 HeapFree(GetProcessHeap(), 0, p
);
628 fmap
->alternate
= fmap_link
;
631 WARN("mismatch in buildid information for %s\n", wine_dbgstr_w(p
));
634 image_unmap_section(&buildid_sect
);
636 image_unmap_file(fmap_link
);
639 TRACE("not found\n");
640 HeapFree(GetProcessHeap(), 0, p
);
641 HeapFree(GetProcessHeap(), 0, fmap_link
);
645 /******************************************************************
646 * image_check_alternate
648 * Load alternate files for a given image file, looking at either .note.gnu_build-id
649 * or .gnu_debuglink sections.
651 BOOL
image_check_alternate(struct image_file_map
* fmap
, const struct module
* module
)
655 struct image_section_map buildid_sect
, debuglink_sect
;
657 /* if present, add the .gnu_debuglink file as an alternate to current one */
658 if (image_find_section(fmap
, ".note.gnu.build-id", &buildid_sect
))
663 note
= (const UINT32
*)image_map_section(&buildid_sect
);
664 if (note
!= IMAGE_NO_MAP
)
666 /* the usual ELF note structure: name-size desc-size type <name> <desc> */
667 if (note
[2] == NOTE_GNU_BUILD_ID
)
669 ret
= image_locate_build_id_target(fmap
, (const BYTE
*)(note
+ 3 + ((note
[0] + 3) >> 2)), note
[1]);
672 image_unmap_section(&buildid_sect
);
674 /* if present, add the .gnu_debuglink file as an alternate to current one */
675 if (!ret
&& image_find_section(fmap
, ".gnu_debuglink", &debuglink_sect
))
677 const char* dbg_link
;
680 dbg_link
= (const char*)image_map_section(&debuglink_sect
);
681 if (dbg_link
!= IMAGE_NO_MAP
)
683 /* The content of a debug link section is:
684 * 1/ a NULL terminated string, containing the file name for the
686 * 2/ padding on 4 byte boundary
687 * 3/ CRC of the linked file
689 DWORD crc
= *(const DWORD
*)(dbg_link
+ ((DWORD_PTR
)(strlen(dbg_link
) + 4) & ~3));
690 ret
= image_locate_debug_link(module
, fmap
, dbg_link
, crc
);
692 WARN("Couldn't load linked debug file for %s\n",
693 debugstr_w(module
->module
.ModuleName
));
695 image_unmap_section(&debuglink_sect
);
697 return found
? ret
: TRUE
;
700 /***********************************************************************
701 * SymLoadModule (DBGHELP.@)
703 DWORD WINAPI
SymLoadModule(HANDLE hProcess
, HANDLE hFile
, PCSTR ImageName
,
704 PCSTR ModuleName
, DWORD BaseOfDll
, DWORD SizeOfDll
)
706 return SymLoadModuleEx(hProcess
, hFile
, ImageName
, ModuleName
, BaseOfDll
,
710 /***********************************************************************
711 * SymLoadModuleEx (DBGHELP.@)
713 DWORD64 WINAPI
SymLoadModuleEx(HANDLE hProcess
, HANDLE hFile
, PCSTR ImageName
,
714 PCSTR ModuleName
, DWORD64 BaseOfDll
, DWORD DllSize
,
715 PMODLOAD_DATA Data
, DWORD Flags
)
717 PWSTR wImageName
, wModuleName
;
721 TRACE("(%p %p %s %s %s %08x %p %08x)\n",
722 hProcess
, hFile
, debugstr_a(ImageName
), debugstr_a(ModuleName
),
723 wine_dbgstr_longlong(BaseOfDll
), DllSize
, Data
, Flags
);
727 len
= MultiByteToWideChar(CP_ACP
, 0, ImageName
, -1, NULL
, 0);
728 wImageName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
729 MultiByteToWideChar(CP_ACP
, 0, ImageName
, -1, wImageName
, len
);
731 else wImageName
= NULL
;
734 len
= MultiByteToWideChar(CP_ACP
, 0, ModuleName
, -1, NULL
, 0);
735 wModuleName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
736 MultiByteToWideChar(CP_ACP
, 0, ModuleName
, -1, wModuleName
, len
);
738 else wModuleName
= NULL
;
740 ret
= SymLoadModuleExW(hProcess
, hFile
, wImageName
, wModuleName
,
741 BaseOfDll
, DllSize
, Data
, Flags
);
742 HeapFree(GetProcessHeap(), 0, wImageName
);
743 HeapFree(GetProcessHeap(), 0, wModuleName
);
747 /***********************************************************************
748 * SymLoadModuleExW (DBGHELP.@)
750 DWORD64 WINAPI
SymLoadModuleExW(HANDLE hProcess
, HANDLE hFile
, PCWSTR wImageName
,
751 PCWSTR wModuleName
, DWORD64 BaseOfDll
, DWORD SizeOfDll
,
752 PMODLOAD_DATA Data
, DWORD Flags
)
755 struct module
* module
= NULL
;
757 TRACE("(%p %p %s %s %s %08x %p %08x)\n",
758 hProcess
, hFile
, debugstr_w(wImageName
), debugstr_w(wModuleName
),
759 wine_dbgstr_longlong(BaseOfDll
), SizeOfDll
, Data
, Flags
);
762 FIXME("Unsupported load data parameter %p for %s\n",
763 Data
, debugstr_w(wImageName
));
764 if (!validate_addr64(BaseOfDll
)) return FALSE
;
766 if (!(pcs
= process_find_by_handle(hProcess
))) return FALSE
;
768 if (Flags
& SLMFLAG_VIRTUAL
)
770 if (!wImageName
) return FALSE
;
771 module
= module_new(pcs
, wImageName
, DMT_PE
, TRUE
, BaseOfDll
, SizeOfDll
, 0, 0);
772 if (!module
) return FALSE
;
773 if (wModuleName
) module_set_module(module
, wModuleName
);
774 module
->module
.SymType
= SymVirtual
;
778 if (Flags
& ~(SLMFLAG_VIRTUAL
))
779 FIXME("Unsupported Flags %08x for %s\n", Flags
, debugstr_w(wImageName
));
781 pcs
->loader
->synchronize_module_list(pcs
);
783 /* this is a Wine extension to the API just to redo the synchronisation */
784 if (!wImageName
&& !hFile
) return 0;
786 /* check if the module is already loaded, or if it's a builtin PE module with
787 * an containing ELF module
791 module
= module_is_already_loaded(pcs
, wImageName
);
792 if (!module
&& module_is_container_loaded(pcs
, wImageName
, BaseOfDll
))
794 /* force the loading of DLL as builtin */
795 module
= pe_load_builtin_module(pcs
, wImageName
, BaseOfDll
, SizeOfDll
);
800 /* otherwise, try a regular PE module */
801 if (!(module
= pe_load_native_module(pcs
, wImageName
, hFile
, BaseOfDll
, SizeOfDll
)) &&
804 /* and finally an ELF or Mach-O module */
805 module
= pcs
->loader
->load_module(pcs
, wImageName
, BaseOfDll
);
810 WARN("Couldn't locate %s\n", debugstr_w(wImageName
));
813 module
->module
.NumSyms
= module
->ht_symbols
.num_elts
;
814 /* by default module_new fills module.ModuleName from a derivation
815 * of LoadedImageName. Overwrite it, if we have better information
818 module_set_module(module
, wModuleName
);
820 lstrcpynW(module
->module
.ImageName
, wImageName
, ARRAY_SIZE(module
->module
.ImageName
));
822 return module
->module
.BaseOfImage
;
825 /***********************************************************************
826 * SymLoadModule64 (DBGHELP.@)
828 DWORD64 WINAPI
SymLoadModule64(HANDLE hProcess
, HANDLE hFile
, PCSTR ImageName
,
829 PCSTR ModuleName
, DWORD64 BaseOfDll
, DWORD SizeOfDll
)
831 return SymLoadModuleEx(hProcess
, hFile
, ImageName
, ModuleName
, BaseOfDll
, SizeOfDll
,
835 /******************************************************************
839 BOOL
module_remove(struct process
* pcs
, struct module
* module
)
841 struct module_format
*modfmt
;
845 TRACE("%s (%p)\n", debugstr_w(module
->module
.ModuleName
), module
);
847 for (i
= 0; i
< DFI_LAST
; i
++)
849 if ((modfmt
= module
->format_info
[i
]) && modfmt
->remove
)
850 modfmt
->remove(pcs
, module
->format_info
[i
]);
852 hash_table_destroy(&module
->ht_symbols
);
853 hash_table_destroy(&module
->ht_types
);
854 HeapFree(GetProcessHeap(), 0, module
->sources
);
855 HeapFree(GetProcessHeap(), 0, module
->addr_sorttab
);
856 HeapFree(GetProcessHeap(), 0, module
->real_path
);
857 pool_destroy(&module
->pool
);
858 /* native dbghelp doesn't invoke registered callback(,CBA_SYMBOLS_UNLOADED,) here
861 for (p
= &pcs
->lmodules
; *p
; p
= &(*p
)->next
)
866 HeapFree(GetProcessHeap(), 0, module
);
870 FIXME("This shouldn't happen\n");
874 /******************************************************************
875 * SymUnloadModule (DBGHELP.@)
878 BOOL WINAPI
SymUnloadModule(HANDLE hProcess
, DWORD BaseOfDll
)
881 struct module
* module
;
883 pcs
= process_find_by_handle(hProcess
);
884 if (!pcs
) return FALSE
;
885 module
= module_find_by_addr(pcs
, BaseOfDll
, DMT_UNKNOWN
);
886 if (!module
) return FALSE
;
887 return module_remove(pcs
, module
);
890 /******************************************************************
891 * SymUnloadModule64 (DBGHELP.@)
894 BOOL WINAPI
SymUnloadModule64(HANDLE hProcess
, DWORD64 BaseOfDll
)
897 struct module
* module
;
899 pcs
= process_find_by_handle(hProcess
);
900 if (!pcs
) return FALSE
;
901 if (!validate_addr64(BaseOfDll
)) return FALSE
;
902 module
= module_find_by_addr(pcs
, BaseOfDll
, DMT_UNKNOWN
);
903 if (!module
) return FALSE
;
904 return module_remove(pcs
, module
);
907 /******************************************************************
908 * SymEnumerateModules (DBGHELP.@)
911 struct enum_modW64_32
913 PSYM_ENUMMODULES_CALLBACK cb
;
915 char module
[MAX_PATH
];
918 static BOOL CALLBACK
enum_modW64_32(PCWSTR name
, DWORD64 base
, PVOID user
)
920 struct enum_modW64_32
* x
= user
;
922 WideCharToMultiByte(CP_ACP
, 0, name
, -1, x
->module
, sizeof(x
->module
), NULL
, NULL
);
923 return x
->cb(x
->module
, (DWORD
)base
, x
->user
);
926 BOOL WINAPI
SymEnumerateModules(HANDLE hProcess
,
927 PSYM_ENUMMODULES_CALLBACK EnumModulesCallback
,
930 struct enum_modW64_32 x
;
932 x
.cb
= EnumModulesCallback
;
933 x
.user
= UserContext
;
935 return SymEnumerateModulesW64(hProcess
, enum_modW64_32
, &x
);
938 /******************************************************************
939 * SymEnumerateModules64 (DBGHELP.@)
942 struct enum_modW64_64
944 PSYM_ENUMMODULES_CALLBACK64 cb
;
946 char module
[MAX_PATH
];
949 static BOOL CALLBACK
enum_modW64_64(PCWSTR name
, DWORD64 base
, PVOID user
)
951 struct enum_modW64_64
* x
= user
;
953 WideCharToMultiByte(CP_ACP
, 0, name
, -1, x
->module
, sizeof(x
->module
), NULL
, NULL
);
954 return x
->cb(x
->module
, base
, x
->user
);
957 BOOL WINAPI
SymEnumerateModules64(HANDLE hProcess
,
958 PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback
,
961 struct enum_modW64_64 x
;
963 x
.cb
= EnumModulesCallback
;
964 x
.user
= UserContext
;
966 return SymEnumerateModulesW64(hProcess
, enum_modW64_64
, &x
);
969 /******************************************************************
970 * SymEnumerateModulesW64 (DBGHELP.@)
973 BOOL WINAPI
SymEnumerateModulesW64(HANDLE hProcess
,
974 PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback
,
977 struct process
* pcs
= process_find_by_handle(hProcess
);
978 struct module
* module
;
980 if (!pcs
) return FALSE
;
982 for (module
= pcs
->lmodules
; module
; module
= module
->next
)
984 if (!dbghelp_opt_native
&&
985 (module
->type
== DMT_ELF
|| module
->type
== DMT_MACHO
))
987 if (!EnumModulesCallback(module
->modulename
,
988 module
->module
.BaseOfImage
, UserContext
))
994 /******************************************************************
995 * EnumerateLoadedModules64 (DBGHELP.@)
998 struct enum_load_modW64_64
1000 PENUMLOADED_MODULES_CALLBACK64 cb
;
1002 char module
[MAX_PATH
];
1005 static BOOL CALLBACK
enum_load_modW64_64(PCWSTR name
, DWORD64 base
, ULONG size
,
1008 struct enum_load_modW64_64
* x
= user
;
1010 WideCharToMultiByte(CP_ACP
, 0, name
, -1, x
->module
, sizeof(x
->module
), NULL
, NULL
);
1011 return x
->cb(x
->module
, base
, size
, x
->user
);
1014 BOOL WINAPI
EnumerateLoadedModules64(HANDLE hProcess
,
1015 PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback
,
1018 struct enum_load_modW64_64 x
;
1020 x
.cb
= EnumLoadedModulesCallback
;
1021 x
.user
= UserContext
;
1023 return EnumerateLoadedModulesW64(hProcess
, enum_load_modW64_64
, &x
);
1026 /******************************************************************
1027 * EnumerateLoadedModules (DBGHELP.@)
1030 struct enum_load_modW64_32
1032 PENUMLOADED_MODULES_CALLBACK cb
;
1034 char module
[MAX_PATH
];
1037 static BOOL CALLBACK
enum_load_modW64_32(PCWSTR name
, DWORD64 base
, ULONG size
,
1040 struct enum_load_modW64_32
* x
= user
;
1041 WideCharToMultiByte(CP_ACP
, 0, name
, -1, x
->module
, sizeof(x
->module
), NULL
, NULL
);
1042 return x
->cb(x
->module
, (DWORD
)base
, size
, x
->user
);
1045 BOOL WINAPI
EnumerateLoadedModules(HANDLE hProcess
,
1046 PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback
,
1049 struct enum_load_modW64_32 x
;
1051 x
.cb
= EnumLoadedModulesCallback
;
1052 x
.user
= UserContext
;
1054 return EnumerateLoadedModulesW64(hProcess
, enum_load_modW64_32
, &x
);
1057 /******************************************************************
1058 * EnumerateLoadedModulesW64 (DBGHELP.@)
1061 BOOL WINAPI
EnumerateLoadedModulesW64(HANDLE hProcess
,
1062 PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback
,
1066 WCHAR baseW
[256], modW
[256];
1070 hMods
= HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(hMods
[0]));
1071 if (!hMods
) return FALSE
;
1073 if (!EnumProcessModules(hProcess
, hMods
, 256 * sizeof(hMods
[0]), &sz
))
1075 /* hProcess should also be a valid process handle !! */
1076 FIXME("If this happens, bump the number in mod\n");
1077 HeapFree(GetProcessHeap(), 0, hMods
);
1080 sz
/= sizeof(HMODULE
);
1081 for (i
= 0; i
< sz
; i
++)
1083 if (!GetModuleInformation(hProcess
, hMods
[i
], &mi
, sizeof(mi
)) ||
1084 !GetModuleBaseNameW(hProcess
, hMods
[i
], baseW
, ARRAY_SIZE(baseW
)))
1086 module_fill_module(baseW
, modW
, ARRAY_SIZE(modW
));
1087 EnumLoadedModulesCallback(modW
, (DWORD_PTR
)mi
.lpBaseOfDll
, mi
.SizeOfImage
,
1090 HeapFree(GetProcessHeap(), 0, hMods
);
1092 return sz
!= 0 && i
== sz
;
1095 static void dbghelp_str_WtoA(const WCHAR
*src
, char *dst
, int dst_len
)
1097 WideCharToMultiByte(CP_ACP
, 0, src
, -1, dst
, dst_len
- 1, NULL
, NULL
);
1098 dst
[dst_len
- 1] = 0;
1101 /******************************************************************
1102 * SymGetModuleInfo (DBGHELP.@)
1105 BOOL WINAPI
SymGetModuleInfo(HANDLE hProcess
, DWORD dwAddr
,
1106 PIMAGEHLP_MODULE ModuleInfo
)
1109 IMAGEHLP_MODULEW64 miw64
;
1111 if (sizeof(mi
) < ModuleInfo
->SizeOfStruct
) FIXME("Wrong size\n");
1113 miw64
.SizeOfStruct
= sizeof(miw64
);
1114 if (!SymGetModuleInfoW64(hProcess
, dwAddr
, &miw64
)) return FALSE
;
1116 mi
.SizeOfStruct
= ModuleInfo
->SizeOfStruct
;
1117 mi
.BaseOfImage
= miw64
.BaseOfImage
;
1118 mi
.ImageSize
= miw64
.ImageSize
;
1119 mi
.TimeDateStamp
= miw64
.TimeDateStamp
;
1120 mi
.CheckSum
= miw64
.CheckSum
;
1121 mi
.NumSyms
= miw64
.NumSyms
;
1122 mi
.SymType
= miw64
.SymType
;
1123 dbghelp_str_WtoA(miw64
.ModuleName
, mi
.ModuleName
, sizeof(mi
.ModuleName
));
1124 dbghelp_str_WtoA(miw64
.ImageName
, mi
.ImageName
, sizeof(mi
.ImageName
));
1125 dbghelp_str_WtoA(miw64
.LoadedImageName
, mi
.LoadedImageName
, sizeof(mi
.LoadedImageName
));
1127 memcpy(ModuleInfo
, &mi
, ModuleInfo
->SizeOfStruct
);
1132 /******************************************************************
1133 * SymGetModuleInfoW (DBGHELP.@)
1136 BOOL WINAPI
SymGetModuleInfoW(HANDLE hProcess
, DWORD dwAddr
,
1137 PIMAGEHLP_MODULEW ModuleInfo
)
1139 IMAGEHLP_MODULEW64 miw64
;
1140 IMAGEHLP_MODULEW miw
;
1142 if (sizeof(miw
) < ModuleInfo
->SizeOfStruct
) FIXME("Wrong size\n");
1144 miw64
.SizeOfStruct
= sizeof(miw64
);
1145 if (!SymGetModuleInfoW64(hProcess
, dwAddr
, &miw64
)) return FALSE
;
1147 miw
.SizeOfStruct
= ModuleInfo
->SizeOfStruct
;
1148 miw
.BaseOfImage
= miw64
.BaseOfImage
;
1149 miw
.ImageSize
= miw64
.ImageSize
;
1150 miw
.TimeDateStamp
= miw64
.TimeDateStamp
;
1151 miw
.CheckSum
= miw64
.CheckSum
;
1152 miw
.NumSyms
= miw64
.NumSyms
;
1153 miw
.SymType
= miw64
.SymType
;
1154 lstrcpyW(miw
.ModuleName
, miw64
.ModuleName
);
1155 lstrcpyW(miw
.ImageName
, miw64
.ImageName
);
1156 lstrcpyW(miw
.LoadedImageName
, miw64
.LoadedImageName
);
1157 memcpy(ModuleInfo
, &miw
, ModuleInfo
->SizeOfStruct
);
1162 /******************************************************************
1163 * SymGetModuleInfo64 (DBGHELP.@)
1166 BOOL WINAPI
SymGetModuleInfo64(HANDLE hProcess
, DWORD64 dwAddr
,
1167 PIMAGEHLP_MODULE64 ModuleInfo
)
1169 IMAGEHLP_MODULE64 mi64
;
1170 IMAGEHLP_MODULEW64 miw64
;
1172 if (sizeof(mi64
) < ModuleInfo
->SizeOfStruct
)
1174 SetLastError(ERROR_MOD_NOT_FOUND
); /* NOTE: native returns this error */
1175 WARN("Wrong size %u\n", ModuleInfo
->SizeOfStruct
);
1179 miw64
.SizeOfStruct
= sizeof(miw64
);
1180 if (!SymGetModuleInfoW64(hProcess
, dwAddr
, &miw64
)) return FALSE
;
1182 mi64
.SizeOfStruct
= ModuleInfo
->SizeOfStruct
;
1183 mi64
.BaseOfImage
= miw64
.BaseOfImage
;
1184 mi64
.ImageSize
= miw64
.ImageSize
;
1185 mi64
.TimeDateStamp
= miw64
.TimeDateStamp
;
1186 mi64
.CheckSum
= miw64
.CheckSum
;
1187 mi64
.NumSyms
= miw64
.NumSyms
;
1188 mi64
.SymType
= miw64
.SymType
;
1189 dbghelp_str_WtoA(miw64
.ModuleName
, mi64
.ModuleName
, sizeof(mi64
.ModuleName
));
1190 dbghelp_str_WtoA(miw64
.ImageName
, mi64
.ImageName
, sizeof(mi64
.ImageName
));
1191 dbghelp_str_WtoA(miw64
.LoadedImageName
, mi64
.LoadedImageName
, sizeof(mi64
.LoadedImageName
));
1192 dbghelp_str_WtoA(miw64
.LoadedPdbName
, mi64
.LoadedPdbName
, sizeof(mi64
.LoadedPdbName
));
1194 mi64
.CVSig
= miw64
.CVSig
;
1195 dbghelp_str_WtoA(miw64
.CVData
, mi64
.CVData
, sizeof(mi64
.CVData
));
1196 mi64
.PdbSig
= miw64
.PdbSig
;
1197 mi64
.PdbSig70
= miw64
.PdbSig70
;
1198 mi64
.PdbAge
= miw64
.PdbAge
;
1199 mi64
.PdbUnmatched
= miw64
.PdbUnmatched
;
1200 mi64
.DbgUnmatched
= miw64
.DbgUnmatched
;
1201 mi64
.LineNumbers
= miw64
.LineNumbers
;
1202 mi64
.GlobalSymbols
= miw64
.GlobalSymbols
;
1203 mi64
.TypeInfo
= miw64
.TypeInfo
;
1204 mi64
.SourceIndexed
= miw64
.SourceIndexed
;
1205 mi64
.Publics
= miw64
.Publics
;
1206 mi64
.MachineType
= miw64
.MachineType
;
1207 mi64
.Reserved
= miw64
.Reserved
;
1209 memcpy(ModuleInfo
, &mi64
, ModuleInfo
->SizeOfStruct
);
1214 /******************************************************************
1215 * SymGetModuleInfoW64 (DBGHELP.@)
1218 BOOL WINAPI
SymGetModuleInfoW64(HANDLE hProcess
, DWORD64 dwAddr
,
1219 PIMAGEHLP_MODULEW64 ModuleInfo
)
1221 struct process
* pcs
= process_find_by_handle(hProcess
);
1222 struct module
* module
;
1223 IMAGEHLP_MODULEW64 miw64
;
1225 TRACE("%p %s %p\n", hProcess
, wine_dbgstr_longlong(dwAddr
), ModuleInfo
);
1227 if (!pcs
) return FALSE
;
1228 if (ModuleInfo
->SizeOfStruct
> sizeof(*ModuleInfo
)) return FALSE
;
1229 module
= module_find_by_addr(pcs
, dwAddr
, DMT_UNKNOWN
);
1230 if (!module
) return FALSE
;
1232 miw64
= module
->module
;
1234 /* update debug information from container if any */
1235 if (module
->module
.SymType
== SymNone
)
1237 module
= module_get_container(pcs
, module
);
1238 if (module
&& module
->module
.SymType
!= SymNone
)
1240 miw64
.SymType
= module
->module
.SymType
;
1241 miw64
.NumSyms
= module
->module
.NumSyms
;
1244 memcpy(ModuleInfo
, &miw64
, ModuleInfo
->SizeOfStruct
);
1248 /***********************************************************************
1249 * SymGetModuleBase (DBGHELP.@)
1251 DWORD WINAPI
SymGetModuleBase(HANDLE hProcess
, DWORD dwAddr
)
1255 ret
= SymGetModuleBase64(hProcess
, dwAddr
);
1256 return validate_addr64(ret
) ? ret
: 0;
1259 /***********************************************************************
1260 * SymGetModuleBase64 (DBGHELP.@)
1262 DWORD64 WINAPI
SymGetModuleBase64(HANDLE hProcess
, DWORD64 dwAddr
)
1264 struct process
* pcs
= process_find_by_handle(hProcess
);
1265 struct module
* module
;
1268 module
= module_find_by_addr(pcs
, dwAddr
, DMT_UNKNOWN
);
1269 if (!module
) return 0;
1270 return module
->module
.BaseOfImage
;
1273 /******************************************************************
1274 * module_reset_debug_info
1275 * Removes any debug information linked to a given module.
1277 void module_reset_debug_info(struct module
* module
)
1279 module
->sortlist_valid
= TRUE
;
1280 module
->sorttab_size
= 0;
1281 module
->addr_sorttab
= NULL
;
1282 module
->num_sorttab
= module
->num_symbols
= 0;
1283 hash_table_destroy(&module
->ht_symbols
);
1284 module
->ht_symbols
.num_buckets
= 0;
1285 module
->ht_symbols
.buckets
= NULL
;
1286 hash_table_destroy(&module
->ht_types
);
1287 module
->ht_types
.num_buckets
= 0;
1288 module
->ht_types
.buckets
= NULL
;
1289 module
->vtypes
.num_elts
= 0;
1290 hash_table_destroy(&module
->ht_symbols
);
1291 module
->sources_used
= module
->sources_alloc
= 0;
1292 module
->sources
= NULL
;
1295 /******************************************************************
1296 * SymRefreshModuleList (DBGHELP.@)
1298 BOOL WINAPI
SymRefreshModuleList(HANDLE hProcess
)
1300 struct process
* pcs
;
1302 TRACE("(%p)\n", hProcess
);
1304 if (!(pcs
= process_find_by_handle(hProcess
))) return FALSE
;
1306 return pcs
->loader
->synchronize_module_list(pcs
);
1309 /***********************************************************************
1310 * SymFunctionTableAccess (DBGHELP.@)
1312 PVOID WINAPI
SymFunctionTableAccess(HANDLE hProcess
, DWORD AddrBase
)
1314 return SymFunctionTableAccess64(hProcess
, AddrBase
);
1317 /***********************************************************************
1318 * SymFunctionTableAccess64 (DBGHELP.@)
1320 PVOID WINAPI
SymFunctionTableAccess64(HANDLE hProcess
, DWORD64 AddrBase
)
1322 struct process
* pcs
= process_find_by_handle(hProcess
);
1323 struct module
* module
;
1325 if (!pcs
|| !dbghelp_current_cpu
->find_runtime_function
) return NULL
;
1326 module
= module_find_by_addr(pcs
, AddrBase
, DMT_UNKNOWN
);
1327 if (!module
) return NULL
;
1329 return dbghelp_current_cpu
->find_runtime_function(module
, AddrBase
);
1332 static BOOL
native_synchronize_module_list(struct process
* pcs
)
1337 static struct module
* native_load_module(struct process
* pcs
, const WCHAR
* name
, ULONG_PTR addr
)
1342 static BOOL
native_load_debug_info(struct process
* process
, struct module
* module
)
1347 static BOOL
native_enum_modules(struct process
*process
, enum_modules_cb cb
, void* user
)
1352 static BOOL
native_fetch_file_info(struct process
* process
, const WCHAR
* name
, ULONG_PTR load_addr
, DWORD_PTR
* base
,
1353 DWORD
* size
, DWORD
* checksum
)
1358 const struct loader_ops no_loader_ops
=
1360 native_synchronize_module_list
,
1362 native_load_debug_info
,
1363 native_enum_modules
,
1364 native_fetch_file_info
,