Call SymLoadModuleEx for modules loaded after init

This fixes issue #293. Symbols are not loaded if the module is loaded dynamically after the SymInitialize call.
This may stall the symbol resolver thread a bit the first time a module is loaded.
This commit is contained in:
Lectem 2021-12-08 21:30:06 +01:00
parent 14392a6e0e
commit 17855cbac5

View File

@ -296,6 +296,8 @@ static const char* GetModuleName( uint64_t addr )
const auto res = GetModuleFileNameA( mod[i], name, 1021 ); const auto res = GetModuleFileNameA( mod[i], name, 1021 );
if( res > 0 ) if( res > 0 )
{ {
// since this is the first time we encounter this module, load its symbols (needed for modules loaded after SymInitialize)
SymLoadModuleEx(proc, NULL, name, NULL, (DWORD64)info.lpBaseOfDll, info.SizeOfImage, NULL, 0);
auto ptr = name + res; auto ptr = name + res;
while( ptr > name && *ptr != '\\' && *ptr != '/' ) ptr--; while( ptr > name && *ptr != '\\' && *ptr != '/' ) ptr--;
if( ptr > name ) ptr++; if( ptr > name ) ptr++;