From 5cc63480b8812846ed5804d0920ebe74950d7022 Mon Sep 17 00:00:00 2001 From: emoose Date: Sun, 5 Jan 2020 20:44:31 +0000 Subject: [PATCH] [CPU] Check patch MediaID if patch signature check failed This should let us make sure patches are being applied to the right XEX, without needing to rely on the signature. --- src/xenia/cpu/xex_module.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index 6f241b50e..066107db0 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -215,6 +215,16 @@ int XexModule::ApplyPatch(XexModule* module) { s.finalize(digest); if (memcmp(digest, patch_header->digest_source, 0x14) != 0) { + // If the signature check failed, check against the MediaID + // (we can forgive signature not matching) + // we won't check MediaID if the sig matches though, since it might not be + // that reliable? + if (memcmp(xex_security_info()->xgd2_media_id, + module->xex_security_info()->xgd2_media_id, 0x10) != 0) { + XELOGE("Patch MediaID doesn't match base XEX MediaID, aborting patch"); + return 1; + } + XELOGW( "XEX patch signature hash doesn't match base XEX signature hash, patch " "will likely fail!");