summaryrefslogtreecommitdiff
path: root/Tweak.xm
diff options
context:
space:
mode:
Diffstat (limited to 'Tweak.xm')
-rw-r--r--Tweak.xm79
1 files changed, 66 insertions, 13 deletions
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,
};