From 8e9b55e939e0be81d7d2bbab4bf3a697e236cb65 Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 9 Dec 2017 11:21:52 -0500 Subject: [PATCH] NCCH: Load the "logo" file from the specified offset if it's present instead of the ExeFS. This is "new" behavior as of firmware 5.0.0-11, older titles have the logo offset and size set to 0, indicating that the logo is stored in the ExeFS. --- src/core/file_sys/ncch_container.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index 56ecd8123..1a9afdb70 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -252,6 +252,26 @@ Loader::ResultStatus NCCHContainer::LoadSectionExeFS(const char* name, std::vect if (result == Loader::ResultStatus::Success || !has_exefs) return result; + // As of firmware 5.0.0-11 the logo is stored between the access descriptor and the plain region + // instead of the ExeFS. + if (std::strcmp(name, "logo") == 0) { + if (ncch_header.logo_region_offset && ncch_header.logo_region_size) { + size_t logo_offset = ncch_header.logo_region_offset * kBlockSize; + size_t logo_size = ncch_header.logo_region_size * kBlockSize; + + buffer.resize(logo_size); + file.Seek(ncch_offset + logo_offset, SEEK_SET); + + if (file.ReadBytes(buffer.data(), logo_size) != logo_size) { + LOG_ERROR(Service_FS, "Could not read NCCH logo"); + return Loader::ResultStatus::Error; + } + return Loader::ResultStatus::Success; + } else { + LOG_INFO(Service_FS, "Attempting to load logo from the ExeFS"); + } + } + // If we don't have any separate files, we'll need a full ExeFS if (!exefs_file.IsOpen()) return Loader::ResultStatus::Error;