This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHooks.m
58 lines (46 loc) · 2.28 KB
/
Hooks.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
#import <CaptainHook/CaptainHook.h>
#import "MPIncomingPhoneCallController.h"
#import "CallManager.h"
#import "IncomingCallView.h"
CHDeclareClass(MPIncomingPhoneCallController);
CHOptimizedMethod(1, self, id, MPIncomingPhoneCallController, initWithCall, CTCallRef, call) {
id orig = CHSuper(1, MPIncomingPhoneCallController, initWithCall, call);
[[CallManager sharedManager] setupForController:orig withCall:call];
return orig;
}
CHOptimizedMethod(0, self, void, MPIncomingPhoneCallController, dealloc) {
[[CallManager sharedManager] teardownForController:self];
CHSuper(0, MPIncomingPhoneCallController, dealloc);
}
CHOptimizedMethod(0, self, UIView *, MPIncomingPhoneCallController, newTopBar) {
UIView *orig = CHSuper(0, MPIncomingPhoneCallController, newTopBar);
[[CallManager sharedManager] setForController:self ABUID:[self incomingCallerABUID]];
[orig addSubview:[[CallManager sharedManager] viewForController:self]];
return orig;
}
CHOptimizedMethod(3, self, void, MPIncomingPhoneCallController, updateLCDWithName, NSString *, name, label, NSString *, aLabel, breakPoint, unsigned, aBreakPoint) {
if ([[CallManager sharedManager] hasViewForController:self]) {
[[[CallManager sharedManager] viewForController:self] setLocationFallback:aLabel];
aLabel = @" ";
}
CHSuper(3, MPIncomingPhoneCallController, updateLCDWithName, name, label, aLabel, breakPoint, aBreakPoint);
}
CHDeclareClass(SBPluginManager);
CHOptimizedMethod(1, self, Class, SBPluginManager, loadPluginBundle, NSBundle *, bundle) {
id orig = CHSuper(1, SBPluginManager, loadPluginBundle, bundle);
if ([[bundle bundleIdentifier] isEqualToString:@"com.apple.mobilephone.incomingcall"] && [bundle isLoaded]) {
CHLoadLateClass(MPIncomingPhoneCallController);
CHHook(1, MPIncomingPhoneCallController, initWithCall);
CHHook(0, MPIncomingPhoneCallController, dealloc);
CHHook(0, MPIncomingPhoneCallController, newTopBar);
CHHook(3, MPIncomingPhoneCallController, updateLCDWithName, label, breakPoint);
}
return orig;
}
CHConstructor {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[CallManager sharedManager];
CHLoadLateClass(SBPluginManager);
CHHook(1, SBPluginManager, loadPluginBundle);
[pool drain];
}