aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-23 18:53:13 -0400
committerZach Hilman <zachhilman@gmail.com>2018-08-23 18:53:13 -0400
commit87927a3be7b8dc13aaf228716db07462d7ee87e4 (patch)
treefc7b487b8ab4311f8a09c73197f2c8e7cfdc546f /src/core
parent8f6ef9d39565c4f694d8f1755420c61366ee3ad6 (diff)
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/core')
-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 008e11d8cc..e8b5d6ece9 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_)) {
file->ReadBytes(sections.data(), length_sections, SECTION_HEADER_OFFSET);
}
+ is_update = std::find_if(sections.begin(), sections.end(), [](const NCASectionHeader& header) {
+ return header.raw.header.crypto_type == NCASectionCryptoType::BKTR;
+ }) != sections.end();
+
for (std::ptrdiff_t i = 0; i < number_sections; ++i) {
auto section = sections[i];
@@ -358,6 +362,10 @@ VirtualFile NCA::GetBaseFile() const {
return file;
}
+bool NCA::IsUpdate() const {
+ return is_update;
+}
+
bool NCA::ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) {
return false;
}
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h
index 4b74c54ec1..b961cfde74 100644
--- a/src/core/file_sys/content_archive.h
+++ b/src/core/file_sys/content_archive.h
@@ -93,6 +93,8 @@ public:
VirtualFile GetBaseFile() const;
+ bool IsUpdate() const;
+
protected:
bool ReplaceFileWithSubdirectory(VirtualFile file, VirtualDir dir) override;
@@ -111,6 +113,7 @@ private:
NCAHeader header{};
bool has_rights_id{};
+ bool is_update{};
Loader::ResultStatus status{};