1
0
Fork 0

DBG: fall back to resolving modules exports when no symbol is found

This commit is contained in:
Duncan Ogilvie 2018-02-12 03:09:00 +01:00
parent 73a5ffebd9
commit 45b49995f3
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 30 additions and 10 deletions

View File

@ -15,7 +15,6 @@ struct SymbolInfo
String decoratedName;
String undecoratedName;
bool publicSymbol;
bool valid;
};
struct LineInfo

View File

@ -2,15 +2,13 @@
#include "dbghelp_safe.h"
#include "addrinfo.h"
#include "threading.h"
#include "sortedlru.h"
#include <algorithm>
template<typename T>
/*template<typename T>
using RangeMap = std::map<Range, T, RangeCompare>;
static RangeMap<RangeMap<SymbolInfo>> symbolRange;
static std::unordered_map<duint, duint> symbolName;
static SortedLRU<duint, SymbolInfo> symbolCache;
static std::unordered_map<duint, duint> symbolName;*/
bool SymbolFromAddressExact(duint address, SymbolInfo & symInfo)
{
@ -21,11 +19,34 @@ bool SymbolFromAddressExact(duint address, SymbolInfo & symInfo)
MODINFO* modInfo = ModInfoFromAddr(address);
if(modInfo)
{
if(modInfo->symbols->isOpen() == false)
return false;
duint rva = address - modInfo->base;
return modInfo->symbols->findSymbolExact(rva, symInfo);
// search in symbols
if(modInfo->symbols->isOpen())
{
if(modInfo->symbols->findSymbolExact(rva, symInfo))
return true;
}
// search in module exports
if(modInfo->exports.size())
{
auto found = std::lower_bound(modInfo->exportsByRva.begin(), modInfo->exportsByRva.end(), rva, [&modInfo](size_t index, duint rva)
{
return modInfo->exports.at(index).rva < rva;
});
found = found != modInfo->exportsByRva.end() && rva >= modInfo->exports.at(*found).rva ? found : modInfo->exportsByRva.end();
if(found != modInfo->exportsByRva.end())
{
auto & modExport = modInfo->exports.at(*found);
symInfo.va = modExport.rva + modInfo->base;
symInfo.size = 0;
symInfo.disp = 0;
symInfo.decoratedName = modExport.name;
symInfo.publicSymbol = true;
return true;
}
}
}
return false;