diff options
author | bunnei <bunneidev@gmail.com> | 2019-03-23 18:46:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-23 18:46:09 +0100 |
commit | 6af322a347340953cb90098645ba6d1b26864c3b (patch) | |
tree | ea15e581f4653eadc9eae05dd21e16920f04471d /src/core/file_sys | |
parent | Merge pull request #2279 from lioncash/cheat-global (diff) | |
parent | loader/nso: Place translation unit specific functions into an anonymous namespace (diff) | |
download | yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar.gz yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar.bz2 yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar.lz yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar.xz yuzu-6af322a347340953cb90098645ba6d1b26864c3b.tar.zst yuzu-6af322a347340953cb90098645ba6d1b26864c3b.zip |
Diffstat (limited to 'src/core/file_sys')
-rw-r--r-- | src/core/file_sys/patch_manager.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 58884b4a0..e11217708 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -20,6 +20,7 @@ #include "core/file_sys/vfs_vector.h" #include "core/hle/service/filesystem/filesystem.h" #include "core/loader/loader.h" +#include "core/loader/nso.h" #include "core/settings.h" namespace FileSys { @@ -32,14 +33,6 @@ constexpr std::array<const char*, 14> EXEFS_FILE_NAMES{ "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "subsdk8", "subsdk9", }; -struct NSOBuildHeader { - u32_le magic; - INSERT_PADDING_BYTES(0x3C); - std::array<u8, 0x20> build_id; - INSERT_PADDING_BYTES(0xA0); -}; -static_assert(sizeof(NSOBuildHeader) == 0x100, "NSOBuildHeader has incorrect size."); - std::string FormatTitleVersion(u32 version, TitleVersionFormat format) { std::array<u8, sizeof(u32)> bytes{}; bytes[0] = version % SINGLE_BYTE_MODULUS; @@ -163,14 +156,16 @@ std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualD } std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { - if (nso.size() < 0x100) + if (nso.size() < sizeof(Loader::NSOHeader)) { return nso; + } - NSOBuildHeader header; - std::memcpy(&header, nso.data(), sizeof(NSOBuildHeader)); + Loader::NSOHeader header; + std::memcpy(&header, nso.data(), sizeof(header)); - if (header.magic != Common::MakeMagic('N', 'S', 'O', '0')) + if (header.magic != Common::MakeMagic('N', 'S', 'O', '0')) { return nso; + } const auto build_id_raw = Common::HexArrayToString(header.build_id); const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); @@ -213,9 +208,11 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { } } - if (out.size() < 0x100) + if (out.size() < sizeof(Loader::NSOHeader)) { return nso; - std::memcpy(out.data(), &header, sizeof(NSOBuildHeader)); + } + + std::memcpy(out.data(), &header, sizeof(header)); return out; } |