1
0
Fork 0

Merged mrexodia/x64_dbg into master

This commit is contained in:
David Reguera Garcia 2014-08-08 15:32:04 +02:00
commit 02d3b834d3
7 changed files with 138 additions and 10 deletions

View File

@ -213,7 +213,10 @@ static bool cbCommandProvider(char* cmd, int maxlen)
msgwait(gMsgStack, &msg);
char* newcmd = (char*)msg.param1;
if(strlen(newcmd) >= deflen)
newcmd[deflen - 1] = 0;
{
dprintf("command cut at ~%d characters\n", deflen);
newcmd[deflen - 2] = 0;
}
strcpy(cmd, newcmd);
efree(newcmd, "cbCommandProvider:newcmd"); //free allocated command
return true;

View File

@ -21,6 +21,8 @@ HexDump::HexDump(QWidget* parent) : AbstractTableView(parent)
textColor = ConfigColor("HexDumpTextColor");
selectionColor = ConfigColor("HexDumpSelectionColor");
mRvaDisplayEnabled = false;
connect(Bridge::getBridge(), SIGNAL(updateDump()), this, SLOT(reloadData()));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChanged(DBGSTATE)));
}
@ -57,6 +59,9 @@ void HexDump::printDumpAt(int_t parVA, bool select, bool repaint)
wRowCount = wSize / wBytePerRowCount;
wRowCount += mByteOffset > 0 ? 1 : 0;
if(mRvaDisplayEnabled && mMemPage->getBase() != mRvaDisplayPageBase)
mRvaDisplayEnabled = false;
setRowCount(wRowCount); //set the number of rows
mMemPage->setAttributes(wBase, wSize); // Set base and size (Useful when memory page changed)

View File

@ -159,6 +159,9 @@ protected:
int mByteOffset;
QList<ColumnDescriptor_t> mDescriptor;
int mForceColumn;
bool mRvaDisplayEnabled;
uint_t mRvaDisplayBase;
int_t mRvaDisplayPageBase;
};
#endif // _HEXDUMP_H

View File

@ -350,12 +350,40 @@ QString CPUDump::paintContent(QPainter* painter, int_t rowBase, int rowOffset, i
{
char label[MAX_LABEL_SIZE] = "";
QString addrText = "";
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
addrText = QString("%1").arg(curAddr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
int_t cur_addr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
if(mRvaDisplayEnabled) //RVA display
{
int_t rva = cur_addr - mRvaDisplayBase;
if(rva == 0)
{
#ifdef _WIN64
addrText = "$ ==> ";
#else
addrText = "$ ==> ";
#endif //_WIN64
}
else if(rva > 0)
{
#ifdef _WIN64
addrText = "$+" + QString("%1").arg(rva, -15, 16, QChar(' ')).toUpper();
#else
addrText = "$+" + QString("%1").arg(rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
else if(rva < 0)
{
#ifdef _WIN64
addrText = "$-" + QString("%1").arg(-rva, -15, 16, QChar(' ')).toUpper();
#else
addrText = "$-" + QString("%1").arg(-rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
}
addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(curAddr, module) && !QString(label).startsWith("JMP.&"))
if(DbgGetModuleAt(cur_addr, module) && !QString(label).startsWith("JMP.&"))
addrText += " <" + QString(module) + "." + QString(label) + ">";
else
addrText += " <" + QString(label) + ">";
@ -451,6 +479,36 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event)
wMenu->exec(event->globalPos()); //execute context menu
}
void CPUDump::mouseDoubleClickEvent(QMouseEvent* event)
{
if(event->button() != Qt::LeftButton)
return;
switch(getColumnIndexFromX(event->x()))
{
case 0: //address
{
//very ugly way to calculate the base of the current row (no clue why it works)
int_t deltaRowBase = getInitialSelection() % getBytePerRowCount() + mByteOffset;
if(deltaRowBase >= getBytePerRowCount())
deltaRowBase -= getBytePerRowCount();
int_t mSelectedVa = rvaToVa(getInitialSelection() - deltaRowBase);
if(mRvaDisplayEnabled && mSelectedVa == mRvaDisplayBase)
mRvaDisplayEnabled = false;
else
{
mRvaDisplayEnabled = true;
mRvaDisplayBase = mSelectedVa;
mRvaDisplayPageBase = mMemPage->getBase();
}
reloadData();
}
break;
default:
break;
}
}
void CPUDump::setLabelSlot()
{
if(!DbgIsDebugging())

View File

@ -20,6 +20,7 @@ public:
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
void setupContextMenu();
void contextMenuEvent(QContextMenuEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
signals:
void displayReferencesWidget();

View File

@ -184,12 +184,40 @@ QString CPUStack::paintContent(QPainter* painter, int_t rowBase, int rowOffset,
{
char label[MAX_LABEL_SIZE] = "";
QString addrText = "";
int_t curAddr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
addrText = QString("%1").arg(curAddr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(curAddr, SEG_DEFAULT, label)) //has label
int_t cur_addr = rvaToVa((rowBase + rowOffset) * getBytePerRowCount() - mByteOffset);
if(mRvaDisplayEnabled) //RVA display
{
int_t rva = cur_addr - mRvaDisplayBase;
if(rva == 0)
{
#ifdef _WIN64
addrText = "$ ==> ";
#else
addrText = "$ ==> ";
#endif //_WIN64
}
else if(rva > 0)
{
#ifdef _WIN64
addrText = "$+" + QString("%1").arg(rva, -15, 16, QChar(' ')).toUpper();
#else
addrText = "$+" + QString("%1").arg(rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
else if(rva < 0)
{
#ifdef _WIN64
addrText = "$-" + QString("%1").arg(-rva, -15, 16, QChar(' ')).toUpper();
#else
addrText = "$-" + QString("%1").arg(-rva, -7, 16, QChar(' ')).toUpper();
#endif //_WIN64
}
}
addrText += QString("%1").arg(cur_addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
if(DbgGetLabelAt(cur_addr, SEG_DEFAULT, label)) //has label
{
char module[MAX_MODULE_SIZE] = "";
if(DbgGetModuleAt(curAddr, module) && !QString(label).startsWith("JMP.&"))
if(DbgGetModuleAt(cur_addr, module) && !QString(label).startsWith("JMP.&"))
addrText += " <" + QString(module) + "." + QString(label) + ">";
else
addrText += " <" + QString(label) + ">";
@ -300,6 +328,36 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event)
wMenu->exec(event->globalPos());
}
void CPUStack::mouseDoubleClickEvent(QMouseEvent* event)
{
if(event->button() != Qt::LeftButton)
return;
switch(getColumnIndexFromX(event->x()))
{
case 0: //address
{
//very ugly way to calculate the base of the current row (no clue why it works)
int_t deltaRowBase = getInitialSelection() % getBytePerRowCount() + mByteOffset;
if(deltaRowBase >= getBytePerRowCount())
deltaRowBase -= getBytePerRowCount();
int_t mSelectedVa = rvaToVa(getInitialSelection() - deltaRowBase);
if(mRvaDisplayEnabled && mSelectedVa == mRvaDisplayBase)
mRvaDisplayEnabled = false;
else
{
mRvaDisplayEnabled = true;
mRvaDisplayBase = mSelectedVa;
mRvaDisplayPageBase = mMemPage->getBase();
}
reloadData();
}
break;
default:
break;
}
}
void CPUStack::stackDumpAt(uint_t addr, uint_t csp)
{
mCsp = csp;

View File

@ -19,7 +19,7 @@ public:
void fontsUpdated();
QString paintContent(QPainter* painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
void contextMenuEvent(QContextMenuEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void setupContextMenu();
signals: