Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 274b287

Browse files
committed
Basic CoreLocation
1 parent a228a4c commit 274b287

File tree

5 files changed

+177
-111
lines changed

5 files changed

+177
-111
lines changed

Hooks/API/CoreLocation.xm

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#import "../Global.h"
2+
#import <CoreLocation/CoreLocation.h>
3+
#define LogCLRegion(obj) \
4+
WTAdd(obj.identifier,@"identifier");\
5+
WTAdd([NSNumber numberWithDouble:obj.center.latitude],@"center.latitude");\
6+
WTAdd([NSNumber numberWithDouble:obj.center.longitude],@"center.longitude");\
7+
WTAdd([NSNumber numberWithDouble:obj.radius],@"radius");
8+
typedef double CLLocationDegrees;
9+
10+
/*
11+
* CLLocationAccuracy
12+
*
13+
* Discussion:
14+
* Type used to represent a location accuracy level in meters. The lower the value in meters, the
15+
* more physically precise the location is. A negative accuracy value indicates an invalid location.
16+
*/
17+
typedef double CLLocationAccuracy;
18+
19+
/*
20+
* CLLocationSpeed
21+
*
22+
* Discussion:
23+
* Type used to represent the speed in meters per second.
24+
*/
25+
typedef double CLLocationSpeed;
26+
27+
/*
28+
* CLLocationDirection
29+
*
30+
* Discussion:
31+
* Type used to represent the direction in degrees from 0 to 359.9. A negative value indicates an
32+
* invalid direction.
33+
*/
34+
typedef double CLLocationDirection;
35+
36+
%group CoreLocation
37+
%hook CLLocationManager
38+
- (void)startUpdatingLocation{
39+
if(WTShouldLog){
40+
WTInit(@"CLLocationManager",@"startUpdatingLocation");
41+
WTSave;
42+
WTRelease;
43+
}
44+
%orig;
45+
}
46+
- (void)stopMonitoringSignificantLocationChanges{
47+
if(WTShouldLog){
48+
WTInit(@"CLLocationManager",@"stopMonitoringSignificantLocationChanges");
49+
WTSave;
50+
WTRelease;
51+
}
52+
%orig;
53+
}
54+
- (void)startMonitoringSignificantLocationChanges{
55+
if(WTShouldLog){
56+
WTInit(@"CLLocationManager",@"startMonitoringSignificantLocationChanges");
57+
WTSave;
58+
WTRelease;
59+
}
60+
%orig;
61+
}
62+
- (void)stopUpdatingLocation{
63+
if(WTShouldLog){
64+
WTInit(@"CLLocationManager",@"stopUpdatingLocation");
65+
WTSave;
66+
WTRelease;
67+
}
68+
%orig;
69+
}
70+
- (void)stopUpdatingHeading{
71+
if(WTShouldLog){
72+
WTInit(@"CLLocationManager",@"stopUpdatingHeading");
73+
WTSave;
74+
WTRelease;
75+
}
76+
%orig;
77+
}
78+
- (void)stopMonitoringForRegion:(CLRegion *)region{
79+
if(WTShouldLog){
80+
WTInit(@"CLLocationManager",@"stopMonitoringForRegion:");
81+
LogCLRegion(region);
82+
WTSave;
83+
WTRelease;
84+
}
85+
%orig;
86+
}
87+
- (void)startMonitoringForRegion:(CLRegion *)region{
88+
if(WTShouldLog){
89+
WTInit(@"CLLocationManager",@"startMonitoringForRegion:");
90+
LogCLRegion(region);
91+
WTSave;
92+
WTRelease;
93+
}
94+
%orig;
95+
}
96+
- (void)startUpdatingHeading{
97+
if(WTShouldLog){
98+
WTInit(@"CLLocationManager",@"startUpdatingHeading");
99+
WTSave;
100+
WTRelease;
101+
}
102+
%orig;
103+
}
104+
- (void)requestStateForRegion:(CLRegion *)region{
105+
if(WTShouldLog){
106+
WTInit(@"CLLocationManager",@"requestStateForRegion:");
107+
LogCLRegion(region);
108+
WTSave;
109+
WTRelease;
110+
}
111+
%orig;
112+
}
113+
- (void)stopRangingBeaconsInRegion:(CLBeaconRegion *)region{
114+
if(WTShouldLog){
115+
WTInit(@"CLLocationManager",@"stopRangingBeaconsInRegion:");
116+
LogCLRegion(region);
117+
WTAdd(region.proximityUUID,@"proximityUUID");
118+
WTSave;
119+
WTRelease;
120+
}
121+
%orig;
122+
}
123+
- (void)startRangingBeaconsInRegion:(CLBeaconRegion *)region{
124+
if(WTShouldLog){
125+
WTInit(@"CLLocationManager",@"startRangingBeaconsInRegion:");
126+
LogCLRegion(region);
127+
WTAdd(region.proximityUUID,@"proximityUUID");
128+
WTSave;
129+
WTRelease;
130+
}
131+
%orig;
132+
}
133+
%end
134+
/*%hook CLLocation
135+
- (id)initWithLatitude:(CLLocationDegrees)latitude
136+
longitude:(CLLocationDegrees)longitude{
137+
138+
}
139+
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate
140+
altitude:(CLLocationDistance)altitude
141+
horizontalAccuracy:(CLLocationAccuracy)hAccuracy
142+
verticalAccuracy:(CLLocationAccuracy)vAccuracy
143+
timestamp:(NSDate *)timestamp;
144+
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate
145+
altitude:(CLLocationDistance)altitude
146+
horizontalAccuracy:(CLLocationAccuracy)hAccuracy
147+
verticalAccuracy:(CLLocationAccuracy)vAccuracy
148+
course:(CLLocationDirection)course
149+
speed:(CLLocationSpeed)speed
150+
timestamp:(NSDate *)timestamp
151+
- (double)distanceFromLocation:(const CLLocation *)location{
152+
153+
154+
}
155+
%end*/
156+
157+
158+
%end
159+
extern void init_CoreLocation_hook() {
160+
%init(CoreLocation);
161+
}
162+
#undef LogCLRegion

Hooks/API/CoreLocation.xm.empty

Lines changed: 0 additions & 82 deletions
This file was deleted.

Hooks/API/libC.xm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,24 @@ int replaced_system(char *command){
6666

6767

6868
}
69-
69+
static char* (*original_getenv)(char* name);
70+
char* replaced_getenv(char *command){
71+
char* ret=original_getenv(command);
72+
if (WTShouldLog) {
73+
WTInit(@"C",@"getenv");
74+
WTAdd([NSString stringWithUTF8String:command],@"name");
75+
WTReturn([NSString stringWithUTF8String:ret]);
76+
WTSave;
77+
WTRelease;
78+
return ret;
79+
}
80+
return ret;
81+
}
7082

7183

7284
extern void init_libC_hook(){
7385
WTHookFunction((void *)random, (void *)replaced_random, (void **) &original_random);
7486
WTHookFunction((void *)rand, (void *)replaced_rand, (void **) &original_rand);
7587
WTHookFunction((void *)system, (void *)replaced_system, (void **) &original_system);
88+
WTHookFunction((void *)system, (void *)replaced_getenv, (void **) &original_getenv);
7689
}

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
521
1+
522

layout/Library/PreferenceLoader/Preferences/WTFJH.plist

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)