Create option to show PID/TID in hex and default to decimal

This commit is contained in:
Duncan Ogilvie 2020-10-02 18:38:59 +02:00
parent a95dd74b9a
commit 54f399f5b1
7 changed files with 18 additions and 17 deletions

View File

@ -33,7 +33,7 @@ AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Attach
//setup process list
int charwidth = mSearchListView->getCharWidth();
mSearchListView->addColumnAt(charwidth * sizeof(int) * 2 + 8, tr("PID"), true, QString(), ConfigBool("Gui", "PidInHex") ? StdTable::SortBy::AsHex : StdTable::SortBy::AsInt);
mSearchListView->addColumnAt(charwidth * sizeof(int) * 2 + 8, tr("PID"), true, QString(), ConfigBool("Gui", "PidTidInHex") ? StdTable::SortBy::AsHex : StdTable::SortBy::AsInt);
mSearchListView->addColumnAt(150, tr("Name"), true);
mSearchListView->addColumnAt(300, tr("Title"), true);
mSearchListView->addColumnAt(500, tr("Path"), true);
@ -69,7 +69,7 @@ void AttachDialog::refresh()
for(int i = 0; i < count; i++)
{
QFileInfo fi(entries[i].szExeFile);
mSearchListView->setCellContent(i, ColPid, QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", entries[i].dwProcessId));
mSearchListView->setCellContent(i, ColPid, QString().sprintf(ConfigBool("Gui", "PidTidInHex") ? "%.8X" : "%u", entries[i].dwProcessId));
mSearchListView->setCellContent(i, ColName, fi.baseName());
mSearchListView->setCellContent(i, ColTitle, QString(entries[i].szExeMainWindowTitle));
mSearchListView->setCellContent(i, ColPath, QString(entries[i].szExeFile));
@ -82,7 +82,7 @@ void AttachDialog::refresh()
void AttachDialog::on_btnAttach_clicked()
{
QString pid = mSearchListView->mCurList->getCellContent(mSearchListView->mCurList->getInitialSelection(), ColPid);
DbgCmdExec(QString("attach %1%2").arg(ConfigBool("Gui", "PidInHex") ? "" : ".").arg(pid));
DbgCmdExec(QString("attach %1%2").arg(ConfigBool("Gui", "PidTidInHex") ? "" : ".").arg(pid));
accept();
}
@ -108,7 +108,7 @@ retryFindWindow:
if(tid = GetWindowThreadProcessId(hWndFound, &pid))
{
refresh();
QString pidText = QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", pid);
QString pidText = QString().sprintf(ConfigBool("Gui", "PidTidInHex") ? "%.8X" : "%u", pid);
bool found = false;
for(int i = 0; i < mSearchListView->mCurList->getRowCount(); i++)
{

View File

@ -429,7 +429,7 @@ void HandlesView::enumWindows()
char threadname[MAX_THREAD_NAME_SIZE];
if(DbgFunctions()->ThreadGetName(windows[i].threadId, threadname))
mWindowsTable->setCellContent(i, 4, QString::fromUtf8(threadname));
else if(Config()->getBool("Gui", "PidInHex"))
else 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

@ -241,7 +241,7 @@ void SettingsDialog::LoadSettings()
GetSettingBool("Gui", "FpuRegistersLittleEndian", &settings.guiFpuRegistersLittleEndian);
GetSettingBool("Gui", "SaveColumnOrder", &settings.guiSaveColumnOrder);
GetSettingBool("Gui", "NoCloseDialog", &settings.guiNoCloseDialog);
GetSettingBool("Gui", "PidInHex", &settings.guiPidInHex);
GetSettingBool("Gui", "PidTidInHex", &settings.guiPidTidInHex);
GetSettingBool("Gui", "SidebarWatchLabels", &settings.guiSidebarWatchLabels);
GetSettingBool("Gui", "NoForegroundWindow", &settings.guiNoForegroundWindow);
GetSettingBool("Gui", "LoadSaveTabOrder", &settings.guiLoadSaveTabOrder);
@ -253,7 +253,7 @@ void SettingsDialog::LoadSettings()
ui->chkFpuRegistersLittleEndian->setChecked(settings.guiFpuRegistersLittleEndian);
ui->chkSaveColumnOrder->setChecked(settings.guiSaveColumnOrder);
ui->chkNoCloseDialog->setChecked(settings.guiNoCloseDialog);
ui->chkPidInHex->setChecked(settings.guiPidInHex);
ui->chkPidTidInHex->setChecked(settings.guiPidTidInHex);
ui->chkSidebarWatchLabels->setChecked(settings.guiSidebarWatchLabels);
ui->chkNoForegroundWindow->setChecked(settings.guiNoForegroundWindow);
ui->chkSaveLoadTabOrder->setChecked(settings.guiLoadSaveTabOrder);
@ -398,7 +398,7 @@ void SettingsDialog::SaveSettings()
BridgeSettingSetUint("Gui", "FpuRegistersLittleEndian", settings.guiFpuRegistersLittleEndian);
BridgeSettingSetUint("Gui", "SaveColumnOrder", settings.guiSaveColumnOrder);
BridgeSettingSetUint("Gui", "NoCloseDialog", settings.guiNoCloseDialog);
BridgeSettingSetUint("Gui", "PidInHex", settings.guiPidInHex);
BridgeSettingSetUint("Gui", "PidTidInHex", settings.guiPidTidInHex);
BridgeSettingSetUint("Gui", "SidebarWatchLabels", settings.guiSidebarWatchLabels);
BridgeSettingSetUint("Gui", "NoForegroundWindow", settings.guiNoForegroundWindow);
BridgeSettingSetUint("Gui", "LoadSaveTabOrder", settings.guiLoadSaveTabOrder);
@ -811,9 +811,9 @@ void SettingsDialog::on_chkSkipInt3Stepping_toggled(bool checked)
settings.engineSkipInt3Stepping = checked;
}
void SettingsDialog::on_chkPidInHex_clicked(bool checked)
void SettingsDialog::on_chkPidTidInHex_clicked(bool checked)
{
settings.guiPidInHex = checked;
settings.guiPidTidInHex = checked;
}
void SettingsDialog::on_chkNoScriptTimeout_stateChanged(int arg1)

View File

@ -82,7 +82,7 @@ private slots:
void on_chkSaveColumnOrder_stateChanged(int arg1);
void on_chkSaveLoadTabOrder_stateChanged(int arg1);
void on_chkNoCloseDialog_toggled(bool checked);
void on_chkPidInHex_clicked(bool checked);
void on_chkPidTidInHex_clicked(bool checked);
void on_chkSidebarWatchLabels_stateChanged(int arg1);
void on_chkNoForegroundWindow_toggled(bool checked);
void on_chkShowExitConfirmation_toggled(bool checked);
@ -183,7 +183,7 @@ private:
bool guiFpuRegistersLittleEndian;
bool guiSaveColumnOrder;
bool guiNoCloseDialog;
bool guiPidInHex;
bool guiPidTidInHex;
bool guiSidebarWatchLabels;
bool guiNoForegroundWindow;
bool guiLoadSaveTabOrder;

View File

@ -683,9 +683,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkPidInHex">
<widget class="QCheckBox" name="chkPidTidInHex">
<property name="text">
<string>Show PID in HEX</string>
<string>Show PID/TID in HEX</string>
</property>
</widget>
</item>

View File

@ -157,7 +157,7 @@ ThreadView::ThreadView(StdTable* parent) : StdTable(parent)
enableMultiSelection(true);
int charwidth = getCharWidth();
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("Number"), true, "", SortBy::AsInt);
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("ID"), true, "", SortBy::AsHex);
addColumnAt(8 + charwidth * sizeof(unsigned int) * 2, tr("ID"), true, "", ConfigBool("Gui", "PidTidInHex") ? SortBy::AsHex : SortBy::AsInt);
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("Entry"), true, "", SortBy::AsHex);
addColumnAt(8 + charwidth * sizeof(duint) * 2, tr("TEB"), true, "", SortBy::AsHex);
addColumnAt(8 + charwidth * sizeof(duint) * 2, ArchValue(tr("EIP"), tr("RIP")), true, "", SortBy::AsHex);
@ -187,13 +187,14 @@ void ThreadView::updateThreadList()
memset(&threadList, 0, sizeof(THREADLIST));
DbgGetThreadList(&threadList);
setRowCount(threadList.count);
auto tidFormat = ConfigBool("Gui", "PidTidInHex") ? "%X" : "%d";
for(int i = 0; i < threadList.count; i++)
{
if(!threadList.list[i].BasicInfo.ThreadNumber)
setCellContent(i, 0, tr("Main"));
else
setCellContent(i, 0, ToDecString(threadList.list[i].BasicInfo.ThreadNumber));
setCellContent(i, 1, ToHexString(threadList.list[i].BasicInfo.ThreadId));
setCellContent(i, 1, QString().sprintf(tidFormat, threadList.list[i].BasicInfo.ThreadId));
setCellContent(i, 2, ToPtrString(threadList.list[i].BasicInfo.ThreadStartAddress));
setCellContent(i, 3, ToPtrString(threadList.list[i].BasicInfo.ThreadLocalBase));
setCellContent(i, 4, ToPtrString(threadList.list[i].ThreadCip));

View File

@ -275,7 +275,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
guiBool.insert("FpuRegistersLittleEndian", false);
guiBool.insert("SaveColumnOrder", true);
guiBool.insert("NoCloseDialog", false);
guiBool.insert("PidInHex", false);
guiBool.insert("PidTidInHex", false);
guiBool.insert("SidebarWatchLabels", true);
guiBool.insert("LoadSaveTabOrder", true);
guiBool.insert("ShowGraphRva", false);