Skip to content

feat(libkernel): implement sceKernelGetModuleInfoFromAddr on Windows - #1188

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
MathiasDevelopes:feat/kernel-module-info-windows
Oct 9, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
MathiasDevelopes:feat/kernel-module-info-windows

Conversation

@MathiasDevelopes

@MathiasDevelopes MathiasDevelopes commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What

sceKernelGetModuleInfoFromAddr was not implemented on Windows: it called NotImplemented_nid_no_patch, so any title whose libc.prx asks which module an address belongs to aborted at startup.

On Windows the module is now the PE image that holds the address (VirtualQuery, MEM_IMAGE):

  • name: the image file name without .guest.prx, as on Linux
  • id: the sceKernelLoadStartModule handle from the dynamic loader, otherwise a stable id from the same range (ModuleIdForImage_nid_no_patch, as on Linux)
  • segments: for an image the relinker produced, its .elfN sections (the ELF load pages); for any other image, its first 4 sections with memory access. Protection comes from the section characteristics
  • eh_frame: for a relinked image, the eh_frame_hdr whose RVA the relinker records in .ehmeta, with its size computed from the header encodings and table; for a host image, the .ehfram section that configure_windows_unwind produces, without an eh_frame_hdr
  • TLS fields, init_proc_addr and fini_proc_addr stay 0; ref_count is 1. Addresses outside any image return SCE_KERNEL_ERROR_ESRCH

The eh_frame_hdr/eh_frame decoding (pointer encodings, record walk) is shared between the Linux and Windows paths instead of being duplicated. The Linux path behaves the same, and its eh_frame_ptr decoding now accepts every standard encoding instead of only 0x1b, 0x03 and 0x00.

guest_module_info now runs on Windows too. The fixture and test binary go through configure_windows_unwind, and only the eh_frame_hdr check stays Linux-only. The TechnicalDebt entry describes the Windows behaviour instead of saying "Not implemented on Windows".

Tested

  • Windows 11, MinGW-w64 GCC (winlibs), Release: guest_module_info and guest_dynamic_loader pass
  • tools/check_conventions.py --base main passes
  • PPSA14632 (relinked, Windows): previously aborted at startup on this call; with this change it boots to the loading screen
  • Linux: not built locally. The Linux path was only refactored to use the shared helpers, so CI should confirm it

Checklist

Copilot AI balanced review requested due to automatic review settings October 7, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MathiasDevelopes
MathiasDevelopes force-pushed the feat/kernel-module-info-windows branch from 2a385ad to 17a59d7 Compare October 7, 2026 17:11
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Progress report (bc1fbe8 → 9abc931)

📈 System libraries: 85.25% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetModuleInfoFromAddr

Read the module layout from the PE image that holds the address. A
relinked image reports its .elf sections as segments and the
eh_frame_hdr recorded in .ehmeta; any other image reports its sections
with memory access and its .ehfram section. The eh_frame_hdr and
eh_frame helpers are shared with the Linux path, and the guest module
info test now also runs on Windows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@MathiasDevelopes
MathiasDevelopes force-pushed the feat/kernel-module-info-windows branch from 17a59d7 to 77ef75c Compare October 8, 2026 05:49
@MathiasDevelopes

Copy link
Copy Markdown
Contributor Author

Rebased onto main. Since #1188 was opened, sceKernelGetModuleInfoForUnwind in Module.cpp got its own Windows .ehmeta / eh_frame_hdr parsing, so this PR now does the same work separately in ModuleInfo.cpp. The two also handle bad tables a little differently (NotImplemented there, throw or full support here).

Should this be a follow up PR or should i do the work here? @adriadam10 @oneandonlydean

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Here, please. Move the .ehmeta / eh_frame_hdr parsing into one helper that both sceKernelGetModuleInfoForUnwind and sceKernelGetModuleInfoFromAddr call, so bad tables are handled one way.

…alls

sceKernelGetModuleInfoForUnwind and sceKernelGetModuleInfoFromAddr each
parsed .ehmeta and the eh_frame_hdr it names. Both now read them through
Module/EhFrame.hpp, so a bad table fails the same way in both: an
eh_frame_hdr version other than 1, an indirect or non-absptr/pcrel
encoding, a 64-bit record length or anything outside the image throws.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JkiyF6p7oDAaTtVe8ci5zP
@MathiasDevelopes

Copy link
Copy Markdown
Contributor Author

@oneandonlydean Done in 9abc931. Both sceKernelGetModuleInfoForUnwind and sceKernelGetModuleInfoFromAddr now parse .ehmeta, the eh_frame_hdr and eh_frame through one shared header, Module/EhFrame.hpp.

Both calls now throw on the same bad tables: a version other than 1, an indirect or non-absptr/pcrel encoding, a 64-bit record length, or anything outside the image.

What changes per call:

  • FromAddr: now throws on 64-bit record lengths and indirect encodings, which it accepted before.
  • ForUnwind: now also accepts udata2/sdata2 and checks that the FDE table is inside the image.
  • Reported sizes are the same as before. ForUnwind still leaves out the terminator, and FromAddr still counts it.

Tested: guest_module_info passes on Linux, the Windows path compiles with MinGW, and the GuestUnwindModuleInfo cases pass against the shared parser. The full Windows tests haven't been run locally, so Windows CI will be the check for those.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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
#1498 core/libs/prx/libkernel/Module/src/ModuleInfo.cpp L11, L167-169

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on Linux (merged onto current main): build and full ctest green (522/522, guest_module_info and guest_dynamic_loader included). Windows CI on this head runs guest_module_info green. The shared EhFrame.hpp addresses Dean's request, TechnicalDebt matches the new behaviour, no conflicts. Merging.

@adriadam10
adriadam10 merged commit 5bc7886 into boykopovar:main Oct 9, 2026
4 checks passed
@MathiasDevelopes
MathiasDevelopes deleted the feat/kernel-module-info-windows branch October 9, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants