From ef16aa0659af268ec569987410a92e5e3a4f7c83 Mon Sep 17 00:00:00 2001 From: CLARATION Date: Wed, 22 Jul 2026 19:30:34 -0700 Subject: [PATCH] feat(tui): support for showing errors for exploit --- src/tui/TuiExploitPanel.cpp | 30 +++++++++++++++++++++++++----- src/wx/ExploitPanel.cpp | 3 +-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/tui/TuiExploitPanel.cpp b/src/tui/TuiExploitPanel.cpp index 1523484..f6e4a6d 100644 --- a/src/tui/TuiExploitPanel.cpp +++ b/src/tui/TuiExploitPanel.cpp @@ -125,11 +125,13 @@ void TuiExploitPanel::exploit() } auto stage = std::make_shared>(STAGE_RESET); + auto result = std::make_shared>(0); - std::thread worker([stage]() + std::thread worker([stage, result]() { - ::exploit(reinterpret_cast(stage.get())); - stage->store(STAGE_DONE); + int ret = ::exploit(reinterpret_cast(stage.get())); + result->store(ret); + stage->store(ret == 0 ? STAGE_DONE : STAGE_ERROR); }); for (;;) @@ -137,15 +139,33 @@ void TuiExploitPanel::exploit() int currentStage = stage->load(); int progress = stage_to_progress(currentStage); + if (currentStage == STAGE_ERROR) { + const char* error = err_to_string(result->load()); + + set_status( + std::string(stage_to_string(currentStage)) + + " (" + + error + + ")", + 0 + ); + + break; + } + set_status(stage_to_string(currentStage), progress); - if (currentStage == STAGE_DONE) break; + if (currentStage == STAGE_DONE) + break; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } - if (worker.joinable()) worker.join(); + if (worker.joinable()) + worker.join(); m_is_exploiting = false; + }).detach(); } diff --git a/src/wx/ExploitPanel.cpp b/src/wx/ExploitPanel.cpp index 16507c4..eed79e5 100644 --- a/src/wx/ExploitPanel.cpp +++ b/src/wx/ExploitPanel.cpp @@ -145,9 +145,8 @@ void ExploitPanel::StartExploit() m_statusText->SetLabel(stage_to_string(currentStage)); m_progressBar->SetValue(progress); - if (currentStage == STAGE_DONE) { + if (currentStage == STAGE_DONE) m_backButton->Enable(); - } }); if (currentStage == STAGE_DONE || currentStage == STAGE_ERROR)