mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-23 04:12:02 +00:00
dmnt-cheat: *properly* update frozen address values on write
This commit is contained in:
parent
18e4d80073
commit
a3d44e37b5
1 changed files with 12 additions and 3 deletions
|
@ -108,9 +108,18 @@ Result DmntCheatManager::WriteCheatProcessMemoryForVm(u64 proc_addr, const void
|
||||||
|
|
||||||
/* We might have a frozen address. Update it if we do! */
|
/* We might have a frozen address. Update it if we do! */
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
auto it = g_frozen_addresses_map.find(proc_addr);
|
for (auto & [address, value] : g_frozen_addresses_map) {
|
||||||
if (it != g_frozen_addresses_map.end()) {
|
/* Map is in order, so break here. */
|
||||||
memcpy(&it->second.value, data, size < sizeof(it->second.value) ? size : sizeof(it->second.value));
|
if (address >= proc_addr + size) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we need to write. */
|
||||||
|
if (proc_addr <= address) {
|
||||||
|
const size_t offset = (address - proc_addr);
|
||||||
|
const size_t size_to_copy = size - offset;
|
||||||
|
memcpy(&value.value, (void *)((uintptr_t)data + offset), size_to_copy < sizeof(value.value) ? size_to_copy : sizeof(value.value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue