summaryrefslogtreecommitdiffstats
path: root/src/core/loader/xci.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/loader/xci.cpp')
-rw-r--r--src/core/loader/xci.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp
index eda67a8c8..ee5452eb9 100644
--- a/src/core/loader/xci.cpp
+++ b/src/core/loader/xci.cpp
@@ -9,7 +9,11 @@
#include "core/file_sys/content_archive.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
+#include "core/file_sys/registered_cache.h"
+#include "core/file_sys/romfs.h"
+#include "core/file_sys/submission_package.h"
#include "core/hle/kernel/process.h"
+#include "core/hle/service/filesystem/filesystem.h"
#include "core/loader/nca.h"
#include "core/loader/xci.h"
@@ -63,13 +67,41 @@ ResultStatus AppLoader_XCI::Load(Kernel::Process& process) {
if (result != ResultStatus::Success)
return result;
+ FileSys::VirtualFile update_raw;
+ if (ReadUpdateRaw(update_raw) == ResultStatus::Success && update_raw != nullptr)
+ Service::FileSystem::SetPackedUpdate(std::move(update_raw));
+
is_loaded = true;
return ResultStatus::Success;
}
-ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& dir) {
- return nca_loader->ReadRomFS(dir);
+ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) {
+ return nca_loader->ReadRomFS(file);
+}
+
+u64 AppLoader_XCI::ReadRomFSIVFCOffset() const {
+ return nca_loader->ReadRomFSIVFCOffset();
+}
+
+ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) {
+ u64 program_id{};
+ nca_loader->ReadProgramId(program_id);
+ if (program_id == 0)
+ return ResultStatus::ErrorXCIMissingProgramNCA;
+
+ const auto read = xci->GetSecurePartitionNSP()->GetNCAFile(
+ FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program);
+
+ if (read == nullptr)
+ return ResultStatus::ErrorNoPackedUpdate;
+ const auto nca_test = std::make_shared<FileSys::NCA>(read);
+
+ if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS)
+ return nca_test->GetStatus();
+
+ file = read;
+ return ResultStatus::Success;
}
ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) {