diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index d693ae5abb..a553bca1bd 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1403,7 +1403,7 @@ static bool CheckDebugSelf(fs::file& s) return false; } -fs::file decrypt_self(fs::file elf_or_self, u8* klic_key, SelfAdditionalInfo* out_info) +fs::file decrypt_self(fs::file elf_or_self, u8* klic_key, SelfAdditionalInfo* out_info, bool require_encrypted) { if (out_info) { @@ -1418,8 +1418,14 @@ fs::file decrypt_self(fs::file elf_or_self, u8* klic_key, SelfAdditionalInfo* ou elf_or_self.seek(0); // Check SELF header first. Check for a debug SELF. - if (elf_or_self.size() >= 4 && elf_or_self.read() == "SCE\0"_u32 && !CheckDebugSelf(elf_or_self)) + if (elf_or_self.size() >= 4 && elf_or_self.read() == "SCE\0"_u32) { + if (CheckDebugSelf(elf_or_self)) + { + // TODO: Decrypt + return elf_or_self; + } + // Check the ELF file class (32 or 64 bit). const bool isElf32 = IsSelfElf32(elf_or_self); @@ -1451,6 +1457,11 @@ fs::file decrypt_self(fs::file elf_or_self, u8* klic_key, SelfAdditionalInfo* ou return self_dec.MakeElf(isElf32); } + if (require_encrypted) + { + return {}; + } + return elf_or_self; } diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 4cc5d90ee3..afa3416095 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -559,7 +559,7 @@ private: } }; -fs::file decrypt_self(fs::file elf_or_self, u8* klic_key = nullptr, SelfAdditionalInfo* additional_info = nullptr); +fs::file decrypt_self(fs::file elf_or_self, u8* klic_key = nullptr, SelfAdditionalInfo* additional_info = nullptr, bool require_encrypted = false); bool verify_npdrm_self_headers(const fs::file& self, u8* klic_key = nullptr, NPD_HEADER* npd_out = nullptr); bool get_npdrm_self_header(const fs::file& self, NPD_HEADER& npd); diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index d9144a2d5b..b6f98df46f 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3890,7 +3890,7 @@ extern void ppu_precompile(std::vector& dir_queue, std::vector ovlmid, const std::string& vp u128 klic = g_fxo->get().last_key(); - ppu_exec_object obj = decrypt_self(std::move(src), reinterpret_cast(&klic)); + ppu_exec_object obj = decrypt_self(std::move(src), reinterpret_cast(&klic), nullptr, true); if (obj != elf_error::ok) { diff --git a/rpcs3/Emu/Cell/lv2/sys_prx.cpp b/rpcs3/Emu/Cell/lv2/sys_prx.cpp index 4cde5d52e9..4a9b7d4ee5 100644 --- a/rpcs3/Emu/Cell/lv2/sys_prx.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_prx.cpp @@ -263,11 +263,11 @@ static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptrget().last_key(); - ppu_prx_object obj = decrypt_self(std::move(src), reinterpret_cast(&klic)); + ppu_prx_object obj = decrypt_self(std::move(src), reinterpret_cast(&klic), nullptr, true); if (obj != elf_error::ok) { - return CELL_PRX_ERROR_ILLEGAL_LIBRARY; + return CELL_PRX_ERROR_UNSUPPORTED_PRX_TYPE; } const auto prx = ppu_load_prx(obj, false, path, file_offset);