feat(libSceNpWebApi2): implement the internal and presence initializers #8485

Merged
orezraey merged 2 commits from upstream-pr/8485 into main 2026-10-21 04:49:29 +00:00
orezraey commented 2026-10-20 13:30:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-20T13:30:42Z.


What

sceNpWebApi2IntInitialize, sceNpWebApi2IntInitialize2 and sceNpWebApi2InitializeForPresence were declared from shadPS4's prototypes and threw NotImplemented. They now create a library context the way sceNpWebApi2Initialize already does, following shadPS4's implementation on the PS4:

  • sceNpWebApi2IntInitialize and sceNpWebApi2IntInitialize2 take an argument structure and return SCE_NP_WEBAPI2_ERROR_INVALID_ARGUMENT (0x80553402, as in shadPS4's np_error.h) for a null pointer or a struct_size other than the structure's size; otherwise they create a context with its pool_size.
  • sceNpWebApi2InitializeForPresence(lib_http_ctx_id, pool_size) creates a context with pool_size.
  • NpWebApi2IntInitializeArgs (32 bytes) and NpWebApi2IntInitialize2Args (40 bytes) in SceTypes.hpp follow shadPS4's declarations, with static_asserts on both sizes.
  • sceNpWebApi2Initialize and the three share a CreateLibraryContext(poolSize) helper, so sceNpWebApi2GetMemoryPoolStats and sceNpWebApi2Terminate treat the new contexts like the existing ones.

docs/dev/debt/libSceNpWebApi2.md records what is not modelled: shadPS4 also stores a context type (2 for the internal initializers, 3 for presence), the name and the push configuration group, and refuses more than 0x8000 contexts; none of this is kept here, and nothing is measured on a PS5. The two multipart exports stay in the existing entry.

Tested

  • Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.
  • guest_np_web_api2 now also checks, for each new entry point, the returned context, its pool size through sceNpWebApi2GetMemoryPoolStats, SCE_NP_WEBAPI2_ERROR_INVALID_ARGUMENT for a null pointer and a wrong struct_size, and that sceNpWebApi2Terminate removes the context. It passes.
  • tools/progress.py --module libSceNpWebApi2: 31 of 39 implemented (28 on main).
  • tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py could not compare #5965, #6044, #6977, #7081 and #7412, which conflict with main and share SceTypes.hpp or the library tests; none of their diffs touches these exports or structures.
  • Not tested: a title that calls these exports, Linux or macOS.

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 (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4936494489 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8485). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-20T13:30:42Z. --- ### What `sceNpWebApi2IntInitialize`, `sceNpWebApi2IntInitialize2` and `sceNpWebApi2InitializeForPresence` were declared from shadPS4's prototypes and threw `NotImplemented`. They now create a library context the way `sceNpWebApi2Initialize` already does, following [shadPS4's implementation](https://github.com/shadps4-emu/shadPS4/blob/8d50471b7dc141dd700b51276b8edd1f293bce26/src/core/libraries/np/np_web_api2/np_web_api2.cpp#L174-L222) on the PS4: - `sceNpWebApi2IntInitialize` and `sceNpWebApi2IntInitialize2` take an argument structure and return `SCE_NP_WEBAPI2_ERROR_INVALID_ARGUMENT` (`0x80553402`, as in shadPS4's `np_error.h`) for a null pointer or a `struct_size` other than the structure's size; otherwise they create a context with its `pool_size`. - `sceNpWebApi2InitializeForPresence(lib_http_ctx_id, pool_size)` creates a context with `pool_size`. - `NpWebApi2IntInitializeArgs` (32 bytes) and `NpWebApi2IntInitialize2Args` (40 bytes) in `SceTypes.hpp` follow [shadPS4's declarations](https://github.com/shadps4-emu/shadPS4/blob/8d50471b7dc141dd700b51276b8edd1f293bce26/src/core/libraries/np/np_web_api2/np_web_api2.h#L15-L31), with `static_assert`s on both sizes. - `sceNpWebApi2Initialize` and the three share a `CreateLibraryContext(poolSize)` helper, so `sceNpWebApi2GetMemoryPoolStats` and `sceNpWebApi2Terminate` treat the new contexts like the existing ones. `docs/dev/debt/libSceNpWebApi2.md` records what is not modelled: shadPS4 also stores a context type (2 for the internal initializers, 3 for presence), the name and the push configuration group, and refuses more than 0x8000 contexts; none of this is kept here, and nothing is measured on a PS5. The two multipart exports stay in the existing entry. ### Tested - Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. - `guest_np_web_api2` now also checks, for each new entry point, the returned context, its pool size through `sceNpWebApi2GetMemoryPoolStats`, `SCE_NP_WEBAPI2_ERROR_INVALID_ARGUMENT` for a null pointer and a wrong `struct_size`, and that `sceNpWebApi2Terminate` removes the context. It passes. - `tools/progress.py --module libSceNpWebApi2`: 31 of 39 implemented (28 on `main`). - `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` could not compare #5965, #6044, #6977, #7081 and #7412, which conflict with `main` and share `SceTypes.hpp` or the library tests; none of their diffs touches these exports or structures. - Not tested: a title that calls these exports, Linux or macOS. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-20 13:31:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:31:32Z.


Progress report (2185dbf → a9a0c05)

📈 System libraries: 64.51% (+0.05%, +3 implemented functions)

✅ 3 implemented
Library Name
libSceNpWebApi2 sceNpWebApi2InitializeForPresence
libSceNpWebApi2 sceNpWebApi2IntInitialize
libSceNpWebApi2 sceNpWebApi2IntInitialize2
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6292049111 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8485#issuecomment-6292049111). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T13:31:32Z. --- <!-- progress-report --> ### Progress report (2185dbf → a9a0c05) 📈 **System libraries**: 64.51% (+0.05%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | libSceNpWebApi2 | `sceNpWebApi2InitializeForPresence` | | libSceNpWebApi2 | `sceNpWebApi2IntInitialize` | | libSceNpWebApi2 | `sceNpWebApi2IntInitialize2` | </details>
github-actions[bot] commented 2026-10-20 13:47:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T13:47:11Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5965 core/libs/SceTypes.hpp
PR 6044 core/libs/tests/GuestNpWebApi2.cpp
PR 6977 core/libs/SceTypes.hpp
PR 7081 core/libs/SceTypes.hpp
PR 7412 core/libs/SceTypes.hpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6292368508 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8485#issuecomment-6292368508). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T13:47:11Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5965](https://www.github.com/boykopovar/AnyPS5/pull/5965) | `core/libs/SceTypes.hpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestNpWebApi2.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/SceTypes.hpp` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/SceTypes.hpp` | | [PR 7412](https://www.github.com/boykopovar/AnyPS5/pull/7412) | `core/libs/SceTypes.hpp` |
nikowolf123 commented 2026-10-20 19:05:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T19:05:09Z.


docs/dev/debt/libSceNpWebApi2.md#L14 still says "The pool size is the one given to sceNpWebApi2Initialize". After this change that covers only one of the four initializers. CreateLibraryContext stores every new context's pool in g_pools, and sceNpWebApi2GetMemoryPoolStats reports it from there. For example, a context from sceNpWebApi2IntInitialize with pool_size = 0x4000 reports 0x4000, although nothing was passed to sceNpWebApi2Initialize. The new test checks this for all three new functions at L70, L75 and L79. I'd suggest naming the initializer that created the context instead:

-The pool size is the one given to `sceNpWebApi2Initialize`, and the peak and current use are 0.
+The pool size is the one given to the initializer that created the context, and the peak and current use are 0.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298915895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8485#issuecomment-6298915895). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T19:05:09Z. --- [`docs/dev/debt/libSceNpWebApi2.md#L14`](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/docs/dev/debt/libSceNpWebApi2.md#L14) still says "The pool size is the one given to `sceNpWebApi2Initialize`". After this change that covers only one of the four initializers. [`CreateLibraryContext`](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/core/libs/prx/libSceNpWebApi2/Export.cpp#L25-L30) stores every new context's pool in `g_pools`, and [`sceNpWebApi2GetMemoryPoolStats`](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/core/libs/prx/libSceNpWebApi2/Export.cpp#L101-L107) reports it from there. For example, a context from `sceNpWebApi2IntInitialize` with `pool_size = 0x4000` reports 0x4000, although nothing was passed to `sceNpWebApi2Initialize`. The new test checks this for all three new functions at [L70](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/core/libs/tests/GuestNpWebApi2.cpp#L70), [L75](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/core/libs/tests/GuestNpWebApi2.cpp#L75) and [L79](https://github.com/boykopovar/AnyPS5/blob/812958b09662ca4af6380e462a55e505e3697354/core/libs/tests/GuestNpWebApi2.cpp#L79). I'd suggest naming the initializer that created the context instead: ```diff -The pool size is the one given to `sceNpWebApi2Initialize`, and the peak and current use are 0. +The pool size is the one given to the initializer that created the context, and the peak and current use are 0. ```
orezraey commented 2026-10-20 19:50:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-20T19:50:37Z.


Thanks, applied your wording in a9a0c05af: the entry now says the pool size is the one given to the initializer that created the context.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300016710 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8485#issuecomment-6300016710). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-20T19:50:37Z. --- Thanks, applied your wording in a9a0c05af: the entry now says the pool size is the one given to the initializer that created the context.
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!8485
No description provided.