feat(libSceNpCppWebApi): read size and operator[] of the Sku, Container and PlayerSession vectors from host bodies #11248
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11248"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by AlexFigas on 2026-10-25T22:35:12Z.
What
Four
Vectoraccessors wereNotImplementedstubs:Vector<IntrusivePtr<InGameCatalog::V5::Sku>>::sizeVector<IntrusivePtr<InGameCatalog::V5::Container>>::sizeVector<IntrusivePtr<InGameCatalog::V5::Container>>::operator[]Vector<IntrusivePtr<SessionManager::V1::PlayerSession>>::operator[]They now do what the
empty,sizeandoperator[]of the other element types already do, which theVectordebt entries describe:sizereturns 0 for a vector that has no body and the element count of a body this library created. It throws on any other body.operator[]returns the element of a body this library created that holdsIntrusivePtrelements. It throws when the vector has no body or holds anything else.Two shared helpers,
HostVectorSizeandHostVectorElement, hold this logic.The module bundled with PPSA21564 (
sce_module/libSceNpCppWebApi.prx, the library's own code) computes the same values on its own layout:Vector<...Sku>::size(0xc23d0),Vector<...Container>::size(0xa8290)(end - begin) / 0x18, from[rdi + 0x28] - [rdi + 0x18]Vector<...Container>::operator[](0xa8390),Vector<...PlayerSession>::operator[](0x287f50)begin + index * 0x18, no bounds checkoperator[]here has no bounds check either.The
sizeofVector<IntrusivePtr<UserProfile::V1::BasicPresence>>and ofVector<unsigned long>is the same one-liner. I left it out because the UserProfile debt line that says they throw sits next to the line #10832 rewrites. It can follow once that PR lands.Tested
On Ubuntu 24.04 under WSL2 (GCC 13.3, Release),
ctest --test-dir build -R np_cpp_web_apipasses all 4 tests.guest_np_cpp_web_api_offlinegainsTestVectorSizeAndElements, which checks:sizes return 0 for a vector without a body, and bothoperator[]s throw on one;pushBacks through theJoinableUservector, bothsizes return 2, and bothoperator[]s return the two elements in order and next to each other;Also run:
python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/pr_overlap.py --branch feat/npcppwebapi-vector-size-and-indexreports no overlap.git merge-treeagainst #9612, #10925, #11221, #11235, #10832 and #9015 merges cleanly.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T22:36:05Z.
Review: APPROVED
I checked the shared helpers against the existing
VectorBodylayout and append/destructor paths.HostVectorSizehandles a null body and rejects foreign bodies;HostVectorElementadditionally restricts access to the intrusive-pointer element kind. The four exports use the helper matching their ABI, and the new test exercises null/owned/foreign bodies, contiguous order, and retained references. The lack of an operator[] bounds check matches the documentedoperator[]behavior and the bundled module evidence.git diff --checkand current-main conventions pass. The author reports the focusednp_cpp_web_apiCTest suite passing 4/4 under Ubuntu 24.04/WSL2. I did not rerun the product test locally because the available build is relinker-only; hosted product jobs are skipped by policy. No concrete defect found.