From 88c37048acb26ddda9dddf4451f1f6b6cb6df661 Mon Sep 17 00:00:00 2001 From: ElBread3 <92335081+ElBread3@users.noreply.github.com> Date: Thu, 17 Oct 2024 03:49:29 -0500 Subject: [PATCH] Load Eboot/Modules from Separate Update Folder (#1397) * load eboot from separate update folder * clarify --------- Co-authored-by: georgemoralis --- src/core/file_sys/fs.cpp | 3 ++- src/emulator.cpp | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/core/file_sys/fs.cpp b/src/core/file_sys/fs.cpp index 8e6d74622..afa231c15 100644 --- a/src/core/file_sys/fs.cpp +++ b/src/core/file_sys/fs.cpp @@ -58,7 +58,8 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view guest_directory, b std::filesystem::path patch_path = mount->host_path; patch_path += "-UPDATE"; - if (corrected_path.starts_with("/app0/") && std::filesystem::exists(patch_path / rel_path)) { + if ((corrected_path.starts_with("/app0") || corrected_path.starts_with("/hostapp")) && + std::filesystem::exists(patch_path / rel_path)) { host_path = patch_path / rel_path; } diff --git a/src/emulator.cpp b/src/emulator.cpp index 46bcfea37..a3019c9ca 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -100,6 +100,12 @@ Emulator::~Emulator() { } void Emulator::Run(const std::filesystem::path& file) { + + // Use the eboot from the separated updates folder if it's there + std::filesystem::path game_patch_folder = file.parent_path().concat("-UPDATE"); + bool use_game_patch = std::filesystem::exists(game_patch_folder / "sce_sys"); + std::filesystem::path eboot_path = use_game_patch ? game_patch_folder / file.filename() : file; + // Applications expect to be run from /app0 so mount the file's parent path as app0. auto* mnt = Common::Singleton::Instance(); mnt->Mount(file.parent_path(), "/app0"); @@ -114,10 +120,7 @@ void Emulator::Run(const std::filesystem::path& file) { std::string app_version; u32 fw_version; - std::filesystem::path game_patch_folder = file.parent_path().concat("-UPDATE"); - bool use_game_patch = std::filesystem::exists(game_patch_folder / "sce_sys"); - std::filesystem::path sce_sys_folder = - use_game_patch ? game_patch_folder / "sce_sys" : file.parent_path() / "sce_sys"; + std::filesystem::path sce_sys_folder = eboot_path.parent_path() / "sce_sys"; if (std::filesystem::is_directory(sce_sys_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_sys_folder)) { if (entry.path().filename() == "param.sfo") { @@ -132,7 +135,7 @@ void Emulator::Run(const std::filesystem::path& file) { Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) / id / "TrophyFiles"; if (!std::filesystem::exists(trophyDir)) { TRP trp; - if (!trp.Extract(file.parent_path(), id)) { + if (!trp.Extract(eboot_path.parent_path(), id)) { LOG_ERROR(Loader, "Couldn't extract trophies"); } } @@ -221,17 +224,23 @@ void Emulator::Run(const std::filesystem::path& file) { Libraries::InitHLELibs(&linker->GetHLESymbols()); // Load the module with the linker - linker->LoadModule(file); + linker->LoadModule(eboot_path); // check if we have system modules to load - LoadSystemModules(file); + LoadSystemModules(eboot_path); // Load all prx from game's sce_module folder std::filesystem::path sce_module_folder = file.parent_path() / "sce_module"; if (std::filesystem::is_directory(sce_module_folder)) { for (const auto& entry : std::filesystem::directory_iterator(sce_module_folder)) { - LOG_INFO(Loader, "Loading {}", fmt::UTF(entry.path().u8string())); - linker->LoadModule(entry.path()); + std::filesystem::path module_path = entry.path(); + std::filesystem::path update_module_path = + eboot_path.parent_path() / "sce_module" / entry.path().filename(); + if (std::filesystem::exists(update_module_path) && use_game_patch) { + module_path = update_module_path; + } + LOG_INFO(Loader, "Loading {}", fmt::UTF(module_path.u8string())); + linker->LoadModule(module_path); } }