From 28ad61347c79ff84df68b60a6813e6ebdbb1aedd Mon Sep 17 00:00:00 2001 From: fogydes Date: Mon, 2 Nov 2026 14:57:14 +0530 Subject: [PATCH] fix(libSceVdecSavc): ignore unwritable version pointers in sceSdecGetVersionSw --- core/libs/prx/libSceVdecSavc/Export.cpp | 7 ++++++- core/libs/tests/GuestSdecVersion.cpp | 1 + docs/dev/debt/libSceVdecSavc.md | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/libs/prx/libSceVdecSavc/Export.cpp b/core/libs/prx/libSceVdecSavc/Export.cpp index e588d21cfd..b8d00a795b 100644 --- a/core/libs/prx/libSceVdecSavc/Export.cpp +++ b/core/libs/prx/libSceVdecSavc/Export.cpp @@ -3,6 +3,7 @@ #include #include "SceTypes.hpp" #include "prx/libc/include/General.hpp" +#include extern "C" { @@ -17,7 +18,11 @@ int APS5_VABI sceSdecDestroySw() { } void APS5_VABI sceSdecGetVersionSw(std::uint32_t* version) { - if (version != nullptr) *version = 0u; + if (version == nullptr) return; + const std::uint32_t value = 0u; + const auto preserved = errno; + GuestCopyOut_nid_no_patch(version, &value, sizeof(value)); + errno = preserved; } int APS5_VABI sceSdecQueryMemorySw() { diff --git a/core/libs/tests/GuestSdecVersion.cpp b/core/libs/tests/GuestSdecVersion.cpp index caa541ff28..ac6244d6c6 100644 --- a/core/libs/tests/GuestSdecVersion.cpp +++ b/core/libs/tests/GuestSdecVersion.cpp @@ -38,6 +38,7 @@ void CheckVersion(GetVersion getVersion, std::uint32_t expected, const char* nam int main() { CheckVersion(sceSdecGetVersionSw, 0u, "sceSdecGetVersionSw"); + sceSdecGetVersionSw(reinterpret_cast(0x10)); CheckVersion(sceSdecGetVersionSw2, 0x13590001u, "sceSdecGetVersionSw2"); CheckVersion(sceSdecGetVersionSwHevc, 0x13590001u, "sceSdecGetVersionSwHevc"); std::puts("sdec version tests passed"); diff --git a/docs/dev/debt/libSceVdecSavc.md b/docs/dev/debt/libSceVdecSavc.md index a374f9ca1b..a25a217c34 100644 --- a/docs/dev/debt/libSceVdecSavc.md +++ b/docs/dev/debt/libSceVdecSavc.md @@ -3,4 +3,4 @@ ### Unknown function info - [sceSdecCreateSw, sceSdecDestroySw and sceSdecQueryMemorySw](../../../core/libs/prx/libSceVdecSavc/Export.cpp) (libSceVdecSavc) - names and NIDs are present in the [PS5 3.20 export inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceVdecSavc.c), but no credible prototypes were found. The declarations have no parameters solely to resolve known imports; this is not an ABI claim and callers must not call them until signatures are verified -- [sceSdecGetVersionSw](../../../core/libs/prx/libSceVdecSavc/Export.cpp) (libSceVdecSavc) - the prototype and behaviour follow firmware 13.42's libSceVdecSavc.sprx, read from disassembly and run under an emulator, not measured on a console: it takes a `uint32_t*`, writes 0 there unless the pointer is null, and returns nothing +- [sceSdecGetVersionSw](../../../core/libs/prx/libSceVdecSavc/Export.cpp) (libSceVdecSavc) - the prototype and behaviour follow firmware 13.42's libSceVdecSavc.sprx, read from disassembly and run under an emulator, not measured on a console: it takes a `uint32_t*`, writes 0 there unless the pointer is null, and returns nothing; an unwritable version pointer is ignored defensively, as console behavior on unmapped or read-only memory is not measured