From e7ebb03103afa7b7760f5ede3228ae8fa4535f6d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Apr 2023 19:28:15 -0700 Subject: [PATCH] Module: Save ELFs by name and fix when compressed. Causes confusion for people using this feature. --- Core/HLE/sceKernelModule.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 5f13243d06..72b63b2733 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -884,7 +884,7 @@ void PSPModule::Cleanup() { } } -static void __SaveDecryptedEbootToStorageMedia(const u8 *decryptedEbootDataPtr, const u32 length) { +static void SaveDecryptedEbootToStorageMedia(const u8 *decryptedEbootDataPtr, const u32 length, const char *name) { if (!decryptedEbootDataPtr) { ERROR_LOG(SCEMODULE, "Error saving decrypted EBOOT.BIN: invalid pointer"); return; @@ -895,7 +895,7 @@ static void __SaveDecryptedEbootToStorageMedia(const u8 *decryptedEbootDataPtr, return; } - const std::string filenameToDumpTo = g_paramSFO.GetDiscID() + ".BIN"; + const std::string filenameToDumpTo = StringFromFormat("%s_%s.BIN", g_paramSFO.GetDiscID().c_str(), name); const Path dumpDirectory = GetSysDirectory(DIRECTORY_DUMP); const Path fullPath = dumpDirectory / filenameToDumpTo; @@ -1264,9 +1264,10 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load // If we've made it this far, it should be safe to dump. if (g_Config.bDumpDecryptedEboot) { - INFO_LOG(SCEMODULE, "Dumping decrypted EBOOT.BIN to file."); - const u32 dumpLength = ret; - __SaveDecryptedEbootToStorageMedia(ptr, dumpLength); + // Copy the name to ensure it's null terminated. + char name[32]{}; + strncpy(name, head->modname, ARRAY_SIZE(head->modname)); + SaveDecryptedEbootToStorageMedia(ptr, elfSize, name); } } }