From b68ca43166be4bcb985f442db465b3fcc7d5e4ab Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Mon, 14 Jul 2025 22:44:13 +0200 Subject: [PATCH] Implement sceKernelGetSystemSwVersion (#3243) * Implement sceKernelGetSystemSwVersion * Set the reported firmware version to that of the game executable --- src/core/libraries/kernel/kernel.cpp | 15 +++++++++++++++ src/core/libraries/kernel/kernel.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/core/libraries/kernel/kernel.cpp b/src/core/libraries/kernel/kernel.cpp index 61d2e2f2b..a4d3accac 100644 --- a/src/core/libraries/kernel/kernel.cpp +++ b/src/core/libraries/kernel/kernel.cpp @@ -6,6 +6,7 @@ #include "common/assert.h" #include "common/debug.h" +#include "common/elf_info.h" #include "common/logging/log.h" #include "common/polyfill_thread.h" #include "common/thread.h" @@ -243,6 +244,19 @@ s32 PS4_SYSV_ABI sceKernelSetGPO() { return ORBIS_OK; } +s32 PS4_SYSV_ABI sceKernelGetSystemSwVersion(SwVersionStruct* ret) { + if (ret == nullptr) { + return ORBIS_OK; // but why? + } + ASSERT(ret->struct_size == 40); + u32 fake_fw = Common::ElfInfo::Instance().RawFirmwareVer(); + ret->hex_representation = fake_fw; + std::snprintf(ret->text_representation, 28, "%2x.%03x.%03x", fake_fw >> 0x18, + fake_fw >> 0xc & 0xfff, fake_fw & 0xfff); // why %2x? + LOG_INFO(Lib_Kernel, "called, returned sw version: {}", ret->text_representation); + return ORBIS_OK; +} + void RegisterKernel(Core::Loader::SymbolsResolver* sym) { service_thread = std::jthread{KernelServiceThread}; @@ -258,6 +272,7 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) { Libraries::Kernel::RegisterDebug(sym); LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard); + LIB_FUNCTION("Mv1zUObHvXI", "libkernel", 1, "libkernel", 1, 1, sceKernelGetSystemSwVersion); LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", 1, 1, kernel_ioctl); LIB_FUNCTION("JGfTMBOdUJo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetFsSandboxRandomWord); LIB_FUNCTION("6xVpy0Fdq+I", "libkernel", 1, "libkernel", 1, 1, _sigprocmask); diff --git a/src/core/libraries/kernel/kernel.h b/src/core/libraries/kernel/kernel.h index 0529c06d5..018759e14 100644 --- a/src/core/libraries/kernel/kernel.h +++ b/src/core/libraries/kernel/kernel.h @@ -35,6 +35,12 @@ struct OrbisWrapperImpl { s32* PS4_SYSV_ABI __Error(); +struct SwVersionStruct { + u64 struct_size; + char text_representation[0x1c]; + u32 hex_representation; +}; + void RegisterKernel(Core::Loader::SymbolsResolver* sym); } // namespace Libraries::Kernel