summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/nca_patch.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2021-05-02 08:34:40 +0200
committerLioncash <mathew1800@gmail.com>2021-05-02 08:59:57 +0200
commit1da72c7792e4f68fd44579a713288f6772c193b4 (patch)
tree83061da36f2dd728e86d035c81fb646f23a2aab0 /src/core/file_sys/nca_patch.cpp
parentMerge pull request #6245 from lat9nq/boost-only-config (diff)
downloadyuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar.gz
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar.bz2
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar.lz
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar.xz
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.tar.zst
yuzu-1da72c7792e4f68fd44579a713288f6772c193b4.zip
Diffstat (limited to 'src/core/file_sys/nca_patch.cpp')
-rw-r--r--src/core/file_sys/nca_patch.cpp18
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);