X-Git-Url: https://git.saurik.com/safemode-ios.git/blobdiff_plain/b4f9ed46bedfc2fccd3c8795222e473fb4609f94..e5a54d6937cd0e999c2ba53e35d5545b0b495745:/MobileSafety.mm diff --git a/MobileSafety.mm b/MobileSafety.mm index dd72050..01ce78a 100644 --- a/MobileSafety.mm +++ b/MobileSafety.mm @@ -1,5 +1,5 @@ /* Cydia Substrate - Meta-Library Insert for iPhoneOS - * Copyright (C) 2008-2009 Jay Freeman (saurik) + * Copyright (C) 2008-2010 Jay Freeman (saurik) */ /* @@ -44,6 +44,7 @@ #import #import #import +#import #import #import @@ -70,13 +71,15 @@ void SafeModeAlertItem$alertSheet$buttonClicked$(id self, SEL sel, id sheet, int } void SafeModeAlertItem$configure$requirePasscodeForActions$(id self, SEL sel, BOOL configure, BOOL require) { - UIModalView *sheet([self alertSheet]); + id sheet([self alertSheet]); [sheet setDelegate:self]; [sheet setBodyText:@"We apologize for the inconvenience, but SpringBoard has just crashed.\n\nMobileSubstrate /did not/ cause this problem: it has protected you from it.\n\nYour device is now running in Safe Mode. All extensions that support this safety system are disabled.\n\nReboot (or restart SpringBoard) to return to the normal mode. To return to this dialog touch the status bar."]; [sheet addButtonWithTitle:@"OK"]; [sheet addButtonWithTitle:@"Restart"]; [sheet addButtonWithTitle:@"Help"]; [sheet setNumberOfRows:1]; + if ([sheet respondsToSelector:@selector(setForceHorizontalButtonsLayout:)]) + [sheet setForceHorizontalButtonsLayout:YES]; } void SafeModeAlertItem$performUnlockAction(id self, SEL sel) { @@ -98,7 +101,7 @@ static void MSAlert() { } if ($SBAlertItemsController != nil) - [[$SBAlertItemsController sharedInstance] activateAlertItem:[[$SafeModeAlertItem alloc] init]]; + [[$SBAlertItemsController sharedInstance] activateAlertItem:[[[$SafeModeAlertItem alloc] init] autorelease]]; } MSHook(void, SBStatusBar$touchesEnded$withEvent$, SBStatusBar *self, SEL sel, id touches, id event) { @@ -111,6 +114,18 @@ MSHook(void, SBStatusBar$mouseDown$, SBStatusBar *self, SEL sel, GSEventRef even _SBStatusBar$mouseDown$(self, sel, event); } +MSHook(void, UIStatusBar$touchesBegan$withEvent$, id self, SEL sel, void *arg0, void *arg1) { + MSAlert(); + _UIStatusBar$touchesBegan$withEvent$(self, sel, arg0, arg1); +} + +MSHook(void, SBStatusBarDataManager$_updateTimeString, id self, SEL sel) { + if (char *_data = &MSHookIvar(self, "_data")) { + char *timeString(_data + 20); + strcpy(timeString, "Exit Safe Mode"); + } +} + static void SBIconController$showInfoAlertIfNeeded(id self, SEL sel) { static bool loaded = false; if (loaded) @@ -176,7 +191,7 @@ MSHook(void, SBStatusBarTimeView$tile, SBStatusBarTimeView *self, SEL sel) { #define Dylib_ "/Library/MobileSubstrate/MobileSubstrate.dylib" -extern "C" void MSInitialize() { +MSInitialize { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"MS:Warning: Entering Safe Mode"); @@ -185,8 +200,11 @@ extern "C" void MSInitialize() { _SBUIController$init = MSHookMessage(objc_getClass("SBUIController"), @selector(init), &$SBUIController$init); _SBStatusBar$touchesEnded$withEvent$ = MSHookMessage(objc_getClass("SBStatusBar"), @selector(touchesEnded:withEvent:), &$SBStatusBar$touchesEnded$withEvent$); _SBStatusBar$mouseDown$ = MSHookMessage(objc_getClass("SBStatusBar"), @selector(mouseDown:), &$SBStatusBar$mouseDown$); + _SBStatusBarDataManager$_updateTimeString = MSHookMessage(objc_getClass("SBStatusBarDataManager"), @selector(_updateTimeString), &$SBStatusBarDataManager$_updateTimeString); _SBStatusBarTimeView$tile = MSHookMessage(objc_getClass("SBStatusBarTimeView"), @selector(tile), &$SBStatusBarTimeView$tile); + _UIStatusBar$touchesBegan$withEvent$ = MSHookMessage(objc_getClass("UIStatusBar"), @selector(touchesBegan:withEvent:), &$UIStatusBar$touchesBegan$withEvent$); + _UIImage$defaultDesktopImage = MSHookMessage(object_getClass(objc_getClass("UIImage")), @selector(defaultDesktopImage), &$UIImage$defaultDesktopImage); char *dil = getenv("DYLD_INSERT_LIBRARIES");