Jump to content

Clover EFI Bootloader - Understanding KextsToPatch HOW TO GUIDE


bu11etpr00f
 Share

8 posts in this topic

Recommended Posts

I decided to write up an Article on Understanding how Clover's KextsToPatch feature works. There doesn't seem to be a whole lot of documentation explaining how to use this feature correctly (not that I have been able to find anyway). There is a lot of information out there about what to use, and what to put into your config.plist, but not much as to how to find out why the values used are used, and how the "data" was obtained. This guide hopes to address that. I tried to update this information on the Wiki, but the authentication between Github and Google appears to be nonfunctional... or no longer open to the public. :(

"Authentication failed
Provider did not validate your credentials (invalid_credentials) - please retry or choose another login service"

This Guide will hopefully help those of you (like me) who would like to know how (and why) to use a tool, and not just use it a certain way because you were told to. For now, this Guide will just be an expansion of the part of the Wiki page found here.

 

 

 

KextsToPatch
 
<key>KextsToPatch</key>
<array>
 
Aside from the patches already built-in to Clover, you also have the ability to create your own by using the following obtainable values: the Binary File Name, the Data to Find, and the Data to Replace. Both Data Values will need to be in the same format; either in hexadecimal (Property List Editor/Clover Configurator), or in base64 (plain text editor). The Data Value lengths MUST also be equal. A smaller replacement Data Value may be filled with zeroes.
 
Fresco FL1009 USB 3.0 Device ID Patch by bu11etpr00f
(BTW: This patch is great for people who have a Gigabyte X79-UD5 Motherboard in their hackintosh and want to resolve their USB issues with macOS El Capitan 10.11, Sierra 10.12, High Sierra 10.13, & Mojave 10.14. It enables the Fresco FL1009 USB 3.0 Controller as a Fresco FL1100 USB 3.0 Controller. Works Great! :))
The following example shows a patch for AppleUSBXHCIPCI replacing the data <string>0x11001b73</string> with <string>0x10091b73</string>:
 
<key>KextsToPatch</key>
<array>
	<dict>
		<key>Comment</key>
		<string>Fresco FL1009 USB 3.0 Device ID Patch by bu11etpr00f</string>
		<key>Disabled</key>
		<false/>
		<key>Find</key>
		<data>PHN0cmluZz4weDExMDAxYjczPC9zdHJpbmc+</data>
		<key>InfoPlistPatch</key>
		<true/>
		<key>Name</key>
		<string>AppleUSBXHCIPCI</string>
		<key>Replace</key>
		<data>PHN0cmluZz4weDEwMDkxYjczPC9zdHJpbmc+</data>
	</dict>
<array>
Note: the patch data is encoded in base64 due to the data type of the field.
 
Unfortunately, Tables don't seem to be supported on this Forum, so I've put images of them in this post. I will also leave the text data below them if you wish to copy/paste it somewhere. ;)
 
post-112364-0-17626100-1458684952_thumb.jpg
 
Find Value (base64)
PHN0cmluZz4weDExMDAxYjczPC9zdHJpbmc+
Find Converted to (UTF-8):
<string>0x11001b73</string>
Find Converted to (HEX):
3C737472696E673E307831313030316237333C2F737472696E673E
 
Replace Value (base64)
PHN0cmluZz4weDEwMDkxYjczPC9zdHJpbmc+
Replace Converted to (UTF-8):
<string>0x10091b73</string>
Replace Converted to (HEX):
3C737472696E673E307831303039316237333C2F737472696E673E
 
 
For help converting base64:
 
 
 
Viewed in Property List Editor:
 
Note: The config.plist uses a base64 value, while Property List Editor shows you the HEX value.
 
post-112364-0-25512300-1458684298_thumb.jpg
 
 
Viewed in Clover Configurator:
 
Note: The config.plist uses a base64 value, while Clover Configurator shows you the TEXT (UTF-8) or HEX value.
 
post-112364-0-31601600-1458684306_thumb.jpg
 
 
 
It is sometimes necessary to use a patch to modify a kext's Info.plist. In this case, the following Boolean Key needs to be added to the Patch's Dictionary Item:
 
            <dict>

                <key>InfoPlistPatch</key>
                <true/>
            </dict>
Side note: Patches are applied in the kext cache. If you patch an Info.plist in order to enable the loading of a specific kext, which is not currently present in your cache, you will need to reboot twice:
  • Once with the option NoCaches to allow FSInject to load the specific kext into the cache, and
  • Then again for the cache to be patched successfully.
 
 
 
Other Examples:
 
Enable TRIM for non-Apple SSD
The following example shows a patch for IOAHCIBlockStorage replacing the data APPLE SSD with an empty value:
 
<dict>
	<key>Comment</key>
	<string>Enable TRIM for non-Apple SSD</string>
	<key>Disabled</key>
	<false/>
	<key>Find</key>
	<data>AEFQUExFIFNTRAA=</data>
	<key>InfoPlistPatch</key>
	<false/>
	<key>Name</key>
	<string>com.apple.iokit.IOAHCIBlockStorage</string>
	<key>Replace</key>
	<data>AAAAAAAAAAAAAAA=</data>
</dict>
Note: the patch data is encoded in base64 due to the data type of the field.
 
post-112364-0-24430600-1458684975_thumb.jpg
 
Find Value (base64)
QVBQTEUgU1NEAA==
Find Converted to (UTF-8):
APPLE SSD
Find Converted to (HEX):
4150504C452053534400
 
Replace Value (base64)
AAAAAAAAAAAAAA==
Replace Converted to (UTF-8) (yes, it's blank):

 
Replace Converted to (HEX):
00000000000000000000
 
 
 
AppleAHCIPort patch to fix internal disks displayed as external (Orange Icon) by Slice
The following example shows a patch for AppleAHCIPort replacing the data External with Internal:
 
<dict>
	<key>Comment</key>
	<string>AppleAHCIPort patch to fix internal disks displayed as external (Orange Icon) by Slice</string>
	<key>Disabled</key>
	<false/>
	<key>Find</key>
	<data>RXh0ZXJuYWw=</data>
	<key>Name</key>
	<string>AppleAHCIPort</string>
	<key>Replace</key>
	<data>SW50ZXJuYWw=</data>
</dict>
 
Note: the patch data is encoded in base64 due to the data type of the field.
 
post-112364-0-82670100-1458684990_thumb.jpg
 
Find Value (base64)
RXh0ZXJuYWw=
Find Converted to (UTF-8):
External
Find Converted to (HEX):
45787465726E616C
Replace Value (base64)
SW50ZXJuYWw=
Replace Converted to (UTF-8):
Internal
Replace Converted to (HEX):
496E7465726E616C
 
 
Allow booting with a MacPro4,1 or MacPro5,1 SMBIOS definition without ECC Memory
The following example shows a patch for AppleTyMCEDriver replacing the data
  • r
    MacPro4,1MacPro5,1Xr
 with
  • r
    X
<dict>
	<key>Comment</key>
	<string>Allow booting with a MacPro4,1 or MacPro5,1 SMBIOS definition without ECC memory</string>
	<key>Disabled</key>
	<false/>
	<key>Find</key>
	<data>cgoATWFjUHJvNCwxAE1hY1BybzUsMQBY</data>
	<key>InfoPlistPatch</key>
	<false/>
	<key>Name</key>
	<string>AppleTyMCEDriver</string>
	<key>Replace</key>
	<data>cgoAAAAAAAAAAAAAAAAAAAAAAAAAAABY</data>
</dict>
Note: the patch data is encoded in base64 due to the data type of the field.
 
post-112364-0-92423400-1458685029_thumb.jpg
 
Find Value (base64)
cgoATWFjUHJvNCwxAE1hY1BybzUsMQBY
Find Converted to (UTF-8):
r
MacPro4,1MacPro5,1X
Find Converted to (HEX):
720A004D616350726F342C31004D616350726F352C310058
 
Replace Value (base64)
cgoAAAAAAAAAAAAAAAAAAAAAAAAAAABY
Replace Converted to (UTF-8):
r
X
Replace Converted to (HEX):
720A00000000000000000000000000000000000000000058
Edited by bu11etpr00f
update: code, os application, tags
  • Like 14
Link to comment
Share on other sites

  • 6 months later...

Very informative, thank you very much for this. Is there a way to inject a new Device ID on the .plist instead of replacing an existing one?

<dict>
	<key>Comment</key>
	<string>Add BCM94352HMB with ID 0x43b114e4</string>
	<key>Name</key>
	<string>AirPortBrcm4360</string>
	<key>Find</key>
	<data>PHN0cmluZz5wY2kxNGU0LDQzYmE8L3N0cmluZz4=</data>
	<key>Replace</key>
	<data>PHN0cmluZz5wY2kxNGU0LDQzYjE8L3N0cmluZz4=</data>
	<key>InfoPlistPatch</key>
	<true/>
</dict>

Link to comment
Share on other sites

  • 2 months later...

 

Very informative, thank you very much for this. Is there a way to inject a new Device ID on the .plist instead of replacing an existing one?

<dict>
	<key>Comment</key>
	<string>Add BCM94352HMB with ID 0x43b114e4</string>
	<key>Name</key>
	<string>AirPortBrcm4360</string>
	<key>Find</key>
	<data>PHN0cmluZz5wY2kxNGU0LDQzYmE8L3N0cmluZz4=</data>
	<key>Replace</key>
	<data>PHN0cmluZz5wY2kxNGU0LDQzYjE8L3N0cmluZz4=</data>
	<key>InfoPlistPatch</key>
	<true/>
</dict>

 

Unfortunately I'm technically not the correct person to answer this question, but I would think that you would still have to do some sort of a "replacement" even if your goal is to "add" something. Otherwise Clover wouldn't know exactly where to inject your "additional" code into a plist. My guess is that you would have to "replace" an entire UNIQUE (system-wide) <dict></dict> with the same UNIQUE <dict></dict> PLUS your added <dict></dict> code. I'm pretty sure this will NOT work though; being that the replacement code, and the code being replaced, must be equal in size. I could be wrong, but I think that a Kext Injector (or dummy kect) would probably be a better way to go.

Link to comment
Share on other sites

Unfortunately I'm technically not the correct person to answer this question, but I would think that you would still have to do some sort of a "replacement" even if your goal is to "add" something. Otherwise Clover wouldn't know exactly where to inject your "additional" code into a plist. My guess is that you would have to "replace" an entire UNIQUE (system-wide) <dict></dict> with the same UNIQUE <dict></dict> PLUS your added <dict></dict> code. I'm pretty sure this will NOT work though; being that the replacement code, and the code being replaced, must be equal in size. I could be wrong, but I think that a Kext Injector (or dummy kect) would probably be a better way to go.

Thanks for replying. I actually made a .kext injector for the case I described, which only purpose has to inject a new device ID property.

Link to comment
Share on other sites

  • 7 months later...

And how does one troublshoot Clover ACPI DDST patch function?

 

I have patches in my config.plist that do not seem to be processed (as seen in IORegistryExplorer)

 

I need to patch

<key>Comment</key>
                <string>PEGP [to] GFX0</string>
                <key>Find</key>
                <data>
                UEVHUA==
                </data>
                <key>Replace</key>
                <data>
                R0ZYMA==
                </data>

but IORegistryExplorer still shows PEGP

Link to comment
Share on other sites

  • 5 months later...

And how does one troublshoot Clover ACPI DDST patch function?

 

I have patches in my config.plist that do not seem to be processed (as seen in IORegistryExplorer)

 

I need to patch

<key>Comment</key>
                <string>PEGP [to] GFX0</string>
                <key>Find</key>
                <data>
                UEVHUA==
                </data>
                <key>Replace</key>
                <data>
                R0ZYMA==
                </data>

but IORegistryExplorer still shows PEGP

 

I know this is old, but I wanted to reply anyway. I'm pretty sure that a patch for PEGP to GFX0 is a ACPI/DSDT Patch and NOT a KextsToPatch.

 

 

This should go under;

<key>ACPI</key>
<dict>
  <key>DSDT</key>
  <dict>
    <key>Patches</key>
    <array>
      <dict>
           <key>Comment</key>
           <string>PEGP [to] GFX0</string>
           <key>Find</key>
           <data>UEVHUA==</data>
           <key>Replace</key>
           <data>R0ZYMA==</data>
      </dict>
    </array>
  </dict>
</dict>

and NOT under;

<key>KernelAndKextPatches</key>
<dict>
     <key>KextsToPatch</key>
     <array>
           <dict>
                <key>Comment</key>
                <string>PEGP [to] GFX0</string>
                <key>Find</key>
                <data>UEVHUA==</data>
                <key>Replace</key>
                <data>R0ZYMA==</data>
           </dict>
     </array>
</dict>

This thread might help point you in the right direction. ;)

 

http://www.insanelymac.com/forum/topic/308790-applegraphicsdevicepolicy-on-the-fly-patching-impossible-alternate-idea-but-still-does-not-seem-to-work/page-2

Link to comment
Share on other sites

  • 8 months later...
 Share

×
×
  • Create New...