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.
This commit is contained in:
Léo Lam 2019-07-28 14:03:59 +08:00
parent aca55d0378
commit a2cde6e075

View file

@ -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) ==