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
08fe90f5
Commit
08fe90f5
authored
Jan 20, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
done s
parent
27782e47
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
15 deletions
+82
-15
build_file_checksums.ser
.idea/caches/build_file_checksums.ser
+0
-0
CMakeLists.txt
app/CMakeLists.txt
+1
-0
build.gradle
app/build.gradle
+1
-1
native-lib.cpp
app/src/main/cpp/native-lib.cpp
+3
-3
arm32.S
app/src/main/cpp/trampoline/arch/arm32.S
+20
-5
arm64.S
app/src/main/cpp/trampoline/arch/arm64.S
+52
-5
base.h
app/src/main/cpp/trampoline/arch/base.h
+4
-0
trampoline.cpp
app/src/main/cpp/trampoline/trampoline.cpp
+1
-1
No files found.
.idea/caches/build_file_checksums.ser
View file @
08fe90f5
No preview for this file type
app/CMakeLists.txt
View file @
08fe90f5
...
...
@@ -19,6 +19,7 @@ add_library( # Sets the name of the library.
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp
src/main/cpp/trampoline/trampoline.cpp
src/main/cpp/trampoline/arch/arm32.S
src/main/cpp/trampoline/arch/arm64.S
)
...
...
app/build.gradle
View file @
08fe90f5
...
...
@@ -13,7 +13,7 @@ android {
cmake
{
arguments
'-DBUILD_TESTING=OFF'
,
'-DANDROID_TOOLCHAIN=gcc'
cppFlags
"-frtti -fexceptions"
abiFilters
'arm64-v8a'
abiFilters
'arm
eabi-v7a'
,
'arm
64-v8a'
}
}
}
...
...
app/src/main/cpp/native-lib.cpp
View file @
08fe90f5
#include <jni.h>
#include <string>
#include "casts/cast_art_method.h"
#include "./trampoline/
trampolin
e.h"
#include "./trampoline/
arch/bas
e.h"
extern
"C"
JNIEXPORT
jstring
...
...
@@ -32,13 +32,13 @@ Java_com_swift_sandhook_MainActivity_calArtSize(JNIEnv *env, jobject instance, j
return
0
;
}
extern
"C"
void
hook_trampoline
();
extern
"C"
void
INLINE_HOOK_TRAMPOLINE
();
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_MainActivity_initHook
(
JNIEnv
*
env
,
jobject
instance
)
{
hook_trampoline
();
INLINE_HOOK_TRAMPOLINE
();
SandHook
::
cast_art_method
::
init
(
env
);
...
...
app/src/main/cpp/trampoline/arch/arm32.S
View file @
08fe90f5
#include "base.h"
FUNCTION_START(hook_trampoline)
adr r0, addr_art_method
adr pc, addr_entry_code
#if defined(__arm__)
FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE)
ldr r0, addr_art_method
ldr r12, offset_entry_code
add r12, r0, r12
ldr pc, [r12]
addr_art_method:
.long 0
addr_entry_code:
offset_entry_code:
.long 0
FUNCTION_END(REPLACEMENT_HOOK_TRAMPOLINE)
FUNCTION_START(DIRECT_JUMP_TRAMPOLINE)
ldr pc, addr_target
addr_target:
.long 0
FUNCTION_END(hook_trampoline)
FUNCTION_END(DIRECT_JUMP_TRAMPOLINE)
FUNCTION_START(INLINE_HOOK_TRAMPOLINE)
FUNCTION_END(INLINE_HOOK_TRAMPOLINE)
#endif
\ No newline at end of file
app/src/main/cpp/trampoline/arch/arm64.S
View file @
08fe90f5
#include "base.h"
FUNCTION_START(hook_trampoline)
adr x0, addr_art_method
adr x16, addr_entry_code
#if defined(__aarch64__)
FUNCTION_START(REPLACEMENT_HOOK_TRAMPOLINE)
ldr x0, addr_art_method
ldr x16, offset_entry_code
add x16, x0, x16
ldr x16, [x16]
br x16
addr_art_method:
.long 0
.long 0
addr_entry_code:
offset_entry_code:
.long 0
.long 0
FUNCTION_END(REPLACEMENT_HOOK_TRAMPOLINE)
FUNCTION_START(DIRECT_JUMP_TRAMPOLINE)
ldr x16, addr_target
br x16
addr_target:
.long 0
.long 0
FUNCTION_END(DIRECT_JUMP_TRAMPOLINE)
FUNCTION_START(INLINE_HOOK_TRAMPOLINE)
ldr x17, addr_origin_art_method
cmp x0, x17
bne go_to_origin_code
ldr x16, addr_hook_art_method
ldr x17, offset_entry_code2
add x17, x16, x17
ldr x17, [x17]
br x17
go_to_origin_code:
mov x0, x17
b origin_code
addr_origin_art_method:
.long 0
.long 0
origin_code:
.long 0
.long 0
.long 0
.long 0
ldr x17, offset_entry_code2
add x17, x0, x17
ldr x17, [x17]
br x17
offset_entry_code2:
.long 0
FUNCTION_END(hook_trampoline)
.long 0
addr_hook_art_method:
.long 0
.long 0
FUNCTION_END(INLINE_HOOK_TRAMPOLINE)
#endif
app/src/main/cpp/trampoline/arch/base.h
View file @
08fe90f5
...
...
@@ -13,4 +13,8 @@ x: \
#define FUNCTION_END(x) .size x, .-x
#define REPLACEMENT_HOOK_TRAMPOLINE replacement_hook_trampoline
#define INLINE_HOOK_TRAMPOLINE inline_hook_trampoline
#define DIRECT_JUMP_TRAMPOLINE direct_jump_trampoline
#endif //SANDHOOK_BASE_H
app/src/main/cpp/trampoline/trampoline.cpp
View file @
08fe90f5
...
...
@@ -2,7 +2,7 @@
// Created by SwiftGan on 2019/1/17.
//
#include "trampoline.h"
#include "stdlib.h"
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