Building simbl/bundle after using f-script to find what needs to be changed..

118 views
Skip to first unread message

JT

unread,
Sep 10, 2009, 6:45:08 AM9/10/09
to F-Script
Possibly not the best group to ask this but I will ask anyway in case
someone can help.

I have used f-script and f-script anywhere to identify and manipulate
some objects in an application that had some annoying menu items and
frames that I wanted to remove. Most of these is simply a case of
setting their view to hidden and I can do this easy enough with f-
script. However I am fed up of doing this manually so now would like
to convert this into a plugin.

My question is, How do I find the objects instance through a bundle?
I can load my code into the process fine using GDB or SIMBL, but not
sure how I go about finding instances of the objects I need to
manipulate.

Any pointers/tips/guides? Googling is only showing me how to 'swizzle'
but this is not what I want to do.

Thanks

Philippe Mougin

unread,
Sep 10, 2009, 4:29:27 PM9/10/09
to F-Script

One good way to navigate to the instances you want Is to start with a
class object. A number of Cocoa class objects (e.g., NSApplication,
NSUserDefaults, ...) provide methods that give access to internal
objects of the program. From there, you can often navigate to the
objects you need. For instance, getting at the main menu looks like
this (from memory): NSApplication sharedApplication mainMenu.
You can explore class objects with the "classes" button in the object
browser.
Philippe

James Tapper

unread,
Sep 11, 2009, 9:11:23 AM9/11/09
to f-sc...@googlegroups.com
Thanks for the hints. I will take a look at that and see what I find.

James Tapper

unread,
Sep 17, 2009, 7:27:12 AM9/17/09
to f-sc...@googlegroups.com
OK I succeeded in my task for a 32bit app using the advice provided.
However I am now trying to do the same with a 64bit application but
am at a loss.

For 32bit mode I used the -dynamic_lookup linker flag to access the
classes/objects
however this does not work for me in 64bit mode. I keep getting the
following
error when trying to inject a bundle that uses objects inside the main
application:

Error loading .../64bitApp.bundle/Contents/MacOS/64bitApp:
dlopen(../64bitApp/build/Debug/64bitApp.bundle/Contents/MacOS/
64bitApp, 265): Symbol not found: _OBJC_CLASS_$_xxxx
Referenced from:../64bitApp.bundle/Contents/MacOS/64bitApp
Expected in: flat namespace
in ../Debug/64bitApp.bundle/Contents/MacOS/64bitApp

If I do not reference an object in the main application the bundle
will inject fine.
All I am trying to do here is add a method to an existing object using
categories (which works
in 32bit mode). If I try doing this to a standard object it works (eg
NSString) The problem
seems to be with the applications custom objects.

I am stumped. Not sure what I need to do? Any help is appreciated.

Thanks


On 10 Sep 2009, at 21:29, Philippe Mougin wrote:

>
>

Philippe Mougin

unread,
Sep 17, 2009, 8:21:45 AM9/17/09
to F-Script
The 64 bit ObjC runtime allow frameworks to somewhat hide their
internal classes from the linker. You are probably hit by this
(https://developer.apple.com/mac/library/releasenotes/Cocoa/RN-
ObjectiveC/index.html#//apple_ref/doc/uid/TP40004309-CH1-SW1).

One simple workaround if you need to simply get at the class object to
message it is to use NSClassFromString() to do a dynamic lookup
instead of a static reference in your code. That doesn't help for your
category problem, though.
Instead of a category, try to add methods dynamically using the
class_addMethod() function (see
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/c/func/class_addMethod).

Philippe

James Tapper

unread,
Sep 17, 2009, 9:05:59 AM9/17/09
to f-sc...@googlegroups.com
Ah excellent thanks for pointing that out. I can probably get away
without adding the code as a category actually so I will look at that.

Just a note though, the problem I am having is not at the linking stage
rather I get the output on the console when I try to load the code into
the process either via gdb or SIMBL. I surpass the linker warning
with the dynamic_lookup option.

Thanks again for your help!
Reply all
Reply to author
Forward
0 new messages