feat(libkernel): implement sceKernelInternalMemoryGetModuleSegmentInfo #4524
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4524"
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 jagrat04 on 2026-10-12T14:21:49Z.
What
Fixes #4173.
Carries screamm's implementation of
sceKernelInternalMemoryGetModuleSegmentInforebased ontomain.libkernelexportedsceKernelInternalMemoryGetModuleSegmentInfoas a stub (NotImplemented_nid_no_patch), which is imported by 44 audited titles bundling their ownlibc.prx(including Stremio Plus and PS5MC). Note thatgetsidfrom #4173 was previously implemented in #3493.Implements
sceKernelInternalMemoryGetModuleSegmentInfo(NID-YTW+qXc3CQ) inModuleInfo.cpp. It fillsInternalSegmentInfowith the address and size of the first segment of the main program (eboot.bin), returning 0 on success and throwingstd::invalid_argumenton null pointer, matching fpPS4. Technical debt is documented inTechnicalDebt.md.Tested
python tools/check_conventions.py --base origin/mainpassed cleanly with 0 errors.core/libs/tests/GuestModuleInfo.cppchecking valid module segment retrieval againstsceKernelGetModuleInfoand verifyingnullptrthrowsstd::invalid_argument.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-12T14:27:31Z.
Progress report (
43e3a70→ea03a22)📈 System libraries: 87.89% (+0.02%, +1 implemented functions)
✅ 1 implemented
sceKernelInternalMemoryGetModuleSegmentInfo_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T14:43:06Z.
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.
main)docs/dev/debt/libkernel.mdL34-35Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T15:05:15Z.
Review: COMMENTED
Checked against the source #4173 cites, plus what this NID is doing in the title trees I hold.
mainstill carries the stub and its// unknown signature.From fpPS4
kernel/ps4_libkernel.pas(abridged — the record is a packedaddress: Pointer; size: QWORD, and the function isSysV_ABI_CDecl):{address, size}result, the out-pointer-only signature and the "first segment of the main program" choice all match that. Of the three public sources I checked, fpPS4 is the only one with a plausible signature: shadPS4's table entry has no parameters because it is a generated stub, and the PS5SDK header writesvoidfor every export in that block, including ones with known arguments. Neither argues against a parameter — they are silent.-YTW+qXc3CQoccurs insce_module/libc.prxof Ghost of Yōtei (PPSA26344, dumped and decrypted, plus its.guest.prx), Trails in the Sky 2nd Chapter (PPSA35169), Wolverine (PPSA03671), Sons of Sparta (PPSA28997) and PPSA02929, and in no other module file there — not the 21 other.prx, the 18.sprx, the one.elf, nor any of the fiveeboot.bin. So there is no title-specific importer in that set. It is still import evidence: I have no run in which this call executes, and no log line naming it.Two things I would not want read as settled:
sceKernelGetLibkernelTextLocation, and its body readsTelf_file(ps4_program.ps4_app.prog).ModuleInfo.segmentInfo[0]after a nil guard — segment 0 of the application. So the carried implementation follows the cited code. What keeps the reading open is the helper's name, plus a NID→name entry forsceKernelGetLibkernelTextLocation(AmJ0mn2l4lM, a value that matches fpPS4's constant for that function) with nothing of that name in our libkernel. If the console's answer is libkernel's own text, segment 0 of the eboot is a different address.Require(segment.address == program.segments[0].address …), compared againstsceKernelGetModuleInfo(self.id, …), compares the answer with itself whenever the test binary is the main program, so both readings pass. If a distinguishing case is worth having I am glad to write it as a patch against this PR; otherwise treat that as a limit of the test rather than a request.One duplicate note, on the API's own data rather than a preference: the overlap bot on this PR already pairs #4193, with the same post-image blobs in
ModuleInfo.cpp(90873a76b8..aa47f2cf6e),GuestModuleInfo.cpp(40eacdf818..dd99d92f30) andModule.cpp(f1d39a1ecd..d196d86131). #4193 was opened at 01:01Z against this PR's 14:21Z, so this is the later copy of the same commit — worth settling between their authors before a second review is spent.Written with AI assistance.
Hermes Agent 🤖 at your service
Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-12T23:00:52Z.
Rebased cleanly onto origin/main resolving merge conflicts:
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-13T00:26:48Z.
@jagrat04 thanks for the rebase. The delegation to
sceKernelGetLibkernelTextLocation_nid_postfixmatches the fpPS4 code I cited, and thenullptrthrow test is useful.Two points from my review are still open on this head, and the rebase does not answer either:
main(ModuleInfo.cpp:431) returns segment 0 of the main program. That matches fpPS4, but I still have no evidence that the console's answer is the same range. Only one run would settle it, and I don't have one.segment.address == program.segments[0].addressis compared against the same main program the helper reads, so it passes under either reading whenever the test binary is the main program. Treat that as a limit of the test, or add a case that distinguishes them.No change is needed if you're comfortable recording point 1 as an open question in the debt entry.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by jagrat04 on 2026-10-13T01:04:08Z.
@Dextroid17 Thanks for the follow-up!
We've rebased cleanly onto latest
origin/main. As noted, point 1 is recorded as an open question in the technical debt entry (docs/dev/debt/libkernel.md):Since console traces for the exact segment reporting are still pending, keeping this explicitly noted in the technical debt ledger covers it as recommended.