1
0
Fork 0

GUI: code recuction + intelligent following of addresses

This commit is contained in:
mrexodia 2016-09-09 09:31:29 +02:00
parent 71059e2c34
commit 12cff2b811
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
21 changed files with 43 additions and 83 deletions

View File

@ -1294,7 +1294,7 @@ CMDRESULT cbInstrFindAll(int argc, char* argv[])
GuiReferenceInitialize(patterntitle);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
if(findData)
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "&Data&")));
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Data")));
else
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Disassembly")));
GuiReferenceSetRowCount(0);
@ -1411,7 +1411,7 @@ CMDRESULT cbInstrFindMemAll(int argc, char* argv[])
GuiReferenceInitialize(patterntitle);
GuiReferenceAddColumn(2 * sizeof(duint), GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Address")));
if(findData)
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "&Data&")));
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Data")));
else
GuiReferenceAddColumn(0, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Disassembly")));
GuiReferenceSetRowCount(0);

View File

@ -10,7 +10,6 @@ ReferenceView::ReferenceView(bool sourceView, QWidget* parent) : SearchListView(
{
// Setup SearchListView settings
mSearchStartCol = 1;
mFollowDumpDefault = false;
// Widget container for progress
QWidget* progressWidget = new QWidget();
@ -148,10 +147,7 @@ void ReferenceView::addColumnAt(int width, QString title)
width = 0;
mSearchBox->setText("");
if(title.toLower() == "&data&")
{
mFollowDumpDefault = true;
title = "Data";
}
mList->addColumnAt(width, title, true);
mSearchList->addColumnAt(width, title, true);
}
@ -228,28 +224,28 @@ void ReferenceView::referenceContextMenu(QMenu* wMenu)
void ReferenceView::followAddress()
{
DbgCmdExecDirect(QString("disasm " + mCurList->getCellContent(mCurList->getInitialSelection(), 0)).toUtf8().constData());
emit showCpu();
}
void ReferenceView::followDumpAddress()
{
DbgCmdExecDirect(QString("dump " + mCurList->getCellContent(mCurList->getInitialSelection(), 0)).toUtf8().constData());
emit showCpu();
}
void ReferenceView::followApiAddress()
{
dsint apiValue = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1));
DbgCmdExecDirect(QString("disasm " + ToPtrString(apiValue)).toUtf8().constData());
emit showCpu();
}
void ReferenceView::followGenericAddress()
{
if(mFollowDumpDefault)
followDumpAddress();
else
auto addr = DbgValFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 0).toUtf8().constData());
if(!addr)
return;
if(DbgFunctions()->MemIsCodePage(addr, false))
followAddress();
else
followDumpAddress();
}
void ReferenceView::setBreakpointAt(int row, BPSetAction action)

View File

@ -54,8 +54,6 @@ private:
QAction* mRemoveBreakpointOnAllApiCalls;
QLabel* mCountTotalLabel;
bool mFollowDumpDefault;
enum BPSetAction
{
Enable,

View File

@ -432,7 +432,6 @@ void BreakpointsView::doubleClickHardwareSlot()
StdTable* table = mHardBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
void BreakpointsView::selectionChangedHardwareSlot()
@ -593,7 +592,6 @@ void BreakpointsView::doubleClickSoftwareSlot()
StdTable* table = mSoftBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
void BreakpointsView::selectionChangedSoftwareSlot()
@ -754,7 +752,6 @@ void BreakpointsView::doubleClickMemorySlot()
StdTable* table = mMemBPTable;
QString addrText = table->getCellContent(table->getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
void BreakpointsView::selectionChangedMemorySlot()

View File

@ -20,9 +20,6 @@ public:
void setupMemBPRightClickContextMenu();
void setupDLLBPRightClickContextMenu();
signals:
void showCpu();
public slots:
void refreshShortcutsSlot();
void reloadData();

View File

@ -152,7 +152,6 @@ QString CalculatorDialog::inFormat(const duint val, CalculatorDialog::NUMBERFORM
void CalculatorDialog::on_btnGoto_clicked()
{
DbgCmdExecDirect(QString("disasm " + ui->txtExpression->text()).toUtf8().constData());
emit showCpu();
}
void CalculatorDialog::on_txtHex_textEdited(const QString & arg1)
@ -253,5 +252,4 @@ void CalculatorDialog::on_txtUnicode_textEdited(const QString & arg1)
void CalculatorDialog::on_btnGotoDump_clicked()
{
DbgCmdExecDirect(QString("dump " + ui->txtExpression->text()).toUtf8().constData());
emit showCpu();
}

View File

@ -36,7 +36,6 @@ public:
signals:
bool validAddress(bool valid);
void showCpu();
private slots:
void expressionChanged(bool validExpression, bool validPointer, dsint value);

View File

@ -77,19 +77,16 @@ void CallStackView::followAddress()
{
QString addrText = getCellContent(getInitialSelection(), 0);
DbgCmdExecDirect(QString("sdump " + addrText).toUtf8().constData());
emit showCpu();
}
void CallStackView::followTo()
{
QString addrText = getCellContent(getInitialSelection(), 1);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}
void CallStackView::followFrom()
{
QString addrText = getCellContent(getInitialSelection(), 2);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}

View File

@ -10,9 +10,6 @@ public:
explicit CallStackView(StdTable* parent = 0);
void setupContextMenu();
signals:
void showCpu();
protected slots:
void updateCallStack();
void contextMenuSlot(const QPoint pos);

View File

@ -1338,7 +1338,6 @@ void DisassemblerGraphView::setupContextMenu()
void DisassemblerGraphView::followDisassemblerSlot()
{
DbgCmdExec(QString("disasm %1").arg(ToPtrString(this->cur_instr)).toUtf8().constData());
emit showCpu();
}
void DisassemblerGraphView::colorsUpdatedSlot()

View File

@ -259,9 +259,6 @@ public slots:
void shortcutsUpdatedSlot();
void toggleOverviewSlot();
signals:
void showCpu();
private:
QString status;
Analysis analysis;

View File

@ -82,6 +82,10 @@ MainWindow::MainWindow(QWidget* parent)
connect(Bridge::getBridge(), SIGNAL(addFavouriteItem(int, QString, QString)), this, SLOT(addFavouriteItem(int, QString, QString)));
connect(Bridge::getBridge(), SIGNAL(setFavouriteItemShortcut(int, QString, QString)), this, SLOT(setFavouriteItemShortcut(int, QString, QString)));
connect(Bridge::getBridge(), SIGNAL(selectInMemoryMap(duint)), this, SLOT(displayMemMapWidget()));
connect(Bridge::getBridge(), SIGNAL(disassembleAt(dsint, dsint)), this, SLOT(displayCpuWidget()));
connect(Bridge::getBridge(), SIGNAL(dumpAt(dsint)), this, SLOT(displayCpuWidget()));
connect(Bridge::getBridge(), SIGNAL(dumpAtN(duint, int)), this, SLOT(displayCpuWidget()));
connect(Bridge::getBridge(), SIGNAL(stackDumpAt(duint, duint)), this, SLOT(displayCpuWidget()));
// Setup menu API
initMenuApi();
@ -119,18 +123,16 @@ MainWindow::MainWindow(QWidget* parent)
mSourceViewManager->setWindowTitle(tr("Source"));
mSourceViewManager->setWindowIcon(DIcon("source.png"));
mSourceViewManager->hide();
connect(mSourceViewManager, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
// Breakpoints
mBreakpointsView = new BreakpointsView();
mBreakpointsView->setWindowTitle(tr("Breakpoints"));
mBreakpointsView->setWindowIcon(DIcon("breakpoint.png"));
mBreakpointsView->hide();
connect(mBreakpointsView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
// Memory map view
mMemMapView = new MemoryMapView();
connect(mMemMapView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
connect(mMemMapView, SIGNAL(showReferences()), this, SLOT(displayReferencesWidget()));
mMemMapView->setWindowTitle(tr("Memory Map"));
mMemMapView->setWindowIcon(DIcon("memory-map.png"));
@ -140,13 +142,11 @@ MainWindow::MainWindow(QWidget* parent)
mCallStackView = new CallStackView();
mCallStackView->setWindowTitle(tr("Call Stack"));
mCallStackView->setWindowIcon(DIcon("callstack.png"));
connect(mCallStackView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
// SEH Chain view
mSEHChainView = new SEHChainView();
mSEHChainView->setWindowTitle(tr("SEH"));
mSEHChainView->setWindowIcon(DIcon("seh-chain.png"));
connect(mSEHChainView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
// Script view
mScriptView = new ScriptView();
@ -172,7 +172,6 @@ MainWindow::MainWindow(QWidget* parent)
// Thread view
mThreadView = new ThreadView();
connect(mThreadView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
mThreadView->setWindowTitle(tr("Threads"));
mThreadView->setWindowIcon(DIcon("arrow-threads.png"));
@ -248,7 +247,6 @@ MainWindow::MainWindow(QWidget* parent)
// Patch dialog
mPatchDialog = new PatchDialog(this);
mCalculatorDialog = new CalculatorDialog(this);
connect(mCalculatorDialog, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
// Setup signals/slots
connect(mCmdLineEdit, SIGNAL(returnPressed()), this, SLOT(executeCommand()));
@ -290,10 +288,7 @@ MainWindow::MainWindow(QWidget* parent)
connect(ui->actionCpu, SIGNAL(triggered()), this, SLOT(displayCpuWidget()));
connect(ui->actionSymbolInfo, SIGNAL(triggered()), this, SLOT(displaySymbolWidget()));
connect(ui->actionSource, SIGNAL(triggered()), this, SLOT(displaySourceViewWidget()));
connect(mSymbolView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
connect(mSymbolView, SIGNAL(showReferences()), this, SLOT(displayReferencesWidget()));
connect(mReferenceManager, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
connect(mGraphView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
connect(ui->actionReferences, SIGNAL(triggered()), this, SLOT(displayReferencesWidget()));
connect(ui->actionThreads, SIGNAL(triggered()), this, SLOT(displayThreadsWidget()));
connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(openSettings()));

View File

@ -46,11 +46,9 @@ void MemoryMapView::setupContextMenu()
//Follow in Disassembler
mFollowDisassembly = new QAction(DIcon(ArchValue("processor32.png", "processor64.png")), tr("Follow in &Disassembler"), this);
mFollowDisassembly->setShortcutContext(Qt::WidgetShortcut);
mFollowDisassembly->setShortcut(QKeySequence("enter"));
connect(mFollowDisassembly, SIGNAL(triggered()), this, SLOT(followDisassemblerSlot()));
connect(this, SIGNAL(enterPressedSignal()), this, SLOT(followDisassemblerSlot()));
connect(this, SIGNAL(doubleClickedSignal()), this, SLOT(followDisassemblerSlot()));
connect(this, SIGNAL(enterPressedSignal()), this, SLOT(doubleClickedSlot()));
connect(this, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
//Yara
mYara = new QAction(DIcon("yara.png"), "&Yara...", this);
@ -379,22 +377,23 @@ void MemoryMapView::stateChangedSlot(DBGSTATE state)
void MemoryMapView::followDumpSlot()
{
QString addr_text = getCellContent(getInitialSelection(), 0);
DbgCmdExecDirect(QString("dump " + addr_text).toUtf8().constData());
emit showCpu();
DbgCmdExec(QString("dump %1").arg(getCellContent(getInitialSelection(), 0)).toUtf8().constData());
}
void MemoryMapView::followDisassemblerSlot()
{
QString commandText = QString("disasm %1").arg(getCellContent(getInitialSelection(), 0));
DbgCmdExec(QString("disasm %1").arg(getCellContent(getInitialSelection(), 0)).toUtf8().constData());
}
// If there was no address loaded, the length
// will only be the command length
if(commandText.length() <= 8)
void MemoryMapView::doubleClickedSlot()
{
auto addr = DbgValFromString(getCellContent(getInitialSelection(), 0).toUtf8().constData());
if(!addr)
return;
DbgCmdExecDirect(commandText.toUtf8().constData());
emit showCpu();
if(DbgFunctions()->MemIsCodePage(addr, false))
followDisassemblerSlot();
else
followDumpSlot();
}
void MemoryMapView::yaraSlot()
@ -522,8 +521,7 @@ void MemoryMapView::memoryAllocateSlot()
duint addr = DbgValFromString("$result");
if(addr != 0)
{
DbgCmdExec("Dump $result");
emit showCpu();
DbgCmdExec("dump $result");
}
else
{

View File

@ -12,7 +12,6 @@ public:
void setupContextMenu();
signals:
void showCpu();
void showReferences();
public slots:
@ -20,6 +19,7 @@ public slots:
void stateChangedSlot(DBGSTATE state);
void followDumpSlot();
void followDisassemblerSlot();
void doubleClickedSlot();
void yaraSlot();
void memoryAccessSingleshootSlot();
void memoryAccessRestoreSlot();

View File

@ -86,12 +86,10 @@ void SEHChainView::followAddress()
{
QString addrText = getCellContent(getInitialSelection(), 0);
DbgCmdExecDirect(QString("sdump " + addrText).toUtf8().constData());
emit showCpu();
}
void SEHChainView::followHandler()
{
QString addrText = getCellContent(getInitialSelection(), 1);
DbgCmdExecDirect(QString("disasm " + addrText).toUtf8().constData());
emit showCpu();
}

View File

@ -10,9 +10,6 @@ public:
explicit SEHChainView(StdTable* parent = 0);
void setupContextMenu();
signals:
void showCpu();
protected slots:
void updateSEHChain();
void contextMenuSlot(const QPoint pos);

View File

@ -17,9 +17,6 @@ public slots:
void closeTab(int index);
void closeAllTabs();
signals:
void showCpu();
private:
QPushButton* mCloseAllTabs;
};

View File

@ -90,7 +90,7 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
connect(Bridge::getBridge(), SIGNAL(setSymbolProgress(int)), ui->symbolProgress, SLOT(setValue(int)));
connect(Bridge::getBridge(), SIGNAL(symbolRefreshCurrent()), this, SLOT(symbolRefreshCurrent()));
connect(mSearchListView, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(symbolContextMenu(QMenu*)));
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(symbolFollow()));
connect(mSearchListView, SIGNAL(enterPressedSignal()), this, SLOT(enterPressedSlot()));
}
SymbolView::~SymbolView()
@ -103,8 +103,6 @@ void SymbolView::setupContextMenu()
QIcon disassembler = DIcon(ArchValue("processor32.png", "processor64.png"));
//Symbols
mFollowSymbolAction = new QAction(disassembler, tr("&Follow in Disassembler"), this);
mFollowSymbolAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
mFollowSymbolAction->setShortcut(QKeySequence("enter"));
connect(mFollowSymbolAction, SIGNAL(triggered()), this, SLOT(symbolFollow()));
mFollowSymbolDumpAction = new QAction(DIcon("dump.png"), tr("Follow in &Dump"), this);
@ -334,14 +332,23 @@ void SymbolView::symbolRefreshCurrent()
void SymbolView::symbolFollow()
{
DbgCmdExecDirect(QString("disasm " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
emit showCpu();
DbgCmdExec(QString("disasm " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
}
void SymbolView::symbolFollowDump()
{
DbgCmdExecDirect(QString("dump " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
emit showCpu();
DbgCmdExec(QString("dump " + mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0)).toUtf8().constData());
}
void SymbolView::enterPressedSlot()
{
auto addr = DbgValFromString(mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), 0).toUtf8().constData());
if(!addr)
return;
if(DbgFunctions()->MemIsCodePage(addr, false))
symbolFollow();
else
symbolFollowDump();
}
void SymbolView::moduleContextMenu(QMenu* wMenu)
@ -382,13 +389,11 @@ void SymbolView::moduleContextMenu(QMenu* wMenu)
void SymbolView::moduleFollow()
{
DbgCmdExecDirect(QString("disasm " + mModuleList->mCurList->getCellContent(mModuleList->mCurList->getInitialSelection(), 0) + "+1000").toUtf8().constData());
emit showCpu();
}
void SymbolView::moduleEntryFollow()
{
DbgCmdExecDirect(QString("disasm " + mModuleList->mCurList->getCellContent(mModuleList->mCurList->getInitialSelection(), 1) + ":entry").toUtf8().constData());
emit showCpu();
}
void SymbolView::moduleCopyPath()

View File

@ -30,6 +30,7 @@ private slots:
void updateSymbolList(int module_count, SYMBOLMODULEINFO* modules);
void symbolFollow();
void symbolFollowDump();
void enterPressedSlot();
void symbolContextMenu(QMenu* wMenu);
void symbolRefreshCurrent();
void moduleContextMenu(QMenu* wMenu);
@ -51,7 +52,6 @@ private slots:
void emptySearchResultSlot();
signals:
void showCpu();
void showReferences();
private:

View File

@ -18,7 +18,6 @@ void ThreadView::GoToThreadEntry()
{
QString addr_text = getCellContent(getInitialSelection(), 2);
DbgCmdExecDirect(QString("disasm " + addr_text).toUtf8().constData());
emit showCpu();
}
void ThreadView::setupContextMenu()
@ -376,7 +375,6 @@ void ThreadView::doubleClickedSlot()
{
QString threadId = getCellContent(getInitialSelection(), 1);
DbgCmdExecDirect(QString("switchthread " + threadId).toUtf8().constData());
emit showCpu();
}
void ThreadView::SetNameSlot()

View File

@ -20,9 +20,6 @@ public slots:
void contextMenuSlot(const QPoint & pos);
void SetNameSlot();
signals:
void showCpu();
private:
QAction* makeCommandAction(QAction* action, const QString & command);
QString mCurrentThreadId;