summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-08-23 18:53:13 -0400
committerGravatar Zach Hilman2018-08-23 18:53:13 -0400
commit4f18c17df77e791d30cc8c919108315610f315ef (patch)
treefc7b487b8ab4311f8a09c73197f2c8e7cfdc546f /src
parentkey_manager: Eliminate indexed for loop (diff)
downloadyuzu-4f18c17df77e791d30cc8c919108315610f315ef.tar.gz
yuzu-4f18c17df77e791d30cc8c919108315610f315ef.tar.xz
yuzu-4f18c17df77e791d30cc8c919108315610f315ef.zip
content_archive: Add update title detection
This is needed because the title IDs of update NCAs will not use the update title ID. The only sure way to tell is to look for a partition with BKTR crypto.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/content_archive.cpp8
-rw-r--r--src/core/file_sys/content_archive.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp
index 008e11d8c..e8b5d6ece 100644
--- a/src/core/file_sys/content_archive.cpp
+++ b/src/core/file_sys/content_archive.cpp
@@ -258,6 +258,10 @@ NCA::NCA(VirtualFile file_) : file(std::move(file_)) {
258 file->ReadBytes(sections.data(), length_sections, SECTION_HEADER_OFFSET); 258 file->ReadBytes(sections.data(), length_sections, SECTION_HEADER_OFFSET);
259 } 259 }
260 260
261 is_update = std::find_if(sections.begin(), sections.end(), [](const NCASectionHeader& header) {
262 return header.raw.header.crypto_type == NCASectionCryptoType::BKTR;
263 }) != sections.end();
264
261 for (std::ptrdiff_t i = 0; i < number_sections; ++i) { 265 for (std::ptrdiff_t i = 0; i < number_sections; ++i) {
262 auto section = sections[i]; 266 auto section = sections[i];
263 267
@@ -358,6 +362,10 @@ VirtualFile NCA::GetBaseFile() const {
358 return file; 362 return file;
359} 363}
360 364
365bool NCA::IsUpdate() const {
366 return is_update;
367}
368
361bool NCA::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) { 369bool NCA::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
362 return false; 370 return false;
363} 371}
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h
index 4b74c54ec..b961cfde7 100644
--- a/src/core/file_sys/content_archive.h
+++ b/src/core/file_sys/content_archive.h
@@ -93,6 +93,8 @@ public:
93 93
94 VirtualFile GetBaseFile() const; 94 VirtualFile GetBaseFile() const;
95 95
96 bool IsUpdate() const;
97
96protected: 98protected:
97 bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override; 99 bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
98 100
@@ -111,6 +113,7 @@ private:
111 113
112 NCAHeader header{}; 114 NCAHeader header{};
113 bool has_rights_id{}; 115 bool has_rights_id{};
116 bool is_update{};
114 117
115 Loader::ResultStatus status{}; 118 Loader::ResultStatus status{};
116 119