This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
/
libMobileGestalt.xm
53 lines (44 loc) · 2.37 KB
/
libMobileGestalt.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
#import "../Global.h"
#import <CoreFoundation/CoreFoundation.h>
CFTypeRef (*old_MGCopyAnswer)(CFStringRef property);
CFTypeRef (*old_MGCopyMultipleAnswers)(CFArrayRef questions, int __unknown0);
int (*old_MGSetAnswer)(CFStringRef question, CFTypeRef answer);
CFTypeRef MGCopyAnswer(CFStringRef property){
CFTypeRef ReturnVal=old_MGCopyAnswer(property);
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"libMobileGestalt" andMethod:@"MGCopyAnswer"];
[tracer addArgFromPlistObject:(__bridge NSString*)property withKey:@"QueryPropertyName"];
[tracer addReturnValueFromPlistObject:(__bridge NSArray*)ReturnVal];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ReturnVal;
}
CFTypeRef MGCopyMultipleAnswers(CFArrayRef questions, int __unknown0){
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"libMobileGestalt" andMethod:@"MGCopyMultipleAnswers"];
[tracer addArgFromPlistObject:(__bridge NSArray*)questions withKey:@"QueryPropertyNames"];
[tracer addArgFromPlistObject:[NSNumber numberWithInt:__unknown0] withKey:@"UsageUnknown"];
CFTypeRef ReturnVal=old_MGCopyMultipleAnswers(questions,__unknown0);
[tracer addReturnValueFromPlistObject:(__bridge NSArray*)ReturnVal];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ReturnVal;
}
int MGSetAnswer(CFStringRef question, CFTypeRef answer){
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"libMobileGestalt" andMethod:@"MGSetAnswer"];
[tracer addArgFromPlistObject:(__bridge NSString*)question withKey:@"Question"];
[tracer addArgFromPlistObject:(__bridge NSObject*)answer withKey:@"Answer"];
int ReturnVal=old_MGSetAnswer(question,answer);
[tracer addReturnValueFromPlistObject:[NSNumber numberWithInt:ReturnVal]];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ReturnVal;
}
static void Loader(){
WTHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyAnswer")),(void*)MGCopyAnswer, (void**)&old_MGCopyAnswer);
WTHookFunction(((void*)MSFindSymbol(NULL, "_MGCopyMultipleAnswers")),(void*)MGCopyMultipleAnswers, (void**)&old_MGCopyMultipleAnswers);
WTHookFunction(((void*)MSFindSymbol(NULL, "_MGSetAnswer")),(void*)MGSetAnswer, (void**)&old_MGSetAnswer);
}
WTCallBack(@"Gestalt",Loader)
extern void init_libMobileGestalt_hook(){
WTAddCallBack(Loader);
}
//Shall We Check Entitlement com.apple.private.MobileGestalt.AllowedProtectedKeys ,which is needed for certain keys?