1
0
Fork 0

DBG: fix a rare bug with module resolving by name (thanks to chessgod101!)

if you had:
blub.exe
blub.exe.dll

And tried to resolve 'blub.exe' it could return the base of 'blub.exe.dll'
This commit is contained in:
Duncan Ogilvie 2017-12-24 13:21:06 +01:00
parent 2106873f55
commit 761e2f67c0
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 9 additions and 3 deletions

View File

@ -424,6 +424,8 @@ duint ModBaseFromName(const char* Module)
ASSERT_TRUE(len < MAX_MODULE_SIZE);
SHARED_ACQUIRE(LockModules);
//TODO: refactor this to query from a map
duint candidate = 0;
for(const auto & i : modinfo)
{
const auto & currentModule = i.second;
@ -431,12 +433,16 @@ duint ModBaseFromName(const char* Module)
strcpy_s(currentModuleName, currentModule.name);
strcat_s(currentModuleName, currentModule.extension);
// Test with and without extension
if(!_stricmp(currentModuleName, Module) || !_stricmp(currentModule.name, Module))
// Compare with extension (perfect match)
if(!_stricmp(currentModuleName, Module))
return currentModule.base;
// Compare without extension, possible candidate (thanks to chessgod101 for finding this)
if(!candidate && !_stricmp(currentModule.name, Module))
candidate = currentModule.base;
}
return 0;
return candidate;
}
duint ModSizeFromAddr(duint Address)