feat(libSceNpCppWebApi): implement Common::Binary as the module does #12808

Merged
edubox merged 4 commits from upstream-pr/12808 into main 2026-11-04 05:34:45 +00:00
edubox commented 2026-10-29 10:12:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-29T10:12:02Z.


What

Common::Binary now follows the module bundled with PPSA21564/PPSA23732 (builds J03093737/J03341606). Binary::size and Binary::getBinary were NotImplemented_nid_no_patch stubs, although 17 dumps import them; the rest of the class was not exported.

The layout is the same 0x20-byte shape as Common::String:

Offset Field
+0x00 32-bit reference count
+0x08 buffer
+0x10 size
+0x18 LibContext*

Implemented exports, with the module addresses used as the contract:

Export Module address Behaviour
Binary::Binary(LibContext*) 0x15600 zeroes the count, buffer and size; stores the context
Binary::~Binary / clear 0x15630 / 0x15670 frees the buffer, clears buffer and size
Binary::intrusive_ptr_add_ref / sub_ref 0x156b0 / 0x156c0 returns the new / previous count
Binary::getBinary / size 0x156d0 / 0x156e0 returns +0x08 / +0x10
Binary::setBinary(void const*, unsigned long) 0x156f0 replaces the buffer; 0x80553504 on allocation failure
Binary::appendBinary(void const*, unsigned long) 0x15770 grows the buffer and appends; 0x80553504 on allocation failure

Allocation uses the host allocator, the same limitation already documented for Common::String; setBinary/appendBinary return 0x80553503 for a null source with a non-zero size, which the module does not check.

Tested

Linux x86-64, GCC 16.2.1, Release with BUILD_TESTING=ON, based on main f99d7fece3:

  • ctest --test-dir build -R '^guest_np_cpp_web_api': 8/8 passed, including the new guest_np_cpp_web_api_binary (constructor/destructor, set/append/clear, null-source guards, reference counts and guard bytes).
  • python3 tools/check_conventions.py --base origin/main passes.
  • python3 tools/pr_overlap.py --branch feat/npcpp-common-binary --jobs 32 reports no pull request implementing these exports.
  • No title run.

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: #10925
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5066126226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12808). Originally posted by [edubox](https://github.com/edubox) on 2026-10-29T10:12:02Z. --- ### What `Common::Binary` now follows the module bundled with PPSA21564/PPSA23732 (builds `J03093737`/`J03341606`). `Binary::size` and `Binary::getBinary` were `NotImplemented_nid_no_patch` stubs, although 17 dumps import them; the rest of the class was not exported. The layout is the same 0x20-byte shape as `Common::String`: | Offset | Field | |---|---| | `+0x00` | 32-bit reference count | | `+0x08` | buffer | | `+0x10` | size | | `+0x18` | `LibContext*` | Implemented exports, with the module addresses used as the contract: | Export | Module address | Behaviour | |---|---|---| | `Binary::Binary(LibContext*)` | `0x15600` | zeroes the count, buffer and size; stores the context | | `Binary::~Binary` / `clear` | `0x15630` / `0x15670` | frees the buffer, clears buffer and size | | `Binary::intrusive_ptr_add_ref` / `sub_ref` | `0x156b0` / `0x156c0` | returns the new / previous count | | `Binary::getBinary` / `size` | `0x156d0` / `0x156e0` | returns `+0x08` / `+0x10` | | `Binary::setBinary(void const*, unsigned long)` | `0x156f0` | replaces the buffer; `0x80553504` on allocation failure | | `Binary::appendBinary(void const*, unsigned long)` | `0x15770` | grows the buffer and appends; `0x80553504` on allocation failure | Allocation uses the host allocator, the same limitation already documented for `Common::String`; `setBinary`/`appendBinary` return `0x80553503` for a null source with a non-zero size, which the module does not check. ### Tested Linux x86-64, GCC 16.2.1, Release with `BUILD_TESTING=ON`, based on `main` `f99d7fece3`: - `ctest --test-dir build -R '^guest_np_cpp_web_api'`: **8/8 passed**, including the new `guest_np_cpp_web_api_binary` (constructor/destructor, set/append/clear, null-source guards, reference counts and guard bytes). - `python3 tools/check_conventions.py --base origin/main` passes. - `python3 tools/pr_overlap.py --branch feat/npcpp-common-binary --jobs 32` reports no pull request implementing these exports. - No title run. ### Checklist - [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: #10925 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!12808
No description provided.