feat(libSceNpManager): retain the game presence callback and validate content restrictions offline #6023
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6023"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-14T19:22:17Z.
What
Implements
sceNpSetContentRestriction(NIDA2CQ3kgSopQ) andsceNpRegisterGamePresenceCallback(NIDuFJpaKNBAj4) on the existing signed-out libSceNpManager model, and replaces the opaque 128-byteNpContentRestrictionwith its 0x18-byte layout.Source of the behaviour. No console measurement is involved.
OrbisNpAgeRestriction/OrbisNpContentRestrictionatf47bbd5np_manager.h L56-L68:u64 size; s8 default_age_restriction; u8 padding[3]; s32 age_restriction_count; const OrbisNpAgeRestriction* age_restriction;with an 8-byte age entry (4-byte country code,s8age, 3 padding bytes). KytyPS5, a PS5 emulator, has the same two structures (network.cpp L3799-L3811); this was pointed out in the review of #926.sceNpSetContentRestriction: shadPS4 np_manager.cpp L748-L763, in this order: null restrictionORBIS_NP_ERROR_INVALID_ARGUMENT;size != sizeof(OrbisNpContentRestriction)ORBIS_NP_ERROR_INVALID_SIZE; negative default age or more than0x100age restrictionsINVALID_ARGUMENT; a positive count with a null arrayINVALID_ARGUMENT; otherwiseORBIS_OK. The values are0x80550003and0x80550011(np_error.h L11 and L26);0x80550003is theSCE_NP_ERROR_INVALID_ARGUMENTthis file already uses. KytyPS5 also rejects a null restriction and a wrongsize(network.cpp L3960-L3964), as unimplemented paths.sceNpRegisterGamePresenceCallback(callback, userdata)returns nothing and stores the callback and user data, replacing any earlier registration: shadPS4 np_manager.cpp L1121-L1126, where the callback isvoid (*)(const OrbisNpOnlineId* online_id, void* userdata)(L1070-L1071); KytyPS5 has the samevoid (void*, void*)signature (network.cpp L4007-L4009). No game presence event is delivered while the model stays signed out, as with the reachability callback merged in #1322.Changes:
core/libs/SceTypes.hpp:NpAgeRestrictionand the 0x18-byteNpContentRestriction, withstatic_asserts on both sizes.sceNpSetContentRestrictionis the only user of the type.core/libs/prx/libSceNpManager/Export.cpp:sceNpSetContentRestrictionapplies the checks above in shadPS4's order and returns 0 for a valid restriction, which nothing enforces while signed out.sceNpRegisterGamePresenceCallbackstores the callback and user data under a mutex of its own (shadPS4 stores them under a mutex it shares with the Plus event callbacks); nothing reads the stored pair until a signed-in NP model delivers presence events.SCE_NP_ERROR_INVALID_SIZEis added.core/libs/tests/GuestNpManager.cpp:guest_np_managercovers an empty restriction, two and 256 age entries (from a 256-entry array), 257 entries, a count with a null array, zero count with a null array, a negative count, a negative default age, a larger and a zerosize,sizechecked before the ages, and a null restriction. For the presence callback it registers a callback with shadPS4's(const NpOnlineId*, void*)signature that increments theintits user data points to, replaces it with a second user data, then clears it, and checks after each step that no counter has changed, so the callback is never called. The new helpers are in the file's anonymous namespace.docs/dev/debt/libSceNpManager.md: one entry per call under Functional, with the pinned shadPS4 lines and what is unverified, including that a negative age restriction count is accepted and that nothing reads the stored presence callback yet.What is unverified: the checks and error codes are from the PS4 library; a negative
age_restriction_countis accepted, as in shadPS4. The restriction is validated and dropped. No case throws.Progress: libSceNpManager 30/34 → 32/34; system libraries 3269/3679 (88.86%) → 3271/3679 (88.91%) by
tools/progress.pyon the branch basee27ff7cand on this branch.Tested
Head
46541633006bec172dc6efcd72b22c4f09d0a966, basee27ff7c545cb5ac669612567d853956ffa02ebe6.BUILD_TESTING=ON, AMD EPYC 7763 (GitHub Codespaces), tests run natively):guest_np_manager_testspasses in 5 of 5 runs, the test executable being run directly five times.core/libs/prx/libSceNpManager/Export.cppwith the base version:guest_np_manager_testsfails withsceNpSetContentRestriction not implemented. Restoring the PR source and rebuilding,guest_np_manager_testspasses in 5 of 5 runs again.mainat2b7e3ce69fd889deceb6b52ac1fbf13e7c0d1084, WinLibs MinGW-w64 GCC 15.2.0, Release,BUILD_TESTING=ON: 1212/1212 tests pass; the relinker (Linux, Windows, macOS), register-context and write-watch jobs of the same run also pass.git diff --checkpass. The Linux job of the Build workflow now targets the project's self-hosted runner, so it was not run on the fork; no title was run.Duplicate and overlap check
Checked the files of every open PR on 2026-10-14 and searched open, merged and closed PRs for both names. No open PR implements or names either function.
Open PRs sharing a file (pairwise
git merge-treeagainst each PR head):libSceNpManager/Export.cpp,GuestNpManager.cpp,sceNpGetUserIdByAccountId), rebased on 2026-10-15, now also adds an entry todocs/dev/debt/libSceNpManager.md; its hunks are apart from ours and it merges with this PR in either order.sceNpCheckCallback) and #6056 (two unknown NIDs) change other hunks ofExport.cpp,GuestNpManager.cppanddocs/dev/debt/libSceNpManager.md, and each merges with this PR in either order. #6044 movesGuestNpManager.cpptocore/libs/tests/services/; merging this branch into #6044's head gives no conflict, the test hunk following the move.SceTypes.hpp: no conflict.Earlier PRs on the same functions, all closed:
static_asserts,SCE_NP_ERROR_INVALID_SIZE, the same null, size, default age, count and null array checks, and the presence callback and user data stored under a mutex. It was closed automatically by the intake pause ("This is not a judgment of the quality of your changes").sceNpSetContentRestrictionorsceNpRegisterGamePresenceCallbackon main, and while the queue is this long we're holding PRs that don't name one"; the same comment said "the layout and checks are fine as they are". This PR does not name a title either (Unblocks is none), so that closing reason applies to it as well.INVALID_SIZEcheck, which this PR has. It was closed on 2026-10-11 because the review points from 2026-10-07 were still open.The overlapping work is @NahuelGenchi's: #2398 came first and #4531 followed with the same layout and checks. Both rejected a negative count, which shadPS4 accepts and this PR accepts. This PR's presence test registers a real callback with counters instead of an invalid pointer.
The branch is one commit based on
e27ff7c.Checklist
main(e27ff7c); no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T19:23:00Z.
Progress report (
19fc5a8→4654163)📈 System libraries: 88.75% (+0.06%, +2 implemented functions)
✅ 2 implemented
sceNpRegisterGamePresenceCallbacksceNpSetContentRestrictionImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:32Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceNpManager/Export.cppL141-143, L182-184Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/GuestNpManager.cppcore/libs/SceTypes.hppcore/libs/SceTypes.hppcore/libs/prx/libSceNpManager/Export.cppdocs/dev/debt/libSceNpManager.mdImported from boykopovar/AnyPS5. Originally posted by KernelPanicNT on 2026-10-18T15:07:00Z.
Closing this myself for now. Like #4531, which this resubmits, no title is known to reach
sceNpRegisterGamePresenceCallbackorsceNpSetContentRestrictionon currentmain, and the behaviour here rests on PS4 sources only, so it falls under the hold asked for on #4531 and #5635.The closest consumer I found is Limbo (CUSA01664) in #6977, which implements
sceNpSetContentRestrictionas part of the PS4 bring-up. If that, or a PS5 title, stops on either call onmain, I'll reopen with the title ID and the log line.Pull request closed