feat(libSceNpSessionSignaling): implement context properties and state queries #14910

Merged
edubox merged 3 commits from upstream-pr/14910 into main 2026-11-05 14:36:30 +00:00
edubox commented 2026-11-02 00:29:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-11-02T00:29:40Z.


What

Seven libSceNpSessionSignaling exports threw not implemented. Their signatures are recovered from the wrappers in the 11.00 module, and the offline host can answer the ones that do not need the network:

  • sceNpSessionSignalingInitializeWithPort forwards (param, port, reserved) to the same initializer as sceNpSessionSignalingInitialize, which passes port 0x217b and reserved 0. The wrapper at 0xab40 forwards both extra arguments; whether the initializer validates them is internal and unmeasured, so the host opens no socket and accepts both.
  • sceNpSessionSignalingGetMemoryInfo returns the pool size recorded at initialization and zero used/peak sizes, since the host allocates no signaling pool.
  • sceNpSessionSignalingGetConnectionStatistics returns all-zero counters, since no connection ever activates.
  • sceNpSessionSignalingGetGroupFromPeerAddress performs the same initialization, null-argument and context checks as the other lookups and then returns group-not-found, because no session exists.
  • sceNpSessionSignalingGetCustomProperty / SetCustomProperty keep one 32-bit property per context. The Set wrapper at 0xb3c0 passes the opaque property pointer to the internal setter together with a stack dword and copies that dword to the optional previous-value output; the Get wrapper at 0xb470 calls the internal getter with a stack dword and copies it to the optional output. That establishes the 32-bit previous/output exchange and the forwarded pointer, not the internal four-byte load and replacement, so the host models one 32-bit value.
  • sceNpSessionSignalingRegisterInternalCallback stores the callback and user-data pointers in the context and never invokes them; null pointers are accepted and the call returns 0 after forwarding, as the wrapper does.

The wrappers at 0xab40 (InitializeWithPort), 0xb3c0 (SetCustomProperty), 0xb470 (GetCustomProperty), 0xb930 (GetGroupFromPeerAddress), 0xbb30 (GetMemoryInfo), 0xbae0 (GetConnectionStatistics) and 0xbb80 (RegisterInternalCallback) establish the error order and the 32-bit outputs. CreateJoinActivate, JoinActivate and the ManualUdp* family still throw.

A destroyed context slot now clears the custom property and both callback pointers before reuse, so a new context starts from the same state as a fresh slot. The callback signature is not measured; the two pointers are only stored.

Tested

  • Linux, GCC 16.2.1, Release, BUILD_TESTING=ON: built guest_np_session_signaling_tests; the test binary passes.
  • GuestNpSessionSignaling.cpp covers each new export before initialization, the null-argument and context-not-found errors, the memory and statistics contents, the default/replaced custom property and the group lookup on a valid context, plus InitializeWithPort after terminate and its already-initialized error. It also runs SetCustomProperty + RegisterInternalCallback -> DestroyContext -> CreateContext -> GetCustomProperty for both CreateContext and CreateContext2, and requires the reused slot to report a zero property.
  • python3 tools/check_conventions.py --base origin/main: all checks pass.

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:5113104971 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14910). Originally posted by [edubox](https://github.com/edubox) on 2026-11-02T00:29:40Z. --- ### What Seven `libSceNpSessionSignaling` exports threw `not implemented`. Their signatures are recovered from the wrappers in the 11.00 module, and the offline host can answer the ones that do not need the network: - `sceNpSessionSignalingInitializeWithPort` forwards `(param, port, reserved)` to the same initializer as `sceNpSessionSignalingInitialize`, which passes port `0x217b` and reserved `0`. The wrapper at `0xab40` forwards both extra arguments; whether the initializer validates them is internal and unmeasured, so the host opens no socket and accepts both. - `sceNpSessionSignalingGetMemoryInfo` returns the pool size recorded at initialization and zero used/peak sizes, since the host allocates no signaling pool. - `sceNpSessionSignalingGetConnectionStatistics` returns all-zero counters, since no connection ever activates. - `sceNpSessionSignalingGetGroupFromPeerAddress` performs the same initialization, null-argument and context checks as the other lookups and then returns group-not-found, because no session exists. - `sceNpSessionSignalingGetCustomProperty` / `SetCustomProperty` keep one 32-bit property per context. The Set wrapper at `0xb3c0` passes the opaque property pointer to the internal setter together with a stack dword and copies that dword to the optional previous-value output; the Get wrapper at `0xb470` calls the internal getter with a stack dword and copies it to the optional output. That establishes the 32-bit previous/output exchange and the forwarded pointer, not the internal four-byte load and replacement, so the host models one 32-bit value. - `sceNpSessionSignalingRegisterInternalCallback` stores the callback and user-data pointers in the context and never invokes them; null pointers are accepted and the call returns 0 after forwarding, as the wrapper does. The wrappers at `0xab40` (InitializeWithPort), `0xb3c0` (SetCustomProperty), `0xb470` (GetCustomProperty), `0xb930` (GetGroupFromPeerAddress), `0xbb30` (GetMemoryInfo), `0xbae0` (GetConnectionStatistics) and `0xbb80` (RegisterInternalCallback) establish the error order and the 32-bit outputs. `CreateJoinActivate`, `JoinActivate` and the `ManualUdp*` family still throw. A destroyed context slot now clears the custom property and both callback pointers before reuse, so a new context starts from the same state as a fresh slot. The callback signature is not measured; the two pointers are only stored. ### Tested - Linux, GCC 16.2.1, Release, `BUILD_TESTING=ON`: built `guest_np_session_signaling_tests`; the test binary passes. - `GuestNpSessionSignaling.cpp` covers each new export before initialization, the null-argument and context-not-found errors, the memory and statistics contents, the default/replaced custom property and the group lookup on a valid context, plus `InitializeWithPort` after terminate and its already-initialized error. It also runs SetCustomProperty + RegisterInternalCallback -> DestroyContext -> CreateContext -> GetCustomProperty for both `CreateContext` and `CreateContext2`, and requires the reused slot to report a zero property. - `python3 tools/check_conventions.py --base origin/main`: all checks pass. ### 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 - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!14910
No description provided.