Repository navigation
fix(libSceNpCppWebApi): return the Matchmaking string members by address - #19511
Conversation
…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.
|
@Opensource55 I reviewed 88a3bbd and passed it. The ten getters now return |
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
Progress report (0294cba → 88a3bbd)📈 System libraries: 39.9% (+0.03%, +10 implemented functions) ✅ 10 implemented
Changed libraries (implemented exports)
|
|
All three points, now that this has merged.
Thanks for the pass. |
What
Ten
Matchmaking2V1accessors are declaredint, butlibSceNpCppWebApi.prx(Demon's Souls, PPSA01341) answers them with an address, not a value:PlayerForRead::getTeamNamelea rax, [rdi + 0x38]intconst CommonString*PlayerForOfferRead::getTeamNamelea rax, [rdi + 0x38]intconst CommonString*PlayerForOfferRead::getTicketIdlea rax, [rdi + 0x60]intconst CommonString*GetOfferResponseBody::getOfferIdlea rax, [rdi + 0x30]intconst CommonString*GetOfferResponseBody::getRulesetNamelea rax, [rdi + 0x58]intconst CommonString*GetTicketResponseBody::getTicketIdlea rax, [rdi + 0x30]intconst CommonString*GetTicketResponseBody::getRulesetNamelea rax, [rdi + 0x58]intconst CommonString*Location::getGameSessionIdlea rax, [rdi + 0x10]intconst CommonString*Attribute::getNamelea rax, [rdi + 0x10]intconst CommonString*Attribute::getValuelea rax, [rdi + 0x38]intconst 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::getCommentis declared and implemented exactly this way and returnsself + 0x18.Why
CommonStringand notvoid*Each of these members is 32 bytes, and the module proves it: every accessor's
IsSetflag sits exactly oneCommonStringpast its ownlea.leateamName0x38teamNameIsSet@0x580x20PlayerForOfferRead::ticketId0x60ticketIdIsSet@0x800x20offerId0x30offerIdIsSet@0x500x20rulesetName0x58rulesetNameIsSet@0x780x20gameSessionId0x10gameSessionIdIsSet@0x300x20Attribute::getNameat0x10ends whereAttribute::getTypereads its four bytes, at0x30— the same 32-byte window.Attribute::getValueat0x38has no flag of its own but is the same shape.CommonStringininclude/Api.hppis{ int32 referenceCount; char* buffer; uint64 bufferSize; void* libContext; }= 32 bytes, so the arithmetic closes.Verification
guest_np_cpp_web_api_matchmaking_stringspasses.tools/check_conventions.py --base upstream/mainpasses.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:buffer + offset, so a wrong offset or a truncated return fails;Checklist
main; no other open PR implements the same functions — the 1504 other open PRs were scanned by file list and patch; only feat(libSceNpCppWebApi): complete the InGameCatalog and Leaderboards offline surface #13206, feat(libSceNpCppWebApi): allocate String, Vector and IntrusivePtr objects from the LibContext #16018 and feat(libSceNpCppWebApi): implement the shared transaction bookkeeping #16052 touch thisExport.cpp, and none of them defines these symbolsNotImplemented_nid_no_patch); no silent stubs added.mdfiles or images added to the repository