This commit is contained in:
panzone 2025-03-08 13:53:33 +01:00
parent 5a122c3012
commit ff76836028

View File

@ -32,41 +32,32 @@ void* PS4_SYSV_ABI sceKernelGetProcParam() {
return linker->GetProcParam(); return linker->GetProcParam();
} }
s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, size_t args, const void* argp, s32 PS4_SYSV_ABI sceKernelLoadStartModule(const char* moduleFileName, u64 args, const void* argp,
u32 flags, const void* pOpt, int* pRes) { u32 flags, const void* pOpt, int* pRes) {
LOG_INFO(Lib_Kernel, "called filename = {}, args = {}", moduleFileName, args); LOG_INFO(Lib_Kernel, "called filename = {}, args = {}", moduleFileName, args);
ASSERT(flags == 0); ASSERT(flags == 0);
std::string guest_path(moduleFileName);
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance(); auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
auto* linker = Common::Singleton<Core::Linker>::Instance(); auto* linker = Common::Singleton<Core::Linker>::Instance();
std::filesystem::path path;
s32 handle;
if (guest_path[0] == '/') { std::filesystem::path path;
std::string guest_path(moduleFileName);
const bool is_root = guest_path[0] == '/';
if (is_root || guest_path.contains('/')) {
path = mnt->GetHostPath(guest_path); path = mnt->GetHostPath(guest_path);
handle = linker->LoadAndStartModule(path, args, argp, pRes); } else if (!guest_path.contains('/')) {
if (handle != -1) {
return handle;
}
// Trying to load a system module
UNREACHABLE();
} else {
if (!guest_path.contains('/')) {
path = mnt->GetHostPath("/app0/" + guest_path); path = mnt->GetHostPath("/app0/" + guest_path);
handle = linker->LoadAndStartModule(path, args, argp, pRes); }
if (handle != -1) {
if (const s32 handle = linker->LoadAndStartModule(path, args, argp, pRes); handle != -1) {
return handle; return handle;
} }
} else {
path = mnt->GetHostPath(guest_path); if (is_root) {
handle = linker->LoadAndStartModule(path, args, argp, pRes); UNREACHABLE();
if (handle != -1) {
return handle;
}
}
} }
return ORBIS_KERNEL_ERROR_ENOENT; return ORBIS_KERNEL_ERROR_ENOENT;
} }