mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-02 05:17:52 +00:00
card_image: Implement system update commands in XCI
This commit is contained in:
parent
c4f3400bea
commit
e0b9ee9b94
2 changed files with 37 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -65,8 +65,8 @@ PartitionFilesystem::PartitionFilesystem(std::shared_ptr<VfsFile> file) {
|
|||
std::string name(
|
||||
reinterpret_cast<const char*>(&file_data[strtab_offset + entry.strtab_offset]));
|
||||
|
||||
offsets[name] = content_offset + entry.offset;
|
||||
sizes[name] = entry.size;
|
||||
offsets.insert_or_assign(name, content_offset + entry.offset);
|
||||
sizes.insert_or_assign(name, entry.size);
|
||||
|
||||
pfs_files.emplace_back(std::make_shared<OffsetVfsFile>(
|
||||
file, entry.size, content_offset + entry.offset, std::move(name)));
|
||||
|
|
Loading…
Reference in a new issue