mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 06:55:09 +00:00
PS3UPDAT.PUP installer (#2386)
* Add PUP loader * Add .tar loader and update .pup loader * Add extract method + offset to TAR loader Also adds error checking + operator bool overload * Add firmware decryption keys to key vault * Initial seperation of SELFDecrypter This seperates SELFDecrypter into itself and SCEDecrypter. SCEDecrypter contains the logic to decrypt any file with an SCE Header. SELFDecrypter inherits from SCEDecrypter and contains the code specifically to do with ELF. DecryptData could be deduplicated more. * Add "Install Firmware" option to tools menu * SCEDecrypter: put each segment in own file Also, const-correctness, adjusted buffer size and better error handling * More SELFDecrypter refactoring * Compile fix * Add messageboxes to firmware install * Add progress bar to firmware install
This commit is contained in:
parent
b1aa87b515
commit
458dbbd15d
11 changed files with 657 additions and 124 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
|
||||
#include "Gui/PADManager.h"
|
||||
#include "Gui/AboutDialog.h"
|
||||
#include "Gui/GameViewer.h"
|
||||
|
|
@ -16,13 +17,16 @@
|
|||
#include "Gui/SettingsDialog.h"
|
||||
#include "Gui/MemoryStringSearcher.h"
|
||||
#include "Gui/CgDisasm.h"
|
||||
|
||||
#include "Crypto/unpkg.h"
|
||||
#include "Crypto/unself.h"
|
||||
|
||||
#include "Loader/PUP.h"
|
||||
#include "Loader/TAR.h"
|
||||
|
||||
#include "Utilities/Thread.h"
|
||||
#include "Utilities/StrUtil.h"
|
||||
|
||||
#include "../Crypto/unself.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
@ -51,6 +55,7 @@ enum IDs
|
|||
id_tools_rsx_debugger,
|
||||
id_tools_string_search,
|
||||
id_tools_decrypt_sprx_libraries,
|
||||
id_tools_install_firmware,
|
||||
id_tools_cg_disasm,
|
||||
id_help_about,
|
||||
id_update_dbg
|
||||
|
|
@ -111,6 +116,7 @@ MainFrame::MainFrame()
|
|||
menu_tools->Append(id_tools_string_search, "&String Search")->Enable(false);
|
||||
menu_tools->AppendSeparator();
|
||||
menu_tools->Append(id_tools_decrypt_sprx_libraries, "&Decrypt SPRX libraries");
|
||||
menu_tools->Append(id_tools_install_firmware, "&Install Firmware");
|
||||
|
||||
wxMenu* menu_help = new wxMenu();
|
||||
menubar->Append(menu_help, "&Help");
|
||||
|
|
@ -146,6 +152,8 @@ MainFrame::MainFrame()
|
|||
Bind(wxEVT_MENU, &MainFrame::ConfigVHDD, this, id_config_vhdd_manager);
|
||||
Bind(wxEVT_MENU, &MainFrame::ConfigSaveData, this, id_config_savedata_manager);
|
||||
Bind(wxEVT_MENU, &MainFrame::DecryptSPRXLibraries, this, id_tools_decrypt_sprx_libraries);
|
||||
Bind(wxEVT_MENU, &MainFrame::InstallFirmware, this, id_tools_install_firmware);
|
||||
|
||||
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenELFCompiler, this, id_tools_compiler);
|
||||
Bind(wxEVT_MENU, &MainFrame::OpenKernelExplorer, this, id_tools_kernel_explorer);
|
||||
|
|
@ -408,6 +416,102 @@ void MainFrame::DecryptSPRXLibraries(wxCommandEvent& WXUNUSED(event))
|
|||
LOG_NOTICE(GENERAL, "Finished decrypting all SPRX libraries.");
|
||||
}
|
||||
|
||||
void MainFrame::InstallFirmware(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxFileDialog ctrl(this, L"Select PS3UPDAT.PUP file", wxEmptyString, wxEmptyString,
|
||||
"PS3 update file (PS3UPDAT.PUP)|PS3UPDAT.PUP",
|
||||
wxFD_OPEN);
|
||||
|
||||
if (ctrl.ShowModal() == wxID_CANCEL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fs::file pup_f(ctrl.GetPath().ToStdString());
|
||||
pup_object pup(pup_f);
|
||||
if (!pup) {
|
||||
LOG_ERROR(GENERAL, "Error while installing firmware: PUP file is invalid.");
|
||||
wxMessageBox("Error while installing firmware: PUP file is invalid.", "Failure!", wxOK | wxICON_ERROR, this);
|
||||
return;
|
||||
}
|
||||
|
||||
fs::file update_files_f = pup.get_file(0x300);
|
||||
tar_object update_files(update_files_f);
|
||||
auto updatefilenames = update_files.get_filenames();
|
||||
|
||||
updatefilenames.erase(std::remove_if(
|
||||
updatefilenames.begin(), updatefilenames.end(), [](std::string s) {return s.find("dev_flash_") == std::string::npos; }),
|
||||
updatefilenames.end());
|
||||
|
||||
wxProgressDialog pdlg("Firmware Installer", "Please wait, unpacking...", updatefilenames.size(), this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
|
||||
|
||||
// Synchronization variable
|
||||
atomic_t<int> progress(0);
|
||||
{
|
||||
// Run asynchronously
|
||||
scope_thread worker("Firmware Installer", [&]
|
||||
{
|
||||
for (auto updatefilename : updatefilenames)
|
||||
{
|
||||
if (progress == -1) break;
|
||||
|
||||
fs::file updatefile = update_files.get_file(updatefilename);
|
||||
|
||||
SCEDecrypter self_dec(updatefile);
|
||||
self_dec.LoadHeaders();
|
||||
self_dec.LoadMetadata(SCEPKG_ERK, SCEPKG_RIV);
|
||||
self_dec.DecryptData();
|
||||
|
||||
auto dev_flash_tar_f = self_dec.MakeFile();
|
||||
if (dev_flash_tar_f.size() < 3) {
|
||||
LOG_ERROR(GENERAL, "Error while installing firmware: PUP contents are invalid.");
|
||||
wxMessageBox("Error while installing firmware: PUP contents are invalid.", "Failure!", wxOK | wxICON_ERROR, this);
|
||||
progress = -1;
|
||||
}
|
||||
|
||||
tar_object dev_flash_tar(dev_flash_tar_f[2]);
|
||||
if (!dev_flash_tar.extract(fs::get_executable_dir()))
|
||||
{
|
||||
LOG_ERROR(GENERAL, "Error while installing firmware: TAR contents are invalid.");
|
||||
wxMessageBox("Error while installing firmware: TAR contents are invalid.", "Failure!", wxOK | wxICON_ERROR, this);
|
||||
progress = -1;
|
||||
}
|
||||
|
||||
if(progress >= 0)
|
||||
progress += 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Wait for the completion
|
||||
while (std::this_thread::sleep_for(5ms), std::abs(progress) < pdlg.GetRange())
|
||||
{
|
||||
// Update progress window
|
||||
if (!pdlg.Update(static_cast<int>(progress)))
|
||||
{
|
||||
// Installation cancelled (signal with negative value)
|
||||
progress = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
update_files_f.close();
|
||||
pup_f.close();
|
||||
|
||||
if (progress > 0)
|
||||
{
|
||||
pdlg.Update(pdlg.GetRange());
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
}
|
||||
pdlg.Close();
|
||||
|
||||
if (progress > 0)
|
||||
{
|
||||
LOG_SUCCESS(GENERAL, "Successfully installed PS3 firmware.");
|
||||
wxMessageBox("Successfully installed PS3 firmware and LLE Modules!", "Success!", wxOK, this);
|
||||
}
|
||||
}
|
||||
|
||||
void MainFrame::Pause(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if(Emu.IsReady())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue