/
Tweak.xm
78 lines (59 loc) · 1.88 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
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
static int visible = 0;
%hook UIStatusBar
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
%orig;
Class $SBBulletinListController
= objc_getClass("SBBulletinListController");
id bulletinListController
= [$SBBulletinListController sharedInstance];
if (visible)
{
[bulletinListController hideListViewAnimated:YES];
visible = NO;
}
else
{
[bulletinListController showListViewAnimated:YES];
visible = YES;
}
UIWindow *window
= [[UIApplication sharedApplication] keyWindow];
UIView *view = [window viewWithTag:200];
if (!view)
{
UIView *listView
= [bulletinListController listView];
listView.tag = 200;
[window addSubview:listView];
}
}
%end
/* 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.
%hook ClassName
// Hooking a class method
+ (id)sharedInstance {
return %orig;
}
// Hooking an instance method with an argument.
- (void)messageName:(int)argument {
%log; // Write a message about this call, including its class, name and arguments, to the system log.
%orig; // Call through to the original function with its original arguments.
%orig(nil); // Call through to the original function with a custom argument.
// If you use %orig(), you MUST supply all arguments (except for self and _cmd, the automatically generated ones.)
}
// Hooking an instance method with no arguments.
- (id)noArguments {
%log;
id awesome = %orig;
[awesome doSomethingElse];
return awesome;
}
// Always make sure you clean up after yourself; Not doing so could have grave consequences!
%end
*/