diff options
author | bunnei <bunneidev@gmail.com> | 2018-10-07 05:58:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 05:58:24 +0200 |
commit | 6e4d2e672d1083f29186ea0ddcb33cd634e360e3 (patch) | |
tree | cbd20aab8705f8efac340c509ca71b08865a1417 /src/core/loader | |
parent | Merge pull request #1446 from bunnei/fast_fermi_copy (diff) | |
parent | romfs_factory: Extract packed update setter to new function (diff) | |
download | yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.gz yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.bz2 yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.lz yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.xz yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.tar.zst yuzu-6e4d2e672d1083f29186ea0ddcb33cd634e360e3.zip |
Diffstat (limited to 'src/core/loader')
-rw-r--r-- | src/core/loader/loader.cpp | 3 | ||||
-rw-r--r-- | src/core/loader/loader.h | 14 | ||||
-rw-r--r-- | src/core/loader/nax.cpp | 4 | ||||
-rw-r--r-- | src/core/loader/nax.h | 1 | ||||
-rw-r--r-- | src/core/loader/nsp.cpp | 32 | ||||
-rw-r--r-- | src/core/loader/nsp.h | 4 | ||||
-rw-r--r-- | src/core/loader/xci.cpp | 36 | ||||
-rw-r--r-- | src/core/loader/xci.h | 4 |
8 files changed, 89 insertions, 9 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index f2a183ba1..91659ec17 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -93,7 +93,7 @@ std::string GetFileTypeString(FileType type) { return "unknown"; } -constexpr std::array<const char*, 58> RESULT_MESSAGES{ +constexpr std::array<const char*, 59> RESULT_MESSAGES{ "The operation completed successfully.", "The loader requested to load is already loaded.", "The operation is not implemented.", @@ -152,6 +152,7 @@ constexpr std::array<const char*, 58> RESULT_MESSAGES{ "The BKTR-type NCA has a bad Relocation bucket.", "The BKTR-type NCA has a bad Subsection bucket.", "The BKTR-type NCA is missing the base RomFS.", + "The NSP or XCI does not contain an update in addition to the base game.", }; std::ostream& operator<<(std::ostream& os, ResultStatus status) { diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 20e66109b..0e0333db5 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -114,6 +114,7 @@ enum class ResultStatus : u16 { ErrorBadRelocationBuckets, ErrorBadSubsectionBuckets, ErrorMissingBKTRBaseRomFS, + ErrorNoPackedUpdate, }; std::ostream& operator<<(std::ostream& os, ResultStatus status); @@ -196,10 +197,19 @@ public: /** * Get the RomFS of the application * Since the RomFS can be huge, we return a file reference instead of copying to a buffer - * @param dir The directory containing the RomFS + * @param file The directory containing the RomFS * @return ResultStatus result of function */ - virtual ResultStatus ReadRomFS(FileSys::VirtualFile& dir) { + virtual ResultStatus ReadRomFS(FileSys::VirtualFile& file) { + return ResultStatus::ErrorNotImplemented; + } + + /** + * Get the raw update of the application, should it come packed with one + * @param file The raw update NCA file (Program-type + * @return ResultStatus result of function + */ + virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) { return ResultStatus::ErrorNotImplemented; } diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index 073fb9d2f..42f4a777b 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp @@ -72,6 +72,10 @@ ResultStatus AppLoader_NAX::ReadRomFS(FileSys::VirtualFile& dir) { return nca_loader->ReadRomFS(dir); } +u64 AppLoader_NAX::ReadRomFSIVFCOffset() const { + return nca_loader->ReadRomFSIVFCOffset(); +} + ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) { return nca_loader->ReadProgramId(out_program_id); } diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index fc3c01876..b4d93bd01 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h @@ -36,6 +36,7 @@ public: ResultStatus Load(Kernel::Process& process) override; ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override; + u64 ReadRomFSIVFCOffset() const override; ResultStatus ReadProgramId(u64& out_program_id) override; private: diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index b7ba77ef4..5534ce01c 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp @@ -10,8 +10,10 @@ #include "core/file_sys/control_metadata.h" #include "core/file_sys/nca_metadata.h" #include "core/file_sys/patch_manager.h" +#include "core/file_sys/registered_cache.h" #include "core/file_sys/submission_package.h" #include "core/hle/kernel/process.h" +#include "core/hle/service/filesystem/filesystem.h" #include "core/loader/deconstructed_rom_directory.h" #include "core/loader/nca.h" #include "core/loader/nsp.h" @@ -91,13 +93,39 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) { if (result != ResultStatus::Success) return result; + FileSys::VirtualFile update_raw; + if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) + Service::FileSystem::SetPackedUpdate(std::move(update_raw)); + is_loaded = true; return ResultStatus::Success; } -ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& dir) { - return secondary_loader->ReadRomFS(dir); +ResultStatus AppLoader_NSP::ReadRomFS(FileSys::VirtualFile& file) { + return secondary_loader->ReadRomFS(file); +} + +u64 AppLoader_NSP::ReadRomFSIVFCOffset() const { + return secondary_loader->ReadRomFSIVFCOffset(); +} + +ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& file) { + if (nsp->IsExtractedType()) + return ResultStatus::ErrorNoPackedUpdate; + + const auto read = + nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program); + + if (read == nullptr) + return ResultStatus::ErrorNoPackedUpdate; + const auto nca_test = std::make_shared<FileSys::NCA>(read); + + if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) + return nca_test->GetStatus(); + + file = read; + return ResultStatus::Success; } ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index eac9b819a..b006594a6 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h @@ -37,7 +37,9 @@ public: ResultStatus Load(Kernel::Process& process) override; - ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override; + ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; + u64 ReadRomFSIVFCOffset() const override; + ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; ResultStatus ReadProgramId(u64& out_program_id) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadTitle(std::string& title) override; diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index eda67a8c8..ee5452eb9 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp @@ -9,7 +9,11 @@ #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" +#include "core/file_sys/registered_cache.h" +#include "core/file_sys/romfs.h" +#include "core/file_sys/submission_package.h" #include "core/hle/kernel/process.h" +#include "core/hle/service/filesystem/filesystem.h" #include "core/loader/nca.h" #include "core/loader/xci.h" @@ -63,13 +67,41 @@ ResultStatus AppLoader_XCI::Load(Kernel::Process& process) { if (result != ResultStatus::Success) return result; + FileSys::VirtualFile update_raw; + if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr) + Service::FileSystem::SetPackedUpdate(std::move(update_raw)); + is_loaded = true; return ResultStatus::Success; } -ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& dir) { - return nca_loader->ReadRomFS(dir); +ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) { + return nca_loader->ReadRomFS(file); +} + +u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { + return nca_loader->ReadRomFSIVFCOffset(); +} + +ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) { + u64 program_id{}; + nca_loader->ReadProgramId(program_id); + if (program_id == 0) + return ResultStatus::ErrorXCIMissingProgramNCA; + + const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( + FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); + + if (read == nullptr) + return ResultStatus::ErrorNoPackedUpdate; + const auto nca_test = std::make_shared<FileSys::NCA>(read); + + if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) + return nca_test->GetStatus(); + + file = read; + return ResultStatus::Success; } ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index 17e47b658..770ed1437 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h @@ -37,7 +37,9 @@ public: ResultStatus Load(Kernel::Process& process) override; - ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override; + ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; + u64 ReadRomFSIVFCOffset() const override; + ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; ResultStatus ReadProgramId(u64& out_program_id) override; ResultStatus ReadIcon(std::vector<u8>& buffer) override; ResultStatus ReadTitle(std::string& title) override; |