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
56125250
Commit
56125250
authored
Jan 17, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add arm64.s
parent
e4af8592
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
5 deletions
+65
-5
CMakeLists.txt
app/CMakeLists.txt
+5
-1
build.gradle
app/build.gradle
+1
-0
native-lib.cpp
app/src/main/cpp/native-lib.cpp
+7
-1
arm64.S
app/src/main/cpp/trampoline/arch/arm64.S
+13
-1
base.h
app/src/main/cpp/trampoline/arch/base.h
+10
-2
trampoline.cpp
app/src/main/cpp/trampoline/trampoline.cpp
+8
-0
trampoline.h
app/src/main/cpp/trampoline/trampoline.h
+21
-0
No files found.
app/CMakeLists.txt
View file @
56125250
...
@@ -18,6 +18,8 @@ add_library( # Sets the name of the library.
...
@@ -18,6 +18,8 @@ add_library( # Sets the name of the library.
# Provides a relative path to your source file(s).
# Provides a relative path to your source file(s).
src/main/cpp/native-lib.cpp
src/main/cpp/native-lib.cpp
src/main/cpp/trampoline/trampoline.cpp
src/main/cpp/trampoline/arch/arm64.S
)
)
# Searches for a specified prebuilt library and stores the path as a
# Searches for a specified prebuilt library and stores the path as a
...
@@ -45,4 +47,6 @@ target_link_libraries( # Specifies the target library.
...
@@ -45,4 +47,6 @@ target_link_libraries( # Specifies the target library.
${
log-lib
}
)
${
log-lib
}
)
add_definitions
(
-std=c++11
)
add_definitions
(
-std=c++11
)
\ No newline at end of file
ENABLE_LANGUAGE
(
ASM
)
\ No newline at end of file
app/build.gradle
View file @
56125250
...
@@ -12,6 +12,7 @@ android {
...
@@ -12,6 +12,7 @@ android {
externalNativeBuild
{
externalNativeBuild
{
cmake
{
cmake
{
cppFlags
"-frtti -fexceptions"
cppFlags
"-frtti -fexceptions"
abiFilters
'arm64-v8a'
}
}
}
}
}
}
...
...
app/src/main/cpp/native-lib.cpp
View file @
56125250
#include <jni.h>
#include <jni.h>
#include <string>
#include <string>
#include "casts/cast_art_method.h"
#include "casts/cast_art_method.h"
#include "./trampoline/trampoline.h"
extern
"C"
JNIEXPORT
jstring
extern
"C"
JNIEXPORT
jstring
...
@@ -29,10 +30,15 @@ Java_com_swift_sandhook_MainActivity_calArtSize(JNIEnv *env, jobject instance, j
...
@@ -29,10 +30,15 @@ Java_com_swift_sandhook_MainActivity_calArtSize(JNIEnv *env, jobject instance, j
// Size addr2 = size + artMethod1 - BYTE_POINT;
// Size addr2 = size + artMethod1 - BYTE_POINT;
return
0
;
return
0
;
}
extern
"C"
}
extern
void
hook_trampoline
();
extern
"C"
JNIEXPORT
void
JNICALL
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_MainActivity_initHook
(
JNIEnv
*
env
,
jobject
instance
)
{
Java_com_swift_sandhook_MainActivity_initHook
(
JNIEnv
*
env
,
jobject
instance
)
{
void
(
*
fp
)()
=
hook_trampoline
;
SandHook
::
cast_art_method
::
init
(
env
);
SandHook
::
cast_art_method
::
init
(
env
);
...
...
app/src/main/cpp/trampoline/arch/arm64.S
View file @
56125250
#include
<base.h>
#include
"base.h"
.align 4
.global hook_trampoline
hook_trampoline:
ldr x0, addr_art_method
ldr x16, addr_entry_code
br x16
addr_art_method:
.long 0
.long 0
addr_entry_code:
.long 0
.long 0
\ No newline at end of file
app/src/main/cpp/trampoline/arch/base.h
View file @
56125250
...
@@ -5,7 +5,15 @@
...
@@ -5,7 +5,15 @@
#ifndef SANDHOOK_BASE_H
#ifndef SANDHOOK_BASE_H
#define SANDHOOK_BASE_H
#define SANDHOOK_BASE_H
#define FUNCTION_START(x) .global x; x:
#if defined(__WIN32__) || defined(__APPLE__)
#define FUNCTION_END(x) . - x
#define cdecl(s) s
#else
#define cdecl(s) s
#endif
#define FUNCTION_START(x) .globl cdecl(x) \
cdecl(x):
#define FUNCTION_END(x) .x:
#endif //SANDHOOK_BASE_H
#endif //SANDHOOK_BASE_H
app/src/main/cpp/trampoline/trampoline.cpp
0 → 100644
View file @
56125250
//
// Created by SwiftGan on 2019/1/17.
//
#include "trampoline.h"
app/src/main/cpp/trampoline/trampoline.h
View file @
56125250
...
@@ -5,4 +5,25 @@
...
@@ -5,4 +5,25 @@
#ifndef SANDHOOK_TRAMPOLINE_H
#ifndef SANDHOOK_TRAMPOLINE_H
#define SANDHOOK_TRAMPOLINE_H
#define SANDHOOK_TRAMPOLINE_H
extern
void
hook_trampoline
();
#if defined(__i386__)
#define SIZE_TRAMPOLINE = 4 * 7
#define OFFSET_ADDR_ART_METHOD 4 * 3
#define OFFSET_ADDR_ENTRY_CODE 4 * 5
#elif defined(__x86_64__)
#define SIZE_TRAMPOLINE = 4 * 7
#define OFFSET_ADDR_ART_METHOD 4 * 3
#define OFFSET_ADDR_ENTRY_CODE 4 * 5
#elif defined(__arm__)
#define SIZE_TRAMPOLINE = 4 * 7
#define OFFSET_ADDR_ART_METHOD 4 * 3
#define OFFSET_ADDR_ENTRY_CODE 4 * 5
#elif defined(__aarch64__)
#define SIZE_TRAMPOLINE = 4 * 7
#define OFFSET_ADDR_ART_METHOD 4 * 3
#define OFFSET_ADDR_ENTRY_CODE 4 * 5
#endif
#endif //SANDHOOK_TRAMPOLINE_H
#endif //SANDHOOK_TRAMPOLINE_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