1
0
Fork 0

Switch to xrefs in InfoBox and some XrefBrowseDialog improvements (#1585)

* Some minor cpu info box enhancements

* Switch to xrefs in InfoBox and some XrefBrowseDialog improvements

* Added search boxes and saving symbols splitters and columns layout

* Using .toULongLong for both platforms

* casting added

* Added option rva addresses in graph
This commit is contained in:
ThunderCls 2017-05-15 17:32:31 -04:00 committed by Duncan Ogilvie
parent 06db8b4856
commit 8829c09300
21 changed files with 262 additions and 207 deletions

View File

@ -46,12 +46,8 @@ QString SearchListViewTable::paintContent(QPainter* painter, dsint rowBase, int
isaddr = false;
if(!getRowCount())
isaddr = false;
ULONGLONG val = 0;
duint wVA;
if(sscanf_s(text.toUtf8().constData(), "%llX", &val) != 1 || !val)
isaddr = false;
else
wVA = val;
duint wVA = duint(text.toULongLong(&isaddr, 16));
auto wIsTraced = isaddr && DbgFunctions()->GetTraceRecordHitCount(wVA) != 0;
QColor lineBackgroundColor;
bool isBackgroundColorSet;

View File

@ -1,6 +1,7 @@
#include "CPUInfoBox.h"
#include "Configuration.h"
#include "WordEditDialog.h"
#include "XrefBrowseDialog.h"
#include "Bridge.h"
CPUInfoBox::CPUInfoBox(StdTable* parent) : StdTable(parent)
@ -406,10 +407,14 @@ void CPUInfoBox::modifySlot()
}
}
void CPUInfoBox::findReferencesSlot()
void CPUInfoBox::findXReferencesSlot()
{
DbgCmdExec(QString("findref ") + QString().number(curAddr, 16).toUtf8().constData());
emit displayReferencesWidget();
if(!DbgIsDebugging())
return;
if(!mXrefDlg)
mXrefDlg = new XrefBrowseDialog(this);
mXrefDlg->setup(curAddr);
mXrefDlg->showNormal();
}
void CPUInfoBox::addModifyValueMenuItem(QMenu* menu, QString name, duint value)
@ -650,7 +655,7 @@ void CPUInfoBox::contextMenuSlot(QPoint pos)
setupWatchMenu(&wWatchMenu, curAddr);
wMenu.addMenu(&wWatchMenu);
if(!getInfoLine(2).isEmpty())
wMenu.addAction(makeAction(DIcon("find.png"), tr("&Show References"), SLOT(findReferencesSlot())));
wMenu.addAction(makeAction(DIcon("xrefs.png"), tr("&Show References"), SLOT(findXReferencesSlot())));
QMenu wCopyMenu(tr("&Copy"), this);
setupCopyMenu(&wCopyMenu);
if(DbgIsDebugging())

View File

@ -4,6 +4,7 @@
#include "StdTable.h"
class WordEditDialog;
class XrefBrowseDialog;
class CPUInfoBox : public StdTable
{
@ -25,16 +26,13 @@ public slots:
void contextMenuSlot(QPoint pos);
void followActionSlot();
void modifySlot();
void findReferencesSlot();
void findXReferencesSlot();
void copyAddress();
void copyRva();
void copyOffset();
void doubleClickedSlot();
void addInfoLine(const QString & infoLine);
signals:
void displayReferencesWidget();
private:
dsint curAddr;
dsint curRva;
@ -45,6 +43,8 @@ private:
void clear();
void setupContextMenu();
XrefBrowseDialog* mXrefDlg = nullptr;
QAction* mCopyAddressAction;
QAction* mCopyRvaAction;
QAction* mCopyOffsetAction;

View File

@ -1486,6 +1486,7 @@ void DisassemblerGraphView::tokenizerConfigUpdatedSlot()
void DisassemblerGraphView::loadCurrentGraph()
{
bool showGraphRva = ConfigBool("Gui", "ShowGraphRva");
Analysis anal;
anal.update_id = this->update_id + 1;
anal.entry = currentGraph.entryPoint;
@ -1516,6 +1517,19 @@ void DisassemblerGraphView::loadCurrentGraph()
Instruction_t instrTok = disasm.DisassembleAt((byte_t*)nodeInstr.data, sizeof(nodeInstr.data), 0, addr, false);
RichTextPainter::List richText;
CapstoneTokenizer::TokenToRichText(instrTok.tokens, richText, 0);
// add rva to node instruction text
if(showGraphRva)
{
RichTextPainter::CustomRichText_t rvaText;
rvaText.highlight = false;
rvaText.textColor = mAddressColor;
rvaText.textBackground = mAddressBackgroundColor;
rvaText.text = QString().number(instrTok.rva, 16).toUpper().trimmed() + " ";
rvaText.flags = rvaText.textBackground.alpha() ? RichTextPainter::FlagAll : RichTextPainter::FlagColor;
richText.insert(richText.begin(), rvaText);
}
auto size = instrTok.length;
instr.addr = addr;
instr.opcode.resize(size);
@ -1687,6 +1701,8 @@ void DisassemblerGraphView::colorsUpdatedSlot()
mLabelBackgroundColor = ConfigColor("DisassemblyLabelBackgroundColor");
mCipBackgroundColor = ConfigColor("DisassemblyCipBackgroundColor");
mCipColor = ConfigColor("DisassemblyCipColor");
mAddressColor = ConfigColor("DisassemblyAddressColor");
mAddressBackgroundColor = ConfigColor("DisassemblyAddressBackgroundColor");
jmpColor = ConfigColor("GraphJmpColor");
brtrueColor = ConfigColor("GraphBrtrueColor");

View File

@ -335,6 +335,8 @@ private:
QColor mCipColor;
QColor mCipBackgroundColor;
QColor graphNodeColor;
QColor mAddressColor;
QColor mAddressBackgroundColor;
BridgeCFGraph currentGraph;
std::unordered_map<duint, duint> currentBlockMap;

View File

@ -6,47 +6,72 @@
#include "StringUtil.h"
#include "ReferenceView.h"
#include "MainWindow.h"
#include "HandlesWindowViewTable.h"
#include "MessagesBreakpoints.h"
#include <QVBoxLayout>
HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
{
mHandlesTable = new StdTable(this);
mHandlesTable->setWindowTitle("Handles");
mHandlesTable->setDrawDebugOnly(true);
int wCharWidth = mHandlesTable->getCharWidth();
mHandlesTable->setContextMenuPolicy(Qt::CustomContextMenu);
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Type"), false);
mHandlesTable->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), false);
mHandlesTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), false);
mHandlesTable->addColumnAt(8 + 16 * wCharWidth, tr("Access"), false);
mHandlesTable->addColumnAt(8 + wCharWidth * 20, tr("Name"), false);
mHandlesTable->loadColumnFromConfig("Handle");
mWindowsTable = new HandlesWindowViewTable(this);
mWindowsTable->setWindowTitle("Windows");
mWindowsTable->setDrawDebugOnly(true);
mWindowsTable->setContextMenuPolicy(Qt::CustomContextMenu);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), false);
mWindowsTable->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), false);
mWindowsTable->addColumnAt(8 + 120 * wCharWidth, tr("Title"), false);
mWindowsTable->addColumnAt(8 + 40 * wCharWidth, tr("Class"), false);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), false);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("Style"), false);
mWindowsTable->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), false);
mWindowsTable->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), false);
mWindowsTable->addColumnAt(8 + 20 * wCharWidth, tr("Size"), false);
mWindowsTable->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), false);
mHandlesTable = new SearchListView(true, this, true);
mHandlesTable->mList->setWindowTitle("Handles");
mHandlesTable->mSearchStartCol = 0;
int wCharWidth = mHandlesTable->mList->getCharWidth();
// Setup handles list
mHandlesTable->mList->setDrawDebugOnly(true);
mHandlesTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Type"), false);
mHandlesTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), false);
mHandlesTable->mList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), false);
mHandlesTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Access"), false);
mHandlesTable->mList->addColumnAt(8 + wCharWidth * 20, tr("Name"), false);
mHandlesTable->mList->loadColumnFromConfig("Handle");
// Setup search list
mHandlesTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Type"), false);
mHandlesTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Type number"), false);
mHandlesTable->mSearchList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Handle"), false);
mHandlesTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Access"), false);
mHandlesTable->mSearchList->addColumnAt(8 + wCharWidth * 20, tr("Name"), false);
mTcpConnectionsTable = new StdTable(this);
mWindowsTable = new SearchListView(true, this, true);
mWindowsTable->mList->setWindowTitle("Windows");
mWindowsTable->mSearchStartCol = 0;
// Setup windows list
mWindowsTable->mList->setDrawDebugOnly(true);
mWindowsTable->mList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), false);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), false);
mWindowsTable->mList->addColumnAt(8 + 120 * wCharWidth, tr("Title"), false);
mWindowsTable->mList->addColumnAt(8 + 40 * wCharWidth, tr("Class"), false);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), false);
mWindowsTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("Style"), false);
mWindowsTable->mList->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), false);
mWindowsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), false);
mWindowsTable->mList->addColumnAt(8 + 20 * wCharWidth, tr("Size"), false);
mWindowsTable->mList->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), false);
mWindowsTable->mList->loadColumnFromConfig("Window");
// Setup search list
mWindowsTable->mSearchList->addColumnAt(8 + sizeof(duint) * 2 * wCharWidth, tr("Proc"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Handle"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 120 * wCharWidth, tr("Title"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 40 * wCharWidth, tr("Class"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Thread"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("Style"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 16 * wCharWidth, tr("StyleEx"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("Parent"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 20 * wCharWidth, tr("Size"), false);
mWindowsTable->mSearchList->addColumnAt(8 + 6 * wCharWidth, tr("Enable"), false);
mTcpConnectionsTable = new SearchListView(true, this, true);
mTcpConnectionsTable->setWindowTitle("TcpConnections");
mTcpConnectionsTable->setDrawDebugOnly(true);
mTcpConnectionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), false);
mTcpConnectionsTable->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), false);
mTcpConnectionsTable->addColumnAt(8 + 8 * wCharWidth, tr("State"), false);
mTcpConnectionsTable->loadColumnFromConfig("TcpConnection");
mHandlesTable->mSearchStartCol = 0;
// create tcp list
mTcpConnectionsTable->mList->setDrawDebugOnly(true);
mTcpConnectionsTable->mList->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), false);
mTcpConnectionsTable->mList->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), false);
mTcpConnectionsTable->mList->addColumnAt(8 + 8 * wCharWidth, tr("State"), false);
mTcpConnectionsTable->mList->loadColumnFromConfig("TcpConnection");
// create search list
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 64 * wCharWidth, tr("Remote address"), false);
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 64 * wCharWidth, tr("Local address"), false);
mTcpConnectionsTable->mSearchList->addColumnAt(8 + 8 * wCharWidth, tr("State"), false);
/*
mHeapsTable = new ReferenceView(this);
mHeapsTable->setWindowTitle("Heaps");
@ -106,18 +131,18 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mActionMessageProcBP = new QAction(DIcon("breakpoint_execute.png"), tr("Message Breakpoint in Proc"), this);
connect(mActionMessageProcBP, SIGNAL(triggered()), this, SLOT(messagesBPSlot()));
connect(mHandlesTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(handlesTableContextMenuSlot(const QPoint &)));
connect(mWindowsTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(windowsTableContextMenuSlot(const QPoint &)));
connect(mTcpConnectionsTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(tcpConnectionsTableContextMenuSlot(const QPoint &)));
connect(mHandlesTable, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(handlesTableContextMenuSlot(QMenu*)));
connect(mWindowsTable, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(windowsTableContextMenuSlot(QMenu*)));
connect(mTcpConnectionsTable, SIGNAL(listContextMenuSignal(QMenu*)), this, SLOT(tcpConnectionsTableContextMenuSlot(QMenu*)));
connect(mPrivilegesTable, SIGNAL(contextMenuSignal(const QPoint &)), this, SLOT(privilegesTableContextMenuSlot(const QPoint &)));
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcuts()));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(dbgStateChanged(DBGSTATE)));
if(!IsWindowsVistaOrGreater())
{
mTcpConnectionsTable->setRowCount(1);
mTcpConnectionsTable->setCellContent(0, 0, tr("TCP Connection enumeration is only available on Windows Vista or greater."));
mTcpConnectionsTable->reloadData();
mTcpConnectionsTable->mList->setRowCount(1);
mTcpConnectionsTable->mList->setCellContent(0, 0, tr("TCP Connection enumeration is only available on Windows Vista or greater."));
mTcpConnectionsTable->mList->reloadData();
}
reloadData();
refreshShortcuts();
@ -135,12 +160,12 @@ void HandlesView::reloadData()
}
else
{
mHandlesTable->setRowCount(0);
mHandlesTable->reloadData();
mWindowsTable->setRowCount(0);
mWindowsTable->reloadData();
mTcpConnectionsTable->setRowCount(0);
mTcpConnectionsTable->reloadData();
mHandlesTable->mList->setRowCount(0);
mHandlesTable->mList->reloadData();
mWindowsTable->mList->setRowCount(0);
mWindowsTable->mList->reloadData();
mTcpConnectionsTable->mList->setRowCount(0);
mTcpConnectionsTable->mList->reloadData();
//mHeapsTable->setRowCount(0);
//mHeapsTable->reloadData();
mPrivilegesTable->setRowCount(0);
@ -159,87 +184,81 @@ void HandlesView::dbgStateChanged(DBGSTATE state)
reloadData();
}
void HandlesView::handlesTableContextMenuSlot(const QPoint & pos)
void HandlesView::handlesTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mHandlesTable;
QMenu wMenu;
StdTable & table = *mHandlesTable->mCurList;
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
wMenu.addAction(mActionRefresh);
wMenu->addAction(mActionRefresh);
if(table.getRowCount())
{
wMenu.addAction(mActionCloseHandle);
wMenu->addAction(mActionCloseHandle);
table.setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
}
wMenu.exec(table.mapToGlobal(pos));
}
void HandlesView::windowsTableContextMenuSlot(const QPoint & pos)
void HandlesView::windowsTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mWindowsTable;
QMenu wMenu;
StdTable & table = *mWindowsTable->mCurList;
QMenu wCopyMenu(tr("Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
wMenu.addAction(mActionRefresh);
wMenu->addAction(mActionRefresh);
if(table.getRowCount())
{
if(table.getCellContent(table.getInitialSelection(), 9) == tr("Enabled"))
{
mActionDisableWindow->setText(tr("Disable window"));
wMenu.addAction(mActionDisableWindow);
wMenu->addAction(mActionDisableWindow);
}
else
{
mActionEnableWindow->setText(tr("Enable window"));
wMenu.addAction(mActionEnableWindow);
wMenu->addAction(mActionEnableWindow);
}
wMenu.addAction(mActionFollowProc);
wMenu.addAction(mActionToggleProcBP);
wMenu.addAction(mActionMessageProcBP);
wMenu.addSeparator();
wMenu->addAction(mActionFollowProc);
wMenu->addAction(mActionToggleProcBP);
wMenu->addAction(mActionMessageProcBP);
wMenu->addSeparator();
table.setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
}
wMenu.exec(table.mapToGlobal(pos));
}
void HandlesView::tcpConnectionsTableContextMenuSlot(const QPoint & pos)
void HandlesView::tcpConnectionsTableContextMenuSlot(QMenu* wMenu)
{
if(!DbgIsDebugging())
return;
StdTable & table = *mTcpConnectionsTable;
QMenu wMenu;
StdTable & table = *mTcpConnectionsTable->mCurList;
QMenu wCopyMenu(tr("&Copy"), this);
wCopyMenu.setIcon(DIcon("copy.png"));
wMenu.addAction(mActionRefresh);
wMenu->addAction(mActionRefresh);
if(table.getRowCount())
{
table.setupCopyMenu(&wCopyMenu);
if(wCopyMenu.actions().length())
{
wMenu.addSeparator();
wMenu.addMenu(&wCopyMenu);
wMenu->addSeparator();
wMenu->addMenu(&wCopyMenu);
}
}
wMenu.exec(table.mapToGlobal(pos));
}
void HandlesView::privilegesTableContextMenuSlot(const QPoint & pos)
@ -279,7 +298,7 @@ void HandlesView::privilegesTableContextMenuSlot(const QPoint & pos)
void HandlesView::closeHandleSlot()
{
DbgCmdExec(QString("handleclose %1").arg(mHandlesTable->getCellContent(mHandlesTable->getInitialSelection(), 2)).toUtf8().constData());
DbgCmdExec(QString("handleclose %1").arg(mHandlesTable->mCurList->getCellContent(mHandlesTable->mCurList->getInitialSelection(), 2)).toUtf8().constData());
enumHandles();
}
@ -319,31 +338,31 @@ void HandlesView::disableAllPrivilegesSlot()
void HandlesView::enableWindowSlot()
{
DbgCmdExec(QString("EnableWindow %1").arg(mWindowsTable->getCellContent(mWindowsTable->getInitialSelection(), 0)).toUtf8().constData());
DbgCmdExec(QString("EnableWindow %1").arg(mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 1)).toUtf8().constData());
enumWindows();
}
void HandlesView::disableWindowSlot()
{
DbgCmdExec(QString("DisableWindow %1").arg(mWindowsTable->getCellContent(mWindowsTable->getInitialSelection(), 0)).toUtf8().constData());
DbgCmdExec(QString("DisableWindow %1").arg(mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 1)).toUtf8().constData());
enumWindows();
}
void HandlesView::followInDisasmSlot()
{
DbgCmdExec(QString("disasm %1").arg(mWindowsTable->getCellContent(mWindowsTable->getInitialSelection(), 1)).toUtf8().constData());
DbgCmdExec(QString("disasm %1").arg(mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 0)).toUtf8().constData());
}
void HandlesView::toggleBPSlot()
{
StdTable & mCurList = *mWindowsTable;
StdTable & mCurList = *mWindowsTable->mCurList;
if(!DbgIsDebugging())
return;
if(!mCurList.getRowCount())
return;
QString addrText = mCurList.getCellContent(mCurList.getInitialSelection(), 1).toUtf8().constData();
QString addrText = mCurList.getCellContent(mCurList.getInitialSelection(), 0).toUtf8().constData();
duint wVA;
if(!DbgFunctions()->ValFromString(addrText.toUtf8().constData(), &wVA))
return;
@ -363,14 +382,14 @@ void HandlesView::toggleBPSlot()
void HandlesView::messagesBPSlot()
{
StdTable & mCurList = *mWindowsTable;
StdTable & mCurList = *mWindowsTable->mCurList;
MessagesBreakpoints::MsgBreakpointData mbpData;
if(!mCurList.getRowCount())
return;
mbpData.wndHandle = mCurList.getCellContent(mCurList.getInitialSelection(), 0).toUtf8().constData();
mbpData.procVA = mCurList.getCellContent(mCurList.getInitialSelection(), 1).toUtf8().constData();
mbpData.wndHandle = mCurList.getCellContent(mCurList.getInitialSelection(), 1).toUtf8().constData();
mbpData.procVA = mCurList.getCellContent(mCurList.getInitialSelection(), 0).toUtf8().constData();
MessagesBreakpoints messagesBPDialog(mbpData, this);
messagesBPDialog.exec();
@ -384,23 +403,23 @@ void HandlesView::enumHandles()
if(DbgFunctions()->EnumHandles(&handles))
{
auto count = handles.Count();
mHandlesTable->setRowCount(count);
mHandlesTable->mList->setRowCount(count);
for(auto i = 0; i < count; i++)
{
const HANDLEINFO & handle = handles[i];
char name[MAX_STRING_SIZE] = "";
char typeName[MAX_STRING_SIZE] = "";
DbgFunctions()->GetHandleName(handle.Handle, name, sizeof(name), typeName, sizeof(typeName));
mHandlesTable->setCellContent(i, 0, typeName);
mHandlesTable->setCellContent(i, 1, ToHexString(handle.TypeNumber));
mHandlesTable->setCellContent(i, 2, ToHexString(handle.Handle));
mHandlesTable->setCellContent(i, 3, ToHexString(handle.GrantedAccess));
mHandlesTable->setCellContent(i, 4, name);
mHandlesTable->mList->setCellContent(i, 0, typeName);
mHandlesTable->mList->setCellContent(i, 1, ToHexString(handle.TypeNumber));
mHandlesTable->mList->setCellContent(i, 2, ToHexString(handle.Handle));
mHandlesTable->mList->setCellContent(i, 3, ToHexString(handle.GrantedAccess));
mHandlesTable->mList->setCellContent(i, 4, name);
}
}
else
mHandlesTable->setRowCount(0);
mHandlesTable->reloadData();
mHandlesTable->mList->setRowCount(0);
mHandlesTable->mList->reloadData();
}
//Enumerate windows and update windows table
void HandlesView::enumWindows()
@ -409,35 +428,35 @@ void HandlesView::enumWindows()
if(DbgFunctions()->EnumWindows(&windows))
{
auto count = windows.Count();
mWindowsTable->setRowCount(count);
mWindowsTable->mList->setRowCount(count);
for(auto i = 0; i < count; i++)
{
mWindowsTable->setCellContent(i, 0, ToHexString(windows[i].handle));
mWindowsTable->setCellContent(i, 1, ToPtrString(windows[i].wndProc));
mWindowsTable->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->setCellContent(i, 3, QString(windows[i].windowClass));
mWindowsTable->mList->setCellContent(i, 0, ToPtrString(windows[i].wndProc));
mWindowsTable->mList->setCellContent(i, 1, ToHexString(windows[i].handle));
mWindowsTable->mList->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->mList->setCellContent(i, 3, QString(windows[i].windowClass));
char threadname[MAX_THREAD_NAME_SIZE];
if(DbgFunctions()->ThreadGetName(windows[i].threadId, threadname))
mWindowsTable->setCellContent(i, 4, QString::fromUtf8(threadname));
mWindowsTable->mList->setCellContent(i, 4, QString::fromUtf8(threadname));
else if(Config()->getBool("Gui", "PidInHex"))
mWindowsTable->setCellContent(i, 4, ToHexString(windows[i].threadId));
mWindowsTable->mList->setCellContent(i, 4, ToHexString(windows[i].threadId));
else
mWindowsTable->setCellContent(i, 4, QString::number(windows[i].threadId));
mWindowsTable->mList->setCellContent(i, 4, QString::number(windows[i].threadId));
//Style
mWindowsTable->setCellContent(i, 5, ToHexString(windows[i].style));
mWindowsTable->mList->setCellContent(i, 5, ToHexString(windows[i].style));
//StyleEx
mWindowsTable->setCellContent(i, 6, ToHexString(windows[i].styleEx));
mWindowsTable->setCellContent(i, 7, ToHexString(windows[i].parent) + (windows[i].parent == ((duint)GetDesktopWindow()) ? tr(" (Desktop window)") : ""));
mWindowsTable->mList->setCellContent(i, 6, ToHexString(windows[i].styleEx));
mWindowsTable->mList->setCellContent(i, 7, ToHexString(windows[i].parent) + (windows[i].parent == ((duint)GetDesktopWindow()) ? tr(" (Desktop window)") : ""));
//Size
QString sizeText = QString("(%1,%2);%3x%4").arg(windows[i].position.left).arg(windows[i].position.top)
.arg(windows[i].position.right - windows[i].position.left).arg(windows[i].position.bottom - windows[i].position.top);
mWindowsTable->setCellContent(i, 8, sizeText);
mWindowsTable->setCellContent(i, 9, windows[i].enabled != FALSE ? tr("Enabled") : tr("Disabled"));
mWindowsTable->mList->setCellContent(i, 8, sizeText);
mWindowsTable->mList->setCellContent(i, 9, windows[i].enabled != FALSE ? tr("Enabled") : tr("Disabled"));
}
}
else
mWindowsTable->setRowCount(0);
mWindowsTable->reloadData();
mWindowsTable->mList->setRowCount(0);
mWindowsTable->mList->reloadData();
}
//Enumerate privileges and update privileges table
@ -507,20 +526,20 @@ void HandlesView::enumTcpConnections()
if(DbgFunctions()->EnumTcpConnections(&connections))
{
auto count = connections.Count();
mTcpConnectionsTable->setRowCount(count);
mTcpConnectionsTable->mList->setRowCount(count);
for(auto i = 0; i < count; i++)
{
const TCPCONNECTIONINFO & connection = connections[i];
auto remoteText = QString("%1:%2").arg(connection.RemoteAddress).arg(connection.RemotePort);
mTcpConnectionsTable->setCellContent(i, 0, remoteText);
mTcpConnectionsTable->mList->setCellContent(i, 0, remoteText);
auto localText = QString("%1:%2").arg(connection.LocalAddress).arg(connection.LocalPort);
mTcpConnectionsTable->setCellContent(i, 1, localText);
mTcpConnectionsTable->setCellContent(i, 2, connection.StateText);
mTcpConnectionsTable->mList->setCellContent(i, 1, localText);
mTcpConnectionsTable->mList->setCellContent(i, 2, connection.StateText);
}
}
else
mTcpConnectionsTable->setRowCount(0);
mTcpConnectionsTable->reloadData();
mTcpConnectionsTable->mList->setRowCount(0);
mTcpConnectionsTable->mList->reloadData();
}
/*
//Enumerate Heaps and update Heaps table

View File

@ -8,7 +8,8 @@ class StdTable;
class ReferenceView;
class QVBoxLayout;
class LabeledSplitter;
class HandlesWindowViewTable;
class SearchListView;
class QMenu;
class HandlesView : public QWidget
{
@ -21,9 +22,9 @@ public slots:
void refreshShortcuts();
void dbgStateChanged(DBGSTATE state);
void handlesTableContextMenuSlot(const QPoint & pos);
void tcpConnectionsTableContextMenuSlot(const QPoint & pos);
void windowsTableContextMenuSlot(const QPoint & pos);
void handlesTableContextMenuSlot(QMenu* wMenu);
void tcpConnectionsTableContextMenuSlot(QMenu* wMenu);
void windowsTableContextMenuSlot(QMenu*);
void privilegesTableContextMenuSlot(const QPoint & pos);
void closeHandleSlot();
@ -40,9 +41,9 @@ public slots:
private:
QVBoxLayout* mVertLayout;
LabeledSplitter* mSplitter;
StdTable* mHandlesTable;
StdTable* mTcpConnectionsTable;
StdTable* mWindowsTable;
SearchListView* mHandlesTable;
SearchListView* mTcpConnectionsTable;
SearchListView* mWindowsTable;
//ReferenceView* mHeapsTable;
StdTable* mPrivilegesTable;

View File

@ -1,43 +0,0 @@
#include "HandlesWindowViewTable.h"
#include "Configuration.h"
#include "Bridge.h"
HandlesWindowViewTable::HandlesWindowViewTable(QWidget* parent)
: StdTable(parent)
{
updateColors();
}
void HandlesWindowViewTable::updateColors()
{
StdTable::updateColors();
mBpBackgroundColor = ConfigColor("DisassemblyBreakpointBackgroundColor");
mBpColor = ConfigColor("DisassemblyBreakpointColor");
}
QString HandlesWindowViewTable::paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h)
{
QString ret = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);
if(col == 1) // proc address
{
QString bpAddrStr = getCellContent(rowBase + rowOffset, col);
bool valid = false;
#ifdef _WIN64
duint bpAddr = bpAddrStr.toULongLong(&valid, 16);
#else //x86
duint bpAddr = bpAddrStr.toULong(&valid, 16);
#endif //_WIN64
BPXTYPE wBpType = DbgGetBpxTypeAt(bpAddr);
if(wBpType != bp_none)
{
painter->fillRect(QRect(x, y, w, h), QBrush(mBpBackgroundColor));
painter->setPen(QPen(mBpColor));
painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, bpAddrStr);
ret = "";
}
}
return ret;
}

View File

@ -1,22 +0,0 @@
#ifndef HANDLESWINDOWVIEWTABLE_H
#define HANDLESWINDOWVIEWTABLE_H
#include "StdTable.h"
class HandlesWindowViewTable : public StdTable
{
Q_OBJECT
public:
explicit HandlesWindowViewTable(QWidget* parent = 0);
void GetConfigColors();
void updateColors() override;
protected:
QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h);
private:
QColor mBpBackgroundColor;
QColor mBpColor;
};
#endif // HANDLESWINDOWVIEWTABLE_H

View File

@ -51,7 +51,6 @@
#include "SimpleTraceDialog.h"
#include "CPUArgumentWidget.h"
#include "MRUList.h"
#include "CPUInfoBox.h"
QString MainWindow::windowTitle = "";
@ -339,8 +338,6 @@ MainWindow::MainWindow(QWidget* parent)
connect(mCpuWidget->getStackWidget(), SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
connect(mCpuWidget->getInfoBoxWidget(), SIGNAL(displayReferencesWidget()), this, SLOT(displayReferencesWidget()));
connect(mTabWidget, SIGNAL(tabMovedTabWidget(int, int)), this, SLOT(tabMovedSlot(int, int)));
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcuts()));
@ -581,6 +578,7 @@ void MainWindow::saveWindowSettings()
}
mCpuWidget->saveWindowSettings();
mSymbolView->saveWindowSettings();
}
void MainWindow::loadWindowSettings()
@ -615,6 +613,7 @@ void MainWindow::loadWindowSettings()
}
mCpuWidget->loadWindowSettings();
mSymbolView->loadWindowSettings();
}
void MainWindow::setGlobalShortcut(QAction* action, const QKeySequence & key)

View File

@ -33,7 +33,6 @@ class SettingsDialog;
class DisassemblerGraphView;
class SimpleTraceDialog;
class MRUList;
class CPUInfoBox;
namespace Ui
{

View File

@ -219,6 +219,7 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Gui", "SidebarWatchLabels", &settings.guiSidebarWatchLabels);
GetSettingBool("Gui", "NoForegroundWindow", &settings.guiNoForegroundWindow);
GetSettingBool("Gui", "LoadSaveTabOrder", &settings.guiLoadSaveTabOrder);
GetSettingBool("Gui", "ShowGraphRva", &settings.guiShowGraphRva);
ui->chkFpuRegistersLittleEndian->setChecked(settings.guiFpuRegistersLittleEndian);
ui->chkSaveColumnOrder->setChecked(settings.guiSaveColumnOrder);
ui->chkNoCloseDialog->setChecked(settings.guiNoCloseDialog);
@ -226,6 +227,7 @@ void SettingsDialog::LoadSettings()
ui->chkSidebarWatchLabels->setChecked(settings.guiSidebarWatchLabels);
ui->chkNoForegroundWindow->setChecked(settings.guiNoForegroundWindow);
ui->chkSaveLoadTabOrder->setChecked(settings.guiLoadSaveTabOrder);
ui->chkShowGraphRva->setChecked(settings.guiShowGraphRva);
//Misc tab
if(DbgFunctions()->GetJit)
@ -353,6 +355,7 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Gui", "SidebarWatchLabels", settings.guiSidebarWatchLabels);
BridgeSettingSetUint("Gui", "NoForegroundWindow", settings.guiNoForegroundWindow);
BridgeSettingSetUint("Gui", "LoadSaveTabOrder", settings.guiLoadSaveTabOrder);
BridgeSettingSetUint("Gui", "ShowGraphRva", settings.guiShowGraphRva);
//Misc tab
if(DbgFunctions()->GetJit)
@ -799,3 +802,9 @@ void SettingsDialog::on_chkNoSourceLinesAutoComments_toggled(bool checked)
{
settings.disasmNoSourceLineAutoComments = checked;
}
void SettingsDialog::on_chkShowGraphRva_toggled(bool checked)
{
bTokenizerConfigUpdated = true;
settings.guiShowGraphRva = checked;
}

View File

@ -86,6 +86,7 @@ private slots:
void on_editSymbolStore_textEdited(const QString & arg1);
void on_editSymbolCache_textEdited(const QString & arg1);
void on_chkUtf16LogRedirect_toggled(bool checked);
void on_chkShowGraphRva_toggled(bool checked);
private:
//enums
@ -168,6 +169,7 @@ private:
bool guiSidebarWatchLabels;
bool guiNoForegroundWindow;
bool guiLoadSaveTabOrder;
bool guiShowGraphRva;
//Misc Tab
bool miscSetJIT;
bool miscSetJITAuto;

View File

@ -620,6 +620,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowGraphRva">
<property name="text">
<string>Show RVA addresses in graph view</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">

View File

@ -36,11 +36,12 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
mModuleList->mList->addColumnAt(300, tr("Module"), true);
mModuleList->mList->addColumnAt(charwidth * 8, tr("Party"), false);
mModuleList->mList->addColumnAt(charwidth * 60, tr("Path"), false);
mModuleList->mList->loadColumnFromConfig("Module");
mModuleList->mSearchList->setCipBase(true);
mModuleList->mSearchList->addColumnAt(charwidth * 2 * sizeof(dsint) + 8, tr("Base"), false);
mModuleList->mSearchList->addColumnAt(300, "Module", true);
mModuleList->mSearchList->addColumnAt(charwidth * 8, tr("Party"), false);
mModuleList->mSearchList->addColumnAt(charwidth * 60, tr("Path"), false);
mModuleList->mSearchList->addColumnAt(charwidth * 60, tr("Path"), false);
// Setup symbol list
mSearchListView->mList->enableMultiSelection(true);
@ -48,6 +49,7 @@ SymbolView::SymbolView(QWidget* parent) : QWidget(parent), ui(new Ui::SymbolView
mSearchListView->mList->addColumnAt(charwidth * 6 + 8, tr("Type"), true);
mSearchListView->mList->addColumnAt(charwidth * 80, tr("Symbol"), true);
mSearchListView->mList->addColumnAt(2000, tr("Symbol (undecorated)"), true);
mSearchListView->mList->loadColumnFromConfig("Symbol");
// Setup search list
mSearchListView->mSearchList->enableMultiSelection(true);
@ -107,6 +109,34 @@ SymbolView::~SymbolView()
delete ui;
}
inline void saveSymbolsSplitter(QSplitter* splitter, QString name)
{
BridgeSettingSet("SymbolsSettings", (name + "Geometry").toUtf8().constData(), splitter->saveGeometry().toBase64().data());
BridgeSettingSet("SymbolsSettings", (name + "State").toUtf8().constData(), splitter->saveState().toBase64().data());
}
inline void loadSymbolsSplitter(QSplitter* splitter, QString name)
{
char setting[MAX_SETTING_SIZE] = "";
if(BridgeSettingGet("SymbolsSettings", (name + "Geometry").toUtf8().constData(), setting))
splitter->restoreGeometry(QByteArray::fromBase64(QByteArray(setting)));
if(BridgeSettingGet("SymbolsSettings", (name + "State").toUtf8().constData(), setting))
splitter->restoreState(QByteArray::fromBase64(QByteArray(setting)));
splitter->splitterMoved(1, 0);
}
void SymbolView::saveWindowSettings()
{
saveSymbolsSplitter(ui->listSplitter, "mVSymbolsSplitter");
saveSymbolsSplitter(ui->mainSplitter, "mHSymbolsLogSplitter");
}
void SymbolView::loadWindowSettings()
{
loadSymbolsSplitter(ui->listSplitter, "mVSymbolsSplitter");
loadSymbolsSplitter(ui->mainSplitter, "mHSymbolsLogSplitter");
}
void SymbolView::setupContextMenu()
{
QIcon disassembler = DIcon(ArchValue("processor32.png", "processor64.png"));

View File

@ -21,6 +21,8 @@ public:
explicit SymbolView(QWidget* parent = 0);
~SymbolView();
void setupContextMenu();
void saveWindowSettings();
void loadWindowSettings();
private slots:
void updateStyle();

View File

@ -17,6 +17,26 @@ XrefBrowseDialog::XrefBrowseDialog(QWidget* parent) :
setupContextMenu();
}
QString XrefBrowseDialog::GetFunctionSymbol(duint addr)
{
QString line;
char clabel[MAX_LABEL_SIZE] = "";
DbgGetLabelAt(addr, SEG_DEFAULT, clabel);
if(*clabel)
line = QString(clabel);
else
{
duint start;
if(DbgFunctionGet(addr, &start, nullptr) && DbgGetLabelAt(start, SEG_DEFAULT, clabel) && start != addr)
line = QString("%1+%2").arg(clabel).arg(ToHexString(addr - start));
else
line = QString("%1").arg(ToHexString(addr));
}
return line;
}
void XrefBrowseDialog::setup(duint address, QString command)
{
if(mXrefInfo.refcount)
@ -30,8 +50,20 @@ void XrefBrowseDialog::setup(duint address, QString command)
ui->listWidget->clear();
if(DbgXrefGet(address, &mXrefInfo))
{
std::vector<XREF_RECORD> data;
for(duint i = 0; i < mXrefInfo.refcount; i++)
data.push_back(mXrefInfo.references[i]);
std::sort(data.begin(), data.end(), [](const XREF_RECORD A, const XREF_RECORD B){
return ((A.type < B.type) || (A.addr < B.addr));
});
for(duint i = 0; i < mXrefInfo.refcount; i++)
mXrefInfo.references[i] = data[i];
data.clear();
char disasm[GUI_MAX_DISASSEMBLY_SIZE] = "";
setWindowTitle(QString(tr("xrefs at %1")).arg(ToHexString(address)));
setWindowTitle(QString(tr("xrefs at <%1>")).arg(GetFunctionSymbol(address)));
for(duint i = 0; i < mXrefInfo.refcount; i++)
{
if(GuiGetDisassembly(mXrefInfo.references[i].addr, disasm))

View File

@ -53,6 +53,7 @@ private:
void changeAddress(duint address);
void setupContextMenu();
QString GetFunctionSymbol(duint addr);
XREF_INFO mXrefInfo;
duint mAddress;

View File

@ -253,6 +253,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
guiBool.insert("PidInHex", true);
guiBool.insert("SidebarWatchLabels", true);
guiBool.insert("LoadSaveTabOrder", false);
guiBool.insert("ShowGraphRva", false);
//Named menu settings
insertMenuBuilderBools(&guiBool, "CPUDisassembly", 50); //CPUDisassembly
insertMenuBuilderBools(&guiBool, "CPUDump", 50); //CPUDump
@ -289,9 +290,12 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Script", 3);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Thread", 14);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Handle", 5);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Window", 10);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "TcpConnection", 3);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Privilege", 2);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "LocalVarsView", 3);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Module", 4);
AbstractTableView::setupColumnConfigDefaultValue(guiUint, "Symbol", 4);
guiUint.insert("SIMDRegistersDisplayMode", 0);
defaultUints.insert("Gui", guiUint);

View File

@ -178,7 +178,6 @@ SOURCES += \
Src/Gui/BreakpointsViewTable.cpp \
Src/Utils/MRUList.cpp \
Src/Gui/LocalVarsView.cpp \
Src/Gui/HandlesWindowViewTable.cpp \
Src/Gui/MessagesBreakpoints.cpp
@ -292,7 +291,6 @@ HEADERS += \
Src/Gui/BreakpointsViewTable.h \
Src/Utils/MRUList.h \
Src/Gui/LocalVarsView.h \
Src/Gui/HandlesWindowViewTable.h \
Src/Gui/MessagesBreakpoints.h

View File

@ -218,7 +218,6 @@ SOURCES += \
dbg/typesparser.cpp \
gui/Src/Utils/MRUList.cpp \
gui/Src/Gui/LocalVarsView.cpp \
gui/Src/Gui/HandlesWindowViewTable.cpp \
gui/Src/Gui/MessagesBreakpoints.cpp
HEADERS += \
@ -448,7 +447,6 @@ HEADERS += \
dbg/types.h \
gui/Src/Utils/MRUList.h \
gui/Src/Gui/LocalVarsView.h \
gui/Src/Gui/HandlesWindowViewTable.h \
gui/Src/Gui/MessagesBreakpoints.cpp
FORMS += \