Merge pull request #1933 from DarkLordZach/cheat-engine

file_sys: Implement parser and interpreter for game memory cheats
This commit is contained in:
bunnei 2019-03-21 21:41:59 -04:00 committed by GitHub
commit 639f0c524d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 813 additions and 0 deletions

View file

@ -7,8 +7,10 @@
#include <lz4.h>
#include "common/common_funcs.h"
#include "common/file_util.h"
#include "common/hex_util.h"
#include "common/logging/log.h"
#include "common/swap.h"
#include "core/core.h"
#include "core/file_sys/patch_manager.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/code_set.h"
@ -165,6 +167,16 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
std::memcpy(program_image.data(), pi_header.data() + 0x100, program_image.size());
}
// Apply cheats if they exist and the program has a valid title ID
if (pm) {
const auto cheats = pm->CreateCheatList(nso_header.build_id);
if (!cheats.empty()) {
Core::System::GetInstance().RegisterCheatList(
cheats, Common::HexArrayToString(nso_header.build_id), load_base,
load_base + program_image.size());
}
}
// Load codeset for current process
codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image));
process.LoadModule(std::move(codeset), load_base);