fix(libSceVideoRecordingP): answer parameter checks and calls without a recorder as a PS5 does #11478

Merged
frankea merged 2 commits from upstream-pr/11478 into main 2026-11-02 10:28:27 +00:00
frankea commented 2026-10-26 16:27:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-26T16:27:00Z.


What

NHL 26 (PPSA26785) imports sceVideoRecordingOpen, Close, QueryMemSize, Start, Stop, GetStatus, GetInfo and SetInfo. The first five threw on every call. They now answer as a PS5 does before a recorder exists, which is the only state this library has:

  • sceVideoRecordingStart, Stop and Close return 0x80A80006 (no recorder open), matching GetStatus's 0 and GetInfo's 0x80A80006 already on main.
  • sceVideoRecordingQueryMemSize checks the parameter block as the console does: 0x80A80003 for a null block, a size field below 16, a duration outside 1 to 3600 seconds, a mode or option above 1, or an unknown format; 0x80A80008 for option 1 without a format; 0x1000 for a block with neither option nor format, including a block whose size field ends before them. A block with a video format (1, 2, 0x10, 0x11, 0x28, 0x40 or 0x41) still throws: its heap size comes from the recorder's MP4 index sizing, which is not implemented.
  • sceVideoRecordingOpen returns 0x80A80003 for a null path, block or heap and for a negative heap size, QueryMemSize's error for a block it refuses, and 0x80A80003 for a block that needs 0x1000 bytes with a smaller heap. Anything it would accept throws, since there is no recording session.
  • VideoRecordingParam had the thread priority at 8 and the duration at 12. The console reads the duration at 8, the mode at 12, an affinity mask at 16, the thread priority at 24, two fields at 28 and 32 that must be 0 or 1 (output mode and option, as VideoRecordingParam2 names them) and the format at 36. The struct now follows that layout, 64 bytes as NHL 26 fills it. VideoRecordingParam2 and Open2 are unchanged (13.40's module does not export Open2).

Measurement: PS5 on firmware 13.40, inside Gran Turismo 7 (PPSA01317). PS5 titles bind these imports to libSceVideoRecording.native.sprx. A payload attached to the game with ptrace called that module's exports with every buffer filled with 0xcc. No call created a recorder: every Open below fails before its session code.

GetStatus() -> 0; Start(), Stop(), Close(0), Close(1) -> 0x80a80006 (also after the failed opens below)
QueryMemSize(NULL) -> 0x80a80003
QueryMemSize({size 0x40, duration 3600, mode 0, affinity 0x1fff, priority 700, +28 0, option 1, format F})
  F = 1, 2, 0x10, 0x11, 0x28 -> 0x11ffef0;  F = 0x40, 0x41 -> 0x20bff06;  F = 0 -> 0x80a80008
  F = 3..0xf, 0x12..0x27, 0x29..0x3f, 0x42..0x44 -> 0x80a80003
  size field 0, 8, 0xf -> 0x80a80003;  0x10..0x20 -> 0x1000;  0x21, 0x24 -> 0x80a80008;  0x25 and up -> 0x11ffef0
  duration 0, 3601, 7200, 0xffffffff -> 0x80a80003;  1 -> 0xc84942, 60 -> 0xc9b954, 3599 -> 0x11ff8b2
  mode 1 -> 0x105ff38;  mode 2, 3 -> 0x80a80003
  option 0 -> 0x11ffef0;  option 0 with format 0 -> 0x1000;  option 2, 3 (with format 1 or 0) -> 0x80a80003
  affinity 0, 1, 0xff, 0x1fff, 0x2000, all ones; priority 0, 0xff, 0x100, 0x2ff, 0x300; +28 0..3; +40, +44 0, 1, 2, 0xffffffff -> no change
Open(path, block, heap, size): NULL path, NULL block, NULL heap, size -1, size 0, QueryMemSize - 1 -> 0x80a80003;
  a block QueryMemSize refuses (duration 0) with size 0x7fffffff -> 0x80a80003; the heap is not written
GetInfo(0xa001, 0xa002, 0xa003, 0xa005, 0xa00a, 0xa00b, 0xa00c) -> 0x80a80006; other ids -> 0x80a80003 (as on main)

Read in the 13.40 module (decrypted from the game's process; not shared) and not measured: Open compares the heap size with QueryMemSize's result before it checks the affinity mask, the thread priority (0x100 to 0x2ff) and the field at 28. Those checks are left out, because anything that passes the heap check throws here anyway.

How NHL 26 uses it, from its own executable: it fills the 64-byte block above for 1080p (format 1 at 60 fps, 0x11 at 30 fps) or 720p at 30 fps (0x10) with 48 kHz audio. It gives up quietly when QueryMemSize fails, and when Open fails it marks the recorder as used and never retries. Its stop routine then calls GetStatus, Stop and Close and treats a negative result as "nothing to save". With this PR NHL's block still throws in QueryMemSize, and no AnyPS5 run of NHL 26 has reached these calls so far.

Tested

Windows 11 (build 26200), MinGW GCC (WinLibs 15.2) Release build with BUILD_TESTING=ON, each test run three times (ctest --repeat until-fail:3).

  • guest_video_recording_tests now checks the measured contract: no-recorder answers before and after failed opens; every QueryMemSize case above except the accepted formats (formats 3 to 0x44 refused, size fields 0 to 0x24, durations outside 1 to 3600, modes and options above 1, fields the size does not depend on); every Open refusal with the heap left untouched. @oneandonlydean's 43debd5f3 removed the checks that expected valid QueryMemSize and Open calls to throw.
  • guest_video_recording and guest_offline_imports (which also loads libSceVideoRecordingP):
    • This PR (a344e526e on main 570089a80): 2/2.
    • Control: main 570089a80 with this PR's struct, its static asserts and its tests: guest_video_recording fails (sceVideoRecordingStart not implemented), guest_offline_imports passes.
    • main 570089a80: 2/2.
  • Linux: @jotitadev ran a344e526e merged onto main abed03546 on Ubuntu 26.04 with GCC 15.2 (review above): guest_video_recording passes 3 of 3, and the same control fails with sceVideoRecordingStart not implemented.
  • tools/check_conventions.py --base origin/main passes.

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
  • 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 known (PPSA26785 imports these functions but has not reached them under AnyPS5)
  • GPUs tested: n/a (no GPU code)
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5020945003 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11478). Originally posted by [frankea](https://github.com/frankea) on 2026-10-26T16:27:00Z. --- ### What NHL 26 (PPSA26785) imports `sceVideoRecordingOpen`, `Close`, `QueryMemSize`, `Start`, `Stop`, `GetStatus`, `GetInfo` and `SetInfo`. The first five threw on every call. They now answer as a PS5 does before a recorder exists, which is the only state this library has: - `sceVideoRecordingStart`, `Stop` and `Close` return 0x80A80006 (no recorder open), matching `GetStatus`'s 0 and `GetInfo`'s 0x80A80006 already on `main`. - `sceVideoRecordingQueryMemSize` checks the parameter block as the console does: 0x80A80003 for a null block, a size field below 16, a duration outside 1 to 3600 seconds, a mode or option above 1, or an unknown format; 0x80A80008 for option 1 without a format; 0x1000 for a block with neither option nor format, including a block whose size field ends before them. A block with a video format (1, 2, 0x10, 0x11, 0x28, 0x40 or 0x41) still throws: its heap size comes from the recorder's MP4 index sizing, which is not implemented. - `sceVideoRecordingOpen` returns 0x80A80003 for a null path, block or heap and for a negative heap size, `QueryMemSize`'s error for a block it refuses, and 0x80A80003 for a block that needs 0x1000 bytes with a smaller heap. Anything it would accept throws, since there is no recording session. - `VideoRecordingParam` had the thread priority at 8 and the duration at 12. The console reads the duration at 8, the mode at 12, an affinity mask at 16, the thread priority at 24, two fields at 28 and 32 that must be 0 or 1 (output mode and option, as `VideoRecordingParam2` names them) and the format at 36. The struct now follows that layout, 64 bytes as NHL 26 fills it. `VideoRecordingParam2` and `Open2` are unchanged (13.40's module does not export `Open2`). Measurement: PS5 on firmware 13.40, inside Gran Turismo 7 (PPSA01317). PS5 titles bind these imports to `libSceVideoRecording.native.sprx`. A payload attached to the game with ptrace called that module's exports with every buffer filled with 0xcc. No call created a recorder: every `Open` below fails before its session code. ``` GetStatus() -> 0; Start(), Stop(), Close(0), Close(1) -> 0x80a80006 (also after the failed opens below) QueryMemSize(NULL) -> 0x80a80003 QueryMemSize({size 0x40, duration 3600, mode 0, affinity 0x1fff, priority 700, +28 0, option 1, format F}) F = 1, 2, 0x10, 0x11, 0x28 -> 0x11ffef0; F = 0x40, 0x41 -> 0x20bff06; F = 0 -> 0x80a80008 F = 3..0xf, 0x12..0x27, 0x29..0x3f, 0x42..0x44 -> 0x80a80003 size field 0, 8, 0xf -> 0x80a80003; 0x10..0x20 -> 0x1000; 0x21, 0x24 -> 0x80a80008; 0x25 and up -> 0x11ffef0 duration 0, 3601, 7200, 0xffffffff -> 0x80a80003; 1 -> 0xc84942, 60 -> 0xc9b954, 3599 -> 0x11ff8b2 mode 1 -> 0x105ff38; mode 2, 3 -> 0x80a80003 option 0 -> 0x11ffef0; option 0 with format 0 -> 0x1000; option 2, 3 (with format 1 or 0) -> 0x80a80003 affinity 0, 1, 0xff, 0x1fff, 0x2000, all ones; priority 0, 0xff, 0x100, 0x2ff, 0x300; +28 0..3; +40, +44 0, 1, 2, 0xffffffff -> no change Open(path, block, heap, size): NULL path, NULL block, NULL heap, size -1, size 0, QueryMemSize - 1 -> 0x80a80003; a block QueryMemSize refuses (duration 0) with size 0x7fffffff -> 0x80a80003; the heap is not written GetInfo(0xa001, 0xa002, 0xa003, 0xa005, 0xa00a, 0xa00b, 0xa00c) -> 0x80a80006; other ids -> 0x80a80003 (as on main) ``` Read in the 13.40 module (decrypted from the game's process; not shared) and not measured: `Open` compares the heap size with `QueryMemSize`'s result before it checks the affinity mask, the thread priority (0x100 to 0x2ff) and the field at 28. Those checks are left out, because anything that passes the heap check throws here anyway. How NHL 26 uses it, from its own executable: it fills the 64-byte block above for 1080p (format 1 at 60 fps, 0x11 at 30 fps) or 720p at 30 fps (0x10) with 48 kHz audio. It gives up quietly when `QueryMemSize` fails, and when `Open` fails it marks the recorder as used and never retries. Its stop routine then calls `GetStatus`, `Stop` and `Close` and treats a negative result as "nothing to save". With this PR NHL's block still throws in `QueryMemSize`, and no AnyPS5 run of NHL 26 has reached these calls so far. ### Tested Windows 11 (build 26200), MinGW GCC (WinLibs 15.2) Release build with `BUILD_TESTING=ON`, each test run three times (`ctest --repeat until-fail:3`). - `guest_video_recording_tests` now checks the measured contract: no-recorder answers before and after failed opens; every `QueryMemSize` case above except the accepted formats (formats 3 to 0x44 refused, size fields 0 to 0x24, durations outside 1 to 3600, modes and options above 1, fields the size does not depend on); every `Open` refusal with the heap left untouched. @oneandonlydean's 43debd5f3 removed the checks that expected valid `QueryMemSize` and `Open` calls to throw. - `guest_video_recording` and `guest_offline_imports` (which also loads libSceVideoRecordingP): - This PR (a344e526e on `main` 570089a80): 2/2. - Control: `main` 570089a80 with this PR's struct, its static asserts and its tests: `guest_video_recording` fails (`sceVideoRecordingStart not implemented`), `guest_offline_imports` passes. - `main` 570089a80: 2/2. - Linux: @jotitadev ran a344e526e merged onto `main` abed03546 on Ubuntu 26.04 with GCC 15.2 (review above): `guest_video_recording` passes 3 of 3, and the same control fails with `sceVideoRecordingStart not implemented`. - `tools/check_conventions.py --base origin/main` passes. ### Checklist - [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) - [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 known (PPSA26785 imports these functions but has not reached them under AnyPS5) - [x] GPUs tested: n/a (no GPU code) - [x] AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-26 16:33:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T16:33:42Z.

Review: APPROVED


Reviewed exact head a344e526ecc71c5a1fbf4bbca3a2416d834bd37a against current main 427dd36164bbc1e7960c85c8e84dca75017c88f8. The four-file diff is focused: the measured 64-byte parameter layout is asserted, CheckParam checks the required prefix before reading duration/mode and applies the reported size gates, and Open returns the measured refusal codes before throwing on paths that would require a recording session. The tests cover the format, duration, mode, option and size matrix, no-recorder calls, and that rejected/open-failing paths leave the heap untouched. The current-main merge preview is clean, git diff --check passes, and hosted eligibility, conventions, intake, labels and report checks pass. The product and relinker jobs were skipped by path policy; I did not independently run the Windows suite or reproduce the PS5 measurements, so the reported Windows results and firmware 13.40 measurements are author-provided. I found no actionable blocker. AI-assisted review: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5655515048 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11478#pullrequestreview-5655515048). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T16:33:42Z. **Review:** APPROVED --- Reviewed exact head `a344e526ecc71c5a1fbf4bbca3a2416d834bd37a` against current `main` `427dd36164bbc1e7960c85c8e84dca75017c88f8`. The four-file diff is focused: the measured 64-byte parameter layout is asserted, `CheckParam` checks the required prefix before reading duration/mode and applies the reported size gates, and `Open` returns the measured refusal codes before throwing on paths that would require a recording session. The tests cover the format, duration, mode, option and size matrix, no-recorder calls, and that rejected/open-failing paths leave the heap untouched. The current-main merge preview is clean, `git diff --check` passes, and hosted eligibility, conventions, intake, labels and report checks pass. The product and relinker jobs were skipped by path policy; I did not independently run the Windows suite or reproduce the PS5 measurements, so the reported Windows results and firmware 13.40 measurements are author-provided. I found no actionable blocker. AI-assisted review: yes.
jotitadev commented 2026-10-27 02:42:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T02:42:23Z.

Review: COMMENTED


First Linux run, since the description says it was not run on Linux.

Bare-metal Linux x86_64: i7-8700, Ubuntu 26.04, kernel 7.0, glibc 2.43, GCC 15.2, Release, BUILD_TESTING=ON, full build. Head a344e526e merged --no-commit onto main abed03546 (clean).

  • guest_video_recording: passes 3 of 3. guest_video_recording and guest_offline_imports: 2 of 2.
  • Control, the same shape as yours: main's Export.cpp with this PR's Api.hpp struct, its VideoRecordingParam size/offset static asserts and the new tests (full rebuild). guest_video_recording aborts 3 of 3 with what(): sceVideoRecordingStart not implemented. Note that reverting Export.cpp alone does not build, because main's static asserts reject the new 64-byte struct.

This was run on a344e526e, before the expected-throw checks @oneandonlydean asked to remove. They pass here as well. I have not checked which of the remaining checks is the first to hit the control's throw.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661630204 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11478#pullrequestreview-5661630204). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T02:42:23Z. **Review:** COMMENTED --- First Linux run, since the description says it was not run on Linux. Bare-metal Linux x86_64: i7-8700, Ubuntu 26.04, kernel 7.0, glibc 2.43, GCC 15.2, Release, `BUILD_TESTING=ON`, full build. Head `a344e526e` merged `--no-commit` onto `main` `abed03546` (clean). - `guest_video_recording`: passes 3 of 3. `guest_video_recording` and `guest_offline_imports`: 2 of 2. - Control, the same shape as yours: `main`'s `Export.cpp` with this PR's `Api.hpp` struct, its `VideoRecordingParam` size/offset static asserts and the new tests (full rebuild). `guest_video_recording` aborts 3 of 3 with `what(): sceVideoRecordingStart not implemented`. Note that reverting `Export.cpp` alone does not build, because `main`'s static asserts reject the new 64-byte struct. This was run on `a344e526e`, before the expected-throw checks @oneandonlydean asked to remove. They pass here as well. I have not checked which of the remaining checks is the first to hit the control's throw. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!11478
No description provided.