1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-22 20:06:40 +00:00

dmnt: fix edge case in debug events thread

This commit is contained in:
Michael Scire 2019-09-16 22:47:00 -07:00 committed by SciresM
parent 8abee1bdaa
commit fe2dd671fb

View file

@ -200,7 +200,7 @@ namespace sts::dmnt::cheat::impl {
/* Spawn application detection thread, spawn cheat vm thread. */
R_ASSERT(this->detect_thread.Initialize(&CheatProcessManager::DetectLaunchThread, this, 0x4000, 39));
R_ASSERT(this->vm_thread.Initialize(&CheatProcessManager::VirtualMachineThread, this, 0x4000, 48));
R_ASSERT(this->debug_events_thread.Initialize(&CheatProcessManager::DebugEventsThread, this, 0x4000, 48));
R_ASSERT(this->debug_events_thread.Initialize(&CheatProcessManager::DebugEventsThread, this, 0x4000, 24));
/* Start threads. */
R_ASSERT(this->detect_thread.Start());
@ -547,12 +547,21 @@ namespace sts::dmnt::cheat::impl {
while (true) {
/* Atomically wait (and clear) signal for new process. */
this_ptr->debug_events_signal.Wait(true);
while (R_SUCCEEDED(svcWaitSynchronizationSingle(this_ptr->GetCheatProcessHandle(), U64_MAX))) {
std::scoped_lock lk(this_ptr->cheat_lock);
while (true) {
while (R_SUCCEEDED(svcWaitSynchronizationSingle(this_ptr->GetCheatProcessHandle(), U64_MAX))) {
std::scoped_lock lk(this_ptr->cheat_lock);
/* Handle any pending debug events. */
if (this_ptr->HasActiveCheatProcess()) {
dmnt::cheat::impl::ContinueCheatProcess(this_ptr->GetCheatProcessHandle());
/* Handle any pending debug events. */
if (this_ptr->HasActiveCheatProcess()) {
dmnt::cheat::impl::ContinueCheatProcess(this_ptr->GetCheatProcessHandle());
}
}
/* WaitSynchronization failed. This means someone canceled our synchronization, possibly us. */
/* Let's check if we should quit! */
std::scoped_lock lk(this_ptr->cheat_lock);
if (!this_ptr->HasActiveCheatProcess()) {
break;
}
}
}