1
0
Fork 0
forked from suyu/suyu

Merge pull request #1600 from DarkLordZach/nsp-secondary-loader-fix

loader/nsp: Move secondary loader initialization to constructor
This commit is contained in:
bunnei 2018-10-28 02:29:14 -04:00 committed by GitHub
commit 6f620b2441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,16 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file)
std::tie(nacp_file, icon_file) = std::tie(nacp_file, icon_file) =
FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca); FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca);
if (nsp->IsExtractedType()) {
secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS());
} else {
if (title_id == 0)
return;
secondary_loader = std::make_unique<AppLoader_NCA>(
nsp->GetNCAFile(title_id, FileSys::ContentRecordType::Program));
}
} }
AppLoader_NSP::~AppLoader_NSP() = default; AppLoader_NSP::~AppLoader_NSP() = default;
@ -67,26 +77,19 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) {
return ResultStatus::ErrorAlreadyLoaded; return ResultStatus::ErrorAlreadyLoaded;
} }
if (nsp->IsExtractedType()) { if (title_id == 0)
secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS()); return ResultStatus::ErrorNSPMissingProgramNCA;
} else {
if (title_id == 0)
return ResultStatus::ErrorNSPMissingProgramNCA;
secondary_loader = std::make_unique<AppLoader_NCA>( if (nsp->GetStatus() != ResultStatus::Success)
nsp->GetNCAFile(title_id, FileSys::ContentRecordType::Program)); return nsp->GetStatus();
if (nsp->GetStatus() != ResultStatus::Success) if (nsp->GetProgramStatus(title_id) != ResultStatus::Success)
return nsp->GetStatus(); return nsp->GetProgramStatus(title_id);
if (nsp->GetProgramStatus(title_id) != ResultStatus::Success) if (nsp->GetNCA(title_id, FileSys::ContentRecordType::Program) == nullptr) {
return nsp->GetProgramStatus(title_id); if (!Core::Crypto::KeyManager::KeyFileExists(false))
return ResultStatus::ErrorMissingProductionKeyFile;
if (nsp->GetNCA(title_id, FileSys::ContentRecordType::Program) == nullptr) { return ResultStatus::ErrorNSPMissingProgramNCA;
if (!Core::Crypto::KeyManager::KeyFileExists(false))
return ResultStatus::ErrorMissingProductionKeyFile;
return ResultStatus::ErrorNSPMissingProgramNCA;
}
} }
const auto result = secondary_loader->Load(process); const auto result = secondary_loader->Load(process);