From 84d2add72dfa1d3e57dd69c0c93e1ae11204acc0 Mon Sep 17 00:00:00 2001 From: DH Date: Mon, 2 Sep 2024 20:32:27 +0300 Subject: [PATCH] rpcsx-os: fix sdk version fetching --- orbis-kernel/include/orbis/thread/Process.hpp | 2 +- orbis-kernel/src/sys/sys_sysctl.cpp | 9 +++++++-- rpcsx-os/main.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/orbis-kernel/include/orbis/thread/Process.hpp b/orbis-kernel/include/orbis/thread/Process.hpp index 5ea16d677..104308f11 100644 --- a/orbis-kernel/include/orbis/thread/Process.hpp +++ b/orbis-kernel/include/orbis/thread/Process.hpp @@ -69,7 +69,7 @@ struct Process final { EventEmitter event; std::optional exitStatus; - std::uint32_t sdkVersion = -1; + std::uint32_t sdkVersion = 0; std::uint64_t nextTlsSlot = 1; std::uint64_t lastTlsOffset = 0; diff --git a/orbis-kernel/src/sys/sys_sysctl.cpp b/orbis-kernel/src/sys/sys_sysctl.cpp index f1b495655..e3d3487e1 100644 --- a/orbis-kernel/src/sys/sys_sysctl.cpp +++ b/orbis-kernel/src/sys/sys_sysctl.cpp @@ -206,8 +206,13 @@ SysResult kern_sysctl(Thread *thread, ptr name, uint namelen, return ErrorCode::INVAL; } - ORBIS_RET_ON_ERROR(uwrite(ptr(old), process->sdkVersion)); - ORBIS_LOG_ERROR("get sdk version by pid", name[3], process->sdkVersion); + auto sdkVersion = process->sdkVersion; + if (sdkVersion == 0) { + sdkVersion = g_context.fwSdkVersion; + } + + ORBIS_RET_ON_ERROR(uwrite(ptr(old), sdkVersion)); + ORBIS_LOG_ERROR("get sdk version by pid", name[3], sdkVersion); return uwrite(oldlenp, sizeof(uint32_t)); } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 87a886511..f91aaf5a3 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -564,7 +564,7 @@ ExecEnv ps4CreateExecEnv(orbis::Thread *mainThread, std::uint64_t entryPoint = executableModule->entryPoint; if (mainThread->tproc->processParam != nullptr && - mainThread->tproc->processParamSize <= sizeof(Ps4ProcessParam)) { + mainThread->tproc->processParamSize >= sizeof(Ps4ProcessParam)) { auto processParam = reinterpret_cast(mainThread->tproc->processParam);