-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tweak.xm
96 lines (83 loc) · 2.75 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#import <spawn.h>
#import <FrontBoardServices/FBSSystemService.h>
#import <objc/runtime.h>
#import <UIKit/UIKit.h>
@interface _UIActionSliderKnob : UIView
-(void)touchedAction;
@end
@interface FBSystemService : NSObject
+(id)sharedInstance; //existing presence of object
-(void)shutdownAndReboot:(BOOL)arg1; //shutting down with the option to reboot (the boolean value)
-(void)exitAndRelaunch:(BOOL)arg1; //restart the FrontBoard process (thus restarting SpringBoard as well; the boolean value has no change, the process restarts anyway)
-(void)nonExistantMethod; //fake method to crash in a safe way, loading SafeMode
@end
@interface _UIActionSlider : UIView
@property (nonatomic,copy) NSString* trackText;
@end
@interface _SBInternalPowerDownView : UIView
@end
static int Tap = 1;
static _UIActionSlider* actionSlider;
%hook _UIActionSliderKnob
%new
-(void)touchedAction {
NSArray *titles = @[@"slide to respring", @"slide to safemode", @"slide to soft reboot", @"slide to reboot", @"slide to power off"];
actionSlider.trackText = titles[Tap - 1];
Tap = Tap == 5 ? 1 : Tap + 1;
}
//Tap gesture recognizer/ if _UIActionSliderKnob gets tapped 1 time it calls touchedAction
-(instancetype)initWithFrame:(CGRect)frame {
self = %orig;
if (self) {
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchedAction)];
tapRecognizer.numberOfTapsRequired = 1;
tapRecognizer.cancelsTouchesInView = NO;
[self addGestureRecognizer:tapRecognizer];
}
return self;
}
%end
%hook _UIActionSlider
-(void)didMoveToWindow {
%orig;
actionSlider = self;
}
%end
%hook _SBInternalPowerDownView
//shutdown
-(void)_powerDownSliderDidCompleteSlide{
if (Tap == 1) {
[[%c(FBSystemService) sharedInstance] shutdownAndReboot:NO];
}
//respring
else if (Tap == 2) {
NSLog(@"called 1");
pid_t pid;
int status;
const char* args[] = {"killall", "-9", "SpringBoard", NULL};
posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
waitpid(pid, &status, WEXITED);
}
//safemode
else if (Tap == 3) {
NSLog(@"called 2");
pid_t pid;
int status;
const char* args[] = {"killall", "-SEGV", "SpringBoard", NULL};
posix_spawn(&pid, "/usr/bin/killall", NULL, NULL, (char* const*)args, NULL);
waitpid(pid, &status, WEXITED);
}
//soft reboot
else if (Tap == 4) {
pid_t pid;
int status;
const char* args[] = {"ldRun", NULL, NULL, NULL};
posix_spawn(&pid, "/usr/bin/ldRun", NULL, NULL, (char* const*)args, NULL);
waitpid(pid, &status, WEXITED);
}
//reboot
else if (Tap == 5) {
[[%c(FBSystemService) sharedInstance] shutdownAndReboot:YES];
}
}
%end