mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 18:49:48 +02:00
feat(tui): support for showing errors for exploit
This commit is contained in:
2 files changed
+26
-7
No files matched your search
@@ -125,11 +125,13 @@ void TuiExploitPanel::exploit()
|
||||
}
|
||||
|
||||
auto stage = std::make_shared<std::atomic<int>>(STAGE_RESET);
|
||||
auto result = std::make_shared<std::atomic<int>>(0);
|
||||
|
||||
std::thread worker([stage]()
|
||||
std::thread worker([stage, result]()
|
||||
{
|
||||
::exploit(reinterpret_cast<int*>(stage.get()));
|
||||
stage->store(STAGE_DONE);
|
||||
int ret = ::exploit(reinterpret_cast<int*>(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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user