1
0
Fork 0

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
This commit is contained in:
Herzeh 2015-12-23 23:43:27 +01:00
parent def33ac44b
commit 3aea6c865d
9 changed files with 50 additions and 21 deletions

View File

@ -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;

View File

@ -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
}

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

@ -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;
}

View File

@ -391,7 +391,7 @@ void BreakpointsView::softwareBPContextMenuSlot(const QPoint & pos)
// Enable All
wMenu->addAction(mSoftBPEnableAllAction);
// Enable All
// Disable All
wMenu->addAction(mSoftBPDisableAllAction);
// Remove All

View File

@ -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.

View File

@ -83,6 +83,7 @@ public slots:
void openSourceSlot();
void decompileSelectionSlot();
void decompileFunctionSlot();
void displayWarningSlot(QString title, QString text);
protected:
void paintEvent(QPaintEvent* event);

View File

@ -11,7 +11,7 @@ CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollAr
mDisas = Ptr;
InstrBuffer = mDisas->instructionsBuffer();
mInstrBuffer = mDisas->instructionsBuffer();
memset(&regDump, 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))
{

View File

@ -54,7 +54,7 @@ private:
CPUDisassembly* mDisas;
QList<Instruction_t>* InstrBuffer;
QList<Instruction_t>* mInstrBuffer;
REGDUMP regDump;
private: