Added api to supress gui message + add set breakpoint on every command in reference view (#710)
* Added API to supress all gui repaint messages * Added related command for scripts * Added Set/Remove Breakpoints on all commands
This commit is contained in:
parent
ac35b0d3ad
commit
36decf84e3
|
|
@ -13,6 +13,11 @@ static HINSTANCE hInst;
|
|||
static Utf8Ini settings;
|
||||
static wchar_t szIniFile[MAX_PATH] = L"";
|
||||
static CRITICAL_SECTION csIni;
|
||||
static bool bDisableGUIUpdate;
|
||||
|
||||
#define CHEKC_GUI_UPDATE_DISABLED \
|
||||
if (bDisableGUIUpdate) \
|
||||
return;
|
||||
|
||||
#ifdef _WIN64
|
||||
#define dbg_lib "x64dbg.dll"
|
||||
|
|
@ -898,8 +903,31 @@ BRIDGE_IMPEXP void GuiLogClear()
|
|||
_gui_sendmessage(GUI_CLEAR_LOG, 0, 0);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateEnable(bool updateNow)
|
||||
{
|
||||
bDisableGUIUpdate = false;
|
||||
if(updateNow)
|
||||
DbgCmdExecDirect("guiupdateenable");
|
||||
else
|
||||
DbgCmdExecDirect("guiupdateenable 0");
|
||||
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateDisable()
|
||||
{
|
||||
bDisableGUIUpdate = true;
|
||||
DbgCmdExecDirect("guimsgdisable");
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP bool GuiIsUpdateDisabled()
|
||||
{
|
||||
return bDisableGUIUpdate;
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateAllViews()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
GuiUpdateRegisterView();
|
||||
GuiUpdateDisassemblyView();
|
||||
GuiUpdateBreakpointsView();
|
||||
|
|
@ -915,17 +943,20 @@ BRIDGE_IMPEXP void GuiUpdateAllViews()
|
|||
|
||||
BRIDGE_IMPEXP void GuiUpdateRegisterView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_REGISTER_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateDisassemblyView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_DISASSEMBLY_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateBreakpointsView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_BREAKPOINTS_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -1112,18 +1143,21 @@ BRIDGE_IMPEXP void GuiStackDumpAt(duint addr, duint csp)
|
|||
|
||||
BRIDGE_IMPEXP void GuiUpdateDumpView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_DUMP_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateMemoryView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_MEMORY_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateThreadView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_THREAD_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -1214,29 +1248,34 @@ BRIDGE_IMPEXP void GuiAddStatusBarMessage(const char* msg)
|
|||
|
||||
BRIDGE_IMPEXP void GuiUpdateSideBar()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_SIDEBAR, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiRepaintTableView()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_REPAINT_TABLE_VIEW, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdatePatches()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_PATCHES, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateCallStack()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_CALLSTACK, 0, 0);
|
||||
}
|
||||
|
||||
BRIDGE_IMPEXP void GuiUpdateSEHChain()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_SEHCHAIN, 0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -1327,6 +1366,7 @@ BRIDGE_IMPEXP void GuiUnregisterScriptLanguage(int id)
|
|||
|
||||
BRIDGE_IMPEXP void GuiUpdateArgumentWidget()
|
||||
{
|
||||
CHEKC_GUI_UPDATE_DISABLED
|
||||
_gui_sendmessage(GUI_UPDATE_ARGUMENT_VIEW, nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -969,6 +969,10 @@ BRIDGE_IMPEXP void GuiRegisterScriptLanguage(SCRIPTTYPEINFO* info);
|
|||
BRIDGE_IMPEXP void GuiUnregisterScriptLanguage(int id);
|
||||
BRIDGE_IMPEXP void GuiUpdateArgumentWidget();
|
||||
BRIDGE_IMPEXP void GuiFocusView(int hWindow);
|
||||
BRIDGE_IMPEXP bool GuiIsUpdateDisabled();
|
||||
BRIDGE_IMPEXP void GuiUpdateEnable(bool updateNow);
|
||||
BRIDGE_IMPEXP void GuiUpdateDisable();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,6 +227,8 @@ DWORD WINAPI updateSEHChainThread(void* ptr)
|
|||
|
||||
void DebugUpdateGui(duint disasm_addr, bool stack)
|
||||
{
|
||||
if(GuiIsUpdateDisabled())
|
||||
return;
|
||||
duint cip = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
if(MemIsValidReadPtr(disasm_addr))
|
||||
{
|
||||
|
|
@ -264,6 +266,8 @@ void DebugUpdateGui(duint disasm_addr, bool stack)
|
|||
|
||||
void DebugUpdateStack(duint dumpAddr, duint csp, bool forceDump)
|
||||
{
|
||||
if(GuiIsUpdateDisabled())
|
||||
return;
|
||||
if(!forceDump && bFreezeStack)
|
||||
{
|
||||
SELECTIONDATA selection;
|
||||
|
|
|
|||
|
|
@ -1232,6 +1232,10 @@ CMDRESULT cbDebugDisasm(int argc, char* argv[])
|
|||
if(!valfromstring(argv[1], &addr))
|
||||
addr = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
addr = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
}
|
||||
if(!MemIsValidReadPtr(addr))
|
||||
return STATUS_CONTINUE;
|
||||
DebugUpdateGui(addr, false);
|
||||
|
|
|
|||
|
|
@ -2559,3 +2559,25 @@ CMDRESULT cbInstrBriefcheck(int argc, char* argv[])
|
|||
}
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
CMDRESULT cbInstrDisableGuiUpdate(int argc, char* argv[])
|
||||
{
|
||||
if(!GuiIsUpdateDisabled())
|
||||
GuiUpdateDisable();
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
CMDRESULT cbInstrEnableGuiUpdate(int argc, char* argv[])
|
||||
{
|
||||
if(GuiIsUpdateDisabled())
|
||||
GuiUpdateEnable(false);
|
||||
duint value;
|
||||
//default: update gui
|
||||
if(argc > 1 && valfromstring(argv[1], &value) && value == 0)
|
||||
return STATUS_CONTINUE;
|
||||
duint cip = GetContextDataEx(hActiveThread, UE_CIP);
|
||||
DebugUpdateGui(cip, false);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,4 +90,7 @@ CMDRESULT cbDisablePrivilege(int argc, char* argv[]);
|
|||
CMDRESULT cbHandleClose(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrBriefcheck(int argc, char* argv[]);
|
||||
|
||||
CMDRESULT cbInstrDisableGuiUpdate(int argc, char* argv[]);
|
||||
CMDRESULT cbInstrEnableGuiUpdate(int argc, char* argv[]);
|
||||
|
||||
#endif // _INSTRUCTION_H
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ static void registercommands()
|
|||
dbgcmdnew("briefcheck", cbInstrBriefcheck, true); //check if mnemonic briefs are missing
|
||||
dbgcmdnew("analrecur\1analr", cbInstrAnalrecur, true); //analyze a single function
|
||||
dbgcmdnew("analxrefs\1analx", cbInstrAnalxrefs, true); //analyze xrefs
|
||||
dbgcmdnew("guiupdatedisable", cbInstrDisableGuiUpdate, true); //disable gui message
|
||||
dbgcmdnew("guiupdateenable", cbInstrEnableGuiUpdate, true); //enable gui message
|
||||
}
|
||||
|
||||
static bool cbCommandProvider(char* cmd, int maxlen)
|
||||
|
|
|
|||
|
|
@ -85,6 +85,21 @@ void ReferenceView::setupContextMenu()
|
|||
mSearchList->addAction(mToggleBookmark);
|
||||
connect(mToggleBookmark, SIGNAL(triggered()), this, SLOT(toggleBookmark()));
|
||||
|
||||
mSetBreakpointOnAllCommands = new QAction("Set breakpoint on all commands", this);
|
||||
connect(mSetBreakpointOnAllCommands, SIGNAL(triggered()), this, SLOT(setBreakpointOnAllCommands()));
|
||||
|
||||
mRemoveBreakpointOnAllCommands = new QAction("Remove breakpoint on all commands", this);
|
||||
connect(mRemoveBreakpointOnAllCommands, SIGNAL(triggered()), this, SLOT(removeBreakpointOnAllCommands()));
|
||||
|
||||
|
||||
mSetBreakpointOnAllApiCalls = new QAction("Set breakpoint on all api calls", this);
|
||||
connect(mSetBreakpointOnAllApiCalls, SIGNAL(triggered()), this, SLOT(setBreakpointOnAllApiCalls()));
|
||||
|
||||
mRemoveBreakpointOnAllApiCalls = new QAction("Remove breakpoint on all api calls", this);
|
||||
connect(mRemoveBreakpointOnAllApiCalls, SIGNAL(triggered()), this, SLOT(removeBreakpointOnAllApiCalls()));
|
||||
|
||||
|
||||
|
||||
refreshShortcutsSlot();
|
||||
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
||||
}
|
||||
|
|
@ -183,10 +198,26 @@ void ReferenceView::referenceContextMenu(QMenu* wMenu)
|
|||
return;
|
||||
wMenu->addAction(mFollowAddress);
|
||||
wMenu->addAction(mFollowDumpAddress);
|
||||
if(apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1)))
|
||||
dsint apiaddr = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1));
|
||||
if(apiaddr)
|
||||
wMenu->addAction(mFollowApiAddress);
|
||||
wMenu->addSeparator();
|
||||
wMenu->addAction(mToggleBreakpoint);
|
||||
wMenu->addAction(mSetBreakpointOnAllCommands);
|
||||
wMenu->addAction(mRemoveBreakpointOnAllCommands);
|
||||
if(apiaddr)
|
||||
{
|
||||
char label[MAX_LABEL_SIZE] = "";
|
||||
if(DbgGetLabelAt(apiaddr, SEG_DEFAULT, label))
|
||||
{
|
||||
wMenu->addSeparator();
|
||||
mSetBreakpointOnAllApiCalls->setText(QString("Set breakpoint on all calls to %1").arg(label));
|
||||
wMenu->addAction(mSetBreakpointOnAllApiCalls);
|
||||
mRemoveBreakpointOnAllApiCalls->setText(QString("Remove breakpoint on all calls to %1").arg(label));
|
||||
wMenu->addAction(mRemoveBreakpointOnAllApiCalls);
|
||||
}
|
||||
}
|
||||
wMenu->addSeparator();
|
||||
wMenu->addAction(mToggleBookmark);
|
||||
}
|
||||
|
||||
|
|
@ -217,14 +248,14 @@ void ReferenceView::followGenericAddress()
|
|||
followAddress();
|
||||
}
|
||||
|
||||
void ReferenceView::toggleBreakpoint()
|
||||
void ReferenceView::setBreakpointAt(int row, BPSetAction action)
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
|
||||
if(!mCurList->getRowCount())
|
||||
return;
|
||||
QString addrText = mCurList->getCellContent(mCurList->getInitialSelection(), 0).toUtf8().constData();
|
||||
QString addrText = mCurList->getCellContent(row, 0).toUtf8().constData();
|
||||
duint wVA;
|
||||
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
|
||||
return;
|
||||
|
|
@ -236,9 +267,14 @@ void ReferenceView::toggleBreakpoint()
|
|||
|
||||
if((wBpType & bp_normal) == bp_normal)
|
||||
{
|
||||
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
if(action == Toggle || action == Remove)
|
||||
wCmd = "bc " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
else if(action == Disable)
|
||||
wCmd = "bpd " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
else if(action == Enable)
|
||||
wCmd = "bpe " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
}
|
||||
else
|
||||
else if(wBpType == bp_none && (action == Toggle || action == Enable))
|
||||
{
|
||||
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
|
||||
}
|
||||
|
|
@ -246,6 +282,68 @@ void ReferenceView::toggleBreakpoint()
|
|||
DbgCmdExec(wCmd.toUtf8().constData());
|
||||
}
|
||||
|
||||
void ReferenceView::toggleBreakpoint()
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
return;
|
||||
|
||||
if(!mCurList->getRowCount())
|
||||
return;
|
||||
|
||||
setBreakpointAt(mCurList->getInitialSelection(), Toggle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReferenceView::setBreakpointOnAllCommands()
|
||||
{
|
||||
for(int i = 0; i < mCurList->getRowCount(); i++)
|
||||
{
|
||||
setBreakpointAt(i, Enable);
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceView::removeBreakpointOnAllCommands()
|
||||
{
|
||||
for(int i = 0; i < mCurList->getRowCount(); i++)
|
||||
{
|
||||
setBreakpointAt(i, Remove);
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceView::setBreakpointOnAllApiCalls()
|
||||
{
|
||||
if(!mCurList->getRowCount())
|
||||
return;
|
||||
dsint apiaddr = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1));
|
||||
if(!apiaddr)
|
||||
return;
|
||||
QString apiText = mCurList->getCellContent(mCurList->getInitialSelection(), 1);
|
||||
for(int i = 0; i < mCurList->getRowCount(); i++)
|
||||
{
|
||||
if(mCurList->getCellContent(i, 1) == apiText)
|
||||
setBreakpointAt(i, Enable);
|
||||
}
|
||||
}
|
||||
|
||||
void ReferenceView::removeBreakpointOnAllApiCalls()
|
||||
{
|
||||
if(!mCurList->getRowCount())
|
||||
return;
|
||||
|
||||
dsint apiaddr = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1));
|
||||
if(!apiaddr)
|
||||
return;
|
||||
QString apiText = mCurList->getCellContent(mCurList->getInitialSelection(), 1);
|
||||
for(int i = 0; i < mCurList->getRowCount(); i++)
|
||||
{
|
||||
if(mCurList->getCellContent(i, 1) == apiText)
|
||||
setBreakpointAt(i, Remove);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ReferenceView::toggleBookmark()
|
||||
{
|
||||
if(!DbgIsDebugging())
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ private slots:
|
|||
void followApiAddress();
|
||||
void followGenericAddress();
|
||||
void toggleBreakpoint();
|
||||
void setBreakpointOnAllCommands();
|
||||
void removeBreakpointOnAllCommands();
|
||||
void setBreakpointOnAllApiCalls();
|
||||
void removeBreakpointOnAllApiCalls();
|
||||
void toggleBookmark();
|
||||
void refreshShortcutsSlot();
|
||||
void referenceSetProgressSlot(int progress);
|
||||
|
|
@ -43,9 +47,23 @@ private:
|
|||
QAction* mFollowApiAddress;
|
||||
QAction* mToggleBreakpoint;
|
||||
QAction* mToggleBookmark;
|
||||
bool mFollowDumpDefault;
|
||||
QAction* mSetBreakpointOnAllCommands;
|
||||
QAction* mRemoveBreakpointOnAllCommands;
|
||||
QAction* mSetBreakpointOnAllApiCalls;
|
||||
QAction* mRemoveBreakpointOnAllApiCalls;
|
||||
QLabel* mCountTotalLabel;
|
||||
|
||||
bool mFollowDumpDefault;
|
||||
|
||||
enum BPSetAction
|
||||
{
|
||||
Enable,
|
||||
Disable,
|
||||
Toggle,
|
||||
Remove
|
||||
};
|
||||
|
||||
void setBreakpointAt(int row, BPSetAction action);
|
||||
dsint apiAddressFromString(const QString & s);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue