diff options
| -rw-r--r-- | src/core/file_sys/submission_package.cpp | 26 | ||||
| -rw-r--r-- | src/core/loader/nsp.cpp | 27 |
2 files changed, 39 insertions, 14 deletions
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 8b3b14e25..730221fd6 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/file_sys/content_archive.h" | 14 | #include "core/file_sys/content_archive.h" |
| 15 | #include "core/file_sys/nca_metadata.h" | 15 | #include "core/file_sys/nca_metadata.h" |
| 16 | #include "core/file_sys/partition_filesystem.h" | 16 | #include "core/file_sys/partition_filesystem.h" |
| 17 | #include "core/file_sys/program_metadata.h" | ||
| 17 | #include "core/file_sys/submission_package.h" | 18 | #include "core/file_sys/submission_package.h" |
| 18 | #include "core/loader/loader.h" | 19 | #include "core/loader/loader.h" |
| 19 | 20 | ||
| @@ -78,6 +79,10 @@ Loader::ResultStatus NSP::GetStatus() const { | |||
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | Loader::ResultStatus NSP::GetProgramStatus(u64 title_id) const { | 81 | Loader::ResultStatus NSP::GetProgramStatus(u64 title_id) const { |
| 82 | if (IsExtractedType() && GetExeFS() != nullptr && FileSys::IsDirectoryExeFS(GetExeFS())) { | ||
| 83 | return Loader::ResultStatus::Success; | ||
| 84 | } | ||
| 85 | |||
| 81 | const auto iter = program_status.find(title_id); | 86 | const auto iter = program_status.find(title_id); |
| 82 | if (iter == program_status.end()) | 87 | if (iter == program_status.end()) |
| 83 | return Loader::ResultStatus::ErrorNSPMissingProgramNCA; | 88 | return Loader::ResultStatus::ErrorNSPMissingProgramNCA; |
| @@ -85,12 +90,29 @@ Loader::ResultStatus NSP::GetProgramStatus(u64 title_id) const { | |||
| 85 | } | 90 | } |
| 86 | 91 | ||
| 87 | u64 NSP::GetFirstTitleID() const { | 92 | u64 NSP::GetFirstTitleID() const { |
| 93 | if (IsExtractedType()) { | ||
| 94 | return GetProgramTitleID(); | ||
| 95 | } | ||
| 96 | |||
| 88 | if (program_status.empty()) | 97 | if (program_status.empty()) |
| 89 | return 0; | 98 | return 0; |
| 90 | return program_status.begin()->first; | 99 | return program_status.begin()->first; |
| 91 | } | 100 | } |
| 92 | 101 | ||
| 93 | u64 NSP::GetProgramTitleID() const { | 102 | u64 NSP::GetProgramTitleID() const { |
| 103 | if (IsExtractedType()) { | ||
| 104 | if (GetExeFS() == nullptr || !IsDirectoryExeFS(GetExeFS())) { | ||
| 105 | return 0; | ||
| 106 | } | ||
| 107 | |||
| 108 | ProgramMetadata meta; | ||
| 109 | if (meta.Load(GetExeFS()->GetFile("main.npdm")) == Loader::ResultStatus::Success) { | ||
| 110 | return meta.GetTitleID(); | ||
| 111 | } else { | ||
| 112 | return 0; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 94 | const auto out = GetFirstTitleID(); | 116 | const auto out = GetFirstTitleID(); |
| 95 | if ((out & 0x800) == 0) | 117 | if ((out & 0x800) == 0) |
| 96 | return out; | 118 | return out; |
| @@ -102,6 +124,10 @@ u64 NSP::GetProgramTitleID() const { | |||
| 102 | } | 124 | } |
| 103 | 125 | ||
| 104 | std::vector<u64> NSP::GetTitleIDs() const { | 126 | std::vector<u64> NSP::GetTitleIDs() const { |
| 127 | if (IsExtractedType()) { | ||
| 128 | return {GetProgramTitleID()}; | ||
| 129 | } | ||
| 130 | |||
| 105 | std::vector<u64> out; | 131 | std::vector<u64> out; |
| 106 | out.reserve(ncas.size()); | 132 | out.reserve(ncas.size()); |
| 107 | for (const auto& kv : ncas) | 133 | for (const auto& kv : ncas) |
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 | } |