diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/content_archive.cpp | 6 | ||||
| -rw-r--r-- | src/core/file_sys/content_archive.h | 10 | ||||
| -rw-r--r-- | src/core/loader/loader.h | 4 | ||||
| -rw-r--r-- | src/core/loader/nax.cpp | 9 | ||||
| -rw-r--r-- | src/core/loader/nax.h | 3 | ||||
| -rw-r--r-- | src/core/loader/nca.cpp | 19 | ||||
| -rw-r--r-- | src/core/loader/nca.h | 3 | ||||
| -rw-r--r-- | src/core/loader/nsp.cpp | 9 | ||||
| -rw-r--r-- | src/core/loader/nsp.h | 3 | ||||
| -rw-r--r-- | src/core/loader/xci.cpp | 8 | ||||
| -rw-r--r-- | src/core/loader/xci.h | 3 |
11 files changed, 77 insertions, 0 deletions
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index 19b6f8600..5aa3b600b 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -359,6 +359,8 @@ bool NCA::ReadPFS0Section(const NCASectionHeader& section, const NCASectionTable | |||
| 359 | dirs.push_back(std::move(npfs)); | 359 | dirs.push_back(std::move(npfs)); |
| 360 | if (IsDirectoryExeFS(dirs.back())) | 360 | if (IsDirectoryExeFS(dirs.back())) |
| 361 | exefs = dirs.back(); | 361 | exefs = dirs.back(); |
| 362 | else if (IsDirectoryLogoPartition(dirs.back())) | ||
| 363 | logo = dirs.back(); | ||
| 362 | } else { | 364 | } else { |
| 363 | if (has_rights_id) | 365 | if (has_rights_id) |
| 364 | status = Loader::ResultStatus::ErrorIncorrectTitlekeyOrTitlekek; | 366 | status = Loader::ResultStatus::ErrorIncorrectTitlekeyOrTitlekek; |
| @@ -546,4 +548,8 @@ u64 NCA::GetBaseIVFCOffset() const { | |||
| 546 | return ivfc_offset; | 548 | return ivfc_offset; |
| 547 | } | 549 | } |
| 548 | 550 | ||
| 551 | VirtualDir NCA::GetLogoPartition() const { | ||
| 552 | return logo; | ||
| 553 | } | ||
| 554 | |||
| 549 | } // namespace FileSys | 555 | } // namespace FileSys |
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 99294cbb4..5d4d05c82 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h | |||
| @@ -74,6 +74,13 @@ inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) { | |||
| 74 | return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr; | 74 | return pfs->GetFile("main") != nullptr && pfs->GetFile("main.npdm") != nullptr; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | inline bool IsDirectoryLogoPartition(const VirtualDir& pfs) { | ||
| 78 | // NintendoLogo is the static image in the top left corner while StartupMovie is the animation | ||
| 79 | // in the bottom right corner. | ||
| 80 | return pfs->GetFile("NintendoLogo.png") != nullptr && | ||
| 81 | pfs->GetFile("StartupMovie.gif") != nullptr; | ||
| 82 | } | ||
| 83 | |||
| 77 | // An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) conatiner. | 84 | // An implementation of VfsDirectory that represents a Nintendo Content Archive (NCA) conatiner. |
| 78 | // After construction, use GetStatus to determine if the file is valid and ready to be used. | 85 | // After construction, use GetStatus to determine if the file is valid and ready to be used. |
| 79 | class NCA : public ReadOnlyVfsDirectory { | 86 | class NCA : public ReadOnlyVfsDirectory { |
| @@ -102,6 +109,8 @@ public: | |||
| 102 | // Returns the base ivfc offset used in BKTR patching. | 109 | // Returns the base ivfc offset used in BKTR patching. |
| 103 | u64 GetBaseIVFCOffset() const; | 110 | u64 GetBaseIVFCOffset() const; |
| 104 | 111 | ||
| 112 | VirtualDir GetLogoPartition() const; | ||
| 113 | |||
| 105 | private: | 114 | private: |
| 106 | bool CheckSupportedNCA(const NCAHeader& header); | 115 | bool CheckSupportedNCA(const NCAHeader& header); |
| 107 | bool HandlePotentialHeaderDecryption(); | 116 | bool HandlePotentialHeaderDecryption(); |
| @@ -122,6 +131,7 @@ private: | |||
| 122 | 131 | ||
| 123 | VirtualFile romfs = nullptr; | 132 | VirtualFile romfs = nullptr; |
| 124 | VirtualDir exefs = nullptr; | 133 | VirtualDir exefs = nullptr; |
| 134 | VirtualDir logo = nullptr; | ||
| 125 | VirtualFile file; | 135 | VirtualFile file; |
| 126 | VirtualFile bktr_base_romfs; | 136 | VirtualFile bktr_base_romfs; |
| 127 | u64 ivfc_offset = 0; | 137 | u64 ivfc_offset = 0; |
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index 01f984098..bb925f4a6 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h | |||
| @@ -178,6 +178,8 @@ public: | |||
| 178 | 178 | ||
| 179 | /** | 179 | /** |
| 180 | * Get the banner (typically banner section) of the application | 180 | * Get the banner (typically banner section) of the application |
| 181 | * In the context of NX, this is the animation that displays in the bottom right of the screen | ||
| 182 | * when a game boots. Stored in GIF format. | ||
| 181 | * @param buffer Reference to buffer to store data | 183 | * @param buffer Reference to buffer to store data |
| 182 | * @return ResultStatus result of function | 184 | * @return ResultStatus result of function |
| 183 | */ | 185 | */ |
| @@ -187,6 +189,8 @@ public: | |||
| 187 | 189 | ||
| 188 | /** | 190 | /** |
| 189 | * Get the logo (typically logo section) of the application | 191 | * Get the logo (typically logo section) of the application |
| 192 | * In the context of NX, this is the static image that displays in the top left of the screen | ||
| 193 | * when a game boots. Stored in JPEG format. | ||
| 190 | * @param buffer Reference to buffer to store data | 194 | * @param buffer Reference to buffer to store data |
| 191 | * @return ResultStatus result of function | 195 | * @return ResultStatus result of function |
| 192 | */ | 196 | */ |
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp index a093e3d36..93a970d10 100644 --- a/src/core/loader/nax.cpp +++ b/src/core/loader/nax.cpp | |||
| @@ -79,4 +79,13 @@ u64 AppLoader_NAX::ReadRomFSIVFCOffset() const { | |||
| 79 | ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) { | 79 | ResultStatus AppLoader_NAX::ReadProgramId(u64& out_program_id) { |
| 80 | return nca_loader->ReadProgramId(out_program_id); | 80 | return nca_loader->ReadProgramId(out_program_id); |
| 81 | } | 81 | } |
| 82 | |||
| 83 | ResultStatus AppLoader_NAX::ReadBanner(std::vector<u8>& buffer) { | ||
| 84 | return nca_loader->ReadBanner(buffer); | ||
| 85 | } | ||
| 86 | |||
| 87 | ResultStatus AppLoader_NAX::ReadLogo(std::vector<u8>& buffer) { | ||
| 88 | return nca_loader->ReadLogo(buffer); | ||
| 89 | } | ||
| 90 | |||
| 82 | } // namespace Loader | 91 | } // namespace Loader |
diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h index 0a97511b8..f40079574 100644 --- a/src/core/loader/nax.h +++ b/src/core/loader/nax.h | |||
| @@ -39,6 +39,9 @@ public: | |||
| 39 | u64 ReadRomFSIVFCOffset() const override; | 39 | u64 ReadRomFSIVFCOffset() const override; |
| 40 | ResultStatus ReadProgramId(u64& out_program_id) override; | 40 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 41 | 41 | ||
| 42 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | ||
| 43 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | ||
| 44 | |||
| 42 | private: | 45 | private: |
| 43 | std::unique_ptr<FileSys::NAX> nax; | 46 | std::unique_ptr<FileSys::NAX> nax; |
| 44 | std::unique_ptr<AppLoader_NCA> nca_loader; | 47 | std::unique_ptr<AppLoader_NCA> nca_loader; |
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 7e1b0d84f..ce8196fcf 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -84,4 +84,23 @@ ResultStatus AppLoader_NCA::ReadProgramId(u64& out_program_id) { | |||
| 84 | return ResultStatus::Success; | 84 | return ResultStatus::Success; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | ResultStatus AppLoader_NCA::ReadBanner(std::vector<u8>& buffer) { | ||
| 88 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | ||
| 89 | return ResultStatus::ErrorNotInitialized; | ||
| 90 | const auto logo = nca->GetLogoPartition(); | ||
| 91 | if (logo == nullptr) | ||
| 92 | return ResultStatus::ErrorNoIcon; | ||
| 93 | buffer = logo->GetFile("StartupMovie.gif")->ReadAllBytes(); | ||
| 94 | return ResultStatus::Success; | ||
| 95 | } | ||
| 96 | |||
| 97 | ResultStatus AppLoader_NCA::ReadLogo(std::vector<u8>& buffer) { | ||
| 98 | if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) | ||
| 99 | return ResultStatus::ErrorNotInitialized; | ||
| 100 | const auto logo = nca->GetLogoPartition(); | ||
| 101 | if (logo == nullptr) | ||
| 102 | return ResultStatus::ErrorNoIcon; | ||
| 103 | buffer = logo->GetFile("NintendoLogo.png")->ReadAllBytes(); | ||
| 104 | return ResultStatus::Success; | ||
| 105 | } | ||
| 87 | } // namespace Loader | 106 | } // namespace Loader |
diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h index cbbe701d2..b9f077468 100644 --- a/src/core/loader/nca.h +++ b/src/core/loader/nca.h | |||
| @@ -39,6 +39,9 @@ public: | |||
| 39 | u64 ReadRomFSIVFCOffset() const override; | 39 | u64 ReadRomFSIVFCOffset() const override; |
| 40 | ResultStatus ReadProgramId(u64& out_program_id) override; | 40 | ResultStatus ReadProgramId(u64& out_program_id) override; |
| 41 | 41 | ||
| 42 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | ||
| 43 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | ||
| 44 | |||
| 42 | private: | 45 | private: |
| 43 | std::unique_ptr<FileSys::NCA> nca; | 46 | std::unique_ptr<FileSys::NCA> nca; |
| 44 | std::unique_ptr<AppLoader_DeconstructedRomDirectory> directory_loader; | 47 | std::unique_ptr<AppLoader_DeconstructedRomDirectory> directory_loader; |
diff --git a/src/core/loader/nsp.cpp b/src/core/loader/nsp.cpp index 7fcb12aa2..7da1f8960 100644 --- a/src/core/loader/nsp.cpp +++ b/src/core/loader/nsp.cpp | |||
| @@ -166,4 +166,13 @@ ResultStatus AppLoader_NSP::ReadManualRomFS(FileSys::VirtualFile& file) { | |||
| 166 | file = nca->GetRomFS(); | 166 | file = nca->GetRomFS(); |
| 167 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | 167 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; |
| 168 | } | 168 | } |
| 169 | |||
| 170 | ResultStatus AppLoader_NSP::ReadBanner(std::vector<u8>& buffer) { | ||
| 171 | return secondary_loader->ReadBanner(buffer); | ||
| 172 | } | ||
| 173 | |||
| 174 | ResultStatus AppLoader_NSP::ReadLogo(std::vector<u8>& buffer) { | ||
| 175 | return secondary_loader->ReadLogo(buffer); | ||
| 176 | } | ||
| 177 | |||
| 169 | } // namespace Loader | 178 | } // namespace Loader |
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h index b6b309400..953a1b508 100644 --- a/src/core/loader/nsp.h +++ b/src/core/loader/nsp.h | |||
| @@ -46,6 +46,9 @@ public: | |||
| 46 | ResultStatus ReadControlData(FileSys::NACP& nacp) override; | 46 | ResultStatus ReadControlData(FileSys::NACP& nacp) override; |
| 47 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; | 47 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; |
| 48 | 48 | ||
| 49 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | ||
| 50 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | ||
| 51 | |||
| 49 | private: | 52 | private: |
| 50 | std::unique_ptr<FileSys::NSP> nsp; | 53 | std::unique_ptr<FileSys::NSP> nsp; |
| 51 | std::unique_ptr<AppLoader> secondary_loader; | 54 | std::unique_ptr<AppLoader> secondary_loader; |
diff --git a/src/core/loader/xci.cpp b/src/core/loader/xci.cpp index ff60a3756..89f7bbf77 100644 --- a/src/core/loader/xci.cpp +++ b/src/core/loader/xci.cpp | |||
| @@ -137,4 +137,12 @@ ResultStatus AppLoader_XCI::ReadManualRomFS(FileSys::VirtualFile& file) { | |||
| 137 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; | 137 | return file == nullptr ? ResultStatus::ErrorNoRomFS : ResultStatus::Success; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | ResultStatus AppLoader_XCI::ReadBanner(std::vector<u8>& buffer) { | ||
| 141 | return nca_loader->ReadBanner(buffer); | ||
| 142 | } | ||
| 143 | |||
| 144 | ResultStatus AppLoader_XCI::ReadLogo(std::vector<u8>& buffer) { | ||
| 145 | return nca_loader->ReadLogo(buffer); | ||
| 146 | } | ||
| 147 | |||
| 140 | } // namespace Loader | 148 | } // namespace Loader |
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h index e18531c93..d6995b61e 100644 --- a/src/core/loader/xci.h +++ b/src/core/loader/xci.h | |||
| @@ -46,6 +46,9 @@ public: | |||
| 46 | ResultStatus ReadControlData(FileSys::NACP& control) override; | 46 | ResultStatus ReadControlData(FileSys::NACP& control) override; |
| 47 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; | 47 | ResultStatus ReadManualRomFS(FileSys::VirtualFile& file) override; |
| 48 | 48 | ||
| 49 | ResultStatus ReadBanner(std::vector<u8>& buffer) override; | ||
| 50 | ResultStatus ReadLogo(std::vector<u8>& buffer) override; | ||
| 51 | |||
| 49 | private: | 52 | private: |
| 50 | std::unique_ptr<FileSys::XCI> xci; | 53 | std::unique_ptr<FileSys::XCI> xci; |
| 51 | std::unique_ptr<AppLoader_NCA> nca_loader; | 54 | std::unique_ptr<AppLoader_NCA> nca_loader; |