Jump to content
Sign in to follow this  
Conti

How to patch Lion's AppleRTC.kext

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Interesting tidbit, I am using it on a GA-X58A-UD3R without problems but I wasn't aware anyone had had an issue with it.

 

Skipping the call to rtcWrites() in updateChecksum() does sound like a cleaner method as that is really what we are after here, and given that you say it's a more universal solution I will definitely test it out on my system and update my post, as well as the resultant kext in myHack.

 

Thanks for the heads up!

Share this post


Link to post
Share on other sites

You're welcome. Though it's difficult to know whether or not the second patch successfully fixes the problem for every system affected by this problem as there's not enough data to support such a claim. And like you say, the first patch works for pretty much everyone and both patches work for me. It's only by users reporting back any failures that we'll really know if one particular solution is universal as so far I've only seen the one report that I posted earlier.

Share this post


Link to post
Share on other sites

Well unless someone reports a problem with it, I'll use it for now. I tested it on my own system and it works perfectly so I've updated the original post and the attachment with the new method.

 

Thanks again :ugeek:

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks for the update aschar, I am going to try this myself soon, I'm wondering if it may fix my auto-sleep issue, some users report that it helped them. If it works I will test to find out if we can backport this all the way to SL.

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×