1
0
Fork 0

Adding Follow in Threads option and setting the Thread ID

This commit is contained in:
foralost 2023-11-26 18:15:45 +01:00
parent 570aaea06d
commit 03baaa1ae3
2 changed files with 23 additions and 5 deletions

View File

@ -47,7 +47,7 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mWindowsTable->addColumnAt(8 + 16 * charWidth, tr("StyleEx"), 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 + 8 * charWidth, tr("Parent"), true);
mWindowsTable->addColumnAt(8 + 20 * charWidth, tr("Size"), true); mWindowsTable->addColumnAt(8 + 20 * charWidth, tr("Size"), true);
mWindowsTable->addColumnAt(8 + 6 * charWidth, tr("Enable"), true); mWindowsTable->addColumnAt(8 + 8 * charWidth, tr("Enable"), true);
mWindowsTable->loadColumnFromConfig("Window"); mWindowsTable->loadColumnFromConfig("Window");
mWindowsTable->setIconColumn(2); mWindowsTable->setIconColumn(2);
@ -118,6 +118,8 @@ HandlesView::HandlesView(QWidget* parent) : QWidget(parent)
mActionFollowProc = new QAction(DIcon(ArchValue("processor32", "processor64")), tr("Follow Proc in Disassembler"), this); mActionFollowProc = new QAction(DIcon(ArchValue("processor32", "processor64")), tr("Follow Proc in Disassembler"), this);
connect(mActionFollowProc, SIGNAL(triggered()), this, SLOT(followInDisasmSlot())); connect(mActionFollowProc, SIGNAL(triggered()), this, SLOT(followInDisasmSlot()));
mActionFollowProc->setShortcut(Qt::Key_Return); mActionFollowProc->setShortcut(Qt::Key_Return);
mActionFollowThread = new QAction(DIcon("arrow-threads"), tr("Follow in Threads window"), this);
connect(mActionFollowThread, SIGNAL(triggered()), this, SLOT(followInThreads()));
mWindowsTable->addAction(mActionFollowProc); mWindowsTable->addAction(mActionFollowProc);
mActionToggleProcBP = new QAction(DIcon("breakpoint_toggle"), tr("Toggle Breakpoint in Proc"), this); mActionToggleProcBP = new QAction(DIcon("breakpoint_toggle"), tr("Toggle Breakpoint in Proc"), this);
connect(mActionToggleProcBP, SIGNAL(triggered()), this, SLOT(toggleBPSlot())); connect(mActionToggleProcBP, SIGNAL(triggered()), this, SLOT(toggleBPSlot()));
@ -218,6 +220,7 @@ void HandlesView::windowsTableContextMenuSlot(QMenu* menu)
} }
menu->addAction(mActionFollowProc); menu->addAction(mActionFollowProc);
menu->addAction(mActionFollowThread);
menu->addAction(mActionToggleProcBP); menu->addAction(mActionToggleProcBP);
menu->addAction(mActionMessageProcBP); menu->addAction(mActionMessageProcBP);
} }
@ -317,11 +320,26 @@ void HandlesView::disableWindowSlot()
enumWindows(); enumWindows();
} }
void HandlesView::followInDisasmSlot() void HandlesView::followInDisasmSlot()
{ {
DbgCmdExec(QString("disasm %1").arg(mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 0))); DbgCmdExec(QString("disasm %1").arg(mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 0)));
} }
void HandlesView::followInThreads()
{
QString threadId = mWindowsTable->mCurList->getCellContent(mWindowsTable->mCurList->getInitialSelection(), 4);
if(Config()->getBool("Gui", "PidTidInHex"))
{
duint threadIdNum = strtoll(threadId.toUtf8().constData(), NULL, 0x10);
threadId = QString::number(threadIdNum);
}
DbgCmdExec(QString("showthreadid %1").arg(threadId));
}
void HandlesView::toggleBPSlot() void HandlesView::toggleBPSlot()
{ {
auto & mCurList = *mWindowsTable->mCurList; auto & mCurList = *mWindowsTable->mCurList;
@ -430,10 +448,8 @@ void HandlesView::enumWindows()
mWindowsTable->setCellContent(i, 1, ToHexString(windows[i].handle)); mWindowsTable->setCellContent(i, 1, ToHexString(windows[i].handle));
mWindowsTable->setCellContent(i, 2, QString(windows[i].windowTitle)); mWindowsTable->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->setCellContent(i, 3, QString(windows[i].windowClass)); mWindowsTable->setCellContent(i, 3, QString(windows[i].windowClass));
char threadname[MAX_THREAD_NAME_SIZE]; // Thread ID
if(DbgFunctions()->ThreadGetName(windows[i].threadId, threadname) && *threadname != '\0') if(Config()->getBool("Gui", "PidTidInHex"))
mWindowsTable->setCellContent(i, 4, QString::fromUtf8(threadname));
else if(Config()->getBool("Gui", "PidTidInHex"))
mWindowsTable->setCellContent(i, 4, ToHexString(windows[i].threadId)); mWindowsTable->setCellContent(i, 4, ToHexString(windows[i].threadId));
else else
mWindowsTable->setCellContent(i, 4, QString::number(windows[i].threadId)); mWindowsTable->setCellContent(i, 4, QString::number(windows[i].threadId));

View File

@ -35,6 +35,7 @@ public slots:
void enableWindowSlot(); void enableWindowSlot();
void disableWindowSlot(); void disableWindowSlot();
void followInDisasmSlot(); void followInDisasmSlot();
void followInThreads();
void toggleBPSlot(); void toggleBPSlot();
void messagesBPSlot(); void messagesBPSlot();
@ -56,6 +57,7 @@ private:
QAction* mActionEnableWindow; QAction* mActionEnableWindow;
QAction* mActionDisableWindow; QAction* mActionDisableWindow;
QAction* mActionFollowProc; QAction* mActionFollowProc;
QAction* mActionFollowThread;
QAction* mActionToggleProcBP; QAction* mActionToggleProcBP;
QAction* mActionMessageProcBP; QAction* mActionMessageProcBP;