refactor: one helper for the title's compiled SDK version (16 copies in 16 libraries) #26276

Closed
opened 2026-11-23 15:52:04 +00:00 by LeandroLP23 · 0 comments
LeandroLP23 commented 2026-11-23 15:52:04 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-23T15:52:04Z.


What

Sixteen libraries each define their own function that returns the compiled SDK version of the running title. They all read the same thing: the 32-bit field at offset 0x10 of the process parameters.

  • 13 copies read it directly: ApplicationProcessParameters_nid_no_patch() (declared in libc/include/ApplicationHeap.hpp), then memcpy from +0x10. They are in AppContent, ContentExport, ConvertKeycode, GnmDriverCompat1, GnmDriverForNeoMode, Hmd, Hmd2, Http, Move, NpCommerce, NpWebApi, ScreenShot and VrTracker2. Four of them keep the parameters pointer in a static, nine read it on each call, and the names differ (CompiledSdkVersion, compiledSdkVersion).
  • 3 copies call sceKernelGetCompiledSdkVersion, which reads the same field (libkernel/SysExports.cpp). They are in Http2, VdecSavc2 and VideoRecordingP. Each picks its own value for a failure that cannot happen with a local output: 0x99900000, or 0xffffffff (VdecSavc2 also saves errno around the call).

Proposal

Add one helper next to the declaration it uses, in libc/include/ApplicationHeap.hpp:

inline std::uint32_t ApplicationCompiledSdkVersion() {
    std::uint32_t version;
    std::memcpy(&version, static_cast<const std::byte*>(ApplicationProcessParameters_nid_no_patch()) + 0x10, sizeof(version));
    return version;
}

The 13 direct readers would call it instead of their copy, with the same result. Only the libraries whose files no open pull request conflicts with would change in the first pull request; the others would follow as those land. #26274 does the same for the guest-errno failure return.

Questions

  1. Is ApplicationHeap.hpp the right home, or would you rather have it in libkernel (or have the callers use sceKernelGetCompiledSdkVersion directly)?
  2. Should the three sceKernelGetCompiledSdkVersion callers move to the helper too? Their failure values would go, since the read cannot fail there. Or should they stay as they are?

If this isn't wanted, say so and I'll leave the copies alone.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6563155440 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/26276). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-23T15:52:04Z. --- ### What Sixteen libraries each define their own function that returns the compiled SDK version of the running title. They all read the same thing: the 32-bit field at offset `0x10` of the process parameters. - **13 copies** read it directly: `ApplicationProcessParameters_nid_no_patch()` (declared in `libc/include/ApplicationHeap.hpp`), then `memcpy` from `+0x10`. They are in AppContent, ContentExport, ConvertKeycode, GnmDriverCompat1, GnmDriverForNeoMode, Hmd, Hmd2, Http, Move, NpCommerce, NpWebApi, ScreenShot and VrTracker2. Four of them keep the parameters pointer in a `static`, nine read it on each call, and the names differ (`CompiledSdkVersion`, `compiledSdkVersion`). - **3 copies** call `sceKernelGetCompiledSdkVersion`, which reads the same field (`libkernel/SysExports.cpp`). They are in Http2, VdecSavc2 and VideoRecordingP. Each picks its own value for a failure that cannot happen with a local output: `0x99900000`, or `0xffffffff` (VdecSavc2 also saves `errno` around the call). ### Proposal Add one helper next to the declaration it uses, in `libc/include/ApplicationHeap.hpp`: ```cpp inline std::uint32_t ApplicationCompiledSdkVersion() { std::uint32_t version; std::memcpy(&version, static_cast<const std::byte*>(ApplicationProcessParameters_nid_no_patch()) + 0x10, sizeof(version)); return version; } ``` The 13 direct readers would call it instead of their copy, with the same result. Only the libraries whose files no open pull request conflicts with would change in the first pull request; the others would follow as those land. #26274 does the same for the guest-errno failure return. ### Questions 1. Is `ApplicationHeap.hpp` the right home, or would you rather have it in `libkernel` (or have the callers use `sceKernelGetCompiledSdkVersion` directly)? 2. Should the three `sceKernelGetCompiledSdkVersion` callers move to the helper too? Their failure values would go, since the read cannot fail there. Or should they stay as they are? If this isn't wanted, say so and I'll leave the copies alone. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#26276
No description provided.