feat(libSceNKWebKit): implement 64 field getters and setters read from the module #23475

Closed
RiverWhy wants to merge 3 commits from upstream-pr/23475 into main
RiverWhy commented 2026-11-19 04:12:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RiverWhy on 2026-11-19T04:12:56Z.


What

Implements 64 libSceNKWebKit exports whose body in the module is a single load from, or store into, this followed by ret. All 64 throw NotImplemented on main today. They extend the existing FieldGetters.cpp (45) and FieldSetters.cpp (19) in the same style: getters read the field, and setters check for a null object and store the argument.

Source: the libSceNKWebKit.sprx with SHA-256 3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d (the module the existing Constant-return exports and Field setters debt entries read as 11.00). Offsets and widths come from the body bytes:

Body Count Implemented as
mov off(%rdi),%al; ret 34 std::uint8_t getter (only al is defined)
mov off(%rdi),%rax; ret 6 std::uint64_t getter
movzwl off(%rdi),%eax; ret 2 std::uint16_t getter
mov off(%rdi),%eax; ret 1 std::uint32_t getter (HTMLInputElement::size)
vmovsd off(%rdi),%xmm0; ret 1 double getter (ProgressTracker::estimatedProgress)
lea off(%rdi),%rax; ret 1 address getter (HTMLFormElement::unsafeAssociatedElements)
mov %sil,off(%rdi); ret 11 byte setter
movb $imm,off(%rdi); ret 5 stores the constant (stopRunningTasks, setDidGCRecently, enable/disableICECandidateFiltering, InspectorTarget::pause)
16/32/64-bit store of si/esi/rsi 3 FrameView::setPaintBehavior, TextureMapperLayer::setID, InspectorController::setInspectorFrontendClient

Where main already reads the same field, the offsets agree. For example, TextureMapperLayer::setID stores at 0x2b0, where main's TextureMapperLayer::id reads, and getter/setter pairs added here (GCActivityCallback 0x23, FullGCActivityCallback 0x30, NetworkStorageSession 0x30/0x31, Page 0xe0, FrameView 0x390) use the same offset for both. None of these classes is constructed by AnyPS5 with a layout of its own; the only overlapping hand-written code, CrossOriginAccessControl.cpp, already implements that class's two accessors and is not touched.

How the table was produced: I recomputed each NID from the declared name and found it in the module's symbol table. I decoded each body twice, once from objdump output and once from the raw bytes, and both agree on all 64 kinds, offsets and constants. I generated the list against the current main; two accessors that main gained in the meantime were dropped.
Debt: the fragment docs/dev/debt/changes/feat-nkwebkit-module-field-accessors.md adds two Functional entries and removes the 46 inventory rows.
Overlap: I fetched every open PR head and diffed it against main. None removes any of these 64 stubs.

Tested

Linux Mint 22.3, GCC 13.3, Release:

  • The new nkwebkit_modulefieldaccessors test uses a 4 KiB object filled with 0xa5. Each getter reads back a distinct byte pattern placed at its offset, and the address getter returns object + offset. Each setter writes the pattern, or its constant, at exactly its offset and width with every other byte untouched. Every setter throws invalid_argument on a null object.
  • Negative control: moving MediaPlayer::muted from 0xd2 to 0xd3 makes the test fail.
  • Full NKWebKit suite: 146/146 nkwebkit_* tests pass, including the existing FieldGetters and FieldSetters tests.
  • tools/check_conventions.py passes.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

Summary by CodeRabbit

  • New Features
    • Expanded access to WebKit browser, media, loading, layout, and inspector state, with additional controls for page behavior and settings.
  • Bug Fixes
    • Improved reliability when accessing and updating WebKit state, including clearer handling of invalid access.
  • Documentation
    • Updated the developer change record to reflect the available accessors and export changes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5388675021 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23475). Originally posted by [RiverWhy](https://github.com/RiverWhy) on 2026-11-19T04:12:56Z. --- ### What Implements 64 `libSceNKWebKit` exports whose body in the module is a single load from, or store into, `this` followed by `ret`. All 64 throw `NotImplemented` on `main` today. They extend the existing `FieldGetters.cpp` (45) and `FieldSetters.cpp` (19) in the same style: getters read the field, and setters check for a null object and store the argument. Source: the `libSceNKWebKit.sprx` with SHA-256 `3af992253665387feeb5df90ff27dff683e3aa270cc4d92a0535b46ab18fa20d` (the module the existing *Constant-return exports* and *Field setters* debt entries read as 11.00). Offsets and widths come from the body bytes: | Body | Count | Implemented as | |---|---|---| | `mov off(%rdi),%al; ret` | 34 | `std::uint8_t` getter (only `al` is defined) | | `mov off(%rdi),%rax; ret` | 6 | `std::uint64_t` getter | | `movzwl off(%rdi),%eax; ret` | 2 | `std::uint16_t` getter | | `mov off(%rdi),%eax; ret` | 1 | `std::uint32_t` getter (`HTMLInputElement::size`) | | `vmovsd off(%rdi),%xmm0; ret` | 1 | `double` getter (`ProgressTracker::estimatedProgress`) | | `lea off(%rdi),%rax; ret` | 1 | address getter (`HTMLFormElement::unsafeAssociatedElements`) | | `mov %sil,off(%rdi); ret` | 11 | byte setter | | `movb $imm,off(%rdi); ret` | 5 | stores the constant (`stopRunningTasks`, `setDidGCRecently`, `enable`/`disableICECandidateFiltering`, `InspectorTarget::pause`) | | 16/32/64-bit store of `si`/`esi`/`rsi` | 3 | `FrameView::setPaintBehavior`, `TextureMapperLayer::setID`, `InspectorController::setInspectorFrontendClient` | Where `main` already reads the same field, the offsets agree. For example, `TextureMapperLayer::setID` stores at 0x2b0, where `main`'s `TextureMapperLayer::id` reads, and getter/setter pairs added here (`GCActivityCallback` 0x23, `FullGCActivityCallback` 0x30, `NetworkStorageSession` 0x30/0x31, `Page` 0xe0, `FrameView` 0x390) use the same offset for both. None of these classes is constructed by AnyPS5 with a layout of its own; the only overlapping hand-written code, `CrossOriginAccessControl.cpp`, already implements that class's two accessors and is not touched. How the table was produced: I recomputed each NID from the declared name and found it in the module's symbol table. I decoded each body twice, once from `objdump` output and once from the raw bytes, and both agree on all 64 kinds, offsets and constants. I generated the list against the current `main`; two accessors that `main` gained in the meantime were dropped. Debt: the fragment `docs/dev/debt/changes/feat-nkwebkit-module-field-accessors.md` adds two Functional entries and removes the 46 inventory rows. Overlap: I fetched every open PR head and diffed it against `main`. None removes any of these 64 stubs. ### Tested Linux Mint 22.3, GCC 13.3, Release: - The new `nkwebkit_modulefieldaccessors` test uses a 4 KiB object filled with 0xa5. Each getter reads back a distinct byte pattern placed at its offset, and the address getter returns `object + offset`. Each setter writes the pattern, or its constant, at exactly its offset and width with every other byte untouched. Every setter throws `invalid_argument` on a null object. - Negative control: moving `MediaPlayer::muted` from 0xd2 to 0xd3 makes the test fail. - Full NKWebKit suite: 146/146 `nkwebkit_*` tests pass, including the existing `FieldGetters` and `FieldSetters` tests. - `tools/check_conventions.py` passes. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Expanded access to WebKit browser, media, loading, layout, and inspector state, with additional controls for page behavior and settings. * **Bug Fixes** * Improved reliability when accessing and updating WebKit state, including clearer handling of invalid access. * **Documentation** * Updated the developer change record to reflect the available accessors and export changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
PrivacyOnion commented 2026-11-19 04:26:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T04:26:07Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against aa4250309f:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_modulefieldaccessors_tests built cleanly.
  • CTest (nkwebkit_modulefieldaccessors):
    1/1 Test #4593: nkwebkit_modulefieldaccessors ....   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/FieldGettersExports.hpp, core/libs/prx/libSceNKWebKit/include/FieldSettersExports.hpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp, core/libs/prx/libSceNKWebKit/src/FieldGetters.cpp, core/libs/prx/libSceNKWebKit/src/FieldSetters.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified mangling and ABI signatures in FieldGettersExports.hpp and FieldSettersExports.hpp match WebKit/JSC/WTF symbols and VABI convention
    • Verified null pointer handling in FieldSetters and FieldGetters behaves consistently without undefined behavior
    • Verified return types across all 64 functions (uint8_t, uint16_t, uint32_t, uint64_t, void*, double) match disassembled module instructions
    • Verified removal of duplicate/stub symbols from Export.cpp, InventoryExports.hpp, and LegacyExports.hpp without conflicting NID exports
    • Verified compliance with AGENTS.md regarding comment rules, technical debt conventions, and non-stubbed implementations

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969299251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23475#pullrequestreview-5969299251). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T04:26:07Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `aa4250309f`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_modulefieldaccessors_tests` built cleanly. - **CTest** (`nkwebkit_modulefieldaccessors`): ``` 1/1 Test #4593: nkwebkit_modulefieldaccessors .... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/FieldGettersExports.hpp`, `core/libs/prx/libSceNKWebKit/include/FieldSettersExports.hpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/LegacyExports.hpp`, `core/libs/prx/libSceNKWebKit/src/FieldGetters.cpp`, `core/libs/prx/libSceNKWebKit/src/FieldSetters.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified mangling and ABI signatures in FieldGettersExports.hpp and FieldSettersExports.hpp match WebKit/JSC/WTF symbols and VABI convention - Verified null pointer handling in FieldSetters and FieldGetters behaves consistently without undefined behavior - Verified return types across all 64 functions (uint8_t, uint16_t, uint32_t, uint64_t, void*, double) match disassembled module instructions - Verified removal of duplicate/stub symbols from Export.cpp, InventoryExports.hpp, and LegacyExports.hpp without conflicting NID exports - Verified compliance with AGENTS.md regarding comment rules, technical debt conventions, and non-stubbed implementations Looks Good To Me
MarcZX10 commented 2026-11-21 07:56:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:56:02Z.

Review: COMMENTED


Reviewed — comments

Changes are required before merge: resolve the test integration and confirm the newly implemented exports are registered in the runtime dispatch.

What I ran

Reviewed head 779e626397e1ba87ebbc7c0f93c1e3080d15b955 using the prepared diff and repo_read.py; no tests were run.

Results

Check Result Note
Changed code review passed Accessor bodies and direct unit test logic inspected
Test integration not run New test is not referenced by the existing test configuration
Runtime export registration not verified Registration path is not established by the inspected changes

Findings

Blocking

None verified.

Non-blocking

  • core/libs/prx/libSceNKWebKit/tests/ModuleFieldAccessors.cpp is not referenced by the CMakeLists.txt test discovery. That file adds tests for the new accessors, but the existing glob searches tests/*.cpp under core/libs/prx/libSceNKWebKit, and the new file is present there; the observed search for its name in the CMake file itself was empty. Verify the normal glob includes it and add an explicit test registration if the project’s test setup does not discover it.

Sources

Not verified

Read: FieldGettersExports.hpp, FieldSettersExports.hpp, FieldGetters.cpp, FieldSetters.cpp, ModuleFieldAccessors.cpp, debt change note, libSceNKWebKit.hpp, CMakeLists.txt, and the relevant prepared diff and metadata. Full text for Export.cpp and InventoryExports.hpp was excluded from the review folder; targeted reader checks confirmed their include structure, but export dispatch and all inventory edits were not audited. Author-reported test results were not rerun. No environment or toolchain checks were run.

To get this to a good state

Nothing is required. Optional: confirm the test is picked up by the CMake glob and verify registration for the new accessor implementations.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6003979408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23475#pullrequestreview-6003979408). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T07:56:02Z. **Review:** COMMENTED --- # Reviewed — comments Changes are required before merge: resolve the test integration and confirm the newly implemented exports are registered in the runtime dispatch. ## What I ran Reviewed head `779e626397e1ba87ebbc7c0f93c1e3080d15b955` using the prepared diff and `repo_read.py`; no tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Accessor bodies and direct unit test logic inspected | | Test integration | not run | New test is not referenced by the existing test configuration | | Runtime export registration | not verified | Registration path is not established by the inspected changes | ## Findings ### Blocking None verified. ### Non-blocking - `core/libs/prx/libSceNKWebKit/tests/ModuleFieldAccessors.cpp` is not referenced by the `CMakeLists.txt` test discovery. That file adds tests for the new accessors, but the existing glob searches `tests/*.cpp` under `core/libs/prx/libSceNKWebKit`, and the new file is present there; the observed search for its name in the CMake file itself was empty. Verify the normal glob includes it and add an explicit test registration if the project’s test setup does not discover it. ## Sources - [Field getter implementations](https://github.com/boykopovar/AnyPS5/blob/779e626397e1ba87ebbc7c0f93c1e3080d15b955/core/libs/prx/libSceNKWebKit/src/FieldGetters.cpp) - [Field setter implementations](https://github.com/boykopovar/AnyPS5/blob/779e626397e1ba87ebbc7c0f93c1e3080d15b955/core/libs/prx/libSceNKWebKit/src/FieldSetters.cpp) - [NKWebKit test configuration](https://github.com/boykopovar/AnyPS5/blob/779e626397e1ba87ebbc7c0f93c1e3080d15b955/core/libs/prx/libSceNKWebKit/CMakeLists.txt) ## Not verified Read: `FieldGettersExports.hpp`, `FieldSettersExports.hpp`, `FieldGetters.cpp`, `FieldSetters.cpp`, `ModuleFieldAccessors.cpp`, debt change note, `libSceNKWebKit.hpp`, `CMakeLists.txt`, and the relevant prepared diff and metadata. Full text for `Export.cpp` and `InventoryExports.hpp` was excluded from the review folder; targeted reader checks confirmed their include structure, but export dispatch and all inventory edits were not audited. Author-reported test results were not rerun. No environment or toolchain checks were run. ## To get this to a good state Nothing is required. Optional: confirm the test is picked up by the CMake glob and verify registration for the new accessor implementations.
MarcZX10 commented 2026-11-26 13:11:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T13:11:02Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and its tests provide enough evidence to support merging.

What I ran

Reviewed head 8c07f3eafd5de8451f2db1dad7215a9c6d518297 using repo_read.py to inspect the prepared diff and targeted source. No test or build commands were run; the test results below are author-reported.

Results

Check Result Note
Targeted source review passed Accessor definitions, declarations, and test coverage inspected
Build and tests not run Linux/GCC test results reported by the author
Negative control not run Author reports a wrong-offset test failure

Findings

Blocking

None.

Non-blocking

None.

Not verified

Export.cpp was excluded from the prepared files because it was too large; its removal hunks were visible in diff.patch, but its full text was not reviewed. InventoryExports.hpp and LegacyExports.hpp had no added lines and their full contents were not read. Repository-wide build and test results, console behavior, and the module binary’s hash and decoded instruction bodies were not independently verified. The author reports Linux Mint 22.3/GCC 13.3 tests and convention checks passed.

Files read: description.md, commits.md, manifest.json, diff.patch, README.md; changed files FieldGettersExports.hpp, FieldSettersExports.hpp, FieldGetters.cpp, FieldSetters.cpp, ModuleFieldAccessors.cpp, and feat-nkwebkit-module-field-accessors.md; targeted context CMakeLists.txt, libSceNKWebKit.hpp, InventoryExports.hpp, LegacyExports.hpp, and Export.cpp. Excluded from full-text review: Export.cpp (too large), InventoryExports.hpp and LegacyExports.hpp (no added lines).

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6074699352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23475#pullrequestreview-6074699352). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-26T13:11:02Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and its tests provide enough evidence to support merging. ## What I ran Reviewed head `8c07f3eafd5de8451f2db1dad7215a9c6d518297` using `repo_read.py` to inspect the prepared diff and targeted source. No test or build commands were run; the test results below are author-reported. ## Results | Check | Result | Note | |---|---|---| | Targeted source review | passed | Accessor definitions, declarations, and test coverage inspected | | Build and tests | not run | Linux/GCC test results reported by the author | | Negative control | not run | Author reports a wrong-offset test failure | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `Export.cpp` was excluded from the prepared files because it was too large; its removal hunks were visible in `diff.patch`, but its full text was not reviewed. `InventoryExports.hpp` and `LegacyExports.hpp` had no added lines and their full contents were not read. Repository-wide build and test results, console behavior, and the module binary’s hash and decoded instruction bodies were not independently verified. The author reports Linux Mint 22.3/GCC 13.3 tests and convention checks passed. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, `README.md`; changed files `FieldGettersExports.hpp`, `FieldSettersExports.hpp`, `FieldGetters.cpp`, `FieldSetters.cpp`, `ModuleFieldAccessors.cpp`, and `feat-nkwebkit-module-field-accessors.md`; targeted context `CMakeLists.txt`, `libSceNKWebKit.hpp`, `InventoryExports.hpp`, `LegacyExports.hpp`, and `Export.cpp`. Excluded from full-text review: `Export.cpp` (too large), `InventoryExports.hpp` and `LegacyExports.hpp` (no added lines). ## To get this to a good state Nothing is required.
ligmaSec commented 2026-12-03 12:52:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:52:18Z.

Review: COMMENTED


Built the branch’s changed sources and ran ModuleFieldAccessors on Linux against the existing runtime libraries. The test run passed and covered the WebKit field getter and setter cases.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170170230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23475#pullrequestreview-6170170230). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T12:52:18Z. **Review:** COMMENTED --- Built the branch’s changed sources and ran ModuleFieldAccessors on Linux against the existing runtime libraries. The test run passed and covered the WebKit field getter and setter cases. AI-assisted: yes.

Pull request closed

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!23475
No description provided.