diff options
| author | 2018-09-25 09:18:55 -0400 | |
|---|---|---|
| committer | 2018-10-05 08:46:31 -0400 | |
| commit | 504574882914902f0648e30078038472ae985570 (patch) | |
| tree | bfa46c9144c1f0f1a5e2375c74996fd1065dbec6 /src/core/loader | |
| parent | loader: Add ReadRomFSIVFCOffset to NSP, XCI, and NAX loaders (diff) | |
| download | yuzu-504574882914902f0648e30078038472ae985570.tar.gz yuzu-504574882914902f0648e30078038472ae985570.tar.xz yuzu-504574882914902f0648e30078038472ae985570.zip | |
loader: Add getter for packed update
Reads the update included with the game if it has one and adds the new ErrorNoPackedUpdate status.
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/nsp.cpp | 18 | ||||
| -rw-r--r-- | src/core/loader/nsp.h | 1 | ||||
| -rw-r--r-- | src/core/loader/xci.cpp | 24 | ||||
| -rw-r--r-- | src/core/loader/xci.h | 1 |
6 files changed, 58 insertions, 3 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) { | |||
| 93 | return "unknown"; | 93 | return "unknown"; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | constexpr std::array<const char*, 58> RESULT_MESSAGES{ | 96 | constexpr std::array<const char*, 59> RESULT_MESSAGES{ |
| 97 | "The operation completed successfully.", | 97 | "The operation completed successfully.", |
| 98 | "The loader requested to load is already loaded.", | 98 | "The loader requested to load is already loaded.", |
| 99 | "The operation is not implemented.", | 99 | "The operation is not implemented.", |
| @@ -152,6 +152,7 @@ constexpr std::array<const char*, 58> RESULT_MESSAGES{ | |||
| 152 | "The BKTR-type NCA has a bad Relocation bucket.", | 152 | "The BKTR-type NCA has a bad Relocation bucket.", |
| 153 | "The BKTR-type NCA has a bad Subsection bucket.", | 153 | "The BKTR-type NCA has a bad Subsection bucket.", |
| 154 | "The BKTR-type NCA is missing the base RomFS.", | 154 | "The BKTR-type NCA is missing the base RomFS.", |
| 155 | "The NSP or XCI does not contain an update in addition to the base game.", | ||
| 155 | }; | 156 | }; |
| 156 | 157 | ||
| 157 | std::ostream& operator<<(std::ostream& os, ResultStatus status) { | 158 | 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 { | |||
| 114 | ErrorBadRelocationBuckets, | 114 | ErrorBadRelocationBuckets, |
| 115 | ErrorBadSubsectionBuckets, | 115 | ErrorBadSubsectionBuckets, |
| 116 | ErrorMissingBKTRBaseRomFS, | 116 | ErrorMissingBKTRBaseRomFS, |
| 117 | ErrorNoPackedUpdate, | ||
| 117 | }; | 118 | }; |
| 118 | 119 | ||
| 119 | std::ostream& operator<<(std::ostream& os, ResultStatus status); | 120 | std::ostream& operator<<(std::ostream& os, ResultStatus status); |
| @@ -196,10 +197,19 @@ public: | |||
| 196 | /** | 197 | /** |
| 197 | * Get the RomFS of the application | 198 | * Get the RomFS of the application |
| 198 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer | 199 | * Since the RomFS can be huge, we return a file reference instead of copying to a buffer |
| 199 | * @param dir The directory containing the RomFS | 200 | * @param file The directory containing the RomFS |
| 200 | * @return ResultStatus result of function | 201 | * @return ResultStatus result of function |
| 201 | */ | 202 | */ |
| 202 | virtual ResultStatus ReadRomFS(FileSys::VirtualFile& dir) { | 203 | virtual ResultStatus ReadRomFS(FileSys::VirtualFile& file) { |
| 204 | return ResultStatus::ErrorNotImplemented; | ||
| 205 | } | ||
| 206 | |||
| 207 | /** | ||
| 208 | * Get the raw update of the application, should it come packed with one | ||
| 209 | * @param file The raw update NCA file (Program-type | ||
| 210 | * @return ResultStatus result of function | ||
| 211 | */ | ||
| 212 | virtual ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) { | ||
| 203 | return ResultStatus::ErrorNotImplemented; | 213 | return ResultStatus::ErrorNotImplemented; |
| 204 | } | 214 | } |
| 205 | 215 | ||
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index ae1edf9ca..a630b618c 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp | |||
| @@ -104,6 +104,24 @@ u64 AppLoader_NSP::ReadRomFSIVFCOffset() const { | |||
| 104 | return secondary_loader->ReadRomFSIVFCOffset(); | 104 | return secondary_loader->ReadRomFSIVFCOffset(); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | ResultStatus AppLoader_NSP::ReadUpdateRaw(FileSys::VirtualFile& file) { | ||
| 108 | if (nsp->IsExtractedType()) | ||
| 109 | return ResultStatus::ErrorNoPackedUpdate; | ||
| 110 | |||
| 111 | const auto read = | ||
| 112 | nsp->GetNCAFile(FileSys::GetUpdateTitleID(title_id), FileSys::ContentRecordType::Program); | ||
| 113 | |||
| 114 | if (read == nullptr) | ||
| 115 | return ResultStatus::ErrorNoPackedUpdate; | ||
| 116 | const auto nca_test = std::make_shared<FileSys::NCA>(read); | ||
| 117 | |||
| 118 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) | ||
| 119 | return nca_test->GetStatus(); | ||
| 120 | |||
| 121 | file = read; | ||
| 122 | return ResultStatus::Success; | ||
| 123 | } | ||
| 124 | |||
| 107 | ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { | 125 | ResultStatus AppLoader_NSP::ReadProgramId(u64& out_program_id) { |
| 108 | if (title_id == 0) | 126 | if (title_id == 0) |
| 109 | return ResultStatus::ErrorNotInitialized; | 127 | return ResultStatus::ErrorNotInitialized; |
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index 351bbf128..b006594a6 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h | |||
| @@ -39,6 +39,7 @@ public: | |||
| 39 | 39 | ||
| 40 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; | 40 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; |
| 41 | u64 ReadRomFSIVFCOffset() const override; | 41 | u64 ReadRomFSIVFCOffset() const override; |
| 42 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; | ||
| 42 | ResultStatus ReadProgramId(u64& out_program_id) override; | 43 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 43 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 44 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 44 | ResultStatus ReadTitle(std::string& title) override; | 45 | ResultStatus ReadTitle(std::string& title) override; |
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index 12d589fab..9d91ef03a 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp | |||
| @@ -9,6 +9,9 @@ | |||
| 9 | #include "core/file_sys/content_archive.h" | 9 | #include "core/file_sys/content_archive.h" |
| 10 | #include "core/file_sys/control_metadata.h" | 10 | #include "core/file_sys/control_metadata.h" |
| 11 | #include "core/file_sys/patch_manager.h" | 11 | #include "core/file_sys/patch_manager.h" |
| 12 | #include "core/file_sys/registered_cache.h" | ||
| 13 | #include "core/file_sys/romfs.h" | ||
| 14 | #include "core/file_sys/submission_package.h" | ||
| 12 | #include "core/hle/kernel/process.h" | 15 | #include "core/hle/kernel/process.h" |
| 13 | #include "core/loader/nca.h" | 16 | #include "core/loader/nca.h" |
| 14 | #include "core/loader/xci.h" | 17 | #include "core/loader/xci.h" |
| @@ -75,6 +78,27 @@ ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) { | |||
| 75 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { | 78 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { |
| 76 | return nca_loader->ReadRomFSIVFCOffset(); | 79 | return nca_loader->ReadRomFSIVFCOffset(); |
| 77 | } | 80 | } |
| 81 | |||
| 82 | ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) { | ||
| 83 | u64 program_id{}; | ||
| 84 | nca_loader->ReadProgramId(program_id); | ||
| 85 | if (program_id == 0) | ||
| 86 | return ResultStatus::ErrorXCIMissingProgramNCA; | ||
| 87 | |||
| 88 | const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( | ||
| 89 | FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); | ||
| 90 | |||
| 91 | if (read == nullptr) | ||
| 92 | return ResultStatus::ErrorNoPackedUpdate; | ||
| 93 | const auto nca_test = std::make_shared<FileSys::NCA>(read); | ||
| 94 | |||
| 95 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) | ||
| 96 | return nca_test->GetStatus(); | ||
| 97 | |||
| 98 | file = read; | ||
| 99 | return ResultStatus::Success; | ||
| 100 | } | ||
| 101 | |||
| 78 | ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { | 102 | ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { |
| 79 | return nca_loader->ReadProgramId(out_program_id); | 103 | return nca_loader->ReadProgramId(out_program_id); |
| 80 | } | 104 | } |
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index 4f9a9da48..770ed1437 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h | |||
| @@ -39,6 +39,7 @@ public: | |||
| 39 | 39 | ||
| 40 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; | 40 | ResultStatus ReadRomFS(FileSys::VirtualFile& file) override; |
| 41 | u64 ReadRomFSIVFCOffset() const override; | 41 | u64 ReadRomFSIVFCOffset() const override; |
| 42 | ResultStatus ReadUpdateRaw(FileSys::VirtualFile& file) override; | ||
| 42 | ResultStatus ReadProgramId(u64& out_program_id) override; | 43 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 43 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; | 44 | ResultStatus ReadIcon(std::vector<u8>& buffer) override; |
| 44 | ResultStatus ReadTitle(std::string& title) override; | 45 | ResultStatus ReadTitle(std::string& title) override; |