From 806758d06f89522d4b9778f0e2d76b0cbfce0acc Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Sun, 24 Mar 2024 12:36:27 +0200 Subject: [PATCH] Fix NPD files decryption in decryption tool --- rpcs3/Crypto/decrypt_binaries.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpcs3/Crypto/decrypt_binaries.cpp b/rpcs3/Crypto/decrypt_binaries.cpp index e47160fa58..8af82d46ce 100644 --- a/rpcs3/Crypto/decrypt_binaries.cpp +++ b/rpcs3/Crypto/decrypt_binaries.cpp @@ -74,6 +74,7 @@ usz decrypt_binaries_t::decrypt(std::string klic_input) const std::string old_path = _module; fs::file elf_file; + fs::file internal_file; bool invalid = false; usz key_it = 0; @@ -83,6 +84,8 @@ usz decrypt_binaries_t::decrypt(std::string klic_input) { for (; key_it < m_klics.size(); key_it++) { + internal_file.close(); + if (!elf_file.open(old_path) || !elf_file.read(file_magic)) { file_magic = 0; @@ -106,7 +109,8 @@ usz decrypt_binaries_t::decrypt(std::string klic_input) case "NPD\0"_u32: { // EDAT / SDAT - elf_file = DecryptEDAT(elf_file, old_path, key_it != 0 ? 8 : 1, reinterpret_cast(&m_klics[key_it])); + internal_file = std::move(elf_file); + elf_file = DecryptEDAT(internal_file, old_path, key_it != 0 ? 8 : 1, reinterpret_cast(&m_klics[key_it])); if (!elf_file) {