Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

The hard way to find hidden Finder preferences System
This recent hint points out that the old strings approach to inspecting applications doesn't work for finding hidden preferences in Snow Leopard. I've worked out a way that works for the Finder, but it may not work with other applications (eg. I didn't have much luck with the Dock). In order to use this hint, you'll need to have the Xcode developer tools installed.

First, quit Finder. This can be done via AppleScript, or by enabling the Quit menu item in the Finder. After that, open a Terminal window (make sure it's in your Dock or running before you quit Finder). Then type:
$ cd ~/Desktop
$ gdb /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
This loads gdb (the GNU debugger) and gets it ready to debug the Finder. You can actually attach gdb to a running copy of the Finder, but (a) you need to be root, and (b) you'll miss all the lovely prefs the Finder asks for when it starts up, so you may as well start fresh.

In gdb, type (or copy and paste) the following:
set logging on
break CFPreferencesCopyAppValue
commands 1
silent
print-object [$rdi stringByAppendingFormat:@";%@",$rsi]
continue
end
run
This basically tells gdb to log the preference string and preference domain every time Finder looks up a preference.

After you hit Return after typing run, gdb will start Finder, and you'll start seeing messages flash by. I recommend you hide Terminal, then switch to Finder and use it normally for a while in order to log a bunch of preference requests. When you're satisfied, quit Finder again (see, aren't you glad you enabled the Quit menu item like I suggested?), switch back to gdb in Terminal, and type quit.

Now, if you look on your Desktop (or elsewhere, if you cd'd somewhere else way back at the beginning), you'll see a file called gdb.txt. If you're a glutton for punishment, you can look through it as it is. But I suggest you open it up quick and delete the first few lines (the stuff gdb printed before it got down to the preferences stuff), and then close it and do the following in your Terminal window (you kept that same window open, right, so you won't need to cd again?):
sort -u -o FinderPrefs.txt gdb.txt
sort will alphabetize the preference keys, and remove duplicates (that's what -u does), which makes your job much much easier.

One last note about the format of the file. I picked a semicolon as the delimiter between the preference and the domain because that shouldn't show up anywhere else in the file. Once you open the file, you can search through for spaces to find any additional lines gdb output, and once you've deleted all those, you can change the semicolons to something more readable.

Oh, and if you're wondering what all the kCFPreferencesCurrentApplication domains mean, you might want to consult this page.

[robg adds: I didn't mark this one as Snow Leopard only, because gdb should also work in 10.5. I haven't tested this one.]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[9,065 views]  

The hard way to find hidden Finder preferences | 11 comments | Create New Account
Click here to return to the 'The hard way to find hidden Finder preferences' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Updated Version
Authored by: arcticmac on Fri, Sep 11 2009 at 8:27AM PDT
Since I first submitted this hint 2+ weeks ago, I've done quite a bit of playing and fine-tuned the process a bit. An updated, more detailed version of this hint is available on my website.

[ Reply to This | # ]
DTrace?
Authored by: sayler on Fri, Sep 11 2009 at 10:00AM PDT
It seems like there should be an easier (= more self-contained) way of doing this with Dtrace.

[ Reply to This | # ]
DTrace?
Authored by: arcticmac on Fri, Sep 11 2009 at 12:07PM PDT
I think not, or at least I couldn't find one on quickly.

Basically, the issue is that preference keys are passed as NSCFString objects, about which DTrace knows nothing. Plus dtrace doesn't have any of your libraries loaded, so you can't just call a library function to get a c-string representation, which means you're stuck. Unless you want to go mucking around and trying to figure out how various instances of NSCFString store their characters, which is a whole lot HARDER than just using gdb.

The way on my website is somewhat more self contained, but it still isn't something that you could, say, do from Instruments.

[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: clmason on Fri, Sep 11 2009 at 8:54AM PDT

Good stuff, any luck finding the setting for using base-2 sizes again?

[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: vramin on Fri, Sep 11 2009 at 11:09AM PDT
It seems that gbg is not included in the Snow Leopard release xtools.



[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: rickt on Fri, Sep 11 2009 at 11:17AM PDT

@vramin hmm, no it sure IS included.

[11:16 AM] rickt@Mago:~ $ uname -a
Darwin Mago.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386
[11:16 AM] rickt@Mago:~ $ which gdb
/usr/bin/gdb



[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: vramin on Fri, Sep 11 2009 at 11:46AM PDT
Thanks, but I get this:

sus /usr/bin $> uname -a
Darwin suslaptop.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:46:25 PDT 2009; root:xnu-1456.1.25~1/RELEASE_X86_64 x86_64
sus /usr/bin $> which gbg
sus /usr/bin $> locate gbg
/Applications/GarageBand.app/Contents/Resources/Dutch.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/English.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/French.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/German.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/Italian.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/Japanese.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/Spanish.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/da.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/fi.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/ko.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/no.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/pl.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/pt.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/pt_PT.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/ru.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/sv.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/zh_CN.lproj/GarageBandHelp/pgs/gbglossary.html
/Applications/GarageBand.app/Contents/Resources/zh_TW.lproj/GarageBandHelp/pgs/gbglossary.html
/opt/local/var/macports/sources/rsync.macports.org/release/ports/www/wml/files/patch-wml_include-des-imgbg.src
sus /usr/bin $>




[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: vramin on Fri, Sep 11 2009 at 11:58AM PDT
Never mind. Forgive my dyslexia.

[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: pendraggon87 on Mon, Sep 14 2009 at 7:23AM PDT
This unfortunately does not help with trying to find hidden preferences for an application like iTunes. It says /Applications/iTunes.app/Contents/MacOS/iTunes" is not a core dump: File format not recognized.

[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: pendraggon87 on Mon, Sep 14 2009 at 7:32AM PDT
Update: I got gdb running, but it did not automatically start up iTunes - I had to open it. Also, where is the log file kept? In your post on your website you mentioned a gdbFinder.txt file, but where/how was the created?

[ Reply to This | # ]
The hard way to find hidden Finder preferences
Authored by: arcticmac on Mon, Sep 14 2009 at 12:27PM PDT

First of all, to debug iTunes at all, you'll need to follow the instructions here to debug iTunes in gdb at all. I think they don't want you to be able to watch FairPlay code do its thing or something, since (gasp) that might allow you to steal music.

Furthermore, iTunes uses older calling conventions, so the commands listed in the hint (and on my site) won't work as written - or rather, they'll work, but they won't actually print out anything useful. Instead, you'll need to replace all occurrences of "$rdi" in the commands with "*(int *)($rbp+8)" and all occurances of "$rsi" with "*(int *)($rbp+12)".

The command that sets the logfile is "set logging file ~/Desktop/gdbFinder.txt" which causes gdb to save a logfile to the Desktop. if you omit telling gdb where to save things explicitly, it'll create the log file as "gdb.txt" in the current directory. Also, if you're having issues with things, it may be best to leave out the line (from the version on my site only) "set logging redirect" command so that you'll be able to see what's going on in gdb.
Hope this helps!



[ Reply to This | # ]