summaryrefslogtreecommitdiff
path: root/src/core/loader/nca.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-04 14:33:11 -0400
committerGravatar GitHub2018-08-04 14:33:11 -0400
commit2b06301dbfbfe79687219bf7783a6d1b47695401 (patch)
tree222cc27ecbc7f7e86d2edef8d36436600dee7d7a /src/core/loader/nca.cpp
parentMerge pull request #919 from lioncash/sign (diff)
parentAdd missing parameter to files.push_back() (diff)
downloadyuzu-2b06301dbfbfe79687219bf7783a6d1b47695401.tar.gz
yuzu-2b06301dbfbfe79687219bf7783a6d1b47695401.tar.xz
yuzu-2b06301dbfbfe79687219bf7783a6d1b47695401.zip
Merge pull request #849 from DarkLordZach/xci
XCI and Encrypted NCA Support
Diffstat (limited to 'src/core/loader/nca.cpp')
-rw-r--r--src/core/loader/nca.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp
index c80df23be..a1f8235d1 100644
--- a/src/core/loader/nca.cpp
+++ b/src/core/loader/nca.cpp
@@ -25,12 +25,10 @@ namespace Loader {
25AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file) : AppLoader(std::move(file)) {} 25AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
26 26
27FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) { 27FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) {
28 // TODO(DarkLordZach): Assuming everything is decrypted. Add crypto support. 28 FileSys::NCA nca(file);
29 FileSys::NCAHeader header{};
30 if (sizeof(FileSys::NCAHeader) != file->ReadObject(&header))
31 return FileType::Error;
32 29
33 if (IsValidNCA(header) && header.content_type == FileSys::NCAContentType::Program) 30 if (nca.GetStatus() == ResultStatus::Success &&
31 nca.GetType() == FileSys::NCAContentType::Program)
34 return FileType::NCA; 32 return FileType::NCA;
35 33
36 return FileType::Error; 34 return FileType::Error;
@@ -98,12 +96,21 @@ ResultStatus AppLoader_NCA::Load(Kernel::SharedPtr<Kernel::Process>& process) {
98} 96}
99 97
100ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { 98ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) {
101 if (nca == nullptr || nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) 99 if (nca == nullptr)
100 return ResultStatus::ErrorNotLoaded;
101 if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0)
102 return ResultStatus::ErrorNotUsed; 102 return ResultStatus::ErrorNotUsed;
103 dir = nca->GetRomFS(); 103 dir = nca->GetRomFS();
104 return ResultStatus::Success; 104 return ResultStatus::Success;
105} 105}
106 106
107ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) {
108 if (nca == nullptr)
109 return ResultStatus::ErrorNotLoaded;
110 out_program_id = nca->GetTitleId();
111 return ResultStatus::Success;
112}
113
107AppLoader_NCA::~AppLoader_NCA() = default; 114AppLoader_NCA::~AppLoader_NCA() = default;
108 115
109} // namespace Loader 116} // namespace Loader