diff options
Diffstat (limited to 'src/core/loader/nca.cpp')
| -rw-r--r-- | src/core/loader/nca.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 513af194d..09d40e695 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/file_sys/content_archive.h" | 7 | #include "core/file_sys/content_archive.h" |
| 8 | #include "core/file_sys/nca_metadata.h" | ||
| 9 | #include "core/file_sys/registered_cache.h" | ||
| 8 | #include "core/file_sys/romfs_factory.h" | 10 | #include "core/file_sys/romfs_factory.h" |
| 9 | #include "core/hle/kernel/k_process.h" | 11 | #include "core/hle/kernel/k_process.h" |
| 10 | #include "core/hle/service/filesystem/filesystem.h" | 12 | #include "core/hle/service/filesystem/filesystem.h" |
| @@ -43,9 +45,23 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S | |||
| 43 | return {ResultStatus::ErrorNCANotProgram, {}}; | 45 | return {ResultStatus::ErrorNCANotProgram, {}}; |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | const auto exefs = nca->GetExeFS(); | 48 | auto exefs = nca->GetExeFS(); |
| 47 | if (exefs == nullptr) { | 49 | if (exefs == nullptr) { |
| 48 | return {ResultStatus::ErrorNoExeFS, {}}; | 50 | LOG_INFO(Loader, "No ExeFS found in NCA, looking for ExeFS from update"); |
| 51 | |||
| 52 | // This NCA may be a sparse base of an installed title. | ||
| 53 | // Try to fetch the ExeFS from the installed update. | ||
| 54 | const auto& installed = system.GetContentProvider(); | ||
| 55 | const auto update_nca = installed.GetEntry(FileSys::GetUpdateTitleID(nca->GetTitleId()), | ||
| 56 | FileSys::ContentRecordType::Program); | ||
| 57 | |||
| 58 | if (update_nca) { | ||
| 59 | exefs = update_nca->GetExeFS(); | ||
| 60 | } | ||
| 61 | |||
| 62 | if (exefs == nullptr) { | ||
| 63 | return {ResultStatus::ErrorNoExeFS, {}}; | ||
| 64 | } | ||
| 49 | } | 65 | } |
| 50 | 66 | ||
| 51 | directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true); | 67 | directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true); |
| @@ -77,14 +93,6 @@ ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { | |||
| 77 | return ResultStatus::Success; | 93 | return ResultStatus::Success; |
| 78 | } | 94 | } |
| 79 | 95 | ||
| 80 | u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { | ||
| 81 | if (nca == nullptr) { | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | return nca->GetBaseIVFCOffset(); | ||
| 86 | } | ||
| 87 | |||
| 88 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { | 96 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { |
| 89 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { | 97 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 90 | return ResultStatus::ErrorNotInitialized; | 98 | return ResultStatus::ErrorNotInitialized; |