refactor(libc): read the title's compiled SDK version through one helper #26296

Merged
LeandroLP23 merged 1 commit from upstream-pr/26296 into main 2026-11-23 18:02:20 +00:00
LeandroLP23 commented 2026-11-23 16:34:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-11-23T16:34:31Z.


What

First step of #26276, as agreed there. Sixteen libraries each define their own function that returns the compiled SDK version of the running title, the 32-bit field at offset 0x10 of the process parameters.

  • libc/include/ApplicationHeap.hpp, which declares ApplicationProcessParameters_nid_no_patch, gets one inline std::uint32_t ApplicationCompiledSdkVersion(). It keeps the parameters pointer in a static, as sceKernelGetCompiledSdkVersion does, so a caller that polls it does not search the image each time.
  • Nine direct copies are removed, in ContentExport, ConvertKeycode, GnmDriverCompat1, Hmd, Move, NpCommerce, NpWebApi, ScreenShot and VrTracker2. Their callers call the helper.
  • VdecSavc2 and VideoRecordingP called sceKernelGetCompiledSdkVersion and returned 0xffffffff on a failure that cannot happen with a local output; VdecSavc2 also saved errno around the call. They call the helper too, and the failure branches go. Http2 did the same, but #25731 conflicts with it, so it is left for later.
  • AppContent (#18954, #24634), GnmDriverForNeoMode (#17711), Hmd2 (#19525) and Http (#24528) are left for later too, because those pull requests change the same files.

#24915 also changes the includes of ApplicationHeap.hpp and cannot be compared automatically because it conflicts with main. git merge-tree of its head with this branch merges that file cleanly.

33 lines added and 102 removed.

No change in behaviour.

Tested

Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release. ctest -R 'guest_content_export|convert_keycode|gnm_driver_compat1|guest_hmd($|_)|^guest_move$|np_commerce|guest_np_web_api|guest_screenshot|vr_tracker2|video_recording|sdec|application_?heap|process_?param', with its 27 build outputs from tools/select_tests.py targets: 41 of 41 on main efc6f9c3ba and 41 of 41 with this change applied to it. tools/check_conventions.py passes. tools/pr_overlap.py --branch finds no overlap with the 2583 open pull requests apart from #24915, which it cannot compare (above).

Not run: Linux and macOS.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5457067659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26296). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-11-23T16:34:31Z. --- ### What First step of #26276, as agreed there. Sixteen libraries each define their own function that returns the compiled SDK version of the running title, the 32-bit field at offset `0x10` of the process parameters. - `libc/include/ApplicationHeap.hpp`, which declares `ApplicationProcessParameters_nid_no_patch`, gets one `inline std::uint32_t ApplicationCompiledSdkVersion()`. It keeps the parameters pointer in a `static`, as `sceKernelGetCompiledSdkVersion` does, so a caller that polls it does not search the image each time. - Nine direct copies are removed, in ContentExport, ConvertKeycode, GnmDriverCompat1, Hmd, Move, NpCommerce, NpWebApi, ScreenShot and VrTracker2. Their callers call the helper. - VdecSavc2 and VideoRecordingP called `sceKernelGetCompiledSdkVersion` and returned `0xffffffff` on a failure that cannot happen with a local output; VdecSavc2 also saved `errno` around the call. They call the helper too, and the failure branches go. `Http2` did the same, but #25731 conflicts with it, so it is left for later. - AppContent (#18954, #24634), GnmDriverForNeoMode (#17711), Hmd2 (#19525) and Http (#24528) are left for later too, because those pull requests change the same files. #24915 also changes the includes of `ApplicationHeap.hpp` and cannot be compared automatically because it conflicts with `main`. `git merge-tree` of its head with this branch merges that file cleanly. 33 lines added and 102 removed. No change in behaviour. ### Tested Windows 11 (10.0.26300), WinLibs GCC 15.2.0 r7, Release. `ctest -R 'guest_content_export|convert_keycode|gnm_driver_compat1|guest_hmd($|_)|^guest_move$|np_commerce|guest_np_web_api|guest_screenshot|vr_tracker2|video_recording|sdec|application_?heap|process_?param'`, with its 27 build outputs from `tools/select_tests.py targets`: 41 of 41 on `main` `efc6f9c3ba` and 41 of 41 with this change applied to it. `tools/check_conventions.py` passes. `tools/pr_overlap.py --branch` finds no overlap with the 2583 open pull requests apart from #24915, which it cannot compare (above). Not run: Linux and macOS. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
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!26296
No description provided.