feat(libSceSysmodule): implement sceSysmoduleLoadModuleByNameInternal #17904

Merged
akkadbakkad89 merged 1 commit from upstream-pr/17904 into main 2026-11-13 05:40:59 +00:00
akkadbakkad89 commented 2026-11-09 21:32:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-11-09T21:32:02Z.


What

Implements sceSysmoduleLoadModuleByNameInternal in libSceSysmodule from firmware 4.03 disassembly. The export formats /<root>/<tier>/lib/<fname>.<ext> and tries sceKernelLoadStartModuleForSysmodule on each candidate in order, returning the first positive handle or the last error. The twelve candidates in firmware order are the sandbox word over priv_ex, common_ex, priv, common with .sprx, then system_ex/priv_ex, system_ex/common_ex, system/priv, system/common with .sprx, then sandbox priv/common with .prx, then system priv/common with .prx. A null fname returns SCE_KERNEL_ERROR_EINVAL; the load option pointer is hardcoded null and args, argp, flags and res forward to the loader.

The host forwards each candidate to sceKernelLoadStartModule, whose SystemLibraryPath translation resolves /<sandbox>/common/lib/<name>.sprx and /system/common/lib/<name>.sprx to libs/<name>.prx; the other candidates fail to open, matching the console's missing-path fallthrough. This also covers the DT_NEEDED-style by-name loads titles issue through this export, such as libSceShaderTranscode_minimal.

Firmware's sceKernelLoadStartModuleForSysmodule ORs 0x10000 into the flags and bypasses the sceKernelLoadStartModule flags-must-be-zero gate, so a nonzero flags is accepted on console but rejected here, where the host loader has no flag semantics. Recorded in docs/dev/debt/libSceSysmodule.md.

Tested

Windows 11, MinGW GCC 15.2.0. guest_sysmodule passes: null fname returns SCE_KERNEL_ERROR_EINVAL, libSceFiber loads by name through the sandbox common/lib path and resolves sceFiberOptParamInitialize via sceKernelDlsym, a repeat load succeeds, an unknown name returns a negative error, and sceKernelStopUnloadModule unloads the handle. Final Fantasy Resonance (PPSA31544) imports this export.

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:5231535727 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17904). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-11-09T21:32:02Z. --- ### What Implements `sceSysmoduleLoadModuleByNameInternal` in `libSceSysmodule` from firmware 4.03 disassembly. The export formats `/<root>/<tier>/lib/<fname>.<ext>` and tries `sceKernelLoadStartModuleForSysmodule` on each candidate in order, returning the first positive handle or the last error. The twelve candidates in firmware order are the sandbox word over `priv_ex`, `common_ex`, `priv`, `common` with `.sprx`, then `system_ex`/`priv_ex`, `system_ex`/`common_ex`, `system`/`priv`, `system`/`common` with `.sprx`, then sandbox `priv`/`common` with `.prx`, then `system` `priv`/`common` with `.prx`. A null `fname` returns `SCE_KERNEL_ERROR_EINVAL`; the load option pointer is hardcoded null and `args`, `argp`, `flags` and `res` forward to the loader. The host forwards each candidate to `sceKernelLoadStartModule`, whose `SystemLibraryPath` translation resolves `/<sandbox>/common/lib/<name>.sprx` and `/system/common/lib/<name>.sprx` to `libs/<name>.prx`; the other candidates fail to open, matching the console's missing-path fallthrough. This also covers the `DT_NEEDED`-style by-name loads titles issue through this export, such as `libSceShaderTranscode_minimal`. Firmware's `sceKernelLoadStartModuleForSysmodule` ORs `0x10000` into the flags and bypasses the `sceKernelLoadStartModule` flags-must-be-zero gate, so a nonzero `flags` is accepted on console but rejected here, where the host loader has no flag semantics. Recorded in `docs/dev/debt/libSceSysmodule.md`. ### Tested Windows 11, MinGW GCC 15.2.0. `guest_sysmodule` passes: null `fname` returns `SCE_KERNEL_ERROR_EINVAL`, `libSceFiber` loads by name through the sandbox `common/lib` path and resolves `sceFiberOptParamInitialize` via `sceKernelDlsym`, a repeat load succeeds, an unknown name returns a negative error, and `sceKernelStopUnloadModule` unloads the handle. Final Fantasy Resonance (PPSA31544) imports this export. ### 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
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!17904
No description provided.