Jump to content

How to patch AppleRTC.kext


Conti

Recommended Posts

Note: As of myHack 2.0 RC3 I have included this kext in the generic extra that is bundled with the myHack app. I tested it and yes, it does work in Snow Leopard as well. The information found below is useful however because it serves as a good example of how to create a patched kext without altering your /System files.

 

So yes, as we all know by now and you have probably figured out, the dsdt fix for RTC does not work on Lion. You have basically two options - use the ElliottForceLegacyRTC.kext which is based off of the AppleRTC.kext from 10.5 Leopard.... (Just recompiled to have x86_64 support) - or you can patch the Lion AppleRTC.kext, which is probably the better option of the two, especially given the fact that the ElliottForceLegacyRTC.kext causes kernel panics on some systems.

 

So basically what we are going to do here is a basic run of the mill hex edit that replaces one string with another, we often refer to it as a 'binpatch' or binary patch. Taken a step further - I will show you what we can do to make sure that this change is retained after any software updates which may overwrite this patched AppleRTC.kext and to do this without touching your vanilla kexts in /System/Library/Extensions.

 

First we are going to make a copy of the AppleRTC.kext to work with. Open a terminal and run the following commands:

 

cp -R /System/Library/Extensions/AppleRTC.kext /Extra/Extensions/

 

Now we are going to binpatch this extension by running the following command:

 

sudo perl -pi -e 's|\x75\x30\x44\x89\xf8|\xeb\x30\x44\x89\xf8|; s|\x75\x3d\x8b\x75\x08|\xeb\x3d\x8b\x75\x08|' /Extra/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC

 

Now to ensure that this kext is loaded instead of the one in /System/Library/Extensions - or any future version that may be installed with a software update, we are going to "version bump" this modified extension by using the following commands:

 

sudo defaults write /Extra/Extensions/AppleRTC.kext/Contents/Info CFBundleVersion 9.9
sudo defaults write /Extra/Extensions/AppleRTC.kext/Contents/Info CFBundleShortVersionString 9.9
sudo defaults write /Extra/Extensions/AppleRTC.kext/Contents/version BuildVersion 999
sudo defaults write /Extra/Extensions/AppleRTC.kext/Contents/version CFBundleVersion 9.9
sudo defaults write /Extra/Extensions/AppleRTC.kext/Contents/version CFBundleShortVersionString 9.9

 

Now we will convert the plist's back to a human readable format (just to be nice to people who may want to poke around later) with plutil

 

sudo plutil -convert xml1 /Extra/Extensions/AppleRTC.kext/Contents/Info.plist 
sudo plutil -convert xml1 /Extra/Extensions/AppleRTC.kext/Contents/version.plist 

 

Now set the permissions so everything is happy

 

sudo chmod -R 0755 /Extra/Extensions/AppleRTC.kext

 

And rename it so we know what it is

 

sudo mv /Extra/Extensions/AppleRTC.kext /Extra/Extensions/Patched_10.7_AppleRTC.kext

 

Finally run myFix to apply these changes to the Extensions.mkext and that's it, u have a binpatched extension that will continue to work even after OS updates that may replace the vanilla one, and you haven't altered the /System files.

 

If you are particularly lazy I have attached the finished product to this post.

Patched_10.7_AppleRTC.kext.zip

Link to comment
Share on other sites

Hi Conti

 

You've come up with an interesting advancement here. I like your idea and will try using the separate kext.

 

One thing I thought might be worth mentioning is the specific patch you've chosen to use is the one that skips the call to updateChecksum() in rtcRecordTracePoint(). I only mention this because bcc9 at IM reported that this patch didn't work for his nvidia mcp79 based system. Having said that, I've used this successfully in the past on a Gigabyte EP45-DS3L.

 

There is another patch which skips the call to rtcWrites() in updateChecksum() which might be worth considering and is the patch I currently use. That patch for your kext would be as follows:

sudo perl -pi -e 's|\x75\x30\x44\x89\xf8|\xeb\x30\x44\x89\xf8|; s|\x75\x3d\x8b\x75\x08|\xeb\x3d\x8b\x75\x08|' /Extra/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC

Regards

blackosx

Link to comment
Share on other sites

Perl Patch for Mountain Lion DP2-DP4 (AppleRTC.kext) in Terminal:

 

 

Since Mountain Lion DP2 AppleRTC is only a 64bit binary. The patch for AppleRTC.kext Mountain Lion GM ( same as DP2-DP4) is:

 

 

 sudo perl -pi -e 's|\x75\x30\x89\xd8|\xEB\x30\x89\xd8|' /System/Library/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC

 

To be sure that you dont use the old Kext from your caches its recommended to delete the caches in terminal and do an immediate reboot (dont give kextd time to rebuild caches).

in Terminal:

 

sudo rm -rf /System/Library/Caches/com.apple.kext.caches/*

 

or better use it in /Extra/Extensions and install myhack.kext and run myfix script

Link to comment
Share on other sites

the perl patch for Macvericks Dp1 (10.9) Applertc.kext is:

 

sudo perl -pi -e 's|\x75\x2e\x0f\xb6|\xeb\x2e\x0f\xb6|' /System/Library/Extensions/AppleRTC.kext/Contents/MacOS/AppleRTC

 

(thanks to Sunki from Applelife.ru)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...