Skip to content

Commit

Permalink
Add psp_cmd_km_submit pattern for macOS 14.4
Browse files Browse the repository at this point in the history
Signed-off-by: Visual Ehrmanntraut <[email protected]>
  • Loading branch information
VisualEhrmanntraut committed Feb 3, 2024
1 parent c71d4f6 commit eff598f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
27 changes: 17 additions & 10 deletions NootedRed/HWLibs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,23 @@ bool X5000HWLibs::processKext(KernelPatcher &patcher, size_t id, mach_vm_address
}
}

RouteRequestPlus requests[] = {
{"_psp_cmd_km_submit", wrapPspCmdKmSubmit, this->orgPspCmdKmSubmit, kPspCmdKmSubmitPattern,
kPspCmdKmSubmitMask},
{"_smu_9_0_1_create_function_pointer_list", wrapSmu901CreateFunctionPointerList,
getKernelVersion() >= KernelVersion::Ventura ? kSmu901CreateFunctionPointerListVenturaPattern :
kSmu901CreateFunctionPointerListPattern,
kSmu901CreateFunctionPointerListPatternMask},
};
PANIC_COND(!RouteRequestPlus::routeAll(patcher, id, requests, slide, size), "HWLibs",
"Failed to route symbols");
if (getKernelVersion() > KernelVersion::Sonoma ||
(getKernelVersion() == KernelVersion::Sonoma && getKernelMinorVersion() >= 4)) {
RouteRequestPlus request = {"_psp_cmd_km_submit", wrapPspCmdKmSubmit, this->orgPspCmdKmSubmit,
kPspCmdKmSubmitPattern14_4, kPspCmdKmSubmitMask14_4};
PANIC_COND(!request.route(patcher, id, slide, size), "HWLibs", "Failed to route psp_cmd_km_submit (14.4+)");
} else {
RouteRequestPlus request = {"_psp_cmd_km_submit", wrapPspCmdKmSubmit, this->orgPspCmdKmSubmit,
kPspCmdKmSubmitPattern, kPspCmdKmSubmitMask};
PANIC_COND(!request.route(patcher, id, slide, size), "HWLibs", "Failed to route psp_cmd_km_submit");
}

RouteRequestPlus request = {"_smu_9_0_1_create_function_pointer_list", wrapSmu901CreateFunctionPointerList,
getKernelVersion() >= KernelVersion::Ventura ? kSmu901CreateFunctionPointerListVenturaPattern :
kSmu901CreateFunctionPointerListPattern,
kSmu901CreateFunctionPointerListPatternMask};
PANIC_COND(!request.route(patcher, id, slide, size), "HWLibs",
"Failed to route smu_9_0_1_create_function_pointer_list");

PANIC_COND(MachInfo::setKernelWriting(true, KernelPatcher::kernelWriteLock) != KERN_SUCCESS, "HWLibs",
"Failed to enable kernel writing");
Expand Down
7 changes: 7 additions & 0 deletions NootedRed/HWLibs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ static const UInt8 kPspCmdKmSubmitMask[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};

static const UInt8 kPspCmdKmSubmitPattern14_4[] = {0x55, 0x48, 0x89, 0xE5, 0x41, 0x57, 0x41, 0x56, 0x41, 0x55, 0x41,
0x54, 0x53, 0x48, 0x83, 0xEC, 0x18, 0x49, 0x89, 0xCD, 0x49, 0x89, 0xD7, 0x49, 0x89, 0xF4, 0x49, 0x89, 0xFE, 0x48,
0x8D, 0x75, 0xD0, 0xC7, 0x06, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x00, 0x00, 0x00, 0x00};
static const UInt8 kPspCmdKmSubmitMask14_4[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};

static const UInt8 kCAILAsicCapsInitTablePattern[] = {0x6E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x67, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};
Expand Down

0 comments on commit eff598f

Please sign in to comment.