-
Notifications
You must be signed in to change notification settings - Fork 24
/
Tweak.xm
79 lines (59 loc) · 2.1 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
#import "MenuWindow/WBAssistantManager.h"
#import "WIFI/WBWifiStore.h"
#import "WIFI/WBWifiModel.h"
#import <SystemConfiguration/CaptiveNetwork.h>
%hook DTAppDelegate
- (void)applicationDidBecomeActive:(id)arg1 {
%orig;
[[WBAssistantManager sharedManager] showMenu];
}
%end
CFArrayRef (*oldCNCopySupportedInterfaces)();
CFDictionaryRef (*oldCNCopyCurrentNetworkInfo)(CFStringRef interfaceName);
Boolean (*oldSCNetworkReachabilityGetFlags)(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags *flags);
CFArrayRef newCNCopySupportedInterfaces() {
CFArrayRef result = NULL;
WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];
if(wifi && wifi.interfaceName) {
NSArray *array = [NSArray arrayWithObject:wifi.interfaceName];
result = (CFArrayRef)CFRetain((__bridge CFArrayRef)(array));
}
if(!result) {
result = oldCNCopySupportedInterfaces();
}
return result;
}
CFDictionaryRef newCNCopyCurrentNetworkInfo(CFStringRef interfaceName) {
CFDictionaryRef result = NULL;
WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];
if(wifi) {
NSDictionary *dictionary = @{
@"BSSID": (wifi.BSSID ? wifi.BSSID : @""),
@"SSID": (wifi.SSID ? wifi.SSID : @""),
@"SSIDDATA": (wifi.SSIDData ? wifi.SSIDData : @"")
};
result = (CFDictionaryRef)CFRetain((__bridge CFDictionaryRef)(dictionary));
}
if(!result) {
result = oldCNCopyCurrentNetworkInfo(interfaceName);
}
return result;
}
Boolean newSCNetworkReachabilityGetFlags(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags *flags) {
Boolean result = false;
WBWifiModel *wifi = [[WBWifiStore sharedStore] wifiHooked];
if(wifi && wifi.flags > 0) {
result = true;
*flags = wifi.flags;
}
if(!result) {
result = oldSCNetworkReachabilityGetFlags(target, flags);
}
return result;
}
%ctor {
%init;
MSHookFunction(&CNCopySupportedInterfaces, &newCNCopySupportedInterfaces, &oldCNCopySupportedInterfaces);
MSHookFunction(&CNCopyCurrentNetworkInfo, &newCNCopyCurrentNetworkInfo, &oldCNCopyCurrentNetworkInfo);
MSHookFunction(&SCNetworkReachabilityGetFlags, &newSCNetworkReachabilityGetFlags, &oldSCNetworkReachabilityGetFlags);
}