]> git.saurik.com Git - safemode-ios.git/commitdiff
Fix the 'it Safe Mode' bug on 4.2+. (chpwn)
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 23 Jul 2011 01:52:46 +0000 (18:52 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 12 Oct 2011 22:14:24 +0000 (15:14 -0700)
MobileSafety.mm

index 3ba31a29cb8b36ccf71220640a600585eace1dcb..d62cab444f068cdbee1ad173b556de89fcf7a043 100644 (file)
@@ -134,10 +134,26 @@ MSInstanceMessageHook2(void, UIStatusBar, touchesBegan,withEvent, void *, touche
 }
 
 MSInstanceMessageHook0(void, SBStatusBarDataManager, _updateTimeString) {
-    if (char *_data = &MSHookIvar<char>(self, "_data")) {
-        char *timeString(_data + 20);
-        strcpy(timeString, "Exit Safe Mode");
-    }
+    char *_data(&MSHookIvar<char>(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) {