Skip to content

Commit

Permalink
Show a message box when the TTD recording is finished. Fix Vector35#599
Browse files Browse the repository at this point in the history
  • Loading branch information
xusheng6 committed Jul 18, 2024
1 parent ab8f87a commit 214b8ba
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions ui/ttdrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
#include "uicontext.h"
#include "qfiledialog.h"
#include "fmt/format.h"
#include <QMessageBox>

using namespace BinaryNinjaDebuggerAPI;
using namespace BinaryNinja;
Expand Down Expand Up @@ -189,7 +190,7 @@ void TTDRecordDialog::DoTTDTrace()
auto ttdPath = GetTTDRecorderPath();
if (ttdPath.empty())
{
LogWarn("The debugger cannot find the path for the TTD recorder. "
QMessageBox::critical(this, "Recording Failed", "The debugger cannot find the path for the TTD recorder. "
"If you have set debugger.x64dbgEngPath, check if it valid");
return;
}
Expand All @@ -203,15 +204,22 @@ void TTDRecordDialog::DoTTDTrace()
m_argumentsEntry->text().toStdString());
LogWarn("TTD tracer cmd: %s %s", ttdRecorder.c_str(), ttdCommandLine.c_str());

HINSTANCE ret = ShellExecuteA(
NULL,
"runas",
ttdRecorder.c_str(),
ttdCommandLine.c_str(),
m_workingDirectoryEntry->text().toStdString().c_str(),
SW_NORMAL
);

if ((INT_PTR)ret < 32)
LogWarn("TTD recording failed: %d", ret);
SHELLEXECUTEINFOA info = {0};
info.cbSize = sizeof(SHELLEXECUTEINFOA);
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.lpVerb = "runas";
info.lpFile = ttdRecorder.c_str();
info.lpParameters = ttdCommandLine.c_str();
info.lpDirectory = m_workingDirectoryEntry->text().toStdString().c_str();
info.nShow = SW_NORMAL;
bool ret = ShellExecuteExA(&info);
if (ret == FALSE)
{
QMessageBox::critical(this, "Recording Failed", QString::asprintf("TTD recording failed: %lu", GetLastError()));
return;
}

LogDebug("info.hProcess: %d", info.hProcess);
WaitForSingleObject(info.hProcess, INFINITE);
QMessageBox::information(this, "Recording Completed", "The TTD recording has completed and you can now debug the trace");
}

0 comments on commit 214b8ba

Please sign in to comment.