From: Jay Freeman (saurik) Date: Sat, 23 Jul 2011 01:52:46 +0000 (-0700) Subject: Fix the 'it Safe Mode' bug on 4.2+. (chpwn) X-Git-Tag: v0.9.3900~4 X-Git-Url: https://git.saurik.com/safemode-ios.git/commitdiff_plain/22a7ee91ef4d3bdc443789c90c10126529aa52d0 Fix the 'it Safe Mode' bug on 4.2+. (chpwn) --- diff --git a/MobileSafety.mm b/MobileSafety.mm index 3ba31a2..d62cab4 100644 --- a/MobileSafety.mm +++ b/MobileSafety.mm @@ -134,10 +134,26 @@ MSInstanceMessageHook2(void, UIStatusBar, touchesBegan,withEvent, void *, touche } MSInstanceMessageHook0(void, SBStatusBarDataManager, _updateTimeString) { - if (char *_data = &MSHookIvar(self, "_data")) { - char *timeString(_data + 20); - strcpy(timeString, "Exit Safe Mode"); - } + char *_data(&MSHookIvar(self, "_data")); + if (_data == NULL) + return; + + Ivar _itemIsEnabled(object_getInstanceVariable(self, "_itemIsEnabled", NULL)); + if (_itemIsEnabled == NULL) + return; + + Ivar _itemIsCloaked(object_getInstanceVariable(self, "_itemIsCloaked", NULL)); + if (_itemIsCloaked == NULL) + return; + + size_t enabledOffset(ivar_getOffset(_itemIsEnabled)); + size_t cloakedOffset(ivar_getOffset(_itemIsCloaked)); + if (enabledOffset >= cloakedOffset) + return; + + size_t offset(cloakedOffset - enabledOffset); + char *timeString(_data + offset); + strcpy(timeString, "Exit Safe Mode"); } static void SBIconController$showInfoAlertIfNeeded(id self, SEL sel) {