forked from coolstar/uikittools-ng
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sbreload.m
76 lines (58 loc) · 2.2 KB
/
sbreload.m
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
#import <dlfcn.h>
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
typedef NS_OPTIONS(NSUInteger, SBSRelaunchActionOptions) {
SBSRelaunchActionOptionsNone,
SBSRelaunchActionOptionsRestartRenderServer = 1 << 0,
SBSRelaunchActionOptionsSnapshotTransition = 1 << 1,
SBSRelaunchActionOptionsFadeToBlackTransition = 1 << 2
};
@interface SBSRelaunchAction : NSObject
+ (instancetype)actionWithReason:(NSString *)reason options:(SBSRelaunchActionOptions)options targetURL:(NSURL *)targetURL;
@end
@interface FBSSystemService : NSObject
+ (instancetype)sharedService;
- (void)sendActions:(NSSet *)actions withResult:(id)result;
@end
pid_t springboardPID;
pid_t backboarddPID;
int stopService(const char *ServiceName);
int updatePIDs(void);
/* Set platform binary flag */
#define FLAG_PLATFORMIZE (1 << 1)
void platformizeme() {
void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
if (!handle) return;
// Reset errors
dlerror();
typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
const char *dlsym_error = dlerror();
if (dlsym_error) {
return;
}
ptr(getpid(), FLAG_PLATFORMIZE);
}
int main(){
@autoreleasepool {
platformizeme();
springboardPID = 0;
backboarddPID = 0;
updatePIDs();
dlopen("/System/Library/PrivateFrameworks/FrontBoardServices.framework/FrontBoardServices", RTLD_NOW);
dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_NOW);
SBSRelaunchAction *restartAction = [objc_getClass("SBSRelaunchAction") actionWithReason:@"respring" options:(SBSRelaunchActionOptionsRestartRenderServer | SBSRelaunchActionOptionsFadeToBlackTransition) targetURL:nil];
[(FBSSystemService *)[objc_getClass("FBSSystemService") sharedService] sendActions:[NSSet setWithObject:restartAction] withResult:nil];
sleep(2);
int old_springboardPID = springboardPID;
int old_backboarddPID = backboarddPID;
updatePIDs();
if (springboardPID == old_springboardPID){
stopService("com.apple.SpringBoard");
}
if (backboarddPID == old_backboarddPID){
stopService("com.apple.backboardd");
}
}
return 0;
}