-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathTweak.xm
78 lines (56 loc) · 2.39 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
/* How to Hook with Logos
Hooks are written with syntax similar to that of an Objective-C @implementation.
You don't need to #include <substrate.h>, it will be done automatically, as will
the generation of a class list and an automatic constructor.
*/
#include <dlfcn.h>
@interface MyDKFLEXLoader : NSObject
@end
@implementation MyDKFLEXLoader
+ (instancetype)sharedInstance
{
static dispatch_once_t onceToken;
static MyDKFLEXLoader *_sharedInstance;
dispatch_once(&onceToken, ^{
_sharedInstance = [[self alloc] init];
});
return _sharedInstance;
}
- (void)show
{
// [[FLEXManager sharedManager] showExplorer];
Class FLEXManager = NSClassFromString(@"FLEXManager");
id sharedManager = [FLEXManager performSelector:@selector(sharedManager)];
[sharedManager performSelector:@selector(showExplorer)];
}
@end
%ctor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.yourcompany.flexinjected.plist"] ;
NSString *libraryPath = @"/Library/Application Support/FLEXLoader/FLEX.framework/FLEX";
NSString *keyPath = [NSString stringWithFormat:@"FLEXInjectedEnabled-%@", [[NSBundle mainBundle] bundleIdentifier]];
NSLog(@"SSFLEXLoader before loaded %@,keyPath = %@,prefs = %@", libraryPath,keyPath,prefs);
if ([[prefs objectForKey:keyPath] boolValue]) {
if ([[NSFileManager defaultManager] fileExistsAtPath:libraryPath]){
void *haldel = dlopen([libraryPath UTF8String], RTLD_NOW);
if (haldel == NULL) {
char *error = dlerror();
NSLog(@"dlopen error: %s", error);
} else {
NSLog(@"dlopen load framework success.");
[[NSNotificationCenter defaultCenter] addObserver:[MyDKFLEXLoader sharedInstance]
selector:@selector(show)
name:UIApplicationDidBecomeActiveNotification
object:nil];
}
NSLog(@"SSFLEXLoader loaded %@", libraryPath);
} else {
NSLog(@"SSFLEXLoader file not exists %@", libraryPath);
}
}
else {
NSLog(@"SSFLEXLoader not enabled %@", libraryPath);
}
NSLog(@"SSFLEXLoader after loaded %@", libraryPath);
[pool drain];
}