diff --git a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp index 6d29e3d7d..2653fc25f 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_manager.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_manager.cpp @@ -21,6 +21,8 @@ static HosMutex g_cheat_lock; static HosThread g_detect_thread, g_vm_thread; +static IEvent *g_cheat_process_event; + static CheatProcessMetadata g_cheat_process_metadata = {0}; static Handle g_cheat_process_debug_hnd = 0; @@ -29,6 +31,7 @@ void DmntCheatManager::CloseActiveCheatProcess() { svcCloseHandle(g_cheat_process_debug_hnd); g_cheat_process_debug_hnd = 0; g_cheat_process_metadata = (CheatProcessMetadata){0}; + g_cheat_process_event->Signal(); } } @@ -157,6 +160,9 @@ void DmntCheatManager::OnNewApplicationLaunch() { /* Continue debug events, etc. */ ContinueCheatProcess(); + + /* Signal to our fans. */ + g_cheat_process_event->Signal(); } void DmntCheatManager::DetectThread(void *arg) { @@ -198,7 +204,26 @@ bool DmntCheatManager::GetHasActiveCheatProcess() { return HasActiveCheatProcess(); } +Handle DmntCheatManager::GetCheatProcessEventHandle() { + return g_cheat_process_event->GetHandle(); +} + +Result DmntCheatManager::GetCheatProcessMetadata(CheatProcessMetadata *out) { + std::scoped_lock lk(g_cheat_lock); + + if (HasActiveCheatProcess()) { + *out = g_cheat_process_metadata; + return 0; + } + + /* TODO: Decide on a set of return values... */ + return 0x20F; +} + void DmntCheatManager::InitializeCheatManager() { + /* Create cheat process detection event. */ + g_cheat_process_event = CreateWriteOnlySystemEvent(); + /* Spawn application detection thread, spawn cheat vm thread. */ if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 28))) { std::abort(); diff --git a/stratosphere/dmnt/source/dmnt_cheat_manager.hpp b/stratosphere/dmnt/source/dmnt_cheat_manager.hpp index afbd63715..e454c30a0 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_manager.hpp +++ b/stratosphere/dmnt/source/dmnt_cheat_manager.hpp @@ -32,6 +32,8 @@ class DmntCheatManager { static void ContinueCheatProcess(); public:; static bool GetHasActiveCheatProcess(); + static Handle GetCheatProcessEventHandle(); + static Result GetCheatProcessMetadata(CheatProcessMetadata *out); static void InitializeCheatManager(); }; diff --git a/stratosphere/dmnt/source/dmnt_cheat_service.cpp b/stratosphere/dmnt/source/dmnt_cheat_service.cpp index 9b154ced4..f2088acf7 100644 --- a/stratosphere/dmnt/source/dmnt_cheat_service.cpp +++ b/stratosphere/dmnt/source/dmnt_cheat_service.cpp @@ -16,20 +16,18 @@ #include #include "dmnt_cheat_service.hpp" +#include "dmnt_cheat_manager.hpp" void DmntCheatService::HasCheatProcess(Out out) { - /* TODO */ - std::abort(); + out.SetValue(DmntCheatManager::GetHasActiveCheatProcess()); } void DmntCheatService::GetCheatProcessEvent(Out out_event) { - /* TODO */ - std::abort(); + out_event.SetValue(DmntCheatManager::GetCheatProcessEventHandle()); } Result DmntCheatService::GetCheatProcessMetadata(Out out_metadata) { - /* TODO */ - return 0xF601; + return DmntCheatManager::GetCheatProcessMetadata(out_metadata.GetPointer()); }