summaryrefslogtreecommitdiff
path: root/src/core/loader/nso.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-22 12:55:03 -0400
committerGravatar Lioncash2019-03-22 14:26:58 -0400
commit90e27ea00355dfe6f189ad116bb5d1bb3e278517 (patch)
tree7e6af9299e2b92c538391f472c4a3eac44df03b9 /src/core/loader/nso.cpp
parentfile_sys/patch_manager: Remove two magic values (diff)
downloadyuzu-90e27ea00355dfe6f189ad116bb5d1bb3e278517.tar.gz
yuzu-90e27ea00355dfe6f189ad116bb5d1bb3e278517.tar.xz
yuzu-90e27ea00355dfe6f189ad116bb5d1bb3e278517.zip
loader/nso: Fix definition of the NSO header struct
The total struct itself is 0x100 (256) bytes in size, so we should be providing that amount of data. Without the data, this can result in omitted data from the final loaded NSO file.
Diffstat (limited to 'src/core/loader/nso.cpp')
-rw-r--r--src/core/loader/nso.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 0eb9fd7f7..a52104792 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -34,20 +34,32 @@ struct NsoSegmentHeader {
34static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect size."); 34static_assert(sizeof(NsoSegmentHeader) == 0x10, "NsoSegmentHeader has incorrect size.");
35 35
36struct NsoHeader { 36struct NsoHeader {
37 using SHA256Hash = std::array<u8, 0x20>;
38
39 struct RODataRelativeExtent {
40 u32 data_offset;
41 u32 size;
42 };
43
37 u32_le magic; 44 u32_le magic;
38 u32_le version; 45 u32_le version;
39 INSERT_PADDING_WORDS(1); 46 u32 reserved;
40 u8 flags; 47 u32_le flags;
41 std::array<NsoSegmentHeader, 3> segments; // Text, RoData, Data (in that order) 48 std::array<NsoSegmentHeader, 3> segments; // Text, RoData, Data (in that order)
42 std::array<u8, 0x20> build_id; 49 std::array<u8, 0x20> build_id;
43 std::array<u32_le, 3> segments_compressed_size; 50 std::array<u32_le, 3> segments_compressed_size;
51 std::array<u8, 0x1C> padding;
52 RODataRelativeExtent api_info_extent;
53 RODataRelativeExtent dynstr_extent;
54 RODataRelativeExtent dynsyn_extent;
55 std::array<SHA256Hash, 3> segment_hashes;
44 56
45 bool IsSegmentCompressed(size_t segment_num) const { 57 bool IsSegmentCompressed(size_t segment_num) const {
46 ASSERT_MSG(segment_num < 3, "Invalid segment {}", segment_num); 58 ASSERT_MSG(segment_num < 3, "Invalid segment {}", segment_num);
47 return ((flags >> segment_num) & 1); 59 return ((flags >> segment_num) & 1);
48 } 60 }
49}; 61};
50static_assert(sizeof(NsoHeader) == 0x6c, "NsoHeader has incorrect size."); 62static_assert(sizeof(NsoHeader) == 0x100, "NsoHeader has incorrect size.");
51static_assert(std::is_trivially_copyable_v<NsoHeader>, "NsoHeader isn't trivially copyable."); 63static_assert(std::is_trivially_copyable_v<NsoHeader>, "NsoHeader isn't trivially copyable.");
52 64
53struct ModHeader { 65struct ModHeader {