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 + 8 * charWidth, tr("Parent"), 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->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);
connect(mActionFollowProc, SIGNAL(triggered()), this, SLOT(followInDisasmSlot()));
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);
mActionToggleProcBP = new QAction(DIcon("breakpoint_toggle"), tr("Toggle Breakpoint in Proc"), this);
connect(mActionToggleProcBP, SIGNAL(triggered()), this, SLOT(toggleBPSlot()));
@ -218,6 +220,7 @@ void HandlesView::windowsTableContextMenuSlot(QMenu* menu)
}
menu->addAction(mActionFollowProc);
menu->addAction(mActionFollowThread);
menu->addAction(mActionToggleProcBP);
menu->addAction(mActionMessageProcBP);
}
@ -317,11 +320,26 @@ void HandlesView::disableWindowSlot()
enumWindows();
}
void HandlesView::followInDisasmSlot()
{
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()
{
auto & mCurList = *mWindowsTable->mCurList;
@ -430,10 +448,8 @@ void HandlesView::enumWindows()
mWindowsTable->setCellContent(i, 1, ToHexString(windows[i].handle));
mWindowsTable->setCellContent(i, 2, QString(windows[i].windowTitle));
mWindowsTable->setCellContent(i, 3, QString(windows[i].windowClass));
char threadname[MAX_THREAD_NAME_SIZE];
if(DbgFunctions()->ThreadGetName(windows[i].threadId, threadname) && *threadname != '\0')
mWindowsTable->setCellContent(i, 4, QString::fromUtf8(threadname));
else if(Config()->getBool("Gui", "PidTidInHex"))
// Thread ID
if(Config()->getBool("Gui", "PidTidInHex"))
mWindowsTable->setCellContent(i, 4, ToHexString(windows[i].threadId));
else
mWindowsTable->setCellContent(i, 4, QString::number(windows[i].threadId));

View File

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