Skip to content

feat(libSceNpCppWebApi): answer the SessionManager value accessors - #19526

Merged
oneandonlydean merged 8 commits into
boykopovar:mainfrom
Opensource55:feat/npcpp-session-manager-value-accessors
Nov 14, 2026
Merged

oneandonlydean merged 8 commits into
boykopovar:mainfrom
Opensource55:feat/npcpp-session-manager-value-accessors

Conversation

@Opensource55

@Opensource55 Opensource55 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

libSceNpCppWebApi.prx in Demon's Souls (PPSA01341) answers twenty-four SessionManager members with a single field read each. This PR replaces their NotImplemented_nid_no_patch stubs with that read and fixes the declarations that described them wrongly.

FromMember::getOnlineId                              0x18, 0x14 bytes
Representative::getPlatform                          0x30 (String)
GameSessionPlayer::getAccountId                      0x10 uint64_t
GameSessionPlayer::getPlatform                       0x30 (String)
GameSessionPlayer::getJoinState / joinStateIsSet     0x78 / 0x7c
GameSessionForRead::getSessionId / sessionIdIsSet    0x10 / 0x30
GameSessionForRead::getMember / memberIsSet          0x70 / 0x88
PlayerSessionForRead::getSessionId                   0x10 (String)
PlayerSessionForRead::getJoinableUserType / IsSet    0x134 / 0x138
GameSessionMemberForRead::getPlayers / playersIsSet  0x10 / 0x28
ResponsePlayerSessionInvitation::getInvitationId     0x10 (String)
UsersPlayerSessionsInvitationForRead::getSessionId   0x78 (String)
  sessionIdIsSet / invitationIdIsSet                 0x98 / 0x30
  getFrom / fromIsSet                                0x38 / 0x50
  receivedTimestampIsSet                             0xe0
PostPlayerSessionsSessionIdInvitationsResponseBody
  getInvitations / invitationsIsSet                  0x30 / 0x48

Each string member is a 0x20-byte CommonString, and each flag sits one member-width after the value it guards, so every pair pins the layout from both ends: getSessionId 0x10 with sessionIdIsSet 0x30, getFrom 0x38 with fromIsSet 0x50, getMember 0x70 with memberIsSet 0x88.

getOnlineId copies 0x14 bytes, which is the same 20-byte online id Representative and GameSessionPlayer already return through the same helper, and those two classes already answer getAccountId at 0x10 with getOnlineId at 0x18 and getPlatform at 0x30 — the same triple this PR answers for GameSessionPlayer.

Twenty declarations were wrong and are corrected here. Fifteen in the appended block returned int whatever the member was; getPlayers, getInvitations and getFrom also lacked the structure-return pointer their IntrusivePtr result needs; getAccountId was 32 bits wide where the module's mov rax returns 64; and getOnlineId and getSessionId returned const char* pointing at the string object's head instead of const CommonString*.

GetUsersAccountIdPlayerSessionsInvitationsResponseBody::getInvitations and its flag are left out of this PR: they sit inside the hunks of #16018 and #16052, and reading those patches line by line shows both use the symbol as context only, so neither implements it. They are answered in #19546, which keeps one topic per PR.

This branch answers 24 of the 1783 NID exports of libSceNpCppWebApi. On the main it now carries (e083b03cff) tools/progress.py --module libSceNpCppWebApi reports 1371 of 1799, leaving 102 NotImplemented stubs; with this PR and the four sibling ones merged it reaches 1450 of 1799 with 23 stubs left. The patched prx exports 1783 NIDs before and after, so no symbol is added or dropped.

Tested

Windows 10 22H2 (19045), MinGW GCC 15.2.0, MinGW-Ninja build.

  • guest_np_cpp_web_api_session_manager_values (new) drives every accessor over a buffer filled with 0xa5; the flags are checked by flipping only their own byte to 0, 1 and 0xa5 and by filling every earlier byte with 0xff; the account id is a 64-bit value with 0xff neighbours on both sides, and the join state is negative so a signed field read as unsigned shows up; the four member copies are checked to return the three words of the IntrusivePtr and to increment the reference count at 0x00 or 0x30 as the member kind requires.
  • ctest -R np_cpp_web_api reports 21 of 21 on this branch after merging e083b03cff: the 20 suites main has plus this PR's own.
  • The export list of build/core/libs/libs/unpatched/libSceNpCppWebApi.prx was parsed before and after: 1783 names both times, so no symbol was added or dropped, and the 24 targets are present.

Checklist

  • Based on current main; no other open PR implements the same functions — checked every open PR's file list (1502 at the time of writing); the only overlap in this library is GetUsersAccountIdPlayerSessionsInvitationsResponseBody::getInvitations, which is left untouched (feat(libSceNpCppWebApi): allocate String, Vector and IntrusivePtr objects from the LibContext #16018, feat(libSceNpCppWebApi): implement the shared transaction bookkeeping #16052)
  • 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); no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source — n/a
  • Generic behaviour, not specific to one title — the offsets follow the module's own accessors
  • Depends on: none
  • Fixes: none
  • Unblocks: n/a
  • GPUs tested: n/a
  • AI-assisted: yes

`libSceNpCppWebApi.prx` in Demon's Souls (PPSA01341) answers twenty-four
SessionManager members with one field read each:

    FromMember::getOnlineId                              0x18, 0x14 bytes
    Representative::getPlatform                          0x30 (String)
    GameSessionPlayer::getAccountId                      0x10 uint64_t
    GameSessionPlayer::getPlatform                       0x30 (String)
    GameSessionPlayer::getJoinState / joinStateIsSet     0x78 / 0x7c
    GameSessionForRead::getSessionId / sessionIdIsSet    0x10 / 0x30
    GameSessionForRead::getMember / memberIsSet          0x70 / 0x88
    PlayerSessionForRead::getSessionId                   0x10 (String)
    PlayerSessionForRead::getJoinableUserType / IsSet    0x134 / 0x138
    GameSessionMemberForRead::getPlayers / playersIsSet  0x10 / 0x28
    ResponsePlayerSessionInvitation::getInvitationId     0x10 (String)
    UsersPlayerSessionsInvitationForRead::getSessionId   0x78 (String)
      sessionIdIsSet / invitationIdIsSet                 0x98 / 0x30
      getFrom / fromIsSet                                0x38 / 0x50
      receivedTimestampIsSet                             0xe0
    PostPlayerSessionsSessionIdInvitationsResponseBody
      getInvitations / invitationsIsSet                  0x30 / 0x48

Every string member is a 0x20-byte `CommonString` and every flag sits
one member-width after the value it guards, so `getSessionId` at 0x10
paired with `sessionIdIsSet` at 0x30, `getFrom` at 0x38 paired with
`fromIsSet` at 0x50, and `getMember` at 0x70 paired with `memberIsSet`
at 0x88 each pin the layout from both ends. `getOnlineId` copies 0x14
bytes, which matches the 20-byte online id `Representative` and
`GameSessionPlayer` already return through the same helper, and their
already-answered `getAccountId` at 0x10 with `getOnlineId` at 0x18 and
`getPlatform` at 0x30 fixes the same triple this PR answers for
`GameSessionPlayer`.

Twenty declarations were wrong and are corrected here. Fifteen in the
appended block returned `int` whatever the member was; `getPlayers`,
`getInvitations` and `getFrom` also lacked the structure-return pointer
their `IntrusivePtr` result needs; `getAccountId` was 32 bits wide where
the module's `mov rax` returns 64; and `getOnlineId` and `getSessionId`
returned `const char*` pointing at the string object's head instead of
`const CommonString*`.

`GetUsersAccountIdPlayerSessionsInvitationsResponseBody::getInvitations`
and its flag are left as they are: #16018 and #16052 both touch that
symbol, so this PR stays out of their way.

`guest_np_cpp_web_api_session_manager_values` drives each accessor over
a buffer filled with `0xa5`, flips only the guarded byte for the flags,
writes a 64-bit account id and a negative join state with `0xff`
neighbours, and checks that the member copies return the three words of
the `IntrusivePtr` with the reference count incremented at 0x00 or 0x30
as the member kind requires.

The library moves from 1641 to 1665 answered symbols of the 1762 it
exports, the patched prx still exports the same 1762 NIDs, and all 18
suites of this library pass.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

The accessors read what the table lists, with one test row per accessor. Two things need to be written down before this can go in, and the first one matters for correctness:

  1. The SessionManager::V1 model accessors entry in docs/dev/debt/libSceNpCppWebApi.md says the model layouts differ between the bundled SDK builds: PlayerSessionForRead::customData1IsSet is at +0x1e0 in PPSA20397's module and at +0x1a0 in the other measured build, so a title built against the other layout gets wrong answers from an accessor with the first build's offset. These 24 offsets come from the PPSA01341 module only. Please say which build of that module the listing is from and whether the PPSA20397 and PPSA21564 modules have the same offsets for these members (PlayerSessionForRead::getJoinableUserType at +0x134 is the one most likely to move, since it sits after the +0x1a0/+0x1e0 region). If only one build was read, the entry has to say that these 24 answer for that build's layout and may be wrong for the other.
  2. The same entry ends with "Other model fields remain unsupported", and it does not name these 24. Please list which accessors now read a field and from which offsets, so the entry is true after the merge.

The same two points apply to #19481 and #19500 (Matchmaking accessors by the same author).

…ir build

The `SessionManager::V1 model accessors` entry said other model fields
remain unsupported without naming what this branch answers, and it did
not say which build the offsets came from.

It now lists the twenty-four accessors with their offsets, says they were
inspected statically and not executed, and states that they were read
from the PPSA01341 v01.007.000 module. Three of them (`getMember` +0x70,
`memberIsSet` +0x88, `sessionIdIsSet` +0x30) are also recorded from
PPSA21564 and read identically here, so those three are confirmed on both
builds. `getJoinableUserType` +0x134 and its flag sit in this class's
diverging region and are called out as answering for the PPSA01341
layout, possibly wrong for a title built against the other one; the
remaining nineteen have no cross-build comparison.
@Opensource55

Copy link
Copy Markdown
Contributor Author

Both points are in 3f586864c4.

1. Which build, and what is confirmed across builds. The listing is from the PPSA01341 v01.007.000 module, and the entry now says so. On the other two builds: the PPSA21564 sce_module copy on this machine is a SELF container (4f 15 3d 1d), not a plain ELF, and there is no PPSA20397 dump at all, so I cannot disassemble either. What I can do is compare against what this file already records from PPSA21564: reading those 34 recorded offsets back out of the PPSA01341 module agrees on 34 of 34 (class, method and displacement).

For these 24 specifically, three offsets are in that recorded set and read identically here — getMember +0x70, memberIsSet +0x88, sessionIdIsSet +0x30 — so those three are confirmed on both builds, not just this one.

Your point about getJoinableUserType +0x134 is the right one to worry about, and I handled it the way you asked rather than silently: this is the class whose layout is documented to diverge (+0x1a0 vs +0x1e0), and +0x134 is not among the recorded members, so the entry now says those two answer for the PPSA01341 layout and may be wrong for a title built against the other one. The remaining nineteen are labelled as read from that build only, with no cross-build comparison.

2. The entry names them. It now lists all 24 with their offsets and no longer leaves them under "other model fields remain unsupported" — that sentence still refers to the fields not listed.

One thing worth stating so you can check the rule I applied: I throw when the same member has two recorded offsets (that is why #19503's getSortMode/getUpdateMode and #19546's getTmpRank/getTmpSerialRank/getUsers are back to throwing), and I document the layout-specific caveat when only one build was readable. If you would rather see +0x134/+0x138 throw too, say so and I will revert those two — the entry already carries the caveat either way.

Extending the `SessionManager::V1 model accessors` entry pushed it past
the 1000-character limit the conventions check warns at, so the list
moves into two entries of its own: the session models and the invitation
models.

The first gives the fourteen session accessors with their offsets, notes
that `getMember`, `memberIsSet` and `sessionIdIsSet` also appear in the
offsets recorded from PPSA21564 and read identically here, and that
`getJoinableUserType` and its flag sit in this class's diverging region
and answer for the PPSA01341 layout only. The second gives the ten
invitation accessors with theirs and says they are one-build only. Both
say the offsets were read from the PPSA01341 v01.007.000 module and
inspected statically rather than executed, and that other fields and
console values are unverified.
@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 006c278224, merged onto main 60c460cc55 (88f48aa92b, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_np_cpp_web_api_session_manager_values passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions github-actions Bot added the docs label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Progress report (8c8a6a2 → 9da9aa9)

📈 System libraries: 40.52% (+0.06%, +24 implemented functions)

✅ 24 implemented
Library Name
libSceNpCppWebApi _ZN3sce2Np9CppWebApi14SessionManager2V124GameSessionMemberForRead10getPlayersEv
libSceNpCppWebApi _ZN3sce2Np9CppWebApi14SessionManager2V150PostPlayerSessionsSessionIdInvitationsResponseBody14getInvitationsEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V110FromMember11getOnlineIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V114Representative11getPlatformEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V117GameSessionPlayer11getPlatformEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V117GameSessionPlayer12getAccountIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V117GameSessionPlayer12getJoinStateEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V117GameSessionPlayer14joinStateIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V118GameSessionForRead11memberIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V118GameSessionForRead12getSessionIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V118GameSessionForRead14sessionIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V118GameSessionForRead9getMemberEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V120PlayerSessionForRead12getSessionIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V120PlayerSessionForRead19getJoinableUserTypeEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V120PlayerSessionForRead21joinableUserTypeIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V124GameSessionMemberForRead12playersIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V131ResponsePlayerSessionInvitation15getInvitationIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead12getSessionIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead14sessionIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead17invitationIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead22receivedTimestampIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead7getFromEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V136UsersPlayerSessionsInvitationForRead9fromIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi14SessionManager2V150PostPlayerSessionsSessionIdInvitationsResponseBody16invitationsIsSetEv

Changed libraries (implemented exports)

Library Before After Change
libSceNpCppWebApi 1381/1799 (76.76%) 1405/1799 (78.10%) +1.33%

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 13, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 13, 2026
The conflict is the tail of `libSceNpCppWebApi/CMakeLists.txt`, where main
gained the DateTime and string blocks from the two merged PRs while this
branch appends its own. All three stay and the file registers fifteen
suites.

`Export.cpp` and `Api.hpp` merged without help: the twenty-four accessors
this branch answers are still converted, with the twenty declaration
corrections this branch carries, and no implementation that main gained
since is dropped. `guest_np_cpp_web_api_*` is 20 of 20 after the merge.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 14, 2026
@ycbuzi

ycbuzi commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Tested d0736d27f2 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 3 tests failed out of 5411; 99% tests passed, 3 tests failed out of 5411. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 5411; 100% tests passed, 0 tests failed out of 5411. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@Opensource55

Copy link
Copy Markdown
Contributor Author

Merged e083b03cff (3759254b4c): the branch merged cleanly, main had moved 242 commits. After the merge 24 of 24 answered symbols are in the NID export table (1783 entries), ctest -R np_cpp_web_api is 21 of 21, check_conventions.py passes, and git merge-tree 3759254b4c upstream/main is clean. The body's counts now use that base (1371 of 1799 before, 1450 of 1799 with all five PRs).

The failed windows job on d0736d27f2 was not this branch: ctest ran 4457 tests and the single failure was guest_freebsd_clocks (exit code 0xc0000409, stack-buffer check). The public_headers line was only a warning (33.8 s against the 30 s guideline). Neither test touches libSceNpCppWebApi. The new run on 3759254b4c will show whether it reproduces.

Thanks @ycbuzi for the full suite on d0736d27f2; the 24 answers are unchanged, only the merge commit is new.

@Opensource55

Copy link
Copy Markdown
Contributor Author

The windows job on 3759254b4c is red: 1 failure out of 4520, agc_shader_memory (Exit code 0xc0000374). public_headers 33.1 s is only a warning. This branch changes Export.cpp, Api.hpp, one test and the debt file — nothing under AGC.

#19481 (agc_shader_empty_table_resolution, Timeout) and #19546 (agc_shader_memory, Timeout) failed the same family in the same window, so this looks like the runner. I cannot rerun jobs (403, admin only); a rerun on your side should clear it.

@Opensource55

Copy link
Copy Markdown
Contributor Author

Merged c7102526b5 (303cd65d9e), 393 commits since the base this branch carried. The merge was clean: no conflict in Export.cpp, the test lists or the debt file.

Re-verified on the merged tree, not on the old one: ninja builds the unpatched and the NID-patched prx; 24 of 24 answered symbols are in the export table (1783 entries); ctest -R np_cpp_web_api is 21 of 21; check_conventions.py passes.

The windows job on the previous head was red on agc_shader_memory timing out at the 120 s ctest limit (0xc0000374, 1 of 4520 tests), which is why I asked for a rerun rather than changing anything. I cannot rerun jobs from this account (403 Must have admin rights), so the push above is also the way to get a fresh run. If the new one lands green, nothing else in the branch changed.

# Conflicts:
#	core/libs/prx/libSceNpCppWebApi/CMakeLists.txt
@oneandonlydean
oneandonlydean merged commit b9033b7 into boykopovar:main Nov 14, 2026
13 checks passed
@Opensource55
Opensource55 deleted the feat/npcpp-session-manager-value-accessors branch November 14, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants