DBG: fall back to resolving modules exports when no symbol is found
This commit is contained in:
parent
73a5ffebd9
commit
45b49995f3
|
@ -15,7 +15,6 @@ struct SymbolInfo
|
|||
String decoratedName;
|
||||
String undecoratedName;
|
||||
bool publicSymbol;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct LineInfo
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue