-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno_shutdown.m
37 lines (29 loc) · 1.08 KB
/
no_shutdown.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
#import <Foundation/Foundation.h>
void
will_shutdown(
CFNotificationCenterRef center,
void* observer,
CFStringRef name,
const void* object,
CFDictionaryRef userInfo
){
NSLog(@"Exiting...");
exit(0);
}
int
main(int argc, char * argv[]) {
@autoreleasepool {
NSLog(@"Init poc");
NSLog(@"Start listening to 'com.apple.springboard.deviceWillShutDown' notification...");
// Comment out the following function if you want to test the case in which the binary appears inside shutdown.log file
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
will_shutdown,
CFSTR("com.apple.springboard.deviceWillShutDown"),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop run];
}
return 0;
}