check if loading of prx is valid before returning

This commit is contained in:
Stephen Miller 2024-09-27 10:11:14 +03:00 committed by georgemoralis
commit febede3b5a
2 changed files with 7 additions and 5 deletions

View file

@ -226,7 +226,7 @@ void Emulator::Run(const std::filesystem::path& file) {
void Emulator::LoadSystemModules(const std::filesystem::path& file) { void Emulator::LoadSystemModules(const std::filesystem::path& file) {
constexpr std::array<SysModules, 13> ModulesToLoad{ constexpr std::array<SysModules, 13> ModulesToLoad{
{{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2,false}, {{"libSceNgs2.sprx", &Libraries::Ngs2::RegisterlibSceNgs2, false},
{"libSceFiber.sprx", nullptr, true}, {"libSceFiber.sprx", nullptr, true},
{"libSceUlt.sprx", nullptr, true}, {"libSceUlt.sprx", nullptr, true},
{"libSceJson.sprx", nullptr, true}, {"libSceJson.sprx", nullptr, true},
@ -245,17 +245,18 @@ void Emulator::LoadSystemModules(const std::filesystem::path& file) {
for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) { for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) {
found_modules.push_back(entry.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( const auto it = std::ranges::find_if(
found_modules, [&](const auto& path) { return path.filename() == module_name; }); found_modules, [&](const auto& path) { return path.filename() == module_name; });
if (it != found_modules.end()) { if (it != found_modules.end()) {
LOG_INFO(Loader, "Loading {}", it->string()); LOG_INFO(Loader, "Loading {}", it->string());
if (load_at_startup) { if (load_at_startup) {
linker->LoadModule(*it); int result = linker->LoadModule(*it);
} if (result == 0) {
continue; continue;
} }
}
}
if (init_func) { if (init_func) {
LOG_INFO(Loader, "Can't Load {} switching to HLE", module_name); LOG_INFO(Loader, "Can't Load {} switching to HLE", module_name);
init_func(&linker->GetHLESymbols()); init_func(&linker->GetHLESymbols());

View file

@ -18,6 +18,7 @@ using HLEInitDef = void (*)(Core::Loader::SymbolsResolver* sym);
struct SysModules { struct SysModules {
std::string_view module_name; std::string_view module_name;
HLEInitDef callback; HLEInitDef callback;
bool loadAtStartup;
}; };
class Emulator { class Emulator {