Jump to content

Need help to do manual patching of a kext binary (specifically: AppleIntelCPUPowerManagement.kext)?


BillDH2k
 Share

5 posts in this topic

Recommended Posts

I need help to do a manual patching to an old kext binary (AppleIntelCPUPowerManagement.kext from Monterey 12.6), to be used for Sonoma via OpenCore injection. It is my attempt to enable full CPU power management to Sandy-Bridge-E Xeon CPU (on HP Z620, X79 platform) under Sonoma. 

 

Basically, I need to generate a patched kext, with the following equivalent, "hot-patching" applied (this was used under Monterey 12.4+):


image.png.6861778e64175c2fe00a29e100076328.png

 

There are three data strings replacements, to comp.apple.driver.AppleIntelCPUPowerManagement:

"3E7539" -> "3E9090"

"751AB9" -> "EB1AB9"

"EB064531E4" -> "EB034531E4"

 

I noticed an old post here: https://www.insanelymac.com/forum/topic/295587-power-management-for-sandyivy-bridgehaswell-cpus/ . It seems I could use "perl -pi -e" command to do this. So I tried the following, where "my-path" is the path to the kext binary (the kext was copied from Monterey 12.6):

 

perl -pi -e 's|\x3e\x75\x39|\x3e\x90\x90|g' my-path/AppleIntelCPUPowerManagement

perl -pi -e 's|\x75\x1a\xb9|\xeb\x1a\xb9|g' my-path/AppleIntelCPUPowerManagement

perl -pi -e 's|\xeb\x06\x45\x53\xe4|\xeb\x03\x45\x31\xe4|g' my-path/AppleIntelCPUPowerManagement

 

Could anyone tell if the above command is correct?

 

BTW - I tried the above and used the "patched" kext for Sonoma. It did not enable the CPU power management. There could be other reasons, but I need to make sure if I did the patching properly.

 

Thanks in advance!

Edited by BillDH2k
typo
Link to comment
Share on other sites

Thank you! I will give HexFiend a try.

 

Update:  I tried HexFiend to perform data string replacements. It gave the same output when compared to the one generated by using 'perl -pi -e' commands. 

 

BTW - the patched kext failed to enable the CPU power management for Sany-Bridge-E Xeon CPU under Sonoma (HP Z620).

Edited by BillDH2k
Link to comment
Share on other sites

It turned out that there is no need to patch this kext manually. Kernel hot patching is still valid (the kext is loaded first before patching is applied). So simply keeping the three patches in config.list will do the job to enable the full CPU power management for Sandy-Bridge-E CPU.

Link to comment
Share on other sites

for big sur+ you can use my kext code for patching 

i assume you wanna patch the existing AppleIntelCPUPowerManagement.kext instead of replacing

if the kext not in cache maybe use code similiar to this

if (!UserPatcher::matchSharedCachePath(path)) {
        if (LIKELY(strncmp(path, kCoreLSKDMSEPath, arrsize(kCoreLSKDMSEPath))) ||
            LIKELY(strncmp(path, kCoreLSKDPath, arrsize(kCoreLSKDPath)))) {
            return;
        }
        const DYLDPatch patch = {kCoreLSKDOriginal, kCoreLSKDPatched, "CoreLSKD streaming CPUID to Haswell"};
        patch.apply(const_cast<void *>(data), PAGE_SIZE);
        return;
    }

 

Edited by jalavoui
Link to comment
Share on other sites

 Share

×
×
  • Create New...