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
14200bef
Commit
14200bef
authored
Jan 26, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
187156d5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
4 deletions
+27
-4
MyApp.java
app/src/main/java/com/swift/sandhook/MyApp.java
+2
-3
cast_art_method.h
hooklib/src/main/cpp/casts/cast_art_method.h
+10
-0
native-lib.cpp
hooklib/src/main/cpp/native-lib.cpp
+10
-0
arm64.S
hooklib/src/main/cpp/trampoline/arch/arm64.S
+4
-1
ClassNeverCall.java
hooklib/src/main/java/com/swift/sandhook/ClassNeverCall.java
+1
-0
No files found.
app/src/main/java/com/swift/sandhook/MyApp.java
View file @
14200bef
...
@@ -15,12 +15,11 @@ public class MyApp extends Application {
...
@@ -15,12 +15,11 @@ public class MyApp extends Application {
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
try
{
try
{
SandHook
.
addHookClass
(
CtrHook
.
class
,
SandHook
.
addHookClass
(
JniHooker
.
class
,
CtrHook
.
class
,
LogHooker
.
class
,
LogHooker
.
class
,
CustmizeHooker
.
class
,
CustmizeHooker
.
class
,
ActivityHooker
.
class
,
ActivityHooker
.
class
,
ObjectHooker
.
class
,
ObjectHooker
.
class
);
JniHooker
.
class
);
}
catch
(
HookErrorException
e
)
{
}
catch
(
HookErrorException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
hooklib/src/main/cpp/casts/cast_art_method.h
View file @
14200bef
...
@@ -130,6 +130,8 @@ namespace SandHook {
...
@@ -130,6 +130,8 @@ namespace SandHook {
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
dexMethodIndex
;
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
dexMethodIndex
;
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
accessFlag
;
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
accessFlag
;
static
void
*
quickToInterpreterBridge
;
static
void
*
quickToInterpreterBridge
;
static
void
*
genericJniStub
;
static
void
*
staticResolveStub
;
static
void
init
(
JNIEnv
*
env
,
int
sdk
)
{
static
void
init
(
JNIEnv
*
env
,
int
sdk
)
{
...
@@ -164,6 +166,12 @@ namespace SandHook {
...
@@ -164,6 +166,12 @@ namespace SandHook {
art
::
mirror
::
ArtMethod
*
neverCall
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
GetMethodID
(
neverCallTestClass
,
"neverCall"
,
"()V"
));
art
::
mirror
::
ArtMethod
*
neverCall
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
GetMethodID
(
neverCallTestClass
,
"neverCall"
,
"()V"
));
quickToInterpreterBridge
=
entryPointQuickCompiled
->
get
(
neverCall
);
quickToInterpreterBridge
=
entryPointQuickCompiled
->
get
(
neverCall
);
art
::
mirror
::
ArtMethod
*
neverCallStatic
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
GetStaticMethodID
(
neverCallTestClass
,
"neverCallStatic"
,
"()V"
));
staticResolveStub
=
entryPointQuickCompiled
->
get
(
neverCallStatic
);
art
::
mirror
::
ArtMethod
*
neverCallNative
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
GetMethodID
(
neverCallTestClass
,
"neverCallNative"
,
"()V"
));
genericJniStub
=
entryPointQuickCompiled
->
get
(
neverCallNative
);
}
}
static
void
copy
(
art
::
mirror
::
ArtMethod
*
from
,
art
::
mirror
::
ArtMethod
*
to
)
{
static
void
copy
(
art
::
mirror
::
ArtMethod
*
from
,
art
::
mirror
::
ArtMethod
*
to
)
{
...
@@ -179,6 +187,8 @@ namespace SandHook {
...
@@ -179,6 +187,8 @@ namespace SandHook {
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
dexMethodIndex
=
nullptr
;
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
dexMethodIndex
=
nullptr
;
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
accessFlag
=
nullptr
;
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
accessFlag
=
nullptr
;
void
*
CastArtMethod
::
quickToInterpreterBridge
=
nullptr
;
void
*
CastArtMethod
::
quickToInterpreterBridge
=
nullptr
;
void
*
CastArtMethod
::
genericJniStub
=
nullptr
;
void
*
CastArtMethod
::
staticResolveStub
=
nullptr
;
}
}
...
...
hooklib/src/main/cpp/native-lib.cpp
View file @
14200bef
...
@@ -150,6 +150,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
...
@@ -150,6 +150,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
bool
isInterpreter
=
SandHook
::
CastArtMethod
::
entryPointQuickCompiled
->
get
(
origin
)
==
SandHook
::
CastArtMethod
::
quickToInterpreterBridge
;
bool
isInterpreter
=
SandHook
::
CastArtMethod
::
entryPointQuickCompiled
->
get
(
origin
)
==
SandHook
::
CastArtMethod
::
quickToInterpreterBridge
;
bool
idJNi
=
SandHook
::
CastArtMethod
::
entryPointQuickCompiled
->
get
(
origin
)
==
SandHook
::
CastArtMethod
::
genericJniStub
;
// #if defined(__arm__)
// #if defined(__arm__)
// doHookWithReplacement(origin, hook, backup);
// doHookWithReplacement(origin, hook, backup);
// return JNI_TRUE;
// return JNI_TRUE;
...
@@ -188,4 +189,13 @@ JNIEXPORT void JNICALL
...
@@ -188,4 +189,13 @@ JNIEXPORT void JNICALL
Java_com_swift_sandhook_test_TestClass_jni_1test
(
JNIEnv
*
env
,
jobject
instance
)
{
Java_com_swift_sandhook_test_TestClass_jni_1test
(
JNIEnv
*
env
,
jobject
instance
)
{
int
a
=
1
+
1
;
int
a
=
1
+
1
;
int
b
=
a
+
1
;
int
b
=
a
+
1
;
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_ClassNeverCall_neverCallNative
(
JNIEnv
*
env
,
jobject
instance
)
{
// TODO
int
a
=
1
+
1
;
int
b
=
a
+
1
;
}
}
\ No newline at end of file
hooklib/src/main/cpp/trampoline/arch/arm64.S
View file @
14200bef
...
@@ -56,7 +56,10 @@ const vixl::aarch64::CPURegList callee_saved_core_registers(
...
@@ -56,7 +56,10 @@ const vixl::aarch64::CPURegList callee_saved_core_registers(
结论,x16/x17
结论,x16/x17
x22 - x28 貌似可以使用
X16 = IP0
Stub 中有使用
尽量使用 X17
*
*
*/
*/
...
...
hooklib/src/main/java/com/swift/sandhook/ClassNeverCall.java
View file @
14200bef
...
@@ -3,4 +3,5 @@ package com.swift.sandhook;
...
@@ -3,4 +3,5 @@ package com.swift.sandhook;
public
class
ClassNeverCall
{
public
class
ClassNeverCall
{
private
void
neverCall
()
{}
private
void
neverCall
()
{}
private
static
void
neverCallStatic
()
{}
private
static
void
neverCallStatic
()
{}
private
native
void
neverCallNative
();
}
}
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