[orbis-kernel] store sdk version to the context

This commit is contained in:
DH 2023-11-10 20:53:41 +03:00
parent a847e739fc
commit dc44b619b2
3 changed files with 15 additions and 11 deletions

View file

@ -159,6 +159,7 @@ public:
Ref<RcBase> dmemDevice;
Ref<RcBase> blockpoolDevice;
AudioOut *audioOut = nullptr;
uint sdkVersion{};
private:
mutable pthread_mutex_t m_heap_mtx;

View file

@ -372,17 +372,8 @@ orbis::SysResult orbis::sys___sysctl(Thread *thread, ptr<sint> name,
return ErrorCode::INVAL;
}
auto processParam =
reinterpret_cast<std::byte *>(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<uint32_t *>(sdkVersion));
*(uint32_t *)old = *reinterpret_cast<uint32_t *>(sdkVersion);
std::printf("Reporting SDK version %x\n", g_context.sdkVersion);
*(uint32_t *)old = g_context.sdkVersion;
return {};
}

View file

@ -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<std::byte *>(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);