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
2c6f4305
Commit
2c6f4305
authored
Jan 18, 2019
by
swift_gan
Committed by
swift_gan
Jan 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
27782e47
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
11 deletions
+29
-11
build_file_checksums.ser
.idea/caches/build_file_checksums.ser
+0
-0
CMakeLists.txt
app/CMakeLists.txt
+1
-0
build.gradle
app/build.gradle
+0
-1
native-lib.cpp
app/src/main/cpp/native-lib.cpp
+5
-7
arm32.S
app/src/main/cpp/trampoline/arch/arm32.S
+5
-1
arm64.S
app/src/main/cpp/trampoline/arch/arm64.S
+5
-0
MainActivity.java
app/src/main/java/com/swift/sandhook/MainActivity.java
+13
-2
No files found.
.idea/caches/build_file_checksums.ser
View file @
2c6f4305
No preview for this file type
app/CMakeLists.txt
View file @
2c6f4305
...
...
@@ -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 @
2c6f4305
...
...
@@ -13,7 +13,6 @@ android {
cmake
{
arguments
'-DBUILD_TESTING=OFF'
,
'-DANDROID_TOOLCHAIN=gcc'
cppFlags
"-frtti -fexceptions"
abiFilters
'arm64-v8a'
}
}
}
...
...
app/src/main/cpp/native-lib.cpp
View file @
2c6f4305
#include <jni.h>
#include <string>
#include "casts/cast_art_method.h"
#include "./trampoline/trampoline.h"
extern
"C"
JNIEXPORT
jstring
extern
static
thread_local
int
t_i
=
0
;
extern
"C"
JNIEXPORT
jstring
JNICALL
Java_com_swift_sandhook_MainActivity_stringFromJNI
(
JNIEnv
*
env
,
...
...
@@ -29,17 +30,14 @@ Java_com_swift_sandhook_MainActivity_calArtSize(JNIEnv *env, jobject instance, j
// Size addr1 = reinterpret_cast<size_t>(&methodTest->ptr_sized_fields_.entry_point_from_quick_compiled_code_);
// Size addr2 = size + artMethod1 - BYTE_POINT;
return
0
;
return
reinterpret_cast
<
jint
>
(
&
t_i
)
;
}
extern
"C"
void
hook_trampoline
();
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_MainActivity_initHook
(
JNIEnv
*
env
,
jobject
instance
)
{
hook_trampoline
();
SandHook
::
cast_art_method
::
init
(
env
);
}
\ No newline at end of file
app/src/main/cpp/trampoline/arch/arm32.S
View file @
2c6f4305
#include "base.h"
#if defined(__arm__)
FUNCTION_START(hook_trampoline)
adr r0,
addr_art_method
adr r0,
t_i
adr pc, addr_entry_code
addr_art_method:
.long 0
addr_entry_code:
.long 0
FUNCTION_END(hook_trampoline)
#endif
app/src/main/cpp/trampoline/arch/arm64.S
View file @
2c6f4305
#include "base.h"
#if defined(__aarch64__)
FUNCTION_START(hook_trampoline)
adr x0, addr_art_method
adr x16, addr_entry_code
...
...
@@ -11,3 +14,5 @@ addr_entry_code:
.long 0
.long 0
FUNCTION_END(hook_trampoline)
#endif
app/src/main/java/com/swift/sandhook/MainActivity.java
View file @
2c6f4305
package
com
.
swift
.
sandhook
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.widget.TextView
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.design.widget.Snackbar
;
...
...
@@ -68,8 +69,8 @@ public class MainActivity extends AppCompatActivity {
//
// methods[dexMethodIndex] = artMethod;
SandHook
.
init
();
initHook
();
//
SandHook.init();
//
initHook();
tv
.
setText
(
""
+
calArtSize
(
method1
,
method2
));
}
catch
(
NoSuchMethodException
e
)
{
...
...
@@ -79,6 +80,16 @@ public class MainActivity extends AppCompatActivity {
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Log
.
e
(
"Thread_Local"
,
"thread_local_i = "
+
calArtSize
(
null
,
null
));
}
}).
start
();
}
}
public
static
Field
getField
(
Class
topClass
,
String
fieldName
)
throws
NoSuchFieldException
{
...
...
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