Repository navigation
feat(libSceNpCppWebApi): answer the Matchmaking DateTime accessors - #19500
oneandonlydean merged 3 commits into
Conversation
`libSceNpCppWebApi.prx` in Demon's Souls (PPSA01341) reads each of these
from one eight-byte slot, with a one-byte flag in the byte directly after
it:
GetOfferResponseBody::getCreatedDateTime mov rax, [rdi + 0xe8]
GetOfferResponseBody::createdDateTimeIsSet movzx eax, byte [rdi + 0xf0]
GetOfferResponseBody::getUpdatedDateTime mov rax, [rdi + 0xf8]
GetOfferResponseBody::updatedDateTimeIsSet movzx eax, byte [rdi + 0x100]
GetTicketResponseBody::getCreatedDateTime mov rax, [rdi + 0x130]
GetTicketResponseBody::createdDateTimeIsSet movzx eax, byte [rdi + 0x138]
GetTicketResponseBody::getUpdatedDateTime mov rax, [rdi + 0x140]
GetTicketResponseBody::updatedDateTimeIsSet movzx eax, byte [rdi + 0x148]
The getters, however, were declared `int` in `include/Api.hpp`, which
cannot carry what the module returns: the value comes back in `rax` as
eight bytes, and `0x1122334455667788` through an `int` leaves only
`0x55667788`. So the four declarations change to `std::uint64_t` and the
bodies read eight bytes; the four flags keep `int`, since `movzx` of a
single byte yields 0 or 1.
Three things back the widening rather than it being a guess:
- The module leaves the upper half in `rax`, not `eax`, so it is a
64-bit return, and the tree already reads this exact shape the same
way in two other places: `Leaderboards2V1::Entry::getScore` and
`TitleCloudStorage2V1::DataStatus::getLastUpdatedDateTime` are both
`std::uint64_t` over `mov rax, qword ptr [rdi + N]`.
- The same API passes a `DateTime` around as `SceRtcTick`:
`Leaderboards2V1::RecordScoreRequestBody::setComparedDateTime` takes
`const SceRtcTick&`, and a tick is one 64-bit count.
- Every flag is its own byte right after its value, in both bodies, so
the pair is a value plus an optional marker rather than a pointer that
could be null-checked instead.
`guest_np_cpp_web_api_matchmaking_datetime` stores values whose high
halves are non-zero, so a 32-bit return fails outright, and it checks
the flags both ways. It also writes the bytes on either side of each
value to prove the read window is exactly eight bytes. The library's
measured count moves from 1332 to 1340, and all eight symbols appear as
NID exports in the patched prx; the other nine suites of this library
still pass, 18 of 18 in total.
|
Widening the four getters to
If #19481 merges first, the first point is one edit of the same sentence for both PRs. |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 34b6630c64:
- Conventions:
tools/check_conventions.pyfailed;git diff --checkclean.(pull request): error: [pr-template] Fill in the pull request template: add the '### What' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template 3 findings, 3 errors; GitHub shows at most 10 error annotations, the job summary lists all - Build:
guest_np_cpp_web_api_matchmaking_datetime_testsbuilt cleanly. - CTest (
guest_np_cpp_web_api_matchmaking_datetime):1/1 Test #4073: guest_np_cpp_web_api_matchmaking_datetime ... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceNpCppWebApi/Export.cpp,core/libs/prx/libSceNpCppWebApi/include/Api.hppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4073: guest_np_cpp_web_api_matchmaking_datetime ...Subprocess aborted***Exception: 1.91 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified in core/libs/prx/libSceNpCppWebApi/Export.cpp that GetOfferResponseBody getCreatedDateTime and getUpdatedDateTime copy 8-byte values from offsets 0xe8 and 0xf8 via std::memcpy, returning std::uint64_t and avoiding unaligned dereference undefined behavior.
- Verified in core/libs/prx/libSceNpCppWebApi/Export.cpp that GetTicketResponseBody getCreatedDateTime and getUpdatedDateTime read 8-byte values from offsets 0x130 and 0x140 via std::memcpy, accurately reflecting the 64-bit rax return seen in disassembly.
- Verified in core/libs/prx/libSceNpCppWebApi/Export.cpp that createdDateTimeIsSet and updatedDateTimeIsSet on both response bodies check the one-byte flag directly following the value (offsets 0xf0, 0x100, 0x138, and 0x148) and return a normalized 0 or 1 matching movzx semantics.
- Verified in core/libs/prx/libSceNpCppWebApi/include/Api.hpp that the declarations for all four timestamp getters were widened to std::uint64_t with matching APS5_VABI signatures, preserving LP64 and LLP64 portability between Linux and Windows.
- Verified strict AGENTS.md compliance across modified files, ensuring no illegal code comments were introduced (only the permitted namespace end in GuestNpCppWebApiMatchmakingDateTime.cpp) and no prohibited stubs or special-cased values exist.
- Verified that core/libs/tests/GuestNpCppWebApiMatchmakingDateTime.cpp comprehensively exercises the accessors with non-zero upper 32-bit timestamps, tests flag values beyond single-bit masks (0x80), and verifies that reads do not bleed into neighboring struct fields.
- Note: the AI-assisted checkbox can stay.
Requesting changes for the points above.
|
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. |
The four timestamps and their four flags this branch answers had no debt entry. The new one lists them with their offsets, says they were inspected statically and not executed, and records that the getters were declared `int` before this change, which drops the upper half of the word the module returns in `rax`. It also states that these eight were read from the PPSA01341 v01.007.000 build only, so no cross-build comparison exists for them, and that the values, the objects' other fields and any console value remain unverified.
|
Thanks for the Linux run and the negative control — that is the check I could not do here (no console, and the Windows host does not run these tests on PRs). Conventions. The three That is the checker from the base branch, so it is the same rule the job runs; the job should go green on the next event. Debt entry. On the build question: only PPSA01341 is readable here. The PPSA21564 |
Progress report (135da47 → 41be57d)📈 System libraries: 40.07% (+0.02%, +8 implemented functions) ✅ 8 implemented
Changed libraries (implemented exports)
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 41be57d451:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_np_cpp_web_api_matchmaking_datetime_testsbuilt cleanly. - CTest (
guest_np_cpp_web_api_matchmaking_datetime):1/1 Test #4084: guest_np_cpp_web_api_matchmaking_datetime ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceNpCppWebApi/Export.cpp,core/libs/prx/libSceNpCppWebApi/include/Api.hppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4084: guest_np_cpp_web_api_matchmaking_datetime ...Subprocess aborted***Exception: 1.42 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified in core/libs/prx/libSceNpCppWebApi/Export.cpp that GetOfferResponseBody (+0xe8, +0xf0, +0xf8, +0x100) and GetTicketResponseBody (+0x130, +0x138, +0x140, +0x148) accessors match the static disassembly offsets from the PPSA01341 module.
- Verified in core/libs/prx/libSceNpCppWebApi/include/Api.hpp and Export.cpp that getCreatedDateTime and getUpdatedDateTime signatures return std::uint64_t rather than int, matching the 64-bit rax register return and avoiding upper-half timestamp truncation.
- Verified memory safety and undefined behavior avoidance: std::memcpy correctly loads 64-bit integer values without unaligned access or strict aliasing hazards, and the boolean flags properly normalize non-zero values via != 0.
- Verified cross-platform LP64 (Linux) and LLP64 (Windows) portability for std::uint64_t and APS5_VABI calling conventions.
- Verified AGENTS.md compliance: zero forbidden comments in source code, no fake success stubs, no hardcoded game-specific branch hacks, and the technical debt is documented in docs/dev/debt/libSceNpCppWebApi.md.
- Verified test coverage in core/libs/tests/GuestNpCppWebApiMatchmakingDateTime.cpp: exercises high-half 64-bit values, zero values, boolean flag values including 0x80, and neighbouring slot isolation.
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
What
Answers eight
Matchmaking2V1accessors that wereNotImplementedstubs, and corrects the four that were declared with a return type too narrow to hold what the console returns.The offsets
Read off
libSceNpCppWebApi.prxin Demon's Souls (PPSA01341). Every value is one eight-byte slot with a one-byte flag in the byte directly after it:GetOfferResponseBody::getCreatedDateTimemov rax, [rdi + 0xe8]GetOfferResponseBody::createdDateTimeIsSetmovzx eax, byte [rdi + 0xf0]GetOfferResponseBody::getUpdatedDateTimemov rax, [rdi + 0xf8]GetOfferResponseBody::updatedDateTimeIsSetmovzx eax, byte [rdi + 0x100]GetTicketResponseBody::getCreatedDateTimemov rax, [rdi + 0x130]GetTicketResponseBody::createdDateTimeIsSetmovzx eax, byte [rdi + 0x138]GetTicketResponseBody::getUpdatedDateTimemov rax, [rdi + 0x140]GetTicketResponseBody::updatedDateTimeIsSetmovzx eax, byte [rdi + 0x148]The declaration change, and why it is not optional
The four getters were declared
int. The module returns them inrax, eight bytes; through anint,0x1122334455667788becomes0x55667788. Implementing them as declared would have produced code that compiles, passes a naive test, and silently drops every timestamp's upper half.Three independent reasons to widen to
std::uint64_trather than pick something new:rax, noteax, so the return is 64-bit. The tree already reads this exact instruction shape as a 64-bit value elsewhere:Leaderboards2V1::Entry::getScoreandTitleCloudStorage2V1::DataStatus::getLastUpdatedDateTimeare bothstd::uint64_tovermov rax, qword ptr [rdi + N].SceRtcTick:Leaderboards2V1::RecordScoreRequestBody::setComparedDateTimetakesconst SceRtcTick&, and a tick is a single 64-bit count.The four flags keep
int:movzxof one byte yields 0 or 1, which fits.No other translation unit references these symbols, so the widening touches nothing but the four declarations.
Verification
guest_np_cpp_web_api_matchmaking_datetimepasses.libSceNpCppWebApi.prx.tools/check_conventions.py --base upstream/mainpasses.Scope note
Same-family accessors that need a different treatment are left alone here:
GetRankingResponseBody::getLastUpdatedDateTimeis declaredconst void*, which is eight bytes wide but the wrong type, and it is not aMatchmaking2V1symbol. I would rather fix that separately than fold an unrelated declaration change into this one.AI-assisted: yes.
Tested
guest_np_cpp_web_api_matchmaking_datetimedeliberately uses fixtures whose high halves are non-zero (0x1122334455667788,0x99aabbccddeeff00,0xf0e0d0c0b0a09080,0xffffffff00000001), so a 32-bit return fails rather than passing by accident. It also:0x80to show it is a flag and not the byte value);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