1
0
Fork 0

Merge pull request #469 from Herz3h/Herz3hDev

Drawing stuff should be faster + Fixed WordEdit and Calculator dialogs being unresponsive to inputs (no "conversion" done..)
This commit is contained in:
Duncan Ogilvie 2015-12-24 19:03:31 +01:00
commit d832509703
20 changed files with 296 additions and 86 deletions

View File

@ -1250,9 +1250,10 @@ BRIDGE_IMPEXP void GuiDumpAtN(duint va, int index)
_gui_sendmessage(GUI_DUMP_AT_N, (void*)va, (void*)index);
}
BRIDGE_IMPEXP void GuiDisplayWarning(const char *title, const char *text)
{
_gui_sendmessage(GUI_DISPLAY_WARNING, (void*)title, (void*)text);
_gui_sendmessage(GUI_DISPLAY_WARNING, (void*) title, (void*) text);
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View File

@ -282,7 +282,7 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
int wNewSize = getColumnWidth(mColResizeData.index) + delta;
setColumnWidth(mColResizeData.index, wNewSize);
mColResizeData.lastPosX = event->x();
repaint();
updateViewport();
}
}
break;
@ -299,8 +299,6 @@ void AbstractTableView::mouseMoveEvent(QMouseEvent* event)
{
mColumnList[mHeader.activeButtonIndex].header.isMouseOver = false;
}
repaint();
}
break;
@ -355,7 +353,7 @@ void AbstractTableView::mousePressEvent(QMouseEvent* event)
mGuiState = AbstractTableView::HeaderButtonPressed;
repaint();
updateViewport();
}
}
@ -399,7 +397,7 @@ void AbstractTableView::mouseReleaseEvent(QMouseEvent* event)
mColumnList[i].header.isPressed = false;
}
repaint();
updateViewport();
}
}
@ -994,13 +992,13 @@ void AbstractTableView::reloadData()
{
mShouldReload = true;
emit tableOffsetChanged(mTableOffset);
repaint();
this->viewport()->update();
}
void AbstractTableView::repaint()
void AbstractTableView::updateViewport()
{
this->viewport()->repaint();
this->viewport()->update();
}

View File

@ -130,7 +130,7 @@ public slots:
// Update/Reload/Refresh/Repaint
virtual void reloadData();
void repaint();
void updateViewport();
// ScrollBar Management
void vertSliderActionSlot(int action);

View File

@ -494,7 +494,7 @@ void Disassembly::mouseMoveEvent(QMouseEvent* event)
else
expandSelectionUpTo(wRowIndex);
repaint();
updateViewport();
wAccept = false;
}
@ -574,7 +574,7 @@ void Disassembly::mousePressEvent(QMouseEvent* event)
mGuiState = Disassembly::MultiRowsSelectionState;
repaint();
updateViewport();
wAccept = true;
}
@ -605,7 +605,7 @@ void Disassembly::mouseReleaseEvent(QMouseEvent* event)
{
mGuiState = Disassembly::NoState;
repaint();
updateViewport();
wAccept = false;
}
@ -653,7 +653,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
setTableOffset(getInstructionRVA(getSelectionEnd(), -getNbrOfLineToPrint() + 2));
}
repaint();
updateViewport();
}
else if(key == Qt::Key_Return || key == Qt::Key_Enter)
{
@ -1342,7 +1342,7 @@ void Disassembly::disassembleAt(dsint parVA, dsint parCIP, bool history, dsint n
if(wIsAligned == true)
{
repaint();
updateViewport();
}
else
{

View File

@ -87,7 +87,7 @@ public:
//disassemble
void disassembleAt(dsint parVA, dsint parCIP, bool history, dsint newTableOffset);
QList<Instruction_t>* instructionsBuffer();
QList<Instruction_t>* instructionsBuffer(); // ugly
const dsint baseAddress() const;
const dsint currentEIP() const;

View File

@ -145,7 +145,7 @@ void HexDump::mouseMoveEvent(QMouseEvent* event)
mGuiState = HexDump::MultiRowsSelectionState;
repaint();
updateViewport();
}
}
}
@ -215,7 +215,7 @@ void HexDump::mousePressEvent(QMouseEvent* event)
mGuiState = HexDump::MultiRowsSelectionState;
repaint();
updateViewport();
}
}
@ -238,7 +238,7 @@ void HexDump::mouseReleaseEvent(QMouseEvent* event)
{
mGuiState = HexDump::NoState;
repaint();
updateViewport();
wAccept = false;
}

View File

@ -2,7 +2,6 @@
#include "ui_SearchListView.h"
#include "FlickerThread.h"
#include <QMessageBox>
SearchListView::SearchListView(QWidget* parent) :
QWidget(parent),
@ -187,11 +186,89 @@ void SearchListView::on_checkBoxRegex_toggled(bool checked)
searchTextChanged(ui->searchBox->text());
}
void SearchListView::addCharToSearchBox(char ch)
{
QString newText;
newText = mSearchBox->text();
// If text is selected
if(mSearchBox->hasSelectedText())
{
QString selectedText = mSearchBox->selectedText();
int indexOfSelectedText = newText.indexOf(selectedText);
if(indexOfSelectedText != -1)
{
newText.replace(indexOfSelectedText, selectedText.length(), QString(ch));
mCursorPosition = indexOfSelectedText;
mSearchBox->setText(newText);
}
}
// No text selected
else
{
mSearchBox->setText(mSearchBox->text().insert(mSearchBox->cursorPosition(), QString(ch)));
mCursorPosition++;
}
}
void SearchListView::deleteTextFromSearchBox(QKeyEvent *keyEvent)
{
QString newText;
newText = mSearchBox->text();
// If Ctrl key pressed
if(keyEvent->modifiers() == Qt::ControlModifier)
{
newText = "";
mCursorPosition = 0;
}
else
{
// If text is selected
if(mSearchBox->hasSelectedText())
{
QString selectedText = mSearchBox->selectedText();
int indexOfSelectedText = newText.indexOf(selectedText);
if(indexOfSelectedText != -1)
{
newText.remove(indexOfSelectedText, selectedText.length());
mCursorPosition = indexOfSelectedText;
}
}
// No text selected
else
{
// Backspace Key
if(keyEvent->key() == Qt::Key_Backspace)
{
if(mCursorPosition > 0)
newText.remove(mCursorPosition-1, 1);
(mCursorPosition - 1) < 0 ? mCursorPosition = 0 : mCursorPosition--;
}
// Delete Key
else
{
if(mCursorPosition < newText.length())
newText.remove(mCursorPosition, 1);
}
}
}
mSearchBox->setText(newText);
}
bool SearchListView::eventFilter(QObject *obj, QEvent *event)
{
// Click in searchBox
if(obj == mSearchBox && event->type() == QEvent::MouseButtonPress)
{
// Give focus to current list to avoid having it elsewhere when you click on a different searchbox
mCurList->setFocus();
QMouseEvent *mouseEvent = static_cast<QMouseEvent* >(event);
QLineEdit *lineEdit = static_cast<QLineEdit* >(obj);
@ -201,45 +278,30 @@ bool SearchListView::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
// KeyPress in List
else if((obj == mList || obj == mSearchList) && event->type() == QEvent::KeyPress)
else if((obj == mList || obj == mSearchList || obj == mSearchBox) && event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent* >(event);
char ch = keyEvent->text().toUtf8().constData()[0];
if(isprint(ch)) //add a char to the search box
{
mSearchBox->setText(mSearchBox->text().insert(mSearchBox->cursorPosition(), QString(QChar(ch))));
mCursorPosition++;
}
else if(keyEvent->key() == Qt::Key_Backspace) //remove a char from the search box
{
QString newText;
if(keyEvent->modifiers() == Qt::ControlModifier) //clear the search box
{
newText = "";
mCursorPosition = 0;
}
else
{
newText = mSearchBox->text();
//add a char to the search box
if(isprint(ch))
addCharToSearchBox(ch);
if(mCursorPosition > 0)
newText.remove(mCursorPosition-1, 1);
//remove a char from the search box
else if(keyEvent->key() == Qt::Key_Backspace || keyEvent->key() == Qt::Key_Delete)
deleteTextFromSearchBox(keyEvent);
((mCursorPosition - 1) < 0) ? mCursorPosition = 0 : mCursorPosition--;
}
mSearchBox->setText(newText);
}
else if((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter)) //user pressed enter
{
// user pressed enter
else if((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter))
if(mCurList->getCellContent(mCurList->getInitialSelection(), 0).length())
emit enterPressedSignal();
}
else if(keyEvent->key() == Qt::Key_Escape) // Press escape, clears the search box
{
mSearchBox->clear();
mCursorPosition = 0;
}
// Press escape, clears the search box
else if(keyEvent->key() == Qt::Key_Escape)
{
mSearchBox->clear();
mCursorPosition = 0;
}
// Update cursorPosition to avoid a weird bug
mSearchBox->setCursorPosition(mCursorPosition);

View File

@ -47,6 +47,8 @@ private:
QWidget* mListPlaceHolder;
QAction* mSearchAction;
int mCursorPosition;
void addCharToSearchBox(char ch);
void deleteTextFromSearchBox(QKeyEvent *keyEvent);
protected:
bool eventFilter(QObject *obj, QEvent *event);

View File

@ -50,7 +50,7 @@ void StdTable::mouseMoveEvent(QMouseEvent* event)
else
setSingleSelection(wRowIndex);
repaint();
updateViewport();
wAccept = false;
}
@ -82,7 +82,7 @@ void StdTable::mousePressEvent(QMouseEvent* event)
mGuiState = StdTable::MultiRowsSelectionState;
repaint();
updateViewport();
wAccept = true;
}
@ -111,7 +111,7 @@ void StdTable::mouseReleaseEvent(QMouseEvent* event)
{
mGuiState = StdTable::NoState;
repaint();
updateViewport();
wAccept = false;
}
@ -145,7 +145,7 @@ void StdTable::keyPressEvent(QKeyEvent* event)
setTableOffset(getInitialSelection() - getNbrOfLineToPrint() + 2);
}
repaint();
updateViewport();
}
else
{

View File

@ -188,6 +188,7 @@ void BreakpointsView::reloadData()
mMemBPTable->setCellContent(wI, 4, "");
}
mMemBPTable->reloadData();
if(wBPList.count)
BridgeFree(wBPList.bp);
}
@ -333,6 +334,16 @@ void BreakpointsView::setupSoftBPRightClickContextMenu()
mSoftBPEnableDisableAction->setShortcutContext(Qt::WidgetShortcut);
mSoftBPTable->addAction(mSoftBPEnableDisableAction);
connect(mSoftBPEnableDisableAction, SIGNAL(triggered()), this, SLOT(enableDisableSoftBPActionSlot()));
// Enable All
mSoftBPEnableAllAction = new QAction("Enable All", this);
mSoftBPTable->addAction(mSoftBPEnableAllAction);
connect(mSoftBPEnableAllAction, SIGNAL(triggered()), this, SLOT(enableAllSoftBPActionSlot()));
// Disable All
mSoftBPDisableAllAction = new QAction("Disable All", this);
mSoftBPTable->addAction(mSoftBPDisableAllAction);
connect(mSoftBPDisableAllAction, SIGNAL(triggered()), this, SLOT(disableAllSoftBPActionSlot()));
}
void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos)
@ -377,6 +388,12 @@ void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos)
// Separator
wMenu->addSeparator();
// Enable All
wMenu->addAction(mSoftBPEnableAllAction);
// Disable All
wMenu->addAction(mSoftBPDisableAllAction);
// Remove All
wMenu->addAction(mSoftBPRemoveAllAction);
@ -412,6 +429,16 @@ void BreakpointsView::enableDisableSoftBPActionSlot()
table->selectNext();
}
void BreakpointsView::enableAllSoftBPActionSlot()
{
Breakpoints::toggleAllBP(bp_normal, true);
}
void BreakpointsView::disableAllSoftBPActionSlot()
{
Breakpoints::toggleAllBP(bp_normal, false);
}
void BreakpointsView::doubleClickSoftwareSlot()
{
StdTable* table = mSoftBPTable;

View File

@ -34,6 +34,8 @@ public slots:
void removeSoftBPActionSlot();
void removeAllSoftBPActionSlot();
void enableDisableSoftBPActionSlot();
void enableAllSoftBPActionSlot();
void disableAllSoftBPActionSlot();
void doubleClickSoftwareSlot();
// Memory
@ -59,6 +61,8 @@ private:
QAction* mSoftBPRemoveAction;
QAction* mSoftBPRemoveAllAction;
QAction* mSoftBPEnableDisableAction;
QAction* mSoftBPEnableAllAction;
QAction* mSoftBPDisableAllAction;
// Memory BP Context Menu
QAction* mMemBPRemoveAction;

View File

@ -306,6 +306,7 @@ void CPUDisassembly::setupRightClickContextMenu()
MenuBuilder* labelMenu = new MenuBuilder(this);
labelMenu->addAction(makeShortcutAction("Label Current Address", SLOT(setLabelSlot()), "ActionSetLabel"));
QAction* labelAddress = makeAction("Label", SLOT(setLabelAddressSlot()));
labelMenu->addAction(labelAddress, [this, labelAddress](QMenu*)
{
BASIC_INSTRUCTION_INFO instr_info;
@ -558,6 +559,7 @@ void CPUDisassembly::setLabelSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -587,6 +589,7 @@ void CPUDisassembly::setLabelAddressSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -616,6 +619,7 @@ void CPUDisassembly::setCommentSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -637,6 +641,7 @@ void CPUDisassembly::setBookmarkSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -690,6 +695,7 @@ void CPUDisassembly::toggleFunctionSlot()
QString cmd = "functiondel " + start_text;
DbgCmdExec(cmd.toUtf8().constData());
}
}
void CPUDisassembly::assembleSlot()

View File

@ -1,6 +1,7 @@
#include "CPUSideBar.h"
#include "Configuration.h"
#include "Breakpoints.h"
#include <QToolTip>
CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollArea(parent)
{
@ -8,13 +9,16 @@ CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollAr
selectedVA = -1;
viewableRows = 0;
CodePtr = Ptr;
mDisas = Ptr;
InstrBuffer = CodePtr->instructionsBuffer();
mInstrBuffer = mDisas->instructionsBuffer();
memset(&regDump, 0, sizeof(REGDUMP));
updateSlots();
this->setMouseTracking(true);
}
CPUSideBar::~CPUSideBar()
@ -51,12 +55,15 @@ void CPUSideBar::updateColors()
void CPUSideBar::updateFonts()
{
m_DefaultFont = CodePtr->font();
m_DefaultFont = mDisas->font();
this->setFont(m_DefaultFont);
QFontMetrics metrics(m_DefaultFont);
fontWidth = metrics.width(' ');
fontHeight = metrics.height();
mBulletRadius = fontHeight / 2;
mBulletYOffset = (fontHeight - mBulletRadius) / 2;
}
QSize CPUSideBar::sizeHint() const
@ -74,7 +81,7 @@ void CPUSideBar::debugStateChangedSlot(DBGSTATE state)
void CPUSideBar::repaint()
{
fontHeight = CodePtr->getRowHeight();
fontHeight = mDisas->getRowHeight();
viewport()->update();
}
@ -105,15 +112,20 @@ void CPUSideBar::setSelection(dsint selVA)
bool CPUSideBar::isJump(int i) const
{
const auto & instr = InstrBuffer->at(i);
auto branchType = instr.branchType;
const Instruction_t & instr = mInstrBuffer->at(i);
Instruction_t::BranchType branchType = instr.branchType;
if(branchType != Instruction_t::None)
{
duint start = CodePtr->getBase();
duint end = start + CodePtr->getSize();
duint addr = instr.branchDestination;
duint start = mDisas->getBase();
duint end = start + mDisas->getSize();
duint addr = DbgGetBranchDestination(start + instr.rva);
if(!addr)
return false;
return addr >= start && addr < end; //do not draw jumps that go out of the section
}
return false;
}
@ -127,7 +139,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
painter.fillRect(painter.viewport(), mBackgroundColor);
// Don't draw anything if there aren't any instructions to draw
if(InstrBuffer->size() == 0)
if(mInstrBuffer->size() == 0)
return;
// Line numbers to draw each register label
@ -135,15 +147,15 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
int jumpoffset = 0;
dsint last_va = InstrBuffer->last().rva + CodePtr->getBase();
dsint first_va = InstrBuffer->first().rva + CodePtr->getBase();
dsint last_va = mInstrBuffer->last().rva + mDisas->getBase();
dsint first_va = mInstrBuffer->first().rva + mDisas->getBase();
for(int line = 0; line < viewableRows; line++)
{
if(line >= InstrBuffer->size()) //at the end of the page it will crash otherwise
if(line >= mInstrBuffer->size()) //at the end of the page it will crash otherwise
break;
Instruction_t instr = InstrBuffer->at(line);
dsint instrVA = instr.rva + CodePtr->getBase();
Instruction_t instr = mInstrBuffer->at(line);
dsint instrVA = instr.rva + mDisas->getBase();
// draw bullet
drawBullets(&painter, line, DbgGetBpxTypeAt(instrVA) != bp_none, DbgIsBpDisabled(instrVA), DbgGetBookmarkAt(instrVA));
@ -155,26 +167,28 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
bool isConditional = instr.branchType == Instruction_t::Conditional;
/*
if(CodePtr->currentEIP() != InstrBuffer->at(line).rva) //create a setting for this
if(mDisas->currentEIP() != mInstrBuffer->at(line).rva) //create a setting for this
isJumpGoingToExecute=false;
*/
jumpoffset++;
dsint destVA = instr.branchDestination;
dsint baseAddr = mDisas->getBase();
dsint destVA = DbgGetBranchDestination(baseAddr + instr.rva);
// Do not try to draw EBFE (Jump to the same line)
if(destVA == instrVA)
continue;
// Do not draw jumps that leave the memory range
if(destVA >= CodePtr->getBase() + CodePtr->getSize() || destVA < CodePtr->getBase())
if(destVA >= mDisas->getBase() + mDisas->getSize() || destVA < mDisas->getBase())
continue;
if(destVA <= last_va && destVA >= first_va)
{
int destLine = line;
while(destLine > -1 && destLine < InstrBuffer->size() && InstrBuffer->at(destLine).rva + CodePtr->getBase() != destVA)
while(destLine > -1 && destLine < mInstrBuffer->size() && mInstrBuffer->at(destLine).rva + mDisas->getBase() != destVA)
{
if(destVA > instrVA) //jump goes up
destLine++;
@ -190,9 +204,9 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
}
// Register label line positions
const dsint cur_VA = CodePtr->getBase() + InstrBuffer->at(line).rva;
const dsint cur_VA = mDisas->getBase() + mInstrBuffer->at(line).rva;
if(InstrBuffer->at(line).rva == CodePtr->currentEIP())
if(mInstrBuffer->at(line).rva == mDisas->currentEIP())
registerLines[0] = line;
if(cur_VA == regDump.regcontext.cax) registerLines[1] = line;
@ -242,8 +256,8 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
if(y < bulletY || y > bulletY + bulletRadius)
return;
// calculate virtual adress of clicked line
duint wVA = InstrBuffer->at(line).rva + CodePtr->getBase();
// calculate virtual address of clicked line
duint wVA = mInstrBuffer->at(line).rva + mDisas->getBase();
QString wCmd;
// create --> disable --> delete --> create --> ...
@ -264,7 +278,48 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
wCmd = "bp " + QString("%1").arg(wVA, sizeof(dsint) * 2, 16, QChar('0')).toUpper();
DbgCmdExec(wCmd.toUtf8().constData());
break;
}
}
void CPUSideBar::mouseMoveEvent(QMouseEvent *event)
{
if(!DbgIsDebugging() || !mInstrBuffer->size())
{
QAbstractScrollArea::mouseMoveEvent(event);
return;
}
QPoint mousePos = event->pos();
QPoint globalMousePos = event->globalPos();
const int mLine = mousePos.y() / fontHeight;
const int mBulletX = viewport()->width() - mBulletXOffset;
const int mBulletY = mLine * fontHeight + mBulletYOffset;
const int mouseBulletXOffset = abs(mBulletX - mousePos.x());
const int mouseBulletYOffset = abs(mBulletY - mousePos.y());
// mouseCursor not on a bullet
if(mouseBulletXOffset > mBulletRadius || mouseBulletYOffset > mBulletRadius)
{
QToolTip::hideText();
return;
}
// calculate virtual address of clicked line
duint wVA = mInstrBuffer->at(mLine).rva + mDisas->getBase();
switch(Breakpoints::BPState(bp_normal, wVA))
{
case bp_enabled:
QToolTip::showText(globalMousePos, "BP enabled");
break;
case bp_disabled:
QToolTip::showText(globalMousePos, "BP disabled");
break;
case bp_non_existent:
QToolTip::showText(globalMousePos, "No BP set");
break;
}
}
@ -413,15 +468,14 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
painter->setPen(mBackgroundColor);
const int radius = fontHeight / 2; //14/2=7
const int x = viewport()->width() - mBulletXOffset; //initial x
const int y = line * fontHeight; //initial y
const int yAdd = (fontHeight - radius) / 2;
const int x = viewport()->width() - 10; //initial x
painter->setRenderHint(QPainter::Antialiasing, true);
if(isbpdisabled) //disabled breakpoint
painter->setBrush(QBrush(mBulletDisabledBreakpointColor));
painter->drawEllipse(x, y + yAdd, radius, radius);
painter->drawEllipse(x, y + mBulletYOffset, mBulletRadius, mBulletRadius);
painter->restore();
}

View File

@ -33,8 +33,9 @@ public slots:
void setSelection(dsint selVA);
protected:
virtual void paintEvent(QPaintEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* e);
void paintEvent(QPaintEvent* event);
void mouseReleaseEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* event);
void drawLabel(QPainter* painter, int Line, QString Text);
void drawBullets(QPainter* painter, int line, bool ispb, bool isbpdisabled, bool isbookmark);
@ -47,9 +48,13 @@ private:
QFont m_DefaultFont;
int fontWidth, fontHeight;
int viewableRows;
int mBulletRadius;
int mBulletYOffset = 10;
const int mBulletXOffset = 10;
CPUDisassembly* CodePtr;
QList<Instruction_t>* InstrBuffer;
CPUDisassembly* mDisas;
QList<Instruction_t>* mInstrBuffer;
REGDUMP regDump;
private:

View File

@ -16,6 +16,8 @@ CalculatorDialog::CalculatorDialog(QWidget* parent) : QDialog(parent), ui(new Ui
ui->txtExpression->selectAll();
ui->txtExpression->setFocus();
mValidateThread = new ValidateExpressionThread(this);
mValidateThread->setOnExpressionChangedCallback(std::bind(&CalculatorDialog::validateExpression, this, std::placeholders::_1));
connect(mValidateThread, SIGNAL(expressionChanged(bool, bool, dsint)), this, SLOT(expressionChanged(bool, bool, dsint)));
connect(ui->txtExpression, SIGNAL(textChanged(QString)), mValidateThread, SLOT(textChanged(QString)));
}
@ -25,6 +27,14 @@ CalculatorDialog::~CalculatorDialog()
delete ui;
}
void CalculatorDialog::validateExpression(QString expression)
{
duint value;
bool validExpression = DbgFunctions()->ValFromString(expression.toUtf8().constData(), &value);
bool validPointer = validExpression && DbgMemIsValidReadPtr(value);
this->mValidateThread->emitExpressionChanged(validExpression, validPointer, value);
}
void CalculatorDialog::showEvent(QShowEvent* event)
{
Q_UNUSED(event);

View File

@ -28,6 +28,7 @@ class CalculatorDialog : public QDialog
public:
explicit CalculatorDialog(QWidget* parent = 0);
~CalculatorDialog();
void validateExpression(QString expression);
void setExpressionFocus();
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);

View File

@ -14,11 +14,21 @@ WordEditDialog::WordEditDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Wo
ui->unsignedLineEdit->setValidator(new QRegExpValidator(QRegExp("^\\d*(\\d+)?$"), this));// No signs, 0-9
mValidateThread = new ValidateExpressionThread(this);
mValidateThread->setOnExpressionChangedCallback(std::bind(&WordEditDialog::validateExpression, this, std::placeholders::_1));
connect(mValidateThread, SIGNAL(expressionChanged(bool, bool, dsint)), this, SLOT(expressionChanged(bool, bool, dsint)));
connect(ui->expressionLineEdit, SIGNAL(textChanged(QString)), mValidateThread, SLOT(textChanged(QString)));
mWord = 0;
}
void WordEditDialog::validateExpression(QString expression)
{
duint value;
bool validExpression = DbgFunctions()->ValFromString(expression.toUtf8().constData(), &value);
bool validPointer = validExpression && DbgMemIsValidReadPtr(value);
this->mValidateThread->emitExpressionChanged(validExpression, validPointer, value);
}
WordEditDialog::~WordEditDialog()
{
delete ui;

View File

@ -18,6 +18,7 @@ class WordEditDialog : public QDialog
public:
explicit WordEditDialog(QWidget* parent = 0);
~WordEditDialog();
void validateExpression(QString expression);
void setup(QString title, duint defVal, int byteCount);
duint getVal();
void showEvent(QShowEvent* event);

View File

@ -279,6 +279,34 @@ void Breakpoints::toggleBPByDisabling(BPXTYPE type, duint va)
BridgeFree(wBPList.bp);
}
void Breakpoints::toggleAllBP(BPXTYPE type, bool bEnable)
{
BPMAP wBPList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
if(bEnable)
{
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
{
enableBP(wBPList.bp[wI]);
}
}
else
{
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
{
disableBP(wBPList.bp[wI]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
}
/**
* @brief returns if a breakpoint is disabled or not
*

View File

@ -26,6 +26,7 @@ public:
static void removeBP(BPXTYPE type, duint va);
static void toggleBPByDisabling(const BRIDGEBP & bp);
static void toggleBPByDisabling(BPXTYPE type, duint va);
static void toggleAllBP(BPXTYPE type, bool bEnable);
static void toggleBPByRemoving(BPXTYPE type, duint va);
static BPXSTATE BPState(BPXTYPE type, duint va);
};