From febede3b5a4edd953bd7ff1197bd956e6687c9e3 Mon Sep 17 00:00:00 2001 From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:11:14 +0300 Subject: [PATCH] check if loading of prx is valid before returning --- src/emulator.cpp | 11 ++++++----- src/emulator.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 19199bd7b..84c9f79c4 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -226,7 +226,7 @@ void Emulator::Run(const std::filesystem::path& file) { void Emulator::LoadSystemModules(const std::filesystem::path& file) { constexpr std::array ModulesToLoad{ - {{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2,false}, + {{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2, false}, {"libSceFiber.sprx", nullptr, true}, {"libSceUlt.sprx", nullptr, true}, {"libSceJson.sprx", nullptr, true}, @@ -245,16 +245,17 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file) { for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { found_modules.push_back(entry.path()); } - for (const auto& [module_name, init_func , load_at_startup] : ModulesToLoad) { + for (const auto& [module_name, init_func, load_at_startup] : ModulesToLoad) { const auto it = std::ranges::find_if( found_modules, [&](const auto& path) { return path.filename() == module_name; }); if (it != found_modules.end()) { LOG_INFO(Loader, "Loading {}", it->string()); if (load_at_startup) { - linker->LoadModule(*it); + int result = linker->LoadModule(*it); + if (result == 0) { + continue; + } } - - continue; } if (init_func) { LOG_INFO(Loader, "Can't Load {} switching to HLE", module_name); diff --git a/src/emulator.h b/src/emulator.h index 01bce7e7c..7a3b62186 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -18,6 +18,7 @@ using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym); struct SysModules { std::string_view module_name; HLEInitDef callback; + bool loadAtStartup; }; class Emulator {