fix(pad): return INVALID_HANDLE from scePadReadState for an unknown handle #890

Merged
alfalfa-star merged 1 commit from upstream-pr/890 into main 2026-10-06 21:15:01 +00:00
alfalfa-star commented 2026-10-06 13:10:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-06T13:10:43Z.


What

Return PAD_ERROR_INVALID_HANDLE (0x80920003) from scePadReadState for a handle that is not open, instead of throwing invalid argument.

PPSA14632 (LEGO Horizon Adventures, Unreal Engine) opens one pad with scePadOpen(0x10000000, 0, 0, NULL) (handle 1) and then calls scePadReadState (eboot 0x4593a8) for that pad and for a second pad slot it never opened, whose handle is still 0. The title skips only negative handles before the call and does not check the result. On main the second call throws. The other functions in libScePad already return PAD_ERROR_INVALID_HANDLE for an unknown handle, and shadPS4's scePadRead (which its scePadReadState calls) does the same. scePadRead passes the error on. A null data still throws.

Tested

  • Arch Linux, GCC 16.2, Release. guest_pad now checks handle 0 and an unopened handle with scePadReadState and scePadRead, and a read of the open handle; it fails on main. Full ctest: 359/359.
  • LEGO Horizon Adventures (PPSA14632) on Linux, together with #861, #722, #723, #732, #734, #889 and local stubs for its other missing imports: both reads return, and the title runs on until the shader recompiler rejects a compute shader (CFG shared merge splitting exceeded budget), which is unrelated.
  • Windows not built or tested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4759205303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/890). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-06T13:10:43Z. --- ### What Return `PAD_ERROR_INVALID_HANDLE` (0x80920003) from `scePadReadState` for a handle that is not open, instead of throwing `invalid argument`. PPSA14632 (LEGO Horizon Adventures, Unreal Engine) opens one pad with `scePadOpen(0x10000000, 0, 0, NULL)` (handle 1) and then calls `scePadReadState` (eboot 0x4593a8) for that pad and for a second pad slot it never opened, whose handle is still 0. The title skips only negative handles before the call and does not check the result. On `main` the second call throws. The other functions in `libScePad` already return `PAD_ERROR_INVALID_HANDLE` for an unknown handle, and shadPS4's `scePadRead` (which its `scePadReadState` calls) does the same. `scePadRead` passes the error on. A null `data` still throws. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. --> - Arch Linux, GCC 16.2, Release. `guest_pad` now checks handle 0 and an unopened handle with `scePadReadState` and `scePadRead`, and a read of the open handle; it fails on `main`. Full ctest: 359/359. - LEGO Horizon Adventures (PPSA14632) on Linux, together with #861, #722, #723, #732, #734, #889 and local stubs for its other missing imports: both reads return, and the title runs on until the shader recompiler rejects a compute shader (`CFG shared merge splitting exceeded budget`), which is unrelated. - Windows not built or tested. ### 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) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!890
No description provided.