config command (#1355)
* config command * Find window in attach dialog * attach to hidden process
This commit is contained in:
parent
f61509ad8b
commit
694d94cf1f
|
@ -581,4 +581,45 @@ bool cbInstrMnemonicbrief(int argc, char* argv[])
|
|||
return false;
|
||||
dputs(MnemonicHelp::getBriefDescription(argv[1]).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cbInstrConfig(int argc, char* argv[])
|
||||
{
|
||||
if(IsArgumentsLessThan(argc, 3))
|
||||
return false;
|
||||
duint val = 0;
|
||||
if(argc == 3)
|
||||
{
|
||||
if(BridgeSettingGetUint(argv[1], argv[2], &val))
|
||||
{
|
||||
varset("$result", val, false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error: Configuration not found."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(valfromstring(argv[3], &val, true))
|
||||
{
|
||||
if(BridgeSettingSetUint(argv[1], argv[2], val))
|
||||
{
|
||||
DbgSettingsUpdated();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dputs(QT_TRANSLATE_NOOP("DBG", "Error updating configuration."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf(QT_TRANSLATE_NOOP("DBG", "Invalid expression: \"%s\"!\n"), argv[3]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,4 +19,6 @@ bool cbDebugGetCmdline(int argc, char* argv[]);
|
|||
bool cbDebugSetCmdline(int argc, char* argv[]);
|
||||
|
||||
bool cbInstrMnemonichelp(int argc, char* argv[]);
|
||||
bool cbInstrMnemonicbrief(int argc, char* argv[]);
|
||||
bool cbInstrMnemonicbrief(int argc, char* argv[]);
|
||||
|
||||
bool cbInstrConfig(int argc, char* argv[]);
|
|
@ -412,6 +412,8 @@ static void registercommands()
|
|||
dbgcmdnew("mnemonichelp", cbInstrMnemonichelp, false); //mnemonic help
|
||||
dbgcmdnew("mnemonicbrief", cbInstrMnemonicbrief, false); //mnemonic brief
|
||||
|
||||
dbgcmdnew("config", cbInstrConfig, false); //get or set config uint
|
||||
|
||||
//undocumented
|
||||
dbgcmdnew("bench", cbDebugBenchmark, true); //benchmark test (readmem etc)
|
||||
dbgcmdnew("dprintf", cbPrintf, false); //printf
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "ui_AttachDialog.h"
|
||||
#include "SearchListView.h"
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
AttachDialog::AttachDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AttachDialog)
|
||||
{
|
||||
|
@ -85,6 +86,56 @@ void AttachDialog::on_btnAttach_clicked()
|
|||
accept();
|
||||
}
|
||||
|
||||
void AttachDialog::on_btnFindWindow_clicked()
|
||||
{
|
||||
QString windowText;
|
||||
retryFindWindow:
|
||||
if(!SimpleInputBox(this, tr("Find Window"), windowText, windowText, tr("Enter window title or class name here.")))
|
||||
return;
|
||||
HWND hWndFound = FindWindowW(NULL, reinterpret_cast<LPCWSTR>(windowText.utf16())); //Window Title first
|
||||
if(hWndFound == NULL)
|
||||
hWndFound = FindWindowW(reinterpret_cast<LPCWSTR>(windowText.utf16()), NULL); //Then try window class name
|
||||
if(hWndFound == NULL)
|
||||
{
|
||||
QMessageBox retryDialog(QMessageBox::Critical, tr("Find Window"), tr("Cannot find window \"%1\". Retry?").arg(windowText), QMessageBox::Cancel | QMessageBox::Retry, this);
|
||||
retryDialog.setWindowIcon(DIcon("compile-error.png"));
|
||||
if(retryDialog.exec() == QMessageBox::Retry)
|
||||
goto retryFindWindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD pid, tid;
|
||||
if(tid = GetWindowThreadProcessId(hWndFound, &pid))
|
||||
{
|
||||
refresh();
|
||||
QString pidText = QString().sprintf(ConfigBool("Gui", "PidInHex") ? "%.8X" : "%u", pid);
|
||||
bool found = false;
|
||||
for(int i = 0; i < mSearchListView->mList->getRowCount(); i++)
|
||||
{
|
||||
if(mSearchListView->mList->getCellContent(i, 0) == pidText)
|
||||
{
|
||||
mSearchListView->mList->setSingleSelection(i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
QMessageBox hiddenProcessDialog(QMessageBox::Question, tr("Find Window"),
|
||||
tr("The PID of the window \"%1\" is %2, but it's hidden in the process list. Do you want to attach to it immediately?").arg(windowText).arg(pidText),
|
||||
QMessageBox::Yes | QMessageBox::No, this);
|
||||
if(hiddenProcessDialog.exec() == QMessageBox::Yes)
|
||||
{
|
||||
DbgCmdExec(QString("attach " + pid).toUtf8().constData());
|
||||
accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
SimpleErrorBox(this, tr("Find Window"), tr("GetWindowThreadProcessId() failed. Cannot get the PID of the window."));
|
||||
}
|
||||
}
|
||||
|
||||
void AttachDialog::processListContextMenu(QMenu* wMenu)
|
||||
{
|
||||
// Don't show menu options if nothing is listed
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void on_btnAttach_clicked();
|
||||
void on_btnFindWindow_clicked();
|
||||
void refresh();
|
||||
void processListContextMenu(QMenu* wMenu);
|
||||
|
||||
|
|
|
@ -97,6 +97,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnFindWindow">
|
||||
<property name="text">
|
||||
<string>Find Window...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAttach">
|
||||
<property name="sizePolicy">
|
||||
|
|
Loading…
Reference in New Issue