-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.xm
33 lines (25 loc) · 897 Bytes
/
main.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
#import <Foundation/Foundation.h>
#include <roothide.h>
#include <dlfcn.h>
static void* _SMJobSubmit;
%hookf(Boolean, _SMJobSubmit, CFStringRef domain, CFDictionaryRef job, CFTypeID auth, CFErrorRef *outError)
{
NSMutableDictionary* mjob = [(__bridge NSDictionary*)job mutableCopy];
if (job != nil && mjob[@"ProgramArguments"] != nil)
{
NSArray* argv = mjob[@"ProgramArguments"];
NSLog(@"_SMJobSubmit argv=%@", argv);
if ([argv[0] hasSuffix:@"/debugserver"])
{
NSMutableArray* new_argv = [argv mutableCopy];
new_argv[0] = jbroot(@"/usr/bin/xcodeanydebug/debugserver");
mjob[@"UserName"] = @"root";
mjob[@"ProgramArguments"] = new_argv;
}
job = (__bridge_retained CFDictionaryRef)mjob;
}
return %orig;
}
%ctor {
_SMJobSubmit = dlsym(RTLD_DEFAULT, "SMJobSubmit");
}