DBG: actually use findSymbolsByPrefix
This commit is contained in:
parent
876abcdf10
commit
73b30ed49b
|
|
@ -372,38 +372,31 @@ static bool _modrelocationsinrange(duint addr, duint size, ListOf(DBGRELOCATIONI
|
|||
return true;
|
||||
}
|
||||
|
||||
typedef struct _SYMAUTOCOMPLETECALLBACKPARAM
|
||||
{
|
||||
char** Buffer;
|
||||
int* count;
|
||||
int MaxSymbols;
|
||||
} SYMAUTOCOMPLETECALLBACKPARAM;
|
||||
|
||||
static BOOL CALLBACK SymAutoCompleteCallback(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
|
||||
{
|
||||
SYMAUTOCOMPLETECALLBACKPARAM* param = reinterpret_cast<SYMAUTOCOMPLETECALLBACKPARAM*>(UserContext);
|
||||
if(param->Buffer)
|
||||
{
|
||||
param->Buffer[*param->count] = (char*)BridgeAlloc(pSymInfo->NameLen + 1);
|
||||
memcpy(param->Buffer[*param->count], pSymInfo->Name, pSymInfo->NameLen + 1);
|
||||
param->Buffer[*param->count][pSymInfo->NameLen] = 0;
|
||||
}
|
||||
if(++*param->count >= param->MaxSymbols)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int SymAutoComplete(const char* Search, char** Buffer, int MaxSymbols)
|
||||
{
|
||||
//debug
|
||||
int count = 0;
|
||||
SYMAUTOCOMPLETECALLBACKPARAM param;
|
||||
param.Buffer = Buffer;
|
||||
param.count = &count;
|
||||
param.MaxSymbols = MaxSymbols;
|
||||
if(!SafeSymEnumSymbols(fdProcessInfo->hProcess, 0, Search, SymAutoCompleteCallback, ¶m))
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "SymEnumSymbols failed!"));
|
||||
//TODO: refactor this in a function because this pattern will become common
|
||||
std::vector<duint> mods;
|
||||
ModEnum([&mods](const MODINFO & info)
|
||||
{
|
||||
mods.push_back(info.base);
|
||||
});
|
||||
std::string prefix(Search);
|
||||
for(duint base : mods)
|
||||
{
|
||||
SHARED_ACQUIRE(LockModules);
|
||||
auto modInfo = ModInfoFromAddr(base);
|
||||
if(modInfo && modInfo->symbols->isOpen())
|
||||
{
|
||||
modInfo->symbols->findSymbolsByPrefix(prefix, [Buffer, MaxSymbols, &count](const SymbolInfo & symInfo)
|
||||
{
|
||||
Buffer[count] = (char*)BridgeAlloc(symInfo.decoratedName.size() + 1);
|
||||
memcpy(Buffer[count], symInfo.decoratedName.c_str(), symInfo.decoratedName.size() + 1);
|
||||
Buffer[count][symInfo.decoratedName.size()] = 0; //TODO: not needed?
|
||||
return ++count < MaxSymbols;
|
||||
}, true); //TODO: support case insensitive in the GUI
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ bool SymAddrFromName(const char* Name, duint* Address)
|
|||
if(!_strnicmp(Name, "Ordinal", 7))
|
||||
return false;
|
||||
|
||||
//TODO: refactor this in a function because this pattern will become common
|
||||
std::vector<duint> mods;
|
||||
ModEnum([&mods](const MODINFO & info)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ bool SymbolSourcePDB::loadSymbolsAsync(String path)
|
|||
symInfo.disp = sym.disp;
|
||||
symInfo.addr = sym.virtualAddress;
|
||||
symInfo.publicSymbol = sym.publicSymbol;
|
||||
_symData.push_back(symInfo);
|
||||
|
||||
// Check if we already have it inside, private symbols have priority over public symbols.
|
||||
// TODO: only use this map during initialization phase
|
||||
|
|
@ -137,11 +136,12 @@ bool SymbolSourcePDB::loadSymbolsAsync(String path)
|
|||
if(_symData[it->second].publicSymbol == true && symInfo.publicSymbol == false)
|
||||
{
|
||||
// Replace.
|
||||
it->second = _symData.size() - 1;
|
||||
_symData[it->second] = symInfo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_symData.push_back(symInfo);
|
||||
_symAddrs.insert({ symInfo.addr, _symData.size() - 1 });
|
||||
}
|
||||
}
|
||||
|
|
@ -450,9 +450,9 @@ bool SymbolSourcePDB::findSymbolsByPrefix(const std::string & prefix, const std:
|
|||
return false;
|
||||
|
||||
bool result = false;
|
||||
for(; found != _symNameMap.end() && prefixCmp.cmp(find, *found, false); ++found)
|
||||
for(; found != _symNameMap.end() && prefixCmp.cmp(find, *found, false) == 0; ++found)
|
||||
{
|
||||
if(!caseSensitive || prefixCmp.cmp(find, *found, true))
|
||||
if(!caseSensitive || prefixCmp.cmp(find, *found, true) == 0)
|
||||
{
|
||||
result = true;
|
||||
if(!cbSymbol(_symData.at(found->index)))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ QVariant SymbolAutoCompleteModel::data(const QModelIndex & index, int role) cons
|
|||
|
||||
void SymbolAutoCompleteModel::update() const
|
||||
{
|
||||
QString text = "*!" + mGetTextProc() + "*";
|
||||
QString text = mGetTextProc();
|
||||
if(text == lastAutocompleteText)
|
||||
return;
|
||||
char* data[MAXAUTOCOMPLETEENTRY];
|
||||
|
|
|
|||
Loading…
Reference in New Issue