diff options
Diffstat (limited to 'src/core/loader/xci.cpp')
| -rw-r--r-- | src/core/loader/xci.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index aaa250cea..0125ddf33 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp | |||
| @@ -20,11 +20,11 @@ | |||
| 20 | 20 | ||
| 21 | namespace Loader { | 21 | namespace Loader { |
| 22 | 22 | ||
| 23 | AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file, | 23 | AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file_, |
| 24 | const Service::FileSystem::FileSystemController& fsc, | 24 | const Service::FileSystem::FileSystemController& fsc, |
| 25 | const FileSys::ContentProvider& content_provider, | 25 | const FileSys::ContentProvider& content_provider, |
| 26 | std::size_t program_index) | 26 | std::size_t program_index) |
| 27 | : AppLoader(file), xci(std::make_unique<FileSys::XCI>(file, program_index)), | 27 | : AppLoader(file_), xci(std::make_unique<FileSys::XCI>(file_, program_index)), |
| 28 | nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) { | 28 | nca_loader(std::make_unique<AppLoader_NCA>(xci->GetProgramNCAFile())) { |
| 29 | if (xci->GetStatus() != ResultStatus::Success) { | 29 | if (xci->GetStatus() != ResultStatus::Success) { |
| 30 | return; | 30 | return; |
| @@ -43,8 +43,8 @@ AppLoader_XCI::AppLoader_XCI(FileSys::VirtualFile file, | |||
| 43 | 43 | ||
| 44 | AppLoader_XCI::~AppLoader_XCI() = default; | 44 | AppLoader_XCI::~AppLoader_XCI() = default; |
| 45 | 45 | ||
| 46 | FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& file) { | 46 | FileType AppLoader_XCI::IdentifyType(const FileSys::VirtualFile& xci_file) { |
| 47 | FileSys::XCI xci(file); | 47 | const FileSys::XCI xci(xci_file); |
| 48 | 48 | ||
| 49 | if (xci.GetStatus() == ResultStatus::Success && | 49 | if (xci.GetStatus() == ResultStatus::Success && |
| 50 | xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && | 50 | xci.GetNCAByType(FileSys::NCAContentType::Program) != nullptr && |
| @@ -87,31 +87,33 @@ AppLoader_XCI::LoadResult AppLoader_XCI::Load(Kernel::Process& process, Core::Sy | |||
| 87 | return result; | 87 | return result; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& file) { | 90 | ResultStatus AppLoader_XCI::ReadRomFS(FileSys::VirtualFile& out_file) { |
| 91 | return nca_loader->ReadRomFS(file); | 91 | return nca_loader->ReadRomFS(out_file); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { | 94 | u64 AppLoader_XCI::ReadRomFSIVFCOffset() const { |
| 95 | return nca_loader->ReadRomFSIVFCOffset(); | 95 | return nca_loader->ReadRomFSIVFCOffset(); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& file) { | 98 | ResultStatus AppLoader_XCI::ReadUpdateRaw(FileSys::VirtualFile& out_file) { |
| 99 | u64 program_id{}; | 99 | u64 program_id{}; |
| 100 | nca_loader->ReadProgramId(program_id); | 100 | nca_loader->ReadProgramId(program_id); |
| 101 | if (program_id == 0) | 101 | if (program_id == 0) { |
| 102 | return ResultStatus::ErrorXCIMissingProgramNCA; | 102 | return ResultStatus::ErrorXCIMissingProgramNCA; |
| 103 | } | ||
| 103 | 104 | ||
| 104 | const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( | 105 | const auto read = xci->GetSecurePartitionNSP()->GetNCAFile( |
| 105 | FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); | 106 | FileSys::GetUpdateTitleID(program_id), FileSys::ContentRecordType::Program); |
| 106 | 107 | if (read == nullptr) { | |
| 107 | if (read == nullptr) | ||
| 108 | return ResultStatus::ErrorNoPackedUpdate; | 108 | return ResultStatus::ErrorNoPackedUpdate; |
| 109 | const auto nca_test = std::make_shared<FileSys::NCA>(read); | 109 | } |
| 110 | 110 | ||
| 111 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) | 111 | const auto nca_test = std::make_shared<FileSys::NCA>(read); |
| 112 | if (nca_test->GetStatus() != ResultStatus::ErrorMissingBKTRBaseRomFS) { | ||
| 112 | return nca_test->GetStatus(); | 113 | return nca_test->GetStatus(); |
| 114 | } | ||
| 113 | 115 | ||
| 114 | file = read; | 116 | out_file = read; |
| 115 | return ResultStatus::Success; | 117 | return ResultStatus::Success; |
| 116 | } | 118 | } |
| 117 | 119 | ||
| @@ -120,33 +122,41 @@ ResultStatus AppLoader_XCI::ReadProgramId(u64& out_program_id) { | |||
| 120 | } | 122 | } |
| 121 | 123 | ||
| 122 | ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) { | 124 | ResultStatus AppLoader_XCI::ReadIcon(std::vector<u8>& buffer) { |
| 123 | if (icon_file == nullptr) | 125 | if (icon_file == nullptr) { |
| 124 | return ResultStatus::ErrorNoControl; | 126 | return ResultStatus::ErrorNoControl; |
| 127 | } | ||
| 128 | |||
| 125 | buffer = icon_file->ReadAllBytes(); | 129 | buffer = icon_file->ReadAllBytes(); |
| 126 | return ResultStatus::Success; | 130 | return ResultStatus::Success; |
| 127 | } | 131 | } |
| 128 | 132 | ||
| 129 | ResultStatus AppLoader_XCI::ReadTitle(std::string& title) { | 133 | ResultStatus AppLoader_XCI::ReadTitle(std::string& title) { |
| 130 | if (nacp_file == nullptr) | 134 | if (nacp_file == nullptr) { |
| 131 | return ResultStatus::ErrorNoControl; | 135 | return ResultStatus::ErrorNoControl; |
| 136 | } | ||
| 137 | |||
| 132 | title = nacp_file->GetApplicationName(); | 138 | title = nacp_file->GetApplicationName(); |
| 133 | return ResultStatus::Success; | 139 | return ResultStatus::Success; |
| 134 | } | 140 | } |
| 135 | 141 | ||
| 136 | ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) { | 142 | ResultStatus AppLoader_XCI::ReadControlData(FileSys::NACP& control) { |
| 137 | if (nacp_file == nullptr) | 143 | if (nacp_file == nullptr) { |
| 138 | return ResultStatus::ErrorNoControl; | 144 | return ResultStatus::ErrorNoControl; |
| 145 | } | ||
| 146 | |||
| 139 | control = *nacp_file; | 147 | control = *nacp_file; |
| 140 | return ResultStatus::Success; | 148 | return ResultStatus::Success; |
| 141 | } | 149 | } |
| 142 | 150 | ||
| 143 | ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) { | 151 | ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& out_file) { |
| 144 | const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(), | 152 | const auto nca = xci->GetSecurePartitionNSP()->GetNCA(xci->GetProgramTitleID(), |
| 145 | FileSys::ContentRecordType::HtmlDocument); | 153 | FileSys::ContentRecordType::HtmlDocument); |
| 146 | if (xci->GetStatus() != ResultStatus::Success || nca == nullptr) | 154 | if (xci->GetStatus() != ResultStatus::Success || nca == nullptr) { |
| 147 | return ResultStatus::ErrorXCIMissingPartition; | 155 | return ResultStatus::ErrorXCIMissingPartition; |
| 148 | file = nca->GetRomFS(); | 156 | } |
| 149 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | 157 | |
| 158 | out_file = nca->GetRomFS(); | ||
| 159 | return out_file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | ||
| 150 | } | 160 | } |
| 151 | 161 | ||
| 152 | ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { | 162 | ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { |