From 3aea6c865da97ef3461809a732fe0a33c90eb888 Mon Sep 17 00:00:00 2001 From: Herzeh Date: Wed, 23 Dec 2015 23:43:27 +0100 Subject: [PATCH] Added back GuiDisplayWarning which confused me since i used it for two reasons (one reason of the reasons doesn't exist anymore)...basically im a retard CPUSideBar : Added arrows showing up when there is a jmp with a register (say jmp eax) and the address in the register is within the current module --- src/bridge/bridgemain.cpp | 6 +++++ src/bridge/bridgemain.h | 4 ++- src/gui/Src/BasicView/Disassembly.h | 2 +- src/gui/Src/Bridge/Bridge.cpp | 8 ++++++ src/gui/Src/Gui/BreakpointsView.cpp | 2 +- src/gui/Src/Gui/CPUDisassembly.cpp | 5 ++++ src/gui/Src/Gui/CPUDisassembly.h | 1 + src/gui/Src/Gui/CPUSideBar.cpp | 41 +++++++++++++++++------------ src/gui/Src/Gui/CPUSideBar.h | 2 +- 9 files changed, 50 insertions(+), 21 deletions(-) diff --git a/src/bridge/bridgemain.cpp b/src/bridge/bridgemain.cpp index f7f8278e..8d396aa6 100644 --- a/src/bridge/bridgemain.cpp +++ b/src/bridge/bridgemain.cpp @@ -1250,6 +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) +{ + _gui_sendmessage(GUI_DISPLAY_WARNING, (void*) title, (void*) text); +} + BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hInst = hinstDLL; diff --git a/src/bridge/bridgemain.h b/src/bridge/bridgemain.h index 22fbd56d..3ae6e3f9 100644 --- a/src/bridge/bridgemain.h +++ b/src/bridge/bridgemain.h @@ -787,7 +787,8 @@ typedef enum GUI_GET_GLOBAL_NOTES, // param1=char** text, param2=unused GUI_SET_DEBUGGEE_NOTES, // param1=const char* text, param2=unused GUI_GET_DEBUGGEE_NOTES, // param1=char** text, param2=unused - GUI_DUMP_AT_N // param1=int index, param2=duint va + GUI_DUMP_AT_N, // param1=int index, param2=duint va + GUI_DISPLAY_WARNING // param1=const char *text, param2=unused } GUIMSG; //GUI Typedefs @@ -887,6 +888,7 @@ BRIDGE_IMPEXP void GuiGetGlobalNotes(char** text); BRIDGE_IMPEXP void GuiSetDebuggeeNotes(const char* text); BRIDGE_IMPEXP void GuiGetDebuggeeNotes(char** text); BRIDGE_IMPEXP void GuiDumpAtN(duint va, int index); +BRIDGE_IMPEXP void GuiDisplayWarning(const char *title, const char *text); #ifdef __cplusplus } diff --git a/src/gui/Src/BasicView/Disassembly.h b/src/gui/Src/BasicView/Disassembly.h index 01339c14..dafa2c67 100644 --- a/src/gui/Src/BasicView/Disassembly.h +++ b/src/gui/Src/BasicView/Disassembly.h @@ -87,7 +87,7 @@ public: //disassemble void disassembleAt(dsint parVA, dsint parCIP, bool history, dsint newTableOffset); - QList* instructionsBuffer(); + QList* instructionsBuffer(); // ugly const dsint baseAddress() const; const dsint currentEIP() const; diff --git a/src/gui/Src/Bridge/Bridge.cpp b/src/gui/Src/Bridge/Bridge.cpp index c44417bb..d2f00d81 100644 --- a/src/gui/Src/Bridge/Bridge.cpp +++ b/src/gui/Src/Bridge/Bridge.cpp @@ -528,6 +528,14 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2) emit dumpAtN((duint)param1, (int)param2); } break; + + case GUI_DISPLAY_WARNING: + { + QString title = QString((const char*)param1); + QString text = QString((const char*)param2); + emit displayWarning(title, text); + } + break; } return nullptr; } diff --git a/src/gui/Src/Gui/BreakpointsView.cpp b/src/gui/Src/Gui/BreakpointsView.cpp index f3114d3c..2f5d3328 100644 --- a/src/gui/Src/Gui/BreakpointsView.cpp +++ b/src/gui/Src/Gui/BreakpointsView.cpp @@ -391,7 +391,7 @@ void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos) // Enable All wMenu->addAction(mSoftBPEnableAllAction); - // Enable All + // Disable All wMenu->addAction(mSoftBPDisableAllAction); // Remove All diff --git a/src/gui/Src/Gui/CPUDisassembly.cpp b/src/gui/Src/Gui/CPUDisassembly.cpp index 7ca5af91..d8c8b717 100644 --- a/src/gui/Src/Gui/CPUDisassembly.cpp +++ b/src/gui/Src/Gui/CPUDisassembly.cpp @@ -1240,6 +1240,11 @@ void CPUDisassembly::decompileFunctionSlot() } } +void CPUDisassembly::displayWarningSlot(QString title, QString text) +{ + QMessageBox::QMessageBox(QMessageBox::Information, title, text, QMessageBox::Ok).exec(); +} + void CPUDisassembly::paintEvent(QPaintEvent* event) { // Hook/hack to update the sidebar at the same time as this widget. diff --git a/src/gui/Src/Gui/CPUDisassembly.h b/src/gui/Src/Gui/CPUDisassembly.h index 02da9752..fa51d5c8 100644 --- a/src/gui/Src/Gui/CPUDisassembly.h +++ b/src/gui/Src/Gui/CPUDisassembly.h @@ -83,6 +83,7 @@ public slots: void openSourceSlot(); void decompileSelectionSlot(); void decompileFunctionSlot(); + void displayWarningSlot(QString title, QString text); protected: void paintEvent(QPaintEvent* event); diff --git a/src/gui/Src/Gui/CPUSideBar.cpp b/src/gui/Src/Gui/CPUSideBar.cpp index 2c526641..fe258e6c 100644 --- a/src/gui/Src/Gui/CPUSideBar.cpp +++ b/src/gui/Src/Gui/CPUSideBar.cpp @@ -11,7 +11,7 @@ CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollAr mDisas = Ptr; - InstrBuffer = mDisas->instructionsBuffer(); + mInstrBuffer = mDisas->instructionsBuffer(); memset(®Dump, 0, sizeof(REGDUMP)); @@ -112,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 = mDisas->getBase(); duint end = start + mDisas->getSize(); - duint addr = instr.branchDestination; + 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; } @@ -134,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 @@ -142,14 +147,14 @@ void CPUSideBar::paintEvent(QPaintEvent* event) int jumpoffset = 0; - dsint last_va = InstrBuffer->last().rva + mDisas->getBase(); - dsint first_va = InstrBuffer->first().rva + mDisas->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); + Instruction_t instr = mInstrBuffer->at(line); dsint instrVA = instr.rva + mDisas->getBase(); // draw bullet @@ -162,13 +167,15 @@ void CPUSideBar::paintEvent(QPaintEvent* event) bool isConditional = instr.branchType == Instruction_t::Conditional; /* - if(mDisas->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) @@ -181,7 +188,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event) if(destVA <= last_va && destVA >= first_va) { int destLine = line; - while(destLine > -1 && destLine < InstrBuffer->size() && InstrBuffer->at(destLine).rva + mDisas->getBase() != destVA) + while(destLine > -1 && destLine < mInstrBuffer->size() && mInstrBuffer->at(destLine).rva + mDisas->getBase() != destVA) { if(destVA > instrVA) //jump goes up destLine++; @@ -197,9 +204,9 @@ void CPUSideBar::paintEvent(QPaintEvent* event) } // Register label line positions - const dsint cur_VA = mDisas->getBase() + InstrBuffer->at(line).rva; + const dsint cur_VA = mDisas->getBase() + mInstrBuffer->at(line).rva; - if(InstrBuffer->at(line).rva == mDisas->currentEIP()) + if(mInstrBuffer->at(line).rva == mDisas->currentEIP()) registerLines[0] = line; if(cur_VA == regDump.regcontext.cax) registerLines[1] = line; @@ -250,7 +257,7 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e) return; // calculate virtual address of clicked line - duint wVA = InstrBuffer->at(line).rva + mDisas->getBase(); + duint wVA = mInstrBuffer->at(line).rva + mDisas->getBase(); QString wCmd; // create --> disable --> delete --> create --> ... @@ -276,7 +283,7 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e) void CPUSideBar::mouseMoveEvent(QMouseEvent *event) { - if(!DbgIsDebugging() || !InstrBuffer->size()) + if(!DbgIsDebugging() || !mInstrBuffer->size()) { QAbstractScrollArea::mouseMoveEvent(event); return; @@ -300,7 +307,7 @@ void CPUSideBar::mouseMoveEvent(QMouseEvent *event) } // calculate virtual address of clicked line - duint wVA = InstrBuffer->at(mLine).rva + mDisas->getBase(); + duint wVA = mInstrBuffer->at(mLine).rva + mDisas->getBase(); switch(Breakpoints::BPState(bp_normal, wVA)) { diff --git a/src/gui/Src/Gui/CPUSideBar.h b/src/gui/Src/Gui/CPUSideBar.h index dd952810..d172655c 100644 --- a/src/gui/Src/Gui/CPUSideBar.h +++ b/src/gui/Src/Gui/CPUSideBar.h @@ -54,7 +54,7 @@ private: CPUDisassembly* mDisas; - QList* InstrBuffer; + QList* mInstrBuffer; REGDUMP regDump; private: