mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-17 17:36:44 +00:00
dmnt: Skeleton cheat service API.
This commit is contained in:
parent
89503049b3
commit
434f600f95
5 changed files with 239 additions and 3 deletions
|
@ -30,7 +30,8 @@
|
||||||
"fatal:u"
|
"fatal:u"
|
||||||
],
|
],
|
||||||
"service_host": [
|
"service_host": [
|
||||||
"dmnt:-"
|
"dmnt:-",
|
||||||
|
"dmnt:cht"
|
||||||
],
|
],
|
||||||
"kernel_capabilities": [{
|
"kernel_capabilities": [{
|
||||||
"type": "kernel_flags",
|
"type": "kernel_flags",
|
||||||
|
|
101
stratosphere/dmnt/source/dmnt_cheat_service.cpp
Normal file
101
stratosphere/dmnt/source/dmnt_cheat_service.cpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <switch.h>
|
||||||
|
#include "dmnt_cheat_service.hpp"
|
||||||
|
|
||||||
|
void DmntCheatService::HasCheatProcess(Out<bool> out) {
|
||||||
|
/* TODO */
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DmntCheatService::GetCheatProcessEvent(Out<CopiedHandle> out_event) {
|
||||||
|
/* TODO */
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheatProcessMappingCount(Out<u64> out_count) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheatProcessMappings(OutBuffer<MemoryInfo> mappings, Out<u64> out_count, u64 offset) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::ReadCheatProcessMemory(OutBuffer<u8> buffer, u64 address, u64 out_size) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::WriteCheatProcessMemory(InBuffer<u8> buffer, u64 address, u64 in_size) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheatCount(Out<u64> out_count) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheats(OutBuffer<CheatEntry> cheats, Out<u64> out_count, u64 offset) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::GetCheatById(OutBuffer<CheatEntry> cheat, u32 cheat_id) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::ToggleCheat(u32 cheat_id) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::AddCheat(InBuffer<CheatEntry> cheat) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::RemoveCheat(u32 cheat_id) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result DmntCheatService::GetFrozenAddressCount(Out<u64> out_count) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::GetFrozenAddresses(OutBuffer<uintptr_t> addresses, Out<u64> out_count, u64 offset) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result DmntCheatService::ToggleAddressFrozen(uintptr_t address) {
|
||||||
|
/* TODO */
|
||||||
|
return 0xF601;
|
||||||
|
}
|
93
stratosphere/dmnt/source/dmnt_cheat_service.hpp
Normal file
93
stratosphere/dmnt/source/dmnt_cheat_service.hpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <switch.h>
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
|
#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<bool> out);
|
||||||
|
void GetCheatProcessEvent(Out<CopiedHandle> out_event);
|
||||||
|
Result GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata);
|
||||||
|
|
||||||
|
Result GetCheatProcessMappingCount(Out<u64> out_count);
|
||||||
|
Result GetCheatProcessMappings(OutBuffer<MemoryInfo> mappings, Out<u64> out_count, u64 offset);
|
||||||
|
Result ReadCheatProcessMemory(OutBuffer<u8> buffer, u64 address, u64 out_size);
|
||||||
|
Result WriteCheatProcessMemory(InBuffer<u8> buffer, u64 address, u64 in_size);
|
||||||
|
|
||||||
|
Result GetCheatCount(Out<u64> out_count);
|
||||||
|
Result GetCheats(OutBuffer<CheatEntry> cheats, Out<u64> out_count, u64 offset);
|
||||||
|
Result GetCheatById(OutBuffer<CheatEntry> cheat, u32 cheat_id);
|
||||||
|
Result ToggleCheat(u32 cheat_id);
|
||||||
|
Result AddCheat(InBuffer<CheatEntry> cheat);
|
||||||
|
Result RemoveCheat(u32 cheat_id);
|
||||||
|
|
||||||
|
Result GetFrozenAddressCount(Out<u64> out_count);
|
||||||
|
Result GetFrozenAddresses(OutBuffer<uintptr_t> addresses, Out<u64> out_count, u64 offset);
|
||||||
|
Result ToggleAddressFrozen(uintptr_t address);
|
||||||
|
|
||||||
|
public:
|
||||||
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_HasCheatProcess, &DmntCheatService::HasCheatProcess>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatProcessEvent, &DmntCheatService::GetCheatProcessEvent>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatProcessMetadata, &DmntCheatService::GetCheatProcessMetadata>(),
|
||||||
|
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatProcessMappingCount, &DmntCheatService::GetCheatProcessMappingCount>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatProcessMappings, &DmntCheatService::GetCheatProcessMappings>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_ReadCheatProcessMemory, &DmntCheatService::ReadCheatProcessMemory>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_WriteCheatProcessMemory, &DmntCheatService::WriteCheatProcessMemory>(),
|
||||||
|
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatCount, &DmntCheatService::GetCheatCount>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheats, &DmntCheatService::GetCheats>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetCheatById, &DmntCheatService::GetCheatById>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_ToggleCheat, &DmntCheatService::ToggleCheat>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_AddCheat, &DmntCheatService::AddCheat>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_RemoveCheat, &DmntCheatService::RemoveCheat>(),
|
||||||
|
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetFrozenAddressCount, &DmntCheatService::GetFrozenAddressCount>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_GetFrozenAddresses, &DmntCheatService::GetFrozenAddresses>(),
|
||||||
|
MakeServiceCommandMeta<DmntCheat_Cmd_ToggleAddressFrozen, &DmntCheatService::ToggleAddressFrozen>(),
|
||||||
|
};
|
||||||
|
};
|
39
stratosphere/dmnt/source/dmnt_cheat_types.hpp
Normal file
39
stratosphere/dmnt/source/dmnt_cheat_types.hpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <switch.h>
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
|
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];
|
||||||
|
};
|
|
@ -24,6 +24,7 @@
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
#include "dmnt_service.hpp"
|
#include "dmnt_service.hpp"
|
||||||
|
#include "dmnt_cheat_service.hpp"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern u32 __start__;
|
extern u32 __start__;
|
||||||
|
@ -124,11 +125,12 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
consoleDebugInit(debugDevice_SVC);
|
consoleDebugInit(debugDevice_SVC);
|
||||||
|
|
||||||
/* Nintendo uses four threads. */
|
/* Nintendo uses four threads. Add a fifth for our cheat service. */
|
||||||
auto server_manager = new WaitableManager(4);
|
auto server_manager = new WaitableManager(5);
|
||||||
|
|
||||||
/* Create services. */
|
/* Create services. */
|
||||||
server_manager->AddWaitable(new ServiceServer<DebugMonitorService>("dmnt:-", 4));
|
server_manager->AddWaitable(new ServiceServer<DebugMonitorService>("dmnt:-", 4));
|
||||||
|
server_manager->AddWaitable(new ServiceServer<DmntCheatService>("dmnt:cht", 1));
|
||||||
|
|
||||||
/* Loop forever, servicing our services. */
|
/* Loop forever, servicing our services. */
|
||||||
server_manager->Process();
|
server_manager->Process();
|
||||||
|
|
Loading…
Reference in a new issue