1
0
Fork 0

Merge branch 'development' into graph_ogfd_new

Conflicts:
	src/bridge/bridgemain.cpp
	src/bridge/bridgemain.h
	src/gui/Src/BasicView/Disassembly.cpp
	src/gui/Src/BasicView/Disassembly.h
	src/gui/Src/BasicView/SearchListView.cpp
	src/gui/Src/BasicView/SearchListView.h
	src/gui/Src/Bridge/Bridge.cpp
	src/gui/Src/Bridge/Bridge.h
	src/gui/Src/Gui/CPUDisassembly.cpp
	src/gui/Src/Gui/MainWindow.cpp
	src/gui/Src/Gui/MainWindow.h
	src/gui/x64dbg.pro
This commit is contained in:
Mr. eXoDia 2015-12-24 21:38:23 +01:00
commit 3d8a0d3ec5
27 changed files with 312 additions and 103 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ debug/
doxygen*/
doc/
COV/
minidump/
# Global filetypes to ignore
*.depend

View File

@ -1250,12 +1250,12 @@ 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)
BRIDGE_IMPEXP void GuiDisplayWarning(const char* title, const char* text)
{
_gui_sendmessage(GUI_DISPLAY_WARNING, (void*)title, (void*)text);
}
BRIDGE_IMPEXP void GuiSetControlFlowInfos(CONTROLFLOWINFOS *ctrlFlow)
BRIDGE_IMPEXP void GuiSetControlFlowInfos(CONTROLFLOWINFOS* ctrlFlow)
{
_gui_sendmessage(GUI_SET_CONTROLFLOWINFOS, (void*) ctrlFlow, nullptr);
}

View File

@ -357,7 +357,7 @@ void BpCacheLoad(JSON Root)
memset(&breakpoint, 0, sizeof(BREAKPOINT));
if(breakpoint.type == BPNORMAL)
breakpoint.oldbytes = (short)json_hex_value(json_object_get(value, "oldbytes"));
breakpoint.oldbytes = (unsigned short)(json_hex_value(json_object_get(value, "oldbytes")) & 0xFFFF);
breakpoint.type = (BP_TYPE)json_integer_value(json_object_get(value, "type"));
breakpoint.addr = (duint)json_hex_value(json_object_get(value, "address"));
breakpoint.enabled = json_boolean_value(json_object_get(value, "enabled"));

View File

@ -22,7 +22,7 @@ struct BREAKPOINT
bool enabled;
bool singleshoot;
bool active;
short oldbytes;
unsigned short oldbytes;
BP_TYPE type;
DWORD titantype;
char name[MAX_BREAKPOINT_SIZE];

View File

@ -660,7 +660,7 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
MemUpdateMap();
GuiUpdateMemoryView();
GuiDumpAt(MemFindBaseAddr(GetContextData(UE_CIP), 0) + PAGE_SIZE); //dump somewhere
GuiDumpAt(MemFindBaseAddr(GetContextDataEx(CreateProcessInfo->hThread, UE_CIP), 0) + PAGE_SIZE); //dump somewhere
// Init program database
DBSetPath(nullptr, szFileName);
@ -929,7 +929,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
if((bBreakOnNextDll || settingboolget("Events", "DllEntry")) && !bAlreadySetEntry)
{
duint oep = GetPE32Data(DLLDebugFileName, 0, UE_OEP);
duint oep = GetPE32DataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), 0, UE_OEP);
if(oep)
{
char command[256] = "";
@ -1463,7 +1463,7 @@ DWORD WINAPI threadAttachLoop(void* lpParameter)
static PROCESS_INFORMATION pi_attached;
fdProcessInfo = &pi_attached;
//do some init stuff
bFileIsDll = IsFileDLL(szFileName, 0);
bFileIsDll = IsFileDLLW(StringUtils::Utf8ToUtf16(szFileName).c_str(), 0);
GuiAddRecentFile(szFileName);
ecount = 0;
//NOTE: set custom handlers

View File

@ -73,7 +73,7 @@ static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, ch
if (write)
{
lRv = RegCreateKeyEx(HKEY_LOCAL_MACHINE, JIT_REG_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, key_flags, NULL, &hKey, &dwDisposition);
lRv = RegCreateKeyExW(HKEY_LOCAL_MACHINE, JIT_REG_KEY, 0, NULL, REG_OPTION_NON_VOLATILE, key_flags, NULL, &hKey, &dwDisposition);
if (lRv != ERROR_SUCCESS)
return false;
@ -81,7 +81,7 @@ static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, ch
}
else
{
lRv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, JIT_REG_KEY, 0, key_flags, &hKey);
lRv = RegOpenKeyExW(HKEY_LOCAL_MACHINE, JIT_REG_KEY, 0, key_flags, &hKey);
if (lRv != ERROR_SUCCESS)
{
if (error != NULL)

View File

@ -3,7 +3,7 @@
#include "_global.h"
#define ATTACH_CMD_LINE "\" -a %ld -e %ld"
#define JIT_REG_KEY TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug")
#define JIT_REG_KEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug"
#define JIT_ENTRY_MAX_SIZE 512
#define JIT_ENTRY_DEF_SIZE (MAX_PATH + sizeof(ATTACH_CMD_LINE) + 2)

View File

@ -53,17 +53,16 @@ void MemUpdateMap()
if (!ModNameFromAddr(pageStart, curPage.info, true))
{
// Module lookup failed; check if it's a file mapping
wchar_t szMappedName[sizeof(curPage.info)] = L"";
if ((mbi.Type == MEM_MAPPED) &&
(GetMappedFileName(fdProcessInfo->hProcess, mbi.AllocationBase, curPage.info, MAX_MODULE_SIZE) != 0))
(GetMappedFileNameW(fdProcessInfo->hProcess, mbi.AllocationBase, szMappedName, MAX_MODULE_SIZE) != 0))
{
// Get the file name only
char* fileStart = strrchr(curPage.info, '\\');
size_t fileLen = strlen(fileStart);
if (fileStart)
memmove(curPage.info, fileStart + 1, fileLen);
curPage.info[fileLen] = '\0';
bool bFileNameOnly = false; //TODO: setting for this
auto fileStart = wcsrchr(szMappedName, L'\\');
if (bFileNameOnly && fileStart)
strcpy_s(curPage.info, StringUtils::Utf16ToUtf8(fileStart + 1).c_str());
else
strcpy_s(curPage.info, StringUtils::Utf16ToUtf8(szMappedName).c_str());
}
}

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

@ -495,7 +495,7 @@ void Disassembly::mouseMoveEvent(QMouseEvent* event)
else
expandSelectionUpTo(wRowIndex);
repaint();
updateViewport();
wAccept = false;
}
@ -575,7 +575,7 @@ void Disassembly::mousePressEvent(QMouseEvent* event)
mGuiState = Disassembly::MultiRowsSelectionState;
repaint();
updateViewport();
wAccept = true;
}
@ -606,7 +606,7 @@ void Disassembly::mouseReleaseEvent(QMouseEvent* event)
{
mGuiState = Disassembly::NoState;
repaint();
updateViewport();
wAccept = false;
}
@ -654,7 +654,7 @@ void Disassembly::keyPressEvent(QKeyEvent* event)
setTableOffset(getInstructionRVA(getSelectionEnd(), -getNbrOfLineToPrint() + 2));
}
repaint();
updateViewport();
}
else if(key == Qt::Key_Return || key == Qt::Key_Enter)
{
@ -1343,7 +1343,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

@ -187,11 +187,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 +279,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

@ -319,6 +319,7 @@ void CPUDisassembly::setupRightClickContextMenu()
});
mMenuBuilder->addMenu(makeMenu(QIcon(":/icons/images/label.png"), "Label"), labelMenu);
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/comment.png"), "Comment", SLOT(setCommentSlot()), "ActionSetComment"));
mMenuBuilder->addAction(makeShortcutAction(QIcon(":/icons/images/bookmark.png"), "Bookmark", SLOT(setBookmarkSlot()), "ActionToggleBookmark"));
QAction* toggleFunctionAction = makeShortcutAction(QIcon(":/icons/images/functions.png"), "Function", SLOT(toggleFunctionSlot()), "ActionToggleFunction");
@ -558,6 +559,7 @@ void CPUDisassembly::setLabelSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -616,6 +618,7 @@ void CPUDisassembly::setCommentSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -637,6 +640,7 @@ void CPUDisassembly::setBookmarkSlot()
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
msg.exec();
}
GuiUpdateAllViews();
}
@ -690,6 +694,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);
};