Skip to content

feat(libSceNpCppWebApi): answer the Matchmaking model accessors - #19481

Merged
oneandonlydean merged 11 commits into
boykopovar:mainfrom
Opensource55:feat/npcpp-matchmaking-model-accessors
Nov 15, 2026
Merged

oneandonlydean merged 11 commits into
boykopovar:mainfrom
Opensource55:feat/npcpp-matchmaking-model-accessors

Conversation

@Opensource55

@Opensource55 Opensource55 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Answers 17 Matchmaking model accessors in libSceNpCppWebApi that the console reduces to a single field read. The offsets come from the decrypted libSceNpCppWebApi.prx of Demon's Souls (PPSA01341 v01.007.000, sha256 d03d64abc6f82a2a6b0b9e992782f98b7f488fd225a8553132b41e23bdad5b10), read from its disassembly; nothing here was run on a console. They are not taken from the model headers:

PlayerForRead::getPlatform            mov eax, dword ptr [rdi + 0x30]
PlayerForRead::accountIdIsSet         movzx eax, byte ptr [rdi + 0x18]
PlayerForRead::onlineIdIsSet          movzx eax, byte ptr [rdi + 0x2d]
PlayerForRead::platformIsSet          movzx eax, byte ptr [rdi + 0x34]
PlayerForRead::teamNameIsSet          movzx eax, byte ptr [rdi + 0x58]
PlayerForRead::playerAttributesIsSet  movzx eax, byte ptr [rdi + 0x80]
PlayerForOfferRead::getPlatform       mov eax, dword ptr [rdi + 0x30]
PlayerForOfferRead::accountIdIsSet    movzx eax, byte ptr [rdi + 0x18]
PlayerForOfferRead::onlineIdIsSet     movzx eax, byte ptr [rdi + 0x2d]
PlayerForOfferRead::platformIsSet     movzx eax, byte ptr [rdi + 0x34]
PlayerForOfferRead::teamNameIsSet     movzx eax, byte ptr [rdi + 0x58]
PlayerForOfferRead::ticketIdIsSet     movzx eax, byte ptr [rdi + 0x80]
Attribute::getType                    mov eax, dword ptr [rdi + 0x30]
Submitter::getPlatform                mov eax, dword ptr [rdi + 0x1c]
Submitter::accountIdIsSet             movzx eax, byte ptr [rdi + 0x18]
Submitter::platformIsSet              movzx eax, byte ptr [rdi + 0x20]
Location::gameSessionIdIsSet          movzx eax, byte ptr [rdi + 0x30]

The numbers are not independent guesses; three other accessors in the same module close the layout around them:

  • PlayerForRead::getAccountId was already implemented here and reads [rdi + 0x10] as a uint64_t. accountIdIsSet at 0x18 is the byte immediately after that id.
  • PlayerForRead::getOnlineId copies 16 bytes from [rsi + 0x19] and 4 more from [rsi + 0x29], so the id is 20 bytes at 0x19. onlineIdIsSet at 0x2d is exactly its last byte plus one.
  • getTeamName is lea rax, [rdi + 0x38], and teamNameIsSet at 0x58 closes a 32-byte String.
  • Location::setGameSessionId writes the string at +0x10 and then stores 1 at [rbx + 0x30], which is the flag this PR reads.

include/Api.hpp is untouched: all 17 already returned int, and none of them needs a size or signature change.

Tested

Windows 10 19045, MinGW GCC 15.2, Release.

  • New guest_np_cpp_web_api_matchmaking_model test: a buffer whose byte i holds i. An accessor that read the wrong offset, the wrong width or a constant would fail; three of them are also re-checked after rewriting a byte, so the value tracks memory. Passes.
  • Existing guest_np_cpp_web_api_matchmaking still passes.
  • The 17 symbols appear as NID exports in the built build/core/libs/libs/libSceNpCppWebApi.prx (patched form), 17 of 17.
  • tools/progress.py --module libSceNpCppWebApi moves from 1332 to 1349 and nothing else changes.
  • tools/check_conventions.py --base upstream/main passes.

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

`libSceNpCppWebApi.prx` in Demon's Souls (PPSA01341) answers these 17
accessors with a single field read, so the offsets are read off the
module itself rather than guessed from the models:

    PlayerForRead::getPlatform            mov eax, [rdi + 0x30]
    PlayerForRead::accountIdIsSet         movzx eax, byte [rdi + 0x18]
    PlayerForRead::onlineIdIsSet          movzx eax, byte [rdi + 0x2d]
    PlayerForRead::platformIsSet          movzx eax, byte [rdi + 0x34]
    PlayerForRead::teamNameIsSet          movzx eax, byte [rdi + 0x58]
    PlayerForRead::playerAttributesIsSet  movzx eax, byte [rdi + 0x80]
    PlayerForOfferRead::getPlatform       mov eax, [rdi + 0x30]
    PlayerForOfferRead::accountIdIsSet    movzx eax, byte [rdi + 0x18]
    PlayerForOfferRead::onlineIdIsSet     movzx eax, byte [rdi + 0x2d]
    PlayerForOfferRead::platformIsSet     movzx eax, byte [rdi + 0x34]
    PlayerForOfferRead::teamNameIsSet     movzx eax, byte [rdi + 0x58]
    PlayerForOfferRead::ticketIdIsSet     movzx eax, byte [rdi + 0x80]
    Attribute::getType                    mov eax, [rdi + 0x30]
    Submitter::getPlatform                mov eax, [rdi + 0x1c]
    Submitter::accountIdIsSet             movzx eax, byte [rdi + 0x18]
    Submitter::platformIsSet              movzx eax, byte [rdi + 0x20]
    Location::gameSessionIdIsSet          movzx eax, byte [rdi + 0x30]

Cross-checks that the offsets are the real layout rather than four
unrelated numbers:

- `PlayerForRead::getAccountId`, already implemented against the module,
  reads `[rdi + 0x10]` as a `uint64_t`; `accountIdIsSet` at `0x18` is the
  flag right after it.
- `getOnlineId` copies 16 bytes from `[rsi + 0x19]` and 4 more from
  `[rsi + 0x29]`, i.e. a 20-byte `OnlineId` at `0x19`; `onlineIdIsSet` at
  `0x2d` sits exactly at its end.
- `getTeamName` is `lea rax, [rdi + 0x38]`; the flag at `0x58` closes a
  32-byte `String`.
- `Location::setGameSessionId` stores the string at `+0x10` and then sets
  the byte at `0x30` to 1, which is the flag this change reads.

The new `guest_np_cpp_web_api_matchmaking_model` test fills a buffer with
each byte holding its own offset, so an accessor that read the wrong
offset, the wrong width, or returned a constant would fail. All 17
symbols also appear as NID exports in the built
`build/core/libs/libs/libSceNpCppWebApi.prx`, and the library's measured
count moves from 1332 to 1349 with nothing else changing.

No size, signature or declaration changes: every one of these already
returned `int`, so `include/Api.hpp` is untouched.
… test

CONVENTIONS.md allows comments only for technical debt, #endif and the
end of a namespace; the test relied on prose instead of names.
@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 211d7db2d6, merged onto main 8de3dc8140 (211d7db2d6, 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_matchmaking_model passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

The accessors read what the PR body lists, the test is a real one (an index-valued buffer, three of them re-read after a byte is rewritten), and the 17 NID exports are checked, so the code itself looks right. Two documentation points before it can pass:

  1. docs/dev/debt/libSceNpCppWebApi.md, the Matchmaking::V1 entry, still says "Response accessors throw: a failed request produces no response." These 17 accessors now answer a field read, so that sentence is no longer true for them. Please update the entry to say which accessors read a field and from which offsets.
  2. That entry says the Matchmaking behaviour comes from the module bundled with PPSA21564 and PPSA23732 (builds J03093737 and J03341606), while the PR takes the offsets from the module of PPSA01341. Please say which build of the PPSA01341 module the listing is from, and whether the PPSA21564 module has the same offsets (the model layouts can differ between SDK builds), or record in the entry that only the PPSA01341 build was read.

…ome from

The `Matchmaking::V1` debt entry said response accessors throw, which is
no longer true for the seventeen model accessors this branch answers, and
it names the PPSA21564/PPSA23732 builds as the source of the Matchmaking
behaviour while the offsets here come from the PPSA01341 module.

The entry now lists each accessor with its offset, says they were
inspected statically and not executed, and states that these seventeen
were read from the PPSA01341 v01.007.000 build only: none of the members
this file records from PPSA21564 is a Matchmaking member, so the general
agreement between those builds (recorded in the entry below) is context,
not a per-member measurement. The models' other fields, their
construction and any console value stay unverified.
@Opensource55

Copy link
Copy Markdown
Contributor Author

Both points are in f768650b02.

1. The Matchmaking::V1 entry no longer says response accessors throw. It now names the seventeen accessors and the offset each reads: PlayerForRead/PlayerForOfferRead getPlatform +0x30 (32-bit), platformIsSet +0x34, onlineIdIsSet +0x2d, accountIdIsSet +0x18, teamNameIsSet +0x58, PlayerForRead::playerAttributesIsSet +0x80, PlayerForOfferRead::ticketIdIsSet +0x80, Location::gameSessionIdIsSet +0x30, Attribute::getType +0x30 (32-bit), Submitter getPlatform +0x1c (32-bit), platformIsSet +0x20 and accountIdIsSet +0x18. It also says they were inspected statically and not executed, and that the models' other fields, their construction and any console value remain unverified.

2. Which build the listing is from. PPSA01341 v01.007.000, and the entry says so.

On whether PPSA21564 has the same offsets, I have to be exact about what I could check: no Matchmaking member is among the offsets this file records from PPSA21564, so there is no per-member comparison to report for these seventeen — they are read from the PPSA01341 build only, and the entry says exactly that.

What I could add is the direction of the difference. The PPSA21564 sce_module copy on this machine is a SELF container (4f 15 3d 1d), not a plain ELF, and there is no PPSA05347 or PPSA20397 dump at all, so none of them can be disassembled here. But the 34 offsets that this file does record from PPSA21564 (SessionManager::V1 members, the four Leaderboards accessors and the two Activities ones) read back identical out of the PPSA01341 module — 34 of 34, class, method and displacement. So the two builds share one layout family, which is why I am willing to state PPSA01341 offsets for Matchmaking at all; the entry records that as context and keeps the per-member claim scoped to the one build that was readable.

…wn entry

Extending the `Matchmaking::V1` entry pushed it past the 1000-character
limit `tools/check_conventions.py` warns at, so the list moves into an
entry of its own next to the Account-ID one and the original entry goes
back to what it said: its "response accessors throw" now covers the
accessors that are not listed in the new entry.

The new entry keeps the substance: seventeen accessors with their
offsets, read from the PPSA01341 v01.007.000 module, statically
inspected and not executed, one-build only because no Matchmaking member
is among the offsets recorded from PPSA21564, with other fields,
construction and console values unverified.
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Progress report (2f6d40f → 9ac6cdc)

📈 System libraries: 41.0% (+0.04%, +17 implemented functions)

✅ 17 implemented
Library Name
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead11getPlatformEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead13onlineIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead13platformIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead13teamNameIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead14accountIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead21playerAttributesIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead11getPlatformEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead13onlineIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead13platformIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead13teamNameIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead13ticketIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead14accountIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V18Location18gameSessionIdIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Attribute7getTypeEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Submitter11getPlatformEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Submitter13platformIsSetEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Submitter14accountIdIsSetEv

Changed libraries (implemented exports)

Library Before After Change
libSceNpCppWebApi 1433/1799 (79.66%) 1450/1799 (80.60%) +0.94%

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

Copy link
Copy Markdown
Contributor Author

The windows failure on 9c725bbb54 is not from this branch, and I have restarted the job.

The job's own test list has exactly two entries:

3160 - guest_ces_wide (Timeout)
3161 - guest_ces_wide_module (Timeout)

Both are libSceCesCs suites, killed by ctest --timeout 120. The same run logged guest_ces_mbc at 118.6 s, guest_ces_mbc_module at 118.6 s, agc_shader_disk_cache_large_file at 41.1 s and guest_ces_dbcs/guest_ces_dbcs_module at 38.8 s — the whole libSceCesCs family is over the 30 s budget on that runner, and this branch touches libSceNpCppWebApi/Export.cpp only.

I could not rerun the failed job myself: POST /actions/runs/43447464559/rerun-failed-jobs answers 403 Must have admin rights to Repository. So 736a21443f merges main 27a68078a3 into the branch instead, which is worth doing anyway to keep the five remaining PRs on one base, and it starts a fresh windows job.

After the merge, locally: libSceNpCppWebApi.prx builds, guest_np_cpp_web_api_* is 20 of 20, and all seventeen accessors are still converted. The independent Windows 11 / WinLibs GCC 15.2 run from @JJenkx reported 3 of 3 for guest_np_cpp_web_api_matchmaking_model on an earlier head.

@Opensource55

Copy link
Copy Markdown
Contributor Author

Correction to my earlier comment, plus one commit (914559d5ac).

My reply in f768650b02 said the Matchmaking::V1 entry no longer claims that response accessors throw. That was wrong: the new Matchmaking::V1 model accessors entry is accurate, but the older entry still carried Response accessors throw: a failed request produces no response. — which stopped being true once #19500 and #19511 merged. @oneandonlydean flagged the same line on #19511.

914559d5ac changes it to Unanswered response-body accessors throw: .... The body now also carries the module fingerprint he asked for: libSceNpCppWebApi.prx, PPSA01341 v01.007.000, sha256 d03d64abc6f82a2a6b0b9e992782f98b7f488fd225a8553132b41e23bdad5b10, read from disassembly and not run on a console.

@Opensource55

Copy link
Copy Markdown
Contributor Author

The windows job on 914559d5ac is red, and it is not this branch: 1 failure out of 4455 tests, agc_shader_empty_table_resolution (Timeout at the 120 s ctest limit). This branch changes only Export.cpp, Api.hpp, tests/GuestNpCppWebApiMatchmakingModel.cpp and the debt file — nothing under AGC.

The same window hit the sibling tests on the other two branches: #19526 failed on agc_shader_memory (0xc0000374, heap corruption) and #19546 on the same test (Timeout). Three PRs, two different AGC tests, all inside ten minutes — that reads as the Windows runner rather than any diff.

I cannot rerun jobs from this account (the API answers 403 Must have admin rights), so a rerun on your side is what clears it.

@Opensource55

Copy link
Copy Markdown
Contributor Author

Merged c7102526b5 (03a137edd0), 664 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; 17 of 17 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_empty_table_resolution timing out at the 120 s ctest limit (1 of 4455 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.

@Opensource55

Copy link
Copy Markdown
Contributor Author

Merged 32a2f1e1d7 (c32b3c4). main moved 14 commits; the only overlap is core/libs/prx/libSceNpCppWebApi/CMakeLists.txt, because #19526 landed its own session_manager_values block at the same spot. This branch merged without a conflict.

Re-verified on the merged tree: 17 of 17 answered symbols are in the NID export table (1783 entries), ctest -R np_cpp_web_api is 23 of 23, check_conventions.py passes, and git merge-tree --write-tree HEAD upstream/main is clean.

The windows job on the previous head is red on the 30 s test-duration guideline, not on this branch: agc_driver_graphics 32.6 s, agc_graphics_profile_draw 30.0 s. Nothing here touches AGC. I cannot rerun jobs from this account (403 Must have admin rights); this push is also what triggers a fresh run.

@github-actions

Copy link
Copy Markdown

Some 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.

Pull request Shared files not compared
PR 16018 core/libs/prx/libSceNpCppWebApi/CMakeLists.txt
core/libs/prx/libSceNpCppWebApi/Export.cpp
docs/dev/debt/libSceNpCppWebApi.md
PR 16052 core/libs/prx/libSceNpCppWebApi/CMakeLists.txt
core/libs/prx/libSceNpCppWebApi/Export.cpp
docs/dev/debt/libSceNpCppWebApi.md

…gment

`main` now takes debt changes through `docs/dev/debt/changes/<branch>.md`
instead of editing the debt files (CONTRIBUTING.md, docs/dev/TechnicalDebt.md#fragments).
The two edits this branch made to `docs/dev/debt/libSceNpCppWebApi.md` - the
`Matchmaking::V1` wording change and the new model accessors entry - are the
same two operations in `docs/dev/debt/changes/feat-npcpp-matchmaking-model-accessors.md`,
and the debt file is back to `main`'s version.
@Opensource55

Copy link
Copy Markdown
Contributor Author

Merged 2f6d40f29b (c0749802ac), 391 commits on main. Clean, no conflict; add_test(NAME counts 19, main's 18 plus this PR's matchmaking_model.

One thing did change under this PR: the debt convention. main now takes debt edits as a fragment in docs/dev/debt/changes/<branch>.md rather than as edits to the debt files (CONTRIBUTING.md, docs/dev/TechnicalDebt.md#fragments). 9ac6cdcdc3 therefore carries what this branch did to docs/dev/debt/libSceNpCppWebApi.md as two operations in docs/dev/debt/changes/feat-npcpp-matchmaking-model-accessors.md: change [sce::Np::CppWebApi::Matchmaking::V1] for the "Unanswered response-body accessors" wording, and add Functional for the model accessors entry. The debt file itself is back to main's version. python tools/debt_fold.py --show libSceNpCppWebApi reproduces the two edits the previous head carried; the one difference is that the tool places the new entry after the last Functional entry that links Export.cpp, instead of in the middle where it sat before.

On the overlap comment. #16018 and #16052 are the only open pull requests that share Export.cpp, CMakeLists.txt and the debt file. Checked at their current heads (54fd47ad2c, ed5b89ee15), both still answer all seventeen of these accessors with NotImplemented_nid_no_patch, so nothing is implemented twice. The overlap comment could not compare them because those two conflict with main, not because of this branch.

The windows job. It is red on agc_driver_graphics (34.16 s, 1 of 4523 tests), and the same test is red on main itself: the windows run on 4ed0d308e6 fails agc_graphics_profile_draw (36.26 s) and agc_driver_graphics (35.67 s), 2 of 5562. Nothing here touches AGC. I still cannot rerun jobs from this account (403 Must have admin rights), so the push is also what starts a fresh run.

Verified on the merged tree, not assumed: ninja builds the unpatched and the NID-patched prx; each of the seventeen accessors has one definition and none still calls NotImplemented_nid_no_patch; ctest -R np_cpp_web_api is 25 of 25; python tools/check_conventions.py --base 2f6d40f29b --head 9ac6cdcdc3 passes, the fragment step included. python tools/debt_fold.py --check over the whole tree still stops earlier, on main's docs/dev/debt/changes/feat-icu-ulist.md ([Older callable exports] matches two entries of libSceIcu); #20282 is already open for that and it is not this branch's.

AI-assisted: yes.

@oneandonlydean
oneandonlydean merged commit f695672 into boykopovar:main Nov 15, 2026
14 checks passed
@Opensource55
Opensource55 deleted the feat/npcpp-matchmaking-model-accessors branch November 15, 2026 04:59
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.

3 participants