From e08c7f2a9a5596f51742a4672d4f100e670a23e7 Mon Sep 17 00:00:00 2001 From: NefariousTechSupport <64808609+NefariousTechSupport@users.noreply.github.com> Date: Sat, 19 Apr 2025 18:32:04 +0100 Subject: [PATCH] Copy debug self elf properly In 7de2869a5364ca5d48ea0a2212621adc0e20bc2f this was changed to be a bit more safe, however it was reading from offset 0 instead of where the real elf started, meaning every debug self would just fail to load immediately. --- rpcs3/Crypto/unself.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index db038bc368..3c187400cb 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -1336,8 +1336,8 @@ static fs::file CheckDebugSelf(const fs::file& s) // Get the real elf offset. s.seek(0x10); - // Start at the real elf offset. - s.seek(key_version == 0x80 ? +s.read>() : +s.read>()); + // Read the real elf offset. + usz read_pos = key_version == 0x80 ? +s.read>() : +s.read>(); // Write the real ELF file back. fs::file e = fs::make_stream>(); @@ -1345,7 +1345,6 @@ static fs::file CheckDebugSelf(const fs::file& s) // Copy the data. std::vector buf(std::min(s.size(), 4096)); - usz read_pos = 0; while (const u64 size = s.read_at(read_pos, buf.data(), buf.size())) { e.write(buf.data(), size);