-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathTweak.xm
More file actions
61 lines (45 loc) · 1.46 KB
/
Tweak.xm
File metadata and controls
61 lines (45 loc) · 1.46 KB
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
#include <UIKit/UIKit.h>
#include <objc/runtime.h>
#include <dlfcn.h>
@interface FLEXManager
+ (instancetype)sharedManager;
- (void)showExplorer;
@end
@interface FLEXLoader: NSObject
@end
@implementation FLEXLoader
+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
static FLEXLoader *loader;
dispatch_once(&onceToken, ^{
loader = [[FLEXLoader alloc] init];
});
return loader;
}
- (void)show {
[[objc_getClass("FLEXManager") sharedManager] showExplorer];
}
@end
%ctor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *pref = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.swiftyper.flexloader.plist"];
NSString *dylibPath = @"/Library/Application Support/FLEXLoader/libFLEX.dylib";
if (![[NSFileManager defaultManager] fileExistsAtPath:dylibPath]) {
NSLog(@"FLEXLoader dylib file not found: %@", dylibPath);
return;
}
NSString *keyPath = [NSString stringWithFormat:@"FLEXLoaderEnabled-%@", [[NSBundle mainBundle] bundleIdentifier]];
if ([[pref objectForKey:keyPath] boolValue]) {
void *handle = dlopen([dylibPath UTF8String], RTLD_NOW);
if (handle == NULL) {
char *error = dlerror();
NSLog(@"Load FLEXLoader dylib fail: %s", error);
return;
}
[[NSNotificationCenter defaultCenter] addObserver:[FLEXLoader sharedInstance]
selector:@selector(show)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
[pool drain];
}