diff options
author | Zach Hilman <zachhilman@gmail.com> | 2019-10-13 20:18:09 +0200 |
---|---|---|
committer | Zach Hilman <zachhilman@gmail.com> | 2019-10-13 20:18:45 +0200 |
commit | e0b9ee9b941f3fb47a5b219d27c37081f379d05a (patch) | |
tree | 4b38ed385708e324d491b80377e3f88c4449b9a1 /src/core/file_sys/card_image.cpp | |
parent | card_image: Add accessors for raw partitions in XCI (diff) | |
download | yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar.gz yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar.bz2 yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar.lz yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar.xz yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.tar.zst yuzu-e0b9ee9b941f3fb47a5b219d27c37081f379d05a.zip |
Diffstat (limited to 'src/core/file_sys/card_image.cpp')
-rw-r--r-- | src/core/file_sys/card_image.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index a6a68b748..07d0c8d5d 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -57,7 +57,7 @@ XCI::XCI(VirtualFile file_) const auto partition_idx = static_cast<std::size_t>(partition); auto raw = main_hfs.GetFile(partition_names[partition_idx]); - partitions_raw[static_cast<std::size_t>(partition)] = raw; + partitions_raw[static_cast<std::size_t>(partition)] = std::move(raw); } secure_partition = std::make_shared<NSP>( @@ -172,6 +172,40 @@ u64 XCI::GetProgramTitleID() const { return secure_partition->GetProgramTitleID(); } +u32 XCI::GetSystemUpdateVersion() { + const auto update = GetPartition(XCIPartition::Update); + if (update == nullptr) + return 0; + + for (const auto& file : update->GetFiles()) { + NCA nca{file, nullptr, 0, keys}; + + if (nca.GetStatus() != Loader::ResultStatus::Success) + continue; + + if (nca.GetType() == NCAContentType::Meta && nca.GetTitleId() == 0x0100000000000816) { + const auto dir = nca.GetSubdirectories()[0]; + const auto cnmt = dir->GetFile("SystemUpdate_0100000000000816.cnmt"); + if (cnmt == nullptr) + continue; + + CNMT cnmt_data{cnmt}; + + const auto metas = cnmt_data.GetMetaRecords(); + if (metas.empty()) + continue; + + return metas[0].title_version; + } + } + + return 0; +} + +u64 XCI::GetSystemUpdateTitleID() const { + return 0x0100000000000816; +} + bool XCI::HasProgramNCA() const { return program != nullptr; } |