feat(libSceNpManager): implement sceNpRegisterGamePresenceCallback and sceNpSetContentRestriction #926

Closed
Adin-bima wants to merge 1 commit from upstream-pr/926 into main
Adin-bima commented 2026-10-06 17:22:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Adin-bima on 2026-10-06T17:22:06Z.


What

Implements the last two libSceNpManager stubs on its signed-out model:

  • sceNpRegisterGamePresenceCallback (returns void) accepts the callback. Presence never changes while signed out, so it is never called, as with the other registered NP callbacks here.
  • sceNpSetContentRestriction returns SCE_NP_ERROR_INVALID_ARGUMENT for a null restriction, else 0. shadPS4 also checks the size and fields of a 24-byte PS4 layout, while NpContentRestriction here is opaque; those checks are not applied and this is recorded in TechnicalDebt. prosper returns 0 for both calls.

Depends on #924: it adds core/libs/prx/libSceNpManager/CMakeLists.txt and GuestNpManager.cpp, which this extends. Only the last commit belongs to this PR.

Tested

Linux (GCC), guest_np_manager extended: callback registration with and without a callback, content restriction accepted, null rejected. Full ctest: 358/360 passed; agc_driver_lds_atomics64 and agc_driver_scalar_sop1 fail the same way on unmodified main on this machine (RTX 5070 Ti). Not tested with a title.

Checklist

  • Based on current main; no other open PR implements the same functions — #346 (opened earlier) implements the same functions; this is offered as a replacement if #346 is not continued
  • 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: #924
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4762284698 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/926). Originally posted by [Adin-bima](https://github.com/Adin-bima) on 2026-10-06T17:22:06Z. --- ### What Implements the last two libSceNpManager stubs on its signed-out model: - `sceNpRegisterGamePresenceCallback` (returns `void`) accepts the callback. Presence never changes while signed out, so it is never called, as with the other registered NP callbacks here. - `sceNpSetContentRestriction` returns `SCE_NP_ERROR_INVALID_ARGUMENT` for a null restriction, else 0. [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/np/np_manager.cpp) also checks the size and fields of a 24-byte PS4 layout, while `NpContentRestriction` here is opaque; those checks are not applied and this is recorded in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md). [prosper](https://github.com/mattias800/prosper/blob/main/prosper/src/hle/np/np.cpp) returns 0 for both calls. Depends on #924: it adds `core/libs/prx/libSceNpManager/CMakeLists.txt` and `GuestNpManager.cpp`, which this extends. Only the last commit belongs to this PR. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. --> Linux (GCC), `guest_np_manager` extended: callback registration with and without a callback, content restriction accepted, null rejected. Full `ctest`: 358/360 passed; `agc_driver_lds_atomics64` and `agc_driver_scalar_sop1` fail the same way on unmodified `main` on this machine (RTX 5070 Ti). Not tested with a title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [ ] Based on current `main`; no other open PR implements the same functions — #346 (opened earlier) implements the same functions; this is offered as a replacement if #346 is not continued - [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: #924 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-07 20:56:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T20:56:15Z.


Progress report (5895ea7 → 6204528)

📈 System libraries: 87.1% (+0.1%, +3 implemented functions)

✅ 3 implemented
Library Name
libSceNpManager sceNpGetNpId
libSceNpManager sceNpRegisterGamePresenceCallback
libSceNpManager sceNpSetContentRestriction
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6046691885 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/926#issuecomment-6046691885). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T20:56:15Z. --- <!-- progress-report --> ### Progress report (5895ea7 → 6204528) 📈 **System libraries**: 87.1% (+0.1%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | libSceNpManager | `sceNpGetNpId` | | libSceNpManager | `sceNpRegisterGamePresenceCallback` | | libSceNpManager | `sceNpSetContentRestriction` | </details>
adriadam10 commented 2026-10-07 20:57:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T20:57:36Z.

Review: CHANGES_REQUESTED


Build and ctest pass (405/405, merged onto current main), and guest_np_manager fails without the Export.cpp change. sceNpRegisterGamePresenceCallback matches KytyPS5, shadPS4 and prosper. One issue with sceNpSetContentRestriction:

  • The layout is not unknown. KytyPS5 (a PS5 reference, src/libs/network.cpp NpContentRestriction) has the same 24-byte struct as shadPS4: size_t size; int8_t default_age_restriction; char padding[3]; int32_t age_restriction_count; const NpAgeRestriction* age_restriction;. Both reject a wrong size: shadPS4 returns SCE_NP_ERROR_INVALID_SIZE (0x80550011, same value in KytyPS5 and fpPS4), and KytyPS5 aborts. As written, Export.cpp:150 returns 0 for any non-null pointer, so a garbage or wrong-size restriction succeeds where it should fail (CONTRIBUTING: exact or throw). Suggested direction: replace the opaque[128] placeholder in SceTypes.hpp:1248 with that layout and apply shadPS4's checks (size, default_age_restriction < 0, age_restriction_count > 0x100, null list with a non-zero count). Pin each one in the test, and change the TechnicalDebt line to say which references the checks come from (prosper only logs and returns 0).
  • core/libs/tests/GuestNpManager.cpp conflicts with #1241 (both append to the same spot). Whichever lands second needs a rebase.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5448270784 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/926#pullrequestreview-5448270784). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-07T20:57:36Z. **Review:** CHANGES_REQUESTED --- Build and ctest pass (405/405, merged onto current `main`), and `guest_np_manager` fails without the Export.cpp change. `sceNpRegisterGamePresenceCallback` matches KytyPS5, shadPS4 and prosper. One issue with `sceNpSetContentRestriction`: - The layout is not unknown. KytyPS5 (a PS5 reference, `src/libs/network.cpp` `NpContentRestriction`) has the same 24-byte struct as shadPS4: `size_t size; int8_t default_age_restriction; char padding[3]; int32_t age_restriction_count; const NpAgeRestriction* age_restriction;`. Both reject a wrong `size`: shadPS4 returns `SCE_NP_ERROR_INVALID_SIZE` (0x80550011, same value in KytyPS5 and fpPS4), and KytyPS5 aborts. As written, `Export.cpp:150` returns 0 for any non-null pointer, so a garbage or wrong-size restriction succeeds where it should fail (CONTRIBUTING: exact or throw). Suggested direction: replace the `opaque[128]` placeholder in `SceTypes.hpp:1248` with that layout and apply shadPS4's checks (size, `default_age_restriction < 0`, `age_restriction_count > 0x100`, null list with a non-zero count). Pin each one in the test, and change the TechnicalDebt line to say which references the checks come from (prosper only logs and returns 0). - `core/libs/tests/GuestNpManager.cpp` conflicts with #1241 (both append to the same spot). Whichever lands second needs a rebase.
popcoder565 commented 2026-10-09 19:42:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:12Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 6204528c, merged onto main 8b393b6e in one build with 31 other PRs that had no Windows run.

  • This PR's tests pass: guest_np_manager.
  • Full ctest in that build: 520 of 521. The one failure is guest_offline_imports, broken by #2359 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088014702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/926#issuecomment-6088014702). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:42:12Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `6204528c`, merged onto `main` 8b393b6e in one build with 31 other PRs that had no Windows run. - This PR's tests pass: `guest_np_manager`. - Full ctest in that build: 520 of 521. The one failure is `guest_offline_imports`, broken by #2359 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
oneandonlydean commented 2026-10-11 01:07:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T01:07:35Z.


Closing for now: the points from 2026-10-07 are still open. If you pick it back up, please comment here and it can be reopened.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104047277 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/926#issuecomment-6104047277). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T01:07:35Z. --- Closing for now: the points from 2026-10-07 are still open. If you pick it back up, please comment here and it can be reopened.

Pull request closed

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!926
No description provided.