diff options
Diffstat (limited to 'src/core/loader/nca.cpp')
| -rw-r--r-- | src/core/loader/nca.cpp | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index fa694de37..47e7a77a9 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -21,12 +21,13 @@ AppLoader_NCA::AppLoader_NCA(FileSys::VirtualFile file_) | |||
| 21 | 21 | ||
| 22 | AppLoader_NCA::~AppLoader_NCA() = default; | 22 | AppLoader_NCA::~AppLoader_NCA() = default; |
| 23 | 23 | ||
| 24 | FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& file) { | 24 | FileType AppLoader_NCA::IdentifyType(const FileSys::VirtualFile& nca_file) { |
| 25 | FileSys::NCA nca(file); | 25 | const FileSys::NCA nca(nca_file); |
| 26 | 26 | ||
| 27 | if (nca.GetStatus() == ResultStatus::Success && | 27 | if (nca.GetStatus() == ResultStatus::Success && |
| 28 | nca.GetType() == FileSys::NCAContentType::Program) | 28 | nca.GetType() == FileSys::NCAContentType::Program) { |
| 29 | return FileType::NCA; | 29 | return FileType::NCA; |
| 30 | } | ||
| 30 | 31 | ||
| 31 | return FileType::Error; | 32 | return FileType::Error; |
| 32 | } | 33 | } |
| @@ -67,43 +68,59 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::Process& process, Core::Sy | |||
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { | 70 | ResultStatus AppLoader_NCA::ReadRomFS(FileSys::VirtualFile& dir) { |
| 70 | if (nca == nullptr) | 71 | if (nca == nullptr) { |
| 71 | return ResultStatus::ErrorNotInitialized; | 72 | return ResultStatus::ErrorNotInitialized; |
| 72 | if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) | 73 | } |
| 74 | |||
| 75 | if (nca->GetRomFS() == nullptr || nca->GetRomFS()->GetSize() == 0) { | ||
| 73 | return ResultStatus::ErrorNoRomFS; | 76 | return ResultStatus::ErrorNoRomFS; |
| 77 | } | ||
| 78 | |||
| 74 | dir = nca->GetRomFS(); | 79 | dir = nca->GetRomFS(); |
| 75 | return ResultStatus::Success; | 80 | return ResultStatus::Success; |
| 76 | } | 81 | } |
| 77 | 82 | ||
| 78 | u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { | 83 | u64 AppLoader_NCA::ReadRomFSIVFCOffset() const { |
| 79 | if (nca == nullptr) | 84 | if (nca == nullptr) { |
| 80 | return 0; | 85 | return 0; |
| 86 | } | ||
| 87 | |||
| 81 | return nca->GetBaseIVFCOffset(); | 88 | return nca->GetBaseIVFCOffset(); |
| 82 | } | 89 | } |
| 83 | 90 | ||
| 84 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { | 91 | ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { |
| 85 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 92 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 86 | return ResultStatus::ErrorNotInitialized; | 93 | return ResultStatus::ErrorNotInitialized; |
| 94 | } | ||
| 95 | |||
| 87 | out_program_id = nca->GetTitleId(); | 96 | out_program_id = nca->GetTitleId(); |
| 88 | return ResultStatus::Success; | 97 | return ResultStatus::Success; |
| 89 | } | 98 | } |
| 90 | 99 | ||
| 91 | ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { | 100 | ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { |
| 92 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 101 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 93 | return ResultStatus::ErrorNotInitialized; | 102 | return ResultStatus::ErrorNotInitialized; |
| 103 | } | ||
| 104 | |||
| 94 | const auto logo = nca->GetLogoPartition(); | 105 | const auto logo = nca->GetLogoPartition(); |
| 95 | if (logo == nullptr) | 106 | if (logo == nullptr) { |
| 96 | return ResultStatus::ErrorNoIcon; | 107 | return ResultStatus::ErrorNoIcon; |
| 108 | } | ||
| 109 | |||
| 97 | buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); | 110 | buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); |
| 98 | return ResultStatus::Success; | 111 | return ResultStatus::Success; |
| 99 | } | 112 | } |
| 100 | 113 | ||
| 101 | ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { | 114 | ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { |
| 102 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | 115 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) { |
| 103 | return ResultStatus::ErrorNotInitialized; | 116 | return ResultStatus::ErrorNotInitialized; |
| 117 | } | ||
| 118 | |||
| 104 | const auto logo = nca->GetLogoPartition(); | 119 | const auto logo = nca->GetLogoPartition(); |
| 105 | if (logo == nullptr) | 120 | if (logo == nullptr) { |
| 106 | return ResultStatus::ErrorNoIcon; | 121 | return ResultStatus::ErrorNoIcon; |
| 122 | } | ||
| 123 | |||
| 107 | buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); | 124 | buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); |
| 108 | return ResultStatus::Success; | 125 | return ResultStatus::Success; |
| 109 | } | 126 | } |