Files
AnyPS5/core/libs/tests/GuestKernelSysSdkVersion.cpp
T
erickerxhalliandClaude Opus 5.5 581905d997 docs(libkernel_sys): record which SDK field sceKernelGetCompiledSdkVersion reads
The PS5 payload SDK declares the process parameters with a 32-bit PS4
SDK version at offset 0x10 and a 32-bit PS5 SDK version at 0x14, not
one 64-bit field. The debt entry now states that the export returns the
field at 0x10, as libSceHmd2 and shadPS4 read it, and that which field
the console returns is unmeasured. The test puts different values at
0x10 and 0x14 instead of one 64-bit value with its upper half set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WYjMwvLdPR8iX8EP8tQYWa
2026-10-22 04:20:28 +00:00

46 lines
1.6 KiB
C++

#include "ProcessParametersFixture.hpp"
#include "prx/libc/include/general/VabiMacros.hpp"
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
extern "C" int APS5_VABI sceKernelGetCompiledSdkVersion(std::int32_t* version);
namespace {
alignas(16) std::array<std::byte, 0x40> process{};
void Require(bool condition, const char* message) {
if (!condition) {
std::fprintf(stderr, "KERNEL SYS SDK VERSION: %s\n", message);
std::abort();
}
}
}
int main() {
const std::uint64_t size = process.size();
const std::uint32_t magic = 0x4942524f;
const std::uint32_t ps4SdkVersion = 0x07008001;
const std::uint32_t ps5SdkVersion = 0x0a008001;
std::memcpy(process.data(), &size, sizeof(size));
std::memcpy(process.data() + 8, &magic, sizeof(magic));
std::memcpy(process.data() + 0x10, &ps4SdkVersion, sizeof(ps4SdkVersion));
std::memcpy(process.data() + 0x14, &ps5SdkVersion, sizeof(ps5SdkVersion));
Require(ProcessParametersFixture::Install(process.data(), process.size()), "process parameters were not installed");
Require(sceKernelGetCompiledSdkVersion(nullptr) == static_cast<int>(0x80020016), "null output is not EINVAL");
std::array<std::int32_t, 2> output{-1, 0x5a5a5a5a};
Require(sceKernelGetCompiledSdkVersion(output.data()) == 0, "query failed");
Require(output[0] == 0x07008001, "version is not the 32-bit field at offset 0x10 of the process parameters");
Require(output[1] == 0x5a5a5a5a, "the query wrote past the version");
std::puts("KERNEL SYS SDK VERSION tests passed");
return 0;
}