Add a basic decrypted EBOOT.BIN dump function.

It won't dump already decrypted EBOOTs.
This commit is contained in:
The Dax 2014-02-27 01:19:32 -05:00
parent 056968129c
commit 8c31e1ca21
6 changed files with 55 additions and 1 deletions

View File

@ -291,7 +291,7 @@ static ConfigSetting generalSettings[] = {
ConfigSetting("WindowHeight", &g_Config.iWindowHeight, 0),
ConfigSetting("PauseOnLostFocus", &g_Config.bPauseOnLostFocus, false),
#endif
ConfigSetting("DumpDecryptedEboots", &g_Config.bDumpDecryptedEboot, false),
ConfigSetting(false),
};

View File

@ -66,6 +66,7 @@ public:
int iNumWorkerThreads;
bool bScreenshotsAsPNG;
bool bEnableLogging;
bool bDumpDecryptedEboot;
#if defined(USING_WIN_UI)
bool bPauseOnLostFocus;
bool bTopMost;

View File

@ -48,6 +48,7 @@
#include "Core/HLE/sceKernelMemory.h"
#include "Core/HLE/sceIo.h"
#include "Core/HLE/KernelWaitHelpers.h"
#include "Core/ELF/ParamSFO.h"
#include "GPU/GPUState.h"
@ -719,6 +720,48 @@ void Module::Cleanup() {
}
}
void __SaveDecryptedEbootToStorageMedia(const u8 *decryptedEbootDataPtr, const u32 length) {
if (!decryptedEbootDataPtr) {
ERROR_LOG(SCEMODULE, "Error saving decrypted EBOOT.BIN: invalid pointer");
return;
}
if (length == 0) {
ERROR_LOG(SCEMODULE, "Error saving decrypted EBOOT.BIN: invalid length");
return;
}
const std::string filenameToDumpTo = g_paramSFO.GetValueString("DISC_ID") + ".BIN";
const std::string dumpDirectory = GetSysDirectory(DIRECTORY_DUMP);
const std::string fullPath = dumpDirectory + filenameToDumpTo;
// If the file already exists, don't dump it again.
if (File::Exists(fullPath)) {
INFO_LOG(SCEMODULE, "Decrypted EBOOT.BIN already exists for this game, skipping dump.");
return;
}
// Make sure the dump directory exists before continuing.
if (!File::Exists(dumpDirectory)) {
if (!File::CreateDir(dumpDirectory)) {
ERROR_LOG(SCEMODULE, "Unable to create directory for EBOOT dumping, aborting.");
return;
}
}
FILE *decryptedEbootFile = fopen(fullPath.c_str(), "wb");
if (!decryptedEbootFile) {
ERROR_LOG(SCEMODULE, "Unable to write decrypted EBOOT.");
return;
}
const size_t lengthToWrite = length;
fwrite(decryptedEbootDataPtr, sizeof(u8), lengthToWrite, decryptedEbootFile);
fclose(decryptedEbootFile);
INFO_LOG(SCEMODULE, "Successfully wrote decrypted EBOOT to %s", fullPath.c_str());
}
Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *error_string, u32 *magic) {
Module *module = new Module;
kernelObjects.Create(module);
@ -763,6 +806,12 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, std::string *erro
} else {
// TODO: Is this right?
module->nm.bss_size = head->bss_size;
// If we've made it this far, it should be safe to dump.
if (g_Config.bDumpDecryptedEboot) {
INFO_LOG(SCEMODULE, "Dumping derypted EBOOT.BIN to file.");
__SaveDecryptedEbootToStorageMedia(ptr, head->elf_size);
}
}
}

View File

@ -455,6 +455,8 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
return g_Config.memCardDirectory + "PSP/SYSTEM/";
case DIRECTORY_PAUTH:
return g_Config.memCardDirectory + "PAUTH/";
case DIRECTORY_DUMP:
return g_Config.memCardDirectory + "PSP/SYSTEM/DUMP/";
// Just return the memory stick root if we run into some sort of problem.
default:
ERROR_LOG(FILESYS, "Unknown directory type.");

View File

@ -42,6 +42,7 @@ enum PSPDirectories {
DIRECTORY_GAME,
DIRECTORY_SAVEDATA,
DIRECTORY_PAUTH,
DIRECTORY_DUMP,
};
extern GlobalUIState globalUIState;

View File

@ -576,6 +576,7 @@ void DeveloperToolsScreen::CreateViews() {
list->Add(new Choice(de->T("System Information")))->OnClick.Handle(this, &DeveloperToolsScreen::OnSysInfo);
list->Add(new CheckBox(&g_Config.bShowDeveloperMenu, de->T("Show Developer Menu")));
list->Add(new CheckBox(&g_Config.bDumpDecryptedEboot, de->T("Dump Decrypted Eboot", "Dump Decrypted EBOOT.BIN (If Encrypted) When Booting Game")));
Choice *cpuTests = new Choice(de->T("Run CPU Tests"));
list->Add(cpuTests)->OnClick.Handle(this, &DeveloperToolsScreen::OnRunCPUTests);