1
0
Fork 0

DBG: symbol enumeration

GUI: working symbol enumeration
This commit is contained in:
mr.exodia 2014-02-18 21:35:43 +01:00
parent a59d7cbc36
commit 549a08c6bd
11 changed files with 76 additions and 22 deletions

2
.gitignore vendored
View File

@ -22,11 +22,9 @@ x64_dbg_*/x64/*
!bin/*/test.dll
!bin/*/test.exe
!bin/*/dbghelp.dll
!bin/*/symsrv.dll
!bin/*/sqlite.dll
!bin/*/BeaEngine.dll
!bin/*/Scylla.dll
!bin/*/nasm.exe
#files to ignore
todo_bridge.txt

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -523,6 +523,15 @@ BRIDGE_IMPEXP void DbgScriptSetIp(int line)
_dbg_sendmessage(DBG_SCRIPT_SETIP, (void*)(duint)line, 0);
}
BRIDGE_IMPEXP void DbgSymbolEnum(duint base, CBSYMBOLENUM cbSymbolEnum, void* user)
{
SYMBOLCBINFO cbInfo;
cbInfo.base=base;
cbInfo.cbSymbolEnum=cbSymbolEnum;
cbInfo.user=user;
_dbg_sendmessage(DBG_SYMBOL_ENUM, &cbInfo, 0);
}
//GUI
BRIDGE_IMPEXP void GuiDisasmAt(duint addr, duint cip)
{

View File

@ -286,6 +286,8 @@ BRIDGE_IMPEXP void DbgScriptAbort();
BRIDGE_IMPEXP SCRIPTLINETYPE DbgScriptGetLineType(int line);
BRIDGE_IMPEXP void DbgScriptSetIp(int line);
BRIDGE_IMPEXP void DbgSymbolEnum(duint base, CBSYMBOLENUM cbSymbolEnum, void* user);
//Gui enums
enum GUIMSG
{

View File

@ -1,8 +1,44 @@
#include "symbolinfo.h"
#include "debugger.h"
#include "addrinfo.h"
static struct SYMBOLCBDATA
{
CBSYMBOLENUM cbSymbolEnum;
void* user;
};
static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
{
int len=strlen(pSymInfo->Name);
SYMBOLINFO curSymbol;
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
curSymbol.addr=pSymInfo->Address;
curSymbol.decoratedSymbol=(char*)BridgeAlloc(len+1);
strcpy(curSymbol.decoratedSymbol, pSymInfo->Name);
curSymbol.undecoratedSymbol=(char*)BridgeAlloc(MAX_SYM_NAME);
if(!UnDecorateSymbolName(pSymInfo->Name, curSymbol.undecoratedSymbol, MAX_SYM_NAME, UNDNAME_COMPLETE))
{
BridgeFree(curSymbol.undecoratedSymbol);
curSymbol.undecoratedSymbol=0;
}
else if(!strcmp(curSymbol.decoratedSymbol, curSymbol.undecoratedSymbol))
{
BridgeFree(curSymbol.undecoratedSymbol);
curSymbol.undecoratedSymbol=0;
}
SYMBOLCBDATA* cbData=(SYMBOLCBDATA*)UserContext;
cbData->cbSymbolEnum(&curSymbol, cbData->user);
return TRUE;
}
void symbolenum(uint base, CBSYMBOLENUM cbSymbolEnum, void* user)
{
SYMBOLCBDATA symbolCbData;
symbolCbData.cbSymbolEnum=cbSymbolEnum;
symbolCbData.user=user;
char mask[]="*";
SymEnumSymbols(fdProcessInfo->hProcess, base, mask, EnumSymbols, &symbolCbData);
}
#ifdef _WIN64
@ -14,7 +50,7 @@ static BOOL CALLBACK EnumModules(PCTSTR ModuleName, ULONG BaseOfDll, PVOID UserC
SYMBOLMODULEINFO curModule;
memset(&curModule, 0, sizeof(SYMBOLMODULEINFO));
curModule.base=BaseOfDll;
strcpy(curModule.name, ModuleName);
modnamefromaddr(BaseOfDll, curModule.name, true);
((std::vector<SYMBOLMODULEINFO>*)UserContext)->push_back(curModule);
return TRUE;
}
@ -23,7 +59,7 @@ void symbolupdatemodulelist()
{
std::vector<SYMBOLMODULEINFO> modList;
modList.clear();
//SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList);
SymEnumerateModules(fdProcessInfo->hProcess, EnumModules, &modList);
int modcount=modList.size();
SYMBOLMODULEINFO* modListBridge=(SYMBOLMODULEINFO*)BridgeAlloc(sizeof(SYMBOLMODULEINFO)*modcount);
for(int i=0; i<modcount; i++)

View File

@ -2,7 +2,6 @@
#include <windows.h>
#include "resource.h"
#include "..\x64_dbg_bridge\bridgemain.h"
#include "..\x64_dbg_crash\x64_dbg_crash.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{

View File

@ -53,7 +53,6 @@ SymbolView::SymbolView(QWidget *parent) :
connect(mModuleList, SIGNAL(selectionChangedSignal(int)), this, SLOT(moduleSelectionChanged(int)));
connect(Bridge::getBridge(), SIGNAL(updateSymbolList(int,SYMBOLMODULEINFO*)), this, SLOT(updateSymbolList(int,SYMBOLMODULEINFO*)));
connect(Bridge::getBridge(), SIGNAL(setSymbolProgress(int)), ui->symbolProgress, SLOT(setValue(int)));
emit mModuleList->selectionChangedSignal(0);
}
SymbolView::~SymbolView()
@ -72,20 +71,44 @@ void SymbolView::clearSymbolLogSlot()
ui->symbolLogEdit->clear();
}
void SymbolView::cbSymbolEnum(SYMBOLINFO* symbol, void* user)
{
StdTable* symbolList=(StdTable*)user;
int_t index=symbolList->getRowCount();
symbolList->setRowCount(index+1);
symbolList->setCellContent(index, 0, QString("%1").arg(symbol->addr, sizeof(int_t)*2, 16, QChar('0')).toUpper());
if(symbol->decoratedSymbol)
{
symbolList->setCellContent(index, 1, symbol->decoratedSymbol);
BridgeFree(symbol->decoratedSymbol);
}
if(symbol->undecoratedSymbol)
{
symbolList->setCellContent(index, 2, symbol->undecoratedSymbol);
BridgeFree(symbol->undecoratedSymbol);
}
}
void SymbolView::moduleSelectionChanged(int index)
{
mSymbolList->setRowCount(0);
DbgSymbolEnum(moduleBaseList.at(index), cbSymbolEnum, mSymbolList);
mSymbolList->reloadData();
}
void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
{
mModuleList->setRowCount(module_count);
QList<uint_t> empty;
empty.clear();
empty.swap(moduleBaseList);
for(int i=0; i<module_count; i++)
{
moduleBaseList.push_back(modules[i].base);
mModuleList->setCellContent(i, 0, QString("%1").arg(modules[i].base, sizeof(int_t)*2, 16, QChar('0')).toUpper());
mModuleList->setCellContent(i, 1, modules[i].name);
}
mModuleList->reloadData();
if(modules)
BridgeFree(modules);
this->moduleSelectionChanged(0);
}

View File

@ -32,22 +32,9 @@ private:
StdTable* mModuleList;
StdTable* mSymbolList;
struct SymbolInfo_t
{
uint_t addr;
QString decoratedSymbol;
QString undecoratedSymbol;
};
struct ModuleInfo_t
{
uint_t base;
QString name;
QList<SymbolInfo_t> symbols;
};
QList<ModuleInfo_t> moduleList;
QList<uint_t> moduleBaseList;
static void cbSymbolEnum(SYMBOLINFO* symbol, void* user);
};
#endif // SYMBOLVIEW_H