diff options
author | David <25727384+ogniK5377@users.noreply.github.com> | 2018-09-21 06:39:30 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-09-21 06:39:30 +0200 |
commit | 1db1e013e0f8f3383e486d4f47d88d1bdb6e2769 (patch) | |
tree | 419c4550b7362c9b247fb1531738888e1d3294ae | |
parent | Merge pull request #1225 from tech4me/travis-windows (diff) | |
download | yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar.gz yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar.bz2 yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar.lz yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar.xz yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.tar.zst yuzu-1db1e013e0f8f3383e486d4f47d88d1bdb6e2769.zip |
-rw-r--r-- | src/core/loader/nso.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 3c6306818..78a4438c4 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -32,11 +32,18 @@ static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect struct NsoHeader { u32_le magic; - INSERT_PADDING_BYTES(0xc); + u32_le version; + INSERT_PADDING_WORDS(1); + u8 flags; std::array<NsoSegmentHeader, 3> segments; // Text, RoData, Data (in that order) u32_le bss_size; INSERT_PADDING_BYTES(0x1c); std::array<u32_le, 3> segments_compressed_size; + + bool IsSegmentCompressed(size_t segment_num) const { + ASSERT_MSG(segment_num < 3, "Invalid segment {}", segment_num); + return ((flags >> segment_num) & 1); + } }; static_assert(sizeof(NsoHeader) == 0x6c, "NsoHeader has incorrect size."); static_assert(std::is_trivially_copyable_v<NsoHeader>, "NsoHeader isn't trivially copyable."); @@ -105,9 +112,11 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base) { Kernel::SharedPtr<Kernel::CodeSet> codeset = Kernel::CodeSet::Create(kernel, ""); std::vector<u8> program_image; for (std::size_t i = 0; i < nso_header.segments.size(); ++i) { - const std::vector<u8> compressed_data = + std::vector<u8> data = file->ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset); - std::vector<u8> data = DecompressSegment(compressed_data, nso_header.segments[i]); + if (nso_header.IsSegmentCompressed(i)) { + data = DecompressSegment(data, nso_header.segments[i]); + } program_image.resize(nso_header.segments[i].location); program_image.insert(program_image.end(), data.begin(), data.end()); codeset->segments[i].addr = nso_header.segments[i].location; |