Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SandHook
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
Administrator
SandHook
Commits
a19666fa
Commit
a19666fa
authored
Mar 15, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
0edd3087
9f403419
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
9338 additions
and
1405 deletions
+9338
-1405
README.md
README.md
+11
-4
MyApp.java
app/src/main/java/com/swift/sandhook/MyApp.java
+2
-3
sandhook.cpp
hooklib/src/main/cpp/sandhook.cpp
+5
-1
SandHook.java
hooklib/src/main/java/com/swift/sandhook/SandHook.java
+1
-1
genhookstubs.py
xposedcompat/genhookstubs.py
+1
-1
XposedCompat.java
...in/java/com/swift/sandhook/xposedcompat/XposedCompat.java
+1
-1
HookStubManager.java
...swift/sandhook/xposedcompat/hookstub/HookStubManager.java
+2
-1
MethodHookerStubs32.java
...t/sandhook/xposedcompat/hookstub/MethodHookerStubs32.java
+4657
-696
MethodHookerStubs64.java
...t/sandhook/xposedcompat/hookstub/MethodHookerStubs64.java
+4657
-696
DynamicBridge.java
.../swift/sandhook/xposedcompat/methodgen/DynamicBridge.java
+1
-1
No files found.
README.md
View file @
a19666fa
...
...
@@ -13,7 +13,7 @@ Android ART Hook
# OS
4.
4(ART Runtime) -
9
.0
4.
4(ART Runtime) -
10
.0
# Scope
...
...
@@ -30,7 +30,7 @@ cant hook if lined
# how to use
```
gradle
implementation
'com.swift.sandhook:hooklib:3.
0.2
'
implementation
'com.swift.sandhook:hooklib:3.
1.0
'
```
-
Annotation API
...
...
@@ -121,7 +121,7 @@ SanHook.public static boolean hook(Member target, Method hook, Method backup) {}
if hookers is in plugin(like xposed):
```
groovy
provided
'com.swift.sandhook:hookannotation:3.
0.2
'
provided
'com.swift.sandhook:hookannotation:3.
1.0
'
```
in your plugin
...
...
@@ -136,7 +136,7 @@ backup method can call itself to avoid be inlining
Now you can use Xposed api:
```
groovy
implementation
'com.swift.sandhook:xposedcompat:3.
0.2
'
implementation
'com.swift.sandhook:xposedcompat:3.
1.0
'
```
```
java
...
...
@@ -191,6 +191,13 @@ You can also deoptimize a caller that inlined your hook method by SandHook.deCom
non-Root Xposed Environment Demo (VirtualApp With SandHook):
https://github.com/ganyao114/SandVXposed
# Android Q(10.0)
in MyApp.java
//if you want test Android Q, please set true, because SDK_INT of Android Q is still 28
public final static boolean testAndroidQ = false;
# References
...
...
app/src/main/java/com/swift/sandhook/MyApp.java
View file @
a19666fa
...
...
@@ -54,10 +54,9 @@ public class MyApp extends Application {
XposedCompat
.
classLoader
=
getClassLoader
();
XposedCompat
.
isFirstApplication
=
true
;
//some error when invoke backup in Android Q
//
//some error when invoke backup in Android Q
if
(
SandHookConfig
.
SDK_INT
>=
29
)
{
XposedCompat
.
useNewDexMaker
=
false
;
XposedCompat
.
useInternalStub
=
false
;
XposedCompat
.
useNewCallBackup
=
false
;
}
XposedHelpers
.
findAndHookMethod
(
Activity
.
class
,
"onResume"
,
new
XC_MethodHook
()
{
...
...
hooklib/src/main/cpp/sandhook.cpp
View file @
a19666fa
...
...
@@ -244,7 +244,7 @@ Java_com_swift_sandhook_SandHook_compileMethod(JNIEnv *env, jclass type, jobject
extern
"C"
JNIEXPORT
jboolean
JNICALL
Java_com_swift_sandhook_SandHook_deCompileMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
member
)
{
Java_com_swift_sandhook_SandHook_deCompileMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
member
,
jboolean
disableJit
)
{
if
(
member
==
NULL
)
return
JNI_FALSE
;
...
...
@@ -253,6 +253,10 @@ Java_com_swift_sandhook_SandHook_deCompileMethod(JNIEnv *env, jclass type, jobje
if
(
method
==
nullptr
)
return
JNI_FALSE
;
if
(
disableJit
)
{
method
->
disableCompilable
();
}
if
(
method
->
isCompiled
())
{
SandHook
::
StopTheWorld
stopTheWorld
;
if
(
SDK_INT
>=
ANDROID_N
)
{
...
...
hooklib/src/main/java/com/swift/sandhook/SandHook.java
View file @
a19666fa
...
...
@@ -308,7 +308,7 @@ public class SandHook {
public
static
native
void
ensureMethodCached
(
Method
hook
,
Method
backup
);
public
static
native
boolean
compileMethod
(
Member
member
);
public
static
native
boolean
deCompileMethod
(
Member
member
);
public
static
native
boolean
deCompileMethod
(
Member
member
,
boolean
disableJit
);
public
static
native
boolean
canGetObject
();
public
static
native
Object
getObjectNative
(
long
thread
,
long
address
);
...
...
xposedcompat/genhookstubs.py
View file @
a19666fa
...
...
@@ -61,7 +61,7 @@ TEMP_STUB_INFO = """
STUB_SIZES
=
[
10
,
20
,
30
,
30
,
30
,
30
,
30
,
20
,
10
,
10
,
5
,
5
,
3
]
HAS_BACKUP
=
Fals
e
;
HAS_BACKUP
=
Tru
e
;
def
getMethodId
(
args
,
index
):
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/XposedCompat.java
View file @
a19666fa
...
...
@@ -27,7 +27,7 @@ public class XposedCompat {
//try to use internal stub hooker & backup method to speed up hook
public
static
volatile
boolean
useInternalStub
=
true
;
public
static
volatile
boolean
useNew
DexMaker
=
true
;
public
static
volatile
boolean
useNew
CallBackup
=
true
;
public
static
volatile
boolean
retryWhenCallOriginError
=
false
;
private
static
ClassLoader
sandHookXposedClassLoader
;
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java
View file @
a19666fa
...
...
@@ -6,6 +6,7 @@ import com.swift.sandhook.SandHook;
import
com.swift.sandhook.SandHookMethodResolver
;
import
com.swift.sandhook.utils.ParamWrapper
;
import
com.swift.sandhook.wrapper.BackupMethodStubs
;
import
com.swift.sandhook.xposedcompat.XposedCompat
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
import
java.lang.reflect.Constructor
;
...
...
@@ -44,7 +45,7 @@ public class HookStubManager {
Class
stubClass
=
SandHook
.
is64Bit
()
?
MethodHookerStubs64
.
class
:
MethodHookerStubs32
.
class
;
stubSizes
=
(
int
[])
XposedHelpers
.
getStaticObjectField
(
stubClass
,
"stubSizes"
);
Boolean
hasBackup
=
(
Boolean
)
XposedHelpers
.
getStaticObjectField
(
stubClass
,
"hasStubBackup"
);
hasStubBackup
=
hasBackup
==
null
?
false
:
hasBackup
;
hasStubBackup
=
hasBackup
!=
null
&&
(
hasBackup
&&
!
XposedCompat
.
useNewCallBackup
)
;
if
(
stubSizes
!=
null
&&
stubSizes
.
length
>
0
)
{
MAX_STUB_ARGS
=
stubSizes
.
length
-
1
;
curUseStubIndexes
=
new
AtomicInteger
[
MAX_STUB_ARGS
+
1
];
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/MethodHookerStubs32.java
View file @
a19666fa
This diff is collapsed.
Click to expand it.
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/MethodHookerStubs64.java
View file @
a19666fa
This diff is collapsed.
Click to expand it.
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/methodgen/DynamicBridge.java
View file @
a19666fa
...
...
@@ -24,7 +24,7 @@ import de.robv.android.xposed.XposedBridge;
public
final
class
DynamicBridge
{
private
static
final
HashMap
<
Member
,
Method
>
hookedInfo
=
new
HashMap
<>();
private
static
HookMaker
hookMaker
=
XposedCompat
.
useNew
DexMaker
?
new
HookerDexMakerNew
()
:
new
HookerDexMaker
();
private
static
HookMaker
hookMaker
=
XposedCompat
.
useNew
CallBackup
?
new
HookerDexMakerNew
()
:
new
HookerDexMaker
();
private
static
final
AtomicBoolean
dexPathInited
=
new
AtomicBoolean
(
false
);
private
static
File
dexDir
;
...
...
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