context menu in xrefs dialog (#1244)
This commit is contained in:
parent
c1f15b2794
commit
bb51f6a898
|
@ -1 +1 @@
|
|||
Subproject commit 140b284bd5ff56392b29baccaade6dc4cc79e997
|
||||
Subproject commit 56df3a7d8f3f3af50299b86c918d016a82c481a8
|
|
@ -39,6 +39,8 @@ CustomizeMenuDialog::CustomizeMenuDialog(QWidget* parent) :
|
|||
viewName = tr("Threads");
|
||||
else if(id == "DisassemblerGraphView")
|
||||
viewName = tr("Graph");
|
||||
else if(id == "XrefBrowseDialog")
|
||||
viewName = tr("Xref Browser");
|
||||
else if(id == "CPUStack")
|
||||
viewName = tr("Stack");
|
||||
else if(id == "SourceView")
|
||||
|
|
|
@ -11,6 +11,10 @@ XrefBrowseDialog::XrefBrowseDialog(QWidget* parent) :
|
|||
setWindowIcon(DIcon("xrefs.png"));
|
||||
setModal(false);
|
||||
mXrefInfo.refcount = 0;
|
||||
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(onDebuggerClose(DBGSTATE)));
|
||||
|
||||
setupContextMenu();
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::setup(duint address, QString command)
|
||||
|
@ -40,6 +44,83 @@ void XrefBrowseDialog::setup(duint address, QString command)
|
|||
ui->listWidget->setFocus();
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::setupContextMenu()
|
||||
{
|
||||
mMenu = new MenuBuilder(this);
|
||||
mMenu->addAction(makeAction(DIcon("breakpoint_toggle.png"), tr("Toggle &Breakpoint"), SLOT(breakpointSlot())));
|
||||
//Breakpoint (hardware access) menu
|
||||
auto hardwareAccessMenu = makeMenu(DIcon("breakpoint_access.png"), tr("Hardware, Access"));
|
||||
hardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_byte.png"), tr("&Byte"), SLOT(hardwareAccess1Slot())));
|
||||
hardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_word.png"), tr("&Word"), SLOT(hardwareAccess2Slot())));
|
||||
hardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_dword.png"), tr("&Dword"), SLOT(hardwareAccess4Slot())));
|
||||
#ifdef _WIN64
|
||||
hardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_qword.png"), tr("&Qword"), SLOT(hardwareAccess8Slot())));
|
||||
#endif //_WIN64
|
||||
|
||||
//Breakpoint (hardware write) menu
|
||||
auto hardwareWriteMenu = makeMenu(DIcon("breakpoint_write.png"), tr("Hardware, Write"));
|
||||
hardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_byte.png"), tr("&Byte"), SLOT(hardwareWrite1Slot())));
|
||||
hardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_word.png"), tr("&Word"), SLOT(hardwareWrite2Slot())));
|
||||
hardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_dword.png"), tr("&Dword"), SLOT(hardwareWrite4Slot())));
|
||||
#ifdef _WIN64
|
||||
hardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_qword.png"), tr("&Qword"), SLOT(hardwareAccess8Slot())));
|
||||
#endif //_WIN64
|
||||
|
||||
//Breakpoint (remove hardware)
|
||||
auto hardwareRemove = makeAction(DIcon("breakpoint_remove.png"), tr("Remove &Hardware"), SLOT(hardwareRemoveSlot()));
|
||||
|
||||
//Breakpoint (memory access) menu
|
||||
auto memoryAccessMenu = makeMenu(DIcon("breakpoint_memory_access.png"), tr("Memory, Access"));
|
||||
memoryAccessMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryAccessSingleshootSlot())));
|
||||
memoryAccessMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryAccessRestoreSlot())));
|
||||
|
||||
//Breakpoint (memory write) menu
|
||||
auto memoryWriteMenu = makeMenu(DIcon("breakpoint_memory_write.png"), tr("Memory, Write"));
|
||||
memoryWriteMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryWriteSingleshootSlot())));
|
||||
memoryWriteMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryWriteRestoreSlot())));
|
||||
|
||||
//Breakpoint (remove memory) menu
|
||||
auto memoryRemove = makeAction(DIcon("breakpoint_remove.png"), tr("Remove &Memory"), SLOT(memoryRemoveSlot()));
|
||||
|
||||
//Breakpoint menu
|
||||
auto breakpointMenu = new MenuBuilder(this);
|
||||
|
||||
//Breakpoint menu
|
||||
breakpointMenu->addBuilder(new MenuBuilder(this, [ = ](QMenu * menu)
|
||||
{
|
||||
duint selectedAddr = mXrefInfo.references[ui->listWidget->currentRow()].addr;
|
||||
if(DbgGetBpxTypeAt(selectedAddr) & bp_hardware) //hardware breakpoint set
|
||||
{
|
||||
menu->addAction(hardwareRemove);
|
||||
}
|
||||
else //memory breakpoint not set
|
||||
{
|
||||
menu->addMenu(hardwareAccessMenu);
|
||||
menu->addMenu(hardwareWriteMenu);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
if(DbgGetBpxTypeAt(selectedAddr) & bp_memory) //memory breakpoint set
|
||||
{
|
||||
menu->addAction(memoryRemove);
|
||||
}
|
||||
else //memory breakpoint not set
|
||||
{
|
||||
menu->addMenu(memoryAccessMenu);
|
||||
menu->addMenu(memoryWriteMenu);
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
mMenu->addMenu(makeMenu(DIcon("breakpoint.png"), tr("Brea&kpoint")), breakpointMenu);
|
||||
mMenu->addAction(makeAction(DIcon("breakpoint_toggle.png"), tr("Toggle breakpoints on all xrefs"), SLOT(breakpointAllSlot())));
|
||||
auto mCopyMenu = new MenuBuilder(mMenu);
|
||||
mCopyMenu->addAction(makeAction(tr("Selected xref"), SLOT(copyThisSlot())));
|
||||
mCopyMenu->addAction(makeAction(tr("All xrefs"), SLOT(copyAllSlot())));
|
||||
mMenu->addMenu(makeMenu(DIcon("copy.png"), tr("Copy")), mCopyMenu);
|
||||
mMenu->loadFromConfig();
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::changeAddress(duint address)
|
||||
{
|
||||
DbgCmdExec(QString("%1 %2").arg(mCommand, ToPtrString(address)).toUtf8().constData());
|
||||
|
@ -83,10 +164,150 @@ void XrefBrowseDialog::on_listWidget_currentRowChanged(int row)
|
|||
|
||||
void XrefBrowseDialog::on_XrefBrowseDialog_rejected()
|
||||
{
|
||||
DbgCmdExec(QString("%1 %2").arg(mCommand, ToPtrString(mAddress)).toUtf8().constData());
|
||||
if(DbgIsDebugging())
|
||||
DbgCmdExec(QString("%1 %2").arg(mCommand, ToPtrString(mAddress)).toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::on_listWidget_itemClicked(QListWidgetItem*)
|
||||
{
|
||||
on_listWidget_currentRowChanged(ui->listWidget->currentRow());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::on_listWidget_customContextMenuRequested(const QPoint & pos)
|
||||
{
|
||||
QMenu menu(this);
|
||||
mMenu->build(&menu);
|
||||
menu.exec(ui->listWidget->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief XrefBrowseDialog::onDebuggerClose Close this dialog when the debuggee stops.
|
||||
* @param state The argument passed in representing the debugger state.
|
||||
*/
|
||||
void XrefBrowseDialog::onDebuggerClose(DBGSTATE state)
|
||||
{
|
||||
if(state == stopped)
|
||||
emit close();
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::breakpointSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
if(DbgGetBpxTypeAt(mXrefInfo.references[ui->listWidget->currentRow()].addr) & bp_normal)
|
||||
DbgCmdExec(QString("bc " + addr_text).toUtf8().constData());
|
||||
else
|
||||
DbgCmdExec(QString("bp " + addr_text).toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareAccess1Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", r, 1").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareAccess2Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", r, 2").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareAccess4Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", r, 4").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareAccess8Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", r, 8").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareWrite1Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", w, 1").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareWrite2Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", w, 2").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareWrite4Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", w, 4").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareWrite8Slot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphws " + addr_text + ", w, 8").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::hardwareRemoveSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bphwc " + addr_text).toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::memoryAccessSingleshootSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bpm " + addr_text + ", 0, a").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::memoryAccessRestoreSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bpm " + addr_text + ", 1, a").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::memoryWriteSingleshootSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bpm " + addr_text + ", 0, w").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::memoryWriteRestoreSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bpm " + addr_text + ", 1, w").toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::memoryRemoveSlot()
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr);
|
||||
DbgCmdExec(QString("bpmc " + addr_text).toUtf8().constData());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::copyThisSlot()
|
||||
{
|
||||
Bridge::CopyToClipboard(ToPtrString(mXrefInfo.references[ui->listWidget->currentRow()].addr) + " " + ui->listWidget->selectedItems()[0]->text());
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::breakpointAllSlot()
|
||||
{
|
||||
for(int i = 0; i < ui->listWidget->count(); i++)
|
||||
{
|
||||
QString addr_text = ToPtrString(mXrefInfo.references[i].addr);
|
||||
if(DbgGetBpxTypeAt(mXrefInfo.references[i].addr) & bp_normal)
|
||||
DbgCmdExec(QString("bc " + addr_text).toUtf8().constData());
|
||||
else
|
||||
DbgCmdExec(QString("bp " + addr_text).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
void XrefBrowseDialog::copyAllSlot()
|
||||
{
|
||||
QString temp;
|
||||
for(int i = 0; i < ui->listWidget->count(); i++)
|
||||
{
|
||||
temp.append(ToPtrString(mXrefInfo.references[i].addr) + " ");
|
||||
temp.append(ui->listWidget->selectedItems()[0]->text());
|
||||
temp.append("\r\n");
|
||||
}
|
||||
Bridge::CopyToClipboard(temp);
|
||||
}
|
||||
|
|
|
@ -25,14 +25,41 @@ private slots:
|
|||
void on_listWidget_currentRowChanged(int currentRow);
|
||||
void on_XrefBrowseDialog_rejected();
|
||||
void on_listWidget_itemClicked(QListWidgetItem* item);
|
||||
void on_listWidget_customContextMenuRequested(const QPoint & pos);
|
||||
|
||||
void onDebuggerClose(DBGSTATE state);
|
||||
void memoryAccessSingleshootSlot();
|
||||
void memoryAccessRestoreSlot();
|
||||
void memoryWriteSingleshootSlot();
|
||||
void memoryWriteRestoreSlot();
|
||||
void memoryRemoveSlot();
|
||||
void hardwareAccess1Slot();
|
||||
void hardwareAccess2Slot();
|
||||
void hardwareAccess4Slot();
|
||||
void hardwareAccess8Slot();
|
||||
void hardwareWrite1Slot();
|
||||
void hardwareWrite2Slot();
|
||||
void hardwareWrite4Slot();
|
||||
void hardwareWrite8Slot();
|
||||
void hardwareRemoveSlot();
|
||||
void breakpointSlot();
|
||||
void copyThisSlot();
|
||||
void copyAllSlot();
|
||||
void breakpointAllSlot();
|
||||
|
||||
private:
|
||||
Ui::XrefBrowseDialog* ui;
|
||||
|
||||
void changeAddress(duint address);
|
||||
void setupContextMenu();
|
||||
|
||||
XREF_INFO mXrefInfo;
|
||||
duint mAddress;
|
||||
int mPrevSelectionSize;
|
||||
QString mCommand;
|
||||
void changeAddress(duint address);
|
||||
MenuBuilder* mMenu;
|
||||
|
||||
#include "ActionHelpers.h"
|
||||
};
|
||||
|
||||
#endif // XREFBROWSEDIALOG_H
|
||||
|
|
|
@ -223,6 +223,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
insertMenuBuilderBools(&guiBool, "CPUStack", 50); //Stack
|
||||
insertMenuBuilderBools(&guiBool, "SourceView", 10); //Source
|
||||
insertMenuBuilderBools(&guiBool, "DisassemblerGraphView", 50); //Graph
|
||||
insertMenuBuilderBools(&guiBool, "XrefBrowseDialog", 10); //XrefBrowseDialog
|
||||
insertMenuBuilderBools(&guiBool, "File", 50); //Main Menu : File
|
||||
insertMenuBuilderBools(&guiBool, "Debug", 50); //Main Menu : Debug
|
||||
insertMenuBuilderBools(&guiBool, "Option", 50); //Main Menu : Option
|
||||
|
|
Loading…
Reference in New Issue