xci: Fix error masking issue
Prevents NCA-related errors from being masked into MissingProgramNCA or MissingKeyFile
This commit is contained in:
parent
c7f2fb2151
commit
a9dc5a3c10
|
@ -43,6 +43,8 @@ XCI::XCI(VirtualFile file_) : file(std::move(file_)), partitions(0x4) {
|
||||||
partitions[static_cast<size_t>(partition)] = std::make_shared<PartitionFilesystem>(raw);
|
partitions[static_cast<size_t>(partition)] = std::make_shared<PartitionFilesystem>(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
program_nca_status = Loader::ResultStatus::ErrorXCIMissingProgramNCA;
|
||||||
|
|
||||||
auto result = AddNCAFromPartition(XCIPartition::Secure);
|
auto result = AddNCAFromPartition(XCIPartition::Secure);
|
||||||
if (result != Loader::ResultStatus::Success) {
|
if (result != Loader::ResultStatus::Success) {
|
||||||
status = result;
|
status = result;
|
||||||
|
@ -76,6 +78,10 @@ Loader::ResultStatus XCI::GetStatus() const {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader::ResultStatus XCI::GetProgramNCAStatus() const {
|
||||||
|
return program_nca_status;
|
||||||
|
}
|
||||||
|
|
||||||
VirtualDir XCI::GetPartition(XCIPartition partition) const {
|
VirtualDir XCI::GetPartition(XCIPartition partition) const {
|
||||||
return partitions[static_cast<size_t>(partition)];
|
return partitions[static_cast<size_t>(partition)];
|
||||||
}
|
}
|
||||||
|
@ -143,6 +149,9 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
|
||||||
if (file->GetExtension() != "nca")
|
if (file->GetExtension() != "nca")
|
||||||
continue;
|
continue;
|
||||||
auto nca = std::make_shared<NCA>(file);
|
auto nca = std::make_shared<NCA>(file);
|
||||||
|
if (nca->GetType() == NCAContentType::Program) {
|
||||||
|
program_nca_status = nca->GetStatus();
|
||||||
|
}
|
||||||
if (nca->GetStatus() == Loader::ResultStatus::Success) {
|
if (nca->GetStatus() == Loader::ResultStatus::Success) {
|
||||||
ncas.push_back(std::move(nca));
|
ncas.push_back(std::move(nca));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
explicit XCI(VirtualFile file);
|
explicit XCI(VirtualFile file);
|
||||||
|
|
||||||
Loader::ResultStatus GetStatus() const;
|
Loader::ResultStatus GetStatus() const;
|
||||||
|
Loader::ResultStatus GetProgramNCAStatus() const;
|
||||||
|
|
||||||
u8 GetFormatVersion() const;
|
u8 GetFormatVersion() const;
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ private:
|
||||||
GamecardHeader header{};
|
GamecardHeader header{};
|
||||||
|
|
||||||
Loader::ResultStatus status;
|
Loader::ResultStatus status;
|
||||||
|
Loader::ResultStatus program_nca_status;
|
||||||
|
|
||||||
std::vector<VirtualDir> partitions;
|
std::vector<VirtualDir> partitions;
|
||||||
std::vector<std::shared_ptr<NCA>> ncas;
|
std::vector<std::shared_ptr<NCA>> ncas;
|
||||||
|
|
|
@ -61,11 +61,12 @@ ResultStatus AppLoader_XCI::Load(Kernel::SharedPtr<Kernel::Process>& process) {
|
||||||
if (xci->GetStatus() != ResultStatus::Success)
|
if (xci->GetStatus() != ResultStatus::Success)
|
||||||
return xci->GetStatus();
|
return xci->GetStatus();
|
||||||
|
|
||||||
if (xci->GetNCAFileByType(FileSys::NCAContentType::Program) == nullptr) {
|
if (xci->GetProgramNCAStatus() != ResultStatus::Success)
|
||||||
if (!Core::Crypto::KeyManager::KeyFileExists(false))
|
return xci->GetProgramNCAStatus();
|
||||||
return ResultStatus::ErrorMissingProductionKeyFile;
|
|
||||||
return ResultStatus::ErrorXCIMissingProgramNCA;
|
const auto nca = xci->GetNCAFileByType(FileSys::NCAContentType::Program);
|
||||||
}
|
if (nca == nullptr && !Core::Crypto::KeyManager::KeyFileExists(false))
|
||||||
|
return ResultStatus::ErrorMissingProductionKeyFile;
|
||||||
|
|
||||||
auto result = nca_loader->Load(process);
|
auto result = nca_loader->Load(process);
|
||||||
if (result != ResultStatus::Success)
|
if (result != ResultStatus::Success)
|
||||||
|
|
Loading…
Reference in New Issue