diff --git a/stratosphere/dmnt/dmnt.json b/stratosphere/dmnt/dmnt.json index 0be7e94ed..cbf0e4e6c 100644 --- a/stratosphere/dmnt/dmnt.json +++ b/stratosphere/dmnt/dmnt.json @@ -30,7 +30,8 @@ "fatal:u" ], "service_host": [ - "dmnt:-" + "dmnt:-", + "dmnt:cht" ], "kernel_capabilities": [{ "type": "kernel_flags", diff --git a/stratosphere/dmnt/source/dmnt_cheat_service.cpp b/stratosphere/dmnt/source/dmnt_cheat_service.cpp new file mode 100644 index 000000000..9b154ced4 --- /dev/null +++ b/stratosphere/dmnt/source/dmnt_cheat_service.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "dmnt_cheat_service.hpp" + +void DmntCheatService::HasCheatProcess(Out out) { + /* TODO */ + std::abort(); +} + +void DmntCheatService::GetCheatProcessEvent(Out out_event) { + /* TODO */ + std::abort(); +} + +Result DmntCheatService::GetCheatProcessMetadata(Out out_metadata) { + /* TODO */ + return 0xF601; +} + + +Result DmntCheatService::GetCheatProcessMappingCount(Out out_count) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::GetCheatProcessMappings(OutBuffer mappings, Out out_count, u64 offset) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::ReadCheatProcessMemory(OutBuffer buffer, u64 address, u64 out_size) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::WriteCheatProcessMemory(InBuffer buffer, u64 address, u64 in_size) { + /* TODO */ + return 0xF601; +} + + +Result DmntCheatService::GetCheatCount(Out out_count) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::GetCheats(OutBuffer cheats, Out out_count, u64 offset) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::GetCheatById(OutBuffer cheat, u32 cheat_id) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::ToggleCheat(u32 cheat_id) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::AddCheat(InBuffer cheat) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::RemoveCheat(u32 cheat_id) { + /* TODO */ + return 0xF601; +} + + +Result DmntCheatService::GetFrozenAddressCount(Out out_count) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::GetFrozenAddresses(OutBuffer addresses, Out out_count, u64 offset) { + /* TODO */ + return 0xF601; +} + +Result DmntCheatService::ToggleAddressFrozen(uintptr_t address) { + /* TODO */ + return 0xF601; +} diff --git a/stratosphere/dmnt/source/dmnt_cheat_service.hpp b/stratosphere/dmnt/source/dmnt_cheat_service.hpp new file mode 100644 index 000000000..7ceb91032 --- /dev/null +++ b/stratosphere/dmnt/source/dmnt_cheat_service.hpp @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2018 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include + +#include "dmnt_cheat_types.hpp" + +enum DmntCheatCmd { + /* Meta */ + DmntCheat_Cmd_HasCheatProcess = 65000, + DmntCheat_Cmd_GetCheatProcessEvent = 65001, + DmntCheat_Cmd_GetCheatProcessMetadata = 65002, + + /* Interact with Memory */ + DmntCheat_Cmd_GetCheatProcessMappingCount = 65100, + DmntCheat_Cmd_GetCheatProcessMappings = 65101, + DmntCheat_Cmd_ReadCheatProcessMemory = 65102, + DmntCheat_Cmd_WriteCheatProcessMemory = 65103, + + /* Interact with Cheats */ + DmntCheat_Cmd_GetCheatCount = 65200, + DmntCheat_Cmd_GetCheats = 65201, + DmntCheat_Cmd_GetCheatById = 65202, + DmntCheat_Cmd_ToggleCheat = 65203, + DmntCheat_Cmd_AddCheat = 65204, + DmntCheat_Cmd_RemoveCheat = 65205, + + /* Interact with Frozen Addresses */ + DmntCheat_Cmd_GetFrozenAddressCount = 65300, + DmntCheat_Cmd_GetFrozenAddresses = 65301, + DmntCheat_Cmd_ToggleAddressFrozen = 65302, +}; + +class DmntCheatService final : public IServiceObject { + private: + void HasCheatProcess(Out out); + void GetCheatProcessEvent(Out out_event); + Result GetCheatProcessMetadata(Out out_metadata); + + Result GetCheatProcessMappingCount(Out out_count); + Result GetCheatProcessMappings(OutBuffer mappings, Out out_count, u64 offset); + Result ReadCheatProcessMemory(OutBuffer buffer, u64 address, u64 out_size); + Result WriteCheatProcessMemory(InBuffer buffer, u64 address, u64 in_size); + + Result GetCheatCount(Out out_count); + Result GetCheats(OutBuffer cheats, Out out_count, u64 offset); + Result GetCheatById(OutBuffer cheat, u32 cheat_id); + Result ToggleCheat(u32 cheat_id); + Result AddCheat(InBuffer cheat); + Result RemoveCheat(u32 cheat_id); + + Result GetFrozenAddressCount(Out out_count); + Result GetFrozenAddresses(OutBuffer addresses, Out out_count, u64 offset); + Result ToggleAddressFrozen(uintptr_t address); + + public: + DEFINE_SERVICE_DISPATCH_TABLE { + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + MakeServiceCommandMeta(), + }; +}; diff --git a/stratosphere/dmnt/source/dmnt_cheat_types.hpp b/stratosphere/dmnt/source/dmnt_cheat_types.hpp new file mode 100644 index 000000000..b077d1e09 --- /dev/null +++ b/stratosphere/dmnt/source/dmnt_cheat_types.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include + +struct MemoryRegionExtents { + u64 base; + u64 size; +}; + +struct CheatProcessMetadata { + MemoryRegionExtents main_nso_extents; + MemoryRegionExtents heap_extents; + MemoryRegionExtents alias_extents; + MemoryRegionExtents address_space_extents; + u64 main_nso_build_id[4]; +}; + +struct CheatEntry { + bool enabled; + uint32_t cheat_id; + char readable_name[0x20]; + uint32_t opcodes[0x100]; +}; \ No newline at end of file diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp index fc4917faa..bf56137b7 100644 --- a/stratosphere/dmnt/source/dmnt_main.cpp +++ b/stratosphere/dmnt/source/dmnt_main.cpp @@ -24,6 +24,7 @@ #include #include "dmnt_service.hpp" +#include "dmnt_cheat_service.hpp" extern "C" { extern u32 __start__; @@ -124,11 +125,12 @@ int main(int argc, char **argv) { consoleDebugInit(debugDevice_SVC); - /* Nintendo uses four threads. */ - auto server_manager = new WaitableManager(4); + /* Nintendo uses four threads. Add a fifth for our cheat service. */ + auto server_manager = new WaitableManager(5); /* Create services. */ server_manager->AddWaitable(new ServiceServer("dmnt:-", 4)); + server_manager->AddWaitable(new ServiceServer("dmnt:cht", 1)); /* Loop forever, servicing our services. */ server_manager->Process();