diff options
author | bunnei <bunneidev@gmail.com> | 2021-05-03 00:12:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-03 00:12:07 +0200 |
commit | c17a59b58e4c78dfee976dabddd13c3c6fdf95b7 (patch) | |
tree | 7a935c140bd467ca9e5e3ca27547ee6fee14861f /src/core/file_sys/nca_patch.cpp | |
parent | Merge pull request #6263 from Kewlan/folder-swap-expand-state (diff) | |
parent | file_sys: Resolve cases of variable shadowing (diff) | |
download | yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar.gz yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar.bz2 yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar.lz yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar.xz yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.tar.zst yuzu-c17a59b58e4c78dfee976dabddd13c3c6fdf95b7.zip |
Diffstat (limited to 'src/core/file_sys/nca_patch.cpp')
-rw-r--r-- | src/core/file_sys/nca_patch.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/core/file_sys/nca_patch.cpp b/src/core/file_sys/nca_patch.cpp index a65ec6798..b36827b75 100644 --- a/src/core/file_sys/nca_patch.cpp +++ b/src/core/file_sys/nca_patch.cpp @@ -83,11 +83,14 @@ BKTR::~BKTR() = default; std::size_t BKTR::Read(u8* data, std::size_t length, std::size_t offset) const { // Read out of bounds. - if (offset >= relocation.size) + if (offset >= relocation.size) { return 0; - const auto relocation = GetRelocationEntry(offset); - const auto section_offset = offset - relocation.address_patch + relocation.address_source; - const auto bktr_read = relocation.from_patch; + } + + const auto relocation_entry = GetRelocationEntry(offset); + const auto section_offset = + offset - relocation_entry.address_patch + relocation_entry.address_source; + const auto bktr_read = relocation_entry.from_patch; const auto next_relocation = GetNextRelocationEntry(offset); @@ -106,15 +109,16 @@ std::size_t BKTR::Read(u8* data, std::size_t length, std::size_t offset) const { return bktr_romfs->Read(data, length, section_offset); } - const auto subsection = GetSubsectionEntry(section_offset); + const auto subsection_entry = GetSubsectionEntry(section_offset); Core::Crypto::AESCipher<Core::Crypto::Key128> cipher(key, Core::Crypto::Mode::CTR); // Calculate AES IV std::array<u8, 16> iv{}; - auto subsection_ctr = subsection.ctr; + auto subsection_ctr = subsection_entry.ctr; auto offset_iv = section_offset + base_offset; - for (std::size_t i = 0; i < section_ctr.size(); ++i) + for (std::size_t i = 0; i < section_ctr.size(); ++i) { iv[i] = section_ctr[0x8 - i - 1]; + } offset_iv >>= 4; for (std::size_t i = 0; i < sizeof(u64); ++i) { iv[0xF - i] = static_cast<u8>(offset_iv & 0xFF); |