feat(libSceSysmodule): implement sceSysmoduleGetModuleHandleInternal #3050

Closed
TheAggie wants to merge 1 commit from upstream-pr/3050 into main
TheAggie commented 2026-10-10 21:14:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T21:14:16Z.


What

sceSysmoduleGetModuleHandleInternal (D8cuU4d72xM) isn't exported. Prospero Win (PPSA99995) stops on it at start-up on main:

FAIL: unresolved ELF import D8cuU4d72xM from libSceSysmodule.prx

The title loads libSceKeyboard (0x106) and libSceMouse (0xa9) with sceSysmoduleLoadModule. It then asks for each module's handle and resolves the functions it needs with sceKernelDlsym (native/pw_hid_ps5.c). If the plain id isn't loaded, it retries with the internal form 0x80000000 | id.

sceSysmoduleGetModuleHandleInternal(id, handle):

  • Loaded module: stores a handle that sceKernelDlsym accepts, and returns 0.
  • Not loaded or unknown id: a module that isn't loaded (by the load counts the other sysmodule calls keep), or an id the module table doesn't know, returns SCE_SYSMODULE_ERROR_UNLOADED.
  • Invalid arguments: id 0 and a null handle throw, as id 0 does in the other functions here.
  • Repeated calls: each id keeps one handle.

How the handle is made: sceKernelDlsym only accepts handles from libkernel's module registry. dlopen resolves its path as a guest path, so a bare libSceMouse.prx would be looked up in the title's own directory. The new libkernel-internal HostLibraryHandle_nid_no_patch instead opens the named host library from the directory libkernel was loaded from, and registers it as dlopen does. libSceSysmodule now links libkernel.

Test (guest_sysmodule):

  • no handle before the mouse module is loaded;
  • a non-negative handle after sceSysmoduleLoadModule, the same one on a second call, and sceKernelDlsym(handle, "sceMouseInit") resolves;
  • an unknown internal id returns SCE_SYSMODULE_ERROR_UNLOADED;
  • after sceSysmoduleUnloadModule, the call returns SCE_SYSMODULE_ERROR_UNLOADED again.

Tested

  • Prospero Win: on main b8a083b2 it stops at D8cuU4d72xM. With this PR it starts, reads its dev.conf and opens /app0/lapy.elf, then exits with code 1. That exit is by design: it sends lapy.elf to elfldr on port 9021, a jailbreak service, and per its getting-started guide it returns to Home when that's unavailable.
  • Suite: guest|kernel|module|sysmodule|relinker tests: 240 passed, 1 skipped, 1 failed. The failure is guest_memory, which fails the same way on main here (CheckGuestModuleImageProtection's dlopen).
  • Conventions: tools/check_conventions.py passes.
  • Setup: Windows 11, MinGW-w64 GCC 15.2.0, Release. The Linux branch of HostLibraryHandle_nid_no_patch (dladdr and dlopen) is not tested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4814480323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3050). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T21:14:16Z. --- ### What `sceSysmoduleGetModuleHandleInternal` (`D8cuU4d72xM`) isn't exported. Prospero Win (PPSA99995) stops on it at start-up on `main`: ``` FAIL: unresolved ELF import D8cuU4d72xM from libSceSysmodule.prx ``` The title loads `libSceKeyboard` (`0x106`) and `libSceMouse` (`0xa9`) with `sceSysmoduleLoadModule`. It then asks for each module's handle and resolves the functions it needs with `sceKernelDlsym` ([`native/pw_hid_ps5.c`](https://github.com/mpereiraesaa/prospero-win/blob/main/native/pw_hid_ps5.c)). If the plain id isn't loaded, it retries with the internal form `0x80000000 | id`. `sceSysmoduleGetModuleHandleInternal(id, handle)`: - **Loaded module:** stores a handle that `sceKernelDlsym` accepts, and returns 0. - **Not loaded or unknown id:** a module that isn't loaded (by the load counts the other sysmodule calls keep), or an id the module table doesn't know, returns `SCE_SYSMODULE_ERROR_UNLOADED`. - **Invalid arguments:** id 0 and a null `handle` throw, as id 0 does in the other functions here. - **Repeated calls:** each id keeps one handle. **How the handle is made:** `sceKernelDlsym` only accepts handles from libkernel's module registry. `dlopen` resolves its path as a guest path, so a bare `libSceMouse.prx` would be looked up in the title's own directory. The new libkernel-internal `HostLibraryHandle_nid_no_patch` instead opens the named host library from the directory libkernel was loaded from, and registers it as `dlopen` does. `libSceSysmodule` now links `libkernel`. **Test (`guest_sysmodule`):** - no handle before the mouse module is loaded; - a non-negative handle after `sceSysmoduleLoadModule`, the same one on a second call, and `sceKernelDlsym(handle, "sceMouseInit")` resolves; - an unknown internal id returns `SCE_SYSMODULE_ERROR_UNLOADED`; - after `sceSysmoduleUnloadModule`, the call returns `SCE_SYSMODULE_ERROR_UNLOADED` again. ### Tested - **Prospero Win:** on `main` b8a083b2 it stops at `D8cuU4d72xM`. With this PR it starts, reads its `dev.conf` and opens `/app0/lapy.elf`, then exits with code 1. That exit is by design: it sends `lapy.elf` to elfldr on port 9021, a jailbreak service, and per its [getting-started guide](https://github.com/mpereiraesaa/prospero-win/blob/main/docs/GETTING_STARTED.md) it returns to Home when that's unavailable. - **Suite:** `guest|kernel|module|sysmodule|relinker` tests: 240 passed, 1 skipped, 1 failed. The failure is `guest_memory`, which fails the same way on `main` here (`CheckGuestModuleImageProtection`'s `dlopen`). - **Conventions:** `tools/check_conventions.py` passes. - **Setup:** Windows 11, MinGW-w64 GCC 15.2.0, Release. The Linux branch of `HostLibraryHandle_nid_no_patch` (`dladdr` and `dlopen`) is not tested. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-10 21:14:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T21:14:39Z.


Progress report (262c031 → 73633dd)

➖ System libraries: 84.44% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceSysmodule sceSysmoduleGetModuleHandleInternal
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102246008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3050#issuecomment-6102246008). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T21:14:39Z. --- <!-- progress-report --> ### Progress report (262c031 → 73633dd) ➖ **System libraries**: 84.44% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceSysmodule | `sceSysmoduleGetModuleHandleInternal` | </details>
github-actions[bot] commented 2026-10-10 21:27:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T21:27:18Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2541 core/libs/tests/GuestSysmodule.cpp L18-19, L39
#3041 core/libs/prx/libSceSysmodule/CMakeLists.txt L8-9
core/libs/prx/libSceSysmodule/Export.cpp L29
core/libs/tests/GuestSysmodule.cpp L10, L39
sceSysmoduleGetModuleHandleInternal
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102355523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3050#issuecomment-6102355523). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T21:27:18Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2541 | `core/libs/tests/GuestSysmodule.cpp` [L18-19](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/tests/GuestSysmodule.cpp#L18-L19), [L39](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/tests/GuestSysmodule.cpp#L39) | | | | #3041 | `core/libs/prx/libSceSysmodule/CMakeLists.txt` [L8-9](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/prx/libSceSysmodule/CMakeLists.txt#L8-L9)<br>`core/libs/prx/libSceSysmodule/Export.cpp` [L29](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/prx/libSceSysmodule/Export.cpp#L29)<br>`core/libs/tests/GuestSysmodule.cpp` [L10](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/tests/GuestSysmodule.cpp#L10), [L39](https://github.com/boykopovar/AnyPS5/blob/d9dc6614e0f3ad20a22a3bf5fff8058a8cae4515/core/libs/tests/GuestSysmodule.cpp#L39) | `sceSysmoduleGetModuleHandleInternal` | |
TheAggie commented 2026-10-10 22:01:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-10T22:01:34Z.


Closing as a duplicate of #3041, which came first and implements the same function (Windows test notes there). AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102638738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3050#issuecomment-6102638738). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-10T22:01:34Z. --- Closing as a duplicate of #3041, which came first and implements the same function (Windows test notes there). AI-assisted (Claude Code).

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