feat(libSceSysmodule): implement sceSysmoduleGetModuleHandleInternal #3041
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3041"
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 CouchRiv on 2026-10-10T20:55:34Z.
What
Prospero Win (PPSA99995) stops on that NID at load on
main. It issceSysmoduleGetModuleHandleInternalinlibSceSysmodule.The call returns a
KernelModulehandle for a module id that is already loaded (sceSysmoduleLoadModule/ internal load), for latersceKernelDlsym. Invalid id 0, a null out-pointer, or an id absent from the module table throw like the neighbouring internal load/unload paths. If the id is known but the load count is zero, the function returns0x805A1001(SCE_SYSMODULE_ERROR_UNLOADED). Otherwise it reuses a cached host open of the table name, or opens it once throughdlopen_nid_postfix.Signature and use match Prospero Win (
pw_hid_ps5.c:int sceSysmoduleGetModuleHandleInternal(uint32_t id, int32_t *handle), success== 0 && handle >= 0), prosperodev-libprospero, and OpenOrbis. Unloaded / invalid-id behaviour follows shadPS4 /getModuleHandle, mapped to AnyPS5's throw-or-0x805A1001style. Module names come from existingModuleTable.hpp.Which title needs it
Prospero Win (PPSA99995, catalog 0.2.0, LGPL-2.1) on
main1476f769on Linux stops at load with the line above. With this change the same sandbox run binds the symbol (D8cuU4d72xMclass implemented) and the first stop becomessignal SIGILLafter guestsceKernelOpenattempts ondev.conf/lapy.elf. Remaining absent load import:__udivti3(802pFCwC9w0).Tested
CachyOS Linux, GCC as in the worktree build; RTX 4070 Ti (NVIDIA) and Radeon 610M (RADV).
guest_sysmoduleextended for handle unload/invalid/unknown/load/sceKernelDlsymon Fiber — passed on NVIDIA and RADV (gpu-test.sh both -R guest_sysmodule) after rebase onto currentmain.python3 tools/check_conventions.py --base origin/mainpassed;git diff --checkclean.D8cuU4d72xM; first stopsignal SIGILL(see above).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T20:55:55Z.
Progress report (
bd06925→f1af668)📈 System libraries: 85.81% (+0.01%, +1 implemented functions)
✅ 1 implemented
sceSysmoduleGetModuleHandleInternalImported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-10T21:40:08Z.
Windows validation of the current head
fc2d3014(already onmain262c0316), Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,BUILD_TESTING=ON, full build includinglibs. Three things stop the test on Windows:guest_sysmodule_testslinkslibSceSysmodule libkernelonly, and the newtry/catchneeds the personality routine the other guest tests get fromlibc: Addinglibctotarget_link_libraries(guest_sysmodule_tests ...)fixes the link.[libc] unhandled exception 'St13runtime_error'/what(): sceSysmoduleGetModuleHandleInternal: invalid id 0(exit0xc0000409). The test target is missingconfigure_windows_unwind(guest_sysmodule_tests), which every neighbouring guest test that catches a library exception has (for exampleguest_dynamic_loader_testsandguest_filesystem_tests). With both CMake changes theThrowsRuntimeErrorchecks pass.openHostModulecannot open the module. The run then stops atwhat(): sceSysmoduleGetModuleHandleInternal: failed to open libSceFiber. Bothdlopen("libs/libSceFiber.prx")anddlopen("libSceFiber.prx")fail on Windows from the test'score/libsworking directory, whileguest_dynamic_loaderopens its module through an absolute host path. The relative-path lookup throughResolvePath_nid_no_patchis what works differently here; the WindowsdlopenreportsWindows loader errorfor it.So the change cannot be validated on Windows as it stands. I did not run the suite past that point. Happy to rerun once the branch is updated.
Validation run with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T22:01:33Z.
@CouchRiv I opened #3050 for the same function about half an hour after this one, without seeing yours. Yours came first, so I'm closing mine.
I built yours on Windows, cherry-picked onto
mainb8a083b2(Windows 11, MinGW-w64 GCC 15.2.0, Release). The implementation works there:libs/<name>.prxresolves through the guest root to the host library folder in the usual run layout, and Prospero Win (PPSA99995) gets pastD8cuU4d72xM.guest_sysmoduledoesn't pass on Windows, though:guest_sysmodule_testsfails withundefined reference to '__gxx_personality_v0'. The newtry/catchneedslibcin its link libraries, as the other libkernel tests have (target_link_libraries(guest_sysmodule_tests PRIVATE libSceSysmodule libkernel libc)).terminate called after throwing ... sceSysmoduleGetModuleHandleInternal: invalid id 0. Thestd::runtime_errorthrown insidelibSceSysmodule.prxcomes from the guest libc's C++ runtime, so the test executable'scatch (const std::runtime_error&)doesn't match it there. If the throwing cases are worth keeping in the test, adeath test-style subprocess, or checking only the non-throwing paths on Windows, would avoid that.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:05:15Z.
Review: CHANGES_REQUESTED
Thanks, and thanks to @screamm and @TheAggie for the Windows runs.
guest_sysmodulepasses on Linux here, and fails without the change (the test does not link), but the Windows reports show it breaks there:core/libs/prx/libSceSysmodule/CMakeLists.txt:8: addlibctotarget_link_libraries(guest_sysmodule_tests ...); the newtry/catchneeds__gxx_personality_v0(as other guest tests that catch do).configure_windows_unwind(guest_sysmodule_tests), asguest_dynamic_loader_testsandguest_filesystem_testshave; without it theThrowsRuntimeErrorchecks abort on Windows (core/libs/tests/GuestSysmodule.cpp:58-61). If a library exception still can't be caught from the test on Windows, check only the non-throwing paths there.core/libs/prx/libSceSysmodule/Export.cpp:35-42: @screamm reportsopenHostModulefails forlibs/libSceFiber.prxandlibSceFiber.prxfromcore/libson Windows, while @TheAggie sees it resolve in the normal run layout. Please make the test's working directory/path work on Windows (or open through the same pathguest_dynamic_loaderuses).Please rerun
guest_sysmoduleon Windows after these and say the result.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-10T22:10:18Z.
@TheAggie on the exception point: here the
catch (const std::runtime_error&)does match once the test target getsconfigure_windows_unwind(guest_sysmodule_tests)in addition to thelibclink, the same pair the other guest tests that catch library exceptions use (guest_filesystem_tests,guest_dynamic_loader_tests). With both CMake lines the fourThrowsRuntimeErrorchecks pass on this Windows 11 / GCC 15.2.0 r7 build, so no subprocess is needed. What remains for me is thefailed to open libSceFiberstop from the test'score/libsworking directory; your Prospero Win run shows the lookup works in the real run layout, so that is the test's path rather than the implementation.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:05:36Z.
openHostModuletrieslibs/<name>.prxand then<name>.prxwhen that fails (libSceSysmodule/Export.cpp:35-42). Retrying another path after a failure isn't allowed here; please keep onlylibs/<name>.prx, and giveguest_sysmodulea working directory withlibs/libSceFiber.prxin it instead of the module's own folder.Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-11T06:14:54Z.
Thanks. Pushed
23b4fd35aon top of0b8c556c6, which already has thelibclink andconfigure_windows_unwind(guest_sysmodule_tests).core/libs/prx/libSceSysmodule/Export.cpp:35-37:openHostModuleopens onlylibs/<name>.prx. The retry on<name>.prxis gone.core/libs/prx/libSceSysmodule/CMakeLists.txt:10-20:guest_sysmodulenow runs fromcore/libs/prx/libSceSysmodule/guest_sysmodulein the build tree. That directory holdslibs/libSceFiber.prx, copied from thelibSceFiberoutput by aguest_sysmodule_runtimetarget (add_custom_target+copy_if_different, asagc_driver_visual_runtimedoes). The test depends on it. The copy is the unpatched module, from the same output directory as thelibcandlibkernelthe test process already has loaded.Tested on CachyOS Linux, GCC 16.2.1, Release,
BUILD_TESTING=ON:Export.cppchange on top of0b8c556c6(working dir still the module's own folder),ctest -R guest_sysmoduleaborts withsceSysmoduleGetModuleHandleInternal: failed to open libSceFiber.LD_DEBUG=filesshowslibSceFiber.prxloaded fromguest_sysmodule/libs/.ctest -R ^guest_: 216 of 216 passed (guest_video_out_output_modeskipped).check_conventions.py --base origin/main,check_test_registration.pyandgit diff --checkare clean.mainis clean. #2541 and #3227 are still open and touch the same test and CMake lines, so whichever merges second needs a rebase.Not run on Windows: I have no Windows machine and no MinGW toolchain here. @adriadam10 asked for a Windows rerun; @screamm, @TheAggie, could one of you run
guest_sysmoduleon23b4fd35aand post the result? On Windows the module is now opened as<working dir>\libs\libSceFiber.prx; I did not check that it loads there.Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T07:23:15Z.
Windows rerun of
23b4fd35amerged with currentmain833e5eb5(clean merge). Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,BUILD_TESTING=ON, full build includinglibs.ctest -R '^guest_sysmodule$': passes (also with--repeat until-fail:3). All fourThrowsRuntimeErrorchecks go through with thelibclink andconfigure_windows_unwind.PATH:guest_sysmodule/libs/libSceFiber.prxis byte-identical tocore/libs/libs/unpatched/libSceFiber.prx, and with that copy moved away the test aborts withsceSysmoduleGetModuleHandleInternal: failed to open libSceFiber, even thoughcore/libs/libs/unpatched/(prepended toPATHby the test) still holdslibSceFiber.prx. Put back, it passes again. So<working dir>\libs\libSceFiber.prxis what loads on Windows.ctest -R '^guest_': 260 of 260 passed,guest_video_out_wqhd_detection_no_vulkanskipped.check_conventions.py --base origin/main,check_test_registration.pyandgit diff --checkare clean.No further changes needed from the Windows side.
Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:25:10Z.
Additional platform validation of standalone PR head
23b4fd35a826295a175d4a82e1992c58a202b025(2026-10-11):Windows: passed — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release,
BUILD_TESTING=ON.1 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.
Checks:
guest_sysmodule.Command after building:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_sysmodule$".No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-11T07:32:14Z.
Thanks @screamm. Since your run, the branch is rebased onto
mainafter #3227 (f1af6683a, no merge commit). The only change in our diff is that #3227's new Linux-onlyguest_sysmodule_maps_scantest also runs fromguest_sysmodule/, so it findslibs/libSceFiber.prxlikeguest_sysmodule. Both pass on Linux (ctest -R '^guest_sysmodule': 2 of 2), andcheck_conventions.py --base origin/mainis clean. The Windows path is unchanged.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:50:44Z.
Review: APPROVED
Checked on Linux (PR merged onto current main):
guest_sysmoduleandguest_sysmodule_maps_scanpass, and the test does not link without theExport.cppchange. Windows reruns by @screamm and @Mouhand-Kaddo on the previous head are green, and Dean's singlelibs/<name>.prxpath request is addressed. Merging.Note: #2541 and #3227 touch the same test/CMake lines; they may need a rebase after this lands.