F-Script injection brings amazing capabilities: it lets you explore applications from the inside, interactively navigating and manipulating the internal Objective-C objects they are made of. And it is all done live, while the applications are running. For example, if you haven't seen it yet, here is how the Finder looks like from the inside and here is a fun video clip showing how you can reprogram an application on the fly.
Since the dawn of times, F-Script injection was provided by F-Script Anywhere. But as you may know, Snow Leopard broke it without mercy. Fortunately, an alternative F-Script injection mechanism has been made available. Still, it requires launching gdb and typing a command, which is boring.
Today, I'm glad to announce that all of this is now entirely automated, thanks to the injection service developed by Silvio H. Ferreira. It adds an automated F-Script injection procedure in the Services menu, meaning that injecting a whole F-Script environment in an application is now just two mouse clicks away: one to go to the Services menu, and one to select the "Inject F-Script into application" item. This brings back the zero configuration and ease of use spirit of good old F-Script Anywhere.
Picture: injecting F-Script into the Finder using the new injection service
Once injected (which can take a few seconds), F-Script will make itself available by adding an F-Script menu in the menu bar of the target application.
You can download the F-Script injection service here (for Mac OS X 10.6).
Enjoy!
This is super cool!
Unfortunately the service does not work for me: When I run it from Finder nothing happens (OS X 10.6.2). When I run it from iTunes the error ‘The action “Run AppleScript” encountered an error’ is displayed.
What can I do?
Hi Lukas!
Sorry, the installation instructions were a bit incomplete (now updated), which might explain the problem you get: in order for the service to work you must also install the F-Script framework. It is in the F-Script distribution that you can download at http://www.fscript.org/download/download.htm and is named “FScript.framework”. To install it, just put it in /Library/Frameworks/ on your system.
You must also have gdb installed on your system (to see if it is there, just type “gdb” in a UNIX shell). If it is not there, one way to get it is to install the Mac OS X developer package (the one with XCode, etc.) provided by Apple.
Finally, the F-Script injection service won’t work with iTunes (for a few reasons, one of them is that, unlike other system applications, it isn’t a Cocoa application).
Thanks for the problem report. Please, let me know if that fixed it.
Works like a charm, I missed copying FScript.famework to /Library/Frameworks/. Thank you for the help.
Wonderful! One useful change to the script: add the “-n” parameter to the gdb line in the automator action. This will inhibit running the commands in ~/.gdbinit, which may conflict with the script’s intended gdb effect (mine did).
Inhibiting the .gdbinit execution should be fine because the whole purpose is just to use gdb’s standard facilities to attach and invoke the targeted symbols.
do shell script “gdb -n –command=/tmp/gdbtemp2”
Daniel, thanks for the good suggestion.
I just uploaded a revised version.
[…] Automatic F-Script injection in Snow Leopard. […]
This is fantastic. Thank you.
Great stuff, Philippe! Many thanks.
[…] The revenge of F-Script Anywhere-Mac only Are you a programmer who wants more power? To see inside your applications? […]
Awesome work! It fails when multiple instances of an application are running, a quick fix is replacing “set procname to name of the…” with “set procname to unix id of the…”.
Michael, thanks for the idea. I have modified the service accordingly.
thanks for this lead. i’m using f-script on a regular basis, but i was’t aware of the services plugin.
and it works fine… most of the time, but as a test i tried to load FS into the Finder as you did, but that resulted in a hanging Finder, and short after that an (almost) freeze of the whole system.
the freeze was cause by heavy memory swapping, because gdb had already eaten-up almost 4GB of RAM (and growing) by the time i managed to get to a commandline and kill it…
the log shows only this:
Attaching to process 52072.
Reading symbols for shared libraries + done
warning: Error while reading dyld shared cache region 38115 of 1255683817
if i have some time to research it i’ll contact the creator of the service (if applicable)
arri, thanks for the report. It seems that sometimes injection brings some instability. If you haven’t done it yet, you can try injection in the Finder again, as such problems are sometimes transient. If it persists, it might comes from some conflict with other third party plugins or add-ons that you might have in the Finder. You could try to deactivate them if you have some.
Why doesn’t it work with Safari?
Kentzo, it works for me with Safari. Remember that it can take a few seconds (sometimes even 10 or 20s) during which it is best to not switch application. And sometimes you might have to try twice.
[…] here (read “Crash Course on F-Script Syntax”). If you don’t like it already: Go here and download a service that allows you to inject an F-Script instance into a running cocoa app. […]
[…] 如果您可以写入内存,则绝对可以使用此技术来修改进程。一个类似的方法是F-Script Anywhere如何工作(或工作;我最近无法使它工作)。 […]