feat(libkernel_sys): implement sceKernelGetModuleInfoInternal and sceKernelGetModuleListInternal #9294

Merged
YossiYad merged 5 commits from upstream-pr/9294 into main 2026-10-23 03:43:44 +00:00
YossiYad commented 2026-10-21 17:31:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T17:31:10Z.


What

sceKernelGetModuleInfoInternal and sceKernelGetModuleListInternal threw. Both now answer for every loaded module, system modules included:

  • sceKernelGetModuleInfoInternal(handle, info) fills the 0x1A8-byte SceKernelModuleInfoEx of a module handle, the same structure sceKernelGetModuleInfoFromAddr fills for an address. It checks in shadPS4's order: EFAULT for a null pointer, EINVAL when st_size is not 0x1A8, ESRCH for an unknown handle. sharpemu refuses the same three cases, with its own error codes and the handle checked before the size.
  • sceKernelGetModuleListInternal returns the same list as sceKernelGetModuleList, as fpPS4 does. fpPS4 marks that as a guess; the debt entry says so.

In libkernel, FillModuleInfo becomes a template over SceKernelModuleInfo and SceKernelModuleInfoEx, so the by-handle lookup is shared with sceKernelGetModuleInfo. On Linux the extended form sets id to the handle, as sceKernelGetModuleInfoFromAddr does; the Windows path already fills it.

Not measured on a PS5.

Tested

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main 99844c7eef:

  • New guest_kernel_sys_module_internal (core/libs/tests/GuestKernelSysModuleInternal.cpp): the internal list equals sceKernelGetModuleList, including ENOMEM and EFAULT; for every listed module the extended info has the handle as id and the name and segments of sceKernelGetModuleInfo; for libkernel it is byte for byte what sceKernelGetModuleInfoFromAddr returns; sizes 0x160, 0x1A4, 0x1B0 and 0 give EINVAL and leave the buffer alone, null gives EFAULT and handle -1 ESRCH. It aborts on main. Each of these changes made it fail: not setting id, limiting the lookup to title modules, and an internal list that returns nothing.
  • guest_module_info still passes.
  • Full ctest: 1799 of 1807 pass. The 8 failures fail the same way on main on this machine and do not use these exports: application_heap_scripting, application_heap_lazy, agc_driver_guest_memory_lifetime, agc_driver_image_array_window_past_layer_limit, agc_driver_tessellation and the three net_dontwait_blocking_* cases. Tests that need the GPU skipped themselves.
  • tools/progress.py --compare: libraries +0.02%, 2 functions implemented, none lost.
  • tools/check_conventions.py --base upstream/main passes.
  • tools/pr_overlap.py: no open PR implements these two. #8658 (macOS host) edits FillModuleInfo.

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 under Silent stubs in their library's technical debt file
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4955699957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9294). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-21T17:31:10Z. --- ### What `sceKernelGetModuleInfoInternal` and `sceKernelGetModuleListInternal` threw. Both now answer for every loaded module, system modules included: - `sceKernelGetModuleInfoInternal(handle, info)` fills the 0x1A8-byte `SceKernelModuleInfoEx` of a module handle, the same structure `sceKernelGetModuleInfoFromAddr` fills for an address. It checks in [shadPS4's order](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/kernel/process.cpp#L243-L258): `EFAULT` for a null pointer, `EINVAL` when `st_size` is not 0x1A8, `ESRCH` for an unknown handle. [sharpemu](https://github.com/sharpemu/sharpemu/blob/b6347f9/src/SharpEmu.Libs/Kernel/KernelRuntimeCompatExports.cs#L1564-L1593) refuses the same three cases, with its own error codes and the handle checked before the size. - `sceKernelGetModuleListInternal` returns the same list as `sceKernelGetModuleList`, as [fpPS4](https://github.com/red-prig/fpPS4/blob/04cefd4/kernel/ps4_libkernel.pas#L852-L858) does. fpPS4 marks that as a guess; the debt entry says so. In libkernel, `FillModuleInfo` becomes a template over `SceKernelModuleInfo` and `SceKernelModuleInfoEx`, so the by-handle lookup is shared with `sceKernelGetModuleInfo`. On Linux the extended form sets `id` to the handle, as `sceKernelGetModuleInfoFromAddr` does; the Windows path already fills it. Not measured on a PS5. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `99844c7eef`: - New `guest_kernel_sys_module_internal` (`core/libs/tests/GuestKernelSysModuleInternal.cpp`): the internal list equals `sceKernelGetModuleList`, including `ENOMEM` and `EFAULT`; for every listed module the extended info has the handle as `id` and the name and segments of `sceKernelGetModuleInfo`; for libkernel it is byte for byte what `sceKernelGetModuleInfoFromAddr` returns; sizes 0x160, 0x1A4, 0x1B0 and 0 give `EINVAL` and leave the buffer alone, null gives `EFAULT` and handle -1 `ESRCH`. It aborts on `main`. Each of these changes made it fail: not setting `id`, limiting the lookup to title modules, and an internal list that returns nothing. - `guest_module_info` still passes. - Full `ctest`: 1799 of 1807 pass. The 8 failures fail the same way on `main` on this machine and do not use these exports: `application_heap_scripting`, `application_heap_lazy`, `agc_driver_guest_memory_lifetime`, `agc_driver_image_array_window_past_layer_limit`, `agc_driver_tessellation` and the three `net_dontwait_blocking_*` cases. Tests that need the GPU skipped themselves. - `tools/progress.py --compare`: libraries +0.02%, 2 functions implemented, none lost. - `tools/check_conventions.py --base upstream/main` passes. - `tools/pr_overlap.py`: no open PR implements these two. #8658 (macOS host) edits `FillModuleInfo`. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 - [x] AI-assisted: yes
YossiYad commented 2026-10-22 12:58:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T12:58:45Z.


Rebased onto main 8b3a6ba88 after #9279 (head 26893b36b). The only conflict was the end of Export.cpp, where #9279's pthread calls now sit, and the code is unchanged. guest_kernel_sys_module_internal passes 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341340755 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9294#issuecomment-6341340755). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T12:58:45Z. --- Rebased onto `main` `8b3a6ba88` after #9279 (head `26893b36b`). The only conflict was the end of `Export.cpp`, where #9279's pthread calls now sit, and the code is unchanged. `guest_kernel_sys_module_internal` passes 3 of 3.
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!9294
No description provided.