Floris497 / mac-pixel-clock-patch-V2

993 stars 221 forks source link

MacOS Sierra: CoreDisplay.kext #81

Open dockdude opened 7 years ago

dockdude commented 7 years ago

Can this patch be made into a kext?

My reason is simple, it can be disabled during boot if you can't get through the login screen via Clover. With the patch, I had to reinstall Sierra because I was unsuccessful in unpatching it in Recovery Mode.

Thanks Floris.

-Dockdude

Floris497 commented 7 years ago

Hm.. good question. I have little experience making kernel extensions. I would have no idea where to hook it up. Basically it only skips (makes always true return) 1 function in CoreDisplay.

Any good idea's would be welcome, I must say I never owned a hackintosh.. Why were you not able to undo the patch in recovery mode?

If you mount the drive you can easily move the backup back to it's original place.

dockdude commented 7 years ago

Thanks Floris for the quick response...

Yes a hackintosh running discreet GTX 760 Nvidia card. Used your IOKit patch perfectly in El Capitan, but the CoreDisplay patcher is not working for me, couldn't get through the login screen, it's just lost signal on my 4K TV.

When I tried to unpatch issue the command in Recovery Terminal, I get a "there's no backup file" found. The command I used was CoreDisplay-patcher.command unpatch.

Mount the drive to move the backup back? Mount which drive? I only had the El Capitan time machine backup and not the Sierra backup.

I saw in InsanelyMac the following for MacOS Seirra DP1:

sudo perl -i.bak -pe 's|\xB8\x01\x00\x00\x00\xF6\xC1\x01\x0F\x85|\x33\xC0\x90\x90\x90\x90\x90\x90\x90\xE9|sg' /System/Library/Frameworks/CoreDisplay.framework/Versions/Current/CoreDisplay sudo codesign -f -s - /System/Library/Frameworks/CoreDisplay.framework/Versions/Current/CoreDisplay

Not sure if that helps, but that's all I know.

The pixel clock is the reason I am not running Sierra OS at the moment. 3840x2160x30 Hz is too lagging for me as I can do at 60Hz in El Capitan with your IOKit patcher.

Thanks.

Floris497 commented 7 years ago

The unpatch only moves the backup over the patched file. so a simple mv CoreDisplay.bak CoreDisplay would be sufficient to undo the patch. the script is not working in the Recovery because the CoreDisplay has a different file path there due to a different mount point of your main Partition.

dockdude commented 7 years ago

Floris, good to know. I can attempt to redo the patch and save the CoreDisplay.bak somewhere and copy it back into the Recovery location and just do a mv. But as it stands now, the patch is not working for me, so there's no point to reinstall Sierra until we figure out why the patch didn't work to begin with.

Floris497 commented 7 years ago

The .bak file is saved in the same directory where there patched file is. If you look at the script you can find the file location. and it will not be difficult to find it.

I will look if patching IOKit or a combination of IOKit and CoreDisplay will help for Nvidia cards. I'm not sure why it should work but maybe it does. Else I need to dig a little deeper into the current patch and see what other functions might be causing this behaviour. Since the patch is working fine for Integrated graphics, as far as I'm hearing.

dockdude commented 7 years ago

Thanks Floris,

Two things I did leading up to your CoreDisplay patch, 1) Download Xcode Command line tool and 2) Install SwitchResX with custom resolution of 3840x2160 @60Hz 3) ran your patch and reboot. Obviously, I couldn't get through the login screen and just lost the signal. By the way, I am using an active displayport to HDMI 2.0 adapter from my GTX 760 as by itself, it only capable of 1.4a bandwidth, which is at 30Hz.

Floris497 commented 7 years ago

You could try the IOKit patch in this branch https://github.com/Floris497/mac-pixel-clock-patch-V2/tree/Siera-nvidia-IOKit-test (yep.. it should be Sierra..) Could you try patching both and only IOKit? I will go now. If something messes up.. you can easily undo by moving the backup over the patched file. I Need to see when I can dive into this and test, should bring my old GPU back home so I can do some testing..

dockdude commented 7 years ago

Hi Floris, Tried that patch and retry the CoreDisplay patch and I was able to login, but only able to get 30Hz and SwitchResX custom resolution is not saving/installed doesn't matter even if I create new resolutions. I do see the CoreDisplay.bak inside the Frameworks folder for CoreDisplay, so I guess the patch was applied. I will stay with Sierra while I keep trying to get 60Hz working. Thank you for your time.

Floris497 commented 7 years ago

Check the md5's and see if they differ. You can check with adding md5 behind the script when running like file.command md5

dockdude commented 7 years ago

Ok, I'll unpatch and rerun the CoreDisplay command. Will update. Thanks

dockdude commented 7 years ago
Pixel Clock Patch Neo$ ./CoreDisplay-patcher.command
SIP looks to be disabled, all good!

(otool) Detected unpatched CoreDisplay on OS X 10.12  .
SIP looks to be disabled, all good!
Patching CoreDisplay with patch version 1
Password:
Re-singing /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
/System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay: replacing existing signature
Closing..
Pixel Clock Patch Neo$ ./CoreDisplay-patcher.command md5
---- BEGINNING MD5 HASH SUMS ---- version: 10.12 build:16A323

     otool CoreDisplay: 0a4be6cb6944fb6fcd262b967bac2ad2
 otool CoreDisplay.bak: aa7607dd72a2a4ca70ce094a2fc39cce
           CoreDisplay: a49d5686b574138b4d2e66e0edac93c0
       CoreDisplay.bak: eb27b5d68e9fb15aa65ea0153637eae2

---- ENDING MD5 HASH SUMS -------

Looks like it's patched because of different hash value between CoreDisplay and CoreDisplay.bak.

Rebooting now to see if it works. Will report back.

dockdude commented 7 years ago

Still not getting 60Hz and I can't get SwitchResX to save/install the custom resolutions of 3840x2160x60Hz. Is it something in the Nvidia Driver or Sierra? Is there another way to check in CoreDisplay to see if the limit is still there?

Thanks Floris.

Floris497 commented 7 years ago

Is this not SIP related?

dockdude commented 7 years ago

Pixel Clock Patch Neo$ csrutil status System Integrity Protection status: disabled.

Could it be some in EDID?

SAMSUNG.txt

Floris497 commented 7 years ago

Switchresx overwrites EDID info. Some awesome piece of apple engineering though it was a good idea to make it software overwritable for supporting shitty manufacturers :D so it's most probably not the EDID info. If it worked before it should be able to work again.. if it did not work, it might be a hardware limit or a limit in the framebuffer

dockdude commented 7 years ago

It was working in El Capitan, so it can't be the hardware, so how do we check and lift the limit on the framebuffer?

Floris497 commented 7 years ago

That's a great question I don't have the answer for.. editing the framebuffer isn't easy.. I'll give you some info later. There is some info to be found in the issues from the first patch or this one. Most probably closed issues.

Floris497 commented 7 years ago

You could copy the framebuffer from el capitan and see if that works :)

dockdude commented 7 years ago

My El Capitan is now just a time machine backup as I am currently on Sierra on the same hardware. I can dig through the time machine and where would I find this framebuffer?

By the way, your paypal donation link is not working for me :)

Floris497 commented 7 years ago

It's a kext file intelappleframbuffer**.kext there are 2 something startling with ap* and one with br* don't remember exactly can be appleintel* as well. You will find it :) i can give a specific path tomorrow

svickory commented 7 years ago

I hope we can get 60Hz Working on 4k Resolutions.. 30Hz Stinks

dockdude commented 7 years ago

Hi svickory, are you running a real mac or hack?

Floris497 commented 7 years ago

Let me see how the patch behaves on my mac.. not been using it for a while.. and my mac mini has no HDD at the momen.. but let's see what happens on my macbook :)

Floris497 commented 7 years ago

Made an update to CoreDisplay patch, anyone feeling like testing it?

dockdude commented 7 years ago

I'll try it. I'll unpatch first. Thanks Floris

Floris497 commented 7 years ago

I put it in the same branch as the other test

dockdude commented 7 years ago

Floris, still not pushing 60Hz...

What I did... 1) Unpatch to original CoreDisplay, reboot 2) Delete SwitchResX custom resolution 3) Unload SwitchResX daemon 4) Applied the new CoreDisplay patcher, reboot 5) Load SwitchResX and create custom resolution, reboot. 6) ...Heavy Sigh

Something in Sierra preventing and it's not SIP related.

screenshot_34 screenshot_35 screenshot_36

Floris497 commented 7 years ago

So the IOKit one was not working for you either? Check out the thread few posts up, there someone got it to work.. but on hackintosh

dockdude commented 7 years ago

No, I just ran the CoreDisplay and not the IOKit, should I try the IOKit from the same branch? Which post of someone got it to work as I am also on a hackintosh?

Floris497 commented 7 years ago

https://github.com/Floris497/mac-pixel-clock-patch-V2/issues/76 this one, must say I never owned one..

dockdude commented 7 years ago

I am happy Ruatilda was able to get it working. Not sure how he was able to run the IOKit-patcher, because I tried it too and I got an "unknown version of IOKit found" and didn't patch it at all. Also, Ruatilda was getting 1440p @ 60Hz, I am trying 2160p @60Hz with a different TV. I'll keep trying, perhaps, I need to dig into AppleGraphicsControl.kext. Thanks Floris.

Floris497 commented 7 years ago

Hm.. we should compare the old and new framebuffer.. maybe they changed something, could see if I can find something next week. Maybe this weekend

dockdude commented 7 years ago

Hi Floris, Just updated to the latest beta of Sierra and hoping this will work. Also, changing smbios to Imac Retina hoping to enable 4K @60Hz.

sending you the new CoreDisplay.

screenshot_37

CoreDisplay.zip

dockdude commented 7 years ago

Hi Floris, nevermind of the 10.12.1 Beta, I am rolling back to 10.12 and won't be participating in future betas as it messes up other stuff. Thanks.

dockdude commented 7 years ago

Hi Floris, just a quick comment to say I am able to hit 60Hz now, the issue was SwitchResX. I had to completely uninstall and remove all traces of previous SwitchResX installed files. Had to remove and repatch CoreDisplay, then reinstall fresh version of SwithResX and created custom resolutions. Reboot, and now the custom resolution of 3840x2160 @60Hz is actually saved and active. Thanks for your work on the CoreDisplay patch. Now if I can push it beyond 60Hz, say 75Hz, it would be even smoother. Dockdude.

Floris497 commented 7 years ago

You managed to link a user 60Hz haha.. 75Hz is beyond the capabilities of DP1.2 and most probably also the TCON

dockdude commented 7 years ago

Guess I'll wait to upgrade my graphic card to DP1.3 and/or HDMI 2.0b before I push 4K and >75Hz.

themaxx32000 commented 7 years ago

Lilu by vit9696 (https://github.com/vit9696/Lilu) should allow CoreDisplay.framework-patching – shiki is one good example for this https://github.com/vit9696/Shiki/blob/master/Resources/Patches.plist and https://github.com/vit9696/Shiki/blob/master/Shiki/kern_start.cpp#L39

This could enable update proof 4k-patches in the near future ;)

Floris497 commented 7 years ago

Sounds cool will look into it

Brick-Tamland commented 7 years ago

@dockdude just tried your workaround with 10.12.5 and seems like it's not working.

  1. CoreDisplay unpatch, re-Patched.
  2. SwitchResX uninstall, reinstalled.
  3. Custom Resolution, Reboot, saved and active . Shows up in both SRX and OS X display menu. Still tops out at 30hz.

Have you upgraded to 10.12.5 or are you still on 10.12.1?

@Floris497 any other ideas?