Skip to content

fix(libSceNpCppWebApi): return the Matchmaking string members by address - #19511

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
Opensource55:feat/npcpp-matchmaking-string-accessors
Nov 13, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
Opensource55:feat/npcpp-matchmaking-string-accessors

Conversation

@Opensource55

@Opensource55 Opensource55 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Ten Matchmaking2V1 accessors are declared int, but libSceNpCppWebApi.prx (Demon's Souls, PPSA01341) answers them with an address, not a value:

accessor module was now
PlayerForRead::getTeamName lea rax, [rdi + 0x38] int const CommonString*
PlayerForOfferRead::getTeamName lea rax, [rdi + 0x38] int const CommonString*
PlayerForOfferRead::getTicketId lea rax, [rdi + 0x60] int const CommonString*
GetOfferResponseBody::getOfferId lea rax, [rdi + 0x30] int const CommonString*
GetOfferResponseBody::getRulesetName lea rax, [rdi + 0x58] int const CommonString*
GetTicketResponseBody::getTicketId lea rax, [rdi + 0x30] int const CommonString*
GetTicketResponseBody::getRulesetName lea rax, [rdi + 0x58] int const CommonString*
Location::getGameSessionId lea rax, [rdi + 0x10] int const CommonString*
Attribute::getName lea rax, [rdi + 0x10] int const CommonString*
Attribute::getValue lea rax, [rdi + 0x38] int const CommonString*

As int, the upper 32 bits of that address are discarded, so a caller receives a pointer it cannot dereference. This is the same defect class as #19500, but worse: there the value was truncated, here the pointer is.

const CommonString* is not a new convention — Leaderboards2V1::Entry::getComment is declared and implemented exactly this way and returns self + 0x18.

Why CommonString and not void*

Each of these members is 32 bytes, and the module proves it: every accessor's IsSet flag sits exactly one CommonString past its own lea.

member lea its flag distance
teamName 0x38 teamNameIsSet @ 0x58 0x20
PlayerForOfferRead::ticketId 0x60 ticketIdIsSet @ 0x80 0x20
offerId 0x30 offerIdIsSet @ 0x50 0x20
rulesetName 0x58 rulesetNameIsSet @ 0x78 0x20
gameSessionId 0x10 gameSessionIdIsSet @ 0x30 0x20

Attribute::getName at 0x10 ends where Attribute::getType reads its four bytes, at 0x30 — the same 32-byte window. Attribute::getValue at 0x38 has no flag of its own but is the same shape.

CommonString in include/Api.hpp is { int32 referenceCount; char* buffer; uint64 bufferSize; void* libContext; } = 32 bytes, so the arithmetic closes.

Verification

  • guest_np_cpp_web_api_matchmaking_strings passes.
  • All other targets of this library still pass: 18 of 18.
  • All ten symbols are among the 1420 NIDs the built prx exports (checked against the export directory, not the symbol table).
  • The library's measured count moves 1332 → 1342.
  • tools/check_conventions.py --base upstream/main passes.

Note on the count

While checking this I measured the library two ways: of its 1778 declared functions, 1332 are implemented (74.9%); of the 1420 the built module actually exports, 1074 are implemented (75.6%). The 358 declared-but-not-exported functions cannot be reached by a title, so I only ship implementations for symbols that appear in the export directory. Every symbol in this PR is one of them.

AI-assisted: yes.

Tested

guest_np_cpp_web_api_matchmaking_strings:

  • compares every returned pointer against buffer + offset, so a wrong offset or a truncated return fails;
  • then writes a counter at each target and reads it back through the returned pointer, so the cast is exercised and not just the arithmetic.

Checklist

…ress

These ten accessors do not read a value: `libSceNpCppWebApi.prx` in
Demon's Souls (PPSA01341) computes an address and returns it.

    PlayerForRead::getTeamName            lea rax, [rdi + 0x38]
    PlayerForOfferRead::getTeamName       lea rax, [rdi + 0x38]
    PlayerForOfferRead::getTicketId       lea rax, [rdi + 0x60]
    GetOfferResponseBody::getOfferId      lea rax, [rdi + 0x30]
    GetOfferResponseBody::getRulesetName  lea rax, [rdi + 0x58]
    GetTicketResponseBody::getTicketId    lea rax, [rdi + 0x30]
    GetTicketResponseBody::getRulesetName lea rax, [rdi + 0x58]
    Location::getGameSessionId            lea rax, [rdi + 0x10]
    Attribute::getName                    lea rax, [rdi + 0x10]
    Attribute::getValue                   lea rax, [rdi + 0x38]

All ten were declared `int`, so on this target the upper half of that
address is discarded and the caller receives a pointer that cannot be
dereferenced. They become `const CommonString*`, which is the type the
tree already uses for a member addressed this way:
`Leaderboards2V1::Entry::getComment` is declared and implemented the same
way and returns `self + 0x18`.

The member really is a 32-byte `CommonString`, and it is not an
assumption: each accessor's `IsSet` flag sits exactly one `CommonString`
past its own `lea`. `teamName` at 0x38 closes on `teamNameIsSet` at
0x58, `getTicketId` at 0x60 on `ticketIdIsSet` at 0x80, `getOfferId` at
0x30 on `offerIdIsSet` at 0x50, `getRulesetName` at 0x58 on
`rulesetNameIsSet` at 0x78, and `getGameSessionId` at 0x10 on
`gameSessionIdIsSet` at 0x30. `Attribute::getName` at 0x10 ends where
`Attribute::getType` reads its four bytes, at 0x30.

`guest_np_cpp_web_api_matchmaking_strings` compares each returned pointer
against `buffer + offset`, so a wrong offset or a truncated return fails,
and then writes a counter at each target and reads it back through the
returned pointer, so the cast is exercised rather than just the address.

The library's measured count moves from 1332 to 1342. All ten are among
the module's exported NIDs, and the other targets of this library still
pass, 18 of 18.
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@Opensource55 I reviewed 88a3bbd and passed it. The ten getters now return self + offset as the sibling Entry::getComment and getObjectId already do on main, and the test pins the address and reads a value back through it. One small request, which does not block the PR: please add the module build id or sha256 that the lea rax,[rdi+N] offsets were read from, and a line saying they come from disassembly and were not run on a console. The offsets look consistent (each IsSet flag sits 0x20 after its getter, and Attribute::getName at 0x10 ends where getType at 0x30 begins), so this is only to make the source checkable. The "Response accessors throw" line in the Matchmaking debt entry is now slightly stale too.

@JJenkx

JJenkx commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 88a3bbd335, merged onto main 69c308e1bb (b92989d3e3, 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_strings passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

Copy link
Copy Markdown

Progress report (0294cba → 88a3bbd)

📈 System libraries: 39.9% (+0.03%, +10 implemented functions)

✅ 10 implemented
Library Name
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V113PlayerForRead11getTeamNameEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead11getTeamNameEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V118PlayerForOfferRead11getTicketIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V120GetOfferResponseBody10getOfferIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V120GetOfferResponseBody14getRulesetNameEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V121GetTicketResponseBody11getTicketIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V121GetTicketResponseBody14getRulesetNameEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V18Location16getGameSessionIdEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Attribute7getNameEv
libSceNpCppWebApi _ZNK3sce2Np9CppWebApi11Matchmaking2V19Attribute8getValueEv

Changed libraries (implemented exports)

Library Before After Change
libSceNpCppWebApi 1332/1778 (74.92%) 1342/1778 (75.48%) +0.56%

@oneandonlydean
oneandonlydean merged commit c190819 into boykopovar:main Nov 13, 2026
15 of 18 checks passed
@Opensource55
Opensource55 deleted the feat/npcpp-matchmaking-string-accessors branch November 14, 2026 02:49
@Opensource55

Copy link
Copy Markdown
Contributor Author

All three points, now that this has merged.

  1. The module. Decrypted libSceNpCppWebApi.prx of Demon's Souls, PPSA01341 v01.007.000, sha256 d03d64abc6f82a2a6b0b9e992782f98b7f488fd225a8553132b41e23bdad5b10. The lea rax,[rdi+N] sequences come from its disassembly (capstone over the program headers, no symbols needed). Nothing was executed on a console — the offsets are pinned by the host tests instead.

  2. The stale sentence was real, and main still has it. It is not fixed by this PR. feat(libSceNpCppWebApi): answer the Matchmaking model accessors #19481 carries the fix as 914559d5ac, changing Response accessors throw: ... to Unanswered response-body accessors throw: ..., which matches what the two entries now describe.

  3. The same fingerprint is in the body of feat(libSceNpCppWebApi): answer the Matchmaking model accessors #19481, feat(libSceNpCppWebApi): answer the Leaderboards board definition accessors #19503 and feat(libSceNpCppWebApi): answer the last value accessors of five APIs #19546.

Thanks for the pass.

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