summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-03-22 18:18:48 +0100
committerLioncash <mathew1800@gmail.com>2019-03-22 19:39:17 +0100
commit611f4666fd32c7b55830d24d0c4eb68afe12414a (patch)
tree5a272198faf8e1f43424379f1cda726f16e886d3 /src/core
parentfile_sys/patch_manager: Deduplicate NSO header (diff)
downloadyuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.gz
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.bz2
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.lz
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.xz
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.zst
yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/loader/nso.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 262eaeaee..fc71ad189 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -138,13 +138,15 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
// Apply patches if necessary
if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) {
- std::vector<u8> pi_header(program_image.size() + 0x100);
- std::memcpy(pi_header.data(), &nso_header, sizeof(NSOHeader));
- std::memcpy(pi_header.data() + 0x100, program_image.data(), program_image.size());
+ std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size());
+ pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header),
+ reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader));
+ pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(),
+ program_image.end());
pi_header = pm->PatchNSO(pi_header);
- std::memcpy(program_image.data(), pi_header.data() + 0x100, program_image.size());
+ std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin());
}
// Apply cheats if they exist and the program has a valid title ID