summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-10-13 15:30:09 +0200
committerLioncash <mathew1800@gmail.com>2018-10-13 15:50:08 +0200
commit6467b01de2debf86db8c409160ab50d24d32149e (patch)
tree7eae87a7d9906a9509d8856bb7368bcf6114eb6a /src/core
parentpartition_data_manager: Remove unused std::map instance within DecryptPackage2() (diff)
downloadyuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar.gz
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar.bz2
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar.lz
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar.xz
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.tar.zst
yuzu-6467b01de2debf86db8c409160ab50d24d32149e.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/crypto/partition_data_manager.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/core/crypto/partition_data_manager.cpp b/src/core/crypto/partition_data_manager.cpp
index a311ad846..ed5e2b145 100644
--- a/src/core/crypto/partition_data_manager.cpp
+++ b/src/core/crypto/partition_data_manager.cpp
@@ -499,33 +499,29 @@ void PartitionDataManager::DecryptPackage2(const std::array<Key128, 0x20>& packa
continue;
}
- std::vector<u8> text(kip.sections[0].size_compressed);
- std::vector<u8> rodata(kip.sections[1].size_compressed);
- std::vector<u8> data(kip.sections[2].size_compressed);
+ const u64 initial_offset = sizeof(KIPHeader) + offset;
+ const auto text_begin = c.cbegin() + initial_offset;
+ const auto text_end = text_begin + kip.sections[0].size_compressed;
+ const std::vector<u8> text = DecompressBLZ({text_begin, text_end});
- u64 offset_sec = sizeof(KIPHeader) + offset;
- std::memcpy(text.data(), c.data() + offset_sec, text.size());
- offset_sec += text.size();
- std::memcpy(rodata.data(), c.data() + offset_sec, rodata.size());
- offset_sec += rodata.size();
- std::memcpy(data.data(), c.data() + offset_sec, data.size());
+ const auto rodata_end = text_end + kip.sections[1].size_compressed;
+ const std::vector<u8> rodata = DecompressBLZ({text_end, rodata_end});
- offset += sizeof(KIPHeader) + kip.sections[0].size_compressed +
- kip.sections[1].size_compressed + kip.sections[2].size_compressed;
+ const auto data_end = rodata_end + kip.sections[2].size_compressed;
+ const std::vector<u8> data = DecompressBLZ({rodata_end, data_end});
- text = DecompressBLZ(text);
- rodata = DecompressBLZ(rodata);
- data = DecompressBLZ(data);
+ std::vector<u8> out;
+ out.reserve(text.size() + rodata.size() + data.size());
+ out.insert(out.end(), text.begin(), text.end());
+ out.insert(out.end(), rodata.begin(), rodata.end());
+ out.insert(out.end(), data.begin(), data.end());
- std::vector<u8> out(text.size() + rodata.size() + data.size());
- std::memcpy(out.data(), text.data(), text.size());
- std::memcpy(out.data() + text.size(), rodata.data(), rodata.size());
- std::memcpy(out.data() + text.size() + rodata.size(), data.data(), data.size());
+ offset += sizeof(KIPHeader) + out.size();
if (name == "FS")
- package2_fs[static_cast<size_t>(type)] = out;
+ package2_fs[static_cast<size_t>(type)] = std::move(out);
else if (name == "spl")
- package2_spl[static_cast<size_t>(type)] = out;
+ package2_spl[static_cast<size_t>(type)] = std::move(out);
}
}