1

I'm trying to write a tweak for an app on the iPhone. I have a good background in objective C and iPhone dev, but I've never done any Cydia jailbreak tweaks, save for a few tutorials on tweaks using rpetrich's dumped headers. I'm looking to use PoedCrackMod to decrypt, class-dump-z to get the headers, and then theos/logos to patch the cracked app.

I've gone ahead and run PoedCrackMod to decrypt the app. This yields me a .ipa file which I can then extract to get the .app file, which contains the actual application binary.

I can than use

class-dump-z -k -k -H -g -o ~/dumped_headers/ Foo

to go ahead and get a directory of headers files. I copy these headers to $THEOS/include/Foo. (Should I be using the -g option [Display exported classes only] here, or can I hook non-exported classes as well?)

At this point, I should be able to create a tweak.xm file that looks something like this:

#import <Foo/Foo.h>

and for reference the makefile looks like:

include theos/makefiles/common.mk

TWEAK_NAME = FooTweak
FooTweak_FILES = Tweak.xm

include $(THEOS_MAKE_PATH)/tweak.mk

When I go ahead and try to compile my Tweak (which at this point should do nothing), I come up with all sorts of duplicate declaration errors. Is this normal, or am I doing something wrong?

If it is normal, how do I go about correcting this? I've tried commenting out duplicate declarations, in which case I can get it to compile. I've inserted 20+ hooks that create UIAlertViews when the method is called, but none of them ever seem to trigger- leading me to believe that I'm not hooking methods that aren't being called, but that I'm either making a mistake in dumping the headers or importing the headers into my tweak?

Does anyone have any insights on what I may be doing wrong?

1 Answers1

1

Do not use #import <Foo/Foo.h>

Instead

[File] tweak.xm:

#import <substrate.h>

@interface FooToBeHookedHeader : NSObject {} // We take NSObject here as to avoid any errors.
- (void)fooMethod1; // Only put the methods you are hooking
- (void)fooInheritedMethod; // Inherited method (if hooking) as we are using NSObject up there :)
@end

%hook FooToBeHookedHeader
- (void)fooMethod1 {
// Do hooking stuff
} 
- (void)fooInheritedMethod {
// Do hooking stuff
}
%end

// Include any instance variables which you are modifying if any :)
// ~ SuperDev

Also include the identifier of the App/Framework being hooked in your FooTweak.plist

s6luwJ0A3I
  • 1,023
  • 1
  • 9
  • 22
  • This approach worked. I did need to do one more thing though, which was to edit my FooTweak.plist file to contain the bundle name of the application rather than the springboard. I'm not sure if this is the default, or if I somehow changed it otherwise. – Alex Blyton Jan 02 '13 at 03:01
  • When you create a tweak you get to write down the identifier of the app/framework you are hooking. If a specific header is being hooked, include the bundle identifier of the application/framework using that specific class. – s6luwJ0A3I Jan 02 '13 at 16:09