refactor(prx): name the Hmd2 export aliases the NID database resolves #17271

Merged
dkdhanda8 merged 1 commit from upstream-pr/17271 into main 2026-11-12 01:19:34 +00:00
dkdhanda8 commented 2026-11-08 16:40:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dkdhanda8 on 2026-11-08T16:40:00Z.


What

81 of libSceHmd2's export NIDs resolve in the pinned public symbol databases, and the exports they currently alias through the eight shared behavior handlers (Hmd2BeforeInitializeZero, Hmd2CheckFirstThenError0004, Hmd2BeforeInitializeMinusOne, Hmd2CheckFirstThenError1002, Hmd2BeforeInitializeError0004, Hmd2BeforeInitializeParameterInvalid, Hmd2BeforeInitializeParameterNull, Hmd2SlotUpTo1ThenMinusOne) are renamed after their resolved symbols, following the merged AudioIn/Json/CommonDialog naming series.

Each resolved NID keeps its handler's exact behavior through a small delegating function (sceHmd2InternalDfuOpen() calls the Hmd2BeforeInitializeZero handler, and so on), so the measured pre-initialization answers and their post-initialization throws are byte-identical; the shared handlers stay for the exports the database does not resolve. The explicit APS5_EXPORT lines of the 81 resolved NIDs come off and the bare names hash to the same NIDs; declarations land in include/Api.hpp.

Every resolved name was verified by reproducing its NID with tools/nid_names.py's compute_nid and matching it against aerolib.csv and the ps5rs catalog — the debt entry already annotated many of these NIDs with the resolved names, which this formalizes. No behavior changes; the debt entry's measured descriptions and NID lists stand unchanged.

Tested

  • tools/check_conventions.py --base origin/main passes; git diff --check is clean.
  • Export.cpp and the umbrella compile (-fsyntax-only, MinGW), and the existing GuestHmd2.cpp test — which calls the shared handlers by name — compiles unchanged, since the handlers remain.

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); no silent stubs added
  • 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 (naming refactor)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5213102193 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17271). Originally posted by [dkdhanda8](https://github.com/dkdhanda8) on 2026-11-08T16:40:00Z. --- ### What 81 of `libSceHmd2`'s export NIDs resolve in the pinned public symbol databases, and the exports they currently alias through the eight shared behavior handlers (`Hmd2BeforeInitializeZero`, `Hmd2CheckFirstThenError0004`, `Hmd2BeforeInitializeMinusOne`, `Hmd2CheckFirstThenError1002`, `Hmd2BeforeInitializeError0004`, `Hmd2BeforeInitializeParameterInvalid`, `Hmd2BeforeInitializeParameterNull`, `Hmd2SlotUpTo1ThenMinusOne`) are renamed after their resolved symbols, following the merged AudioIn/Json/CommonDialog naming series. Each resolved NID keeps its handler's exact behavior through a small delegating function (`sceHmd2InternalDfuOpen()` calls the `Hmd2BeforeInitializeZero` handler, and so on), so the measured pre-initialization answers and their post-initialization throws are byte-identical; the shared handlers stay for the exports the database does not resolve. The explicit `APS5_EXPORT` lines of the 81 resolved NIDs come off and the bare names hash to the same NIDs; declarations land in `include/Api.hpp`. Every resolved name was verified by reproducing its NID with `tools/nid_names.py`'s `compute_nid` and matching it against [aerolib.csv](https://github.com/zecoxao/sce_symbols/blob/2883963a0a514ba6e77407a08ef4730a65e88254/aerolib.csv) and the [ps5rs catalog](https://github.com/claimore22/ps5rs/blob/2304be5131221bae0dac24b9767cabffda33f747/data/nids.csv) — the debt entry already annotated many of these NIDs with the resolved names, which this formalizes. No behavior changes; the debt entry's measured descriptions and NID lists stand unchanged. ### Tested - `tools/check_conventions.py --base origin/main` passes; `git diff --check` is clean. - `Export.cpp` and the umbrella compile (`-fsyntax-only`, MinGW), and the existing `GuestHmd2.cpp` test — which calls the shared handlers by name — compiles unchanged, since the handlers remain. ### 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`); no silent stubs added - [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 (naming refactor) - [x] AI-assisted: yes
gabichuuuuu commented 2026-11-08 19:20:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T19:20:31Z.

Review: COMMENTED


Windows build of this head merged onto main 9fabd4aa7e, in one tree with the other open NID-naming PRs in this series (#17271, #17254, #17297, #17298 and #17303, which contains #17299); all merged cleanly. Setup: Windows 11, WinLibs GCC 15.2, Release, BUILD_TESTING=ON.

  • The library builds and links. All 138 guest_hmd2*, guest_user_service*, guest_icu*, guest_nkwebkit_requirements* and guest_libre_ssl* tests pass.
  • Same exports. I listed every NID the library exports before and after, using tools/nid_names.py's own rules: APS5_EXPORT literals, plus compute_nid of each APS5_VABI, assembly and data definition that isn't _nid_no_patch. The set is identical to main's, with no NID defined twice.
  • All 81 renamed NIDs now come from the bare name, and every new body still calls the handler its NID used to alias, so the pre-initialization answers are unchanged. objdump -p on the built libSceHmd2.prx lists sceHmd2InternalDfuOpen by name.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5819297587 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17271#pullrequestreview-5819297587). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T19:20:31Z. **Review:** COMMENTED --- Windows build of this head merged onto `main` `9fabd4aa7e`, in one tree with the other open NID-naming PRs in this series (#17271, #17254, #17297, #17298 and #17303, which contains #17299); all merged cleanly. Setup: Windows 11, WinLibs GCC 15.2, Release, `BUILD_TESTING=ON`. - The library builds and links. All 138 `guest_hmd2*`, `guest_user_service*`, `guest_icu*`, `guest_nkwebkit_requirements*` and `guest_libre_ssl*` tests pass. - **Same exports.** I listed every NID the library exports before and after, using `tools/nid_names.py`'s own rules: `APS5_EXPORT` literals, plus `compute_nid` of each `APS5_VABI`, assembly and data definition that isn't `_nid_no_patch`. The set is identical to `main`'s, with no NID defined twice. - All 81 renamed NIDs now come from the bare name, and every new body still calls the handler its NID used to alias, so the pre-initialization answers are unchanged. `objdump -p` on the built `libSceHmd2.prx` lists `sceHmd2InternalDfuOpen` by name.
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!17271
No description provided.