summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2018-10-10 12:49:13 -1000
committerSam Bingner <sam@bingner.com>2018-10-14 21:11:34 -1000
commit1f226950b01b961674b368554570822c69826c43 (patch)
treef9b45e221063efa638006555fc862f692aa161dd
parentfdf2ae4dbf1d4c961884da76bc3a293609e502d0 (diff)
Updates to work nicely with iOS11
-rw-r--r--Makefile15
-rw-r--r--Tweak.xm79
2 files changed, 75 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 14d0ee2..ba6aa4e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-TARGET := iphone:7.1:2.0
-ARCHS := armv6 armv7s arm64
+TARGET := iphone:11.0:11.0
+ARCHS := arm64
PACKAGE_VERSION := $(shell ./version.sh)
include theos/makefiles/common.mk
@@ -8,10 +8,13 @@ TWEAK_NAME := MobileSafety
MobileSafety_FILES := Tweak.xm
MobileSafety_FRAMEWORKS := UIKit
-ADDITIONAL_CFLAGS += -mllvm -arm-reserve-r9
-ADDITIONAL_LDFLAGS += -Xarch_armv6 -Wl,-lgcc_s.1
+ADDITIONAL_CFLAGS += -Wno-error=tautological-undefined-compare -Wno-error=deprecated-declarations
+#ADDITIONAL_LDFLAGS += -Xarch_armv6 -Wl,-lgcc_s.1
-ADDITIONAL_LDFLAGS += -Xarch_armv6 -Wl,-segalign,4000
-ADDITIONAL_LDFLAGS += -Xarch_armv7s -Wl,-segalign,4000
+#ADDITIONAL_LDFLAGS += -Xarch_armv6 -Wl,-segalign,4000 -Xarch_armv6 -ffixed-r9
+#ADDITIONAL_LDFLAGS += -Xarch_armv7s -Wl,-segalign,4000 -Xarch_armv7s -ffixed-r9
include $(THEOS_MAKE_PATH)/tweak.mk
+
+after-stage::
+ @cp MobileSafety.png $(THEOS_STAGING_DIR)/Library/MobileSubstrate/MobileSafety.png
diff --git a/Tweak.xm b/Tweak.xm
index 189b39b..265744d 100644
--- a/Tweak.xm
+++ b/Tweak.xm
@@ -27,19 +27,28 @@
#include <dlfcn.h>
#include <substrate.h>
+// Because compiler is optimizing out checks for dereferenced null pointers
+template <typename Type_>
+static inline Type_ &MYHookIvar(id self, const char *name) {
+ Ivar ivar(class_getInstanceVariable(object_getClass(self), name));
+ void *value = ivar == NULL ? NULL : *reinterpret_cast<void **>(reinterpret_cast<char *>(self) + ivar_getOffset(ivar));
+ return *reinterpret_cast<Type_ *>(&value);
+}
+
+
Class $SafeModeAlertItem;
#define UIAlertActionStyleDefault 0
-@interface UIAlertAction
-+ (UIAlertAction *) actionWithTitle:(NSString *)title style:(NSUInteger)style handler:(void (^)(UIAlertAction *action))handler;
-@end
+//@interface UIAlertAction
+//+ (UIAlertAction *) actionWithTitle:(NSString *)title style:(NSUInteger)style handler:(void (^)(UIAlertAction *action))handler;
+//@end
-@interface UIAlertController : UIViewController
-- (void) addAction:(UIAlertAction *)action;
-- (void) setMessage:(NSString *)message;
-- (void) setTitle:(NSString *)title;
-@end
+//@interface UIAlertController : UIViewController
+//- (void) addAction:(UIAlertAction *)action;
+//- (void) setMessage:(NSString *)message;
+//- (void) setTitle:(NSString *)title;
+//@end
@interface SBAlertItem : NSObject {
}
@@ -186,6 +195,12 @@ static void MSAlert() {
%orig(touches, event);
} %end
+%hook UIStatusBar_Modern
+- (void) touchesBegan:(void *)touches withEvent:(void *)event {
+ MSAlert();
+ %orig(touches, event);
+} %end
+
// this fairly complex code came from Grant, to solve the "it Safe Mode"-in-bar bug
@@ -254,7 +269,13 @@ static void AlertIfNeeded() {
- (void) _finishUIUnlockFromSource:(int)source withOptions:(id)options {
%orig;
AlertIfNeeded();
-} %end
+}
+
+-(void)lockScreenViewControllerDidDismiss {
+ %orig;
+ AlertIfNeeded();
+}
+%end
// iOS 6
%hook SBAwayController
@@ -313,13 +334,13 @@ static void AlertIfNeeded() {
%hook SBUIController
- (id) init {
if ((self = %orig()) != nil) {
- UIView *&_contentLayer(MSHookIvar<UIView *>(self, "_contentLayer"));
- UIView *&_contentView(MSHookIvar<UIView *>(self, "_contentView"));
+ UIView *_contentLayer = MYHookIvar<UIView *>(self, "_contentLayer");
+ UIView *_contentView = MYHookIvar<UIView *>(self, "_contentView");
UIView *layer;
- if (&_contentLayer != NULL)
+ if (_contentLayer != NULL)
layer = _contentLayer;
- else if (&_contentView != NULL)
+ else if (_contentView != NULL)
layer = _contentView;
else
layer = nil;
@@ -356,6 +377,26 @@ static void AlertIfNeeded() {
_textRect.origin.y = (frame.size.height - size.height) / 2;
} %end
+%hook _UIStatusBarStringView
+- (void) tile {
+ NSString *&_time(MSHookIvar<NSString *>(self, "_time"));
+ CGRect &_textRect(MSHookIvar<CGRect>(self, "_textRect"));
+ if (_time != nil)
+ [_time release];
+ _time = [@"Exit Safe Mode" retain];
+ id font([self textFont]);
+ CGSize size([_time sizeWithFont:font]);
+ CGRect frame([self frame]);
+ _textRect.size = size;
+ _textRect.origin.x = (frame.size.width - size.width) / 2;
+ _textRect.origin.y = (frame.size.height - size.height) / 2;
+} %end
+
+%hook _UIStatusBarStringView
+- (void) setText:(NSString*)text {
+ %orig(@"Exit");
+} %end
+
// on iOS 6.0, Apple split parts of SpringBoard into a daemon called backboardd, including app launches
// in order to allow safe mode to propogate into applications, we need to then tell backboardd here
@@ -371,6 +412,14 @@ static void AlertIfNeeded() {
return %orig(modified);
} %end
+%hook FBApplicationInfo
+- (NSDictionary *)environmentVariables {
+ NSDictionary *originalVariables = %orig;
+ NSMutableDictionary *newVariables = [originalVariables mutableCopy];
+ [newVariables setObject:@1 forKey:@"_MSSafeMode"];
+ return [newVariables autorelease];
+}
+%end
// this highly-general hook replaces all previous attempts to protect SpringBoard from spurious code
// the main purpose is to protect SpringBoard from non-Substrate "away view plug-ins" and "wee apps"
@@ -382,6 +431,10 @@ const char *dylibs_[] = {
"/System/Library/CoreServices",
"/System/Library/AccessibilityBundles",
"/System/Library/HIDPlugins",
+ "/System/Library/SpringBoardPlugins",
+ "/System/Library/Extensions",
+ "/System/Library/BulletinBoardPlugins",
+ "/System/Library/ControlCenter/Bundles",
NULL,
};