Skip to content

Commit e0fbfa5

Browse files
Eric Pouechrbernon
authored andcommitted
dbghelp: Change the order in which we try to load modules.
Change from: dll.so > PE image > ELF/Mach-O image into PE image > dll.so > ELF/Mach-O image and only resychronizing ELF/Mach-O modules after PE image loading failed. This reduces quite a lot loading time for PE images (6/7ms => 1/2ms, local values, YMMV). CW-Bug-Id: https://www.codeweavers.com/support/bugs/browse/?cmd=bug_edit;bug_id=23138
1 parent c399f9d commit e0fbfa5

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

dlls/dbghelp/module.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,12 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
949949
}
950950
}
951951

952-
pcs->loader->synchronize_module_list(pcs);
953-
954952
/* this is a Wine extension to the API just to redo the synchronisation */
955-
if (!wImageName && !hFile) return 0;
953+
if (!wImageName && !hFile)
954+
{
955+
pcs->loader->synchronize_module_list(pcs);
956+
return 0;
957+
}
956958

957959
if (Flags & SLMFLAG_VIRTUAL)
958960
{
@@ -961,27 +963,30 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
961963
if (!module) return 0;
962964
module->module.SymType = SymVirtual;
963965
}
964-
/* check if it's a builtin PE module with a containing ELF module */
965-
else if (wImageName && module_is_container_loaded(pcs, wImageName, BaseOfDll))
966-
{
967-
/* force the loading of DLL as builtin */
968-
module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll);
969-
}
970-
if (!module)
966+
else
971967
{
972-
/* otherwise, try a regular PE module */
973-
if (!(module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll)) &&
974-
wImageName)
968+
/* otherwise, try a regular PE image */
969+
module = pe_load_native_module(pcs, wImageName, hFile, BaseOfDll, SizeOfDll);
970+
if (!module && wImageName)
975971
{
976-
/* and finally an ELF or Mach-O module */
977-
module = pcs->loader->load_module(pcs, wImageName, BaseOfDll);
972+
/* It could be either a dll.so file (for which we need the corresponding
973+
* system module) or a system module.
974+
* In both cases, ensure system module list is up-to-date.
975+
*/
976+
pcs->loader->synchronize_module_list(pcs);
977+
/* try a dll.so... */
978+
if (module_is_container_loaded(pcs, wImageName, BaseOfDll))
979+
module = pe_load_builtin_module(pcs, wImageName, BaseOfDll, SizeOfDll);
980+
/* at last, try ELF or Mach-O module */
981+
if (!module)
982+
module = pcs->loader->load_module(pcs, wImageName, BaseOfDll);
983+
}
984+
if (!module)
985+
{
986+
WARN("Couldn't locate %s\n", debugstr_w(wImageName));
987+
SetLastError(ERROR_NO_MORE_FILES);
988+
return 0;
978989
}
979-
}
980-
if (!module)
981-
{
982-
WARN("Couldn't locate %s\n", debugstr_w(wImageName));
983-
SetLastError(ERROR_NO_MORE_FILES);
984-
return 0;
985990
}
986991
/* by default module_new fills module.ModuleName from a derivation
987992
* of LoadedImageName. Overwrite it, if we have better information

0 commit comments

Comments
 (0)