From dc44b619b2956d00dadac86a214e83d767df9aff Mon Sep 17 00:00:00 2001 From: DH Date: Fri, 10 Nov 2023 20:53:41 +0300 Subject: [PATCH] [orbis-kernel] store sdk version to the context --- orbis-kernel/include/orbis/KernelContext.hpp | 1 + orbis-kernel/src/sys/sys_sysctl.cpp | 13 ++----------- rpcsx-os/main.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/orbis-kernel/include/orbis/KernelContext.hpp b/orbis-kernel/include/orbis/KernelContext.hpp index f8c07ad7c..15bfeb980 100644 --- a/orbis-kernel/include/orbis/KernelContext.hpp +++ b/orbis-kernel/include/orbis/KernelContext.hpp @@ -159,6 +159,7 @@ public: Ref dmemDevice; Ref blockpoolDevice; AudioOut *audioOut = nullptr; + uint sdkVersion{}; private: mutable pthread_mutex_t m_heap_mtx; diff --git a/orbis-kernel/src/sys/sys_sysctl.cpp b/orbis-kernel/src/sys/sys_sysctl.cpp index a1d3ab905..97fee7c13 100644 --- a/orbis-kernel/src/sys/sys_sysctl.cpp +++ b/orbis-kernel/src/sys/sys_sysctl.cpp @@ -372,17 +372,8 @@ orbis::SysResult orbis::sys___sysctl(Thread *thread, ptr name, return ErrorCode::INVAL; } - auto processParam = - reinterpret_cast(thread->tproc->processParam); - - auto sdkVersion = processParam // - + sizeof(uint64_t) // size - + sizeof(uint32_t) // magic - + sizeof(uint32_t); // entryCount - - std::printf("Reporting SDK version %x\n", - *reinterpret_cast(sdkVersion)); - *(uint32_t *)old = *reinterpret_cast(sdkVersion); + std::printf("Reporting SDK version %x\n", g_context.sdkVersion); + *(uint32_t *)old = g_context.sdkVersion; return {}; } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index f08b61075..99bdaeb76 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -417,6 +417,18 @@ int ps4Exec(orbis::Thread *mainThread, std::uint64_t interpBase = 0; std::uint64_t entryPoint = executableModule->entryPoint; + if (orbis::g_context.sdkVersion == 0 && mainThread->tproc->processParam) { + auto processParam = + reinterpret_cast(mainThread->tproc->processParam); + + auto sdkVersion = processParam // + + sizeof(uint64_t) // size + + sizeof(uint32_t) // magic + + sizeof(uint32_t); // entryCount + + orbis::g_context.sdkVersion = *(uint32_t *)sdkVersion; + } + if (executableModule->type != rx::linker::kElfTypeExec) { auto libSceLibcInternal = rx::linker::loadModuleFile( "/system/common/lib/libSceLibcInternal.sprx", mainThread);