diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/card_image.cpp | 36 | ||||
| -rw-r--r-- | src/core/file_sys/partition_filesystem.cpp | 4 |
2 files changed, 37 insertions, 3 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_) | |||
| 57 | const auto partition_idx = static_cast<std::size_t>(partition); | 57 | const auto partition_idx = static_cast<std::size_t>(partition); |
| 58 | auto raw = main_hfs.GetFile(partition_names[partition_idx]); | 58 | auto raw = main_hfs.GetFile(partition_names[partition_idx]); |
| 59 | 59 | ||
| 60 | partitions_raw[static_cast<std::size_t>(partition)] = raw; | 60 | partitions_raw[static_cast<std::size_t>(partition)] = std::move(raw); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | secure_partition = std::make_shared<NSP>( | 63 | secure_partition = std::make_shared<NSP>( |
| @@ -172,6 +172,40 @@ u64 XCI::GetProgramTitleID() const { | |||
| 172 | return secure_partition->GetProgramTitleID(); | 172 | return secure_partition->GetProgramTitleID(); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | u32 XCI::GetSystemUpdateVersion() { | ||
| 176 | const auto update = GetPartition(XCIPartition::Update); | ||
| 177 | if (update == nullptr) | ||
| 178 | return 0; | ||
| 179 | |||
| 180 | for (const auto& file : update->GetFiles()) { | ||
| 181 | NCA nca{file, nullptr, 0, keys}; | ||
| 182 | |||
| 183 | if (nca.GetStatus() != Loader::ResultStatus::Success) | ||
| 184 | continue; | ||
| 185 | |||
| 186 | if (nca.GetType() == NCAContentType::Meta && nca.GetTitleId() == 0x0100000000000816) { | ||
| 187 | const auto dir = nca.GetSubdirectories()[0]; | ||
| 188 | const auto cnmt = dir->GetFile("SystemUpdate_0100000000000816.cnmt"); | ||
| 189 | if (cnmt == nullptr) | ||
| 190 | continue; | ||
| 191 | |||
| 192 | CNMT cnmt_data{cnmt}; | ||
| 193 | |||
| 194 | const auto metas = cnmt_data.GetMetaRecords(); | ||
| 195 | if (metas.empty()) | ||
| 196 | continue; | ||
| 197 | |||
| 198 | return metas[0].title_version; | ||
| 199 | } | ||
| 200 | } | ||
| 201 | |||
| 202 | return 0; | ||
| 203 | } | ||
| 204 | |||
| 205 | u64 XCI::GetSystemUpdateTitleID() const { | ||
| 206 | return 0x0100000000000816; | ||
| 207 | } | ||
| 208 | |||
| 175 | bool XCI::HasProgramNCA() const { | 209 | bool XCI::HasProgramNCA() const { |
| 176 | return program != nullptr; | 210 | return program != nullptr; |
| 177 | } | 211 | } |
diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index 932409d79..846986736 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp | |||
| @@ -65,8 +65,8 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) { | |||
| 65 | std::string name( | 65 | std::string name( |
| 66 | reinterpret_cast<const char*>(&file_data[strtab_offset + entry.strtab_offset])); | 66 | reinterpret_cast<const char*>(&file_data[strtab_offset + entry.strtab_offset])); |
| 67 | 67 | ||
| 68 | offsets[name] = content_offset + entry.offset; | 68 | offsets.insert_or_assign(name, content_offset + entry.offset); |
| 69 | sizes[name] = entry.size; | 69 | sizes.insert_or_assign(name, entry.size); |
| 70 | 70 | ||
| 71 | pfs_files.emplace_back(std::make_shared<OffsetVfsFile>( | 71 | pfs_files.emplace_back(std::make_shared<OffsetVfsFile>( |
| 72 | file, entry.size, content_offset + entry.offset, std::move(name))); | 72 | file, entry.size, content_offset + entry.offset, std::move(name))); |