feat(libSceHmd2): answer 125 exports before initialization as the console does #7798
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7798"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by T3cm0 on 2026-10-19T07:57:36Z.
What
A sweep of the 281
libSceHmd2exports on a retail PS5 (firmware 13.60), each called from a payload beforesceHmd2Initializeonce with every argument null and once with every argument pointing at a zeroed 16 KiB buffer, found 127 exports that answer the same code both ways and write nothing. This PR binds 125 of them by NID, withAPS5_EXPORTas #7463 does, to one handler per measured answer:0x8a720008(ParameterNull)0x8a7200040x8a72000b(all reprojection exports)0x8a720002(NotInitialized)0x8a720009(ParameterInvalid)0x8a7210020x8a72002c,0x8a721003,0x400,0x20000Each handler returns its value while the library is not initialized and throws through
NotImplemented_nid_no_patchifsceHmd2Initializeever succeeds, because the initialized behaviour is not measured. Sinceb378541e79sceHmd2Initializefails withUnsupportedFeatureonmain, so the uninitialized answers are the only ones a title reaches here, which is also what it sees on the console until the headset runtime is up. The debt entries list every NID with its aerolib name where one exists (72 of the 125), say thatError0004,Error002C,Error1002andError1003are placeholder names for codes whose meaning is unknown, and thatReprojectionNotInitializedis our name for0x8a72000b.Left as they were: the export that returns a pointer-like value, the one answering
0x8a72000a(whichsceHmd2Initializealso returns for some applications, per the existing debt entry), the exports that answer differently to null and to zeroed arguments or that write output (a follow-up once their argument layouts are known), the 16 that crashed the probe, and everythingmain, #7658 and #7690 already implement.Measurement: probe
hmd2s(281 NIDs, resumable across the crashes it hits), run from Payload Manager with no headset connected; log attached as a comment. The payload process is not a game process, so a game beforesceHmd2Initializeis assumed to answer the same; that assumption is stated in the debt entries.Tested
maineaae7e069d:libs,guest_hmd2_testsandpatched_libraries_testsbuilt;ctest -R "guest_hmd2|patched_libraries"2/2 passed. The test calls all twelve handlers beforesceHmd2Initializeand again after its (failed) call.tools/check_conventions.pyclean;tools/pr_overlap.py: #6844 declares throwing stubs by name for 15 of these exports (sceHmd2GazeSetEnabledEye,sceHmd2ReprojectionSetUserEventStartand others) and this PR answers them from measurement, so whichever lands second rebases; #7658 and #7690 shareHmd2.hppand the debt file only (new constants next to theirs, new bullets at the end). No title was run: no known title calls these exports before initialization.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by T3cm0 on 2026-10-19T07:58:15Z.
Console log behind the table in the description: probe hmd2s, 281 libSceHmd2 NIDs called from a payload before sceHmd2Initialize, first with every argument null and then with every argument pointing at a zeroed 16 KiB buffer, resumed across the crashes it hit; firmware 13.60, no headset connected.
17-hmd2s-console.txt
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T07:58:17Z.
Progress report (
eaae7e0→68ef4ca)📉 System libraries: 84.51% (-0.22%, +12 declared functions)
🆕 12 declared as stubs
Hmd2BeforeInitializeError0004Hmd2BeforeInitializeError002CHmd2BeforeInitializeError1002Hmd2BeforeInitializeError1003Hmd2BeforeInitializeMinusOneHmd2BeforeInitializeNotInitializedHmd2BeforeInitializeParameterInvalidHmd2BeforeInitializeParameterNullHmd2BeforeInitializeReprojectionNotInitializedHmd2BeforeInitializeValue0400Hmd2BeforeInitializeValue20000Hmd2BeforeInitializeZeroImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T08:04:41Z.
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.
core/libs/tests/GuestHmd2.cppcore/libs/prx/libSceHmd2/Export.cppcore/libs/prx/libSceHmd2/Hmd2.hppcore/libs/tests/GuestHmd2.cppdocs/dev/debt/libSceHmd2.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T17:32:22Z.
Review: CHANGES_REQUESTED
Thanks for the sweep. Two things block this as it stands:
mainincore/libs/prx/libSceHmd2/Export.cppandcore/libs/tests/GuestHmd2.cpp.APS5_EXPORTare already exported onmainby named throwing stubs:sceHmd2SetIpdOffset,sceHmd2GazeActivateGazeTracking,sceHmd2GazeGetCalibrationData,sceHmd2GazeObjectSelectionInitialize,sceHmd2GazeObjectSelectionTerminate,sceHmd2GazeSetEnabledEye,sceHmd2GazeSetUserCalibrationData,sceHmd2GazeSetUserCalibrationPoint,sceHmd2GazeStartUserCalibration,sceHmd2GazeStopUserCalibration,sceHmd2ReprojectionClearUserEventStart,sceHmd2ReprojectionClearUserEventEnd,sceHmd2ReprojectionSetUserEventStart,sceHmd2ReprojectionSetUserEventEnd,sceHmd2ReprojectionGetCurrentOutput. The name already hashes to the NID, so the alias exports the same symbol twice. The Linux patcher accepts that and the Windows PE patcher rejects it (duplicate patched export name).To fix: rebase on
main, and for those 15 replace the body of the existing stub (return the measured value throughBeforeInitialize) instead of adding a second export. Recheck against #7658 as well, which also changes some reprojection exports, and update the debt entries and the test to the resulting set. Also add the new debt lines away from the end of the section; #7658 and #7690 both append there.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T19:01:16Z.
This PR looks strictly contained in #7826: its single commit
68ef4ca43("answer 125 exports before initialization as the console does") is the first commit of #7826's branch, and #7826 carries two more commits on top of it (dd86478bc62 pointer-checking exports,6eeb2233918 slot/output-writing exports). All three PRs are from the same series opened within ~1h12m this morning.If the intent was one review thread, closing this in favour of #7826 would keep a single place for the maintainers to look — #7826 also has a verified rebase handoff onto current
main(including the resolution againstmain's05bdd6aebstubs, 22 of which these commits supersede). If the split was deliberate, it may be worth saying so on each so they don't read as accidental.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T03:52:46Z.
Thanks for measuring these. The shared-body design and the per-answer debt entries read well. One thing blocks the stack (#7798, #7805, #7826) from merging: since its base,
maingained named throwing stubs for 22 libSceHmd2 functions whose NIDs are in yourAPS5_EXPORTtables (15 in #7798, 7 more in #7805), so after a rebase each of those NIDs would be exported twice:sceHmd2GazeActivateGazeTracking, sceHmd2GazeGetCalibrationData, sceHmd2GazeGetCalibrationDataMaxSize, sceHmd2GazeGetDeviceStatus, sceHmd2GazeGetUserCalibrationStatus, sceHmd2GazeInsertRawDataWithHandle, sceHmd2GazeObjectSelectionGetSelectedObject, sceHmd2GazeObjectSelectionInitialize, sceHmd2GazeObjectSelectionQueryMemory, sceHmd2GazeObjectSelectionTerminate, sceHmd2GazeSetEnabledEye, sceHmd2GazeSetUserCalibrationData, sceHmd2GazeSetUserCalibrationPoint, sceHmd2GazeStartUserCalibration, sceHmd2GazeStopUserCalibration, sceHmd2ReprojectionClearUserEventEnd, sceHmd2ReprojectionClearUserEventStart, sceHmd2ReprojectionGetCurrentOutput, sceHmd2ReprojectionSetUserEventEnd, sceHmd2ReprojectionSetUserEventStart, sceHmd2SetFieldOfView, sceHmd2SetIpdOffset
Could you rebase the three onto current
main, remove those named stubs in favour of your measured answers, and drop theGuestHmd2.cppchecks that three of them throw (sceHmd2GazeActivateGazeTracking,sceHmd2ReprojectionGetCurrentOutput,sceHmd2SetFieldOfView) along with their entries in the debt file's "Unknown function info" list? Also note thatsceHmd2Initializenow always fails withUNSUPPORTED_FEATUREonmain, so these pre-initialization answers become the answers every caller gets.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T07:28:47Z.
The drop for this is already verified if it saves anyone the work: my rebase handoff on #7826 (branch
blawesom:rebase/7826, head415d41eb2) resolved exactly this — the 22 superseded stubs dropped (15 in the 125-export commit, 7 in the 62-pointer commit, matching the maintainer's list above function-for-function),main's 10 non-overlapping stubs kept, the throw-assertions for the covered ones removed, and the debt entry trimmed to the 10 remaining names. An NID audit on the result (computed NIDs of the named stubs vs the 205APS5_EXPORTliterals) confirms zero double-registrations. The same resolution applies to this PR and #7805 by taking the corresponding prefix of the series.Imported from boykopovar/AnyPS5. Originally posted by T3cm0 on 2026-10-20T12:36:32Z.
Closing in favour of #7826, which carries this commit plus the follow-ups and has @blawesom's verified rebase onto current
main(thank you for the NID audit against05bdd6aeb). The split was meant as a review stack, but one thread is easier to review. AI-assisted: yes.Pull request closed