From a2cde6e0759bab3a4678ddf429626cd54c32fd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 28 Jul 2019 14:03:59 +0800 Subject: [PATCH] ncch_container: Assume override exheaders are decrypted Require and assume that override exheaders are decrypted for consistency with Luma's loader behaviour and to ensure consistent behaviour regardless of whether the NCCH is marked as encrypted or not. Currently, exheader overriding with an encrypted NCCH would cause the title ID checking heuristic to mistakenly disable encryption, which would then make exefs loading fail. --- src/core/file_sys/ncch_container.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index cf050e74e..c3728dfde 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -326,13 +326,19 @@ Loader::ResultStatus NCCHContainer::Load() { }; FileUtil::IOFile exheader_override_file{filepath + ".exheader", "rb"}; - if (read_exheader(exheader_override_file)) { + const bool has_exheader_override = read_exheader(exheader_override_file); + if (has_exheader_override) { + if (exheader_header.system_info.jump_id != + exheader_header.arm11_system_local_caps.program_id) { + LOG_WARNING(Service_FS, "Jump ID and Program ID don't match. " + "The override exheader might not be decrypted."); + } is_tainted = true; } else if (!read_exheader(file)) { return Loader::ResultStatus::Error; } - if (is_encrypted) { + if (!has_exheader_override && is_encrypted) { // This ID check is masked to low 32-bit as a toleration to ill-formed ROM created // by merging games and its updates. if ((exheader_header.system_info.jump_id & 0xFFFFFFFF) ==