From 6f9adbd162c7b4a3f3d936ae573522d6a2a3de70 Mon Sep 17 00:00:00 2001 From: clienthax Date: Tue, 30 Nov 2021 13:16:27 +0000 Subject: [PATCH] Debug SPRX check --- rpcs3/Crypto/unself.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index 65e00092dc..98cf1f21af 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1343,6 +1343,27 @@ static bool IsSelfElf32(const fs::file& f) return (elf_class[4] == 1); } +static bool IsDebugSelf(const fs::file& f) +{ + if (f.size() < 0x18) + { + return false; + } + + // Get the key version. + f.seek(0x08); + + const u16 key_version = f.read>(); + + // Check for DEBUG version. + if (key_version == 0x80 || key_version == 0xc0) + { + return true; + } + + return false; +} + static bool CheckDebugSelf(fs::file& s) { if (s.size() < 0x18) @@ -1442,7 +1463,7 @@ bool verify_npdrm_self_headers(const fs::file& self, u8* klic_key) self.seek(0); - if (self.size() >= 4 && self.read() == "SCE\0"_u32) + if (self.size() >= 4 && self.read() == "SCE\0"_u32 && !IsDebugSelf(self)) { // Check the ELF file class (32 or 64 bit). const bool isElf32 = IsSelfElf32(self);