loader/nsp: Move secondary loader initialization to constructor
Prevents nullptr bug when trying to dump the RomFS of an NSP resulting from secondary_loader not being initialized.
This commit is contained in:
parent
d278f25bda
commit
7c70746ec4
@ -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,15 +77,9 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) {
|
|||||||
return ResultStatus::ErrorAlreadyLoaded;
|
return ResultStatus::ErrorAlreadyLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsp->IsExtractedType()) {
|
|
||||||
secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS());
|
|
||||||
} else {
|
|
||||||
if (title_id == 0)
|
if (title_id == 0)
|
||||||
return ResultStatus::ErrorNSPMissingProgramNCA;
|
return ResultStatus::ErrorNSPMissingProgramNCA;
|
||||||
|
|
||||||
secondary_loader = std::make_unique<AppLoader_NCA>(
|
|
||||||
nsp->GetNCAFile(title_id, FileSys::ContentRecordType::Program));
|
|
||||||
|
|
||||||
if (nsp->GetStatus() != ResultStatus::Success)
|
if (nsp->GetStatus() != ResultStatus::Success)
|
||||||
return nsp->GetStatus();
|
return nsp->GetStatus();
|
||||||
|
|
||||||
@ -87,7 +91,6 @@ ResultStatus AppLoader_NSP::Load(Kernel::Process& process) {
|
|||||||
return ResultStatus::ErrorMissingProductionKeyFile;
|
return ResultStatus::ErrorMissingProductionKeyFile;
|
||||||
return ResultStatus::ErrorNSPMissingProgramNCA;
|
return ResultStatus::ErrorNSPMissingProgramNCA;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const auto result = secondary_loader->Load(process);
|
const auto result = secondary_loader->Load(process);
|
||||||
if (result != ResultStatus::Success)
|
if (result != ResultStatus::Success)
|
||||||
|
Loading…
Reference in New Issue
Block a user