Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Thanks for putting together the automatic patcher. I am, however, unable to get it to work properly. I had been using another 'hack' (outlined here), but I reverted to Dock.app v.10.8.2 from a backup before attempting to run the auto-patcher. Here's the output:

Code:
$ sudo ./patch_dock 
Backing up original Dock contents
Dumping memory from Dock (5263) [0x104eda000-0x105135000]
Copying Dock binary to working directory
Replacing encrypted contents with decrypted dump
Patching __TEXT segment flags
Patching offset 0xDC0AD
Patching offset 0xDC0C8
Patching offset 0xDC0ED
Patching offset 0xDC19F
Patching offset 0xDC1C7
Patching offset 0xDC26D
Patching offset 0xDC31D
Importing code signing certificates
Replacing with patched Dock
Code signing the patched Dock
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: replacing existing signature
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: object file format unrecognized, invalid, or unsuitable
Restarting the Dock process
The Dock process cannot successfully restart, and my wallpaper disappears. Reverting seems to work. Also, if I run the revert_to_original script, and then run the patch_dock script, I get the same results listed above. Any ideas?

Update: After realizing the the scripts already include the sudo command, I tried running them w/o it. Same result.

Uploaded new scripts in first post. Redownload and try the new one. It should actually spit out some helpful messages. And I fixed a few glaring bugs (not including count= in the dd commands) :eek:
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Still not working for me:
Code:
$ sudo ./patch_dock 
Password:
Backing up original Dock contents
Dumping memory from Dock (7038) [0x10a45b000-0x10a6b6000]
Copying Dock binary to working directory
Replacing encrypted contents with decrypted dump
2469888+0 records in
2469888+0 records out
2469888 bytes transferred in 4.562045 secs (541399 bytes/sec)
Patching __TEXT segment flags
1+0 records in
1+0 records out
1 bytes transferred in 0.001120 secs (893 bytes/sec)
Patching offset 0xDC0AD
3+0 records in
3+0 records out
3 bytes transferred in 0.000019 secs (157286 bytes/sec)
Patching offset 0xDC0C8
8+0 records in
8+0 records out
8 bytes transferred in 0.000028 secs (284360 bytes/sec)
Patching offset 0xDC0ED
8+0 records in
8+0 records out
8 bytes transferred in 0.000028 secs (286790 bytes/sec)
Patching offset 0xDC19F
8+0 records in
8+0 records out
8 bytes transferred in 0.000026 secs (307839 bytes/sec)
Patching offset 0xDC1C7
8+0 records in
8+0 records out
8 bytes transferred in 0.000027 secs (296942 bytes/sec)
Patching offset 0xDC26D
3+0 records in
3+0 records out
3 bytes transferred in 0.000019 secs (157286 bytes/sec)
Patching offset 0xDC31D
8+0 records in
8+0 records out
8 bytes transferred in 0.000028 secs (284360 bytes/sec)
Importing code signing certificates
security: SecKeychainItemImport: The specified item already exists in the keychain.
security: SecKeychainItemImport: The specified item already exists in the keychain.
Replacing with patched Dock
Code signing the patched Dock
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: replacing existing signature
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: object file format unrecognized, invalid, or unsuitable
Restarting the Dock process
Same result -- Dock doesn't relanuch, and no wallpaper. Hopefully the added verbosity helps!
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Still not working for me:

Same result -- Dock doesn't relanuch, and no wallpaper. Hopefully the added verbosity helps!

After running "sudo ./patch_dock" and while your wallpaper is still blank and the dock is not onscreen, run these two commands as well (before you revert)

xxd -l 4096 -g 1 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock >> ~/Desktop/Dock_xxd.txt

xxd -l 4096 -g 1 /tmp/dump >> ~/Desktop/dump_xxd.txt

Then proceed to revert, zip the two files on your Desktop (Dock_xxd and dump_xxd) and post them here.

----------

The script worked perfectly for me, thanks! Dock restarted and is black now.

jW

Glad to hear it!!
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
After running "sudo ./patch_dock" and while your wallpaper is still blank and the dock is not onscreen, run these two commands as well (before you revert)

xxd -l 4096 -g 1 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock >> ~/Desktop/Dock_xxd.txt

xxd -l 4096 -g 1 /tmp/dump >> ~/Desktop/dump_xxd.txt

Then proceed to revert, zip the two files on your Desktop (Dock_xxd and dump_xxd) and post them here.
Here ya go!
 

Attachments

  • xxd.zip
    6.9 KB · Views: 256

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Updated patcher in first thread. This one contains sanity checks to insure that things are how the program expects them to be. It must be run as root (i.e. with sudo) though the program checks for it anyway.

Run it like this to patch:
sudo ./patch_dock patch

And like this to revert:
sudo ./patch_dock revert

And like this to revert to the original
sudo ./patch_dock revert_to_original
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Updated patcher in first thread. This one contains sanity checks to insure that things are how the program expects them to be. It must be run as root (i.e. with sudo) though the program checks for it anyway.

Run it like this to patch:
sudo ./patch_dock patch

And like this to revert:
sudo ./patch_dock revert

And like this to revert to the original
sudo ./patch_dock revert_to_original
Ugh. Still not working:
Code:
$ sudo ./patch_dock patch
Password:
Checking for file locations... success
Importing code signing certificates
security: SecKeychainItemImport: The specified item already exists in the keychain.
security: SecKeychainItemImport: The specified item already exists in the keychain.
Backing up original Dock contents
Dumping memory from Dock (10239) [0x10e321000-0x10e57c000]
Replacing encrypted contents with decrypted dump
2469888+0 records in
2469888+0 records out
2469888 bytes transferred in 9.228851 secs (267627 bytes/sec)
Patching __TEXT segment flags
1+0 records in
1+0 records out
1 bytes transferred in 0.000023 secs (43240 bytes/sec)
Patching offset 0xDC0AD
3+0 records in
3+0 records out
3 bytes transferred in 0.000027 secs (111353 bytes/sec)
Patching offset 0xDC0C8
8+0 records in
8+0 records out
8 bytes transferred in 0.000042 secs (190650 bytes/sec)
Patching offset 0xDC0ED
8+0 records in
8+0 records out
8 bytes transferred in 0.000042 secs (190650 bytes/sec)
Patching offset 0xDC19F
8+0 records in
8+0 records out
8 bytes transferred in 0.000047 secs (170327 bytes/sec)
Patching offset 0xDC1C7
8+0 records in
8+0 records out
8 bytes transferred in 0.000048 secs (166937 bytes/sec)
Patching offset 0xDC26D
3+0 records in
3+0 records out
3 bytes transferred in 0.000032 secs (93902 bytes/sec)
Patching offset 0xDC31D
8+0 records in
8+0 records out
8 bytes transferred in 0.000045 secs (177537 bytes/sec)
Code signing the patched Dock
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: replacing existing signature
/System/Library/CoreServices/Dock.app/Contents/MacOS/Dock: object file format unrecognized, invalid, or unsuitable
Restarting the Dock process
$ xxd -l 4096 -g 1 /System/Library/CoreServices/Dock.app/Contents/MacOS/Dock >> ~/Desktop/Dock_xxd.txt
$ xxd -l 4096 -g 1 /tmp/dump >> ~/Desktop/dump_xxd.txt
$ sudo ./patch_dock revert_to_original
Reverting to original copy of 10.8.2 Dock
No matching processes were found
$ sudo ./patch_dock revert
Reverting to backed up copy of Dock
No matching processes were found
This time, I wasn't able to revert or revert_to_original -- once I manually moved my backed-up Dock.app back into place, it re-spawned. I've attached the two xxd files you requested before.
 

Attachments

  • xxd.zip
    7 KB · Views: 227

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Ugh. Still not working:


This time, I wasn't able to revert or revert_to_original -- once I manually moved my backed-up Dock.app back into place, it re-spawned. I've attached the two xxd files you requested before.

Ahh I think that I have found your problem. It appears that codesign is breaking because it requires the command-line tools from Xcode to be installed. I thought that by bypassing the need for gdb by coding my own app to dump the Dock's memory that we wouldn't need Xcode, but it appears that we do still need it to be installed to code sign binaries.

You can download them without having to D/L Xcode, I believe. Just go here: https://developer.apple.com/
Then go to Mac Dev Center link.
Then, near where it says download Xcode 4.5.2, you'll see Additional Downloads. Click on the link that says "View all downloads"
https://developer.apple.com/downloads/

Then download the tools for "Command Line Tools (OS X Mountain Lion) for Xcode Nov. 1st"
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Ahh I think that I have found your problem. It appears that codesign is breaking because it requires the command-line tools from Xcode to be installed. I thought that by bypassing the need for gdb by coding my own app to dump the Dock's memory that we wouldn't need Xcode, but it appears that we do still need it to be installed to code sign binaries.
Makes sense. I figured I was missing some sort of dependency. I'll leave everything as-is, since I'm content with my 'other' dark Dock. If you decide to include the necessary command line tool(s) to your package, I'll be glad to do more testing for ya!
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Makes sense. I figured I was missing some sort of dependency. I'll leave everything as-is, since I'm content with my 'other' dark Dock. If you decide to include the necessary command line tool(s) to your package, I'll be glad to do more testing for ya!

Too big to include. But see my previous post (just above yours) about just installing the tools you need rather than all of Xcode. Perhaps that will work.
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Too big to include. But see my previous post (just above yours) about just installing the tools you need rather than all of Xcode. Perhaps that will work.
That was it. I'm not sure if other general users will want to go through all the trouble of registering for Apple Developer access just so they can install the CLI tools, which is why I was hoping that you'd be able to figure out what was specifically required from the toolkit to tie it all together. At any rate, really nice work! I appreciate what you've done with this. Of course, we'll all need to do it once again as soon as 10.8.3 RTMs.
 

3282868

macrumors 603
Jan 8, 2009
5,281
0
At any rate, really nice work! I appreciate what you've done with this. Of course, we'll all need to do it once again as soon as 10.8.3 RTMs.

Ugh, I'm installing 10.8.3 now and completely forgot. Sometimes .x beta's don't impact the Dock.app, hoping this won't.
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
That was it. I'm not sure if other general users will want to go through all the trouble of registering for Apple Developer access just so they can install the CLI tools, which is why I was hoping that you'd be able to figure out what was specifically required from the toolkit to tie it all together. At any rate, really nice work! I appreciate what you've done with this. Of course, we'll all need to do it once again as soon as 10.8.3 RTMs.

You're quite right, and I will actually look into exactly what's required so that I can perhaps include an all-in-one package. It's probably something very minor missing...
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Alright, the all-in-one solution is there in the first post, and it's all of 29kb large :)
 
Last edited:

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Alright, the all-in-one solution is there in the first post, and it's all of 29kb large :)
Argh. It looks like there's no quick and easy way to remove the command line tools. I'd love to help test out the new script from the perspective of a non-developer, but unfortunately, I'm going to have wait until I come across a definitive way to remove the tools properly, or until my next OS nuke and pave.
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
Yeah, I tried to find a way to definitively remove them and couldn't figure it out either. Essentially, though, I've just taken the code-signing code directly from the codesign command-line tool (its source code is on opensource.apple.com) and it does what it's supposed to do so it *shouldn't* require anything else. Also, I've linked to some of Apple's private frameworks and that makes me a little iffy of whether it'll work on every machine, so I guess my biggest question for you is: does it do what it's supposed to as is?
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
Yeah, I tried to find a way to definitively remove them and couldn't figure it out either. Essentially, though, I've just taken the code-signing code directly from the codesign command-line tool (its source code is on opensource.apple.com) and it does what it's supposed to do so it *shouldn't* require anything else. Also, I've linked to some of Apple's private frameworks and that makes me a little iffy of whether it'll work on every machine, so I guess my biggest question for you is: does it do what it's supposed to as is?
I'll tell you what - I've been meaning to fire up a new ML virt. When I do, I'll give it a shot!

UPDATE: Fresh install of ML and all updates...

Code:
$ sudo ./dpatch patch
Checking Dock version... 1168.6, ready to patch
Checking privileges... we are root.
Importing CS_DockPatch codesign certificate... done.
Importing CS_DockPatch codesign private key... done.
Requesting task for Dock (132)... aquired - taskid: 6327
Searching memory for __TEXT segment... found @ 0x108CB9000-0x108F14000
Reading out decrypted segment (size: 0x25B000)... done.
Patching memory...
	Offset 0x000000AC: 08 -> 00 
	Offset 0x000DC0AD: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC0C8: F2 0F 10 05 20 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC0ED: F2 0F 10 05 03 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC19F: F2 0F 10 05 89 FC 0E 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC1C7: F2 0F 10 05 31 02 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC26D: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC31D: F2 0F 10 05 63 FF 0E 00 -> 0F 57 C0 90 90 90 90 90 
Patches have been written to disk.
Code signing... replacing existing signature... signed.
Sent SIGKILL to Dock process.
No wallpaper, no Dock!
 
Last edited:

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
I'll tell you what - I've been meaning to fire up a new ML virt. When I do, I'll give it a shot!

UPDATE: Fresh install of ML and all updates...

Code:
$ sudo ./dpatch patch
Checking Dock version... 1168.6, ready to patch
Checking privileges... we are root.
Importing CS_DockPatch codesign certificate... done.
Importing CS_DockPatch codesign private key... done.
Requesting task for Dock (132)... aquired - taskid: 6327
Searching memory for __TEXT segment... found @ 0x108CB9000-0x108F14000
Reading out decrypted segment (size: 0x25B000)... done.
Patching memory...
	Offset 0x000000AC: 08 -> 00 
	Offset 0x000DC0AD: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC0C8: F2 0F 10 05 20 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC0ED: F2 0F 10 05 03 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC19F: F2 0F 10 05 89 FC 0E 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC1C7: F2 0F 10 05 31 02 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC26D: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC31D: F2 0F 10 05 63 FF 0E 00 -> 0F 57 C0 90 90 90 90 90 
Patches have been written to disk.
Code signing... replacing existing signature... signed.
Sent SIGKILL to Dock process.
No wallpaper, no Dock!

See first post. The only thing it needs from the command line tools is the tool codesign_allocate. This is because the Security.framework (the framework that handles code signing) calls this tool to allocate space for the code signature in the binary. Took some digging, but I found it in the framework source code. I've included the tool in the first post, and if you copy it to /usr/bin/, then it will work.

This weekend I will code a GUI app, and in the app I can include the codesign_allocate tool (in the bundle's resources) because the Security.framework respects an environment variable that points to the location of the tool.

Thank you for helping me on this.
 

TheAngryPenguin

macrumors member
Oct 1, 2012
39
0
See first post. The only thing it needs from the command line tools is the tool codesign_allocate. This is because the Security.framework (the framework that handles code signing) calls this tool to allocate space for the code signature in the binary. Took some digging, but I found it in the framework source code. I've included the tool in the first post, and if you copy it to /usr/bin/, then it will work.

This weekend I will code a GUI app, and in the app I can include the codesign_allocate tool (in the bundle's resources) because the Security.framework respects an environment variable that points to the location of the tool.

Thank you for helping me on this.
Reverted to my VM's snapshot, copied codesign_allocate to /usr/bin and ran dpatch:

Code:
$ sudo ./dpatch patch
Checking Dock version... 1168.6, ready to patch
Checking privileges... we are root.
Importing CS_DockPatch codesign certificate... done.
Importing CS_DockPatch codesign private key... done.
Requesting task for Dock (143)... aquired - taskid: 6347
Searching memory for __TEXT segment... found @ 0x10159A000-0x1017F5000
Reading out decrypted segment (size: 0x25B000)... done.
Patching memory...
	Offset 0x000000AC: 08 -> 00 
	Offset 0x000DC0AD: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC0C8: F2 0F 10 05 20 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC0ED: F2 0F 10 05 03 03 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC19F: F2 0F 10 05 89 FC 0E 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC1C7: F2 0F 10 05 31 02 0F 00 -> 0F 57 C0 90 90 90 90 90 
	Offset 0x000DC26D: 0F 28 C1 -> 0F 57 C0 
	Offset 0x000DC31D: F2 0F 10 05 63 FF 0E 00 -> 0F 57 C0 90 90 90 90 90 
Patches have been written to disk.
Code signing... replacing existing signature... signed.
Sent SIGKILL to Dock process.
The Dock process restarted successfully this time, and the wallpaper reappeared, but the Dock itself remained unchanged.
 

jfo43

macrumors newbie
Dec 1, 2012
6
0
nice

Screen Shot 2012-12-01 at 7.46.22 PM.png Looks awesome thanks!
 

j800r

macrumors 6502
Jan 5, 2011
399
140
Coventry, West mids, England
Old style dock back

I agree that looks kinda cool but what I've always wanted since upgrading to ML is the old style 3d dock back. The one used since Leopard. That, to me, was one of the most attractive things about OSX and the new dock just feels like a dull regression to me.

Has anyone figured out a way of patching the binary like this to bring back the old style dock? I don't want anyone telling me to downgrade either as that what mean the money spent on upgrading down the drain.
 

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
I agree that looks kinda cool but what I've always wanted since upgrading to ML is the old style 3d dock back. The one used since Leopard. That, to me, was one of the most attractive things about OSX and the new dock just feels like a dull regression to me.

Has anyone figured out a way of patching the binary like this to bring back the old style dock? I don't want anyone telling me to downgrade either as that what mean the money spent on upgrading down the drain.

There's no way to do what you ask. The difference in code is just too huge. Here, we're patching a few bytes to change the gradient color from light grey to black, and that's quite easy because a gradient is 3 colors over a region (and the only difference between a color is a single floating-point value). What you're asking would require the source code, or an incredibly time-consuming venture that would take incredible expertise.
 

fruityth1ng

macrumors newbie
Nov 16, 2012
2
0
*hug*

as the title says: I could hug you right now. Thanks. I *REALLY* wanted my black dock back! :)

If I can help out in any way, let me know. Need an icon for it?

BlackDock.png
 
Last edited:

HoosPhotog

macrumors member
Aug 4, 2011
36
0
Here's something I came up with to help those who absolutely have to have a black dock. Since Apple moved from image files to CoreGraphics rendering code, the only way to customize the color of the dock is to modify the code.

It can be quite complex as it involves some hacking of the OS, but as I wanted a black dock bad enough to do this, I figured there may be others.




Automatic Method UPDATED:

Coded a program that should handle it for you without the need for any extra tools or files, except the codesign_allocate tool. Hope you enjoy.

Code:
usage: dpatch <command>
   commands:
      patch            patch dock to render black
      revert           revert patches to original (code signature will still be fake)

You must also download the codesign_allocate tool and copy it to /usr/bin/
Keep in mind, again, this will only work for 10.8.2 so far, and will have to be update for future versions.

I just wanted to post my results with the default ML background (may have to find a lighter background) and say thanks! Total coding idiot (had to look up that one uses sudo to execute terminal commands as root) and this took me about a minute. I love it. :D
 

Attachments

  • Screen Shot 2012-12-04 at 10.43.04 PM.png
    Screen Shot 2012-12-04 at 10.43.04 PM.png
    276.6 KB · Views: 322

unsanity77

macrumors member
Original poster
Nov 22, 2012
67
0
I just wanted to post my results with the default ML background (may have to find a lighter background) and say thanks! Total coding idiot (had to look up that one uses sudo to execute terminal commands as root) and this took me about a minute. I love it. :D


as the title says: I could hug you right now. Thanks. I *REALLY* wanted my black dock back! :)

I'm glad you like it!
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.