diff --git a/stratosphere/dmnt/Makefile b/stratosphere/dmnt/Makefile
index 71c014dc5..61cc0123e 100644
--- a/stratosphere/dmnt/Makefile
+++ b/stratosphere/dmnt/Makefile
@@ -26,7 +26,7 @@ endif
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
-SOURCES := source
+SOURCES := source source/cheat source/cheat/impl
DATA := data
INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src
diff --git a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp
new file mode 100644
index 000000000..e0e5956fe
--- /dev/null
+++ b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.cpp
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2018-2019 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"
+#include "impl/dmnt_cheat_api.hpp"
+
+namespace sts::dmnt::cheat {
+
+ /* ========================================================================================= */
+ /* ==================================== Meta Commands ==================================== */
+ /* ========================================================================================= */
+
+ void CheatService::HasCheatProcess(Out out) {
+ out.SetValue(dmnt::cheat::impl::GetHasActiveCheatProcess());
+ }
+
+ void CheatService::GetCheatProcessEvent(Out out_event) {
+ out_event.SetValue(dmnt::cheat::impl::GetCheatProcessEventHandle());
+ }
+
+ Result CheatService::GetCheatProcessMetadata(Out out_metadata) {
+ return dmnt::cheat::impl::GetCheatProcessMetadata(out_metadata.GetPointer());
+ }
+
+ Result CheatService::ForceOpenCheatProcess() {
+ if (R_FAILED(dmnt::cheat::impl::ForceOpenCheatProcess())) {
+ return ResultDmntCheatNotAttached;
+ }
+
+ return ResultSuccess;
+ }
+
+ /* ========================================================================================= */
+ /* =================================== Memory Commands =================================== */
+ /* ========================================================================================= */
+
+ Result CheatService::GetCheatProcessMappingCount(Out out_count) {
+ return dmnt::cheat::impl::GetCheatProcessMappingCount(out_count.GetPointer());
+ }
+
+ Result CheatService::GetCheatProcessMappings(OutBuffer mappings, Out out_count, u64 offset) {
+ if (mappings.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ return dmnt::cheat::impl::GetCheatProcessMappings(mappings.buffer, mappings.num_elements, out_count.GetPointer(), offset);
+ }
+
+ Result CheatService::ReadCheatProcessMemory(OutBuffer buffer, u64 address, u64 out_size) {
+ if (buffer.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.buffer, std::min(out_size, buffer.num_elements));
+ }
+
+ Result CheatService::WriteCheatProcessMemory(InBuffer buffer, u64 address, u64 in_size) {
+ if (buffer.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.buffer, std::min(in_size, buffer.num_elements));
+ }
+
+ Result CheatService::QueryCheatProcessMemory(Out mapping, u64 address) {
+ return dmnt::cheat::impl::QueryCheatProcessMemory(mapping.GetPointer(), address);
+ }
+
+ /* ========================================================================================= */
+ /* =================================== Cheat Commands ==================================== */
+ /* ========================================================================================= */
+
+ Result CheatService::GetCheatCount(Out out_count) {
+ return dmnt::cheat::impl::GetCheatCount(out_count.GetPointer());
+ }
+
+ Result CheatService::GetCheats(OutBuffer cheats, Out out_count, u64 offset) {
+ if (cheats.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ return dmnt::cheat::impl::GetCheats(cheats.buffer, cheats.num_elements, out_count.GetPointer(), offset);
+ }
+
+ Result CheatService::GetCheatById(OutBuffer cheat, u32 cheat_id) {
+ if (cheat.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ if (cheat.num_elements < 1) {
+ return ResultDmntCheatInvalidBuffer;
+ }
+
+ return dmnt::cheat::impl::GetCheatById(cheat.buffer, cheat_id);
+ }
+
+ Result CheatService::ToggleCheat(u32 cheat_id) {
+ return dmnt::cheat::impl::ToggleCheat(cheat_id);
+ }
+
+ Result CheatService::AddCheat(InBuffer cheat, Out out_cheat_id, bool enabled) {
+ if (cheat.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ if (cheat.num_elements < 1) {
+ return ResultDmntCheatInvalidBuffer;
+ }
+
+ return dmnt::cheat::impl::AddCheat(out_cheat_id.GetPointer(), cheat.buffer, enabled);
+ }
+
+ Result CheatService::RemoveCheat(u32 cheat_id) {
+ return dmnt::cheat::impl::RemoveCheat(cheat_id);
+ }
+
+ /* ========================================================================================= */
+ /* =================================== Address Commands ================================== */
+ /* ========================================================================================= */
+
+ Result CheatService::GetFrozenAddressCount(Out out_count) {
+ return dmnt::cheat::impl::GetFrozenAddressCount(out_count.GetPointer());
+ }
+
+ Result CheatService::GetFrozenAddresses(OutBuffer frz_addrs, Out out_count, u64 offset) {
+ if (frz_addrs.buffer == nullptr) {
+ return ResultDmntCheatNullBuffer;
+ }
+
+ return dmnt::cheat::impl::GetFrozenAddresses(frz_addrs.buffer, frz_addrs.num_elements, out_count.GetPointer(), offset);
+ }
+
+ Result CheatService::GetFrozenAddress(Out entry, u64 address) {
+ return dmnt::cheat::impl::GetFrozenAddress(entry.GetPointer(), address);
+ }
+
+ Result CheatService::EnableFrozenAddress(Out out_value, u64 address, u64 width) {
+ switch (width) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ break;
+ default:
+ return ResultDmntCheatInvalidFreezeWidth;
+ }
+
+ return dmnt::cheat::impl::EnableFrozenAddress(out_value.GetPointer(), address, width);
+ }
+
+ Result CheatService::DisableFrozenAddress(u64 address) {
+ return dmnt::cheat::impl::DisableFrozenAddress(address);
+ }
+
+}
diff --git a/stratosphere/dmnt/source/cheat/dmnt_cheat_service.hpp b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.hpp
new file mode 100644
index 000000000..2cb29cc6b
--- /dev/null
+++ b/stratosphere/dmnt/source/cheat/dmnt_cheat_service.hpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2018-2019 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
+
+namespace sts::dmnt::cheat {
+
+ class CheatService final : public IServiceObject {
+ private:
+ enum class CommandId {
+ /* Meta */
+ HasCheatProcess = 65000,
+ GetCheatProcessEvent = 65001,
+ GetCheatProcessMetadata = 65002,
+ ForceOpenCheatProcess = 65003,
+
+ /* Interact with Memory */
+ GetCheatProcessMappingCount = 65100,
+ GetCheatProcessMappings = 65101,
+ ReadCheatProcessMemory = 65102,
+ WriteCheatProcessMemory = 65103,
+ QueryCheatProcessMemory = 65104,
+
+ /* Interact with Cheats */
+ GetCheatCount = 65200,
+ GetCheats = 65201,
+ GetCheatById = 65202,
+ ToggleCheat = 65203,
+ AddCheat = 65204,
+ RemoveCheat = 65205,
+
+ /* Interact with Frozen Addresses */
+ GetFrozenAddressCount = 65300,
+ GetFrozenAddresses = 65301,
+ GetFrozenAddress = 65302,
+ EnableFrozenAddress = 65303,
+ DisableFrozenAddress = 65304,
+ };
+ private:
+ void HasCheatProcess(Out out);
+ void GetCheatProcessEvent(Out out_event);
+ Result GetCheatProcessMetadata(Out out_metadata);
+ Result ForceOpenCheatProcess();
+
+ 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 QueryCheatProcessMemory(Out mapping, u64 address);
+
+ 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, Out out_cheat_id, bool enabled);
+ Result RemoveCheat(u32 cheat_id);
+
+ Result GetFrozenAddressCount(Out out_count);
+ Result GetFrozenAddresses(OutBuffer addresses, Out out_count, u64 offset);
+ Result GetFrozenAddress(Out entry, u64 address);
+ Result EnableFrozenAddress(Out out_value, u64 address, u64 width);
+ Result DisableFrozenAddress(u64 address);
+
+ public:
+ DEFINE_SERVICE_DISPATCH_TABLE {
+ MAKE_SERVICE_COMMAND_META(CheatService, HasCheatProcess),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatProcessEvent),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatProcessMetadata),
+ MAKE_SERVICE_COMMAND_META(CheatService, ForceOpenCheatProcess),
+
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatProcessMappingCount),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatProcessMappings),
+ MAKE_SERVICE_COMMAND_META(CheatService, ReadCheatProcessMemory),
+ MAKE_SERVICE_COMMAND_META(CheatService, WriteCheatProcessMemory),
+ MAKE_SERVICE_COMMAND_META(CheatService, QueryCheatProcessMemory),
+
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatCount),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheats),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetCheatById),
+ MAKE_SERVICE_COMMAND_META(CheatService, ToggleCheat),
+ MAKE_SERVICE_COMMAND_META(CheatService, AddCheat),
+ MAKE_SERVICE_COMMAND_META(CheatService, RemoveCheat),
+
+ MAKE_SERVICE_COMMAND_META(CheatService, GetFrozenAddressCount),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetFrozenAddresses),
+ MAKE_SERVICE_COMMAND_META(CheatService, GetFrozenAddress),
+ MAKE_SERVICE_COMMAND_META(CheatService, EnableFrozenAddress),
+ MAKE_SERVICE_COMMAND_META(CheatService, DisableFrozenAddress),
+ };
+ };
+
+}
diff --git a/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp
new file mode 100644
index 000000000..c315b8dec
--- /dev/null
+++ b/stratosphere/dmnt/source/cheat/impl/dmnt_cheat_api.cpp
@@ -0,0 +1,1084 @@
+/*
+ * Copyright (c) 2018-2019 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