This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
/
CoreTelephony.xm
134 lines (126 loc) · 5.35 KB
/
CoreTelephony.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#import "../Global.h"
struct CTResult
{
int flag;
int a;
};
struct __CTServerConnection {
int a;
int b;
CFMachPortRef myport;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
};
typedef struct __CTServerConnection CTServerConnection;
typedef CTServerConnection* CTServerConnectionRef;
struct __CellInfo {
int servingmnc;
int network;
int location;
int cellid;
int station;
int freq;
int rxlevel;
int c1;
int c2;
};
typedef struct __CellInfo CellInfo;
typedef CellInfo* CellInfoRef;
%group CoreTelephony
%hook CTAsciiAddress
+ (id)asciiAddressWithString:(id)arg1{
id ret=%orig;
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"asciiAddressWithString:"];
[tracer addArgFromPlistObject:arg1 withKey:@"arg1"];
[tracer addReturnValueFromPlistObject: ret];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ret;
}
- (id)canonicalFormat{
id ret=%orig;
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"canonicalFormat"];
[tracer addReturnValueFromPlistObject: ret];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ret;
}
- (id)address{
id ret=%orig;
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"address"];
[tracer addReturnValueFromPlistObject: ret];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ret;
}
- (id)initWithAddress:(id)arg1{
id ret=%orig;
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"initWithAddress"];
[tracer addArgFromPlistObject:arg1 withKey:@"arg1"];
[traceStorage saveTracedCall: tracer];
[tracer release];
return ret;
}
%end
%end
int* (*old_CTServerConnectionCopyMobileEquipmentInfo)(struct CTResult * Status,struct __CTServerConnection * Connection,CFMutableDictionaryRef * Dictionary);
int* new_CTServerConnectionCopyMobileEquipmentInfo(struct CTResult * Status,
struct __CTServerConnection * Connection,
CFMutableDictionaryRef * Dictionary){
int* retValue=old_CTServerConnectionCopyMobileEquipmentInfo(Status,Connection,Dictionary);
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"_CTServerConnectionCopyMobileEquipmentInfo"];
[tracer addArgFromPlistObject:(__bridge NSDictionary*)*Dictionary withKey:@"Dictionary"];
[tracer addArgFromPlistObject:[NSNumber numberWithInt:Status->flag] withKey:@"CTResult->flag"];
[tracer addArgFromPlistObject:[NSNumber numberWithInt:Status->a] withKey:@"CTResult->a"];
[tracer addReturnValueFromPlistObject:[NSNumber numberWithInt:*retValue]];
[traceStorage saveTracedCall: tracer];
[tracer release];
return retValue;
}
void (*old_CTServerConnectionCellMonitorGetCellCount)(CFMachPortRef port,CTServerConnectionRef CRef,int *cellinfo_count);
void _CTServerConnectionCellMonitorGetCellCount(CFMachPortRef port,CTServerConnectionRef CRef,int *cellinfo_count){
old_CTServerConnectionCellMonitorGetCellCount(port,CRef,cellinfo_count);
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"_CTServerConnectionCellMonitorGetCellCount"];
[tracer addArgFromPlistObject:[NSNumber numberWithInt:*cellinfo_count] withKey:@"cellinfo_count"];
[traceStorage saveTracedCall: tracer];
[tracer release];
}
void (*old_CTServerConnectionCellMonitorGetCellInfo)(CFMachPortRef port,CTServerConnectionRef,int cellinfo_number,CellInfoRef* ref);
void _CTServerConnectionCellMonitorGetCellInfo(CFMachPortRef port,CTServerConnectionRef CRef,int cellinfo_number,CellInfoRef* ref){
old_CTServerConnectionCellMonitorGetCellInfo(port,CRef,cellinfo_number,ref);
CallTracer *tracer = [[CallTracer alloc] initWithClass:@"CTAsciiAddress" andMethod:@"_CTServerConnectionCellMonitorGetCellInfo"];
[tracer addArgFromPlistObject:[NSNumber numberWithInt:cellinfo_number] withKey:@"cellinfo_number"];
struct __CellInfo* info=*ref;
[tracer addArgFromPlistObject:@{@"servingmnc":[NSNumber numberWithInt:info->servingmnc],
@"location":[NSNumber numberWithInt:info->location],
@"cellid":[NSNumber numberWithInt:info->cellid],
@"station":[NSNumber numberWithInt:info->station],
@"freq":[NSNumber numberWithInt:info->freq],
@"rxlevel":[NSNumber numberWithInt:info->rxlevel],
@"c1":[NSNumber numberWithInt:info->c1],
@"c2":[NSNumber numberWithInt:info->c2],
@"network":[NSNumber numberWithInt:info->network]
}
withKey:@"CellInfo"];
[traceStorage saveTracedCall: tracer];
[tracer release];
}
/*
typedef void (*CTServerConnectionCallback)(CTServerConnectionRef, CFStringRef, CFDictionaryRef, void *);
int _CTServerConnectionSetVibratorState(int *, void *, int, int, int, int, int);
*/
static void Loader(){
%init(CoreTelephony);
WTHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCopyMobileEquipmentInfo")),(void*)new_CTServerConnectionCopyMobileEquipmentInfo, (void**)&old_CTServerConnectionCopyMobileEquipmentInfo);
WTHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCellMonitorGetCellCount")),(void*)_CTServerConnectionCellMonitorGetCellCount, (void**)&old_CTServerConnectionCellMonitorGetCellCount);
WTHookFunction(((void*)MSFindSymbol(NULL, "__CTServerConnectionCellMonitorGetCellInfo")),(void*)_CTServerConnectionCellMonitorGetCellInfo, (void**)&old_CTServerConnectionCellMonitorGetCellInfo);
}
WTCallBack(@"CoreTelephony",Loader)
extern void init_CoreTelephony_hook(){
WTAddCallBack(Loader);
}