feat(libSceNpCppWebApi): read size and operator[] of the Sku, Container and PlayerSession vectors from host bodies #11248

Merged
AlexFigas merged 1 commit from upstream-pr/11248 into main 2026-10-26 22:05:51 +00:00
AlexFigas commented 2026-10-25 22:35:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlexFigas on 2026-10-25T22:35:12Z.


What

Four Vector accessors were NotImplemented stubs:

  • Vector<IntrusivePtr<InGameCatalog::V5::Sku>>::size
  • Vector<IntrusivePtr<InGameCatalog::V5::Container>>::size
  • Vector<IntrusivePtr<InGameCatalog::V5::Container>>::operator[]
  • Vector<IntrusivePtr<SessionManager::V1::PlayerSession>>::operator[]

They now do what the empty, size and operator[] of the other element types already do, which the Vector debt entries describe:

  • size returns 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 holds IntrusivePtr elements. It throws when the vector has no body or holds anything else.

Two shared helpers, HostVectorSize and HostVectorElement, 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:

Export Module
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 check

operator[] here has no bounds check either.

The size of Vector<IntrusivePtr<UserProfile::V1::BasicPresence>> and of Vector<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_api passes all 4 tests. guest_np_cpp_web_api_offline gains TestVectorSizeAndElements, which checks:

  • both sizes return 0 for a vector without a body, and both operator[]s throw on one;
  • after two pushBacks through the JoinableUser vector, both sizes return 2, and both operator[]s return the two elements in order and next to each other;
  • destroying the vector gives back the references it took;
  • every accessor throws on a foreign body.

Also run:

  • python3 tools/check_conventions.py --base origin/main passes.
  • python3 tools/pr_overlap.py --branch feat/npcppwebapi-vector-size-and-index reports no overlap.
  • git merge-tree against #9612, #10925, #11221, #11235, #10832 and #9015 merges cleanly.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5009400599 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11248). Originally posted by [AlexFigas](https://github.com/AlexFigas) on 2026-10-25T22:35:12Z. --- ### What Four `Vector` accessors were `NotImplemented` stubs: - `Vector<IntrusivePtr<InGameCatalog::V5::Sku>>::size` - `Vector<IntrusivePtr<InGameCatalog::V5::Container>>::size` - `Vector<IntrusivePtr<InGameCatalog::V5::Container>>::operator[]` - `Vector<IntrusivePtr<SessionManager::V1::PlayerSession>>::operator[]` They now do what the `empty`, `size` and `operator[]` of the other element types already do, which the `Vector` debt entries describe: - `size` returns 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 holds `IntrusivePtr` elements. It throws when the vector has no body or holds anything else. Two shared helpers, `HostVectorSize` and `HostVectorElement`, 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: | Export | Module | |---|---| | `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 check | `operator[]` here has no bounds check either. The `size` of `Vector<IntrusivePtr<UserProfile::V1::BasicPresence>>` and of `Vector<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 <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> On Ubuntu 24.04 under WSL2 (GCC 13.3, Release), `ctest --test-dir build -R np_cpp_web_api` passes all 4 tests. `guest_np_cpp_web_api_offline` gains `TestVectorSizeAndElements`, which checks: - both `size`s return 0 for a vector without a body, and both `operator[]`s throw on one; - after two `pushBack`s through the `JoinableUser` vector, both `size`s return 2, and both `operator[]`s return the two elements in order and next to each other; - destroying the vector gives back the references it took; - every accessor throws on a foreign body. Also run: - `python3 tools/check_conventions.py --base origin/main` passes. - `python3 tools/pr_overlap.py --branch feat/npcppwebapi-vector-size-and-index` reports no overlap. - `git merge-tree` against #9612, #10925, #11221, #11235, #10832 and #9015 merges cleanly. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 22:36:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T22:36:05Z.

Review: APPROVED


I checked the shared helpers against the existing VectorBody layout and append/destructor paths. HostVectorSize handles a null body and rejects foreign bodies; HostVectorElement additionally 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 documented operator[] behavior and the bundled module evidence.

git diff --check and current-main conventions pass. The author reports the focused np_cpp_web_api CTest 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645703039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11248#pullrequestreview-5645703039). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T22:36:05Z. **Review:** APPROVED --- I checked the shared helpers against the existing `VectorBody` layout and append/destructor paths. `HostVectorSize` handles a null body and rejects foreign bodies; `HostVectorElement` additionally 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 documented `operator[]` behavior and the bundled module evidence. `git diff --check` and current-main conventions pass. The author reports the focused `np_cpp_web_api` CTest 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11248
No description provided.