Skip to content

Commit

Permalink
interface: Fix load app when module is missing in auto mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zangetsu38 committed Sep 27, 2024
1 parent 70e034e commit 5419a07
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vita3k/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, bool> is_app_modules = {};
const std::vector<std::string> 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<std::string> 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);
Expand Down

0 comments on commit 5419a07

Please sign in to comment.