feat(libSceNpUtility): model the lookup and word filter requests offline #9887

Merged
MarrasFederico merged 2 commits from upstream-pr/9887 into main 2026-10-23 12:15:08 +00:00
MarrasFederico commented 2026-10-22 20:42:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-22T20:42:52Z.


What

The 14 lookup and word filter exports of libSceNpUtility threw. They now follow shadPS4's np_utility.cpp offline, the way #9009 modelled libSceNpTus:

  • Title contexts and requests: lookup and word filter keep separate tables. A null NpId is INSUFFICIENT_ARGUMENT; more than 32 title contexts or 32 requests is TOO_MANY_OBJECTS; an unknown id is INVALID_ID; deleting a title context deletes its requests. Word filter ids start at 0x01000001 and 0x02000001, as in shadPS4's np_utility.h. sceNpWordFilterCreateAsyncRequest needs a parameter whose size field is 0x18.
  • The calls that would reach the server: sceNpLookupNpId checks the option before the null arguments, the censor and sanitize calls check the null arguments, the option and the 0x400-byte comment limit, all in shadPS4's order. A request can be used once (INVALID_TYPE after), and an aborted one answers ABORTED. Then they finish with SCE_NP_ERROR_SIGNED_OUT: returned by a synchronous request, reported by sceNpWordFilterPollAsync for an asynchronous one. No NpId or sanitized comment is written.
  • Polling and aborting: sceNpWordFilterPollAsync refuses a null result (INVALID_ARGUMENT) and a synchronous request (INVALID_ID); sceNpWordFilterAbortRequest finishes an unstarted request with ABORTED and leaves a finished one's result.

shadPS4's own word filter accepts every comment as a stand-in for the server, so only its argument checks are used here. Nothing is measured on a PS5; the new debt file says so. sceNpBandwidthTestInitStart keeps throwing.

#8472 declares other libSceNpUtility exports between the bandwidth test calls and these, and creates the same debt file with an Unknown function info section; the Export.cpp hunks do not touch each other, and whichever lands second keeps both debt sections.

Tested

Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with BUILD_TESTING=ON. Windows was not compiled. No title was run.

  • New guest_np_utility_offline (core/libs/tests/GuestNpUtilityOffline.cpp): both id bases and the 32-context and 32-request limits, every argument check and the check order in sceNpLookupNpId and both comment calls, the 0x400 and 0x401-byte comments, single use, SIGNED_OUT from synchronous requests and through sceNpWordFilterPollAsync, polling a synchronous request, abort before and after the request finished, deleting a title context with its requests, and no NpId or comment written.
  • It aborts on main (sceNpLookupCreateTitleCtx not implemented) and passes with this change. 15 mutations of the new code (each check and its order, single use, both offline results, the limits, the async parameter size, the id base, the abort rule, polling a synchronous request, deleting a context's requests) each fail it.
  • tools/check_conventions.py --base upstream/main passes; tools/pr_overlap.py lists only #8472, described above.

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
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4973850738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9887). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-10-22T20:42:52Z. --- ### What The 14 lookup and word filter exports of libSceNpUtility threw. They now follow [shadPS4's np_utility.cpp](https://github.com/shadps4-emu/shadPS4/blob/91e6afa69b0a64b0afaa0281b80f8fbb0cd88136/src/core/libraries/np/np_utility/np_utility.cpp) offline, the way #9009 modelled libSceNpTus: - **Title contexts and requests:** lookup and word filter keep separate tables. A null NpId is `INSUFFICIENT_ARGUMENT`; more than 32 title contexts or 32 requests is `TOO_MANY_OBJECTS`; an unknown id is `INVALID_ID`; deleting a title context deletes its requests. Word filter ids start at `0x01000001` and `0x02000001`, as in shadPS4's [`np_utility.h`](https://github.com/shadps4-emu/shadPS4/blob/91e6afa69b0a64b0afaa0281b80f8fbb0cd88136/src/core/libraries/np/np_utility/np_utility.h#L19-L44). `sceNpWordFilterCreateAsyncRequest` needs a parameter whose size field is `0x18`. - **The calls that would reach the server:** `sceNpLookupNpId` checks the option before the null arguments, the censor and sanitize calls check the null arguments, the option and the 0x400-byte comment limit, all in shadPS4's order. A request can be used once (`INVALID_TYPE` after), and an aborted one answers `ABORTED`. Then they finish with `SCE_NP_ERROR_SIGNED_OUT`: returned by a synchronous request, reported by `sceNpWordFilterPollAsync` for an asynchronous one. No NpId or sanitized comment is written. - **Polling and aborting:** `sceNpWordFilterPollAsync` refuses a null result (`INVALID_ARGUMENT`) and a synchronous request (`INVALID_ID`); `sceNpWordFilterAbortRequest` finishes an unstarted request with `ABORTED` and leaves a finished one's result. shadPS4's own word filter accepts every comment as a stand-in for the server, so only its argument checks are used here. Nothing is measured on a PS5; the new debt file says so. `sceNpBandwidthTestInitStart` keeps throwing. #8472 declares other libSceNpUtility exports between the bandwidth test calls and these, and creates the same debt file with an `Unknown function info` section; the `Export.cpp` hunks do not touch each other, and whichever lands second keeps both debt sections. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with `BUILD_TESTING=ON`. Windows was not compiled. No title was run. - New `guest_np_utility_offline` (`core/libs/tests/GuestNpUtilityOffline.cpp`): both id bases and the 32-context and 32-request limits, every argument check and the check order in `sceNpLookupNpId` and both comment calls, the 0x400 and 0x401-byte comments, single use, `SIGNED_OUT` from synchronous requests and through `sceNpWordFilterPollAsync`, polling a synchronous request, abort before and after the request finished, deleting a title context with its requests, and no NpId or comment written. - It aborts on `main` (`sceNpLookupCreateTitleCtx not implemented`) and passes with this change. 15 mutations of the new code (each check and its order, single use, both offline results, the limits, the async parameter size, the id base, the abort rule, polling a synchronous request, deleting a context's requests) each fail it. - `tools/check_conventions.py --base upstream/main` passes; `tools/pr_overlap.py` lists only #8472, described above. ### 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 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
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!9887
No description provided.