diff options
| author | 2019-09-21 20:05:24 +1000 | |
|---|---|---|
| committer | 2019-09-21 20:05:24 +1000 | |
| commit | 25383b9ff26af3152749fcc9864fd6f777c81f9f (patch) | |
| tree | b18c475af680ac4d59ba0ce15ae9cb102d2006e3 /src/core/loader/nsp.cpp | |
| parent | Merge pull request #2866 from Morph1984/checkbox_fix (diff) | |
| parent | nsp: Correct status codes for extracted NSPs (diff) | |
| download | yuzu-25383b9ff26af3152749fcc9864fd6f777c81f9f.tar.gz yuzu-25383b9ff26af3152749fcc9864fd6f777c81f9f.tar.xz yuzu-25383b9ff26af3152749fcc9864fd6f777c81f9f.zip | |
Merge pull request #2576 from DarkLordZach/nsp-fix-1
nsp: Fix various errors with loading and processing of extracted NSPs
Diffstat (limited to 'src/core/loader/nsp.cpp')
| -rw-r--r-- | src/core/loader/nsp.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index b1171ce65..35c82c99d 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp | |||
| @@ -26,20 +26,18 @@ AppLoader_NSP::AppLoader_NSP(FileSys::VirtualFile file) | |||
| 26 | 26 | ||
| 27 | if (nsp->GetStatus() != ResultStatus::Success) | 27 | if (nsp->GetStatus() != ResultStatus::Success) |
| 28 | return; | 28 | return; |
| 29 | if (nsp->IsExtractedType()) | ||
| 30 | return; | ||
| 31 | |||
| 32 | const auto control_nca = | ||
| 33 | nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::Control); | ||
| 34 | if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success) | ||
| 35 | return; | ||
| 36 | |||
| 37 | std::tie(nacp_file, icon_file) = | ||
| 38 | FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca); | ||
| 39 | 29 | ||
| 40 | if (nsp->IsExtractedType()) { | 30 | if (nsp->IsExtractedType()) { |
| 41 | secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS()); | 31 | secondary_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(nsp->GetExeFS()); |
| 42 | } else { | 32 | } else { |
| 33 | const auto control_nca = | ||
| 34 | nsp->GetNCA(nsp->GetProgramTitleID(), FileSys::ContentRecordType::Control); | ||
| 35 | if (control_nca == nullptr || control_nca->GetStatus() != ResultStatus::Success) | ||
| 36 | return; | ||
| 37 | |||
| 38 | std::tie(nacp_file, icon_file) = | ||
| 39 | FileSys::PatchManager(nsp->GetProgramTitleID()).ParseControlNCA(*control_nca); | ||
| 40 | |||
| 43 | if (title_id == 0) | 41 | if (title_id == 0) |
| 44 | return; | 42 | return; |
| 45 | 43 | ||
| @@ -56,11 +54,11 @@ FileType AppLoader_NSP::IdentifyType(const FileSys::VirtualFile& file) { | |||
| 56 | if (nsp.GetStatus() == ResultStatus::Success) { | 54 | if (nsp.GetStatus() == ResultStatus::Success) { |
| 57 | // Extracted Type case | 55 | // Extracted Type case |
| 58 | if (nsp.IsExtractedType() && nsp.GetExeFS() != nullptr && | 56 | if (nsp.IsExtractedType() && nsp.GetExeFS() != nullptr && |
| 59 | FileSys::IsDirectoryExeFS(nsp.GetExeFS()) && nsp.GetRomFS() != nullptr) { | 57 | FileSys::IsDirectoryExeFS(nsp.GetExeFS())) { |
| 60 | return FileType::NSP; | 58 | return FileType::NSP; |
| 61 | } | 59 | } |
| 62 | 60 | ||
| 63 | // Non-Ectracted Type case | 61 | // Non-Extracted Type case |
| 64 | if (!nsp.IsExtractedType() && | 62 | if (!nsp.IsExtractedType() && |
| 65 | nsp.GetNCA(nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program) != nullptr && | 63 | nsp.GetNCA(nsp.GetFirstTitleID(), FileSys::ContentRecordType::Program) != nullptr && |
| 66 | AppLoader_NCA::IdentifyType(nsp.GetNCAFile( | 64 | AppLoader_NCA::IdentifyType(nsp.GetNCAFile( |
| @@ -77,7 +75,7 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process) { | |||
| 77 | return {ResultStatus::ErrorAlreadyLoaded, {}}; | 75 | return {ResultStatus::ErrorAlreadyLoaded, {}}; |
| 78 | } | 76 | } |
| 79 | 77 | ||
| 80 | if (title_id == 0) { | 78 | if (!nsp->IsExtractedType() && title_id == 0) { |
| 81 | return {ResultStatus::ErrorNSPMissingProgramNCA, {}}; | 79 | return {ResultStatus::ErrorNSPMissingProgramNCA, {}}; |
| 82 | } | 80 | } |
| 83 | 81 | ||
| @@ -91,7 +89,8 @@ AppLoader_NSP::LoadResult AppLoader_NSP::Load(Kernel::Process& process) { | |||
| 91 | return {nsp_program_status, {}}; | 89 | return {nsp_program_status, {}}; |
| 92 | } | 90 | } |
| 93 | 91 | ||
| 94 | if (nsp->GetNCA(title_id, FileSys::ContentRecordType::Program) == nullptr) { | 92 | if (!nsp->IsExtractedType() && |
| 93 | nsp->GetNCA(title_id, FileSys::ContentRecordType::Program) == nullptr) { | ||
| 95 | if (!Core::Crypto::KeyManager::KeyFileExists(false)) { | 94 | if (!Core::Crypto::KeyManager::KeyFileExists(false)) { |
| 96 | return {ResultStatus::ErrorMissingProductionKeyFile, {}}; | 95 | return {ResultStatus::ErrorMissingProductionKeyFile, {}}; |
| 97 | } | 96 | } |