feat(libkernel): implement sceKernelGetModuleInfoFromAddr #723

Merged
alfalfa-star merged 1 commit from upstream-pr/723 into main 2026-10-06 09:29:01 +00:00
alfalfa-star commented 2026-10-05 18:00:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-05T18:00:41Z.


What

Implement sceKernelGetModuleInfoFromAddr, which threw.

A title's own libc.prx calls it from __cxa_thread_atexit with flags 2 and st_size 0x1A8, and stores the 32-bit field at offset 0x108 (id) in its destructor record (PPSA14632). The placeholder ModuleInfo is replaced by the 0x1A8-byte ModuleInfoEx layout from shadPS4, with offset asserts.

On Linux the image containing the address is found with dl_iterate_phdr, and the info reports its name (host file name without .guest.prx), id, TLS block, DT_INIT/DT_FINI, eh_frame_hdr, the eh_frame it points to with its size, and up to four load segments with their protection. The id is the sceKernelLoadStartModule handle when the image was opened through the loader, and otherwise a stable id from the same range, so ids never collide with loader handles. An address outside every image returns ESRCH and a null info EFAULT. Unknown flags values and a different st_size throw, and Windows throws through NotImplemented_nid_no_patch. The assumptions are recorded in TechnicalDebt.

Tested

  • Arch Linux, GCC 16.2, Release. New guest_module_info test (Linux only): id equals the loader handle and is stable across a second dlopen, name, an executable segment containing the queried function, eh_frame_hdr/eh_frame, a stable distinct id for the executable, ESRCH, EFAULT and the rejected flags and st_size. Full ctest: 291/291 apart from the three wave64 pixel tests that fail on main on this GPU (RX 9070 XT, RADV).
  • LEGO Horizon Adventures (PPSA14632), together with #672, #580, #722 and local throwing stubs for its missing imports: __cxa_thread_atexit completes and Unreal Engine starts, reads uecommandline.txt and its config, and runs until sceVoiceQoSInit, which is not implemented.
  • Windows not built or 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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4748935994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/723). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-05T18:00:41Z. --- ### What Implement `sceKernelGetModuleInfoFromAddr`, which threw. A title's own `libc.prx` calls it from `__cxa_thread_atexit` with flags 2 and `st_size` 0x1A8, and stores the 32-bit field at offset 0x108 (`id`) in its destructor record (PPSA14632). The placeholder `ModuleInfo` is replaced by the 0x1A8-byte `ModuleInfoEx` layout from shadPS4, with offset asserts. On Linux the image containing the address is found with `dl_iterate_phdr`, and the info reports its name (host file name without `.guest.prx`), id, TLS block, `DT_INIT`/`DT_FINI`, `eh_frame_hdr`, the `eh_frame` it points to with its size, and up to four load segments with their protection. The id is the `sceKernelLoadStartModule` handle when the image was opened through the loader, and otherwise a stable id from the same range, so ids never collide with loader handles. An address outside every image returns ESRCH and a null info EFAULT. Unknown `flags` values and a different `st_size` throw, and Windows throws through `NotImplemented_nid_no_patch`. The assumptions are recorded in TechnicalDebt. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. --> - Arch Linux, GCC 16.2, Release. New `guest_module_info` test (Linux only): id equals the loader handle and is stable across a second `dlopen`, name, an executable segment containing the queried function, `eh_frame_hdr`/`eh_frame`, a stable distinct id for the executable, ESRCH, EFAULT and the rejected flags and `st_size`. Full ctest: 291/291 apart from the three wave64 pixel tests that fail on `main` on this GPU (RX 9070 XT, RADV). - LEGO Horizon Adventures (PPSA14632), together with #672, #580, #722 and local throwing stubs for its missing imports: `__cxa_thread_atexit` completes and Unreal Engine starts, reads `uecommandline.txt` and its config, and runs until `sceVoiceQoSInit`, which is not implemented. - Windows not built or tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!723
No description provided.