diff options
author | Fernando S <fsahmkow27@gmail.com> | 2023-08-21 16:29:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-21 16:29:04 +0200 |
commit | 861597eb2e32663dba37813273ff91434566523a (patch) | |
tree | a05b7c596209f754a822c03cca162c6f32b6a565 /src/core/loader/nca.cpp | |
parent | 6a5db5679b61d3d73244e42682f1b34d401e7736 (diff) | |
parent | 775bf8e215c8c771b45f383b0b2ce46fa37ebe95 (diff) |
Merge pull request #11284 from liamwhite/nca-release
vfs: expand support for NCA reading
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 @@ #include "core/core.h" #include "core/file_sys/content_archive.h" +#include "core/file_sys/nca_metadata.h" +#include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs_factory.h" #include "core/hle/kernel/k_process.h" #include "core/hle/service/filesystem/filesystem.h" @@ -43,9 +45,23 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S return {ResultStatus::ErrorNCANotProgram, {}}; } - const auto exefs = nca->GetExeFS(); + auto exefs = nca->GetExeFS(); if (exefs == nullptr) { - return {ResultStatus::ErrorNoExeFS, {}}; + LOG_INFO(Loader, "No ExeFS found in NCA, looking for ExeFS from update"); + + // This NCA may be a sparse base of an installed title. + // Try to fetch the ExeFS from the installed update. + const auto& installed = system.GetContentProvider(); + const auto update_nca = installed.GetEntry(FileSys::GetUpdateTitleID(nca->GetTitleId()), + FileSys::ContentRecordType::Program); + + if (update_nca) { + exefs = update_nca->GetExeFS(); + } + + if (exefs == nullptr) { + return {ResultStatus::ErrorNoExeFS, {}}; + } } directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true); @@ -77,14 +93,6 @@ ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { return ResultStatus::Success; } -u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { - if (nca == nullptr) { - return 0; - } - - return nca->GetBaseIVFCOffset(); -} - ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { return ResultStatus::ErrorNotInitialized; |