Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
ratelvirtuallocation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ratel-modules
ratelvirtuallocation
Commits
1ab64c03
Commit
1ab64c03
authored
Sep 08, 2021
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持企业微信
parent
c81046d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
153 additions
and
1 deletion
+153
-1
XPosedPlugin.java
...ain/java/top/littlerich/virtuallocation/XPosedPlugin.java
+153
-1
No files found.
app/src/main/java/top/littlerich/virtuallocation/XPosedPlugin.java
View file @
1ab64c03
...
...
@@ -52,6 +52,7 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
handleGaoDeMap
();
handleBaiduMap
();
handleTencent
();
handleqywxTencent
();
handleOriginal
();
Log
.
i
(
TAG
,
"virtual location component init success!!"
);
...
...
@@ -142,9 +143,16 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
});
}
private
static
void
handleTencent
()
{
ClassLoadMonitor
.
addClassLoadMonitor
(
new
ClassLoadMonitor
.
OnClassLoader
()
{
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
if
(
clazz
.
getName
().
contains
(
"location"
))
{
Log
.
i
(
AppApplication
.
tag
,
"init class: "
+
clazz
.
getName
());
}
}
});
//com.tencent.map.geolocation.TencentLocationManager
//com.tencent.map.geolocation.TencentLocationListener
...
...
@@ -279,6 +287,150 @@ public class XPosedPlugin implements IRposedHookLoadPackage {
}
});
}
private
static
void
handleqywxTencent
()
{
ClassLoadMonitor
.
addClassLoadMonitor
(
new
ClassLoadMonitor
.
OnClassLoader
()
{
@Override
public
void
onClassLoad
(
Class
<?>
clazz
)
{
if
(
clazz
.
getName
().
contains
(
"location"
))
{
Log
.
i
(
AppApplication
.
tag
,
"init class: "
+
clazz
.
getName
());
}
}
});
//com.tencent.map.geolocation.TencentLocationManager
//com.tencent.map.geolocation.TencentLocationListener
ClassLoadMonitor
.
addClassLoadMonitor
(
"com.tencent.map.qywxgeolocation.TencentLocationManager"
,
new
ClassLoadMonitor
.
OnClassLoader
()
{
@Override
public
void
onClassLoad
(
final
Class
<?>
clazz
)
{
Log
.
i
(
AppApplication
.
tag
,
"命中企业微信腾讯API:"
+
clazz
);
hasMapApi
=
true
;
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2) {
// public final int requestLocationUpdates(TencentLocationRequest var1, TencentLocationListener var2, Looper var3) {
//public final int requestSingleFreshLocation(TencentLocationRequest var1, TencentLocationListener var2, Looper var3) {
//public final void removeUpdates(TencentLocationListener var1) {
final
Map
<
Object
,
Object
>
listenerMap
=
new
ConcurrentHashMap
<>();
RC_MethodHook
replaceLocationListenerHook
=
new
RC_MethodHook
()
{
private
Object
produceTencentLocation
(
final
Object
tencentLocation
,
Class
<?>
TencentLocationClass
)
throws
IOException
{
// Class<?> TencentLocationClass = tencentLocation.getClass();
InvocationHandler
invocationHandler
=
new
InvocationHandler
()
{
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
if
(
method
.
getName
().
equals
(
"getLatitude"
))
{
return
AppApplication
.
mockGPS
.
mLatitude
;
}
else
if
(
method
.
getName
().
equals
(
"getLongitude"
))
{
return
AppApplication
.
mockGPS
.
mLongitude
;
}
else
if
(
method
.
getName
().
equals
(
"getAddress"
))
{
return
AppApplication
.
mockGPS
.
address
;
}
if
(
args
==
null
)
{
return
RposedHelpers
.
callMethod
(
tencentLocation
,
method
.
getName
());
}
else
{
return
RposedHelpers
.
callMethod
(
tencentLocation
,
method
.
getName
(),
args
);
}
}
};
Object
fakeTencentLocation
;
if
(
TencentLocationClass
.
isInterface
())
{
fakeTencentLocation
=
Proxy
.
newProxyInstance
(
TencentLocationClass
.
getClassLoader
(),
new
Class
[]{
TencentLocationClass
},
invocationHandler
);
}
else
{
fakeTencentLocation
=
RatelToolKit
.
dexMakerProxyBuilderHelper
.
forClass
(
TencentLocationClass
)
.
parentClassLoader
(
TencentLocationClass
.
getClassLoader
())
.
onlyMethods
(
TencentLocationClass
.
getDeclaredMethods
())
.
handler
(
invocationHandler
).
build
();
}
return
fakeTencentLocation
;
}
@Override
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
//com.tencent.map.geolocation.TencentLocationListener
for
(
int
i
=
0
;
i
<
param
.
args
.
length
;
i
++)
{
Class
<?>
tencentLocationListenerSubclass
=
param
.
args
[
i
].
getClass
();
Class
<?>
TencentLocationListenerClass
=
RposedHelpers
.
findClass
(
"com.tencent.map.qywxgeolocation.TencentLocationListener"
,
clazz
.
getClassLoader
());
if
(!
TencentLocationListenerClass
.
isAssignableFrom
(
tencentLocationListenerSubclass
))
{
continue
;
}
final
Object
originListener
=
param
.
args
[
i
];
if
(
originListener
==
null
)
{
return
;
}
InvocationHandler
invocationHandler
=
new
InvocationHandler
()
{
@Override
public
Object
invoke
(
Object
proxy
,
Method
method
,
Object
[]
args
)
throws
Throwable
{
// Debug.waitForDebugger();
if
(
method
.
getName
().
equals
(
"onLocationChanged"
))
{
Class
<?>
TencentLocationClass
=
RposedHelpers
.
findClass
(
"com.tencent.map.qywxgeolocation.TencentLocation"
,
clazz
.
getClassLoader
());
// void onLocationChanged(com.tencent.map.geolocation.TencentLocation var1);
for
(
int
j
=
0
;
j
<
args
.
length
;
j
++)
{
Object
tencentLocation
=
args
[
j
];
if
(!
TencentLocationClass
.
isAssignableFrom
(
args
[
j
].
getClass
()))
{
continue
;
}
args
[
j
]
=
produceTencentLocation
(
tencentLocation
,
TencentLocationClass
);
break
;
}
}
if
(
args
==
null
)
{
return
RposedHelpers
.
callMethod
(
originListener
,
method
.
getName
());
}
else
{
return
RposedHelpers
.
callMethod
(
originListener
,
method
.
getName
(),
args
);
}
}
};
Object
proxyListener
;
if
(
TencentLocationListenerClass
.
isInterface
())
{
proxyListener
=
Proxy
.
newProxyInstance
(
TencentLocationListenerClass
.
getClassLoader
(),
new
Class
[]{
TencentLocationListenerClass
},
invocationHandler
);
}
else
{
proxyListener
=
RatelToolKit
.
dexMakerProxyBuilderHelper
.
forClass
(
tencentLocationListenerSubclass
)
.
parentClassLoader
(
tencentLocationListenerSubclass
.
getClassLoader
())
.
onlyMethods
(
tencentLocationListenerSubclass
.
getDeclaredMethods
())
.
handler
(
invocationHandler
).
build
();
}
listenerMap
.
put
(
param
.
args
[
i
],
proxyListener
);
param
.
args
[
i
]
=
proxyListener
;
break
;
}
}
};
RposedBridge
.
hookAllMethods
(
clazz
,
"requestLocationUpdates"
,
replaceLocationListenerHook
);
RposedBridge
.
hookAllMethods
(
clazz
,
"requestSingleFreshLocation"
,
replaceLocationListenerHook
);
RposedHelpers
.
findAndHookMethod
(
clazz
,
"removeUpdates"
,
"com.tencent.map.qywxgeolocation.TencentLocationListener"
,
new
RC_MethodHook
()
{
@Override
protected
void
beforeHookedMethod
(
MethodHookParam
param
)
throws
Throwable
{
Object
fakeListener
=
listenerMap
.
get
(
param
.
args
[
0
]);
if
(
fakeListener
!=
null
)
{
param
.
args
[
0
]
=
fakeListener
;
}
}
}
);
}
});
}
private
static
void
handleBaiduMap
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment