Fix sceKernelLoadStartModule (#2635)

This commit is contained in:
Pavel 2025-03-10 12:12:12 +03:00 committed by GitHub
parent 46b1bafa17
commit 8bcdd9c068
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,19 +43,30 @@ s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, u64 args,
std::filesystem::path path;
std::string guest_path(moduleFileName);
const bool is_root = guest_path[0] == '/';
if (is_root || guest_path.contains('/')) {
s32 handle = -1;
if (guest_path[0] == '/') {
// try load /system/common/lib/ +path
// try load /system/priv/lib/ +path
path = mnt->GetHostPath(guest_path);
} else if (!guest_path.contains('/')) {
path = mnt->GetHostPath("/app0/" + guest_path);
}
if (const s32 handle = linker->LoadAndStartModule(path, args, argp, pRes); handle != -1) {
return handle;
}
if (is_root) {
UNREACHABLE();
handle = linker->LoadAndStartModule(path, args, argp, pRes);
if (handle != -1)
return handle;
} else {
if (!guest_path.contains('/')) {
path = mnt->GetHostPath("/app0/" + guest_path);
handle = linker->LoadAndStartModule(path, args, argp, pRes);
if (handle != -1)
return handle;
// if ((flags & 0x10000) != 0)
// try load /system/priv/lib/ +basename
// try load /system/common/lib/ +basename
} else {
path = mnt->GetHostPath(guest_path);
handle = linker->LoadAndStartModule(path, args, argp, pRes);
if (handle != -1)
return handle;
}
}
return ORBIS_KERNEL_ERROR_ENOENT;