1
0
Fork 0

Get rid of the wLocal variable naming convention (mostly)

This commit is contained in:
Duncan Ogilvie 2023-08-26 10:58:36 +02:00
parent 6fba4478fb
commit 812c91d361
55 changed files with 1534 additions and 1550 deletions

View File

@ -326,7 +326,7 @@ void AbstractStdTable::updateColors()
void AbstractStdTable::mouseMoveEvent(QMouseEvent* event)
{
bool wAccept = true;
bool accept = true;
int y = transY(event->y());
if(mGuiState == AbstractStdTable::MultiRowsSelectionState)
@ -335,18 +335,18 @@ void AbstractStdTable::mouseMoveEvent(QMouseEvent* event)
if(y >= 0 && y <= this->getTableHeight())
{
int wRowIndex = getTableOffset() + getIndexOffsetFromY(y);
auto rowIndex = getTableOffset() + getIndexOffsetFromY(y);
if(wRowIndex < getRowCount())
if(rowIndex < getRowCount())
{
if(mIsMultiSelectionAllowed)
expandSelectionUpTo(wRowIndex);
expandSelectionUpTo(rowIndex);
else
setSingleSelection(wRowIndex);
setSingleSelection(rowIndex);
updateViewport();
wAccept = false;
accept = false;
}
}
else if(y < 0)
@ -359,13 +359,13 @@ void AbstractStdTable::mouseMoveEvent(QMouseEvent* event)
}
}
if(wAccept)
if(accept)
AbstractTableView::mouseMoveEvent(event);
}
void AbstractStdTable::mousePressEvent(QMouseEvent* event)
{
bool wAccept = false;
bool accept = false;
if(((event->buttons() & Qt::LeftButton) != 0) && ((event->buttons() & Qt::RightButton) == 0))
{
@ -373,26 +373,26 @@ void AbstractStdTable::mousePressEvent(QMouseEvent* event)
{
if(event->y() > getHeaderHeight())
{
int wRowIndex = getTableOffset() + getIndexOffsetFromY(transY(event->y()));
auto rowIndex = getTableOffset() + getIndexOffsetFromY(transY(event->y()));
if(wRowIndex < getRowCount())
if(rowIndex < getRowCount())
{
if(mIsMultiSelectionAllowed && (event->modifiers() & Qt::ShiftModifier))
expandSelectionUpTo(wRowIndex);
expandSelectionUpTo(rowIndex);
else
setSingleSelection(wRowIndex);
setSingleSelection(rowIndex);
mGuiState = AbstractStdTable::MultiRowsSelectionState;
updateViewport();
wAccept = true;
accept = true;
}
}
}
}
if(!wAccept)
if(!accept)
AbstractTableView::mousePressEvent(event);
}
@ -405,7 +405,7 @@ void AbstractStdTable::mouseDoubleClickEvent(QMouseEvent* event)
void AbstractStdTable::mouseReleaseEvent(QMouseEvent* event)
{
bool wAccept = true;
bool accept = true;
if((event->buttons() & Qt::LeftButton) == 0)
{
@ -415,11 +415,11 @@ void AbstractStdTable::mouseReleaseEvent(QMouseEvent* event)
updateViewport();
wAccept = false;
accept = false;
}
}
if(wAccept)
if(accept)
AbstractTableView::mouseReleaseEvent(event);
}
@ -436,8 +436,8 @@ void AbstractStdTable::keyPressEvent(QKeyEvent* event)
key == Qt::Key_A ||
key == Qt::Key_C)
{
dsint wBotIndex = getTableOffset();
dsint wTopIndex = wBotIndex + getNbrOfLineToPrint() - 1;
auto botIndex = getTableOffset();
auto topIndex = botIndex + getNbrOfLineToPrint() - 1;
switch(key)
{
@ -500,11 +500,11 @@ void AbstractStdTable::keyPressEvent(QKeyEvent* event)
break;
}
if(getInitialSelection() < wBotIndex)
if(getInitialSelection() < botIndex)
{
setTableOffset(getInitialSelection());
}
else if(getInitialSelection() >= wTopIndex)
else if(getInitialSelection() >= topIndex)
{
setTableOffset(getInitialSelection() - getNbrOfLineToPrint() + 2);
}
@ -552,46 +552,46 @@ void AbstractStdTable::expandSelectionUpTo(int to)
void AbstractStdTable::expandUp()
{
int wRowIndex = mSelection.firstSelectedIndex - 1;
if(wRowIndex >= 0)
auto rowIndex = mSelection.firstSelectedIndex - 1;
if(rowIndex >= 0)
{
if(wRowIndex < mSelection.fromIndex)
if(rowIndex < mSelection.fromIndex)
{
mSelection.fromIndex = wRowIndex;
mSelection.firstSelectedIndex = wRowIndex;
mSelection.fromIndex = rowIndex;
mSelection.firstSelectedIndex = rowIndex;
}
else
{
mSelection.firstSelectedIndex = wRowIndex;
mSelection.toIndex = wRowIndex;
mSelection.firstSelectedIndex = rowIndex;
mSelection.toIndex = rowIndex;
}
emit selectionChangedSignal(wRowIndex);
emit selectionChanged(rowIndex);
}
}
void AbstractStdTable::expandDown()
{
int wRowIndex = mSelection.firstSelectedIndex + 1;
int endIndex = getRowCount() - 1;
if(wRowIndex <= endIndex)
auto rowIndex = mSelection.firstSelectedIndex + 1;
auto endIndex = getRowCount() - 1;
if(rowIndex <= endIndex)
{
if(wRowIndex > mSelection.toIndex)
if(rowIndex > mSelection.toIndex)
{
mSelection.firstSelectedIndex = wRowIndex;
mSelection.toIndex = wRowIndex;
mSelection.firstSelectedIndex = rowIndex;
mSelection.toIndex = rowIndex;
}
else
{
mSelection.fromIndex = wRowIndex;
mSelection.firstSelectedIndex = wRowIndex;
mSelection.fromIndex = rowIndex;
mSelection.firstSelectedIndex = rowIndex;
}
emit selectionChangedSignal(wRowIndex);
emit selectionChanged(rowIndex);
}
}
@ -605,10 +605,10 @@ void AbstractStdTable::expandTop()
void AbstractStdTable::expandBottom()
{
int endIndex = getRowCount() - 1;
if(endIndex >= 0)
auto rowCount = getRowCount();
if(rowCount > 0)
{
expandSelectionUpTo(endIndex);
expandSelectionUpTo(rowCount - 1);
}
}
@ -646,7 +646,7 @@ void AbstractStdTable::selectStart()
void AbstractStdTable::selectEnd()
{
int endIndex = getRowCount() - 1;
auto endIndex = getRowCount() - 1;
if(endIndex >= 0)
{
setSingleSelection(endIndex);
@ -1002,6 +1002,8 @@ void AbstractStdTable::setCopyMenuOnly(bool bSet, bool bDebugOnly)
void AbstractStdTable::contextMenuRequestedSlot(const QPoint & pos)
{
if(pos.y() < getHeaderHeight())
return;
if(!mCopyMenuOnly)
{
emit contextMenuSignal(pos);
@ -1009,14 +1011,14 @@ void AbstractStdTable::contextMenuRequestedSlot(const QPoint & pos)
}
if(mCopyMenuDebugOnly && !DbgIsDebugging())
return;
QMenu wMenu(this);
QMenu wCopyMenu(tr("&Copy"), this);
setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
auto menu = new QMenu(this);
auto copyMenu = new QMenu(tr("&Copy"), this);
setupCopyMenu(copyMenu);
if(copyMenu->actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
wMenu.exec(mapToGlobal(pos));
menu->addSeparator();
menu->addMenu(copyMenu);
menu->popup(mapToGlobal(pos));
}
}

View File

@ -465,21 +465,21 @@ void AbstractTableView::mousePressEvent(QMouseEvent* event)
{
if(((event->buttons() & Qt::LeftButton) != 0) && ((event->buttons() & Qt::RightButton) == 0))
{
if(mColResizeData.splitHandle == true)
if(mColResizeData.splitHandle)
{
int wColIndex = getColumnDisplayIndexFromX(event->x());
int wDisplayIndex = getColumnDisplayIndexFromX(event->x());
int wStartPos = getColumnPosition(wDisplayIndex); // Position X of the start of column
int colIndex = getColumnDisplayIndexFromX(event->x());
int displayIndex = getColumnDisplayIndexFromX(event->x());
int startPos = getColumnPosition(displayIndex); // Position X of the start of column
mGuiState = AbstractTableView::ResizeColumnState;
if(event->x() <= (wStartPos + 2))
if(event->x() <= (startPos + 2))
{
mColResizeData.index = wColIndex - 1;
mColResizeData.index = colIndex - 1;
}
else
{
mColResizeData.index = wColIndex;
mColResizeData.index = colIndex;
}
mColResizeData.lastPosX = event->x();
@ -488,16 +488,16 @@ void AbstractTableView::mousePressEvent(QMouseEvent* event)
{
mReorderStartX = event->x();
int wColIndex = getColumnIndexFromX(event->x());
if(mColumnList[wColIndex].header.isClickable)
int colIndex = getColumnIndexFromX(event->x());
if(mColumnList[colIndex].header.isClickable)
{
//qDebug() << "Button " << wColIndex << "has been pressed.";
emit headerButtonPressed(wColIndex);
//qDebug() << "Button " << colIndex << "has been pressed.";
emit headerButtonPressed(colIndex);
mColumnList[wColIndex].header.isPressed = true;
mColumnList[wColIndex].header.isMouseOver = true;
mColumnList[colIndex].header.isPressed = true;
mColumnList[colIndex].header.isMouseOver = true;
mHeader.activeButtonIndex = wColIndex;
mHeader.activeButtonIndex = colIndex;
mGuiState = AbstractTableView::HeaderButtonPressed;
@ -536,9 +536,8 @@ void AbstractTableView::mouseReleaseEvent(QMouseEvent* event)
}
else if(mGuiState == AbstractTableView::HeaderButtonPressed)
{
if(mColumnList[mHeader.activeButtonIndex].header.isMouseOver == true)
if(mColumnList[mHeader.activeButtonIndex].header.isMouseOver)
{
//qDebug() << "Button " << mHeader.activeButtonIndex << "has been released.";
emit headerButtonReleased(mHeader.activeButtonIndex);
}
mGuiState = AbstractTableView::NoState;
@ -662,28 +661,34 @@ void AbstractTableView::leaveEvent(QEvent* event)
*/
void AbstractTableView::keyPressEvent(QKeyEvent* event)
{
int wKey = event->key();
auto key = event->key();
if(event->modifiers() != Qt::NoModifier && event->modifiers() != Qt::KeypadModifier)
return;
return QAbstractScrollArea::keyPressEvent(event);
if(wKey == Qt::Key_Up)
if(key == Qt::Key_Up)
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepSub);
}
else if(wKey == Qt::Key_Down)
else if(key == Qt::Key_Down)
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderSingleStepAdd);
}
else if(wKey == Qt::Key_PageUp)
else if(key == Qt::Key_PageUp)
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepSub);
}
else if(wKey == Qt::Key_PageDown)
else if(key == Qt::Key_PageDown)
{
verticalScrollBar()->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
else if(wKey == Qt::Key_Return || wKey == Qt::Key_Enter) //user pressed enter
else if(key == Qt::Key_Return || key == Qt::Key_Enter) //user pressed enter
{
emit enterPressedSignal();
}
else
{
QAbstractScrollArea::keyPressEvent(event);
}
}
/************************************************************************************
@ -918,26 +923,26 @@ int AbstractTableView::getIndexOffsetFromY(int y) const
*/
int AbstractTableView::getColumnIndexFromX(int x) const
{
int wX = -horizontalScrollBar()->value();
int wColIndex = 0;
int scrollX = -horizontalScrollBar()->value();
duint colIndex = 0;
while(wColIndex < getColumnCount())
while(colIndex < getColumnCount())
{
int col = mColumnOrder[wColIndex];
auto col = mColumnOrder[colIndex];
if(getColumnHidden(col))
{
wColIndex++;
colIndex++;
continue;
}
wX += getColumnWidth(col);
scrollX += getColumnWidth(col);
if(x <= wX)
if(x <= scrollX)
{
return mColumnOrder[wColIndex];
return mColumnOrder[colIndex];
}
else if(wColIndex < getColumnCount())
else if(colIndex < getColumnCount())
{
wColIndex++;
colIndex++;
}
}
return getColumnCount() > 0 ? mColumnOrder[getColumnCount() - 1] : -1;
@ -952,26 +957,26 @@ int AbstractTableView::getColumnIndexFromX(int x) const
*/
int AbstractTableView::getColumnDisplayIndexFromX(int x)
{
int wX = -horizontalScrollBar()->value();
int wColIndex = 0;
int scrollX = -horizontalScrollBar()->value();
int colIndex = 0;
while(wColIndex < getColumnCount())
while(colIndex < getColumnCount())
{
int col = mColumnOrder[wColIndex];
auto col = mColumnOrder[colIndex];
if(getColumnHidden(col))
{
wColIndex++;
colIndex++;
continue;
}
wX += getColumnWidth(col);
scrollX += getColumnWidth(col);
if(x <= wX)
if(x <= scrollX)
{
return wColIndex;
return colIndex;
}
else if(wColIndex < getColumnCount())
else if(colIndex < getColumnCount())
{
wColIndex++;
colIndex++;
}
}
return getColumnCount() - 1;
@ -1014,7 +1019,7 @@ int AbstractTableView::transY(int y) const
}
/**
* @brief Returns the number of viewable rows in the current window (Partially viewable rows are aslo counted).
* @brief Returns the number of viewable rows in the current window (Partially viewable rows are also counted).
*
* @return Number of viewable rows.
*/
@ -1178,7 +1183,7 @@ int AbstractTableView::getColumnOrder(int index) const
int AbstractTableView::getHeaderHeight() const
{
if(mHeader.isVisible == true)
if(mHeader.isVisible)
return mHeader.height;
else
return 0;
@ -1211,7 +1216,7 @@ void AbstractTableView::setShowHeader(bool show)
int AbstractTableView::getCharWidth() const
{
return QFontMetrics(this->font()).width(QChar(' '));
return mFontMetrics->width(' ');
}
/************************************************************************************

View File

@ -67,7 +67,7 @@ QString HistoryLineEdit::addHistoryClear()
void HistoryLineEdit::keyPressEvent(QKeyEvent* event)
{
int wKey = event->key();
int key = event->key();
//This fixes a very annoying bug on some systems
if(bSixPressed)
@ -79,14 +79,14 @@ void HistoryLineEdit::keyPressEvent(QKeyEvent* event)
return;
}
}
if(wKey == Qt::Key_6)
if(key == Qt::Key_6)
bSixPressed = true;
if(wKey == Qt::Key_Up || wKey == Qt::Key_Down)
if(key == Qt::Key_Up || key == Qt::Key_Down)
{
if(wKey == Qt::Key_Up)
if(key == Qt::Key_Up)
mCmdIndex++;
else if(wKey == Qt::Key_Down)
else if(key == Qt::Key_Down)
mCmdIndex--;
mCmdIndex = mCmdIndex < -1 ? -1 : mCmdIndex;

View File

@ -203,7 +203,7 @@ void ReferenceView::addCommand(QString title, QString command)
mCommands.append(command);
}
void ReferenceView::referenceContextMenu(QMenu* wMenu)
void ReferenceView::referenceContextMenu(QMenu* menu)
{
if(!mCurList->getRowCount())
return;
@ -213,39 +213,39 @@ void ReferenceView::referenceContextMenu(QMenu* wMenu)
return;
if(DbgMemIsValidReadPtr(addr))
{
wMenu->addAction(mFollowAddress);
wMenu->addAction(mFollowDumpAddress);
menu->addAction(mFollowAddress);
menu->addAction(mFollowDumpAddress);
dsint apiaddr = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1));
if(apiaddr)
wMenu->addAction(mFollowApiAddress);
wMenu->addSeparator();
wMenu->addAction(mToggleBreakpoint);
wMenu->addAction(mSetBreakpointOnAllCommands);
wMenu->addAction(mRemoveBreakpointOnAllCommands);
menu->addAction(mFollowApiAddress);
menu->addSeparator();
menu->addAction(mToggleBreakpoint);
menu->addAction(mSetBreakpointOnAllCommands);
menu->addAction(mRemoveBreakpointOnAllCommands);
if(apiaddr)
{
char label[MAX_LABEL_SIZE] = "";
if(DbgGetLabelAt(apiaddr, SEG_DEFAULT, label))
{
wMenu->addSeparator();
menu->addSeparator();
mSetBreakpointOnAllApiCalls->setText(tr("Set breakpoint on all calls to %1").arg(label));
wMenu->addAction(mSetBreakpointOnAllApiCalls);
menu->addAction(mSetBreakpointOnAllApiCalls);
mRemoveBreakpointOnAllApiCalls->setText(tr("Remove breakpoint on all calls to %1").arg(label));
wMenu->addAction(mRemoveBreakpointOnAllApiCalls);
menu->addAction(mRemoveBreakpointOnAllApiCalls);
}
}
wMenu->addSeparator();
wMenu->addAction(mToggleBookmark);
menu->addSeparator();
menu->addAction(mToggleBookmark);
}
if(this->mCommands.size() > 0)
{
wMenu->addSeparator();
menu->addSeparator();
for(auto i = 0; i < this->mCommandTitles.size(); i++)
{
QAction* newCommandAction = new QAction(this->mCommandTitles.at(i), wMenu);
QAction* newCommandAction = new QAction(this->mCommandTitles.at(i), menu);
newCommandAction->setData(QVariant(mCommands.at(i)));
connect(newCommandAction, SIGNAL(triggered()), this, SLOT(referenceExecCommand()));
wMenu->addAction(newCommandAction);
menu->addAction(newCommandAction);
}
}
}
@ -292,30 +292,30 @@ void ReferenceView::setBreakpointAt(int row, BPSetAction action)
if(!mCurList->getRowCount())
return;
QString addrText = mCurList->getCellContent(row, 0).toUtf8().constData();
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
duint va = 0;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &va))
return;
if(!DbgMemIsValidReadPtr(wVA))
if(!DbgMemIsValidReadPtr(va))
return;
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
BPXTYPE bpType = DbgGetBpxTypeAt(va);
QString cmd;
if((wBpType & bp_normal) == bp_normal)
if((bpType & bp_normal) == bp_normal)
{
if(action == Toggle || action == Remove)
wCmd = "bc " + ToPtrString(wVA);
cmd = "bc " + ToPtrString(va);
else if(action == Disable)
wCmd = "bpd " + ToPtrString(wVA);
cmd = "bpd " + ToPtrString(va);
else if(action == Enable)
wCmd = "bpe " + ToPtrString(wVA);
cmd = "bpe " + ToPtrString(va);
}
else if(wBpType == bp_none && (action == Toggle || action == Enable))
else if(bpType == bp_none && (action == Toggle || action == Enable))
{
wCmd = "bp " + ToPtrString(wVA);
cmd = "bp " + ToPtrString(va);
}
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
void ReferenceView::toggleBreakpoint()
@ -384,17 +384,17 @@ void ReferenceView::toggleBookmark()
if(!mCurList->getRowCount())
return;
QString addrText = mCurList->getCellContent(mCurList->getInitialSelection(), 0);
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
duint va = 0;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &va))
return;
if(!DbgMemIsValidReadPtr(wVA))
if(!DbgMemIsValidReadPtr(va))
return;
bool result;
if(DbgGetBookmarkAt(wVA))
result = DbgSetBookmarkAt(wVA, false);
if(DbgGetBookmarkAt(va))
result = DbgSetBookmarkAt(va, false);
else
result = DbgSetBookmarkAt(wVA, true);
result = DbgSetBookmarkAt(va, true);
if(!result)
SimpleErrorBox(this, tr("Error!"), tr("DbgSetBookmarkAt failed!"));
GuiUpdateAllViews();

View File

@ -26,7 +26,7 @@ public slots:
void setSingleSelection(int index, bool scroll);
void addCommand(QString title, QString command);
void referenceContextMenu(QMenu* wMenu);
void referenceContextMenu(QMenu* menu);
void followAddress();
void followDumpAddress();
void followApiAddress();

View File

@ -297,16 +297,16 @@ void SearchListView::clearFilter()
void SearchListView::listContextMenu(const QPoint & pos)
{
QMenu wMenu(this);
emit listContextMenuSignal(&wMenu);
wMenu.addSeparator();
wMenu.addAction(mSearchAction);
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy"));
mCurList->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
wMenu.addMenu(&wCopyMenu);
wMenu.exec(mCurList->mapToGlobal(pos));
QMenu menu(this);
emit listContextMenuSignal(&menu);
menu.addSeparator();
menu.addAction(mSearchAction);
QMenu copyMenu(tr("&Copy"), this);
copyMenu.setIcon(DIcon("copy"));
mCurList->setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
menu.addMenu(&copyMenu);
menu.exec(mCurList->mapToGlobal(pos));
}
void SearchListView::doubleClickedSlot()

View File

@ -32,7 +32,7 @@ private slots:
signals:
void enterPressedSignal();
void listContextMenuSignal(QMenu* wMenu);
void listContextMenuSignal(QMenu* menu);
void emptySearchResult();
protected:

View File

@ -10,8 +10,7 @@ StdTable::StdTable(QWidget* parent) : AbstractStdTable(parent)
************************************************************************************/
bool StdTable::SortBy::AsText(const QString & a, const QString & b)
{
auto i = QString::compare(a, b);
return i < 0;
return QString::compare(a, b) < 0;
}
bool StdTable::SortBy::AsInt(const QString & a, const QString & b)

View File

@ -358,11 +358,11 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
char* text = (char*)param2;
if(!text || !parVA || !DbgIsDebugging())
return 0;
byte_t wBuffer[16];
if(!DbgMemRead(parVA, wBuffer, 16))
byte_t buffer[16];
if(!DbgMemRead(parVA, buffer, 16))
return 0;
QBeaEngine disasm(int(ConfigUint("Disassembler", "MaxModuleSize")));
Instruction_t instr = disasm.DisassembleAt(wBuffer, 16, 0, parVA);
QBeaEngine disasm(int(ConfigUint("Disassembler", "MaxModuleSize")), Bridge::getArch());
Instruction_t instr = disasm.DisassembleAt(buffer, 16, 0, parVA);
QString finalInstruction;
for(const auto & curToken : instr.tokens.tokens)
finalInstruction += curToken.text;

View File

@ -331,25 +331,25 @@ Instruction_t QBeaEngine::DecodeDataAt(const byte_t* data, duint size, duint ori
_tokenizer.TokenizeData(mnemonic, datastr, cap);
Instruction_t wInst;
wInst.instStr = mnemonic + " " + datastr;
wInst.dump = QByteArray((const char*)data, len);
wInst.rva = origInstRVA;
wInst.length = len;
wInst.branchType = Instruction_t::None;
wInst.branchDestination = 0;
wInst.tokens = cap;
wInst.prefixSize = 0;
wInst.opcodeSize = len;
wInst.group1Size = 0;
wInst.group2Size = 0;
wInst.group3Size = 0;
wInst.vectorElementType[0] = Zydis::VETDefault;
wInst.vectorElementType[1] = Zydis::VETDefault;
wInst.vectorElementType[2] = Zydis::VETDefault;
wInst.vectorElementType[3] = Zydis::VETDefault;
Instruction_t inst;
inst.instStr = mnemonic + " " + datastr;
inst.dump = QByteArray((const char*)data, len);
inst.rva = origInstRVA;
inst.length = len;
inst.branchType = Instruction_t::None;
inst.branchDestination = 0;
inst.tokens = cap;
inst.prefixSize = 0;
inst.opcodeSize = len;
inst.group1Size = 0;
inst.group2Size = 0;
inst.group3Size = 0;
inst.vectorElementType[0] = Zydis::VETDefault;
inst.vectorElementType[1] = Zydis::VETDefault;
inst.vectorElementType[2] = Zydis::VETDefault;
inst.vectorElementType[3] = Zydis::VETDefault;
return wInst;
return inst;
}
void QBeaEngine::UpdateDataInstructionMap()

View File

@ -138,12 +138,12 @@ retryFindWindow:
}
}
void AttachDialog::processListContextMenu(QMenu* wMenu)
void AttachDialog::processListContextMenu(QMenu* menu)
{
// Don't show menu options if nothing is listed
if(!mSearchListView->mCurList->getRowCount())
return;
wMenu->addAction(mAttachAction);
wMenu->addAction(mRefreshAction);
menu->addAction(mAttachAction);
menu->addAction(mRefreshAction);
}

View File

@ -23,7 +23,7 @@ private slots:
void on_btnAttach_clicked();
void on_btnFindWindow_clicked();
void refresh();
void processListContextMenu(QMenu* wMenu);
void processListContextMenu(QMenu* menu);
private:
Ui::AttachDialog* ui;

View File

@ -570,10 +570,10 @@ void BreakpointsView::tokenizerConfigUpdatedSlot()
void BreakpointsView::contextMenuSlot(const QPoint & pos)
{
QMenu wMenu(this);
mMenuBuilder->build(&wMenu);
if(!wMenu.actions().isEmpty())
wMenu.exec(mapToGlobal(pos));
QMenu menu(this);
mMenuBuilder->build(&menu);
if(!menu.actions().isEmpty())
menu.exec(mapToGlobal(pos));
}
void BreakpointsView::followBreakpointSlot()

View File

@ -120,12 +120,12 @@ void CPUArgumentWidget::refreshData()
mTable->reloadData();
}
static void configAction(QMenu & wMenu, const QIcon & icon, QAction* action, const QString & value, const QString & name)
static void configAction(QMenu & menu, const QIcon & icon, QAction* action, const QString & value, const QString & name)
{
action->setText(QApplication::translate("CPUArgumentWidget", "Follow %1 in %2").arg(value).arg(name));
action->setIcon(icon);
action->setObjectName(value);
wMenu.addAction(action);
menu.addAction(action);
}
void CPUArgumentWidget::contextMenuSlot(QPoint pos)
@ -136,7 +136,7 @@ void CPUArgumentWidget::contextMenuSlot(QPoint pos)
if(int(mArgumentValues.size()) <= selection)
return;
auto value = mArgumentValues[selection];
QMenu wMenu(this);
QMenu menu(this);
if(DbgMemIsValidReadPtr(value))
{
duint valueAddr;
@ -152,27 +152,27 @@ void CPUArgumentWidget::contextMenuSlot(QPoint pos)
return addr >= base && addr < base + size;
};
configAction(wMenu, DIcon(ArchValue("processor32", "processor64")), mFollowDisasm, valueText, tr("Disassembler"));
configAction(wMenu, DIcon("dump"), mFollowDump, valueText, tr("Dump"));
configAction(menu, DIcon(ArchValue("processor32", "processor64")), mFollowDisasm, valueText, tr("Disassembler"));
configAction(menu, DIcon("dump"), mFollowDump, valueText, tr("Dump"));
if(inStackRange(value))
configAction(wMenu, DIcon("stack"), mFollowStack, valueText, tr("Stack"));
configAction(menu, DIcon("stack"), mFollowStack, valueText, tr("Stack"));
if(DbgMemIsValidReadPtr(valueAddr))
{
configAction(wMenu, DIcon(ArchValue("processor32", "processor64")), mFollowAddrDisasm, valueAddrText, tr("Disassembler"));
configAction(wMenu, DIcon("dump"), mFollowDump, valueAddrText, tr("Dump"));
configAction(menu, DIcon(ArchValue("processor32", "processor64")), mFollowAddrDisasm, valueAddrText, tr("Disassembler"));
configAction(menu, DIcon("dump"), mFollowDump, valueAddrText, tr("Dump"));
if(inStackRange(valueAddr))
configAction(wMenu, DIcon("stack"), mFollowAddrStack, valueAddrText, tr("Stack"));
configAction(menu, DIcon("stack"), mFollowAddrStack, valueAddrText, tr("Stack"));
}
}
QMenu wCopyMenu(tr("&Copy"));
wCopyMenu.setIcon(DIcon("copy"));
mTable->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
QMenu copyMenu(tr("&Copy"));
copyMenu.setIcon(DIcon("copy"));
mTable->setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
menu.addSeparator();
menu.addMenu(&copyMenu);
}
wMenu.exec(mTable->mapToGlobal(pos));
menu.exec(mTable->mapToGlobal(pos));
}
void CPUArgumentWidget::followDisasmSlot()

View File

@ -256,13 +256,13 @@ void CPUDisassembly::setupFollowReferenceMenu(dsint wVA, QMenu* menu, bool isRef
*/
void CPUDisassembly::contextMenuEvent(QContextMenuEvent* event)
{
QMenu wMenu(this);
QMenu menu(this);
if(!mHighlightContextMenu)
mMenuBuilder->build(&wMenu);
mMenuBuilder->build(&menu);
else if(mHighlightToken.text.length())
mHighlightMenuBuilder->build(&wMenu);
if(wMenu.actions().length())
wMenu.exec(event->globalPos());
mHighlightMenuBuilder->build(&menu);
if(menu.actions().length())
menu.exec(event->globalPos());
}
/************************************************************************************
@ -898,12 +898,12 @@ void CPUDisassembly::assembleSlot()
do
{
dsint wRVA = getInitialSelection();
duint wVA = rvaToVa(wRVA);
unfold(wRVA);
QString addr_text = ToPtrString(wVA);
dsint rva = getInitialSelection();
duint va = rvaToVa(rva);
unfold(rva);
QString addr_text = ToPtrString(va);
Instruction_t instr = this->DisassembleAt(wRVA);
Instruction_t instr = this->DisassembleAt(rva);
QString actual_inst = instr.instStr;

File diff suppressed because it is too large Load Diff

View File

@ -17,9 +17,9 @@ public:
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
void setupContextMenu();
void getAttention();
void contextMenuEvent(QContextMenuEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void contextMenuEvent(QContextMenuEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
signals:
void displayReferencesWidget();

View File

@ -26,7 +26,7 @@ CPUInfoBox::CPUInfoBox(QWidget* parent) : StdTable(parent)
connect(Bridge::getBridge(), SIGNAL(addInfoLine(QString)), this, SLOT(addInfoLine(QString)));
connect(this, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(contextMenuSlot(QPoint)));
connect(this, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot()));
curAddr = 0;
mCurAddr = 0;
// Deselect any row (visual reasons only)
setSingleSelection(-1);
@ -148,11 +148,11 @@ QString CPUInfoBox::formatSSEOperand(const QByteArray & data, unsigned char vect
return hex;
}
void CPUInfoBox::disasmSelectionChanged(dsint parVA)
void CPUInfoBox::disasmSelectionChanged(duint parVA)
{
curAddr = parVA;
curRva = -1;
curOffset = -1;
mCurAddr = parVA;
mCurRva = -1;
mCurOffset = -1;
if(!DbgIsDebugging() || !DbgMemIsValidReadPtr(parVA))
return;
@ -163,10 +163,10 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
setCellContent(1, 0, "");
setCellContent(2, 0, "");
Instruction_t wInst;
Instruction_t inst;
unsigned char instructiondata[MAX_DISASM_BUFFER];
DbgMemRead(parVA, &instructiondata, MAX_DISASM_BUFFER);
wInst = mDisasm->DisassembleAt(instructiondata, MAX_DISASM_BUFFER, 0, parVA);
inst = mDisasm->DisassembleAt(instructiondata, MAX_DISASM_BUFFER, 0, parVA);
DISASM_INSTR instr; //Fix me: these disasm methods are so messy
DbgDisasmAt(parVA, &instr);
BASIC_INSTRUCTION_INFO basicinfo;
@ -174,7 +174,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
int start = 0;
bool commentThis = !ConfigBool("Disassembler", "OnlyCipAutoComments") || parVA == DbgValFromString("cip");
if(wInst.branchType == Instruction_t::Conditional && commentThis) //jump
if(inst.branchType == Instruction_t::Conditional && commentThis) //jump
{
bool taken = DbgIsJumpGoingToExecute(parVA);
if(taken)
@ -262,7 +262,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
{
setInfoLine(j, sizeName + "[" + argMnemonic + "]=???");
}
else if(knownsize && wInst.vectorElementType[i] == Zydis::VETDefault) // MOVSD/MOVSS instruction
else if(knownsize && inst.vectorElementType[i] == Zydis::VETDefault) // MOVSD/MOVSS instruction
{
QString addrText = getSymbolicNameStr(arg.memvalue);
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + addrText);
@ -274,7 +274,7 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
memset(data.data(), 0, data.size());
if(DbgMemRead(arg.value, data.data(), data.size()))
{
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + formatSSEOperand(data, wInst.vectorElementType[i]));
setInfoLine(j, sizeName + "[" + argMnemonic + "]=" + formatSSEOperand(data, inst.vectorElementType[i]));
}
else
{
@ -315,72 +315,72 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
REGDUMP registers;
DbgGetRegDumpEx(&registers, sizeof(registers));
if(mnemonic == "xmm0")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[0], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[0], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm1")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[1], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[1], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm2")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[2], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[2], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm3")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[3], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[3], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm4")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[4], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[4], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm5")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[5], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[5], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm6")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[6], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[6], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm7")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[7], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[7], 16), inst.vectorElementType[i]);
#ifdef _WIN64
else if(mnemonic == "xmm8")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[8], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[8], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm9")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[9], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[9], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm10")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[10], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[10], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm11")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[11], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[11], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm12")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[12], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[12], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm13")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[13], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[13], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm14")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[14], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[14], 16), inst.vectorElementType[i]);
else if(mnemonic == "xmm15")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[15], 16), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.XmmRegisters[15], 16), inst.vectorElementType[i]);
#endif //_WIN64
else if(mnemonic == "ymm0")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[0], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[0], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm1")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[1], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[1], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm2")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[2], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[2], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm3")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[3], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[3], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm4")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[4], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[4], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm5")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[5], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[5], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm6")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[6], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[6], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm7")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[7], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[7], 32), inst.vectorElementType[i]);
#ifdef _WIN64
else if(mnemonic == "ymm8")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[8], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[8], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm9")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[9], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[9], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm10")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[10], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[10], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm11")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[11], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[11], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm12")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[12], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[12], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm13")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[13], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[13], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm14")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[14], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[14], 32), inst.vectorElementType[i]);
else if(mnemonic == "ymm15")
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[15], 32), wInst.vectorElementType[i]);
valText = formatSSEOperand(QByteArray((const char*)&registers.regcontext.YmmRegisters[15], 32), inst.vectorElementType[i]);
#endif //_WIN64
else if(mnemonic == "st0")
valText = ToLongDoubleString(&registers.x87FPURegisters[registers.x87StatusWordFields.TOP & 7]);
@ -498,13 +498,13 @@ void CPUInfoBox::disasmSelectionChanged(dsint parVA)
info += " " + QString(mod);
// Module RVA
curRva = parVA - modbase;
mCurRva = parVA - modbase;
if(modbase)
info += QString(":$%1").arg(ToHexString(curRva));
info += QString(":$%1").arg(ToHexString(mCurRva));
// File offset
curOffset = DbgFunctions()->VaToFileOffset(parVA);
info += QString(" #%1").arg(ToHexString(curOffset));
mCurOffset = DbgFunctions()->VaToFileOffset(parVA);
info += QString(" #%1").arg(ToHexString(mCurOffset));
}
// Function/label name
@ -554,13 +554,13 @@ void CPUInfoBox::modifySlot()
{
duint addrVal = 0;
DbgFunctions()->ValFromString(action->objectName().toUtf8().constData(), &addrVal);
WordEditDialog wEditDialog(this);
WordEditDialog editDialog(this);
dsint value = 0;
DbgMemRead(addrVal, &value, sizeof(dsint));
wEditDialog.setup(tr("Modify Value"), value, sizeof(dsint));
if(wEditDialog.exec() != QDialog::Accepted)
editDialog.setup(tr("Modify Value"), value, sizeof(dsint));
if(editDialog.exec() != QDialog::Accepted)
return;
value = wEditDialog.getVal();
value = editDialog.getVal();
DbgMemWrite(addrVal, &value, sizeof(dsint));
GuiUpdateAllViews();
}
@ -572,7 +572,7 @@ void CPUInfoBox::findXReferencesSlot()
return;
if(!mXrefDlg)
mXrefDlg = new XrefBrowseDialog(this);
mXrefDlg->setup(curAddr, [](duint address)
mXrefDlg->setup(mCurAddr, [](duint address)
{
DbgCmdExec(QString("disasm %1").arg(ToPtrString(address)));
});
@ -590,13 +590,13 @@ void CPUInfoBox::addModifyValueMenuItem(QMenu* menu, QString name, duint value)
connect(newAction, SIGNAL(triggered()), this, SLOT(modifySlot()));
}
void CPUInfoBox::setupModifyValueMenu(QMenu* menu, duint wVA)
void CPUInfoBox::setupModifyValueMenu(QMenu* menu, duint va)
{
menu->setIcon(DIcon("modify"));
//add follow actions
DISASM_INSTR instr;
DbgDisasmAt(wVA, &instr);
DbgDisasmAt(va, &instr);
for(int i = 0; i < instr.argcount; i++)
{
@ -650,17 +650,17 @@ void CPUInfoBox::addFollowMenuItem(QMenu* menu, QString name, duint value)
/**
* @brief CPUInfoBox::setupFollowMenu Set up a follow menu.
* @param menu The menu to create
* @param wVA The selected VA
* @param va The selected VA
*/
void CPUInfoBox::setupFollowMenu(QMenu* menu, duint wVA)
void CPUInfoBox::setupFollowMenu(QMenu* menu, duint va)
{
menu->setIcon(DIcon("dump"));
//most basic follow action
addFollowMenuItem(menu, tr("&Selected Address"), wVA);
addFollowMenuItem(menu, tr("&Selected Address"), va);
//add follow actions
DISASM_INSTR instr;
DbgDisasmAt(wVA, &instr);
DbgDisasmAt(va, &instr);
for(int i = 0; i < instr.argcount; i++)
{
@ -714,17 +714,17 @@ void CPUInfoBox::addWatchMenuItem(QMenu* menu, QString name, duint value)
/**
* @brief CPUInfoBox::setupFollowMenu Set up a follow menu.
* @param menu The menu to create
* @param wVA The selected VA
* @param va The selected VA
*/
void CPUInfoBox::setupWatchMenu(QMenu* menu, duint wVA)
void CPUInfoBox::setupWatchMenu(QMenu* menu, duint va)
{
menu->setIcon(DIcon("animal-dog"));
//most basic follow action
addWatchMenuItem(menu, tr("&Selected Address"), wVA);
addWatchMenuItem(menu, tr("&Selected Address"), va);
//add follow actions
DISASM_INSTR instr;
DbgDisasmAt(wVA, &instr);
DbgDisasmAt(va, &instr);
for(int i = 0; i < instr.argcount; i++)
{
@ -758,7 +758,7 @@ void CPUInfoBox::setupWatchMenu(QMenu* menu, duint wVA)
}
}
int CPUInfoBox::followInDump(dsint wVA)
int CPUInfoBox::followInDump(duint va)
{
// Copy pasta from setupFollowMenu for now
int tableOffset = getInitialSelection();
@ -771,12 +771,12 @@ int CPUInfoBox::followInDump(dsint wVA)
// Last line of infoBox => Current Address(EIP) in disassembly
if(tableOffset == 2)
{
DbgCmdExec(QString("dump %1").arg(ToPtrString(wVA)));
DbgCmdExec(QString("dump %1").arg(ToPtrString(va)));
return 0;
}
DISASM_INSTR instr;
DbgDisasmAt(wVA, &instr);
DbgDisasmAt(va, &instr);
if(instr.type == instr_branch && cellContent.contains("Jump"))
{
@ -805,55 +805,55 @@ int CPUInfoBox::followInDump(dsint wVA)
void CPUInfoBox::contextMenuSlot(QPoint pos)
{
QMenu wMenu(this); //create context menu
QMenu wFollowMenu(tr("&Follow in Dump"), this);
setupFollowMenu(&wFollowMenu, curAddr);
wMenu.addMenu(&wFollowMenu);
QMenu wModifyValueMenu(tr("&Modify Value"), this);
setupModifyValueMenu(&wModifyValueMenu, curAddr);
if(!wModifyValueMenu.isEmpty())
wMenu.addMenu(&wModifyValueMenu);
QMenu wWatchMenu(tr("&Watch"), this);
setupWatchMenu(&wWatchMenu, curAddr);
wMenu.addMenu(&wWatchMenu);
QMenu menu(this); //create context menu
QMenu followMenu(tr("&Follow in Dump"), this);
setupFollowMenu(&followMenu, mCurAddr);
menu.addMenu(&followMenu);
QMenu modifyValueMenu(tr("&Modify Value"), this);
setupModifyValueMenu(&modifyValueMenu, mCurAddr);
if(!modifyValueMenu.isEmpty())
menu.addMenu(&modifyValueMenu);
QMenu watchMenu(tr("&Watch"), this);
setupWatchMenu(&watchMenu, mCurAddr);
menu.addMenu(&watchMenu);
if(!getInfoLine(2).isEmpty())
wMenu.addAction(makeAction(DIcon("xrefs"), tr("&Show References"), SLOT(findXReferencesSlot())));
QMenu wCopyMenu(tr("&Copy"), this);
setupCopyMenu(&wCopyMenu);
menu.addAction(makeAction(DIcon("xrefs"), tr("&Show References"), SLOT(findXReferencesSlot())));
QMenu copyMenu(tr("&Copy"), this);
setupCopyMenu(&copyMenu);
if(DbgIsDebugging())
{
wCopyMenu.addAction(mCopyAddressAction);
if(curRva != -1)
wCopyMenu.addAction(mCopyRvaAction);
if(curOffset != -1)
wCopyMenu.addAction(mCopyOffsetAction);
copyMenu.addAction(mCopyAddressAction);
if(mCurRva != -1)
copyMenu.addAction(mCopyRvaAction);
if(mCurOffset != -1)
copyMenu.addAction(mCopyOffsetAction);
}
if(wCopyMenu.actions().length())
if(copyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
menu.addSeparator();
menu.addMenu(&copyMenu);
}
wMenu.exec(mapToGlobal(pos)); //execute context menu
menu.exec(mapToGlobal(pos)); //execute context menu
}
void CPUInfoBox::copyAddress()
{
Bridge::CopyToClipboard(ToPtrString(curAddr));
Bridge::CopyToClipboard(ToPtrString(mCurAddr));
}
void CPUInfoBox::copyRva()
{
Bridge::CopyToClipboard(ToHexString(curRva));
Bridge::CopyToClipboard(ToHexString(mCurRva));
}
void CPUInfoBox::copyOffset()
{
Bridge::CopyToClipboard(ToHexString(curOffset));
Bridge::CopyToClipboard(ToHexString(mCurOffset));
}
void CPUInfoBox::doubleClickedSlot()
{
followInDump(curAddr);
followInDump(mCurAddr);
}
void CPUInfoBox::setupShortcuts()

View File

@ -14,17 +14,17 @@ public:
~CPUInfoBox();
int getHeight();
void addFollowMenuItem(QMenu* menu, QString name, duint value);
void setupFollowMenu(QMenu* menu, duint wVA);
void setupFollowMenu(QMenu* menu, duint va);
void addModifyValueMenuItem(QMenu* menu, QString name, duint value);
void setupModifyValueMenu(QMenu* menu, duint wVA);
void setupModifyValueMenu(QMenu* menu, duint va);
void addWatchMenuItem(QMenu* menu, QString name, duint value);
void setupWatchMenu(QMenu* menu, duint wVA);
int followInDump(dsint wVA);
void setupWatchMenu(QMenu* menu, duint va);
int followInDump(duint va);
static QString formatSSEOperand(const QByteArray & data, unsigned char vectorType);
public slots:
void disasmSelectionChanged(dsint parVA);
void disasmSelectionChanged(duint parVA);
void dbgStateChanged(DBGSTATE state);
void contextMenuSlot(QPoint pos);
void followActionSlot();
@ -37,9 +37,9 @@ public slots:
void addInfoLine(const QString & infoLine);
private:
dsint curAddr;
dsint curRva;
dsint curOffset;
duint mCurAddr = 0;
duint mCurRva = 0;
duint mCurOffset = 0;
void setInfoLine(int line, QString text);
QString getInfoLine(int line);
void clear();

View File

@ -252,17 +252,17 @@ void CPURegistersView::displayEditDialog()
updateRegistersSlot();
}
else if(mFPUYMM.contains(mSelected))
editSIMDRegister(this, 256, tr("Edit YMM register"), registerValue(&wRegDumpStruct, mSelected), mSelected);
editSIMDRegister(this, 256, tr("Edit YMM register"), registerValue(&mRegDumpStruct, mSelected), mSelected);
else if(mFPUXMM.contains(mSelected))
editSIMDRegister(this, 128, tr("Edit XMM register"), registerValue(&wRegDumpStruct, mSelected), mSelected);
editSIMDRegister(this, 128, tr("Edit XMM register"), registerValue(&mRegDumpStruct, mSelected), mSelected);
else if(mFPUMMX.contains(mSelected))
editSIMDRegister(this, 64, tr("Edit MMX register"), registerValue(&wRegDumpStruct, mSelected), mSelected);
editSIMDRegister(this, 64, tr("Edit MMX register"), registerValue(&mRegDumpStruct, mSelected), mSelected);
else
{
bool errorinput = false;
LineEditDialog mLineEdit(this);
mLineEdit.setText(GetRegStringValueFromValue(mSelected, registerValue(&wRegDumpStruct, mSelected)));
mLineEdit.setText(GetRegStringValueFromValue(mSelected, registerValue(&mRegDumpStruct, mSelected)));
mLineEdit.setWindowTitle(tr("Edit FPU register"));
mLineEdit.setWindowIcon(DIcon("log"));
mLineEdit.setCursorPosition(0);
@ -357,7 +357,7 @@ void CPURegistersView::displayEditDialog()
{
bool errorinput = false;
LineEditDialog mLineEdit(this);
LASTERROR* error = (LASTERROR*)registerValue(&wRegDumpStruct, LastError);
LASTERROR* error = (LASTERROR*)registerValue(&mRegDumpStruct, LastError);
mLineEdit.setText(QString::number(error->code, 16));
mLineEdit.setWindowTitle(tr("Set Last Error"));
mLineEdit.setCursorPosition(0);
@ -378,7 +378,7 @@ void CPURegistersView::displayEditDialog()
{
bool statusinput = false;
LineEditDialog mLineEdit(this);
LASTSTATUS* status = (LASTSTATUS*)registerValue(&wRegDumpStruct, LastStatus);
LASTSTATUS* status = (LASTSTATUS*)registerValue(&mRegDumpStruct, LastStatus);
mLineEdit.setText(QString::number(status->code, 16));
mLineEdit.setWindowTitle(tr("Set Last Status"));
mLineEdit.setCursorPosition(0);
@ -397,10 +397,10 @@ void CPURegistersView::displayEditDialog()
}
else
{
WordEditDialog wEditDial(this);
wEditDial.setup(tr("Edit"), (* ((duint*) registerValue(&wRegDumpStruct, mSelected))), sizeof(dsint));
if(wEditDial.exec() == QDialog::Accepted) //OK button clicked
setRegister(mSelected, wEditDial.getVal());
WordEditDialog editDialog(this);
editDialog.setup(tr("Edit"), (* ((duint*) registerValue(&mRegDumpStruct, mSelected))), sizeof(dsint));
if(editDialog.exec() == QDialog::Accepted) //OK button clicked
setRegister(mSelected, editDialog.getVal());
}
}
@ -423,13 +423,13 @@ void CPURegistersView::CreateDumpNMenu(QMenu* dumpMenu)
void CPURegistersView::onIncrementx87StackAction()
{
if(mFPUx87_80BITSDISPLAY.contains(mSelected))
setRegister(x87SW_TOP, ((* ((duint*) registerValue(&wRegDumpStruct, x87SW_TOP))) + 1) % 8);
setRegister(x87SW_TOP, ((* ((duint*) registerValue(&mRegDumpStruct, x87SW_TOP))) + 1) % 8);
}
void CPURegistersView::onDecrementx87StackAction()
{
if(mFPUx87_80BITSDISPLAY.contains(mSelected))
setRegister(x87SW_TOP, ((* ((duint*) registerValue(&wRegDumpStruct, x87SW_TOP))) - 1) % 8);
setRegister(x87SW_TOP, ((* ((duint*) registerValue(&mRegDumpStruct, x87SW_TOP))) - 1) % 8);
}
void CPURegistersView::onModifyAction()
@ -442,7 +442,7 @@ void CPURegistersView::onIncrementAction()
{
if(mINCREMENTDECREMET.contains(mSelected))
{
duint value = *((duint*) registerValue(&wRegDumpStruct, mSelected));
duint value = *((duint*) registerValue(&mRegDumpStruct, mSelected));
setRegister(mSelected, value + 1);
}
}
@ -451,7 +451,7 @@ void CPURegistersView::onDecrementAction()
{
if(mINCREMENTDECREMET.contains(mSelected))
{
duint value = *((duint*) registerValue(&wRegDumpStruct, mSelected));
duint value = *((duint*) registerValue(&mRegDumpStruct, mSelected));
setRegister(mSelected, value - 1);
}
}
@ -466,7 +466,7 @@ void CPURegistersView::onToggleValueAction()
{
if(mBOOLDISPLAY.contains(mSelected))
{
int value = (int)(* (bool*) registerValue(&wRegDumpStruct, mSelected));
int value = (int)(* (bool*) registerValue(&mRegDumpStruct, mSelected));
setRegister(mSelected, value ^ 1);
}
}
@ -476,9 +476,9 @@ void CPURegistersView::onUndoAction()
if(mUNDODISPLAY.contains(mSelected))
{
if(mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected) || mFPUx87_80BITSDISPLAY.contains(mSelected))
setRegister(mSelected, (duint)registerValue(&wCipRegDumpStruct, mSelected));
setRegister(mSelected, (duint)registerValue(&mCipRegDumpStruct, mSelected));
else
setRegister(mSelected, *(duint*)registerValue(&wCipRegDumpStruct, mSelected));
setRegister(mSelected, *(duint*)registerValue(&mCipRegDumpStruct, mSelected));
}
}
@ -507,8 +507,8 @@ void CPURegistersView::onFollowInDisassembly()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&mRegDumpStruct, mSelected)))))
DbgCmdExec(QString().sprintf("disasm \"%s\"", addr.toUtf8().constData()));
}
}
@ -517,8 +517,8 @@ void CPURegistersView::onFollowInDump()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&mRegDumpStruct, mSelected)))))
DbgCmdExec(QString().sprintf("dump \"%s\"", addr.toUtf8().constData()));
}
}
@ -527,8 +527,8 @@ void CPURegistersView::onFollowInDumpN()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&mRegDumpStruct, mSelected)))))
{
QAction* action = qobject_cast<QAction*>(sender());
int numDump = action->data().toInt();
@ -541,8 +541,8 @@ void CPURegistersView::onFollowInStack()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&mRegDumpStruct, mSelected)))))
DbgCmdExec(QString().sprintf("sdump \"%s\"", addr.toUtf8().constData()));
}
}
@ -551,8 +551,8 @@ void CPURegistersView::onFollowInMemoryMap()
{
if(mCANSTOREADDRESS.contains(mSelected))
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&wRegDumpStruct, mSelected)))))
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
if(DbgMemIsValidReadPtr((* ((duint*) registerValue(&mRegDumpStruct, mSelected)))))
DbgCmdExec(QString().sprintf("memmapdump \"%s\"", addr.toUtf8().constData()));
}
}
@ -561,7 +561,7 @@ void CPURegistersView::onRemoveHardware()
{
if(mSelected == DR0 || mSelected == DR1 || mSelected == DR2 || mSelected == DR3)
{
QString addr = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
QString addr = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, mSelected))), mRegisterPlaces[mSelected].valuesize, 16, QChar('0')).toUpper();
DbgCmdExec(QString().sprintf("bphc \"%s\"", addr.toUtf8().constData()));
}
}
@ -570,7 +570,7 @@ void CPURegistersView::displayCustomContextMenuSlot(QPoint pos)
{
if(!isActive)
return;
QMenu wMenu(this);
QMenu menu(this);
QMenu* followInDumpNMenu = nullptr;
setupSIMDModeMenu();
@ -578,111 +578,111 @@ void CPURegistersView::displayCustomContextMenuSlot(QPoint pos)
{
if(mMODIFYDISPLAY.contains(mSelected))
{
wMenu.addAction(wCM_Modify);
menu.addAction(wCM_Modify);
}
if(mINCREMENTDECREMET.contains(mSelected))
{
wMenu.addAction(wCM_Increment);
wMenu.addAction(wCM_Decrement);
wMenu.addAction(wCM_Zero);
menu.addAction(wCM_Increment);
menu.addAction(wCM_Decrement);
menu.addAction(wCM_Zero);
}
if(mCANSTOREADDRESS.contains(mSelected))
{
duint addr = (* ((duint*) registerValue(&wRegDumpStruct, mSelected)));
duint addr = (* ((duint*) registerValue(&mRegDumpStruct, mSelected)));
if(DbgMemIsValidReadPtr(addr))
{
wMenu.addAction(wCM_FollowInDump);
followInDumpNMenu = new QMenu(tr("Follow in &Dump"), &wMenu);
menu.addAction(wCM_FollowInDump);
followInDumpNMenu = new QMenu(tr("Follow in &Dump"), &menu);
CreateDumpNMenu(followInDumpNMenu);
wMenu.addMenu(followInDumpNMenu);
wMenu.addAction(wCM_FollowInDisassembly);
wMenu.addAction(wCM_FollowInMemoryMap);
menu.addMenu(followInDumpNMenu);
menu.addAction(wCM_FollowInDisassembly);
menu.addAction(wCM_FollowInMemoryMap);
duint size = 0;
duint base = DbgMemFindBaseAddr(DbgValFromString("csp"), &size);
if(addr >= base && addr < base + size)
wMenu.addAction(wCM_FollowInStack);
menu.addAction(wCM_FollowInStack);
}
}
if(mSelected == DR0 || mSelected == DR1 || mSelected == DR2 || mSelected == DR3)
{
if(* ((duint*) registerValue(&wRegDumpStruct, mSelected)) != 0)
wMenu.addAction(wCM_RemoveHardware);
if(* ((duint*) registerValue(&mRegDumpStruct, mSelected)) != 0)
menu.addAction(wCM_RemoveHardware);
}
wMenu.addAction(wCM_CopyToClipboard);
menu.addAction(wCM_CopyToClipboard);
if(mFPUx87_80BITSDISPLAY.contains(mSelected))
{
wMenu.addAction(wCM_CopyFloatingPointValueToClipboard);
menu.addAction(wCM_CopyFloatingPointValueToClipboard);
}
if(mLABELDISPLAY.contains(mSelected))
{
QString symbol = getRegisterLabel(mSelected);
if(symbol != "")
wMenu.addAction(wCM_CopySymbolToClipboard);
menu.addAction(wCM_CopySymbolToClipboard);
}
wMenu.addAction(wCM_CopyAll);
menu.addAction(wCM_CopyAll);
if((mGPR.contains(mSelected) && mSelected != REGISTER_NAME::EFLAGS) || mSEGMENTREGISTER.contains(mSelected) || mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected))
{
wMenu.addAction(wCM_Highlight);
menu.addAction(wCM_Highlight);
}
if(mUNDODISPLAY.contains(mSelected) && CompareRegisters(mSelected, &wRegDumpStruct, &wCipRegDumpStruct) != 0)
if(mUNDODISPLAY.contains(mSelected) && CompareRegisters(mSelected, &mRegDumpStruct, &mCipRegDumpStruct) != 0)
{
wMenu.addAction(wCM_Undo);
wCM_CopyPrevious->setData(GetRegStringValueFromValue(mSelected, registerValue(&wCipRegDumpStruct, mSelected)));
menu.addAction(wCM_Undo);
wCM_CopyPrevious->setData(GetRegStringValueFromValue(mSelected, registerValue(&mCipRegDumpStruct, mSelected)));
wCM_CopyPrevious->setText(tr("Copy old value: %1").arg(wCM_CopyPrevious->data().toString()));
wMenu.addAction(wCM_CopyPrevious);
menu.addAction(wCM_CopyPrevious);
}
if(mBOOLDISPLAY.contains(mSelected))
{
wMenu.addAction(wCM_ToggleValue);
menu.addAction(wCM_ToggleValue);
}
if(mFPUx87_80BITSDISPLAY.contains(mSelected))
{
wMenu.addAction(wCM_Incrementx87Stack);
wMenu.addAction(wCM_Decrementx87Stack);
menu.addAction(wCM_Incrementx87Stack);
menu.addAction(wCM_Decrementx87Stack);
}
if(mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected))
{
wMenu.addMenu(mSwitchSIMDDispMode);
menu.addMenu(mSwitchSIMDDispMode);
}
if(mFPUMMX.contains(mSelected) || mFPUx87_80BITSDISPLAY.contains(mSelected))
{
if(mFpuMode != 0)
wMenu.addAction(mDisplaySTX);
menu.addAction(mDisplaySTX);
if(mFpuMode != 1)
wMenu.addAction(mDisplayx87rX);
menu.addAction(mDisplayx87rX);
if(mFpuMode != 2)
wMenu.addAction(mDisplayMMX);
menu.addAction(mDisplayMMX);
}
wMenu.exec(this->mapToGlobal(pos));
menu.exec(this->mapToGlobal(pos));
}
else
{
wMenu.addSeparator();
wMenu.addAction(wCM_ChangeFPUView);
wMenu.addAction(wCM_CopyAll);
wMenu.addMenu(mSwitchSIMDDispMode);
menu.addSeparator();
menu.addAction(wCM_ChangeFPUView);
menu.addAction(wCM_CopyAll);
menu.addMenu(mSwitchSIMDDispMode);
if(mFpuMode != 0)
wMenu.addAction(mDisplaySTX);
menu.addAction(mDisplaySTX);
if(mFpuMode != 1)
wMenu.addAction(mDisplayx87rX);
menu.addAction(mDisplayx87rX);
if(mFpuMode != 2)
wMenu.addAction(mDisplayMMX);
wMenu.addSeparator();
QAction* wHwbpCsp = wMenu.addAction(DIcon("breakpoint"), tr("Set Hardware Breakpoint on %1").arg(ArchValue("ESP", "RSP")));
QAction* wAction = wMenu.exec(this->mapToGlobal(pos));
menu.addAction(mDisplayMMX);
menu.addSeparator();
QAction* hwbpCsp = menu.addAction(DIcon("breakpoint"), tr("Set Hardware Breakpoint on %1").arg(ArchValue("ESP", "RSP")));
QAction* action = menu.exec(this->mapToGlobal(pos));
if(wAction == wHwbpCsp)
if(action == hwbpCsp)
DbgCmdExec("bphws csp,rw");
}
}
@ -693,31 +693,31 @@ void CPURegistersView::setRegister(REGISTER_NAME reg, duint value)
if(mRegisterMapping.contains(reg))
{
// map x87st0 to x87r0
QString wRegName;
QString regName;
if(reg >= x87st0 && reg <= x87st7)
wRegName = QString().sprintf("st%d", reg - x87st0);
regName = QString().sprintf("st%d", reg - x87st0);
else
// map "cax" to "eax" or "rax"
wRegName = mRegisterMapping.constFind(reg).value();
regName = mRegisterMapping.constFind(reg).value();
// flags need to '_' infront
if(mFlags.contains(reg))
wRegName = "_" + wRegName;
regName = "_" + regName;
// we change the value (so highlight it)
mRegisterUpdates.insert(reg);
// tell everything the compiler
if(mFPU.contains(reg))
wRegName = "_" + wRegName;
regName = "_" + regName;
DbgValToString(wRegName.toUtf8().constData(), value);
DbgValToString(regName.toUtf8().constData(), value);
// force repaint
emit refresh();
}
}
void CPURegistersView::disasmSelectionChangedSlot(dsint va)
void CPURegistersView::disasmSelectionChangedSlot(duint va)
{
mHighlightRegs = mParent->getDisasmWidget()->DisassembleAt(va - mParent->getDisasmWidget()->getBase()).regsReferenced;
emit refresh();

View File

@ -5,24 +5,17 @@
#include "CachedFontMetrics.h"
#include <QToolTip>
CPUSideBar::CPUSideBar(CPUDisassembly* Ptr, QWidget* parent) : QAbstractScrollArea(parent)
CPUSideBar::CPUSideBar(CPUDisassembly* disassembly, QWidget* parent)
: QAbstractScrollArea(parent)
{
setWindowTitle("SideBar");
topVA = -1;
selectedVA = -1;
viewableRows = 0;
mFontMetrics = nullptr;
mDisas = Ptr;
mInstrBuffer = mDisas->instructionsBuffer();
memset(&regDump, 0, sizeof(REGDUMP));
mDisassembly = disassembly;
mInstrBuffer = mDisassembly->instructionsBuffer();
updateSlots();
this->setMouseTracking(true);
setMouseTracking(true);
}
CPUSideBar::~CPUSideBar()
@ -73,21 +66,21 @@ void CPUSideBar::updateColors()
void CPUSideBar::updateFonts()
{
mDefaultFont = mDisas->font();
this->setFont(mDefaultFont);
mDefaultFont = mDisassembly->font();
setFont(mDefaultFont);
delete mFontMetrics;
mFontMetrics = new CachedFontMetrics(this, mDefaultFont);
fontWidth = mFontMetrics->width(' ');
fontHeight = mFontMetrics->height();
mFontWidth = mFontMetrics->width(' ');
mFontHeight = mFontMetrics->height();
mBulletYOffset = 2;
mBulletRadius = fontHeight - 2 * mBulletYOffset;
mBulletRadius = mFontHeight - 2 * mBulletYOffset;
}
QSize CPUSideBar::sizeHint() const
{
return QSize(40, this->viewport()->height());
return QSize(40, viewport()->height());
}
void CPUSideBar::debugStateChangedSlot(DBGSTATE state)
@ -100,27 +93,27 @@ void CPUSideBar::debugStateChangedSlot(DBGSTATE state)
void CPUSideBar::reload()
{
fontHeight = mDisas->getRowHeight();
mFontHeight = mDisassembly->getRowHeight();
viewport()->update();
}
void CPUSideBar::changeTopmostAddress(dsint i)
void CPUSideBar::changeTopmostAddress(duint i)
{
topVA = i;
DbgGetRegDumpEx(&regDump, sizeof(REGDUMP));
mTopVA = i;
DbgGetRegDumpEx(&mRegDump, sizeof(REGDUMP));
reload();
}
void CPUSideBar::setViewableRows(int rows)
void CPUSideBar::setViewableRows(duint rows)
{
viewableRows = rows;
mViewableRows = rows;
}
void CPUSideBar::setSelection(dsint selVA)
void CPUSideBar::setSelection(duint selVA)
{
if(selVA != selectedVA)
if(selVA != mSelectedVA)
{
selectedVA = selVA;
mSelectedVA = selVA;
reload();
}
}
@ -134,8 +127,8 @@ bool CPUSideBar::isJump(int i) const
Instruction_t::BranchType branchType = instr.branchType;
if(branchType == Instruction_t::Unconditional || branchType == Instruction_t::Conditional)
{
duint start = mDisas->getBase();
duint end = start + mDisas->getSize();
duint start = mDisassembly->getBase();
duint end = start + mDisassembly->getSize();
duint addr = DbgGetBranchDestination(start + instr.rva);
if(!addr)
@ -151,7 +144,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
{
Q_UNUSED(event);
QPainter painter(this->viewport());
QPainter painter(viewport());
// Paints background
painter.fillRect(painter.viewport(), mBackgroundColor);
@ -160,16 +153,16 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
if(mInstrBuffer->size() == 0)
return;
if(mCodeFoldingManager.isFolded(regDump.regcontext.cip))
if(mCodeFoldingManager.isFolded(mRegDump.regcontext.cip))
{
mCodeFoldingManager.expandFoldSegment(regDump.regcontext.cip);
mDisas->reloadData();
mCodeFoldingManager.expandFoldSegment(mRegDump.regcontext.cip);
mDisassembly->reloadData();
}
int jumpoffset = 0;
duint last_va = mInstrBuffer->last().rva + mDisas->getBase();
duint first_va = mInstrBuffer->first().rva + mDisas->getBase();
duint last_va = mInstrBuffer->last().rva + mDisassembly->getBase();
duint first_va = mInstrBuffer->first().rva + mDisassembly->getBase();
QVector<std::pair<QString, duint>> regLabel;
auto appendReg = [&regLabel, last_va, first_va](const QString & name, duint value)
@ -178,33 +171,33 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
regLabel.append(std::make_pair(name, value));
};
#ifdef _WIN64
appendReg("RIP", regDump.regcontext.cip);
appendReg("RAX", regDump.regcontext.cax);
appendReg("RCX", regDump.regcontext.ccx);
appendReg("RDX", regDump.regcontext.cdx);
appendReg("RBX", regDump.regcontext.cbx);
appendReg("RSP", regDump.regcontext.csp);
appendReg("RBP", regDump.regcontext.cbp);
appendReg("RSI", regDump.regcontext.csi);
appendReg("RDI", regDump.regcontext.cdi);
appendReg("R8", regDump.regcontext.r8);
appendReg("R9", regDump.regcontext.r9);
appendReg("R10", regDump.regcontext.r10);
appendReg("R11", regDump.regcontext.r11);
appendReg("R12", regDump.regcontext.r12);
appendReg("R13", regDump.regcontext.r13);
appendReg("R14", regDump.regcontext.r14);
appendReg("R15", regDump.regcontext.r15);
appendReg("RIP", mRegDump.regcontext.cip);
appendReg("RAX", mRegDump.regcontext.cax);
appendReg("RCX", mRegDump.regcontext.ccx);
appendReg("RDX", mRegDump.regcontext.cdx);
appendReg("RBX", mRegDump.regcontext.cbx);
appendReg("RSP", mRegDump.regcontext.csp);
appendReg("RBP", mRegDump.regcontext.cbp);
appendReg("RSI", mRegDump.regcontext.csi);
appendReg("RDI", mRegDump.regcontext.cdi);
appendReg("R8", mRegDump.regcontext.r8);
appendReg("R9", mRegDump.regcontext.r9);
appendReg("R10", mRegDump.regcontext.r10);
appendReg("R11", mRegDump.regcontext.r11);
appendReg("R12", mRegDump.regcontext.r12);
appendReg("R13", mRegDump.regcontext.r13);
appendReg("R14", mRegDump.regcontext.r14);
appendReg("R15", mRegDump.regcontext.r15);
#else //x86
appendReg("EIP", regDump.regcontext.cip);
appendReg("EAX", regDump.regcontext.cax);
appendReg("ECX", regDump.regcontext.ccx);
appendReg("EDX", regDump.regcontext.cdx);
appendReg("EBX", regDump.regcontext.cbx);
appendReg("ESP", regDump.regcontext.csp);
appendReg("EBP", regDump.regcontext.cbp);
appendReg("ESI", regDump.regcontext.csi);
appendReg("EDI", regDump.regcontext.cdi);
appendReg("EIP", mRegDump.regcontext.cip);
appendReg("EAX", mRegDump.regcontext.cax);
appendReg("ECX", mRegDump.regcontext.ccx);
appendReg("EDX", mRegDump.regcontext.cdx);
appendReg("EBX", mRegDump.regcontext.cbx);
appendReg("ESP", mRegDump.regcontext.csp);
appendReg("EBP", mRegDump.regcontext.cbp);
appendReg("ESI", mRegDump.regcontext.csi);
appendReg("EDI", mRegDump.regcontext.cdi);
#endif //_WIN64
if(ConfigBool("Gui", "SidebarWatchLabels"))
{
@ -222,13 +215,13 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
std::vector<JumpLine> jumpLines;
std::vector<LabelArrow> labelArrows;
for(int line = 0; line < viewableRows; line++)
for(int line = 0; line < mViewableRows; line++)
{
if(line >= mInstrBuffer->size()) //at the end of the page it will crash otherwise
break;
const Instruction_t & instr = mInstrBuffer->at(line);
duint instrVA = instr.rva + mDisas->getBase();
duint instrVA = instr.rva + mDisassembly->getBase();
duint instrVAEnd = instrVA + instr.length;
// draw bullet
@ -236,12 +229,12 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
if(isJump(line)) //handle jumps
{
duint baseAddr = mDisas->getBase();
duint baseAddr = mDisassembly->getBase();
duint destVA = DbgGetBranchDestination(baseAddr + instr.rva);
JumpLine jmp;
jmp.isJumpGoingToExecute = DbgIsJumpGoingToExecute(instrVA);
jmp.isSelected = (selectedVA == instrVA || selectedVA == destVA);
jmp.isSelected = (mSelectedVA == instrVA || mSelectedVA == destVA);
jmp.isConditional = instr.branchType == Instruction_t::Conditional;
jmp.line = line;
@ -253,7 +246,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
jumpoffset++;
// Do not draw jumps that leave the memory range
if(destVA >= mDisas->getBase() + mDisas->getSize() || destVA < mDisas->getBase())
if(destVA >= mDisassembly->getBase() + mDisassembly->getSize() || destVA < mDisassembly->getBase())
continue;
if(destVA <= last_va && destVA >= first_va)
@ -261,7 +254,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
int destLine = line;
while(destLine > -1 && destLine < mInstrBuffer->size())
{
duint va = mInstrBuffer->at(destLine).rva + mDisas->getBase();
duint va = mInstrBuffer->at(destLine).rva + mDisassembly->getBase();
if(destVA > instrVA) //jump goes down
{
duint vaEnd = va + mInstrBuffer->at(destLine).length - 1;
@ -279,7 +272,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
jmp.destLine = destLine;
}
else if(destVA > last_va)
jmp.destLine = viewableRows + 6;
jmp.destLine = mViewableRows + 6;
else if(destVA < first_va)
jmp.destLine = -6;
jumpLines.emplace_back(jmp);
@ -300,16 +293,16 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
if(isFoldingGraphicsPresent(line) == 1)
{
if(mCodeFoldingManager.isFoldStart(instrVA))
drawFoldingCheckbox(&painter, line * fontHeight, mCodeFoldingManager.isFolded(instrVA));
drawFoldingCheckbox(&painter, line * mFontHeight, mCodeFoldingManager.isFolded(instrVA));
else
drawFoldingCheckbox(&painter, line * fontHeight, false);
drawFoldingCheckbox(&painter, line * mFontHeight, false);
}
else if(mCodeFoldingManager.isFoldBody(instrVA))
{
painter.setPen(QColor(Qt::black));
painter.drawLine(QPointF(viewport()->width() - fontHeight / 2 - mBulletXOffset - mBulletRadius, line * fontHeight), QPointF(viewport()->width() - fontHeight / 2 - mBulletXOffset - mBulletRadius, (line + 1) * fontHeight));
painter.drawLine(QPointF(viewport()->width() - mFontHeight / 2 - mBulletXOffset - mBulletRadius, line * mFontHeight), QPointF(viewport()->width() - mFontHeight / 2 - mBulletXOffset - mBulletRadius, (line + 1) * mFontHeight));
if(mCodeFoldingManager.isFoldEnd(instrVA + instr.length - 1))
painter.drawLine(QPointF(viewport()->width() - fontHeight / 2 - mBulletXOffset - mBulletRadius, (line + 1) * fontHeight), QPointF(viewport()->width(), (line + 1) * fontHeight));
painter.drawLine(QPointF(viewport()->width() - mFontHeight / 2 - mBulletXOffset - mBulletRadius, (line + 1) * mFontHeight), QPointF(viewport()->width(), (line + 1) * mFontHeight));
}
}
if(jumpLines.size())
@ -321,7 +314,7 @@ void CPUSideBar::paintEvent(QPaintEvent* event)
else
{
for(auto i = labelArrows.begin(); i != labelArrows.end(); i++)
i->endX = viewport()->width() - 1 - 11 - (isFoldingGraphicsPresent(i->line) != 0 ? mBulletRadius + fontHeight : 0);
i->endX = viewport()->width() - 1 - 11 - (isFoldingGraphicsPresent(i->line) != 0 ? mBulletRadius + mFontHeight : 0);
}
drawLabelArrows(&painter, labelArrows);
}
@ -335,12 +328,12 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
// get clicked line
const int x = e->pos().x();
const int y = e->pos().y();
const int line = y / fontHeight;
const int line = y / mFontHeight;
if(line >= mInstrBuffer->size())
return;
const int width = viewport()->width();
const int bulletRadius = fontHeight / 2 + 1; //14/2=7
const int bulletRadius = mFontHeight / 2 + 1; //14/2=7
const int bulletX = width - mBulletXOffset;
//const int bulletY = line * fontHeight + mBulletYOffset;
@ -349,30 +342,30 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
if(x > bulletX + bulletRadius)
return;
// calculate virtual address of clicked line
duint wVA = mInstrBuffer->at(line).rva + mDisas->getBase();
duint va = mInstrBuffer->at(line).rva + mDisassembly->getBase();
if(CheckBoxPresent)
{
if(x > width - fontHeight - mBulletXOffset - mBulletRadius && x < width - mBulletXOffset - mBulletRadius)
if(x > width - mFontHeight - mBulletXOffset - mBulletRadius && x < width - mBulletXOffset - mBulletRadius)
{
if(e->button() == Qt::LeftButton)
{
duint start, end;
const Instruction_t* instr = &mInstrBuffer->at(line);
const dsint SelectionStart = mDisas->getSelectionStart();
const dsint SelectionEnd = mDisas->getSelectionEnd();
if(mCodeFoldingManager.isFoldStart(wVA))
const dsint SelectionStart = mDisassembly->getSelectionStart();
const dsint SelectionEnd = mDisassembly->getSelectionEnd();
if(mCodeFoldingManager.isFoldStart(va))
{
mCodeFoldingManager.setFolded(wVA, !mCodeFoldingManager.isFolded(wVA));
mCodeFoldingManager.setFolded(va, !mCodeFoldingManager.isFolded(va));
}
else if(instr->rva == SelectionStart && (SelectionEnd - SelectionStart + 1) != instr->length)
{
bool success = mCodeFoldingManager.addFoldSegment(wVA, mDisas->getSelectionEnd() - mDisas->getSelectionStart());
bool success = mCodeFoldingManager.addFoldSegment(va, mDisassembly->getSelectionEnd() - mDisassembly->getSelectionStart());
if(!success)
GuiAddLogMessage(tr("Cannot fold selection.\n").toUtf8().constData());
}
else if((DbgArgumentGet(wVA, &start, &end) || DbgFunctionGet(wVA, &start, &end)) && wVA == start)
else if((DbgArgumentGet(va, &start, &end) || DbgFunctionGet(va, &start, &end)) && va == start)
{
bool success = mCodeFoldingManager.addFoldSegment(wVA, end - start);
bool success = mCodeFoldingManager.addFoldSegment(va, end - start);
if(!success)
GuiAddLogMessage(tr("Cannot fold selection.\n").toUtf8().constData());
}
@ -381,9 +374,9 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
}
else if(e->button() == Qt::RightButton)
{
mCodeFoldingManager.delFoldSegment(wVA);
mCodeFoldingManager.delFoldSegment(va);
}
mDisas->reloadData();
mDisassembly->reloadData();
viewport()->update();
}
}
@ -394,52 +387,52 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
if(e->button() == Qt::LeftButton)
{
QString wCmd;
QString cmd;
// create --> disable --> delete --> create --> ...
switch(Breakpoints::BPState(bp_normal, wVA))
switch(Breakpoints::BPState(bp_normal, va))
{
case bp_enabled:
// breakpoint exists and is enabled --> disable breakpoint
wCmd = "bd ";
cmd = "bd ";
break;
case bp_disabled:
// is disabled --> delete or enable
if(Breakpoints::BPTrival(bp_normal, wVA))
wCmd = "bc ";
if(Breakpoints::BPTrival(bp_normal, va))
cmd = "bc ";
else
wCmd = "be ";
cmd = "be ";
break;
case bp_non_existent:
// no breakpoint was found --> create breakpoint
wCmd = "bp ";
cmd = "bp ";
break;
}
wCmd += ToPtrString(wVA);
DbgCmdExec(wCmd);
cmd += ToPtrString(va);
DbgCmdExec(cmd);
}
}
void CPUSideBar::mouseDoubleClickEvent(QMouseEvent* event)
{
const int line = event->y() / fontHeight;
const int line = event->y() / mFontHeight;
if(line >= mInstrBuffer->size())
return;
const bool CheckBoxPresent = isFoldingGraphicsPresent(line);
if(CheckBoxPresent)
{
if(event->x() > width() - fontHeight - mBulletXOffset - mBulletRadius && event->x() < width() - mBulletXOffset - mBulletRadius)
if(event->x() > width() - mFontHeight - mBulletXOffset - mBulletRadius && event->x() < width() - mBulletXOffset - mBulletRadius)
{
if(event->button() == Qt::LeftButton)
{
duint wVA = mInstrBuffer->at(line).rva + mDisas->getBase();
duint start = mCodeFoldingManager.getFoldBegin(wVA);
duint end = mCodeFoldingManager.getFoldEnd(wVA);
if(mCodeFoldingManager.isFolded(wVA) || (start <= regDump.regcontext.cip && end >= regDump.regcontext.cip))
duint va = mInstrBuffer->at(line).rva + mDisassembly->getBase();
duint start = mCodeFoldingManager.getFoldBegin(va);
duint end = mCodeFoldingManager.getFoldEnd(va);
if(mCodeFoldingManager.isFolded(va) || (start <= mRegDump.regcontext.cip && end >= mRegDump.regcontext.cip))
{
mDisas->setSingleSelection(start - mDisas->getBase());
mDisas->expandSelectionUpTo(end - mDisas->getBase());
mDisas->setFocus();
mDisassembly->setSingleSelection(start - mDisassembly->getBase());
mDisassembly->expandSelectionUpTo(end - mDisassembly->getBase());
mDisassembly->setFocus();
}
}
}
@ -460,33 +453,33 @@ void CPUSideBar::mouseMoveEvent(QMouseEvent* event)
const QPoint & globalMousePos = event->globalPos();
const int width = viewport()->width();
const int mLine = mousePos.y() / fontHeight;
const int mLine = mousePos.y() / mFontHeight;
const bool lineInBounds = mLine > 0 && mLine < mInstrBuffer->size();
const int mBulletX = width - mBulletXOffset;
const int mBulletY = mLine * fontHeight + mBulletYOffset;
const int mBulletY = mLine * mFontHeight + mBulletYOffset;
const int mouseBulletXOffset = abs(mBulletX - mousePos.x());
const int mouseBulletYOffset = abs(mBulletY - mousePos.y());
// calculate virtual address of clicked line
duint wVA = 0;
duint va = 0;
if(lineInBounds)
wVA = mInstrBuffer->at(mLine).rva + mDisas->getBase();
va = mInstrBuffer->at(mLine).rva + mDisassembly->getBase();
// check if mouse is on a code folding box
if(mousePos.x() > width - fontHeight - mBulletXOffset - mBulletRadius && mousePos.x() < width - mBulletXOffset - mBulletRadius)
if(mousePos.x() > width - mFontHeight - mBulletXOffset - mBulletRadius && mousePos.x() < width - mBulletXOffset - mBulletRadius)
{
if(isFoldingGraphicsPresent(mLine))
{
if(mCodeFoldingManager.isFolded(wVA))
if(mCodeFoldingManager.isFolded(va))
{
QToolTip::showText(globalMousePos, tr("Click to unfold, right click to delete."));
}
else
{
if(mCodeFoldingManager.isFoldStart(wVA))
if(mCodeFoldingManager.isFoldStart(va))
QToolTip::showText(globalMousePos, tr("Click to fold, right click to delete."));
else
QToolTip::showText(globalMousePos, tr("Click to fold."));
@ -501,7 +494,7 @@ void CPUSideBar::mouseMoveEvent(QMouseEvent* event)
}
else
{
switch(Breakpoints::BPState(bp_normal, wVA))
switch(Breakpoints::BPState(bp_normal, va))
{
case bp_enabled:
QToolTip::showText(globalMousePos, tr("Breakpoint Enabled"));
@ -524,8 +517,8 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine, int endLine, int jum
// Pixel adjustment to make drawing lines even
int pixel_y_offs = 0;
int y_start = fontHeight * (1 + startLine) - 0.5 * fontHeight - pixel_y_offs;
int y_end = fontHeight * (1 + endLine) - 0.5 * fontHeight;
int y_start = mFontHeight * (1 + startLine) - 0.5 * mFontHeight - pixel_y_offs;
int y_end = mFontHeight * (1 + endLine) - 0.5 * mFontHeight;
int y_diff = y_end >= y_start ? 1 : -1;
if(conditional)
@ -581,21 +574,21 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine, int endLine, int jum
const int viewportHeight = viewport()->height();
const int JumpPadding = 11;
int x = viewportWidth - jumpoffset * JumpPadding - 15 - fontHeight;
int x = viewportWidth - jumpoffset * JumpPadding - 15 - mFontHeight;
int x_right = viewportWidth - 12;
// special handling of self-jumping
if(startLine == endLine)
{
y_start -= fontHeight / 4;
y_end += fontHeight / 4;
y_start -= mFontHeight / 4;
y_end += mFontHeight / 4;
}
// Horizontal (<----)
if(!isFoldingGraphicsPresent(startLine) != 0)
painter->drawLine(x_right, y_start, x, y_start);
else
painter->drawLine(x_right - mBulletRadius - fontHeight, y_start, x, y_start);
painter->drawLine(x_right - mBulletRadius - mFontHeight, y_start, x, y_start);
// Vertical
painter->drawLine(x, y_start, x, y_end);
@ -609,82 +602,82 @@ void CPUSideBar::drawJump(QPainter* painter, int startLine, int endLine, int jum
{
// Horizontal (---->)
if(isFoldingGraphicsPresent(endLine) != 0)
painter->drawLine(x, y_end, x_right - mBulletRadius - fontHeight, y_end);
painter->drawLine(x, y_end, x_right - mBulletRadius - mFontHeight, y_end);
else
painter->drawLine(x, y_end, x_right, y_end);
if(endLine == viewableRows + 6)
if(endLine == mViewableRows + 6)
{
int y = viewportHeight - 1;
if(y > y_start)
{
painter->setPen(solidLine);
QPoint wPoints[] =
QPoint points[] =
{
QPoint(x - 3, y - 3),
QPoint(x, y),
QPoint(x + 3, y - 3),
};
painter->drawPolyline(wPoints, 3);
painter->drawPolyline(points, 3);
}
}
else if(endLine == -6)
{
int y = 0;
painter->setPen(solidLine);
QPoint wPoints[] =
QPoint points[] =
{
QPoint(x - 3, y + 3),
QPoint(x, y),
QPoint(x + 3, y + 3),
};
painter->drawPolyline(wPoints, 3);
painter->drawPolyline(points, 3);
}
else
{
if(isFoldingGraphicsPresent(endLine) != 0)
x_right -= mBulletRadius + fontHeight;
x_right -= mBulletRadius + mFontHeight;
painter->setPen(solidLine);
QPoint wPoints[] =
QPoint points[] =
{
QPoint(x_right - 3, y_end - 3),
QPoint(x_right, y_end),
QPoint(x_right - 3, y_end + 3),
};
painter->drawPolyline(wPoints, 3);
painter->drawPolyline(points, 3);
}
}
else
{
if(endLine == viewableRows + 6)
if(endLine == mViewableRows + 6)
{
int y = viewportHeight - 1;
x--;
painter->setPen(solidLine);
QPoint wPoints[] =
QPoint points[] =
{
QPoint(x - 3, y - 3),
QPoint(x, y),
QPoint(x + 3, y - 3),
};
painter->drawPolyline(wPoints, 3);
painter->drawPolyline(points, 3);
}
else if(endLine == -6)
{
int y = 0;
painter->setPen(solidLine);
QPoint wPoints[] =
QPoint points[] =
{
QPoint(x - 3, y + 3),
QPoint(x, y),
QPoint(x + 3, y + 3),
};
painter->drawPolyline(wPoints, 3);
painter->drawPolyline(points, 3);
}
else
{
if(isFoldingGraphicsPresent(endLine) != 0)
drawStraightArrow(painter, x, y_end, x_right - mBulletRadius - fontHeight, y_end);
drawStraightArrow(painter, x, y_end, x_right - mBulletRadius - mFontHeight, y_end);
else
drawStraightArrow(painter, x, y_end, x_right, y_end);
}
@ -706,7 +699,7 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
painter->setPen(mBackgroundColor);
const int x = viewport()->width() - mBulletXOffset; //initial x
const int y = line * fontHeight; //initial y
const int y = line * mFontHeight; //initial y
painter->setRenderHint(QPainter::Antialiasing, true);
if(isbpdisabled) //disabled breakpoint
@ -720,16 +713,16 @@ void CPUSideBar::drawBullets(QPainter* painter, int line, bool isbp, bool isbpdi
CPUSideBar::LabelArrow CPUSideBar::drawLabel(QPainter* painter, int Line, const QString & Text)
{
painter->save();
const int LineCoordinate = fontHeight * (1 + Line);
const int LineCoordinate = mFontHeight * (1 + Line);
const QColor & IPLabel = mCipLabelColor;
const QColor & IPLabelBG = mCipLabelBackgroundColor;
int width = mFontMetrics->width(Text);
int x = 1;
int y = LineCoordinate - fontHeight;
int y = LineCoordinate - mFontHeight;
QRect rect(x, y, width, fontHeight - 1);
QRect rect(x, y, width, mFontHeight - 1);
// Draw rectangle
painter->setBrush(IPLabelBG);
@ -745,7 +738,7 @@ CPUSideBar::LabelArrow CPUSideBar::drawLabel(QPainter* painter, int Line, const
painter->setPen(QPen(IPLabelBG, 2.0));
painter->setBrush(QBrush(IPLabelBG));
drawStraightArrow(painter, rect.right() + 2, y, this->viewport()->width() - x - 11 - (isFoldingGraphicsPresent(Line) != 0 ? mBulletRadius + fontHeight : 0), y);*/
drawStraightArrow(painter, rect.right() + 2, y, viewport()->width() - x - 11 - (isFoldingGraphicsPresent(Line) != 0 ? mBulletRadius + fontHeight : 0), y);*/
LabelArrow labelArrow;
labelArrow.line = Line;
@ -767,7 +760,7 @@ void CPUSideBar::drawLabelArrows(QPainter* painter, const std::vector<LabelArrow
{
if(i.startX < i.endX)
{
int y = fontHeight * (1 + i.line) - 0.5 * fontHeight;
int y = mFontHeight * (1 + i.line) - 0.5 * mFontHeight;
drawStraightArrow(painter, i.startX, y, i.endX, y);
}
}
@ -777,16 +770,16 @@ void CPUSideBar::drawLabelArrows(QPainter* painter, const std::vector<LabelArrow
void CPUSideBar::drawFoldingCheckbox(QPainter* painter, int y, bool state)
{
int x = viewport()->width() - fontHeight - mBulletXOffset - mBulletRadius;
int x = viewport()->width() - mFontHeight - mBulletXOffset - mBulletRadius;
painter->save();
painter->setBrush(QBrush(mChkBoxBackColor));
painter->setPen(QColor(mChkBoxForeColor));
QRect rect(x, y, fontHeight, fontHeight);
QRect rect(x, y, mFontHeight, mFontHeight);
painter->drawRect(rect);
painter->drawLine(QPointF(x + fontHeight / 4, y + fontHeight / 2), QPointF(x + 3 * fontHeight / 4, y + fontHeight / 2));
painter->drawLine(QPointF(x + mFontHeight / 4, y + mFontHeight / 2), QPointF(x + 3 * mFontHeight / 4, y + mFontHeight / 2));
if(state) // "+"
painter->drawLine(QPointF(x + fontHeight / 2, y + fontHeight / 4), QPointF(x + fontHeight / 2, y + 3 * fontHeight / 4));
painter->drawLine(QPointF(x + mFontHeight / 2, y + mFontHeight / 4), QPointF(x + mFontHeight / 2, y + 3 * mFontHeight / 4));
painter->restore();
}
@ -804,8 +797,8 @@ void CPUSideBar::drawStraightArrow(QPainter* painter, int x1, int y1, int x2, in
void CPUSideBar::AllocateJumpOffsets(std::vector<JumpLine> & jumpLines, std::vector<LabelArrow> & labelArrows)
{
unsigned int* numLines = new unsigned int[viewableRows * 2]; // Low:jump offsets of the vertical jumping line, High:jump offsets of the horizontal jumping line.
memset(numLines, 0, sizeof(unsigned int) * viewableRows * 2);
unsigned int* numLines = new unsigned int[mViewableRows * 2]; // Low:jump offsets of the vertical jumping line, High:jump offsets of the horizontal jumping line.
memset(numLines, 0, sizeof(unsigned int) * mViewableRows * 2);
// preprocessing
for(size_t i = 0; i < jumpLines.size(); i++)
{
@ -824,7 +817,7 @@ void CPUSideBar::AllocateJumpOffsets(std::vector<JumpLine> & jumpLines, std::vec
unsigned int maxJmpOffset = 0;
if(jmp.line < jmp.destLine)
{
for(int j = jmp.line; j <= jmp.destLine && j < viewableRows; j++)
for(int j = jmp.line; j <= jmp.destLine && j < mViewableRows; j++)
{
if(numLines[j] > maxJmpOffset)
maxJmpOffset = numLines[j];
@ -841,7 +834,7 @@ void CPUSideBar::AllocateJumpOffsets(std::vector<JumpLine> & jumpLines, std::vec
jmp.jumpOffset = maxJmpOffset + 1;
if(jmp.line < jmp.destLine)
{
for(int j = jmp.line; j <= jmp.destLine && j < viewableRows; j++)
for(int j = jmp.line; j <= jmp.destLine && j < mViewableRows; j++)
numLines[j] = jmp.jumpOffset;
}
else
@ -849,20 +842,20 @@ void CPUSideBar::AllocateJumpOffsets(std::vector<JumpLine> & jumpLines, std::vec
for(int j = jmp.line; j >= jmp.destLine && j >= 0; j--)
numLines[j] = jmp.jumpOffset;
}
if(jmp.line >= 0 && jmp.line < viewableRows)
numLines[jmp.line + viewableRows] = jmp.jumpOffset;
if(jmp.destLine >= 0 && jmp.destLine < viewableRows)
numLines[jmp.destLine + viewableRows] = jmp.jumpOffset;
if(jmp.line >= 0 && jmp.line < mViewableRows)
numLines[jmp.line + mViewableRows] = jmp.jumpOffset;
if(jmp.destLine >= 0 && jmp.destLine < mViewableRows)
numLines[jmp.destLine + mViewableRows] = jmp.jumpOffset;
}
// set label arrows according to jump offsets
auto viewportWidth = viewport()->width();
const int JumpPadding = 11;
for(auto i = labelArrows.begin(); i != labelArrows.end(); i++)
{
if(numLines[i->line + viewableRows] != 0)
i->endX = viewportWidth - numLines[i->line + viewableRows] * JumpPadding - 15 - fontHeight; // This expression should be consistent with drawJump
if(numLines[i->line + mViewableRows] != 0)
i->endX = viewportWidth - numLines[i->line + mViewableRows] * JumpPadding - 15 - mFontHeight; // This expression should be consistent with drawJump
else
i->endX = viewportWidth - 1 - 11 - (isFoldingGraphicsPresent(i->line) != 0 ? mBulletRadius + fontHeight : 0);
i->endX = viewportWidth - 1 - 11 - (isFoldingGraphicsPresent(i->line) != 0 ? mBulletRadius + mFontHeight : 0);
}
delete[] numLines;
}
@ -874,13 +867,13 @@ int CPUSideBar::isFoldingGraphicsPresent(int line)
const Instruction_t* instr = &mInstrBuffer->at(line);
if(instr == nullptr) //Selection out of a memory page
return 0;
auto wVA = instr->rva + mDisas->getBase();
if(mCodeFoldingManager.isFoldStart(wVA)) //Code is already folded
auto va = instr->rva + mDisassembly->getBase();
if(mCodeFoldingManager.isFoldStart(va)) //Code is already folded
return 1;
const dsint SelectionStart = mDisas->getSelectionStart();
const dsint SelectionEnd = mDisas->getSelectionEnd();
const dsint SelectionStart = mDisassembly->getSelectionStart();
const dsint SelectionEnd = mDisassembly->getSelectionEnd();
duint start, end;
if((DbgArgumentGet(wVA, &start, &end) || DbgFunctionGet(wVA, &start, &end)) && wVA == start)
if((DbgArgumentGet(va, &start, &end) || DbgFunctionGet(va, &start, &end)) && va == start)
{
return end - start + 1 != instr->length ? 1 : 0;
}

View File

@ -2,7 +2,7 @@
#include <QAbstractScrollArea>
#include <QPen>
#include "QBeaEngine.h"
#include "QZydis.h"
#include "CodeFolding.h"
#include "Imports.h"
@ -11,11 +11,11 @@ class CPUDisassembly;
class CPUSideBar : public QAbstractScrollArea
{
Q_OBJECT
QPair<dsint, dsint> mHighlightedJump;
QPair<duint, duint> mHighlightedJump;
public:
// Constructors
explicit CPUSideBar(CPUDisassembly* Ptr, QWidget* parent = 0);
CPUSideBar(CPUDisassembly* disassembly, QWidget* parent = 0);
~CPUSideBar();
QSize sizeHint() const;
@ -38,9 +38,9 @@ public slots:
void debugStateChangedSlot(DBGSTATE state);
void reload();
void changeTopmostAddress(dsint i);
void setViewableRows(int rows);
void setSelection(dsint selVA);
void changeTopmostAddress(duint i);
void setViewableRows(duint rows);
void setSelection(duint selVA);
void foldDisassembly(duint startAddress, duint length);
protected:
@ -56,19 +56,19 @@ protected:
CodeFoldingHelper mCodeFoldingManager;
private:
CachedFontMetrics* mFontMetrics;
dsint topVA;
dsint selectedVA;
CachedFontMetrics* mFontMetrics = nullptr;
duint mTopVA = -1;
duint mSelectedVA = -1;
QFont mDefaultFont;
int fontWidth, fontHeight;
int viewableRows;
int mBulletRadius;
int mFontWidth = 0;
int mFontHeight = 0;
duint mViewableRows = 0;
int mBulletRadius = 0;
int mBulletYOffset = 10;
const int mBulletXOffset = 10;
CPUDisassembly* mDisas;
CPUDisassembly* mDisassembly = nullptr;
QList<Instruction_t>* mInstrBuffer;
REGDUMP regDump;
REGDUMP mRegDump = {};
struct JumpLine
{

View File

@ -14,31 +14,31 @@ CPUStack::CPUStack(CPUMultiDump* multiDump, QWidget* parent) : HexDump(parent)
setWindowTitle("Stack");
setShowHeader(false);
int charwidth = getCharWidth();
ColumnDescriptor wColDesc;
ColumnDescriptor colDesc;
DataDescriptor dDesc;
mMultiDump = multiDump;
mForceColumn = 1;
wColDesc.isData = true; //void*
wColDesc.itemCount = 1;
wColDesc.separator = 0;
colDesc.isData = true; //void*
colDesc.itemCount = 1;
colDesc.separator = 0;
#ifdef _WIN64
wColDesc.data.itemSize = Qword;
wColDesc.data.qwordMode = HexQword;
colDesc.data.itemSize = Qword;
colDesc.data.qwordMode = HexQword;
#else
wColDesc.data.itemSize = Dword;
wColDesc.data.dwordMode = HexDword;
colDesc.data.itemSize = Dword;
colDesc.data.dwordMode = HexDword;
#endif
appendDescriptor(10 + charwidth * 2 * sizeof(duint), "void*", false, wColDesc);
appendDescriptor(10 + charwidth * 2 * sizeof(duint), "void*", false, colDesc);
wColDesc.isData = false; //comments
wColDesc.itemCount = 0;
wColDesc.separator = 0;
colDesc.isData = false; //comments
colDesc.itemCount = 0;
colDesc.separator = 0;
dDesc.itemSize = Byte;
dDesc.byteMode = AsciiByte;
wColDesc.data = dDesc;
appendDescriptor(2000, tr("Comments"), false, wColDesc);
colDesc.data = dDesc;
appendDescriptor(2000, tr("Comments"), false, colDesc);
setupContextMenu();
@ -312,9 +312,9 @@ void CPUStack::updateFreezeStackAction()
void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & richText)
{
// Compute VA
duint wVa = rvaToVa(rva);
duint va = rvaToVa(rva);
bool wActiveStack = (wVa >= mCsp); //inactive stack
bool activeStack = (va >= mCsp); //inactive stack
STACK_COMMENT comment;
RichTextPainter::CustomRichText_t curData;
@ -325,7 +325,7 @@ void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & ric
if(col && mDescriptor.at(col - 1).isData == true) //paint stack data
{
HexDump::getColumnRichText(col, rva, richText);
if(!wActiveStack)
if(!activeStack)
{
QColor inactiveColor = ConfigColor("StackInactiveTextColor");
for(int i = 0; i < int(richText.size()); i++)
@ -335,9 +335,9 @@ void CPUStack::getColumnRichText(int col, dsint rva, RichTextPainter::List & ric
}
}
}
else if(col && DbgStackCommentGet(wVa, &comment)) //paint stack comments
else if(col && DbgStackCommentGet(va, &comment)) //paint stack comments
{
if(wActiveStack)
if(activeStack)
{
if(*comment.color)
{
@ -479,9 +479,9 @@ QString CPUStack::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
void CPUStack::contextMenuEvent(QContextMenuEvent* event)
{
QMenu wMenu(this); //create context menu
mMenuBuilder->build(&wMenu);
wMenu.exec(event->globalPos());
QMenu menu(this); //create context menu
mMenuBuilder->build(&menu);
menu.exec(event->globalPos());
}
void CPUStack::mouseDoubleClickEvent(QMouseEvent* event)
@ -493,12 +493,14 @@ void CPUStack::mouseDoubleClickEvent(QMouseEvent* event)
case 0: //address
{
//very ugly way to calculate the base of the current row (no clue why it works)
dsint deltaRowBase = getInitialSelection() % getBytePerRowCount() + mByteOffset;
auto deltaRowBase = getInitialSelection() % getBytePerRowCount() + mByteOffset;
if(deltaRowBase >= getBytePerRowCount())
deltaRowBase -= getBytePerRowCount();
dsint mSelectedVa = rvaToVa(getInitialSelection() - deltaRowBase);
if(mRvaDisplayEnabled && mSelectedVa == mRvaDisplayBase)
{
mRvaDisplayEnabled = false;
}
else
{
mRvaDisplayEnabled = true;
@ -517,9 +519,9 @@ void CPUStack::mouseDoubleClickEvent(QMouseEvent* event)
default:
{
duint wVa = rvaToVa(getInitialSelection());
duint va = rvaToVa(getInitialSelection());
STACK_COMMENT comment;
if(DbgStackCommentGet(wVa, &comment) && strcmp(comment.color, "!rtnclr") == 0)
if(DbgStackCommentGet(va, &comment) && strcmp(comment.color, "!rtnclr") == 0)
followDisasmSlot();
}
break;
@ -653,11 +655,11 @@ void CPUStack::gotoCbpSlot()
DbgCmdExec("sdump cbp");
}
int CPUStack::getCurrentFrame(const std::vector<CPUStack::CPUCallStack> & mCallstack, duint wVA)
int CPUStack::getCurrentFrame(const std::vector<CPUStack::CPUCallStack> & mCallstack, duint va)
{
if(mCallstack.size())
for(size_t i = 0; i < mCallstack.size() - 1; i++)
if(wVA >= mCallstack[i].addr && wVA < mCallstack[i + 1].addr)
if(va >= mCallstack[i].addr && va < mCallstack[i + 1].addr)
return int(i);
return -1;
}
@ -889,13 +891,13 @@ void CPUStack::undoSelectionSlot()
void CPUStack::modifySlot()
{
dsint addr = getInitialSelection();
WordEditDialog wEditDialog(this);
WordEditDialog editDialog(this);
dsint value = 0;
mMemPage->read(&value, addr, sizeof(dsint));
wEditDialog.setup(tr("Modify"), value, sizeof(dsint));
if(wEditDialog.exec() != QDialog::Accepted)
editDialog.setup(tr("Modify"), value, sizeof(dsint));
if(editDialog.exec() != QDialog::Accepted)
return;
value = wEditDialog.getVal();
value = editDialog.getVal();
mMemPage->write(&value, addr, sizeof(dsint));
GuiUpdateAllViews();
}

View File

@ -53,16 +53,16 @@ void CallStackView::setupContextMenu()
// TODO: Is Label/Comment/Bookmark useful?
mCommonActions->build(mMenuBuilder, CommonActions::ActionBreakpoint);
mMenuBuilder->addSeparator();
QAction* wShowSuspectedCallStack = makeAction(tr("Show Suspected Call Stack Frame"), SLOT(showSuspectedCallStack()));
mMenuBuilder->addAction(wShowSuspectedCallStack, [wShowSuspectedCallStack](QMenu*)
QAction* showSuspectedCallStack = makeAction(tr("Show Suspected Call Stack Frame"), SLOT(showSuspectedCallStack()));
mMenuBuilder->addAction(showSuspectedCallStack, [showSuspectedCallStack](QMenu*)
{
duint i;
if(!BridgeSettingGetUint("Engine", "ShowSuspectedCallStack", &i))
i = 0;
if(i != 0)
wShowSuspectedCallStack->setText(tr("Show Active Call Stack Frame"));
showSuspectedCallStack->setText(tr("Show Active Call Stack Frame"));
else
wShowSuspectedCallStack->setText(tr("Show Suspected Call Stack Frame"));
showSuspectedCallStack->setText(tr("Show Suspected Call Stack Frame"));
return true;
});
MenuBuilder* mCopyMenu = new MenuBuilder(this);
@ -196,10 +196,10 @@ void CallStackView::updateCallStack()
void CallStackView::contextMenuSlot(const QPoint pos)
{
QMenu wMenu(this); //create context menu
mMenuBuilder->build(&wMenu);
if(!wMenu.isEmpty())
wMenu.exec(mapToGlobal(pos)); //execute context menu
QMenu menu(this); //create context menu
mMenuBuilder->build(&menu);
if(!menu.isEmpty())
menu.exec(mapToGlobal(pos)); //execute context menu
}
void CallStackView::followAddress()

View File

@ -1026,14 +1026,14 @@ bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisToken
int row = int(blocky / this->charHeight);
//Check tokens to see if one was clicked
int selectedCodeRow = row - block.block.header_text.lines.size();
int selectedCodeRow = row - (int)block.block.header_text.lines.size();
if(selectedCodeRow < 0)
return false; // skip the header
int rowIndex = 0;
for(auto & instr : block.block.instrs)
{
int lineCount = instr.text.lines.size();
auto lineCount = (int)instr.text.lines.size();
if(rowIndex + lineCount > selectedCodeRow)
{
@ -1111,9 +1111,9 @@ void DisassemblerGraphView::mousePressEvent(QMouseEvent* event)
}
else if(event->button() == Qt::RightButton)
{
QMenu wMenu(this);
mMenuBuilder->build(&wMenu);
wMenu.exec(event->globalPos()); //execute context menu
QMenu menu(this);
mMenuBuilder->build(&menu);
menu.exec(event->globalPos()); //execute context menu
}
}
else if(event->button() & (Qt::LeftButton | Qt::RightButton))
@ -1182,9 +1182,9 @@ void DisassemblerGraphView::mousePressEvent(QMouseEvent* event)
if(overrideCtxMenu && !mHighlightToken.text.isEmpty())
{
// show the "copy highlighted token" context menu
QMenu wMenu(this);
mHighlightMenuBuilder->build(&wMenu);
wMenu.exec(event->globalPos());
QMenu menu(this);
mHighlightMenuBuilder->build(&menu);
menu.exec(event->globalPos());
lastRightClickPosition.pos = {};
}
else if(!overrideCtxMenu)
@ -2415,9 +2415,9 @@ void DisassemblerGraphView::setupContextMenu()
void DisassemblerGraphView::showContextMenu(QMouseEvent* event)
{
QMenu wMenu(this);
mMenuBuilder->build(&wMenu);
wMenu.exec(event->globalPos());
QMenu menu(this);
mMenuBuilder->build(&menu);
menu.exec(event->globalPos());
lastRightClickPosition.pos = {};
}
@ -2596,17 +2596,17 @@ void DisassemblerGraphView::xrefSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = this->get_cursor_pos();
if(!DbgMemIsValidReadPtr(wVA))
duint va = this->get_cursor_pos();
if(!DbgMemIsValidReadPtr(va))
return;
XREF_INFO mXrefInfo;
DbgXrefGet(wVA, &mXrefInfo);
DbgXrefGet(va, &mXrefInfo);
if(!mXrefInfo.refcount)
return;
BridgeFree(mXrefInfo.references);
if(!mXrefDlg)
mXrefDlg = new XrefBrowseDialog(this);
mXrefDlg->setup(wVA, [](duint addr)
mXrefDlg->setup(va, [](duint addr)
{
DbgCmdExec(QString("graph %1").arg(ToPtrString(addr)));
});

View File

@ -19,13 +19,12 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mHandlesTable->setInternalTitle("Handles");
mHandlesTable->mSearchStartCol = 0;
mHandlesTable->setDrawDebugOnly(true);
mHandlesTable->setDisassemblyPopupEnabled(false);
int wCharWidth = mHandlesTable->getCharWidth();
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Type"), true);
mHandlesTable->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Access"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + wCharWidth * 20, tr("Name"), true);
int charWidth = mHandlesTable->getCharWidth();
mHandlesTable->addColumnAt(8 + 16 * charWidth, tr("Type"), true);
mHandlesTable->addColumnAt(8 + 8 * charWidth, tr("Type number"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + sizeof(duint) * 2 * charWidth, tr("Handle"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + 16 * charWidth, tr("Access"), true, "", StdTable::SortBy::AsHex);
mHandlesTable->addColumnAt(8 + charWidth * 20, tr("Name"), true);
mHandlesTable->loadColumnFromConfig("Handle");
// Setup windows list
@ -33,17 +32,17 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mWindowsTable->setInternalTitle("Windows");
mWindowsTable->setSearchStartCol(0);
mWindowsTable->setDrawDebugOnly(true);
wCharWidth = mWindowsTable->getCharWidth();
mWindowsTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 120 * wCharWidth, tr("Title"), true);
mWindowsTable->addColumnAt(8 + 40 * wCharWidth, tr("Class"), true);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("Style"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), true);
mWindowsTable->addColumnAt(8 + 20 * wCharWidth, tr("Size"), true);
mWindowsTable->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), true);
charWidth = mWindowsTable->getCharWidth();
mWindowsTable->addColumnAt(8 + sizeof(duint) * 2 * charWidth, tr("Proc"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 8 * charWidth, tr("Handle"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 120 * charWidth, tr("Title"), true);
mWindowsTable->addColumnAt(8 + 40 * charWidth, tr("Class"), true);
mWindowsTable->addColumnAt(8 + 8 * charWidth, tr("Thread"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 16 * charWidth, tr("Style"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 16 * charWidth, tr("StyleEx"), true, "", StdTable::SortBy::AsHex);
mWindowsTable->addColumnAt(8 + 8 * charWidth, tr("Parent"), true);
mWindowsTable->addColumnAt(8 + 20 * charWidth, tr("Size"), true);
mWindowsTable->addColumnAt(8 + 6 * charWidth, tr("Enable"), true);
mWindowsTable->loadColumnFromConfig("Window");
mWindowsTable->setIconColumn(2);
@ -52,11 +51,10 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mTcpConnectionsTable->setInternalTitle("TcpConnections");
mTcpConnectionsTable->setSearchStartCol(0);
mTcpConnectionsTable->setDrawDebugOnly(true);
mTcpConnectionsTable->setDisassemblyPopupEnabled(false);
wCharWidth = mTcpConnectionsTable->getCharWidth();
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), true);
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), true);
mTcpConnectionsTable->addColumnAt(8 + 8 * wCharWidth, tr("State"), true);
charWidth = mTcpConnectionsTable->getCharWidth();
mTcpConnectionsTable->addColumnAt(8 + 64 * charWidth, tr("Remote address"), true);
mTcpConnectionsTable->addColumnAt(8 + 64 * charWidth, tr("Local address"), true);
mTcpConnectionsTable->addColumnAt(8 + 8 * charWidth, tr("State"), true);
mTcpConnectionsTable->loadColumnFromConfig("TcpConnection");
/*
@ -72,10 +70,9 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mPrivilegesTable = new StdTable(this);
mPrivilegesTable->setWindowTitle("Privileges");
mPrivilegesTable->setDrawDebugOnly(true);
mPrivilegesTable->setDisassemblyPopupEnabled(false);
mPrivilegesTable->setContextMenuPolicy(Qt::CustomContextMenu);
mPrivilegesTable->addColumnAt(8 + 32 * wCharWidth, tr("Privilege"), true);
mPrivilegesTable->addColumnAt(8 + 16 * wCharWidth, tr("State"), true);
mPrivilegesTable->addColumnAt(8 + 32 * charWidth, tr("Privilege"), true);
mPrivilegesTable->addColumnAt(8 + 16 * charWidth, tr("State"), true);
mPrivilegesTable->loadColumnFromConfig("Privilege");
// Splitter
@ -184,48 +181,48 @@ void HandlesView::dbgStateChanged(DBGSTATE state)
reloadData();
}
void HandlesView::handlesTableContextMenuSlot(QMenu* wMenu)
void HandlesView::handlesTableContextMenuSlot(QMenu* menu)
{
if(!DbgIsDebugging())
return;
auto & table = *mHandlesTable->mCurList;
wMenu->addAction(mActionRefresh);
menu->addAction(mActionRefresh);
if(table.getRowCount())
wMenu->addAction(mActionCloseHandle);
menu->addAction(mActionCloseHandle);
}
void HandlesView::windowsTableContextMenuSlot(QMenu* wMenu)
void HandlesView::windowsTableContextMenuSlot(QMenu* menu)
{
if(!DbgIsDebugging())
return;
auto & table = *mWindowsTable->mCurList;
wMenu->addAction(mActionRefresh);
menu->addAction(mActionRefresh);
if(table.getRowCount())
{
if(table.getCellContent(table.getInitialSelection(), 9) == tr("Enabled"))
{
mActionDisableWindow->setText(tr("Disable window"));
wMenu->addAction(mActionDisableWindow);
menu->addAction(mActionDisableWindow);
}
else
{
mActionEnableWindow->setText(tr("Enable window"));
wMenu->addAction(mActionEnableWindow);
menu->addAction(mActionEnableWindow);
}
wMenu->addAction(mActionFollowProc);
wMenu->addAction(mActionToggleProcBP);
wMenu->addAction(mActionMessageProcBP);
menu->addAction(mActionFollowProc);
menu->addAction(mActionToggleProcBP);
menu->addAction(mActionMessageProcBP);
}
}
void HandlesView::tcpConnectionsTableContextMenuSlot(QMenu* wMenu)
void HandlesView::tcpConnectionsTableContextMenuSlot(QMenu* menu)
{
if(!DbgIsDebugging())
return;
wMenu->addAction(mActionRefresh);
menu->addAction(mActionRefresh);
}
void HandlesView::privilegesTableContextMenuSlot(const QPoint & pos)
@ -233,34 +230,34 @@ void HandlesView::privilegesTableContextMenuSlot(const QPoint & pos)
if(!DbgIsDebugging())
return;
StdTable & table = *mPrivilegesTable;
QMenu wMenu;
QMenu menu;
bool isValid = (table.getRowCount() != 0 && table.getCellContent(table.getInitialSelection(), 1) != tr("Unknown"));
wMenu.addAction(mActionRefresh);
menu.addAction(mActionRefresh);
if(isValid)
{
if(table.getCellContent(table.getInitialSelection(), 1) == tr("Enabled"))
{
mActionDisablePrivilege->setText(tr("Disable Privilege: ") + table.getCellContent(table.getInitialSelection(), 0));
wMenu.addAction(mActionDisablePrivilege);
menu.addAction(mActionDisablePrivilege);
}
else
{
mActionEnablePrivilege->setText(tr("Enable Privilege: ") + table.getCellContent(table.getInitialSelection(), 0));
wMenu.addAction(mActionEnablePrivilege);
menu.addAction(mActionEnablePrivilege);
}
}
wMenu.addAction(mActionDisableAllPrivileges);
wMenu.addAction(mActionEnableAllPrivileges);
menu.addAction(mActionDisableAllPrivileges);
menu.addAction(mActionEnableAllPrivileges);
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy"));
table.setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
QMenu copyMenu(tr("&Copy"), this);
copyMenu.setIcon(DIcon("copy"));
table.setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
menu.addSeparator();
menu.addMenu(&copyMenu);
}
wMenu.exec(table.mapToGlobal(pos));
menu.exec(table.mapToGlobal(pos));
}
void HandlesView::closeHandleSlot()
@ -330,21 +327,21 @@ void HandlesView::toggleBPSlot()
if(!mCurList.getRowCount())
return;
QString addrText = mCurList.getCellContent(mCurList.getInitialSelection(), 0).toUtf8().constData();
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
duint va = 0;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &va))
return;
if(!DbgMemIsValidReadPtr(wVA))
if(!DbgMemIsValidReadPtr(va))
return;
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
BPXTYPE bpType = DbgGetBpxTypeAt(va);
QString cmd;
if((wBpType & bp_normal) == bp_normal)
wCmd = "bc " + ToPtrString(wVA);
else if(wBpType == bp_none)
wCmd = "bp " + ToPtrString(wVA);
if((bpType & bp_normal) == bp_normal)
cmd = "bc " + ToPtrString(va);
else if(bpType == bp_none)
cmd = "bp " + ToPtrString(va);
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
void HandlesView::messagesBPSlot()

View File

@ -22,8 +22,8 @@ public slots:
void refreshShortcuts();
void dbgStateChanged(DBGSTATE state);
void handlesTableContextMenuSlot(QMenu* wMenu);
void tcpConnectionsTableContextMenuSlot(QMenu* wMenu);
void handlesTableContextMenuSlot(QMenu* menu);
void tcpConnectionsTableContextMenuSlot(QMenu* menu);
void windowsTableContextMenuSlot(QMenu*);
void privilegesTableContextMenuSlot(const QPoint & pos);

View File

@ -121,9 +121,9 @@ void LocalVarsView::mousePressEvent(QMouseEvent* event)
void LocalVarsView::contextMenuSlot(const QPoint & pos)
{
QMenu wMenu(this);
mMenu->build(&wMenu);
wMenu.exec(mapToGlobal(pos));
QMenu menu(this);
mMenu->build(&menu);
menu.exec(mapToGlobal(pos));
}
void LocalVarsView::baseChangedSlot()
@ -270,7 +270,7 @@ void LocalVarsView::updateSlot()
} // Analyze finish
this->currentFunc = start;
}
for(dsint i = 0; i < getRowCount(); i++)
for(duint i = 0; i < getRowCount(); i++)
{
duint val = 0;
QByteArray buf = getCellContent(i, 1).toUtf8();

View File

@ -133,32 +133,32 @@ void LogView::refreshShortcutsSlot()
void LogView::contextMenuEvent(QContextMenuEvent* event)
{
QMenu wMenu(this);
wMenu.addAction(actionClear);
wMenu.addAction(actionSelectAll);
wMenu.addAction(actionCopy);
QMenu menu(this);
menu.addAction(actionClear);
menu.addAction(actionSelectAll);
menu.addAction(actionCopy);
if(QApplication::clipboard()->mimeData()->hasText())
wMenu.addAction(actionPaste);
wMenu.addAction(actionSave);
menu.addAction(actionPaste);
menu.addAction(actionSave);
if(getLoggingEnabled())
actionToggleLogging->setText(tr("Disable &Logging"));
else
actionToggleLogging->setText(tr("Enable &Logging"));
actionCopyToDebuggeeNotes->setEnabled(DbgIsDebugging());
wMenu.addMenu(menuCopyToNotes);
wMenu.addAction(actionToggleLogging);
menu.addMenu(menuCopyToNotes);
menu.addAction(actionToggleLogging);
actionAutoScroll->setChecked(autoScroll);
wMenu.addAction(actionAutoScroll);
wMenu.addAction(actionFindInLog);
wMenu.addAction(actionFindNext);
wMenu.addAction(actionFindPrevious);
menu.addAction(actionAutoScroll);
menu.addAction(actionFindInLog);
menu.addAction(actionFindNext);
menu.addAction(actionFindPrevious);
if(logRedirection == nullptr)
actionRedirectLog->setText(tr("&Redirect Log..."));
else
actionRedirectLog->setText(tr("Stop &Redirection"));
wMenu.addAction(actionRedirectLog);
menu.addAction(actionRedirectLog);
wMenu.exec(event->globalPos());
menu.exec(event->globalPos());
}
void LogView::showEvent(QShowEvent* event)

View File

@ -736,7 +736,7 @@ void MainWindow::setupLanguagesMenu2()
QMenu* languageMenu = dynamic_cast<QMenu*>(sender()); //The only sender is languageMenu
QAction* action_enUS = languageMenu->actions()[0]; //There is only one action "action_enUS" created by setupLanguagesMenu()
QDir translationsDir(QString("%1/../translations/").arg(QCoreApplication::applicationDirPath()));
QString wCurrentLocale(currentLocale);
QString currentLocale(gCurrentLocale);
if(!translationsDir.exists())
{
@ -745,7 +745,7 @@ void MainWindow::setupLanguagesMenu2()
disconnect(languageMenu, SIGNAL(aboutToShow()), this, 0);
return;
}
if(wCurrentLocale == QString("en_US"))
if(currentLocale == QString("en_US"))
action_enUS->setChecked(true);
QStringList filter;
filter << "x64dbg_*.qm";
@ -761,7 +761,7 @@ void MainWindow::setupLanguagesMenu2()
QAction* actionLanguage = new QAction(QString("[%1] %2 - %3").arg(localeName).arg(j.nativeLanguageName()).arg(j.nativeCountryName()), languageMenu);
connect(actionLanguage, SIGNAL(triggered()), this, SLOT(chooseLanguage()));
actionLanguage->setCheckable(true);
actionLanguage->setChecked(localeName == wCurrentLocale);
actionLanguage->setChecked(localeName == currentLocale);
languageMenu->addAction(actionLanguage);
break;
}
@ -1531,24 +1531,24 @@ void MainWindow::addMenu(int hMenu, QString title)
QMutexLocker locker(mMenuMutex);
// Abort if another thread deleted the entry or the parent menu
auto menu = findMenu(hMenuNew);
if(!menu)
auto menuInfo = findMenu(hMenuNew);
if(!menuInfo)
return;
auto parentMenu = findMenu(menu->hParentMenu);
if(parentMenu == nullptr && menu->hParentMenu != -1)
auto parentMenu = findMenu(menuInfo->hParentMenu);
if(parentMenu == nullptr && menuInfo->hParentMenu != -1)
return;
// Actually create the menu
QWidget* parent = menu->hParentMenu == -1 ? this : parentMenu->parent;
menu->parent = parent;
QMenu* wMenu = new QMenu(title, parent);
menu->mMenu = wMenu;
wMenu->menuAction()->setVisible(false);
if(menu->hParentMenu == -1) //top-level
ui->menuBar->addMenu(wMenu);
QWidget* parent = menuInfo->hParentMenu == -1 ? this : parentMenu->parent;
menuInfo->parent = parent;
QMenu* menu = new QMenu(title, parent);
menuInfo->mMenu = menu;
menu->menuAction()->setVisible(false);
if(menuInfo->hParentMenu == -1) //top-level
ui->menuBar->addMenu(menu);
else //deeper level
{
parentMenu->mMenu->addMenu(wMenu);
parentMenu->mMenu->addMenu(menu);
parentMenu->mMenu->menuAction()->setVisible(true);
}
});
@ -1585,18 +1585,18 @@ void MainWindow::addMenuEntry(int hMenu, QString title)
// Actually create the menu action
QWidget* parent = entry->hParentMenu == -1 ? this : menu->parent;
QAction* wAction = new QAction(title, parent);
parent->addAction(wAction);
wAction->setObjectName(QString().sprintf("ENTRY|%d", hEntryNew));
wAction->setShortcutContext((!menu || menu->globalMenu) ? Qt::ApplicationShortcut : Qt::WidgetShortcut);
parent->addAction(wAction); // TODO: something is wrong here
connect(wAction, SIGNAL(triggered()), this, SLOT(menuEntrySlot()));
entry->mAction = wAction;
QAction* action = new QAction(title, parent);
parent->addAction(action);
action->setObjectName(QString().sprintf("ENTRY|%d", hEntryNew));
action->setShortcutContext((!menu || menu->globalMenu) ? Qt::ApplicationShortcut : Qt::WidgetShortcut);
parent->addAction(action); // TODO: something is wrong here
connect(action, SIGNAL(triggered()), this, SLOT(menuEntrySlot()));
entry->mAction = action;
if(entry->hParentMenu == -1) //top level
ui->menuBar->addAction(wAction);
ui->menuBar->addAction(action);
else //deeper level
{
menu->mMenu->addAction(wAction);
menu->mMenu->addAction(action);
menu->mMenu->menuAction()->setVisible(true);
}
});
@ -2481,7 +2481,7 @@ void MainWindow::chooseLanguage()
QAction* action = qobject_cast<QAction*>(sender());
QString localeName = action->text();
localeName = localeName.mid(1, localeName.indexOf(QChar(']')) - 1);
action->setChecked(localeName == QString(currentLocale));
action->setChecked(localeName == QString(gCurrentLocale));
if(localeName != "en_US")
{
QDir translationsDir(QString("%1/../translations/").arg(QCoreApplication::applicationDirPath()));

View File

@ -216,38 +216,38 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
duint selectedAddr = getSelectionAddr();
QMenu wMenu(this); //create context menu
wMenu.addAction(mFollowDisassembly);
wMenu.addAction(mFollowDump);
QMenu menu(this); //create context menu
menu.addAction(mFollowDisassembly);
menu.addAction(mFollowDump);
if(DbgFunctions()->ModBaseFromAddr(selectedAddr))
wMenu.addAction(mFollowSymbols);
menu.addAction(mFollowSymbols);
wMenu.addAction(mDumpMemory);
//wMenu.addAction(mLoadMemory); //TODO:loaddata command
wMenu.addAction(mComment);
wMenu.addAction(mFindPattern);
wMenu.addAction(mSwitchView);
wMenu.addAction(mReferences);
wMenu.addSeparator();
wMenu.addAction(mMemoryAllocate);
wMenu.addAction(mMemoryFree);
wMenu.addAction(mAddVirtualMod);
wMenu.addMenu(mGotoMenu);
wMenu.addSeparator();
wMenu.addAction(mPageMemoryRights);
wMenu.addSeparator();
wMenu.addMenu(mBreakpointMenu);
wMenu.addSeparator();
menu.addAction(mDumpMemory);
//menu.addAction(mLoadMemory); //TODO:loaddata command
menu.addAction(mComment);
menu.addAction(mFindPattern);
menu.addAction(mSwitchView);
menu.addAction(mReferences);
menu.addSeparator();
menu.addAction(mMemoryAllocate);
menu.addAction(mMemoryFree);
menu.addAction(mAddVirtualMod);
menu.addMenu(mGotoMenu);
menu.addSeparator();
menu.addAction(mPageMemoryRights);
menu.addSeparator();
menu.addMenu(mBreakpointMenu);
menu.addSeparator();
DbgMenuPrepare(GUI_MEMMAP_MENU);
wMenu.addActions(mPluginMenu->actions());
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy"));
setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
menu.addActions(mPluginMenu->actions());
QMenu copyMenu(tr("&Copy"), this);
copyMenu.setIcon(DIcon("copy"));
setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
menu.addSeparator();
menu.addMenu(&copyMenu);
}
if((DbgGetBpxTypeAt(selectedAddr) & bp_memory) == bp_memory) //memory breakpoint set
@ -269,7 +269,7 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
mAddVirtualMod->setVisible(!DbgFunctions()->ModBaseFromAddr(selectedAddr));
wMenu.exec(mapToGlobal(pos)); //execute context menu
menu.exec(mapToGlobal(pos)); //execute context menu
}
static QString getProtectionString(DWORD Protect)
@ -407,84 +407,78 @@ void MemoryMapView::ExecCommand()
void MemoryMapView::refreshMap()
{
MEMMAP wMemMapStruct;
int wI;
MEMMAP memoryMap = {};
DbgMemMap(&memoryMap);
memset(&wMemMapStruct, 0, sizeof(MEMMAP));
setRowCount(memoryMap.count);
DbgMemMap(&wMemMapStruct);
setRowCount(wMemMapStruct.count);
QString wS;
MEMORY_BASIC_INFORMATION wMbi;
for(wI = 0; wI < wMemMapStruct.count; wI++)
for(int i = 0; i < memoryMap.count; i++)
{
wMbi = (wMemMapStruct.page)[wI].mbi;
const auto & mbi = (memoryMap.page)[i].mbi;
// Base address
setCellContent(wI, ColAddress, ToPtrString((duint)wMbi.BaseAddress));
setCellUserdata(wI, ColAddress, (duint)wMbi.BaseAddress);
setCellContent(i, ColAddress, ToPtrString((duint)mbi.BaseAddress));
setCellUserdata(i, ColAddress, (duint)mbi.BaseAddress);
// Size
setCellContent(wI, ColSize, ToPtrString((duint)wMbi.RegionSize));
setCellUserdata(wI, ColSize, (duint)wMbi.RegionSize);
setCellContent(i, ColSize, ToPtrString((duint)mbi.RegionSize));
setCellUserdata(i, ColSize, (duint)mbi.RegionSize);
// Party
int party = DbgFunctions()->ModGetParty((duint)wMbi.BaseAddress);
int party = DbgFunctions()->ModGetParty((duint)mbi.BaseAddress);
switch(party)
{
case mod_user:
setCellContent(wI, ColParty, tr("User"));
setRowIcon(wI, DIcon("markasuser"));
setCellContent(i, ColParty, tr("User"));
setRowIcon(i, DIcon("markasuser"));
break;
case mod_system:
setCellContent(wI, ColParty, tr("System"));
setRowIcon(wI, DIcon("markassystem"));
setCellContent(i, ColParty, tr("System"));
setRowIcon(i, DIcon("markassystem"));
break;
default:
setCellContent(wI, ColParty, QString::number(party));
setRowIcon(wI, DIcon("markasparty"));
setCellContent(i, ColParty, QString::number(party));
setRowIcon(i, DIcon("markasparty"));
break;
}
// Information
wS = QString((wMemMapStruct.page)[wI].info);
setCellContent(wI, ColPageInfo, wS);
auto content = QString((memoryMap.page)[i].info);
setCellContent(i, ColPageInfo, content);
// Content, TODO: proper section content analysis in dbg/memory.cpp:MemUpdateMap
char comment_text[MAX_COMMENT_SIZE];
if(DbgFunctions()->GetUserComment((duint)wMbi.BaseAddress, comment_text)) // user comment present
wS = comment_text;
else if(wS.contains(".bss"))
wS = tr("Uninitialized data");
else if(wS.contains(".data"))
wS = tr("Initialized data");
else if(wS.contains(".edata"))
wS = tr("Export tables");
else if(wS.contains(".idata"))
wS = tr("Import tables");
else if(wS.contains(".pdata"))
wS = tr("Exception information");
else if(wS.contains(".rdata"))
wS = tr("Read-only initialized data");
else if(wS.contains(".reloc"))
wS = tr("Base relocations");
else if(wS.contains(".rsrc"))
wS = tr("Resources");
else if(wS.contains(".text"))
wS = tr("Executable code");
else if(wS.contains(".tls"))
wS = tr("Thread-local storage");
else if(wS.contains(".xdata"))
wS = tr("Exception information");
if(DbgFunctions()->GetUserComment((duint)mbi.BaseAddress, comment_text)) // user comment present
content = comment_text;
else if(content.contains(".bss"))
content = tr("Uninitialized data");
else if(content.contains(".data"))
content = tr("Initialized data");
else if(content.contains(".edata"))
content = tr("Export tables");
else if(content.contains(".idata"))
content = tr("Import tables");
else if(content.contains(".pdata"))
content = tr("Exception information");
else if(content.contains(".rdata"))
content = tr("Read-only initialized data");
else if(content.contains(".reloc"))
content = tr("Base relocations");
else if(content.contains(".rsrc"))
content = tr("Resources");
else if(content.contains(".text"))
content = tr("Executable code");
else if(content.contains(".tls"))
content = tr("Thread-local storage");
else if(content.contains(".xdata"))
content = tr("Exception information");
else
wS = QString("");
setCellContent(wI, ColContent, std::move(wS));
content = QString("");
setCellContent(i, ColContent, std::move(content));
// Type
const char* type = "";
switch(wMbi.Type)
switch(mbi.Type)
{
case MEM_IMAGE:
type = "IMG";
@ -499,17 +493,17 @@ void MemoryMapView::refreshMap()
type = "N/A";
break;
}
setCellContent(wI, ColAllocation, type);
setCellContent(i, ColAllocation, type);
// current access protection
setCellContent(wI, ColCurProtect, getProtectionString(wMbi.Protect));
setCellContent(i, ColCurProtect, getProtectionString(mbi.Protect));
// allocation protection
setCellContent(wI, ColAllocProtect, getProtectionString(wMbi.AllocationProtect));
setCellContent(i, ColAllocProtect, getProtectionString(mbi.AllocationProtect));
}
if(wMemMapStruct.page != 0)
BridgeFree(wMemMapStruct.page);
if(memoryMap.page != 0)
BridgeFree(memoryMap.page);
reloadData(); //refresh memory map
}

View File

@ -63,8 +63,8 @@ void MessagesBreakpoints::on_btnOk_clicked()
if(!translMsg)
{
BPXTYPE wBpType = DbgGetBpxTypeAt(procVA);
if(wBpType == bp_none)
BPXTYPE bpType = DbgGetBpxTypeAt(procVA);
if(bpType == bp_none)
DbgCmdExec(QString("bp 0x%1").arg(bpData.procVA));
bpCondCmd = QString("bpcnd 0x%1, \"arg.get(1) == 0x%2").arg(bpData.procVA).arg(messages.key(ui->cboxMessages->currentText()), 1, 16);
@ -72,8 +72,8 @@ void MessagesBreakpoints::on_btnOk_clicked()
}
else
{
BPXTYPE wBpType = DbgGetBpxTypeAt(DbgValFromString("TranslateMessage"));
if(wBpType == bp_none)
BPXTYPE bpType = DbgGetBpxTypeAt(DbgValFromString("TranslateMessage"));
if(bpType == bp_none)
DbgCmdExec("bp TranslateMessage");
#ifdef _WIN64

View File

@ -1194,8 +1194,8 @@ RegistersView::RegistersView(QWidget* parent) : QScrollArea(parent), mVScrollOff
connect(wCM_CopyAll, SIGNAL(triggered()), this, SLOT(onCopyAllAction()));
connect(wCM_ChangeFPUView, SIGNAL(triggered()), this, SLOT(onChangeFPUViewAction()));
memset(&wRegDumpStruct, 0, sizeof(REGDUMP));
memset(&wCipRegDumpStruct, 0, sizeof(REGDUMP));
memset(&mRegDumpStruct, 0, sizeof(REGDUMP));
memset(&mCipRegDumpStruct, 0, sizeof(REGDUMP));
mCip = 0;
mRegisterUpdates.clear();
@ -1226,10 +1226,10 @@ void RegistersView::fontsUpdatedSlot()
if(mChangeViewButton)
mChangeViewButton->setFont(font);
//update metrics information
int wRowsHeight = QFontMetrics(this->font()).height();
wRowsHeight = (wRowsHeight * 105) / 100;
wRowsHeight = (wRowsHeight % 2) == 0 ? wRowsHeight : wRowsHeight + 1;
mRowHeight = wRowsHeight;
int rowHeight = QFontMetrics(this->font()).height();
rowHeight = (rowHeight * 105) / 100;
rowHeight = (rowHeight % 2) == 0 ? rowHeight : rowHeight + 1;
mRowHeight = rowHeight;
mCharWidth = QFontMetrics(this->font()).averageCharWidth();
//reload layout because the layout is dependent on the font.
@ -1451,7 +1451,7 @@ QString RegistersView::helpRegister(REGISTER_NAME reg)
{
char dat[1024];
LASTERROR* error;
error = (LASTERROR*)registerValue(&wRegDumpStruct, LastError);
error = (LASTERROR*)registerValue(&mRegDumpStruct, LastError);
if(DbgFunctions()->StringFormatInline(QString().sprintf("{winerror@%X}", error->code).toUtf8().constData(), sizeof(dat), dat))
return dat;
else
@ -1461,7 +1461,7 @@ QString RegistersView::helpRegister(REGISTER_NAME reg)
{
char dat[1024];
LASTSTATUS* error;
error = (LASTSTATUS*)registerValue(&wRegDumpStruct, LastStatus);
error = (LASTSTATUS*)registerValue(&mRegDumpStruct, LastStatus);
if(DbgFunctions()->StringFormatInline(QString().sprintf("{ntstatus@%X}", error->code).toUtf8().constData(), sizeof(dat), dat))
return dat;
else
@ -1552,9 +1552,9 @@ void RegistersView::paintEvent(QPaintEvent* event)
mChangeViewButton->setText(tr("Show FPU"));
}
QPainter wPainter(this->viewport());
wPainter.setFont(font());
wPainter.fillRect(wPainter.viewport(), QBrush(ConfigColor("RegistersBackgroundColor")));
QPainter painter(this->viewport());
painter.setFont(font());
painter.fillRect(painter.viewport(), QBrush(ConfigColor("RegistersBackgroundColor")));
// Don't draw the registers if a program isn't actually running
if(!isActive)
@ -1564,7 +1564,7 @@ void RegistersView::paintEvent(QPaintEvent* event)
for(auto itr = mRegisterMapping.begin(); itr != mRegisterMapping.end(); itr++)
{
// Paint register at given position
drawRegister(&wPainter, itr.key(), registerValue(&wRegDumpStruct, itr.key()));
drawRegister(&painter, itr.key(), registerValue(&mRegDumpStruct, itr.key()));
}
}
@ -1629,8 +1629,8 @@ QString RegistersView::getRegisterLabel(REGISTER_NAME register_selected)
char string_text[MAX_STRING_SIZE] = "";
char status_text[MAX_STRING_SIZE] = "";
QString valueText = QString("%1").arg((* ((duint*) registerValue(&wRegDumpStruct, register_selected))), mRegisterPlaces[register_selected].valuesize, 16, QChar('0')).toUpper();
duint register_value = (* ((duint*) registerValue(&wRegDumpStruct, register_selected)));
QString valueText = QString("%1").arg((* ((duint*) registerValue(&mRegDumpStruct, register_selected))), mRegisterPlaces[register_selected].valuesize, 16, QChar('0')).toUpper();
duint register_value = (* ((duint*) registerValue(&mRegDumpStruct, register_selected)));
QString newText = QString("");
bool hasString = DbgGetStringAt(register_value, string_text);
@ -2113,11 +2113,11 @@ void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, char* value)
if(reg >= x87r0 && reg <= x87r7)
{
newText = QString("ST%1 ").arg(((X87FPUREGISTER*) registerValue(&wRegDumpStruct, reg))->st_value);
newText = QString("ST%1 ").arg(((X87FPUREGISTER*) registerValue(&mRegDumpStruct, reg))->st_value);
}
else
{
newText = QString("x87r%1 ").arg((wRegDumpStruct.x87StatusWordFields.TOP + (reg - x87st0)) & 7);
newText = QString("x87r%1 ").arg((mRegDumpStruct.x87StatusWordFields.TOP + (reg - x87st0)) & 7);
}
width = fontMetrics.width(newText);
p->drawText(x, y, width, mRowHeight, Qt::AlignVCenter, newText);
@ -2131,7 +2131,7 @@ void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, char* value)
if(reg >= x87r0 && reg <= x87r7 && mRegisterUpdates.contains((REGISTER_NAME)(x87TW_0 + (reg - x87r0))))
p->setPen(ConfigColor("RegistersModifiedColor"));
newText += GetTagWordStateString(((X87FPUREGISTER*) registerValue(&wRegDumpStruct, reg))->tag) + QString(" ");
newText += GetTagWordStateString(((X87FPUREGISTER*) registerValue(&mRegDumpStruct, reg))->tag) + QString(" ");
width = fontMetrics.width(newText);
p->drawText(x, y, width, mRowHeight, Qt::AlignVCenter, newText);
@ -2145,7 +2145,7 @@ void RegistersView::drawRegister(QPainter* p, REGISTER_NAME reg, char* value)
if(isActive && mRegisterUpdates.contains(reg))
p->setPen(ConfigColor("RegistersModifiedColor"));
newText += ToLongDoubleString(((X87FPUREGISTER*) registerValue(&wRegDumpStruct, reg))->data);
newText += ToLongDoubleString(((X87FPUREGISTER*) registerValue(&mRegDumpStruct, reg))->data);
width = fontMetrics.width(newText);
p->drawText(x, y, width, mRowHeight, Qt::AlignVCenter, newText);
}
@ -2179,7 +2179,7 @@ void RegistersView::appendRegister(QString & text, REGISTER_NAME reg, const char
Q_UNUSED(name64);
text.append(name32);
#endif //_WIN64
text.append(GetRegStringValueFromValue(reg, registerValue(&wRegDumpStruct, reg)));
text.append(GetRegStringValueFromValue(reg, registerValue(&mRegDumpStruct, reg)));
symbol = getRegisterLabel(reg);
if(symbol != "")
{
@ -2268,12 +2268,12 @@ void RegistersView::onFpuMode()
void RegistersView::onCopyToClipboardAction()
{
Bridge::CopyToClipboard(GetRegStringValueFromValue(mSelected, registerValue(&wRegDumpStruct, mSelected)));
Bridge::CopyToClipboard(GetRegStringValueFromValue(mSelected, registerValue(&mRegDumpStruct, mSelected)));
}
void RegistersView::onCopyFloatingPointToClipboardAction()
{
Bridge::CopyToClipboard(ToLongDoubleString(((X87FPUREGISTER*) registerValue(&wRegDumpStruct, mSelected))->data));
Bridge::CopyToClipboard(ToLongDoubleString(((X87FPUREGISTER*) registerValue(&mRegDumpStruct, mSelected))->data));
}
void RegistersView::onCopySymbolToClipboardAction()
@ -2847,7 +2847,7 @@ void RegistersView::setRegisters(REGDUMP* reg)
// tests if new-register-value == old-register-value holds
if(mCip != reg->regcontext.cip) //CIP changed
{
wCipRegDumpStruct = wRegDumpStruct;
mCipRegDumpStruct = mRegDumpStruct;
mRegisterUpdates.clear();
mCip = reg->regcontext.cip;
}
@ -2855,17 +2855,17 @@ void RegistersView::setRegisters(REGDUMP* reg)
// iterate all ids (CAX, CBX, ...)
for(auto itr = mRegisterMapping.begin(); itr != mRegisterMapping.end(); itr++)
{
if(CompareRegisters(itr.key(), reg, &wCipRegDumpStruct) != 0)
if(CompareRegisters(itr.key(), reg, &mCipRegDumpStruct) != 0)
mRegisterUpdates.insert(itr.key());
else if(mRegisterUpdates.contains(itr.key())) //registers are equal
mRegisterUpdates.remove(itr.key());
}
// now we can save the values
wRegDumpStruct = (*reg);
mRegDumpStruct = (*reg);
if(mCip != reg->regcontext.cip)
wCipRegDumpStruct = wRegDumpStruct;
mCipRegDumpStruct = mRegDumpStruct;
// force repaint
emit refresh();

View File

@ -238,8 +238,8 @@ protected:
// contains names of closest registers in view
QMap<REGISTER_NAME, Register_Relative_Position> mRegisterRelativePlaces;
// contains a dump of the current register values
REGDUMP wRegDumpStruct;
REGDUMP wCipRegDumpStruct;
REGDUMP mRegDumpStruct;
REGDUMP mCipRegDumpStruct;
// font measures (TODO: create a class that calculates all thos values)
unsigned int mRowHeight, mCharWidth;
// SIMD registers display mode

View File

@ -65,18 +65,18 @@ void SEHChainView::contextMenuSlot(const QPoint pos)
{
if(!DbgIsDebugging() || this->getRowCount() == 0)
return;
QMenu wMenu(this); //create context menu
wMenu.addAction(mFollowAddress);
wMenu.addAction(mFollowHandler);
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy"));
setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
QMenu menu(this); //create context menu
menu.addAction(mFollowAddress);
menu.addAction(mFollowHandler);
QMenu copyMenu(tr("&Copy"), this);
copyMenu.setIcon(DIcon("copy"));
setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
menu.addSeparator();
menu.addMenu(&copyMenu);
}
wMenu.exec(mapToGlobal(pos)); //execute context menu
menu.exec(mapToGlobal(pos)); //execute context menu
}
void SEHChainView::doubleClickedSlot()

View File

@ -327,9 +327,9 @@ QString ScriptView::paintContent(QPainter* painter, dsint rowBase, int rowOffset
void ScriptView::contextMenuSlot(const QPoint & pos)
{
QMenu wMenu(this);
mMenu->build(&wMenu);
wMenu.exec(mapToGlobal(pos));
QMenu menu(this);
mMenu->build(&menu);
menu.exec(mapToGlobal(pos));
}
void ScriptView::mouseDoubleClickEvent(QMouseEvent* event)
@ -348,8 +348,8 @@ void ScriptView::keyPressEvent(QKeyEvent* event)
int key = event->key();
if(key == Qt::Key_Up || key == Qt::Key_Down)
{
dsint botRVA = getTableOffset();
dsint topRVA = botRVA + getNbrOfLineToPrint() - 1;
auto botRVA = getTableOffset();
auto topRVA = botRVA + getNbrOfLineToPrint() - 1;
if(key == Qt::Key_Up)
selectPrevious();
else

View File

@ -112,9 +112,9 @@ QString SourceView::getSourcePath()
void SourceView::contextMenuSlot(const QPoint & pos)
{
QMenu wMenu(this);
mMenuBuilder->build(&wMenu);
wMenu.exec(mapToGlobal(pos));
QMenu menu(this);
mMenuBuilder->build(&menu);
menu.exec(mapToGlobal(pos));
}
void SourceView::gotoLineSlot()

View File

@ -284,10 +284,10 @@ duint StructWidget::selectedValue() const
void StructWidget::on_treeWidget_customContextMenuRequested(const QPoint & pos)
{
QMenu wMenu;
mMenuBuilder->build(&wMenu);
if(wMenu.actions().count())
wMenu.exec(ui->treeWidget->viewport()->mapToGlobal(pos));
QMenu menu;
mMenuBuilder->build(&menu);
if(menu.actions().count())
menu.exec(ui->treeWidget->viewport()->mapToGlobal(pos));
}
void StructWidget::followDumpSlot()

View File

@ -434,9 +434,9 @@ void SymbolView::moduleSelectionChanged(int index)
for(auto index : mModuleList->mCurList->getSelection())
{
QString modBase = mModuleList->mCurList->getCellContent(index, ColBase);
duint wVA;
if(DbgFunctions()->ValFromString(modBase.toUtf8().constData(), &wVA))
selectedModules.push_back(wVA);
duint va = 0;
if(DbgFunctions()->ValFromString(modBase.toUtf8().constData(), &va))
selectedModules.push_back(va);
}
std::vector<SYMBOLPTR> data;
@ -512,17 +512,17 @@ void SymbolView::updateSymbolList(int module_count, SYMBOLMODULEINFO* modules)
BridgeFree(modules);
}
void SymbolView::symbolContextMenu(QMenu* wMenu)
void SymbolView::symbolContextMenu(QMenu* menu)
{
if(!mSymbolList->mCurList->getRowCount())
return;
wMenu->addAction(mFollowSymbolAction);
wMenu->addAction(mFollowSymbolDumpAction);
menu->addAction(mFollowSymbolAction);
menu->addAction(mFollowSymbolDumpAction);
if(mSymbolList->mCurList->getCellContent(mSymbolList->mCurList->getInitialSelection(), 1) == tr("Import"))
wMenu->addAction(mFollowSymbolImportAction);
wMenu->addSeparator();
wMenu->addAction(mToggleBreakpoint);
wMenu->addAction(mToggleBookmark);
menu->addAction(mFollowSymbolImportAction);
menu->addSeparator();
menu->addAction(mToggleBreakpoint);
menu->addAction(mToggleBookmark);
}
void SymbolView::symbolRefreshCurrent()
@ -587,43 +587,43 @@ void SymbolView::enterPressedSlot()
}
}
void SymbolView::moduleContextMenu(QMenu* wMenu)
void SymbolView::moduleContextMenu(QMenu* menu)
{
if(!DbgIsDebugging() || !mModuleList->mCurList->getRowCount())
return;
wMenu->addAction(mFollowModuleAction);
wMenu->addAction(mFollowModuleEntryAction);
wMenu->addAction(mFollowInMemMap);
wMenu->addAction(mDownloadSymbolsAction);
wMenu->addAction(mDownloadAllSymbolsAction);
menu->addAction(mFollowModuleAction);
menu->addAction(mFollowModuleEntryAction);
menu->addAction(mFollowInMemMap);
menu->addAction(mDownloadSymbolsAction);
menu->addAction(mDownloadAllSymbolsAction);
duint modbase = DbgValFromString(mModuleList->mCurList->getCellContent(mModuleList->mCurList->getInitialSelection(), ColBase).toUtf8().constData());
char szModPath[MAX_PATH] = "";
if(DbgFunctions()->ModPathFromAddr(modbase, szModPath, _countof(szModPath)))
{
wMenu->addAction(mCopyPathAction);
wMenu->addAction(mBrowseInExplorer);
menu->addAction(mCopyPathAction);
menu->addAction(mBrowseInExplorer);
}
wMenu->addAction(mLoadLib);
wMenu->addAction(mFreeLib);
wMenu->addSeparator();
menu->addAction(mLoadLib);
menu->addAction(mFreeLib);
menu->addSeparator();
int party = DbgFunctions()->ModGetParty(modbase);
if(party != 0)
wMenu->addAction(mModSetUserAction);
menu->addAction(mModSetUserAction);
if(party != 1)
wMenu->addAction(mModSetSystemAction);
wMenu->addAction(mModSetPartyAction);
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy"));
mModuleList->mCurList->setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
menu->addAction(mModSetSystemAction);
menu->addAction(mModSetPartyAction);
QMenu copyMenu(tr("&Copy"), this);
copyMenu.setIcon(DIcon("copy"));
mModuleList->mCurList->setupCopyMenu(&copyMenu);
if(copyMenu.actions().length())
{
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
menu->addSeparator();
menu->addMenu(&copyMenu);
}
wMenu->addSeparator();
menu->addSeparator();
DbgMenuPrepare(GUI_SYMMOD_MENU);
wMenu->addActions(mPluginMenu->actions());
menu->addActions(mPluginMenu->actions());
}
void SymbolView::moduleFollow()
@ -731,30 +731,30 @@ void SymbolView::toggleBreakpoint()
for(auto selectedIdx : selection)
{
QString addrText = mSymbolList->mCurList->getCellContent(selectedIdx, 0);
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
duint va;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &va))
return;
//Import means that the address is an IAT entry so we read the actual function address
if(mSymbolList->mCurList->getCellContent(selectedIdx, 1) == tr("Import"))
DbgMemRead(wVA, &wVA, sizeof(wVA));
DbgMemRead(va, &va, sizeof(va));
if(!DbgMemIsValidReadPtr(wVA))
if(!DbgMemIsValidReadPtr(va))
return;
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
BPXTYPE bpType = DbgGetBpxTypeAt(va);
QString cmd;
if((wBpType & bp_normal) == bp_normal)
if((bpType & bp_normal) == bp_normal)
{
wCmd = "bc " + ToPtrString(wVA);
cmd = "bc " + ToPtrString(va);
}
else
{
wCmd = "bp " + ToPtrString(wVA);
cmd = "bp " + ToPtrString(va);
}
DbgCmdExec(wCmd);
DbgCmdExec(cmd);
}
}
@ -770,17 +770,17 @@ void SymbolView::toggleBookmark()
for(auto index : selection)
{
QString addrText = mSymbolList->mCurList->getCellContent(index, 0);
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
duint va;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &va))
return;
if(!DbgMemIsValidReadPtr(wVA))
if(!DbgMemIsValidReadPtr(va))
return;
bool result;
if(DbgGetBookmarkAt(wVA))
result = DbgSetBookmarkAt(wVA, false);
if(DbgGetBookmarkAt(va))
result = DbgSetBookmarkAt(va, false);
else
result = DbgSetBookmarkAt(wVA, true);
result = DbgSetBookmarkAt(va, true);
if(!result)
{
QMessageBox msg(QMessageBox::Critical, tr("Error!"), tr("DbgSetBookmarkAt failed!"));

View File

@ -39,9 +39,9 @@ private slots:
void symbolFollowImport();
void symbolSelectModule(duint base);
void enterPressedSlot();
void symbolContextMenu(QMenu* wMenu);
void symbolContextMenu(QMenu* menu);
void symbolRefreshCurrent();
void moduleContextMenu(QMenu* wMenu);
void moduleContextMenu(QMenu* menu);
void moduleFollow();
void moduleEntryFollow();
void moduleDownloadSymbols();

View File

@ -37,20 +37,20 @@ void MHTabBar::contextMenuEvent(QContextMenuEvent* event)
{
if(!mAllowDetach && !mAllowDelete)
return;
QMenu wMenu(this);
QAction wDetach(tr("&Detach"), this);
QMenu menu(this);
QAction detach(tr("&Detach"), this);
if(mAllowDetach)
wMenu.addAction(&wDetach);
QAction wDelete(tr("&Close"), this);
menu.addAction(&detach);
QAction close(tr("&Close"), this);
if(mAllowDelete)
wMenu.addAction(&wDelete);
QAction* executed = wMenu.exec(event->globalPos());
if(executed == &wDetach)
menu.addAction(&close);
QAction* executed = menu.exec(event->globalPos());
if(executed == &detach)
{
QPoint p(0, 0);
emit OnDetachTab((int)tabAt(event->pos()), p);
}
else if(executed == &wDelete)
else if(executed == &close)
{
emit OnDeleteTab((int)tabAt(event->pos()));
}

View File

@ -9,9 +9,9 @@ void ThreadView::contextMenuSlot(const QPoint & pos)
if(!DbgIsDebugging())
return;
QMenu wMenu(this); //create context menu
mMenuBuilder->build(&wMenu);
wMenu.exec(mapToGlobal(pos)); //execute context menu
QMenu menu(this); //create context menu
mMenuBuilder->build(&menu);
menu.exec(mapToGlobal(pos)); //execute context menu
}
void ThreadView::GoToThreadEntry()

View File

@ -200,9 +200,9 @@ QString WatchView::paintContent(QPainter* painter, dsint rowBase, int rowOffset,
void WatchView::contextMenuSlot(const QPoint & pos)
{
QMenu wMenu(this);
mMenu->build(&wMenu);
wMenu.exec(mapToGlobal(pos));
QMenu menu(this);
mMenu->build(&menu);
menu.exec(mapToGlobal(pos));
}
void WatchView::addWatchSlot()

View File

@ -151,9 +151,9 @@ QString ZehSymbolTable::symbolInfoString(const SYMBOLINFO* info, int c)
// Get module name for import symbols
if(info->type == sym_import)
{
duint wVA;
if(DbgMemRead(info->addr, &wVA, sizeof(duint)))
if(DbgGetModuleAt(wVA, modname))
duint va = 0;
if(DbgMemRead(info->addr, &va, sizeof(duint)))
if(DbgGetModuleAt(va, modname))
return QString(modname).append('.').append(info->decoratedSymbol);
}
return info->decoratedSymbol;
@ -168,10 +168,10 @@ QString ZehSymbolTable::symbolInfoString(const SYMBOLINFO* info, int c)
{
case sym_import:
{
duint wVA;
if(DbgMemRead(info->addr, &wVA, sizeof(duint)))
duint va = 0;
if(DbgMemRead(info->addr, &va, sizeof(duint)))
{
DbgGetLabelAt(wVA, SEG_DEFAULT, label);
DbgGetLabelAt(va, SEG_DEFAULT, label);
return label;
}
}

View File

@ -317,12 +317,12 @@ QString TraceBrowser::paintContent(QPainter* painter, dsint rowBase, int rowOffs
reg = mTraceFile->Registers(index);
cur_addr = reg.regcontext.cip;
auto traceCount = DbgFunctions()->GetTraceRecordHitCount(cur_addr);
bool wIsSelected = (index >= mSelection.fromIndex && index <= mSelection.toIndex);
bool rowSelected = (index >= mSelection.fromIndex && index <= mSelection.toIndex);
// Highlight if selected
if(wIsSelected && traceCount)
if(rowSelected && traceCount)
painter->fillRect(QRect(x, y, w, h), QBrush(mTracedSelectedAddressBackgroundColor));
else if(wIsSelected)
else if(rowSelected)
painter->fillRect(QRect(x, y, w, h), QBrush(mSelectionColor));
else if(traceCount)
{

View File

@ -350,11 +350,11 @@ void TraceInfoBox::setupContextMenu()
void TraceInfoBox::contextMenuSlot(QPoint pos)
{
QMenu wMenu(this); //create context menu
QMenu wCopyMenu(tr("&Copy"), this);
setupCopyMenu(&wCopyMenu);
wMenu.addMenu(&wCopyMenu);
wMenu.exec(mapToGlobal(pos)); //execute context menu
QMenu menu(this); //create context menu
QMenu copyMenu(tr("&Copy"), this);
setupCopyMenu(&copyMenu);
menu.addMenu(&copyMenu);
menu.exec(mapToGlobal(pos)); //execute context menu
}
void TraceInfoBox::setupShortcuts()

View File

@ -20,64 +20,64 @@ void TraceRegisters::setRegisters(REGDUMP* registers)
void TraceRegisters::setActive(bool isActive)
{
this->isActive = isActive;
this->RegistersView::setRegisters(&this->wRegDumpStruct);
this->RegistersView::setRegisters(&this->mRegDumpStruct);
}
void TraceRegisters::displayCustomContextMenuSlot(QPoint pos)
{
if(!isActive)
return;
QMenu wMenu(this);
QMenu menu(this);
setupSIMDModeMenu();
if(mSelected != UNKNOWN)
{
wMenu.addAction(wCM_CopyToClipboard);
menu.addAction(wCM_CopyToClipboard);
if(mFPUx87_80BITSDISPLAY.contains(mSelected))
{
wMenu.addAction(wCM_CopyFloatingPointValueToClipboard);
menu.addAction(wCM_CopyFloatingPointValueToClipboard);
}
if(mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected))
{
wMenu.addAction(wCM_CopySIMDRegister);
menu.addAction(wCM_CopySIMDRegister);
}
if(mLABELDISPLAY.contains(mSelected))
{
QString symbol = getRegisterLabel(mSelected);
if(symbol != "")
wMenu.addAction(wCM_CopySymbolToClipboard);
menu.addAction(wCM_CopySymbolToClipboard);
}
wMenu.addAction(wCM_CopyAll);
menu.addAction(wCM_CopyAll);
if(mFPUMMX.contains(mSelected) || mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected))
{
wMenu.addMenu(mSwitchSIMDDispMode);
menu.addMenu(mSwitchSIMDDispMode);
}
if(mFPUMMX.contains(mSelected) || mFPUx87_80BITSDISPLAY.contains(mSelected))
{
if(mFpuMode != 0)
wMenu.addAction(mDisplaySTX);
menu.addAction(mDisplaySTX);
if(mFpuMode != 1)
wMenu.addAction(mDisplayx87rX);
menu.addAction(mDisplayx87rX);
if(mFpuMode != 2)
wMenu.addAction(mDisplayMMX);
menu.addAction(mDisplayMMX);
}
wMenu.exec(this->mapToGlobal(pos));
menu.exec(this->mapToGlobal(pos));
}
else // Right-click on empty space
{
wMenu.addSeparator();
wMenu.addAction(wCM_ChangeFPUView);
wMenu.addAction(wCM_CopyAll);
wMenu.addMenu(mSwitchSIMDDispMode);
menu.addSeparator();
menu.addAction(wCM_ChangeFPUView);
menu.addAction(wCM_CopyAll);
menu.addMenu(mSwitchSIMDDispMode);
if(mFpuMode != 0)
wMenu.addAction(mDisplaySTX);
menu.addAction(mDisplaySTX);
if(mFpuMode != 1)
wMenu.addAction(mDisplayx87rX);
menu.addAction(mDisplayx87rX);
if(mFpuMode != 2)
wMenu.addAction(mDisplayMMX);
menu.addAction(mDisplayMMX);
}
}
@ -94,11 +94,11 @@ static void showCopyFloatRegister(int bits, QWidget* parent, const QString & tit
void TraceRegisters::onCopySIMDRegister()
{
if(mFPUYMM.contains(mSelected))
showCopyFloatRegister(256, this, tr("View YMM register"), registerValue(&wRegDumpStruct, mSelected));
showCopyFloatRegister(256, this, tr("View YMM register"), registerValue(&mRegDumpStruct, mSelected));
else if(mFPUXMM.contains(mSelected))
showCopyFloatRegister(128, this, tr("View XMM register"), registerValue(&wRegDumpStruct, mSelected));
showCopyFloatRegister(128, this, tr("View XMM register"), registerValue(&mRegDumpStruct, mSelected));
else if(mFPUMMX.contains(mSelected))
showCopyFloatRegister(64, this, tr("View MMX register"), registerValue(&wRegDumpStruct, mSelected));
showCopyFloatRegister(64, this, tr("View MMX register"), registerValue(&mRegDumpStruct, mSelected));
}
void TraceRegisters::mouseDoubleClickEvent(QMouseEvent* event)
@ -113,7 +113,7 @@ void TraceRegisters::mouseDoubleClickEvent(QMouseEvent* event)
if(!identifyRegister(y, x, 0))
return;
if(mSelected == CIP) //double clicked on CIP register: follow in disassembly
DbgCmdExec(QString("disasm %1").arg(ToPtrString(wRegDumpStruct.regcontext.cip)));
DbgCmdExec(QString("disasm %1").arg(ToPtrString(mRegDumpStruct.regcontext.cip)));
// double clicked on XMM register: open view XMM register dialog
else if(mFPUXMM.contains(mSelected) || mFPUYMM.contains(mSelected) || mFPUMMX.contains(mSelected))
onCopySIMDRegister();

View File

@ -16,25 +16,25 @@ Breakpoints::Breakpoints(QObject* parent) : QObject(parent)
*/
void Breakpoints::setBP(BPXTYPE type, duint va)
{
QString wCmd = "";
QString cmd = "";
switch(type)
{
case bp_normal:
{
wCmd = "bp " + ToPtrString(va);
cmd = "bp " + ToPtrString(va);
}
break;
case bp_hardware:
{
wCmd = "bph " + ToPtrString(va);
cmd = "bph " + ToPtrString(va);
}
break;
case bp_memory:
{
wCmd = "bpm " + ToPtrString(va);
cmd = "bpm " + ToPtrString(va);
}
break;
@ -45,7 +45,7 @@ void Breakpoints::setBP(BPXTYPE type, duint va)
break;
}
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
/**
@ -57,30 +57,30 @@ void Breakpoints::setBP(BPXTYPE type, duint va)
*/
void Breakpoints::enableBP(const BRIDGEBP & bp)
{
QString wCmd = "";
QString cmd = "";
if(bp.type == bp_hardware)
{
wCmd = QString("bphwe \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("bphwe \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_normal)
{
wCmd = QString("be \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("be \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_memory)
{
wCmd = QString("bpme \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("bpme \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_dll)
{
wCmd = QString("LibrarianEnableBreakPoint \"%1\"").arg(QString(bp.mod));
cmd = QString("LibrarianEnableBreakPoint \"%1\"").arg(QString(bp.mod));
}
else if(bp.type == bp_exception)
{
wCmd = QString("EnableExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("EnableExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
}
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
/**
@ -96,21 +96,21 @@ void Breakpoints::enableBP(const BRIDGEBP & bp)
*/
void Breakpoints::enableBP(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
enableBP(wBPList.bp[wI]);
enableBP(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
/**
@ -122,30 +122,30 @@ void Breakpoints::enableBP(BPXTYPE type, duint va)
*/
void Breakpoints::disableBP(const BRIDGEBP & bp)
{
QString wCmd = "";
QString cmd = "";
if(bp.type == bp_hardware)
{
wCmd = QString("bphwd \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("bphwd \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_normal)
{
wCmd = QString("bd \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("bd \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_memory)
{
wCmd = QString("bpmd \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("bpmd \"%1\"").arg(ToPtrString(bp.addr));
}
else if(bp.type == bp_dll)
{
wCmd = QString("LibrarianDisableBreakPoint \"%1\"").arg(QString(bp.mod));
cmd = QString("LibrarianDisableBreakPoint \"%1\"").arg(QString(bp.mod));
}
else if(bp.type == bp_exception)
{
wCmd = QString("DisableExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("DisableExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
}
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
/**
@ -161,21 +161,21 @@ void Breakpoints::disableBP(const BRIDGEBP & bp)
*/
void Breakpoints::disableBP(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
disableBP(wBPList.bp[wI]);
disableBP(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
static QString getBpIdentifier(const BRIDGEBP & bp)
@ -198,35 +198,35 @@ static QString getBpIdentifier(const BRIDGEBP & bp)
*/
void Breakpoints::removeBP(const BRIDGEBP & bp)
{
QString wCmd = "";
QString cmd = "";
switch(bp.type)
{
case bp_normal:
wCmd = QString("bc \"%1\"").arg(getBpIdentifier(bp));
cmd = QString("bc \"%1\"").arg(getBpIdentifier(bp));
break;
case bp_hardware:
wCmd = QString("bphc \"%1\"").arg(getBpIdentifier(bp));
cmd = QString("bphc \"%1\"").arg(getBpIdentifier(bp));
break;
case bp_memory:
wCmd = QString("bpmc \"%1\"").arg(getBpIdentifier(bp));
cmd = QString("bpmc \"%1\"").arg(getBpIdentifier(bp));
break;
case bp_dll:
wCmd = QString("bcdll \"%1\"").arg(QString(bp.mod));
cmd = QString("bcdll \"%1\"").arg(QString(bp.mod));
break;
case bp_exception:
wCmd = QString("DeleteExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
cmd = QString("DeleteExceptionBPX \"%1\"").arg(ToPtrString(bp.addr));
break;
default:
break;
}
DbgCmdExecDirect(wCmd);
DbgCmdExecDirect(cmd);
}
/**
@ -242,40 +242,40 @@ void Breakpoints::removeBP(const BRIDGEBP & bp)
*/
void Breakpoints::removeBP(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
removeBP(wBPList.bp[wI]);
removeBP(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
void Breakpoints::removeBP(const QString & DLLName)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(bp_dll, &wBPList);
DbgGetBpList(bp_dll, &bpList);
// Find breakpoint at DLLName
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(QString(wBPList.bp[wI].mod) == DLLName)
if(QString(bpList.bp[i].mod) == DLLName)
{
removeBP(wBPList.bp[wI]);
removeBP(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
/**
@ -308,68 +308,68 @@ void Breakpoints::toggleBPByDisabling(const BRIDGEBP & bp)
*/
void Breakpoints::toggleBPByDisabling(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
toggleBPByDisabling(wBPList.bp[wI]);
toggleBPByDisabling(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
void Breakpoints::toggleBPByDisabling(const QString & DLLName)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(bp_dll, &wBPList);
DbgGetBpList(bp_dll, &bpList);
// Find breakpoint at module name
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(QString(wBPList.bp[wI].mod) == DLLName)
if(QString(bpList.bp[i].mod) == DLLName)
{
toggleBPByDisabling(wBPList.bp[wI]);
toggleBPByDisabling(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
void Breakpoints::toggleAllBP(BPXTYPE type, bool bEnable)
{
BPMAP wBPList;
BPMAP bpList;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
if(bEnable)
{
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
enableBP(wBPList.bp[wI]);
enableBP(bpList.bp[i]);
}
}
else
{
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
disableBP(wBPList.bp[wI]);
disableBP(bpList.bp[i]);
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
/**
@ -382,18 +382,18 @@ void Breakpoints::toggleAllBP(BPXTYPE type, bool bEnable)
*/
BPXSTATE Breakpoints::BPState(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
BPXSTATE result = bp_non_existent;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
if(wBPList.bp[wI].enabled)
if(bpList.bp[i].enabled)
{
result = bp_enabled;
break;
@ -405,32 +405,32 @@ BPXSTATE Breakpoints::BPState(BPXTYPE type, duint va)
}
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
return result;
}
bool Breakpoints::BPTrival(BPXTYPE type, duint va)
{
BPMAP wBPList;
BPMAP bpList;
bool trival = true;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoint at address VA
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
BRIDGEBP & bp = wBPList.bp[wI];
BRIDGEBP & bp = bpList.bp[i];
if(bp.addr == va)
{
trival = !(bp.breakCondition[0] || bp.logCondition[0] || bp.commandCondition[0] || bp.commandText[0] || bp.logText[0] || bp.name[0] || bp.fastResume || bp.silent);
break;
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
return trival;
}
@ -449,49 +449,49 @@ bool Breakpoints::BPTrival(BPXTYPE type, duint va)
*/
void Breakpoints::toggleBPByRemoving(BPXTYPE type, duint va)
{
BPMAP wBPList;
bool wNormalWasRemoved = false;
bool wMemoryWasRemoved = false;
bool wHardwareWasRemoved = false;
BPMAP bpList;
bool normalWasRemoved = false;
bool memoryWasRemoved = false;
bool hardwareWasRemoved = false;
// Get breakpoints list
DbgGetBpList(type, &wBPList);
DbgGetBpList(type, &bpList);
// Find breakpoints at address VA and remove them
for(int wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].addr == va)
if(bpList.bp[i].addr == va)
{
removeBP(wBPList.bp[wI]);
removeBP(bpList.bp[i]);
switch(wBPList.bp[wI].type)
switch(bpList.bp[i].type)
{
case bp_normal:
wNormalWasRemoved = true;
normalWasRemoved = true;
break;
case bp_memory:
wMemoryWasRemoved = true;
memoryWasRemoved = true;
break;
case bp_hardware:
wHardwareWasRemoved = true;
hardwareWasRemoved = true;
break;
default:
break;
}
}
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
if((type == bp_none || type == bp_normal) && (wNormalWasRemoved == false))
if((type == bp_none || type == bp_normal) && (normalWasRemoved == false))
{
setBP(bp_normal, va);
}
else if((type == bp_none || type == bp_memory) && (wMemoryWasRemoved == false))
else if((type == bp_none || type == bp_memory) && (memoryWasRemoved == false))
{
setBP(bp_memory, va);
}
else if((type == bp_none || type == bp_hardware) && (wHardwareWasRemoved == false))
else if((type == bp_none || type == bp_hardware) && (hardwareWasRemoved == false))
{
setBP(bp_hardware, va);
}

View File

@ -17,11 +17,11 @@ CommonActions::CommonActions(QWidget* parent, ActionHelperFuncs funcs, GetSelect
void CommonActions::build(MenuBuilder* builder, int actions)
{
// Condition Lambda
auto wIsDebugging = [this](QMenu*)
auto isDebugging = [this](QMenu*)
{
return mGetSelection() != 0 && DbgIsDebugging();
};
auto wIsValidReadPtrCallback = [this](QMenu*)
auto isValidReadPtr = [this](QMenu*)
{
duint ptr = 0;
DbgMemRead(mGetSelection(), (unsigned char*)&ptr, sizeof(duint));
@ -31,11 +31,11 @@ void CommonActions::build(MenuBuilder* builder, int actions)
// Menu action
if(actions & ActionDisasm)
{
builder->addAction(makeShortcutDescAction(DIcon(ArchValue("processor32", "processor64")), tr("Follow in Disassembler"), tr("Show this address in disassembler. Equivalent command \"d address\"."), std::bind(&CommonActions::followDisassemblySlot, this), "ActionFollowDisasm"), wIsDebugging);
builder->addAction(makeShortcutDescAction(DIcon(ArchValue("processor32", "processor64")), tr("Follow in Disassembler"), tr("Show this address in disassembler. Equivalent command \"d address\"."), std::bind(&CommonActions::followDisassemblySlot, this), "ActionFollowDisasm"), isDebugging);
}
if(actions & ActionDisasmData)
{
builder->addAction(makeCommandAction(DIcon("processor32"), ArchValue(tr("&Follow DWORD in Disassembler"), tr("&Follow QWORD in Disassembler")), "disasm [$]", "ActionFollowDwordQwordDisasm"), wIsValidReadPtrCallback);
builder->addAction(makeCommandAction(DIcon("processor32"), ArchValue(tr("&Follow DWORD in Disassembler"), tr("&Follow QWORD in Disassembler")), "disasm [$]", "ActionFollowDwordQwordDisasm"), isValidReadPtr);
}
if(actions & ActionDump)
{
@ -43,7 +43,7 @@ void CommonActions::build(MenuBuilder* builder, int actions)
}
if(actions & ActionDumpData)
{
builder->addAction(makeCommandAction(DIcon("dump"), ArchValue(tr("&Follow DWORD in Current Dump"), tr("&Follow QWORD in Current Dump")), "dump [$]", "ActionFollowDwordQwordDump"), wIsValidReadPtrCallback);
builder->addAction(makeCommandAction(DIcon("dump"), ArchValue(tr("&Follow DWORD in Current Dump"), tr("&Follow QWORD in Current Dump")), "dump [$]", "ActionFollowDwordQwordDump"), isValidReadPtr);
}
if(actions & ActionDumpN)
{
@ -74,7 +74,7 @@ void CommonActions::build(MenuBuilder* builder, int actions)
}
if(actions & ActionMemoryMap)
{
builder->addAction(makeCommandDescAction(DIcon("memmap_find_address_page"), tr("Follow in Memory Map"), tr("Show this address in memory map view. Equivalent command \"memmapdump address\"."), "memmapdump $", "ActionFollowMemMap"), wIsDebugging);
builder->addAction(makeCommandDescAction(DIcon("memmap_find_address_page"), tr("Follow in Memory Map"), tr("Show this address in memory map view. Equivalent command \"memmapdump address\"."), "memmapdump $", "ActionFollowMemMap"), isDebugging);
}
if(actions & ActionGraph)
{
@ -156,15 +156,15 @@ void CommonActions::build(MenuBuilder* builder, int actions)
}
if(actions & ActionLabel)
{
builder->addAction(makeShortcutAction(DIcon("label"), tr("Label Current Address"), std::bind(&CommonActions::setLabelSlot, this), "ActionSetLabel"), wIsDebugging);
builder->addAction(makeShortcutAction(DIcon("label"), tr("Label Current Address"), std::bind(&CommonActions::setLabelSlot, this), "ActionSetLabel"), isDebugging);
}
if(actions & ActionComment)
{
builder->addAction(makeShortcutAction(DIcon("comment"), tr("Comment"), std::bind(&CommonActions::setCommentSlot, this), "ActionSetComment"), wIsDebugging);
builder->addAction(makeShortcutAction(DIcon("comment"), tr("Comment"), std::bind(&CommonActions::setCommentSlot, this), "ActionSetComment"), isDebugging);
}
if(actions & ActionBookmark)
{
builder->addAction(makeShortcutDescAction(DIcon("bookmark_toggle"), tr("Toggle Bookmark"), tr("Set a bookmark here, or remove bookmark. Equivalent command \"bookmarkset address\"/\"bookmarkdel address\"."), std::bind(&CommonActions::setBookmarkSlot, this), "ActionToggleBookmark"), wIsDebugging);
builder->addAction(makeShortcutDescAction(DIcon("bookmark_toggle"), tr("Toggle Bookmark"), tr("Set a bookmark here, or remove bookmark. Equivalent command \"bookmarkset address\"/\"bookmarkdel address\"."), std::bind(&CommonActions::setBookmarkSlot, this), "ActionToggleBookmark"), isDebugging);
}
if(actions & ActionNewOrigin)
{
@ -231,19 +231,19 @@ void CommonActions::followDisassemblySlot()
void CommonActions::setLabelSlot()
{
duint wVA = mGetSelection();
duint va = mGetSelection();
LineEditDialog mLineEdit(widgetparent());
mLineEdit.setTextMaxLength(MAX_LABEL_SIZE - 2);
QString addr_text = ToPtrString(wVA);
QString addr_text = ToPtrString(va);
char label_text[MAX_COMMENT_SIZE] = "";
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
if(DbgGetLabelAt((duint)va, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
mLineEdit.setWindowTitle(tr("Add label at ") + addr_text);
restart:
if(mLineEdit.exec() != QDialog::Accepted)
return;
QByteArray utf8data = mLineEdit.editText.toUtf8();
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != wVA)
if(!utf8data.isEmpty() && DbgIsValidExpression(utf8data.constData()) && DbgValFromString(utf8data.constData()) != va)
{
QMessageBox msg(QMessageBox::Warning, tr("The label may be in use"),
tr("The label \"%1\" may be an existing label or a valid expression. Using such label might have undesired effects. Do you still want to continue?").arg(mLineEdit.editText),
@ -254,7 +254,7 @@ restart:
if(msg.exec() == QMessageBox::No)
goto restart;
}
if(!DbgSetLabelAt(wVA, utf8data.constData()))
if(!DbgSetLabelAt(va, utf8data.constData()))
SimpleErrorBox(widgetparent(), tr("Error!"), tr("DbgSetLabelAt failed!"));
GuiUpdateAllViews();
@ -264,12 +264,12 @@ void CommonActions::setCommentSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = mGetSelection();
duint va = mGetSelection();
LineEditDialog mLineEdit(widgetparent());
mLineEdit.setTextMaxLength(MAX_COMMENT_SIZE - 2);
QString addr_text = ToPtrString(wVA);
QString addr_text = ToPtrString(va);
char comment_text[MAX_COMMENT_SIZE] = "";
if(DbgGetCommentAt((duint)wVA, comment_text))
if(DbgGetCommentAt((duint)va, comment_text))
{
if(comment_text[0] == '\1') //automatic comment
mLineEdit.setText(QString(comment_text + 1));
@ -280,7 +280,7 @@ void CommonActions::setCommentSlot()
if(mLineEdit.exec() != QDialog::Accepted)
return;
QString comment = mLineEdit.editText.replace('\r', "").replace('\n', "");
if(!DbgSetCommentAt(wVA, comment.toUtf8().constData()))
if(!DbgSetCommentAt(va, comment.toUtf8().constData()))
SimpleErrorBox(widgetparent(), tr("Error!"), tr("DbgSetCommentAt failed!"));
static bool easter = isEaster();
@ -301,20 +301,20 @@ void CommonActions::setBookmarkSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = mGetSelection();
duint va = mGetSelection();
bool result;
result = DbgSetBookmarkAt(wVA, !DbgGetBookmarkAt(wVA));
result = DbgSetBookmarkAt(va, !DbgGetBookmarkAt(va));
if(!result)
SimpleErrorBox(widgetparent(), tr("Error!"), tr("DbgSetBookmarkAt failed!"));
GuiUpdateAllViews();
}
// Give a warning about the selected address is not executable
bool CommonActions::WarningBoxNotExecutable(const QString & text, duint wVA) const
bool CommonActions::WarningBoxNotExecutable(const QString & text, duint va) const
{
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(wVA, false))
if(DbgFunctions()->IsDepEnabled() && !DbgFunctions()->MemIsCodePage(va, false))
{
QMessageBox msgyn(QMessageBox::Warning, tr("Address %1 is not executable").arg(ToPtrString(wVA)), text, QMessageBox::Yes | QMessageBox::No, widgetparent());
QMessageBox msgyn(QMessageBox::Warning, tr("Address %1 is not executable").arg(ToPtrString(va)), text, QMessageBox::Yes | QMessageBox::No, widgetparent());
msgyn.setWindowIcon(DIcon("compile-warning"));
msgyn.setParent(widgetparent(), Qt::Dialog);
msgyn.setDefaultButton(QMessageBox::No);
@ -329,20 +329,20 @@ void CommonActions::toggleInt3BPActionSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = mGetSelection();
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
duint va = mGetSelection();
BPXTYPE bpType = DbgGetBpxTypeAt(va);
QString cmd;
if((wBpType & bp_normal) == bp_normal)
wCmd = "bc " + ToPtrString(wVA);
if((bpType & bp_normal) == bp_normal)
cmd = "bc " + ToPtrString(va);
else
{
if(!WarningBoxNotExecutable(tr("Setting software breakpoint here may result in crash. Do you really want to continue?"), wVA))
if(!WarningBoxNotExecutable(tr("Setting software breakpoint here may result in crash. Do you really want to continue?"), va))
return;
wCmd = "bp " + ToPtrString(wVA);
cmd = "bp " + ToPtrString(va);
}
DbgCmdExec(wCmd);
DbgCmdExec(cmd);
//emit Disassembly::repainted();
}
@ -373,20 +373,20 @@ void CommonActions::editSoftBpActionSlot()
void CommonActions::toggleHwBpActionSlot()
{
duint wVA = mGetSelection();
BPXTYPE wBpType = DbgGetBpxTypeAt(wVA);
QString wCmd;
duint va = mGetSelection();
BPXTYPE bpType = DbgGetBpxTypeAt(va);
QString cmd;
if((wBpType & bp_hardware) == bp_hardware)
if((bpType & bp_hardware) == bp_hardware)
{
wCmd = "bphwc " + ToPtrString(wVA);
cmd = "bphwc " + ToPtrString(va);
}
else
{
wCmd = "bphws " + ToPtrString(wVA);
cmd = "bphws " + ToPtrString(va);
}
DbgCmdExec(wCmd);
DbgCmdExec(cmd);
}
@ -412,40 +412,38 @@ void CommonActions::setHwBpOnSlot3ActionSlot()
void CommonActions::setHwBpAt(duint va, int slot)
{
int wI = 0;
int wSlotIndex = -1;
BPMAP wBPList;
QString wCmd = "";
DbgGetBpList(bp_hardware, &wBPList);
int slotIndex = -1;
BPMAP bpList = {};
DbgGetBpList(bp_hardware, &bpList);
// Find index of slot slot in the list
for(wI = 0; wI < wBPList.count; wI++)
for(int i = 0; i < bpList.count; i++)
{
if(wBPList.bp[wI].slot == (unsigned short)slot)
if(bpList.bp[i].slot == (unsigned short)slot)
{
wSlotIndex = wI;
slotIndex = i;
break;
}
}
if(wSlotIndex < 0) // Slot not used
QString cmd;
if(slotIndex < 0) // Slot not used
{
wCmd = "bphws " + ToPtrString(va);
DbgCmdExec(wCmd);
cmd = "bphws " + ToPtrString(va);
DbgCmdExec(cmd);
}
else // Slot used
{
wCmd = "bphwc " + ToPtrString((duint)(wBPList.bp[wSlotIndex].addr));
DbgCmdExec(wCmd);
cmd = "bphwc " + ToPtrString((duint)(bpList.bp[slotIndex].addr));
DbgCmdExec(cmd);
Sleep(200);
wCmd = "bphws " + ToPtrString(va);
DbgCmdExec(wCmd);
cmd = "bphws " + ToPtrString(va);
DbgCmdExec(cmd);
}
if(wBPList.count)
BridgeFree(wBPList.bp);
if(bpList.count)
BridgeFree(bpList.bp);
}
void CommonActions::graphSlot()
@ -458,21 +456,21 @@ void CommonActions::setNewOriginHereActionSlot()
{
if(!DbgIsDebugging())
return;
duint wVA = mGetSelection();
if(!WarningBoxNotExecutable(tr("Setting new origin here may result in crash. Do you really want to continue?"), wVA))
duint va = mGetSelection();
if(!WarningBoxNotExecutable(tr("Setting new origin here may result in crash. Do you really want to continue?"), va))
return;
QString wCmd = "cip=" + ToPtrString(wVA);
DbgCmdExec(wCmd);
QString cmd = "cip=" + ToPtrString(va);
DbgCmdExec(cmd);
}
void CommonActions::createThreadSlot()
{
duint wVA = mGetSelection();
if(!WarningBoxNotExecutable(tr("Creating new thread here may result in crash. Do you really want to continue?"), wVA))
duint va = mGetSelection();
if(!WarningBoxNotExecutable(tr("Creating new thread here may result in crash. Do you really want to continue?"), va))
return;
WordEditDialog argWindow(widgetparent());
argWindow.setup(tr("Argument for the new thread"), 0, sizeof(duint));
if(argWindow.exec() != QDialog::Accepted)
return;
DbgCmdExec(QString("createthread %1, %2").arg(ToPtrString(wVA)).arg(ToPtrString(argWindow.getVal())));
DbgCmdExec(QString("createthread %1, %2").arg(ToPtrString(va)).arg(ToPtrString(argWindow.getVal())));
}

View File

@ -74,6 +74,6 @@ public slots:
void createThreadSlot();
private:
GetSelectionFunc mGetSelection;
bool WarningBoxNotExecutable(const QString & text, duint wVA) const;
bool WarningBoxNotExecutable(const QString & text, duint va) const;
QWidget* widgetparent() const;
};

View File

@ -264,7 +264,7 @@ QString FILETIMEToDate(const FILETIME & date)
localdate.dwHighDateTime = time100ns >> 32;
localdate.dwLowDateTime = time100ns & 0xFFFFFFFF;
if(qdate != QDate::currentDate())
return QLocale(QString(currentLocale)).toString(qdate) + FILETIMEToTime(localdate);
return QLocale(QString(gCurrentLocale)).toString(qdate) + FILETIMEToTime(localdate);
else // today
return FILETIMEToTime(localdate);
}

View File

@ -80,9 +80,9 @@ template<typename T>
inline QString ToFloatingString(const void* buffer, int precision)
{
auto value = *(const T*)buffer;
std::stringstream wFloatingStr;
wFloatingStr << std::setprecision(precision) << value;
return QString::fromStdString(wFloatingStr.str());
std::stringstream floatingStr;
floatingStr << std::setprecision(precision) << value;
return QString::fromStdString(floatingStr.str());
}
template<typename T>

View File

@ -5,17 +5,17 @@
class VaHistory
{
public:
void addVaToHistory(duint parVa)
void addVaToHistory(duint va)
{
//truncate everything right from the current VA
if(mVaHistory.size() && mCurrentVa < mVaHistory.size() - 1) //mCurrentVa is not the last
mVaHistory.erase(mVaHistory.begin() + mCurrentVa + 1, mVaHistory.end());
//do not have 2x the same va in a row
if(!mVaHistory.size() || mVaHistory.back() != parVa)
if(!mVaHistory.size() || mVaHistory.back() != va)
{
mCurrentVa++;
mVaHistory.push_back(parVa);
mVaHistory.push_back(va);
}
}

View File

@ -61,7 +61,7 @@ bool MyApplication::notify(QObject* receiver, QEvent* event)
}
static Configuration* mConfiguration;
char currentLocale[MAX_SETTING_SIZE] = "";
char gCurrentLocale[MAX_SETTING_SIZE] = "";
// Boom... VS does not support "thread_local"... and cannot use "__declspec(thread)" in a DLL... https://blogs.msdn.microsoft.com/oldnewthing/20101122-00/?p=12233
// Simulating Thread Local Storage with a map...
std::map<DWORD, TranslatedStringStorage>* TLS_TranslatedStringMap; //key = Thread Id, value = Translate Buffer
@ -149,23 +149,23 @@ int main(int argc, char* argv[])
#endif
// Get the language setting
if(!BridgeSettingGet("Engine", "Language", currentLocale) || !isValidLocale(currentLocale))
if(!BridgeSettingGet("Engine", "Language", gCurrentLocale) || !isValidLocale(gCurrentLocale))
{
QStringList uiLanguages = QLocale::system().uiLanguages();
QString sysLocale = uiLanguages.size() ? QLocale(uiLanguages[0]).name() : QLocale::system().name();
strcpy_s(currentLocale, sysLocale.toUtf8().constData());
BridgeSettingSet("Engine", "Language", currentLocale);
strcpy_s(gCurrentLocale, sysLocale.toUtf8().constData());
BridgeSettingSet("Engine", "Language", gCurrentLocale);
}
// Load translations for Qt
QTranslator qtTranslator;
if(qtTranslator.load(QString("qt_%1").arg(currentLocale), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
if(qtTranslator.load(QString("qt_%1").arg(gCurrentLocale), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
application.installTranslator(&qtTranslator);
//x64dbg and x32dbg can share the same translation
QTranslator x64dbgTranslator;
auto path = QString("%1/../translations").arg(QCoreApplication::applicationDirPath());
if(x64dbgTranslator.load(QString("x64dbg_%1").arg(currentLocale), path))
if(x64dbgTranslator.load(QString("x64dbg_%1").arg(gCurrentLocale), path))
application.installTranslator(&x64dbgTranslator);
TLS_TranslatedStringMap = new std::map<DWORD, TranslatedStringStorage>();

View File

@ -21,7 +21,7 @@ public:
};
int main(int argc, char* argv[]);
extern char currentLocale[MAX_SETTING_SIZE];
extern char gCurrentLocale[MAX_SETTING_SIZE];
struct TranslatedStringStorage
{