dmnt-cheat: Implement all meta commands.

This commit is contained in:
Michael Scire 2019-02-27 04:37:02 -08:00
parent c80eb26135
commit e4cc39c29b
3 changed files with 31 additions and 6 deletions

View file

@ -21,6 +21,8 @@
static HosMutex g_cheat_lock; static HosMutex g_cheat_lock;
static HosThread g_detect_thread, g_vm_thread; static HosThread g_detect_thread, g_vm_thread;
static IEvent *g_cheat_process_event;
static CheatProcessMetadata g_cheat_process_metadata = {0}; static CheatProcessMetadata g_cheat_process_metadata = {0};
static Handle g_cheat_process_debug_hnd = 0; static Handle g_cheat_process_debug_hnd = 0;
@ -29,6 +31,7 @@ void DmntCheatManager::CloseActiveCheatProcess() {
svcCloseHandle(g_cheat_process_debug_hnd); svcCloseHandle(g_cheat_process_debug_hnd);
g_cheat_process_debug_hnd = 0; g_cheat_process_debug_hnd = 0;
g_cheat_process_metadata = (CheatProcessMetadata){0}; g_cheat_process_metadata = (CheatProcessMetadata){0};
g_cheat_process_event->Signal();
} }
} }
@ -157,6 +160,9 @@ void DmntCheatManager::OnNewApplicationLaunch() {
/* Continue debug events, etc. */ /* Continue debug events, etc. */
ContinueCheatProcess(); ContinueCheatProcess();
/* Signal to our fans. */
g_cheat_process_event->Signal();
} }
void DmntCheatManager::DetectThread(void *arg) { void DmntCheatManager::DetectThread(void *arg) {
@ -198,7 +204,26 @@ bool DmntCheatManager::GetHasActiveCheatProcess() {
return HasActiveCheatProcess(); return HasActiveCheatProcess();
} }
Handle DmntCheatManager::GetCheatProcessEventHandle() {
return g_cheat_process_event->GetHandle();
}
Result DmntCheatManager::GetCheatProcessMetadata(CheatProcessMetadata *out) {
std::scoped_lock<HosMutex> 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() { void DmntCheatManager::InitializeCheatManager() {
/* Create cheat process detection event. */
g_cheat_process_event = CreateWriteOnlySystemEvent();
/* Spawn application detection thread, spawn cheat vm thread. */ /* Spawn application detection thread, spawn cheat vm thread. */
if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 28))) { if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 28))) {
std::abort(); std::abort();

View file

@ -32,6 +32,8 @@ class DmntCheatManager {
static void ContinueCheatProcess(); static void ContinueCheatProcess();
public:; public:;
static bool GetHasActiveCheatProcess(); static bool GetHasActiveCheatProcess();
static Handle GetCheatProcessEventHandle();
static Result GetCheatProcessMetadata(CheatProcessMetadata *out);
static void InitializeCheatManager(); static void InitializeCheatManager();
}; };

View file

@ -16,20 +16,18 @@
#include <switch.h> #include <switch.h>
#include "dmnt_cheat_service.hpp" #include "dmnt_cheat_service.hpp"
#include "dmnt_cheat_manager.hpp"
void DmntCheatService::HasCheatProcess(Out<bool> out) { void DmntCheatService::HasCheatProcess(Out<bool> out) {
/* TODO */ out.SetValue(DmntCheatManager::GetHasActiveCheatProcess());
std::abort();
} }
void DmntCheatService::GetCheatProcessEvent(Out<CopiedHandle> out_event) { void DmntCheatService::GetCheatProcessEvent(Out<CopiedHandle> out_event) {
/* TODO */ out_event.SetValue(DmntCheatManager::GetCheatProcessEventHandle());
std::abort();
} }
Result DmntCheatService::GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata) { Result DmntCheatService::GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata) {
/* TODO */ return DmntCheatManager::GetCheatProcessMetadata(out_metadata.GetPointer());
return 0xF601;
} }