diff options
| author | 2019-03-22 13:18:48 -0400 | |
|---|---|---|
| committer | 2019-03-22 14:39:17 -0400 | |
| commit | 611f4666fd32c7b55830d24d0c4eb68afe12414a (patch) | |
| tree | 5a272198faf8e1f43424379f1cda726f16e886d3 | |
| parent | file_sys/patch_manager: Deduplicate NSO header (diff) | |
| download | yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.gz yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.tar.xz yuzu-611f4666fd32c7b55830d24d0c4eb68afe12414a.zip | |
loader/nso: Clean up use of magic constants
Now that the NSO header has the proper size, we can just use sizeof on
it instead of having magic constants.
| -rw-r--r-- | src/core/loader/nso.cpp | 10 |
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, | |||
| 138 | 138 | ||
| 139 | // Apply patches if necessary | 139 | // Apply patches if necessary |
| 140 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { | 140 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { |
| 141 | std::vector<u8> pi_header(program_image.size() + 0x100); | 141 | std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size()); |
| 142 | std::memcpy(pi_header.data(), &nso_header, sizeof(NSOHeader)); | 142 | pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header), |
| 143 | std::memcpy(pi_header.data() + 0x100, program_image.data(), program_image.size()); | 143 | reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader)); |
| 144 | pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(), | ||
| 145 | program_image.end()); | ||
| 144 | 146 | ||
| 145 | pi_header = pm->PatchNSO(pi_header); | 147 | pi_header = pm->PatchNSO(pi_header); |
| 146 | 148 | ||
| 147 | std::memcpy(program_image.data(), pi_header.data() + 0x100, program_image.size()); | 149 | std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin()); |
| 148 | } | 150 | } |
| 149 | 151 | ||
| 150 | // Apply cheats if they exist and the program has a valid title ID | 152 | // Apply cheats if they exist and the program has a valid title ID |