dmnt: update for new-ipc
This commit is contained in:
@@ -24,15 +24,15 @@ namespace sts::dmnt::cheat {
|
||||
/* ==================================== Meta Commands ==================================== */
|
||||
/* ========================================================================================= */
|
||||
|
||||
void CheatService::HasCheatProcess(Out<bool> out) {
|
||||
void CheatService::HasCheatProcess(sf::Out<bool> out) {
|
||||
out.SetValue(dmnt::cheat::impl::GetHasActiveCheatProcess());
|
||||
}
|
||||
|
||||
void CheatService::GetCheatProcessEvent(Out<CopiedHandle> out_event) {
|
||||
void CheatService::GetCheatProcessEvent(sf::OutCopyHandle out_event) {
|
||||
out_event.SetValue(dmnt::cheat::impl::GetCheatProcessEventHandle());
|
||||
}
|
||||
|
||||
Result CheatService::GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata) {
|
||||
Result CheatService::GetCheatProcessMetadata(sf::Out<CheatProcessMetadata> out_metadata) {
|
||||
return dmnt::cheat::impl::GetCheatProcessMetadata(out_metadata.GetPointer());
|
||||
}
|
||||
|
||||
@@ -48,35 +48,35 @@ namespace sts::dmnt::cheat {
|
||||
/* =================================== Memory Commands =================================== */
|
||||
/* ========================================================================================= */
|
||||
|
||||
Result CheatService::GetCheatProcessMappingCount(Out<u64> out_count) {
|
||||
Result CheatService::GetCheatProcessMappingCount(sf::Out<u64> out_count) {
|
||||
return dmnt::cheat::impl::GetCheatProcessMappingCount(out_count.GetPointer());
|
||||
}
|
||||
|
||||
Result CheatService::GetCheatProcessMappings(OutBuffer<MemoryInfo> mappings, Out<u64> out_count, u64 offset) {
|
||||
if (mappings.buffer == nullptr) {
|
||||
Result CheatService::GetCheatProcessMappings(const sf::OutArray<MemoryInfo> &mappings, sf::Out<u64> out_count, u64 offset) {
|
||||
if (mappings.GetPointer() == nullptr) {
|
||||
return ResultDmntCheatNullBuffer;
|
||||
}
|
||||
|
||||
return dmnt::cheat::impl::GetCheatProcessMappings(mappings.buffer, mappings.num_elements, out_count.GetPointer(), offset);
|
||||
return dmnt::cheat::impl::GetCheatProcessMappings(mappings.GetPointer(), mappings.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
Result CheatService::ReadCheatProcessMemory(OutBuffer<u8> buffer, u64 address, u64 out_size) {
|
||||
if (buffer.buffer == nullptr) {
|
||||
Result CheatService::ReadCheatProcessMemory(const sf::OutBuffer &buffer, u64 address, u64 out_size) {
|
||||
if (buffer.GetPointer() == nullptr) {
|
||||
return ResultDmntCheatNullBuffer;
|
||||
}
|
||||
|
||||
return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.buffer, std::min(out_size, buffer.num_elements));
|
||||
return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.GetPointer(), std::min(out_size, buffer.GetSize()));
|
||||
}
|
||||
|
||||
Result CheatService::WriteCheatProcessMemory(InBuffer<u8> buffer, u64 address, u64 in_size) {
|
||||
if (buffer.buffer == nullptr) {
|
||||
Result CheatService::WriteCheatProcessMemory(const sf::InBuffer &buffer, u64 address, u64 in_size) {
|
||||
if (buffer.GetPointer() == nullptr) {
|
||||
return ResultDmntCheatNullBuffer;
|
||||
}
|
||||
|
||||
return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.buffer, std::min(in_size, buffer.num_elements));
|
||||
return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.GetPointer(), std::min(in_size, buffer.GetSize()));
|
||||
}
|
||||
|
||||
Result CheatService::QueryCheatProcessMemory(Out<MemoryInfo> mapping, u64 address) {
|
||||
Result CheatService::QueryCheatProcessMemory(sf::Out<MemoryInfo> mapping, u64 address) {
|
||||
return dmnt::cheat::impl::QueryCheatProcessMemory(mapping.GetPointer(), address);
|
||||
}
|
||||
|
||||
@@ -84,44 +84,28 @@ namespace sts::dmnt::cheat {
|
||||
/* =================================== Cheat Commands ==================================== */
|
||||
/* ========================================================================================= */
|
||||
|
||||
Result CheatService::GetCheatCount(Out<u64> out_count) {
|
||||
Result CheatService::GetCheatCount(sf::Out<u64> out_count) {
|
||||
return dmnt::cheat::impl::GetCheatCount(out_count.GetPointer());
|
||||
}
|
||||
|
||||
Result CheatService::GetCheats(OutBuffer<CheatEntry> cheats, Out<u64> out_count, u64 offset) {
|
||||
if (cheats.buffer == nullptr) {
|
||||
Result CheatService::GetCheats(const sf::OutArray<CheatEntry> &cheats, sf::Out<u64> out_count, u64 offset) {
|
||||
if (cheats.GetPointer() == nullptr) {
|
||||
return ResultDmntCheatNullBuffer;
|
||||
}
|
||||
|
||||
return dmnt::cheat::impl::GetCheats(cheats.buffer, cheats.num_elements, out_count.GetPointer(), offset);
|
||||
return dmnt::cheat::impl::GetCheats(cheats.GetPointer(), cheats.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
Result CheatService::GetCheatById(OutBuffer<CheatEntry> 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::GetCheatById(sf::Out<CheatEntry> cheat, u32 cheat_id) {
|
||||
return dmnt::cheat::impl::GetCheatById(cheat.GetPointer(), cheat_id);
|
||||
}
|
||||
|
||||
Result CheatService::ToggleCheat(u32 cheat_id) {
|
||||
return dmnt::cheat::impl::ToggleCheat(cheat_id);
|
||||
}
|
||||
|
||||
Result CheatService::AddCheat(InBuffer<CheatDefinition> cheat, Out<u32> 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::AddCheat(const CheatDefinition &cheat, sf::Out<u32> out_cheat_id, bool enabled) {
|
||||
return dmnt::cheat::impl::AddCheat(out_cheat_id.GetPointer(), cheat, enabled);
|
||||
}
|
||||
|
||||
Result CheatService::RemoveCheat(u32 cheat_id) {
|
||||
@@ -132,23 +116,23 @@ namespace sts::dmnt::cheat {
|
||||
/* =================================== Address Commands ================================== */
|
||||
/* ========================================================================================= */
|
||||
|
||||
Result CheatService::GetFrozenAddressCount(Out<u64> out_count) {
|
||||
Result CheatService::GetFrozenAddressCount(sf::Out<u64> out_count) {
|
||||
return dmnt::cheat::impl::GetFrozenAddressCount(out_count.GetPointer());
|
||||
}
|
||||
|
||||
Result CheatService::GetFrozenAddresses(OutBuffer<FrozenAddressEntry> frz_addrs, Out<u64> out_count, u64 offset) {
|
||||
if (frz_addrs.buffer == nullptr) {
|
||||
Result CheatService::GetFrozenAddresses(const sf::OutArray<FrozenAddressEntry> &addresses, sf::Out<u64> out_count, u64 offset) {
|
||||
if (addresses.GetPointer() == nullptr) {
|
||||
return ResultDmntCheatNullBuffer;
|
||||
}
|
||||
|
||||
return dmnt::cheat::impl::GetFrozenAddresses(frz_addrs.buffer, frz_addrs.num_elements, out_count.GetPointer(), offset);
|
||||
return dmnt::cheat::impl::GetFrozenAddresses(addresses.GetPointer(), addresses.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
Result CheatService::GetFrozenAddress(Out<FrozenAddressEntry> entry, u64 address) {
|
||||
Result CheatService::GetFrozenAddress(sf::Out<FrozenAddressEntry> entry, u64 address) {
|
||||
return dmnt::cheat::impl::GetFrozenAddress(entry.GetPointer(), address);
|
||||
}
|
||||
|
||||
Result CheatService::EnableFrozenAddress(Out<u64> out_value, u64 address, u64 width) {
|
||||
Result CheatService::EnableFrozenAddress(sf::Out<u64> out_value, u64 address, u64 width) {
|
||||
switch (width) {
|
||||
case 1:
|
||||
case 2:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
namespace sts::dmnt::cheat {
|
||||
|
||||
class CheatService final : public IServiceObject {
|
||||
class CheatService final : public sf::IServiceObject {
|
||||
private:
|
||||
enum class CommandId {
|
||||
/* Meta */
|
||||
@@ -53,55 +53,55 @@ namespace sts::dmnt::cheat {
|
||||
DisableFrozenAddress = 65304,
|
||||
};
|
||||
private:
|
||||
void HasCheatProcess(Out<bool> out);
|
||||
void GetCheatProcessEvent(Out<CopiedHandle> out_event);
|
||||
Result GetCheatProcessMetadata(Out<CheatProcessMetadata> out_metadata);
|
||||
void HasCheatProcess(sf::Out<bool> out);
|
||||
void GetCheatProcessEvent(sf::OutCopyHandle out_event);
|
||||
Result GetCheatProcessMetadata(sf::Out<CheatProcessMetadata> out_metadata);
|
||||
Result ForceOpenCheatProcess();
|
||||
|
||||
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 QueryCheatProcessMemory(Out<MemoryInfo> mapping, u64 address);
|
||||
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);
|
||||
|
||||
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 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);
|
||||
Result ToggleCheat(u32 cheat_id);
|
||||
Result AddCheat(InBuffer<CheatDefinition> cheat, Out<u32> out_cheat_id, bool enabled);
|
||||
Result AddCheat(const CheatDefinition &cheat, sf::Out<u32> out_cheat_id, bool enabled);
|
||||
Result RemoveCheat(u32 cheat_id);
|
||||
|
||||
Result GetFrozenAddressCount(Out<u64> out_count);
|
||||
Result GetFrozenAddresses(OutBuffer<FrozenAddressEntry> addresses, Out<u64> out_count, u64 offset);
|
||||
Result GetFrozenAddress(Out<FrozenAddressEntry> entry, u64 address);
|
||||
Result EnableFrozenAddress(Out<u64> out_value, u64 address, u64 width);
|
||||
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);
|
||||
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(HasCheatProcess),
|
||||
MAKE_SERVICE_COMMAND_META(GetCheatProcessEvent),
|
||||
MAKE_SERVICE_COMMAND_META(GetCheatProcessMetadata),
|
||||
MAKE_SERVICE_COMMAND_META(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(GetCheatProcessMappingCount),
|
||||
MAKE_SERVICE_COMMAND_META(GetCheatProcessMappings),
|
||||
MAKE_SERVICE_COMMAND_META(ReadCheatProcessMemory),
|
||||
MAKE_SERVICE_COMMAND_META(WriteCheatProcessMemory),
|
||||
MAKE_SERVICE_COMMAND_META(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(GetCheatCount),
|
||||
MAKE_SERVICE_COMMAND_META(GetCheats),
|
||||
MAKE_SERVICE_COMMAND_META(GetCheatById),
|
||||
MAKE_SERVICE_COMMAND_META(ToggleCheat),
|
||||
MAKE_SERVICE_COMMAND_META(AddCheat),
|
||||
MAKE_SERVICE_COMMAND_META(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),
|
||||
MAKE_SERVICE_COMMAND_META(GetFrozenAddressCount),
|
||||
MAKE_SERVICE_COMMAND_META(GetFrozenAddresses),
|
||||
MAKE_SERVICE_COMMAND_META(GetFrozenAddress),
|
||||
MAKE_SERVICE_COMMAND_META(EnableFrozenAddress),
|
||||
MAKE_SERVICE_COMMAND_META(DisableFrozenAddress),
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
bool enable_cheats_by_default = true;
|
||||
bool always_save_cheat_toggles = false;
|
||||
bool should_save_cheat_toggles = false;
|
||||
CheatEntry cheat_entries[MaxCheatCount];
|
||||
CheatEntry cheat_entries[MaxCheatCount] = {};
|
||||
std::map<u64, FrozenAddressValue> frozen_addresses_map;
|
||||
private:
|
||||
static void DetectLaunchThread(void *_this);
|
||||
@@ -146,11 +146,11 @@ namespace sts::dmnt::cheat::impl {
|
||||
|
||||
bool HasActiveCheatProcess() {
|
||||
/* Note: This function *MUST* be called only with the cheat lock held. */
|
||||
u64 tmp;
|
||||
os::ProcessId pid;
|
||||
bool has_cheat_process = this->cheat_process_debug_handle != INVALID_HANDLE;
|
||||
has_cheat_process &= R_SUCCEEDED(svcGetProcessId(&tmp, this->cheat_process_debug_handle));
|
||||
has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(&tmp));
|
||||
has_cheat_process &= (tmp == this->cheat_process_metadata.process_id);
|
||||
has_cheat_process &= R_SUCCEEDED(os::GetProcessId(&pid, this->cheat_process_debug_handle));
|
||||
has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(&pid));
|
||||
has_cheat_process &= (pid == this->cheat_process_metadata.process_id);
|
||||
|
||||
if (!has_cheat_process) {
|
||||
this->CloseActiveCheatProcess();
|
||||
@@ -176,7 +176,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
return h;
|
||||
}
|
||||
|
||||
void StartProcess(u64 process_id) const {
|
||||
void StartProcess(os::ProcessId process_id) const {
|
||||
R_ASSERT(pm::dmnt::StartProcess(process_id));
|
||||
}
|
||||
|
||||
@@ -404,12 +404,12 @@ namespace sts::dmnt::cheat::impl {
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition *def, bool enabled) {
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled) {
|
||||
std::scoped_lock lk(this->cheat_lock);
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
if (def->num_opcodes == 0 || def->num_opcodes > util::size(def->opcodes)) {
|
||||
if (def.num_opcodes == 0 || def.num_opcodes > util::size(def.opcodes)) {
|
||||
return ResultDmntCheatInvalidCheat;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
}
|
||||
|
||||
new_entry->enabled = enabled;
|
||||
new_entry->definition = *def;
|
||||
new_entry->definition = def;
|
||||
|
||||
/* Trigger a VM reload. */
|
||||
this->SetNeedsReloadVm(true);
|
||||
@@ -630,7 +630,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
if (on_process_launch) {
|
||||
this->StartProcess(this->cheat_process_metadata.process_id);
|
||||
}
|
||||
this->cheat_process_metadata.process_id = 0;
|
||||
this->cheat_process_metadata.process_id = os::ProcessId{};
|
||||
};
|
||||
|
||||
/* Get process handle, use it to learn memory extents. */
|
||||
@@ -667,7 +667,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
u32 num_modules;
|
||||
|
||||
/* TODO: ldr::dmnt:: */
|
||||
R_ASSERT_IF_NEW_PROCESS(ldrDmntGetModuleInfos(this->cheat_process_metadata.process_id, proc_modules, util::size(proc_modules), &num_modules));
|
||||
R_ASSERT_IF_NEW_PROCESS(ldrDmntGetModuleInfos(static_cast<u64>(this->cheat_process_metadata.process_id), proc_modules, util::size(proc_modules), &num_modules));
|
||||
|
||||
/* All applications must have two modules. */
|
||||
/* Only accept one (which means we're attaching to HBL) */
|
||||
@@ -696,7 +696,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
}
|
||||
|
||||
/* Open a debug handle. */
|
||||
R_ASSERT_IF_NEW_PROCESS(svcDebugActiveProcess(&this->cheat_process_debug_handle, this->cheat_process_metadata.process_id));
|
||||
R_ASSERT_IF_NEW_PROCESS(svcDebugActiveProcess(&this->cheat_process_debug_handle, static_cast<u64>(this->cheat_process_metadata.process_id)));
|
||||
|
||||
/* Cancel process guard. */
|
||||
proc_guard.Cancel();
|
||||
@@ -1064,7 +1064,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
return g_cheat_process_manager.ToggleCheat(cheat_id);
|
||||
}
|
||||
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition *def, bool enabled) {
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled) {
|
||||
return g_cheat_process_manager.AddCheat(out_id, def, enabled);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
Result GetCheats(CheatEntry *cheats, size_t max_count, u64 *out_count, u64 offset);
|
||||
Result GetCheatById(CheatEntry *out_cheat, u32 cheat_id);
|
||||
Result ToggleCheat(u32 cheat_id);
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition *def, bool enabled);
|
||||
Result AddCheat(u32 *out_id, const CheatDefinition &def, bool enabled);
|
||||
Result RemoveCheat(u32 cheat_id);
|
||||
|
||||
Result GetFrozenAddressCount(u64 *out_count);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace sts::dmnt::cheat::impl {
|
||||
}
|
||||
|
||||
Result ContinueDebugEvent(Handle debug_handle) {
|
||||
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_300) {
|
||||
if (hos::GetVersion() >= hos::Version_300) {
|
||||
return svcContinueDebugEvent(debug_handle, 5, nullptr, 0);
|
||||
} else {
|
||||
return svcLegacyContinueDebugEvent(debug_handle, 5, 0);
|
||||
|
||||
Reference in New Issue
Block a user