-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroupPatcher.m
65 lines (54 loc) · 2.43 KB
/
GroupPatcher.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
#import <Foundation/Foundation.h>
#import <substrate.h>
static NSDictionary * replacement;
static NSString * replaceKey(NSString *origKey) {
NSLog(@"[GroupPatcher] orig key: %@", origKey);
NSString *newKey = replacement[origKey];
if (newKey != nil) {
NSLog(@"[GroupPatcher] Replacing key: %@ to : %@", origKey, newKey);
return newKey;
}
return origKey;
}
// -[NSFileManager containerURLForSecurityApplicationGroupIdentifier:]
static NSURL *(*orig_NSFileManager_container)(id, SEL, id);
static NSURL *override_NSFileManager_container(id self, SEL _cmd, NSString *groupIdentifier){
return orig_NSFileManager_container(self, _cmd, replaceKey(groupIdentifier));
}
// -[NSUserDefaaults initWithSuiteName:]
static NSUserDefaults *(*orig_NSUserDefaults_suit)(id, SEL, id);
static NSUserDefaults *override_NSUserDefaults_suit(id self, SEL _cmd, NSString *suit){
return orig_NSUserDefaults_suit(self, _cmd, replaceKey(suit));
}
// +[NSHTTPCookieStorage sharedCookieStorageForGroupContainerIdentifier:]
static NSHTTPCookieStorage *(*orig_NSHTTPCookieStorage_container)(id, SEL, id);
static NSHTTPCookieStorage *override_NSHTTPCookieStorage_container(NSHTTPCookieStorage *self, SEL _cmd, NSString *identifier){
return orig_NSHTTPCookieStorage_container(self, _cmd, replaceKey(identifier));
}
__attribute__((constructor)) static void Siuuuu(void){
// "group.com.facebook.family" gets replaced to "group.dev.extbh.family"
replacement = @{
@"group.com.facebook.family": @"group.dev.extbh.family",
@"group.com.facebook.Messenger": @"group.dev.extbh.Messenger",
@"group.com.facebook.msysstorage": @"group.dev.extbh.msysstorage",
@"T84QZS65DQ.platformFamily" : @"82DA3FVS98.platformFamily"
};
MSHookMessageEx(
NSClassFromString(@"NSFileManager"),
@selector(containerURLForSecurityApplicationGroupIdentifier:),
(IMP) &override_NSFileManager_container,
(IMP*) &orig_NSFileManager_container
);
MSHookMessageEx(
NSClassFromString(@"NSUserDefaults"),
@selector(initWithSuiteName:),
(IMP) &override_NSUserDefaults_suit,
(IMP*) &orig_NSUserDefaults_suit
);
MSHookMessageEx(
objc_getMetaClass("NSHTTPCookieStorage"),
@selector(sharedCookieStorageForGroupContainerIdentifier:),
(IMP) &override_NSHTTPCookieStorage_container,
(IMP*) &orig_NSHTTPCookieStorage_container
);
}