mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 00:41:26 +12:00
Fixed VFS initialization order
Fixed RAP location for SELF Fixed custom config loading
This commit is contained in:
parent
45bb51ded8
commit
3751d5d5c1
6 changed files with 85 additions and 89 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "sha1.h"
|
||||
#include "utils.h"
|
||||
#include "unself.h"
|
||||
#include "Emu/VFS.h"
|
||||
|
||||
// TODO: Still reliant on wxWidgets for zlib functions. Alternative solutions?
|
||||
#include <zlib.h>
|
||||
|
@ -1397,23 +1398,15 @@ bool SELFDecrypter::GetKeyFromRap(u8 *content_id, u8 *npdrm_key)
|
|||
memset(rap_key, 0, 0x10);
|
||||
|
||||
// Try to find a matching RAP file under exdata folder.
|
||||
std::string ci_str((const char *)content_id);
|
||||
std::string pf_str("00000001"); // TODO: Allow multiple profiles. Use default for now.
|
||||
std::string rap_path("dev_hdd0/home/" + pf_str + "/exdata/" + ci_str + ".rap");
|
||||
|
||||
// Check if we have a valid RAP file.
|
||||
if (!fs::is_file(rap_path))
|
||||
{
|
||||
LOG_ERROR(LOADER, "This application requires a valid RAP file for decryption!");
|
||||
return false;
|
||||
}
|
||||
const std::string ci_str = reinterpret_cast<const char*>(content_id);
|
||||
const std::string rap_path = "/dev_hdd0/home/00000001/exdata/" + ci_str + ".rap";
|
||||
|
||||
// Open the RAP file and read the key.
|
||||
fs::file rap_file(rap_path);
|
||||
const fs::file rap_file(vfs::get(rap_path));
|
||||
|
||||
if (!rap_file)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Failed to load RAP file!");
|
||||
LOG_FATAL(LOADER, "Failed to load RAP file: %s", rap_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,44 +194,24 @@ void Emulator::Load()
|
|||
m_title = psf::get_string(_psf, "TITLE", m_path);
|
||||
m_title_id = psf::get_string(_psf, "TITLE_ID");
|
||||
|
||||
LOG_NOTICE(LOADER, "Title: %s", GetTitle());
|
||||
LOG_NOTICE(LOADER, "Serial: %s", GetTitleID());
|
||||
|
||||
// Initialize data/cache directory
|
||||
m_cache_path = fs::get_data_dir(m_title_id, m_path);
|
||||
LOG_NOTICE(LOADER, "Cache: %s", GetCachePath());
|
||||
|
||||
// Check SELF header
|
||||
if (elf_file.size() >= 4 && elf_file.read<u32>() == "SCE\0"_u32)
|
||||
// Load custom config-0
|
||||
if (fs::file cfg_file{m_cache_path + "/config.yml"})
|
||||
{
|
||||
const std::string decrypted_path = m_cache_path + "boot.elf";
|
||||
|
||||
fs::stat_t encrypted_stat = elf_file.stat();
|
||||
fs::stat_t decrypted_stat;
|
||||
|
||||
// Check modification time and try to load decrypted ELF
|
||||
if (fs::stat(decrypted_path, decrypted_stat) && decrypted_stat.mtime == encrypted_stat.mtime)
|
||||
{
|
||||
elf_file.open(decrypted_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decrypt SELF
|
||||
elf_file = decrypt_self(std::move(elf_file));
|
||||
|
||||
if (fs::file elf_out{decrypted_path, fs::rewrite})
|
||||
{
|
||||
elf_out.write(elf_file.to_vector<u8>());
|
||||
elf_out.close();
|
||||
fs::utime(decrypted_path, encrypted_stat.atime, encrypted_stat.mtime);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR(LOADER, "Failed to create boot.elf");
|
||||
}
|
||||
}
|
||||
LOG_NOTICE(LOADER, "Applying custom config: %s/config.yml", m_cache_path);
|
||||
cfg::root.from_string(cfg_file.to_string());
|
||||
}
|
||||
|
||||
// Load custom config-1
|
||||
if (fs::file cfg_file{fs::get_config_dir() + "data/" + m_title_id + "/config.yml"})
|
||||
{
|
||||
LOG_NOTICE(LOADER, "Applying custom config %s", fs::get_config_dir() + "data/" + m_title_id + "/config.yml");
|
||||
LOG_NOTICE(LOADER, "Applying custom config: data/%s/config.yml", m_title_id);
|
||||
cfg::root.from_string(cfg_file.to_string());
|
||||
}
|
||||
|
||||
|
@ -242,37 +222,13 @@ void Emulator::Load()
|
|||
cfg::root.from_string(cfg_file.to_string());
|
||||
}
|
||||
|
||||
ppu_exec_object ppu_exec;
|
||||
ppu_prx_object ppu_prx;
|
||||
spu_exec_object spu_exec;
|
||||
arm_exec_object arm_exec;
|
||||
|
||||
if (!elf_file)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Failed to decrypt SELF: %s", m_path);
|
||||
return;
|
||||
}
|
||||
else if (ppu_exec.open(elf_file) == elf_error::ok)
|
||||
{
|
||||
// PS3 executable
|
||||
g_system = system_type::ps3;
|
||||
m_status = Ready;
|
||||
vm::ps3::init();
|
||||
|
||||
if (m_elf_path.empty())
|
||||
{
|
||||
m_elf_path = "/host_root/" + m_path;
|
||||
LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path);
|
||||
}
|
||||
|
||||
LOG_NOTICE(LOADER, "Title: %s", GetTitle());
|
||||
LOG_NOTICE(LOADER, "Serial: %s", GetTitleID());
|
||||
LOG_NOTICE(LOADER, "Used configuration:\n%s\n", cfg::root.to_string());
|
||||
|
||||
// Mount all devices
|
||||
const std::string& emu_dir_ = g_cfg_vfs_emulator_dir;
|
||||
const std::string& emu_dir = emu_dir_.empty() ? fs::get_config_dir() : emu_dir_;
|
||||
const std::string& bdvd_dir = g_cfg_vfs_dev_bdvd;
|
||||
const std::string& home_dir = g_cfg_vfs_app_home;
|
||||
const std::string emu_dir_ = g_cfg_vfs_emulator_dir;
|
||||
const std::string emu_dir = emu_dir_.empty() ? fs::get_config_dir() : emu_dir_;
|
||||
const std::string bdvd_dir = g_cfg_vfs_dev_bdvd;
|
||||
const std::string home_dir = g_cfg_vfs_app_home;
|
||||
|
||||
vfs::mount("dev_hdd0", fmt::replace_all(g_cfg_vfs_dev_hdd0, "$(EmulatorDir)", emu_dir));
|
||||
vfs::mount("dev_hdd1", fmt::replace_all(g_cfg_vfs_dev_hdd1, "$(EmulatorDir)", emu_dir));
|
||||
|
@ -309,7 +265,59 @@ void Emulator::Load()
|
|||
vfs::mount("host_root", {});
|
||||
}
|
||||
|
||||
LOG_NOTICE(LOADER, "Used configuration:\n%s\n", cfg::root.to_string());
|
||||
// Check SELF header
|
||||
if (elf_file.size() >= 4 && elf_file.read<u32>() == "SCE\0"_u32)
|
||||
{
|
||||
const std::string decrypted_path = m_cache_path + "boot.elf";
|
||||
|
||||
fs::stat_t encrypted_stat = elf_file.stat();
|
||||
fs::stat_t decrypted_stat;
|
||||
|
||||
// Check modification time and try to load decrypted ELF
|
||||
if (fs::stat(decrypted_path, decrypted_stat) && decrypted_stat.mtime == encrypted_stat.mtime)
|
||||
{
|
||||
elf_file.open(decrypted_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Decrypt SELF
|
||||
elf_file = decrypt_self(std::move(elf_file));
|
||||
|
||||
if (fs::file elf_out{decrypted_path, fs::rewrite})
|
||||
{
|
||||
elf_out.write(elf_file.to_vector<u8>());
|
||||
elf_out.close();
|
||||
fs::utime(decrypted_path, encrypted_stat.atime, encrypted_stat.mtime);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR(LOADER, "Failed to create boot.elf");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ppu_exec_object ppu_exec;
|
||||
ppu_prx_object ppu_prx;
|
||||
spu_exec_object spu_exec;
|
||||
arm_exec_object arm_exec;
|
||||
|
||||
if (!elf_file)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Failed to decrypt SELF: %s", m_path);
|
||||
return;
|
||||
}
|
||||
else if (ppu_exec.open(elf_file) == elf_error::ok)
|
||||
{
|
||||
// PS3 executable
|
||||
g_system = system_type::ps3;
|
||||
m_status = Ready;
|
||||
vm::ps3::init();
|
||||
|
||||
if (m_elf_path.empty())
|
||||
{
|
||||
m_elf_path = "/host_root/" + m_path;
|
||||
LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path);
|
||||
}
|
||||
|
||||
ppu_load_exec(ppu_exec);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ void GameViewer::LoadPSF()
|
|||
|
||||
GameInfo game;
|
||||
game.root = m_games[i];
|
||||
game.serial = psf::get_string(psf, "TITLE_ID", "unknown");
|
||||
game.serial = psf::get_string(psf, "TITLE_ID", "");
|
||||
game.name = psf::get_string(psf, "TITLE", "unknown");
|
||||
game.app_ver = psf::get_string(psf, "APP_VER", "unknown");
|
||||
game.category = psf::get_string(psf, "CATEGORY", "unknown");
|
||||
|
@ -138,11 +138,6 @@ void GameViewer::LoadPSF()
|
|||
game.resolution = psf::get_integer(psf, "RESOLUTION");
|
||||
game.sound_format = psf::get_integer(psf, "SOUND_FORMAT");
|
||||
|
||||
if (game.serial.length() == 9)
|
||||
{
|
||||
game.serial.insert(4, 1, '-');
|
||||
}
|
||||
|
||||
if (game.category == "HG")
|
||||
{
|
||||
game.category = "HDD Game";
|
||||
|
@ -230,11 +225,7 @@ void GameViewer::ConfigureGame(wxCommandEvent& WXUNUSED(event))
|
|||
{
|
||||
long i = GetFirstSelected();
|
||||
if (i < 0) return;
|
||||
if (!fs::exists(fs::get_config_dir() + "data/" + m_game_data[i].root))
|
||||
{
|
||||
fs::create_dir(fs::get_config_dir() + "data/" + m_game_data[i].root);
|
||||
}
|
||||
SettingsDialog(this, fs::get_config_dir() + "data/" + m_game_data[i].root + "/config.yml");
|
||||
SettingsDialog(this, "data/" + m_game_data[i].serial);
|
||||
}
|
||||
|
||||
void GameViewer::RemoveGame(wxCommandEvent& event)
|
||||
|
|
|
@ -202,15 +202,19 @@ struct textctrl_pad : cfg_adapter
|
|||
};
|
||||
|
||||
|
||||
SettingsDialog::SettingsDialog(wxWindow* parent, const wxString& pergameload)
|
||||
SettingsDialog::SettingsDialog(wxWindow* parent, const std::string& path)
|
||||
: wxDialog(parent, wxID_ANY, "Settings", wxDefaultPosition)
|
||||
{
|
||||
// Load default config
|
||||
loaded = YAML::Load(g_cfg_defaults);
|
||||
|
||||
// Create config path if necessary
|
||||
fs::create_path(fs::get_config_dir() + path);
|
||||
|
||||
// Incrementally load config.yml
|
||||
const fs::file config(!pergameload.IsEmpty() ? pergameload.ToStdString() : fs::get_config_dir() + "/config.yml", fs::read + fs::write + fs::create);
|
||||
if (config.to_string().length() == 0 && !pergameload.IsEmpty())//empty first time gameconfig
|
||||
const fs::file config(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write + fs::create);
|
||||
|
||||
if (config.size() == 0 && !path.empty()) // First time
|
||||
{
|
||||
const fs::file configexisted(fs::get_config_dir() + "/config.yml", fs::read + fs::write + fs::create);
|
||||
loaded += YAML::Load(configexisted.to_string());
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class SettingsDialog : public wxDialog
|
||||
{
|
||||
public:
|
||||
SettingsDialog(wxWindow* parent, const wxString& pergameload);
|
||||
SettingsDialog(wxWindow* parent, const std::string& path);
|
||||
|
||||
private:
|
||||
wxCheckListBox* chbox_list_core_lle;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue