fix: kernel PRX support, OSK/dialog rendering, robust hooking#6
Merged
AndrewAltimit merged 5 commits intomainfrom Feb 15, 2026
Merged
fix: kernel PRX support, OSK/dialog rendering, robust hooking#6AndrewAltimit merged 5 commits intomainfrom
AndrewAltimit merged 5 commits intomainfrom
Conversation
The OSK and message dialog utility functions never rendered because their polling loops lacked GU frame cycle management. The caller's open display list was not finalized before the dialog tried to render, and sceGuSwapBuffers was never called to present the dialog on screen. Now both osk::OskBuilder::show() and dialog::run_dialog(): 1. Close the caller's open GU list via sceGuFinish/sceGuSync 2. Provide a dedicated 16KB display list for each polling iteration 3. Call sceGuFinish/sceGuSync/sceDisplayWaitVblankStart/sceGuSwapBuffers The caller must re-open their own display list after the dialog returns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- module_start: create kernel threads (no USER flag) when module attribute has kernel bit (0x1000). Previously all modules created USER threads, causing kernel PRX plugins to crash when calling kernel-only APIs like sctrlHEN*. - alloc_impl: use SceKernelPrimaryKernelPartition (1) when the "kernel" feature is enabled, instead of always using user partition (2) which fails in kernel mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The import flags were 0x4001 (user-space search) but SystemCtrlForKernel is a kernel-mode library. Without bit 3 (0x0008), the PSP module loader searches user space and fails to resolve the stubs. Changed to 0x4009 so the loader looks in kernel space where the CFW SystemControl module lives. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rewrite SyscallHook to handle real-world CFW quirks discovered on PRO-C2 6.20: - Kernel stub delay slot fix: PRO-C2 patches import stubs with `j target` but leaves the delay slot as garbage Stub struct data. Resolve CFW functions by reading raw stub bytes and extracting the jump target, bypassing the broken psp_extern! wrappers entirely. - PatchSyscall return value fix: PRO-C2 returns the old syscall table entry (a kernel address like 0x8802xxxx) on success, not 0. The previous `ret < 0` check incorrectly treated this as failure. - Inline hook fallback: when PatchSyscall fails, automatically falls back to inline patching -- overwrites the target function's first two instructions with `j hook; nop` and builds a trampoline with the saved instructions. The trampoline is stored inside SyscallHook for stable addressing. - New `find_function()` standalone API for resolving kernel driver functions by NID without hooking (e.g. sceCtrl_driver). - MIPS instruction helpers: encode_j, extract_j_target, branch detection for safe instruction relocation. The API is backwards-compatible: SyscallHook::install() takes the same parameters and returns Option<SyscallHook>. original_ptr() returns the trampoline address for inline hooks or the original address for syscall hooks transparently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
Author
Review Response Agent (Iteration 1)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
Automated fix by Claude in response to pipeline failures. Failures addressed: - format - lint - test-suite Actions taken: - Ran autoformat (ruff format, cargo fmt) - Fixed remaining lint issues Iteration: 1/5 Co-Authored-By: AI Pipeline Agent <noreply@anthropic.com>
Owner
Author
Failure Handler Agent (Iteration 1)Status: Changes committed and pushed Commit: Failures addressed:
Automated fix in response to CI pipeline failures. |
Owner
Author
Review Response Agent (Iteration 2)Status: No changes needed Fixed Issues
Ignored Issues
Deferred to Human
Notes
The agent reviewed feedback but determined no code changes were required. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes several issues discovered while building a kernel-mode PRX overlay plugin on PSP 6.20 PRO-C2:
Kernel PRX thread/allocator support (
lib.rs,alloc_impl.rs): Kernel modules (attr & 0x1000) now create kernel-mode threads instead of user-mode threads (which crash when calling kernel APIs likesctrlHEN*). The allocator uses the kernel partition when thekernelfeature is enabled.OSK and dialog GU frame management (
osk.rs,dialog.rs):OskBuilder::show()andrun_dialog()now properly manage the GU display list lifecycle -- closing the caller's open list, providing a GU frame for each dialog update iteration, and callingsceGuSwapBuffers()so the dialog is actually visible on screen.SystemCtrlForKernel import flags (
sctrl.rs): Changed flags from0x4001to0x4009(added kernel library search bit0x0008) so the PSP loader resolves the import stubs from kernel space.Robust kernel hooking with inline fallback (
hook.rs): Complete rewrite ofSyscallHookto handle real-world CFW quirks:j targetbut leaves the delay slot as unpatchedStubstruct data (anid_addrpointer that decodes to garbage MIPS). The module now reads raw stub bytes and extracts the jump target, bypassing the brokenpsp_extern!wrappers.0x8802xxxx) on success, not 0. The previousret < 0check incorrectly treated this as failure.sctrlHENPatchSyscallfails, automatically falls back to inline patching -- overwrites the target function's first two instructions withj hook; nopand builds a trampoline with the saved instructions.find_function()API: Standalone function for resolving kernel driver functions by NID without hooking them (e.g.sceCtrl_driver).Test plan
SyscallHook::install()successfully hookssceDisplaySetFrameBuf(via inline fallback)find_function()resolvessceCtrl_driverfunctions for kernel-mode controller pollingreinit_gu_frame()call after return)Generated with Claude Code