2019-09-16 09:22:08 +01:00
|
|
|
/*
|
2020-01-24 10:10:40 +00:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2019-09-16 09:22:08 +01:00
|
|
|
*
|
|
|
|
* 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 <stratosphere.hpp>
|
|
|
|
|
2019-10-24 10:30:10 +01:00
|
|
|
namespace ams::dmnt::cheat {
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2020-07-08 01:07:23 +01:00
|
|
|
/* TODO: In libstratosphere, eventually? */
|
|
|
|
namespace impl {
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2020-07-08 01:07:23 +01:00
|
|
|
#define AMS_DMNT_I_CHEAT_INTERFACE_INTERFACE_INFO(C, H) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65000, void, HasCheatProcess, (sf::Out<bool> out)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65001, void, GetCheatProcessEvent, (sf::OutCopyHandle out_event)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65002, Result, GetCheatProcessMetadata, (sf::Out<CheatProcessMetadata> out_metadata)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65003, Result, ForceOpenCheatProcess, ()) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65004, Result, PauseCheatProcess, ()) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65005, Result, ResumeCheatProcess, ()) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65100, Result, GetCheatProcessMappingCount, (sf::Out<u64> out_count)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65101, Result, GetCheatProcessMappings, (const sf::OutArray<MemoryInfo> &mappings, sf::Out<u64> out_count, u64 offset)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65102, Result, ReadCheatProcessMemory, (const sf::OutBuffer &buffer, u64 address, u64 out_size)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65103, Result, WriteCheatProcessMemory, (const sf::InBuffer &buffer, u64 address, u64 in_size)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65104, Result, QueryCheatProcessMemory, (sf::Out<MemoryInfo> mapping, u64 address)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65200, Result, GetCheatCount, (sf::Out<u64> out_count)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65201, Result, GetCheats, (const sf::OutArray<CheatEntry> &cheats, sf::Out<u64> out_count, u64 offset)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65202, Result, GetCheatById, (sf::Out<CheatEntry> cheat, u32 cheat_id)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65203, Result, ToggleCheat, (u32 cheat_id)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65204, Result, AddCheat, (const CheatDefinition &cheat, sf::Out<u32> out_cheat_id, bool enabled)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65205, Result, RemoveCheat, (u32 cheat_id)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65206, Result, ReadStaticRegister, (sf::Out<u64> out, u8 which)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65207, Result, WriteStaticRegister, (u8 which, u64 value)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65208, Result, ResetStaticRegisters, ()) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65300, Result, GetFrozenAddressCount, (sf::Out<u64> out_count)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65301, Result, GetFrozenAddresses, (const sf::OutArray<FrozenAddressEntry> &addresses, sf::Out<u64> out_count, u64 offset)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65302, Result, GetFrozenAddress, (sf::Out<FrozenAddressEntry> entry, u64 address)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65303, Result, EnableFrozenAddress, (sf::Out<u64> out_value, u64 address, u64 width)) \
|
|
|
|
AMS_SF_METHOD_INFO(C, H, 65304, Result, DisableFrozenAddress, (u64 address))
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2020-07-08 01:07:23 +01:00
|
|
|
AMS_SF_DEFINE_INTERFACE(ICheatInterface, AMS_DMNT_I_CHEAT_INTERFACE_INTERFACE_INFO)
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2020-07-08 01:07:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class CheatService final {
|
|
|
|
public:
|
2019-10-18 05:18:27 +01:00
|
|
|
void HasCheatProcess(sf::Out<bool> out);
|
|
|
|
void GetCheatProcessEvent(sf::OutCopyHandle out_event);
|
|
|
|
Result GetCheatProcessMetadata(sf::Out<CheatProcessMetadata> out_metadata);
|
2019-09-16 09:22:08 +01:00
|
|
|
Result ForceOpenCheatProcess();
|
2020-04-25 01:24:15 +01:00
|
|
|
Result PauseCheatProcess();
|
|
|
|
Result ResumeCheatProcess();
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2019-10-18 05:18:27 +01:00
|
|
|
Result GetCheatProcessMappingCount(sf::Out<u64> out_count);
|
|
|
|
Result GetCheatProcessMappings(const sf::OutArray<MemoryInfo> &mappings, sf::Out<u64> out_count, u64 offset);
|
|
|
|
Result ReadCheatProcessMemory(const sf::OutBuffer &buffer, u64 address, u64 out_size);
|
|
|
|
Result WriteCheatProcessMemory(const sf::InBuffer &buffer, u64 address, u64 in_size);
|
|
|
|
Result QueryCheatProcessMemory(sf::Out<MemoryInfo> mapping, u64 address);
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2019-10-18 05:18:27 +01:00
|
|
|
Result GetCheatCount(sf::Out<u64> out_count);
|
|
|
|
Result GetCheats(const sf::OutArray<CheatEntry> &cheats, sf::Out<u64> out_count, u64 offset);
|
|
|
|
Result GetCheatById(sf::Out<CheatEntry> cheat, u32 cheat_id);
|
2019-09-16 09:22:08 +01:00
|
|
|
Result ToggleCheat(u32 cheat_id);
|
2019-10-18 05:18:27 +01:00
|
|
|
Result AddCheat(const CheatDefinition &cheat, sf::Out<u32> out_cheat_id, bool enabled);
|
2019-09-16 09:22:08 +01:00
|
|
|
Result RemoveCheat(u32 cheat_id);
|
2020-04-25 01:00:43 +01:00
|
|
|
Result ReadStaticRegister(sf::Out<u64> out, u8 which);
|
|
|
|
Result WriteStaticRegister(u8 which, u64 value);
|
|
|
|
Result ResetStaticRegisters();
|
2019-09-16 09:22:08 +01:00
|
|
|
|
2019-10-18 05:18:27 +01:00
|
|
|
Result GetFrozenAddressCount(sf::Out<u64> out_count);
|
|
|
|
Result GetFrozenAddresses(const sf::OutArray<FrozenAddressEntry> &addresses, sf::Out<u64> out_count, u64 offset);
|
|
|
|
Result GetFrozenAddress(sf::Out<FrozenAddressEntry> entry, u64 address);
|
|
|
|
Result EnableFrozenAddress(sf::Out<u64> out_value, u64 address, u64 width);
|
2019-09-16 09:22:08 +01:00
|
|
|
Result DisableFrozenAddress(u64 address);
|
|
|
|
};
|
2020-07-08 01:07:23 +01:00
|
|
|
static_assert(impl::IsICheatInterface<CheatService>);
|
2019-09-16 09:22:08 +01:00
|
|
|
|
|
|
|
}
|