strat: always use explicit result namespacing
This commit is contained in:
@@ -36,7 +36,7 @@ namespace ams::dmnt::cheat {
|
||||
}
|
||||
|
||||
Result CheatService::ForceOpenCheatProcess() {
|
||||
R_UNLESS(R_SUCCEEDED(dmnt::cheat::impl::ForceOpenCheatProcess()), ResultCheatNotAttached());
|
||||
R_UNLESS(R_SUCCEEDED(dmnt::cheat::impl::ForceOpenCheatProcess()), dmnt::cheat::ResultCheatNotAttached());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
@@ -61,17 +61,17 @@ namespace ams::dmnt::cheat {
|
||||
}
|
||||
|
||||
Result CheatService::GetCheatProcessMappings(const sf::OutArray<svc::MemoryInfo> &mappings, sf::Out<u64> out_count, u64 offset) {
|
||||
R_UNLESS(mappings.GetPointer() != nullptr, ResultCheatNullBuffer());
|
||||
R_UNLESS(mappings.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer());
|
||||
return dmnt::cheat::impl::GetCheatProcessMappings(mappings.GetPointer(), mappings.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
Result CheatService::ReadCheatProcessMemory(const sf::OutBuffer &buffer, u64 address, u64 out_size) {
|
||||
R_UNLESS(buffer.GetPointer() != nullptr, ResultCheatNullBuffer());
|
||||
R_UNLESS(buffer.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer());
|
||||
return dmnt::cheat::impl::ReadCheatProcessMemory(address, buffer.GetPointer(), std::min(out_size, buffer.GetSize()));
|
||||
}
|
||||
|
||||
Result CheatService::WriteCheatProcessMemory(const sf::InBuffer &buffer, u64 address, u64 in_size) {
|
||||
R_UNLESS(buffer.GetPointer() != nullptr, ResultCheatNullBuffer());
|
||||
R_UNLESS(buffer.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer());
|
||||
return dmnt::cheat::impl::WriteCheatProcessMemory(address, buffer.GetPointer(), std::min(in_size, buffer.GetSize()));
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace ams::dmnt::cheat {
|
||||
}
|
||||
|
||||
Result CheatService::GetCheats(const sf::OutArray<CheatEntry> &cheats, sf::Out<u64> out_count, u64 offset) {
|
||||
R_UNLESS(cheats.GetPointer() != nullptr, ResultCheatNullBuffer());
|
||||
R_UNLESS(cheats.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer());
|
||||
return dmnt::cheat::impl::GetCheats(cheats.GetPointer(), cheats.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace ams::dmnt::cheat {
|
||||
}
|
||||
|
||||
Result CheatService::GetFrozenAddresses(const sf::OutArray<FrozenAddressEntry> &addresses, sf::Out<u64> out_count, u64 offset) {
|
||||
R_UNLESS(addresses.GetPointer() != nullptr, ResultCheatNullBuffer());
|
||||
R_UNLESS(addresses.GetPointer() != nullptr, dmnt::cheat::ResultCheatNullBuffer());
|
||||
return dmnt::cheat::impl::GetFrozenAddresses(addresses.GetPointer(), addresses.GetSize(), out_count.GetPointer(), offset);
|
||||
}
|
||||
|
||||
@@ -143,9 +143,9 @@ namespace ams::dmnt::cheat {
|
||||
|
||||
Result CheatService::EnableFrozenAddress(sf::Out<u64> out_value, u64 address, u64 width) {
|
||||
/* Width needs to be a power of two <= 8. */
|
||||
R_UNLESS(width > 0, ResultFrozenAddressInvalidWidth());
|
||||
R_UNLESS(width <= sizeof(u64), ResultFrozenAddressInvalidWidth());
|
||||
R_UNLESS((width & (width - 1)) == 0, ResultFrozenAddressInvalidWidth());
|
||||
R_UNLESS(width > 0, dmnt::cheat::ResultFrozenAddressInvalidWidth());
|
||||
R_UNLESS(width <= sizeof(u64), dmnt::cheat::ResultFrozenAddressInvalidWidth());
|
||||
R_UNLESS((width & (width - 1)) == 0, dmnt::cheat::ResultFrozenAddressInvalidWidth());
|
||||
return dmnt::cheat::impl::EnableFrozenAddress(out_value.GetPointer(), address, width);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
}
|
||||
|
||||
Result EnsureCheatProcess() {
|
||||
R_UNLESS(this->HasActiveCheatProcess(), ResultCheatNotAttached());
|
||||
R_UNLESS(this->HasActiveCheatProcess(), dmnt::cheat::ResultCheatNotAttached());
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
@@ -480,8 +480,8 @@ namespace ams::dmnt::cheat::impl {
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
const CheatEntry *entry = this->GetCheatEntryById(cheat_id);
|
||||
R_UNLESS(entry != nullptr, ResultCheatUnknownId());
|
||||
R_UNLESS(entry->definition.num_opcodes != 0, ResultCheatUnknownId());
|
||||
R_UNLESS(entry != nullptr, dmnt::cheat::ResultCheatUnknownId());
|
||||
R_UNLESS(entry->definition.num_opcodes != 0, dmnt::cheat::ResultCheatUnknownId());
|
||||
|
||||
*out_cheat = *entry;
|
||||
return ResultSuccess();
|
||||
@@ -493,10 +493,10 @@ namespace ams::dmnt::cheat::impl {
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
CheatEntry *entry = this->GetCheatEntryById(cheat_id);
|
||||
R_UNLESS(entry != nullptr, ResultCheatUnknownId());
|
||||
R_UNLESS(entry->definition.num_opcodes != 0, ResultCheatUnknownId());
|
||||
R_UNLESS(entry != nullptr, dmnt::cheat::ResultCheatUnknownId());
|
||||
R_UNLESS(entry->definition.num_opcodes != 0, dmnt::cheat::ResultCheatUnknownId());
|
||||
|
||||
R_UNLESS(cheat_id != 0, ResultCheatCannotDisable());
|
||||
R_UNLESS(cheat_id != 0, dmnt::cheat::ResultCheatCannotDisable());
|
||||
|
||||
entry->enabled = !entry->enabled;
|
||||
|
||||
@@ -511,11 +511,11 @@ namespace ams::dmnt::cheat::impl {
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
R_UNLESS(def.num_opcodes != 0, ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes <= util::size(def.opcodes), ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes != 0, dmnt::cheat::ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes <= util::size(def.opcodes), dmnt::cheat::ResultCheatInvalid());
|
||||
|
||||
CheatEntry *new_entry = this->GetFreeCheatEntry();
|
||||
R_UNLESS(new_entry != nullptr, ResultCheatOutOfResource());
|
||||
R_UNLESS(new_entry != nullptr, dmnt::cheat::ResultCheatOutOfResource());
|
||||
|
||||
new_entry->enabled = enabled;
|
||||
new_entry->definition = def;
|
||||
@@ -533,7 +533,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
std::scoped_lock lk(this->cheat_lock);
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
R_UNLESS(cheat_id < MaxCheatCount, ResultCheatUnknownId());
|
||||
R_UNLESS(cheat_id < MaxCheatCount, dmnt::cheat::ResultCheatUnknownId());
|
||||
|
||||
this->ResetCheatEntry(cheat_id);
|
||||
|
||||
@@ -548,8 +548,8 @@ namespace ams::dmnt::cheat::impl {
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
R_UNLESS(def.num_opcodes != 0, ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes <= util::size(def.opcodes), ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes != 0, dmnt::cheat::ResultCheatInvalid());
|
||||
R_UNLESS(def.num_opcodes <= util::size(def.opcodes), dmnt::cheat::ResultCheatInvalid());
|
||||
|
||||
CheatEntry *master_entry = this->cheat_entries + 0;
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
std::scoped_lock lk(this->cheat_lock);
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, ResultCheatInvalid());
|
||||
R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, dmnt::cheat::ResultCheatInvalid());
|
||||
|
||||
*out = this->cheat_vm.GetStaticRegister(which);
|
||||
return ResultSuccess();
|
||||
@@ -576,7 +576,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
std::scoped_lock lk(this->cheat_lock);
|
||||
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, ResultCheatInvalid());
|
||||
R_UNLESS(which < CheatVirtualMachine::NumStaticRegisters, dmnt::cheat::ResultCheatInvalid());
|
||||
|
||||
this->cheat_vm.SetStaticRegister(which, value);
|
||||
return ResultSuccess();
|
||||
@@ -629,7 +629,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
const auto it = this->frozen_addresses_map.find_key(address);
|
||||
R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound());
|
||||
R_UNLESS(it != this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound());
|
||||
|
||||
frz_addr->address = it->GetAddress();
|
||||
frz_addr->value = it->GetValue();
|
||||
@@ -642,14 +642,14 @@ namespace ams::dmnt::cheat::impl {
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
const auto it = this->frozen_addresses_map.find_key(address);
|
||||
R_UNLESS(it == this->frozen_addresses_map.end(), ResultFrozenAddressAlreadyExists());
|
||||
R_UNLESS(it == this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressAlreadyExists());
|
||||
|
||||
FrozenAddressValue value = {};
|
||||
value.width = width;
|
||||
R_TRY(this->ReadCheatProcessMemoryUnsafe(address, &value.value, width));
|
||||
|
||||
FrozenAddressMapEntry *entry = AllocateFrozenAddress(address, value);
|
||||
R_UNLESS(entry != nullptr, ResultFrozenAddressOutOfResource());
|
||||
R_UNLESS(entry != nullptr, dmnt::cheat::ResultFrozenAddressOutOfResource());
|
||||
|
||||
this->frozen_addresses_map.insert(*entry);
|
||||
*out_value = value.value;
|
||||
@@ -662,7 +662,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
R_TRY(this->EnsureCheatProcess());
|
||||
|
||||
const auto it = this->frozen_addresses_map.find_key(address);
|
||||
R_UNLESS(it != this->frozen_addresses_map.end(), ResultFrozenAddressNotFound());
|
||||
R_UNLESS(it != this->frozen_addresses_map.end(), dmnt::cheat::ResultFrozenAddressNotFound());
|
||||
|
||||
FrozenAddressMapEntry *entry = std::addressof(*it);
|
||||
this->frozen_addresses_map.erase(it);
|
||||
@@ -820,7 +820,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
|
||||
/* If new process launch, we may not want to actually attach. */
|
||||
if (on_process_launch) {
|
||||
R_UNLESS(status.IsCheatEnabled(), ResultCheatNotAttached());
|
||||
R_UNLESS(status.IsCheatEnabled(), dmnt::cheat::ResultCheatNotAttached());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
} else if (num_modules == 1 && !on_process_launch) {
|
||||
proc_module = &proc_modules[0];
|
||||
} else {
|
||||
return ResultCheatNotAttached();
|
||||
return dmnt::cheat::ResultCheatNotAttached();
|
||||
}
|
||||
|
||||
this->cheat_process_metadata.main_nso_extents.base = proc_module->base_address;
|
||||
@@ -853,7 +853,7 @@ namespace ams::dmnt::cheat::impl {
|
||||
if (!this->LoadCheats(this->cheat_process_metadata.program_id, this->cheat_process_metadata.main_nso_build_id) ||
|
||||
!this->LoadCheatToggles(this->cheat_process_metadata.program_id)) {
|
||||
/* If new process launch, require success. */
|
||||
R_UNLESS(!on_process_launch, ResultCheatNotAttached());
|
||||
R_UNLESS(!on_process_launch, dmnt::cheat::ResultCheatNotAttached());
|
||||
}
|
||||
|
||||
/* Open a debug handle. */
|
||||
|
||||
Reference in New Issue
Block a user