From 5419a075ba3d5b5f7a17072d9fc5b81a73f2d570 Mon Sep 17 00:00:00 2001 From: Zangetsu38 Date: Fri, 27 Sep 2024 06:59:07 +0200 Subject: [PATCH] interface: Fix load app when module is missing in auto mode. --- vita3k/interface.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vita3k/interface.cpp b/vita3k/interface.cpp index f93a321412..f0dbab564d 100644 --- a/vita3k/interface.cpp +++ b/vita3k/interface.cpp @@ -466,27 +466,32 @@ static ExitCode load_app_impl(SceUID &main_module_id, EmuEnvState &emuenv) { } } const auto module_app_path{ emuenv.pref_path / "ux0/app" / emuenv.io.app_path / "sce_module" }; - const auto is_app = fs::exists(module_app_path) && !fs::is_empty(module_app_path); + std::map is_app_modules = {}; + const std::vector modules_app_list = { "libc", "libfios2" }; + for (const auto &module_name : modules_app_list) + is_app_modules[module_name] = !fs::is_empty(module_app_path) && fs::exists(module_app_path / fmt::format("{}.suprx", module_name)); + std::vector lib_load_list = {}; // todo: check if module is imported auto add_preload_module = [&](uint32_t code, SceSysmoduleModuleId module_id, const std::string &name, bool load_from_app) { if ((process_preload_disabled & code) == 0) { if (is_lle_module(name, emuenv)) { + const auto module_name_file = fmt::format("{}.suprx", name); if (load_from_app) - lib_load_list.emplace_back(fmt::format("app0:sce_module/{}.suprx", name)); - else - lib_load_list.emplace_back(fmt::format("vs0:sys/external/{}.suprx", name)); + lib_load_list.emplace_back(fmt::format("app0:sce_module/{}", module_name_file)); + else if (fs::exists(emuenv.pref_path / "vs0/sys/external" / module_name_file)) + lib_load_list.emplace_back(fmt::format("vs0:sys/external/{}", module_name_file)); } if (module_id != SCE_SYSMODULE_INVALID) emuenv.kernel.loaded_sysmodules[module_id] = {}; } }; - add_preload_module(0x00010000, SCE_SYSMODULE_INVALID, "libc", is_app); + add_preload_module(0x00010000, SCE_SYSMODULE_INVALID, "libc", is_app_modules["libc"]); add_preload_module(0x00020000, SCE_SYSMODULE_DBG, "libdbg", false); add_preload_module(0x00080000, SCE_SYSMODULE_INVALID, "libshellsvc", false); add_preload_module(0x00100000, SCE_SYSMODULE_INVALID, "libcdlg", false); - add_preload_module(0x00200000, SCE_SYSMODULE_FIOS2, "libfios2", is_app); + add_preload_module(0x00200000, SCE_SYSMODULE_FIOS2, "libfios2", is_app_modules["libfios2"]); add_preload_module(0x00400000, SCE_SYSMODULE_APPUTIL, "apputil", false); add_preload_module(0x00800000, SCE_SYSMODULE_INVALID, "libSceFt2", false); add_preload_module(0x01000000, SCE_SYSMODULE_INVALID, "libpvf", false);