diff --git a/src/core/importer.cpp b/src/core/importer.cpp index 996ff1e..9df5a78 100644 --- a/src/core/importer.cpp +++ b/src/core/importer.cpp @@ -404,19 +404,35 @@ static bool LoadTMD(const std::string& sdmc_path, const std::string& path, SDMCD } // English short title name, extdata id, encryption, seed, icon +using TitleData = std::tuple>; + template -std::tuple> LoadTitleData( - NCCHContainer& ncch) { +TitleData LoadTitleData(NCCHContainer& ncch) { + std::string codeset_name; + ncch.ReadCodesetName(codeset_name); + + u64 program_id{}; + ncch.ReadProgramId(program_id); + + std::string title_name_from_codeset; + if (!codeset_name.empty()) { + title_name_from_codeset = + fmt::format("{} (0x{:016x})", std::move(codeset_name), program_id); + } std::vector smdh_buffer; if (ncch.LoadSectionExeFS("icon", smdh_buffer) != ResultStatus::Success) { LOG_WARNING(Core, "Failed to load icon in ExeFS"); - return {}; + TitleData data{}; + std::get<0>(data) = std::move(title_name_from_codeset); + return data; } if (smdh_buffer.size() != sizeof(SMDH)) { LOG_ERROR(Core, "ExeFS icon section size is not correct"); - return {}; + TitleData data{}; + std::get<0>(data) = std::move(title_name_from_codeset); + return data; } SMDH smdh; diff --git a/src/core/ncch/ncch_container.cpp b/src/core/ncch/ncch_container.cpp index fa6c810..5d940be 100644 --- a/src/core/ncch/ncch_container.cpp +++ b/src/core/ncch/ncch_container.cpp @@ -374,6 +374,21 @@ bool NCCHContainer::HasExHeader() { return has_exheader; } +template +ResultStatus NCCHContainer::ReadCodesetName(std::string& name) { + ResultStatus result = Load(); + if (result != ResultStatus::Success) + return result; + + if (!has_exheader) + return ResultStatus::ErrorNotUsed; + + std::array name_data{}; + std::memcpy(name_data.data(), exheader_header.codeset_info.name, 8); + name = name_data.data(); + return ResultStatus::Success; +} + template ResultStatus NCCHContainer::ReadEncryptionType(EncryptionType& encryption) { ResultStatus result = Load(); diff --git a/src/core/ncch/ncch_container.h b/src/core/ncch/ncch_container.h index 47d9b4a..fb668d9 100644 --- a/src/core/ncch/ncch_container.h +++ b/src/core/ncch/ncch_container.h @@ -250,6 +250,12 @@ public: */ bool HasExHeader(); + /** + * Reads the name of the codeset. + * @return ResultStatus result of function. + */ + ResultStatus ReadCodesetName(std::string& name); + /** * Gets encryption type (which key is used). * @return ResultStatus result of function.