Doodle-Jump hack

Discussion in 'iOS Jailbreak & Cydia' started by flyingguitar, Aug 6, 2010.

  1. flyingguitar

    flyingguitar Active Member

    Joined:
    May 14, 2008
    Messages:
    1,860
    Likes Received:
    11
    Device:
    iPhone 6
    So I spent the past few hours playing around with doodle-jump and came up with a few hacks for you guys. Now these are all generally pretty easy Hacks and hopefully there will be more to come. I know there are some bugs... Report them if you find any please.

    So basically the hack makes it so none of the platforms move, or can disappear. That generally makes the game at least a little easier. Anyway, because I'm so nice

    Please Register or Log in to view images

    and strongly believe in open source. I've included the source code here too.

    Code:
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <objc/runtime.h>
     
    #include <substrate.h>
    #pragma mark -
     
    //Creates a class to hold self and _cmd values
    @interface HoldOldValues : NSObject
    {
    }
     
    -(void)setSelf:(id)s And_cmd:(SEL)s_c;
    -(id)_self;
    -(SEL)__cmd;
     
    @end
     
    @implementation HoldOldValues
     
    static id _self = nil;
    static SEL __cmd = nil;
     
    -(void) setSelf:(id)s And_cmd:(SEL)s_c {
        _self = s;
        __cmd = s_c;
    }
     
    -(id)_self {
        return _self;
    }
     
    -(SEL)__cmd {
        return __cmd;
    }
     
    @end
     
    #pragma mark -
    #pragma mark UIActionSheetWithTable
     
    //Declares an actionSheet with a table
    @interface UIActionSheetWithTable : UIActionSheet {
        UITableView *tableView;
    }
     
    -(id)initWithTitle:(NSString *)title delegate:(id <UIActionSheetDelegate, UITableViewDelegate, UITableViewDataSource>)delegate cancelButtonTitle:(NSString *)cancelTitle otherButtonTitle:(NSString *)otherTitle showInView:(UIView *)viewToShowIn;
    -(void)dealloc;
    @end
     
    @implementation UIActionSheetWithTable
     
    -(id)initWithTitle:(NSString *)title delegate:(id <UIActionSheetDelegate, UITableViewDelegate, UITableViewDataSource>)delegate cancelButtonTitle:(NSString *)cancelTitle otherButtonTitle:(NSString *)otherTitle showInView:(UIView *)viewToShowIn {
     
        //Calls supers init method
        if (self = [super initWithTitle:title delegate:delegate cancelButtonTitle:cancelTitle destructiveButtonTitle:nil otherButtonTitles:otherTitle, nil]) {
     
            //shows in view and changes frame to make room for the table
            [self showInView:viewToShowIn];
            [self setFrame:CGRectMake(0, 152, 320, 328)];
     
            //makes a new table and adds it to the actionSheet
            UITableView *newTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, 320, 160) style:UITableViewStylePlain];
            [newTable setDelegate: delegate];
            [newTable setDataSource: delegate];
            tableView = [newTable retain];
            [self addSubview:tableView];
            [newTable release];
     
            //moves buttons to make them visible (i.e not under the table)
            [[self.subviews objectAtIndex:1] setFrame:CGRectMake(20, 221, 280, 46)];
            [[self.subviews objectAtIndex:2] setFrame:CGRectMake(20, 276, 280, 46)];
        }
     
        return self;
    }
     
    -(void)dealloc {
        [tableView release];
        [super dealloc];
    }
     
    @end
     
    #pragma mark -
    #pragma mark Delegate
     
    static NSDictionary *shouldLoad = nil;
    static IMP __playButtonTouched;
     
    //Declares delegate for actionSheet and delegate and datasource for the table
    @interface MyDelegateObject : HoldOldValues <UIActionSheetDelegate, UITableViewDelegate, UITableViewDataSource>
    {
    }
     
    @end
     
    @implementation MyDelegateObject
     
    //declares some static values for working with the dictionary
    static NSNumber *numYesVal = [NSNumber numberWithInt:YES];
    static NSNumber *numNoVal = [NSNumber numberWithInt:NO];
    static NSArray *tableNames = [NSArray arrayWithObjects:mad:"Don't move horizontal", @"Don't explode", @"Don't move vertical", @"Don't fade", @"No breaking platforms", @"Can move all platforms", nil];
    static NSMutableDictionary *tableValues = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:numYesVal, numYesVal, numYesVal, numYesVal, numYesVal, numNoVal, nil] forKeys:tableNames];
     
    #pragma mark -
    #pragma mark Sheet Delegate
     
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        if (buttonIndex != [actionSheet cancelButtonIndex])
            shouldLoad = tableValues; //sets the shouldLoad values based on the tableValues if the user hit the play button
    }
     
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
        if (buttonIndex != [actionSheet cancelButtonIndex])
            __playButtonTouched(_self, __cmd); //calls original play button function if user selected the play button
                [self release]; //releases the delegate so that we can be good memory citizens ;D
    }
     
     
    #pragma mark -
    #pragma mark Table Data Source
     
    - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
        return [tableNames count]; //sets number of rows
    }
     
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        static NSString *cellID = @"CellID"; //Cell identification
     
        //creates new table cell
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        if (cell == nil)
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
     
        NSUInteger row = [indexPath row];
        id key = [tableNames objectAtIndex:row];
     
        //Set cells text and accessory view
        cell.textLabel.text = (NSString *) key;
        cell.accessoryType = ([[tableValues objectForKey:key] intValue]) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
     
        return cell;
     
    }
     
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        return 1; //Number of sections
    }
     
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
        return @"Platforms"; //section name
    }
     
    #pragma mark -
    #pragma mark Table Delegate
     
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     
        //grabs value for the selected cell
            UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        NSUInteger row = [indexPath row];
     
        //unchecks all other cells if the last cell is selected, also changes values
            if ([cell.textLabel.text isEqualToString:[tableNames lastObject]]) {
                for (unsigned int i = 0; i < ([tableNames count] - 1); i++) {
                    NSUInteger index[] = {0, i};
                    NSIndexPath *newIndexPath = [[NSIndexPath alloc] initWithIndexes:index length:2];
           
                    UITableViewCell *anotherCell = [tableView cellForRowAtIndexPath:newIndexPath];
                    anotherCell.accessoryType = UITableViewCellAccessoryNone;
                    [tableValues setValue:numNoVal forKey:[tableNames objectAtIndex:i]];
                    [newIndexPath release];
                    }
                }
     
        //changes value for last cell if any other cells are selected
            else {
                NSUInteger index[] = {0, [tableNames count]};
                NSIndexPath *newIndexPath = [[NSIndexPath alloc] initWithIndexes:index length:2];
       
                UITableViewCell *anotherCell = [tableView cellForRowAtIndexPath:newIndexPath];
                anotherCell.accessoryType = UITableViewCellAccessoryNone;
                [tableValues setValue:numNoVal forKey:[tableNames lastObject]];
                [newIndexPath release];
                }
     
     
        //changes selected cell value
        if (cell.accessoryType == UITableViewCellAccessoryCheckmark)
            [tableValues setValue:numNoVal forKey:[tableNames objectAtIndex:row]];
     
        else
            [tableValues setValue:numYesVal forKey:[tableNames objectAtIndex:row]];
     
        //reloads table and deselects the cell
        [tableView reloadData];
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }
     
    @end
     
    //Declares another object for holding self and _cmd, specifically for exploding platforms
    @interface NSIsExploding : NSObject {
        id _self;
        SEL __cmd;
    }
     
    +(void)setSelf:(id)s And_cmd:(SEL)s_c;
    +(id)_self;
    +(SEL)__cmd;
     
    @end
     
    @implementation NSIsExploding
     
    static id __self = nil;
    static SEL ___cmd = nil;
     
    +(void) setSelf:(id)s And_cmd:(SEL)s_c {
        __self = s;
        ___cmd = s_c;
    }
     
    +(id)_self {
        return __self;
    }
     
    +(SEL)__cmd {
        return ___cmd;
    }
     
    @end
     
     
    //defines some platform values
    #define kBreakingPlatform 2
    #define kMovingTouchablePlatform 7
    #define kNormalPlatform 0
     
    #pragma mark -
    #pragma mark Hooked DoodleJump messages
     
    /*
    *these are all of the hooked messages, they will either load
    *with the hacks or load the original function based on what was
    *selected on the table.
    */
     
    static IMP __setIsMovingH;
    void _setIsMovingH (id self, SEL _cmd, id h) {
        if ([[shouldLoad objectForKey:mad:"Don't move horizontal"] intValue] || [[shouldLoad objectForKey:mad:"Can move all platforms"] intValue])
            __setIsMovingH(self, _cmd, false);
        else
            __setIsMovingH(self, _cmd, h);
    }
     
    static IMP __setIsExplodingOrMovingV;
    static IMP __setShouldExplode;
    void _setShouldExplode (id self, SEL _cmd, id h) {
        if ([[shouldLoad objectForKey:mad:"Don't explode"] intValue] || [[shouldLoad objectForKey:mad:"Can move all platforms"] intValue]) {
            __setShouldExplode(self, _cmd, false);
            __setIsExplodingOrMovingV([NSIsExploding _self], [NSIsExploding __cmd], false);
            }
        else {
            __setShouldExplode(self, _cmd, h);
            __setIsExplodingOrMovingV([NSIsExploding _self], [NSIsExploding __cmd], true);
            }
    }
     
    void _setIsExplodingOrMovingV (id self, SEL _cmd, id h) {
        [NSIsExploding setSelf:self And_cmd:_cmd];
        if (([[shouldLoad objectForKey:mad:"Don't move vertical"] intValue]) || [[shouldLoad objectForKey:mad:"Can move all platforms"] intValue])
            __setIsExplodingOrMovingV(self, _cmd, false);
        else
            __setIsExplodingOrMovingV(self, _cmd, h);
    }
     
    static IMP __setIsFading;
    void _setIsFading (id self, SEL _cmd, id h) {
        if ([[shouldLoad objectForKey:mad:"Don't fade"] intValue] || [[shouldLoad objectForKey:mad:"Can move all platforms"] intValue])
            __setIsFading(self, _cmd, false);
        else
            __setIsFading(self, _cmd, h);
    }
     
    static IMP __setType;
    void _setType (id self, SEL _cmd, int type) {
        if ([[shouldLoad objectForKey:mad:"No breaking platforms"] intValue] && (type == kBreakingPlatform))
            type = kNormalPlatform;
        else if ([[shouldLoad objectForKey:mad:"Can move all platforms"] intValue])
            type = kMovingTouchablePlatform;
        __setType(self, _cmd, type);
    }
     
    void _playButtonTouched (id self, SEL _cmd) {
        MyDelegateObject *myDelegate = [[MyDelegateObject alloc] init];
        [myDelegate setSelf:self And_cmd:_cmd];
        UIActionSheetWithTable *sheet = [[UIActionSheetWithTable alloc] initWithTitle:mad:"Pick Hacks" delegate:myDelegate cancelButtonTitle:mad:"Cancel" otherButtonTitles:mad:"Play" showInView:(object_getIvar(self, class_getClassVariable(self, "window")))];
        [sheet release];
    }
     
    #pragma mark -
    #pragma mark dylib initialization and initial hooks
     
    //HookInit gets class values and reimplementes these methods
    extern "C" void hookInit() {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     
        //Checks open application
        NSString *identifier = [[NSBundle mainBundle] bundleIdentifier];
        if (![identifier isEqualToString:mad:"com.yourcompany.DoodleJump"])
            return;
     
        Class $DJ_Platform = objc_getClass("PlatformObject");
     
        MSHookMessageEx($DJ_Platform, @selector(setIsMovingH:), (IMP) _setIsMovingH, (IMP *) &__setIsMovingH);
        MSHookMessageEx($DJ_Platform, @selector(setShouldExplode:), (IMP) _setShouldExplode, (IMP *) &__setShouldExplode);
        MSHookMessageEx($DJ_Platform, @selector(setIsExplodingOrMovingV:), (IMP) _setIsExplodingOrMovingV, (IMP *) &__setIsExplodingOrMovingV);
        MSHookMessageEx($DJ_Platform, @selector(setIsFading:), (IMP) _setIsFading, (IMP *) &__setIsFading);
        MSHookMessageEx($DJ_Platform, @selector(setType:), (IMP) _setType, (IMP *) &__setType);
     
        Class $DJ_AppDelegate = objc_getClass("JumpAppDelegate");
     
        MSHookMessageEx($DJ_AppDelegate , @selector(playButtonTouched), (IMP) _playButtonTouched, (IMP *) &__playButtonTouched);
     
        [pool release];
    }
    
    UPDATES:
    • Now includes alert to change enabled hacks at runtime.
    • New hack to make all platforms touchable.
    • Can change hacks from pause menu in the middle of the game.
    • Adds some hacks with jet-packs and rockets.
    • No monsters option.
    • Bug fixes

    Please Register or Log in to view images



    Please Register or Log in to view images



    CLICK

    install instructions :
    1. download and extract the .zip
    2. SSH to /Library/MobileSubstrate/DynamicLibraries/ on iDevice
    3. chmod 0755
    4. respring

    Attached Files:

    Last edited: Aug 8, 2012
  2. Centter

    Centter New Member

    Joined:
    Apr 23, 2008
    Messages:
    7
    Likes Received:
    0
    Why would you want this, it is a game...
  3. iP0dT0uch1

    iP0dT0uch1 Member

    Joined:
    Jun 28, 2010
    Messages:
    472
    Likes Received:
    0
    Device:
    4G iPod touch
    People want this because it's just a little bit of fun, and also pretty cool!

    Please Register or Log in to view images

  4. sanga282

    sanga282 New Member

    Joined:
    Mar 13, 2009
    Messages:
    289
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    tis interesting, im not really able to comment on the code as its not a language that i am able to use easily/well but i like the idea. Could you theoretically run a hack for any game? or only some that use certain values?
  5. batoul

    batoul New Member

    Joined:
    Aug 8, 2010
    Messages:
    16
    Likes Received:
    0
    what does it do?
  6. PackerEagles10

    PackerEagles10 Banned

    Joined:
    Aug 7, 2010
    Messages:
    136
    Likes Received:
    0
    Device:
    iPhone 3GS (White)
    It enables hacks for the AppStore game: Doodle Jump.
  7. flyingguitar

    flyingguitar Active Member

    Joined:
    May 14, 2008
    Messages:
    1,860
    Likes Received:
    11
    Device:
    iPhone 6
    Yes I can do hacks for any game. There is a lot more I can do then just change the values. Although that's all I'm doing in this particular hack. If you (or anybody else) has a request for me to hack another game, or further develop this one, send me a message and I'll try to get to it when I have some free time.

    On a separate note, I thought that it would be cool to have an alert come up when you hit the play button to allow you to choose what hacks you want to be enabled or disabled at runtime. Do you guys think I should do this? Also I've tried playing a little bit with the monsters as well as some other obstacles, it definitely is a fun game to play around with. Give me some feedback and we'll work from there

    Please Register or Log in to view images

  8. xmubzx

    xmubzx New Member

    Joined:
    Aug 11, 2010
    Messages:
    10
    Likes Received:
    0
    Yes That Would Be Great For DoodleJump
    Fantastic Work !
  9. sanga282

    sanga282 New Member

    Joined:
    Mar 13, 2009
    Messages:
    289
    Likes Received:
    0
    Device:
    iPhone 4 (Black)
    well im thinking i might try and learn my way through some objective based C and see how things go for me, so hopefully after a few weeks i should be able to give it a crack myself

    Please Register or Log in to view images

    and yeah an alert would be pretty cool, or maybe a separate app that shows you what hacks are active for games
  10. flyingguitar

    flyingguitar Active Member

    Joined:
    May 14, 2008
    Messages:
    1,860
    Likes Received:
    11
    Device:
    iPhone 6
    haha, yeah. I actually just finished that. It was a quite a bit of work as you will see in the code when I update it any minute now.
    ------------------double post merged------------------
    updated

    Please Register or Log in to view images

Share This Page