1
0
Fork 0

Add more actions to CommonActions

This commit is contained in:
torusrxxx 2020-10-20 17:26:38 +08:00 committed by Duncan Ogilvie
parent 79af7e656d
commit cc63a2b59f
10 changed files with 130 additions and 421 deletions

View File

@ -405,8 +405,6 @@ void CPUDisassembly::setupRightClickContextMenu()
return true;
});
//mMenuBuilder->addAction(makeShortcutAction(DIcon("comment.png"), tr("Comment"), SLOT(setCommentSlot()), "ActionSetComment"));
//mMenuBuilder->addAction(makeShortcutAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), SLOT(setBookmarkSlot()), "ActionToggleBookmark"));
mMenuBuilder->addSeparator();
MenuBuilder* analysisMenu = new MenuBuilder(this);
@ -513,9 +511,7 @@ void CPUDisassembly::setupRightClickContextMenu()
removeAction(mMenuBuilder->addAction(makeShortcutAction(DIcon("patch.png"), tr("Patches"), SLOT(showPatchesSlot()), "ViewPatches"))); //prevent conflicting shortcut with the MainWindow
mMenuBuilder->addSeparator();
mMenuBuilder->addAction(makeShortcutAction(DIcon("neworigin.png"), tr("Set New Origin Here"), SLOT(setNewOriginHereActionSlot()), "ActionSetNewOriginHere"));
mMenuBuilder->addAction(makeShortcutAction(DIcon("createthread.png"), tr("Create New Thread Here"), SLOT(createThreadSlot()), "ActionCreateNewThreadHere"));
mCommonActions->build(mMenuBuilder, CommonActions::ActionNewOrigin | CommonActions::ActionNewThread);
MenuBuilder* gotoMenu = new MenuBuilder(this);
gotoMenu->addAction(makeShortcutAction(DIcon("cbp.png"), tr("Origin"), SLOT(gotoOriginSlot()), "ActionGotoOrigin"));
gotoMenu->addAction(makeShortcutAction(DIcon("previous.png"), tr("Previous"), SLOT(gotoPreviousSlot()), "ActionGotoPrevious"), [this](QMenu*)
@ -685,25 +681,6 @@ void CPUDisassembly::gotoOriginSlot()
gotoAddress(DbgValFromString("cip"));
}
void CPUDisassembly::setNewOriginHereActionSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = rvaToVa(getInitialSelection());
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(wVA, false))
{
QMessageBox msg(QMessageBox::Warning, tr("Current address is not executable"),
tr("Setting new origin here may result in crash. Do you really want to continue?"), QMessageBox::Yes | QMessageBox::No, this);
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
return;
}
QString wCmd = "cip=" + ToPtrString(wVA);
DbgCmdExec(wCmd);
}
void CPUDisassembly::setLabelSlot()
{
if(!DbgIsDebugging())
@ -1996,26 +1973,6 @@ void CPUDisassembly::analyzeModuleSlot()
DbgCmdExec("analx");
}
void CPUDisassembly::createThreadSlot()
{
duint addr = rvaToVa(getSelectionStart());
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(addr, false))
{
QMessageBox msg(QMessageBox::Warning, tr("Current address is not executable"),
tr("Creating new thread here may result in crash. Do you really want to continue?"), QMessageBox::Yes | QMessageBox::No, this);
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
return;
}
WordEditDialog argWindow(this);
argWindow.setup(tr("Argument for the new thread"), 0, sizeof(duint));
if(argWindow.exec() != QDialog::Accepted)
return;
DbgCmdExec(QString("createthread %1, %2").arg(ToPtrString(addr)).arg(ToPtrString(argWindow.getVal())));
}
void CPUDisassembly::copyTokenTextSlot()
{
Bridge::CopyToClipboard(mHighlightToken.text);

View File

@ -37,7 +37,7 @@ signals:
void displaySymbolsWidget();
public slots:
void setNewOriginHereActionSlot();
//void setNewOriginHereActionSlot();
void gotoOriginSlot();
void setLabelSlot();
void setLabelAddressSlot();
@ -107,7 +107,6 @@ public slots:
void setEncodeTypeRangeSlot();
void graphSlot();
void analyzeModuleSlot();
void createThreadSlot();
void copyTokenTextSlot();
void copyTokenValueSlot();
//void followInMemoryMapSlot();

View File

@ -5,7 +5,6 @@
#include <QToolTip>
#include "Configuration.h"
#include "Bridge.h"
#include "LineEditDialog.h"
#include "HexEditDialog.h"
#include "CPUMultiDump.h"
#include "GotoDialog.h"
@ -44,7 +43,7 @@ void CPUDump::setupContextMenu()
mCommonActions = new CommonActions(this, getActionHelperFuncs(), [this]()
{
return rvaToVa(getInitialSelection());
return rvaToVa(getSelectionStart());
});
MenuBuilder* wBinaryMenu = new MenuBuilder(this);
@ -81,16 +80,9 @@ void CPUDump::setupContextMenu()
{
return DbgFunctions()->PatchInRange(rvaToVa(getSelectionStart()), rvaToVa(getSelectionEnd()));
});
//mMenuBuilder->addAction(makeShortcutAction(DIcon("stack.png"), tr("Follow in Stack"), SLOT(followStackSlot()), "ActionFollowStack"), [this](QMenu*)
//{
// auto start = rvaToVa(getSelectionStart());
// return (DbgMemIsValidReadPtr(start) && DbgMemFindBaseAddr(start, 0) == DbgMemFindBaseAddr(DbgValFromString("csp"), 0));
//});
mCommonActions->build(mMenuBuilder, CommonActions::ActionDisasm | CommonActions::ActionMemoryMap | CommonActions::ActionDumpData | CommonActions::ActionDisasmData
| CommonActions::ActionStackDump);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("memmap_find_address_page.png"), tr("Follow in Memory Map"), SLOT(followInMemoryMapSlot()), "ActionFollowMemMap"));
//mMenuBuilder->addAction(makeShortcutAction(DIcon(ArchValue("processor32.png", "processor64.png")), tr("Follow in Disassembler"), SLOT(followInDisasmSlot()), "ActionFollowDisasm"));
| CommonActions::ActionStackDump | CommonActions::ActionLabel);
auto wIsValidReadPtrCallback = [this](QMenu*)
{
duint ptr = 0;
@ -98,9 +90,6 @@ void CPUDump::setupContextMenu()
return DbgMemIsValidReadPtr(ptr);
};
//mMenuBuilder->addAction(makeShortcutAction(DIcon("processor32.png"), ArchValue(tr("&Follow DWORD in Disassembler"), tr("&Follow QWORD in Disassembler")), SLOT(followDataSlot()), "ActionFollowDwordQwordDisasm"), wIsValidReadPtrCallback);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("dump.png"), ArchValue(tr("&Follow DWORD in Current Dump"), tr("&Follow QWORD in Current Dump")), SLOT(followDataDumpSlot()), "ActionFollowDwordQwordDump"), wIsValidReadPtrCallback);
MenuBuilder* wFollowInDumpMenu = new MenuBuilder(this, [wIsValidReadPtrCallback, this](QMenu * menu)
{
if(!wIsValidReadPtrCallback(menu))
@ -119,7 +108,6 @@ void CPUDump::setupContextMenu()
mFollowInDumpActions.push_back(action);
}
mMenuBuilder->addMenu(makeMenu(DIcon("dump.png"), ArchValue(tr("&Follow DWORD in Dump"), tr("&Follow QWORD in Dump"))), wFollowInDumpMenu);
mMenuBuilder->addAction(makeShortcutAction(DIcon("label.png"), tr("Set &Label"), SLOT(setLabelSlot()), "ActionSetLabel"));
mMenuBuilder->addAction(makeShortcutAction(DIcon("modify.png"), tr("&Modify Value"), SLOT(modifyValueSlot()), "ActionModifyValue"), [this](QMenu*)
{
return getSizeOf(mDescriptor.at(0).data.itemSize) <= sizeof(duint);
@ -150,42 +138,42 @@ void CPUDump::setupContextMenu()
{
return (DbgGetBpxTypeAt(rvaToVa(getSelectionStart())) & bp_memory) == 0;
});
wHardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_byte.png"), tr("&Byte"), SLOT(hardwareAccess1Slot())));
wHardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_word.png"), tr("&Word"), SLOT(hardwareAccess2Slot())));
wHardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_dword.png"), tr("&Dword"), SLOT(hardwareAccess4Slot())));
wHardwareAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_byte.png"), tr("&Byte"), "bphws $, r, 1"));
wHardwareAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_word.png"), tr("&Word"), "bphws $, r, 2"));
wHardwareAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_dword.png"), tr("&Dword"), "bphws $, r, 4"));
#ifdef _WIN64
wHardwareAccessMenu->addAction(makeAction(DIcon("breakpoint_qword.png"), tr("&Qword"), SLOT(hardwareAccess8Slot())));
wHardwareAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_qword.png"), tr("&Qword"), "bphws $, r, 8"));
#endif //_WIN64
wHardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_byte.png"), tr("&Byte"), SLOT(hardwareWrite1Slot())));
wHardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_word.png"), tr("&Word"), SLOT(hardwareWrite2Slot())));
wHardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_dword.png"), tr("&Dword"), SLOT(hardwareWrite4Slot())));
wHardwareWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_byte.png"), tr("&Byte"), "bphws $, w, 1"));
wHardwareWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_word.png"), tr("&Word"), "bphws $, w, 2"));
wHardwareWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_dword.png"), tr("&Dword"), "bphws $, w, 4"));
#ifdef _WIN64
wHardwareWriteMenu->addAction(makeAction(DIcon("breakpoint_qword.png"), tr("&Qword"), SLOT(hardwareWrite8Slot())));
wHardwareWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_qword.png"), tr("&Qword"), "bphws $, w, 8"));
#endif //_WIN64
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_access.png"), tr("Hardware, &Access")), wHardwareAccessMenu);
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_write.png"), tr("Hardware, &Write")), wHardwareWriteMenu);
wBreakpointMenu->addAction(makeAction(DIcon("breakpoint_execute.png"), tr("Hardware, &Execute"), SLOT(hardwareExecuteSlot())), [this](QMenu*)
wBreakpointMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_execute.png"), tr("Hardware, &Execute"), "bphws $, x"), [this](QMenu*)
{
return (DbgGetBpxTypeAt(rvaToVa(getSelectionStart())) & bp_hardware) == 0;
});
wBreakpointMenu->addAction(makeAction(DIcon("breakpoint_remove.png"), tr("Remove &Hardware"), SLOT(hardwareRemoveSlot())), [this](QMenu*)
wBreakpointMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_remove.png"), tr("Remove &Hardware"), "bphwc $"), [this](QMenu*)
{
return (DbgGetBpxTypeAt(rvaToVa(getSelectionStart())) & bp_hardware) != 0;
});
wBreakpointMenu->addSeparator();
wMemoryAccessMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryAccessSingleshootSlot())));
wMemoryAccessMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryAccessRestoreSlot())));
wMemoryReadMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryReadSingleshootSlot())));
wMemoryReadMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryReadRestoreSlot())));
wMemoryWriteMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryWriteSingleshootSlot())));
wMemoryWriteMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryWriteRestoreSlot())));
wMemoryExecuteMenu->addAction(makeAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), SLOT(memoryExecuteSingleshootSlot())));
wMemoryExecuteMenu->addAction(makeAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), SLOT(memoryExecuteRestoreSlot())));
wMemoryAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), "bpm $, 0, a"));
wMemoryAccessMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), "bpm $, 1, a"));
wMemoryReadMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), "bpm $, 0, r"));
wMemoryReadMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), "bpm $, 1, r"));
wMemoryWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), "bpm $, 0, w"));
wMemoryWriteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), "bpm $, 1, w"));
wMemoryExecuteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_singleshoot.png"), tr("&Singleshoot"), "bpm $, 0, x"));
wMemoryExecuteMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_memory_restore_on_hit.png"), tr("&Restore on hit"), "bpm $, 1, x"));
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_memory_access.png"), tr("Memory, Access")), wMemoryAccessMenu);
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_memory_read.png"), tr("Memory, Read")), wMemoryReadMenu);
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_memory_write.png"), tr("Memory, Write")), wMemoryWriteMenu);
wBreakpointMenu->addMenu(makeMenu(DIcon("breakpoint_memory_execute.png"), tr("Memory, Execute")), wMemoryExecuteMenu);
wBreakpointMenu->addAction(makeAction(DIcon("breakpoint_remove.png"), tr("Remove &Memory"), SLOT(memoryRemoveSlot())), [this](QMenu*)
wBreakpointMenu->addAction(mCommonActions->makeCommandAction(DIcon("breakpoint_remove.png"), tr("Remove &Memory"), "bpmc $"), [this](QMenu*)
{
return (DbgGetBpxTypeAt(rvaToVa(getSelectionStart())) & bp_memory) != 0;
});
@ -527,39 +515,6 @@ void CPUDump::mouseMoveEvent(QMouseEvent* event)
HexDump::mouseMoveEvent(event);
}
void CPUDump::setLabelSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = rvaToVa(getSelectionStart());
LineEditDialog mLineEdit(this);
mLineEdit.setTextMaxLength(MAX_LABEL_SIZE - 2);
QString addr_text = ToPtrString(wVA);
char label_text[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
restart:
if(mLineEdit.exec() != QDialog::Accepted)
return;
QByteArray utf8data = mLineEdit.editText.toUtf8();
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != wVA)
{
QMessageBox msg(QMessageBox::Warning, tr("The label may be in use"),
tr("The label \"%1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?").arg(mLineEdit.editText),
QMessageBox::Yes | QMessageBox::No, this);
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
goto restart;
}
if(!DbgSetLabelAt(wVA, utf8data.constData()))
SimpleErrorBox(this, tr("Error!"), tr("DbgSetLabelAt failed!"));
GuiUpdateAllViews();
}
void CPUDump::modifyValueSlot()
{
dsint addr = getSelectionStart();
@ -1349,120 +1304,6 @@ void CPUDump::selectionSet(const SELECTIONDATA* selection)
Bridge::getBridge()->setResult(BridgeResult::SelectionSet, 1);
}
void CPUDump::memoryAccessSingleshootSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, a"));
}
void CPUDump::memoryAccessRestoreSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, a"));
}
void CPUDump::memoryReadSingleshootSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, r"));
}
void CPUDump::memoryReadRestoreSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, r"));
}
void CPUDump::memoryWriteSingleshootSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, w"));
}
void CPUDump::memoryWriteRestoreSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, w"));
}
void CPUDump::memoryExecuteSingleshootSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 0, x"));
}
void CPUDump::memoryExecuteRestoreSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpm " + addr_text + ", 1, x"));
}
void CPUDump::memoryRemoveSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bpmc " + addr_text));
}
void CPUDump::hardwareAccess1Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 1"));
}
void CPUDump::hardwareAccess2Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 2"));
}
void CPUDump::hardwareAccess4Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 4"));
}
void CPUDump::hardwareAccess8Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", r, 8"));
}
void CPUDump::hardwareWrite1Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 1"));
}
void CPUDump::hardwareWrite2Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 2"));
}
void CPUDump::hardwareWrite4Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 4"));
}
void CPUDump::hardwareWrite8Slot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", w, 8"));
}
void CPUDump::hardwareExecuteSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphws " + addr_text + ", x"));
}
void CPUDump::hardwareRemoveSlot()
{
QString addr_text = ToPtrString(rvaToVa(getSelectionStart()));
DbgCmdExec(QString("bphwc " + addr_text));
}
void CPUDump::findReferencesSlot()
{
QString addrStart = ToPtrString(rvaToVa(getSelectionStart()));
@ -1619,26 +1460,6 @@ void CPUDump::undoSelectionSlot()
reloadData();
}
//void CPUDump::followStackSlot()
//{
// DbgCmdExec(QString("sdump " + ToPtrString(rvaToVa(getSelectionStart()))));
//}
//void CPUDump::followInDisasmSlot()
//{
// DbgCmdExec(QString("disasm " + ToPtrString(rvaToVa(getSelectionStart()))));
//}
//void CPUDump::followDataSlot()
//{
// DbgCmdExec(QString("disasm \"[%1]\"").arg(ToPtrString(rvaToVa(getSelectionStart()))));
//}
//void CPUDump::followDataDumpSlot()
//{
// DbgCmdExec(QString("dump \"[%1]\"").arg(ToPtrString(rvaToVa(getSelectionStart()))));
//}
void CPUDump::selectionUpdatedSlot()
{
QString selStart = ToPtrString(rvaToVa(getSelectionStart()));
@ -1783,11 +1604,6 @@ void CPUDump::setView(ViewEnum_t view)
}
}
//void CPUDump::followInMemoryMapSlot()
//{
// DbgCmdExec(QString("memmapdump %1").arg(ToHexString(rvaToVa(getSelectionStart()))));
//}
void CPUDump::headerButtonReleasedSlot(int colIndex)
{
auto callback = mDescriptor[colIndex].columnSwitch;

View File

@ -27,27 +27,6 @@ signals:
void showDisassemblyTab(duint selectionStart, duint selectionEnd, duint firstAddress);
public slots:
void memoryAccessSingleshootSlot();
void memoryAccessRestoreSlot();
void memoryReadSingleshootSlot();
void memoryReadRestoreSlot();
void memoryWriteSingleshootSlot();
void memoryWriteRestoreSlot();
void memoryExecuteSingleshootSlot();
void memoryExecuteRestoreSlot();
void memoryRemoveSlot();
void hardwareAccess1Slot();
void hardwareAccess2Slot();
void hardwareAccess4Slot();
void hardwareAccess8Slot();
void hardwareWrite1Slot();
void hardwareWrite2Slot();
void hardwareWrite4Slot();
void hardwareWrite8Slot();
void hardwareExecuteSlot();
void hardwareRemoveSlot();
void setLabelSlot();
void modifyValueSlot();
void gotoExpressionSlot();
void gotoFileOffsetSlot();

View File

@ -4,7 +4,6 @@
#include "QBeaEngine.h"
#include "GotoDialog.h"
#include "XrefBrowseDialog.h"
#include "LineEditDialog.h"
#include <vector>
#include <QPainter>
#include <QScrollBar>
@ -2181,26 +2180,20 @@ void DisassemblerGraphView::setupContextMenu()
return DbgIsDebugging() && this->ready;
});
//mMenuBuilder->addAction(makeShortcutAction(DIcon(QString("processor%1.png").arg(ArchValue("32", "64"))), tr("Follow in &Disassembler"), SLOT(followDisassemblerSlot()), "ActionGraphFollowDisassembler"), [this](QMenu*)
//{
// return this->cur_instr != 0;
//});
mMenuBuilder->addSeparator();
mCommonActions = new CommonActions(this, getActionHelperFuncs(), [this]()
{
return zoomActionHelper();
});
mCommonActions->build(mMenuBuilder, CommonActions::ActionBookmark | CommonActions::ActionComment | CommonActions::ActionDisasm);
mCommonActions->build(mMenuBuilder, CommonActions::ActionBreakpoint | CommonActions::ActionMemoryMap | CommonActions::ActionBookmark | CommonActions::ActionLabel |
CommonActions::ActionComment | CommonActions::ActionDisasm | CommonActions::ActionNewOrigin | CommonActions::ActionNewThread);
auto zoomActionHelperNonZero = [this](QMenu*)
{
return zoomActionHelper() != 0;
};
//mMenuBuilder->addAction(makeShortcutAction(DIcon("comment.png"), tr("&Comment"), SLOT(setCommentSlot()), "ActionSetComment"), zoomActionHelperNonZero);
mMenuBuilder->addAction(makeShortcutAction(DIcon("label.png"), tr("&Label"), SLOT(setLabelSlot()), "ActionSetLabel"), zoomActionHelperNonZero);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), SLOT(setBookmarkSlot()), "ActionToggleBookmark"));
mMenuBuilder->addAction(makeShortcutAction(DIcon("xrefs.png"), tr("Xrefs..."), SLOT(xrefSlot()), "ActionXrefs"), zoomActionHelperNonZero);
MenuBuilder* gotoMenu = new MenuBuilder(this);
@ -2514,97 +2507,6 @@ void DisassemblerGraphView::saveImageSlot()
this->viewport()->update();
}
/*void DisassemblerGraphView::setCommentSlot()
{
duint wVA = this->get_cursor_pos();
LineEditDialog mLineEdit(this);
mLineEdit.setTextMaxLength(MAX_COMMENT_SIZE - 2);
QString addr_text = ToPtrString(wVA);
char comment_text[MAX_COMMENT_SIZE] = "";
if(!DbgIsDebugging())
return;
if(!DbgMemIsValidReadPtr(wVA))
return;
if(DbgGetCommentAt((duint)wVA, comment_text))
{
if(comment_text[0] == '\1') //automatic comment
mLineEdit.setText(QString(comment_text + 1));
else
mLineEdit.setText(QString(comment_text));
}
mLineEdit.setWindowTitle(tr("Add comment at ") + addr_text);
if(mLineEdit.exec() != QDialog::Accepted)
return;
if(!DbgSetCommentAt(wVA, mLineEdit.editText.replace('\r', "").replace('\n', "").toUtf8().constData()))
SimpleErrorBox(this, tr("Error!"), tr("DbgSetCommentAt failed!"));
this->refreshSlot();
}*/
void DisassemblerGraphView::setLabelSlot()
{
duint wVA = this->get_cursor_pos();
LineEditDialog mLineEdit(this);
mLineEdit.setTextMaxLength(MAX_LABEL_SIZE - 2);
QString addr_text = ToPtrString(wVA);
char label_text[MAX_LABEL_SIZE] = "";
if(!DbgIsDebugging())
return;
if(!DbgMemIsValidReadPtr(wVA))
return;
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
restart:
if(mLineEdit.exec() != QDialog::Accepted)
return;
QByteArray utf8data = mLineEdit.editText.toUtf8();
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != wVA)
{
QMessageBox msg(QMessageBox::Warning, tr("The label may be in use"),
tr("The label \"%1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?").arg(mLineEdit.editText),
QMessageBox::Yes | QMessageBox::No, this);
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
goto restart;
}
if(!DbgSetLabelAt(wVA, utf8data.constData()))
SimpleErrorBox(this, tr("Error!"), tr("DbgSetLabelAt failed!"));
this->refreshSlot();
}
/*void DisassemblerGraphView::setBookmarkSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = this->get_cursor_pos();
bool result;
if(DbgGetBookmarkAt(wVA))
result = DbgSetBookmarkAt(wVA, false);
else
result = DbgSetBookmarkAt(wVA, true);
if(!result)
{
QMessageBox msg(QMessageBox::Critical, tr("Error!"), tr("DbgSetBookmarkAt failed!"));
msg.setWindowIcon(DIcon("compile-error.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}*/
void DisassemblerGraphView::xrefSlot()
{
if(!DbgIsDebugging())

View File

@ -286,9 +286,6 @@ public slots:
void followActionSlot();
void refreshSlot();
void saveImageSlot();
//void setCommentSlot();
void setLabelSlot();
//void setBookmarkSlot();
void xrefSlot();
void mnemonicHelpSlot();
void fitToWindowSlot();

View File

@ -863,8 +863,8 @@ void TraceBrowser::setupRightClickContextMenu()
mMenuBuilder->addMenu(makeMenu(DIcon("copy.png"), tr("&Copy")), copyMenu);
//mMenuBuilder->addAction(makeShortcutAction(DIcon(ArchValue("processor32.png", "processor64.png")), tr("&Follow in Disassembler"), SLOT(followDisassemblySlot()), "ActionFollowDisasm"), isValid);
mCommonActions->build(mMenuBuilder, CommonActions::ActionDisasm | CommonActions::ActionBreakpoint | CommonActions::ActionComment | CommonActions::ActionBookmark);
mMenuBuilder->addAction(makeShortcutAction(DIcon("label.png"), tr("Label Current Address"), SLOT(setLabelSlot()), "ActionSetLabel"), isDebugging);
mCommonActions->build(mMenuBuilder, CommonActions::ActionDisasm | CommonActions::ActionBreakpoint | CommonActions::ActionLabel | CommonActions::ActionComment | CommonActions::ActionBookmark);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("label.png"), tr("Label Current Address"), SLOT(setLabelSlot()), "ActionSetLabel"), isDebugging);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("comment.png"), tr("&Comment"), SLOT(setCommentSlot()), "ActionSetComment"), isDebugging);
//mMenuBuilder->addAction(makeShortcutAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), SLOT(setBookmarkSlot()), "ActionToggleBookmark"), isDebugging);
mMenuBuilder->addAction(makeShortcutAction(DIcon("highlight.png"), tr("&Highlighting mode"), SLOT(enableHighlightingModeSlot()), "ActionHighlightingMode"), isValid);
@ -1770,39 +1770,6 @@ void TraceBrowser::exportSlot()
});
}
void TraceBrowser::setLabelSlot()
{
if(!DbgIsDebugging() || mTraceFile == nullptr || mTraceFile->Progress() < 100)
return;
duint wVA = mTraceFile->Registers(getInitialSelection()).regcontext.cip;
LineEditDialog mLineEdit(this);
mLineEdit.setTextMaxLength(MAX_LABEL_SIZE - 2);
QString addr_text = ToPtrString(wVA);
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
restart:
if(mLineEdit.exec() != QDialog::Accepted)
return;
QByteArray utf8data = mLineEdit.editText.toUtf8();
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != wVA)
{
QMessageBox msg(QMessageBox::Warning, tr("The label may be in use"),
tr("The label \"%1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?").arg(mLineEdit.editText),
QMessageBox::Yes | QMessageBox::No, this);
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(this, Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
goto restart;
}
if(!DbgSetLabelAt(wVA, utf8data.constData()))
SimpleErrorBox(this, tr("Error!"), tr("DbgSetLabelAt failed!"));
GuiUpdateAllViews();
}
void TraceBrowser::enableHighlightingModeSlot()
{
if(mHighlightingMode)

View File

@ -164,7 +164,7 @@ public slots:
void gotoNextSlot();
//void followDisassemblySlot();
void enableHighlightingModeSlot();
void setLabelSlot();
//void setLabelSlot();
//void setCommentSlot();
//void setBookmarkSlot();
void mnemonicBriefSlot();

View File

@ -7,6 +7,7 @@
#include "MiscUtil.h"
#include "Breakpoints.h"
#include "LineEditDialog.h"
#include "WordEditDialog.h"
CommonActions::CommonActions(QWidget* parent, ActionHelperFuncs funcs, GetSelectionFunc getSelection)
: QObject(parent), ActionHelperProxy(funcs), mGetSelection(getSelection)
@ -21,9 +22,9 @@ void CommonActions::build(MenuBuilder* builder, int actions)
void CommonActions::build(MenuBuilder* builder, int actions, std::function<void(QList<std::pair<QString, duint>>&, CommonActionsList)> additionalAddress)
{
// Condition Lambda
auto wIsValidCallback = [this](QMenu*)
auto wIsDebugging = [this](QMenu*)
{
return mGetSelection() != 0;
return mGetSelection() != 0 && DbgIsDebugging();
};
auto wIsValidReadPtrCallback = [this](QMenu*)
{
@ -35,7 +36,7 @@ void CommonActions::build(MenuBuilder* builder, int actions, std::function<void(
// Menu action
if(actions & ActionDisasm)
{
builder->addAction(makeShortcutAction(DIcon(ArchValue("processor32.png", "processor64.png")), tr("Follow in Disassembler"), std::bind(&CommonActions::followDisassemblySlot, this), "ActionFollowDisasm"), wIsValidCallback);
builder->addAction(makeShortcutAction(DIcon(ArchValue("processor32.png", "processor64.png")), tr("Follow in Disassembler"), std::bind(&CommonActions::followDisassemblySlot, this), "ActionFollowDisasm"), wIsDebugging);
}
if(actions & ActionDisasmData)
{
@ -55,7 +56,7 @@ void CommonActions::build(MenuBuilder* builder, int actions, std::function<void(
}
if(actions & ActionMemoryMap)
{
builder->addAction(makeCommandAction(DIcon("memmap_find_address_page.png"), tr("Follow in Memory Map"), "memmapdump $", "ActionFollowMemMap"), wIsValidCallback);
builder->addAction(makeCommandAction(DIcon("memmap_find_address_page.png"), tr("Follow in Memory Map"), "memmapdump $", "ActionFollowMemMap"), wIsDebugging);
}
if(actions & ActionBreakpoint)
{
@ -137,25 +138,42 @@ void CommonActions::build(MenuBuilder* builder, int actions, std::function<void(
return true;
});
}
if(actions & ActionLabel)
{
builder->addAction(makeShortcutAction(DIcon("label.png"), tr("Label Current Address"), std::bind(&CommonActions::setLabelSlot, this), "ActionSetLabel"), wIsDebugging);
}
if(actions & ActionComment)
{
builder->addAction(makeShortcutAction(DIcon("comment.png"), tr("Comment"), std::bind(&CommonActions::setCommentSlot, this), "ActionSetComment"), wIsValidCallback);
builder->addAction(makeShortcutAction(DIcon("comment.png"), tr("Comment"), std::bind(&CommonActions::setCommentSlot, this), "ActionSetComment"), wIsDebugging);
}
if(actions & ActionBookmark)
{
builder->addAction(makeShortcutAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), std::bind(&CommonActions::setBookmarkSlot, this), "ActionToggleBookmark"), wIsValidCallback);
builder->addAction(makeShortcutAction(DIcon("bookmark_toggle.png"), tr("Toggle Bookmark"), std::bind(&CommonActions::setBookmarkSlot, this), "ActionToggleBookmark"), wIsDebugging);
}
if(actions & ActionNewOrigin)
{
builder->addAction(makeShortcutAction(DIcon("neworigin.png"), tr("Set New Origin Here"), std::bind(&CommonActions::setNewOriginHereActionSlot, this), "ActionSetNewOriginHere"));
}
if(actions & ActionNewThread)
{
builder->addAction(makeShortcutAction(DIcon("createthread.png"), tr("Create New Thread Here"), std::bind(&CommonActions::createThreadSlot, this), "ActionCreateNewThreadHere"));
}
}
QAction* CommonActions::makeCommandAction(const QIcon & icon, const QString & text, const char* cmd, const char* shortcut)
{
QAction* action;
action = makeShortcutAction(icon, text, [cmd, this]()
return makeShortcutAction(icon, text, [cmd, this]()
{
DbgCmdExec(QString(cmd).replace("$", ToPtrString(mGetSelection())));
}, shortcut);
action->setData(QVariant(cmd));
return action;
}
QAction* CommonActions::makeCommandAction(const QIcon & icon, const QString & text, const char* cmd)
{
return makeAction(icon, text, [cmd, this]()
{
DbgCmdExec(QString(cmd).replace("$", ToPtrString(mGetSelection())));
});
}
QWidget* CommonActions::widgetparent()
@ -173,6 +191,37 @@ void CommonActions::followDisassemblySlot()
GuiAddStatusBarMessage(tr("Cannot follow %1. Address is invalid.\n").arg(ToPtrString(cip)).toUtf8().constData());
}
void CommonActions::setLabelSlot()
{
duint wVA = mGetSelection();
LineEditDialog mLineEdit(widgetparent());
mLineEdit.setTextMaxLength(MAX_LABEL_SIZE - 2);
QString addr_text = ToPtrString(wVA);
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
restart:
if(mLineEdit.exec() != QDialog::Accepted)
return;
QByteArray utf8data = mLineEdit.editText.toUtf8();
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != wVA)
{
QMessageBox msg(QMessageBox::Warning, tr("The label may be in use"),
tr("The label \"%1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?").arg(mLineEdit.editText),
QMessageBox::Yes | QMessageBox::No, widgetparent());
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(widgetparent(), Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
goto restart;
}
if(!DbgSetLabelAt(wVA, utf8data.constData()))
SimpleErrorBox(widgetparent(), tr("Error!"), tr("DbgSetLabelAt failed!"));
GuiUpdateAllViews();
}
void CommonActions::setCommentSlot()
{
if(!DbgIsDebugging())
@ -350,3 +399,42 @@ void CommonActions::setHwBpAt(duint va, int slot)
if(wBPList.count)
BridgeFree(wBPList.bp);
}
void CommonActions::setNewOriginHereActionSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = mGetSelection();
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(wVA, false))
{
QMessageBox msg(QMessageBox::Warning, tr("Current address is not executable"),
tr("Setting new origin here may result in crash. Do you really want to continue?"), QMessageBox::Yes | QMessageBox::No, widgetparent());
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(widgetparent(), Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
return;
}
QString wCmd = "cip=" + ToPtrString(wVA);
DbgCmdExec(wCmd);
}
void CommonActions::createThreadSlot()
{
duint addr = mGetSelection();
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(addr, false))
{
QMessageBox msg(QMessageBox::Warning, tr("Current address is not executable"),
tr("Creating new thread here may result in crash. Do you really want to continue?"), QMessageBox::Yes | QMessageBox::No, widgetparent());
msg.setWindowIcon(DIcon("compile-warning.png"));
msg.setParent(widgetparent(), Qt::Dialog);
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
if(msg.exec() == QMessageBox::No)
return;
}
WordEditDialog argWindow(widgetparent());
argWindow.setup(tr("Argument for the new thread"), 0, sizeof(duint));
if(argWindow.exec() != QDialog::Accepted)
return;
DbgCmdExec(QString("createthread %1, %2").arg(ToPtrString(addr)).arg(ToPtrString(argWindow.getVal())));
}

View File

@ -51,8 +51,10 @@ public:
void build(MenuBuilder* builder, int actions, std::function<void(QList<std::pair<QString, duint>>&, CommonActionsList)> additionalAddress);
QAction* makeCommandAction(const QIcon & icon, const QString & text, const char* cmd, const char* shortcut);
QAction* makeCommandAction(const QIcon & icon, const QString & text, const char* cmd);
public slots:
void followDisassemblySlot();
void setLabelSlot();
void setCommentSlot();
void setBookmarkSlot();
@ -65,6 +67,8 @@ public slots:
void setHwBpOnSlot3ActionSlot();
void setHwBpAt(duint va, int slot);
void setNewOriginHereActionSlot();
void createThreadSlot();
private:
GetSelectionFunc mGetSelection;
QWidget* widgetparent();