mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 02:29:48 +02:00
fix(m8): exit properly this time
This commit is contained in:
5 files changed
+57
-42
No files matched your search
+26
-13
@@ -49,31 +49,33 @@ ExploitPanel::ExploitPanel(MainFrame* frame, wxWindow* parent)
|
||||
{
|
||||
auto* root = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto* text = new wxStaticText(this, wxID_ANY,
|
||||
"Installing jailbreak, this will take a moment. If the device asks for a passcode\nplease enter it. Do not disconnect the device until finished.");
|
||||
auto* descriptionText = new wxStaticText(this, wxID_ANY,
|
||||
"Installing jailbreak, this will take a moment. If the device asks for a passcode\n"
|
||||
"please enter it. Do not disconnect the device until finished."
|
||||
);
|
||||
|
||||
m_statusText = new wxStaticText(this, wxID_ANY, stage_to_string(STAGE_RESET));
|
||||
|
||||
m_statusText = new wxStaticText(this, wxID_ANY, "Idle.");
|
||||
m_progressBar = new wxGauge(this, wxID_ANY, 100);
|
||||
m_progressBar->SetValue(0);
|
||||
|
||||
m_backButton = new wxButton(this, wxID_ANY, "Back");
|
||||
m_backButton->Disable();
|
||||
|
||||
m_backButton->Bind(wxEVT_BUTTON, [this, frame](wxCommandEvent&) {
|
||||
m_statusText->SetLabel("Idle.");
|
||||
m_statusText->SetLabel(stage_to_string(STAGE_RESET));
|
||||
m_progressBar->SetValue(0);
|
||||
m_backButton->Disable();
|
||||
frame->ShowMain();
|
||||
});
|
||||
|
||||
root->Add(text, 0, wxALL, 10);
|
||||
root->Add(descriptionText, 0, wxALL, 10);
|
||||
root->Add(m_statusText, 0, wxALL, 10);
|
||||
root->Add(m_progressBar, 0, wxALL | wxEXPAND, 20);
|
||||
|
||||
root->AddStretchSpacer();
|
||||
auto* bottomRow = new wxBoxSizer(wxHORIZONTAL);
|
||||
bottomRow->AddStretchSpacer();
|
||||
bottomRow->Add(m_backButton, 0, wxRIGHT | wxLEFT | wxBOTTOM, 12);
|
||||
bottomRow->Add(m_backButton, 0, wxRIGHT | wxBOTTOM, 12);
|
||||
|
||||
root->Add(bottomRow, 0, wxEXPAND);
|
||||
|
||||
@@ -95,33 +97,44 @@ void ExploitPanel::StartExploit()
|
||||
std::thread([this]()
|
||||
{
|
||||
const auto deviceState = GetDeviceState();
|
||||
if (!deviceState.connected || deviceState.mode != DeviceMode::DFU)
|
||||
if (!deviceState.connected || deviceState.mode != DeviceMode::DFU) {
|
||||
wxTheApp->CallAfter([this]() { m_backButton->Enable(); });
|
||||
return;
|
||||
}
|
||||
|
||||
auto state = std::make_shared<shared_t>();
|
||||
atomic_init(&state->stage, STAGE_RESET);
|
||||
atomic_init(&state->stop, false);
|
||||
atomic_init(&state->result, 0);
|
||||
|
||||
std::thread worker([state]()
|
||||
auto isFinished = std::make_shared<std::atomic<bool>>(false);
|
||||
|
||||
std::thread worker([state, isFinished]()
|
||||
{
|
||||
exploit(state.get());
|
||||
isFinished->store(true);
|
||||
});
|
||||
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
int stage = atomic_load(&state->stage);
|
||||
int progress = stage_to_progress(stage);
|
||||
bool finished = isFinished->load();
|
||||
|
||||
wxTheApp->CallAfter([this, stage, progress]()
|
||||
wxTheApp->CallAfter([this, stage, progress, finished]()
|
||||
{
|
||||
m_statusText->SetLabel(stage_to_string(stage));
|
||||
m_progressBar->SetValue(progress);
|
||||
if (stage == STAGE_DONE) m_backButton->Enable();
|
||||
|
||||
if (finished || stage == STAGE_DONE) {
|
||||
m_backButton->Enable();
|
||||
}
|
||||
});
|
||||
|
||||
if (stage == STAGE_DONE)
|
||||
if (stage == STAGE_DONE || finished) {
|
||||
atomic_store(&state->stop, true);
|
||||
break;
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user