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
da81d7bd
Commit
da81d7bd
authored
Jan 23, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 5.1 thumb
parent
c5b4c704
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
+13
-5
native-lib.cpp
app/src/main/cpp/native-lib.cpp
+4
-4
trampoline_manager.h
app/src/main/cpp/trampoline/trampoline_manager.h
+1
-1
MainActivity.java
app/src/main/java/com/swift/sandhook/MainActivity.java
+1
-0
CustmizeHooker.java
...src/main/java/com/swift/sandhook/test/CustmizeHooker.java
+7
-0
No files found.
app/src/main/cpp/native-lib.cpp
View file @
da81d7bd
...
@@ -99,10 +99,10 @@ bool doHookWithInline(JNIEnv* env,
...
@@ -99,10 +99,10 @@ bool doHookWithInline(JNIEnv* env,
SandHook
::
HookTrampoline
*
hookTrampoline
=
trampolineManager
.
installInlineTrampoline
(
originMethod
,
hookMethod
,
backupMethod
);
SandHook
::
HookTrampoline
*
hookTrampoline
=
trampolineManager
.
installInlineTrampoline
(
originMethod
,
hookMethod
,
backupMethod
);
if
(
hookTrampoline
==
nullptr
)
if
(
hookTrampoline
==
nullptr
)
return
false
;
return
false
;
void
*
entryPointFormInterpreter
=
SandHook
::
CastArtMethod
::
entryPointFormInterpreter
->
get
(
hookMethod
);
//
void* entryPointFormInterpreter = SandHook::CastArtMethod::entryPointFormInterpreter->get(hookMethod);
if
(
entryPointFormInterpreter
!=
NULL
)
{
//
if (entryPointFormInterpreter != NULL) {
SandHook
::
CastArtMethod
::
entryPointFormInterpreter
->
set
(
originMethod
,
entryPointFormInterpreter
);
//
SandHook::CastArtMethod::entryPointFormInterpreter->set(originMethod, entryPointFormInterpreter);
}
//
}
hookTrampoline
->
inlineSecondory
->
flushCache
(
reinterpret_cast
<
Size
>
(
hookMethod
),
SandHook
::
CastArtMethod
::
size
);
hookTrampoline
->
inlineSecondory
->
flushCache
(
reinterpret_cast
<
Size
>
(
hookMethod
),
SandHook
::
CastArtMethod
::
size
);
if
(
hookTrampoline
->
callOrigin
!=
nullptr
)
{
if
(
hookTrampoline
->
callOrigin
!=
nullptr
)
{
//backup
//backup
...
...
app/src/main/cpp/trampoline/trampoline_manager.h
View file @
da81d7bd
...
@@ -64,7 +64,7 @@ namespace SandHook {
...
@@ -64,7 +64,7 @@ namespace SandHook {
}
}
bool
isThumbCode
(
Size
codeAddr
)
{
bool
isThumbCode
(
Size
codeAddr
)
{
return
(
codeAddr
&
(
Size
)
1
)
==
(
Size
)
1
;
return
(
codeAddr
&
0x1
)
==
0x
1
;
}
}
void
checkThumbCode
(
Trampoline
*
trampoline
,
Code
code
)
{
void
checkThumbCode
(
Trampoline
*
trampoline
,
Code
code
)
{
...
...
app/src/main/java/com/swift/sandhook/MainActivity.java
View file @
da81d7bd
...
@@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity {
public
static
int
methodBeHooked
(
int
a
,
int
b
)
{
public
static
int
methodBeHooked
(
int
a
,
int
b
)
{
a
=
a
+
1
+
2
;
a
=
a
+
1
+
2
;
b
=
b
+
a
+
3
;
b
=
b
+
a
+
3
;
Log
.
e
(
"MainActivity"
,
"methodBeHooked called"
);
return
a
+
b
;
return
a
+
b
;
}
}
...
...
app/src/main/java/com/swift/sandhook/test/CustmizeHooker.java
View file @
da81d7bd
...
@@ -5,6 +5,7 @@ import android.util.Log;
...
@@ -5,6 +5,7 @@ import android.util.Log;
import
com.swift.sandhook.MainActivity
;
import
com.swift.sandhook.MainActivity
;
import
com.swift.sandhook.wrapper.HookClass
;
import
com.swift.sandhook.wrapper.HookClass
;
import
com.swift.sandhook.wrapper.HookMethod
;
import
com.swift.sandhook.wrapper.HookMethod
;
import
com.swift.sandhook.wrapper.HookMethodBackup
;
import
com.swift.sandhook.wrapper.MethodParams
;
import
com.swift.sandhook.wrapper.MethodParams
;
@HookClass
(
MainActivity
.
class
)
@HookClass
(
MainActivity
.
class
)
...
@@ -14,6 +15,12 @@ public class CustmizeHooker {
...
@@ -14,6 +15,12 @@ public class CustmizeHooker {
@MethodParams
({
int
.
class
,
int
.
class
})
@MethodParams
({
int
.
class
,
int
.
class
})
public
static
int
staticMethodHooked
(
int
a
,
int
b
)
{
public
static
int
staticMethodHooked
(
int
a
,
int
b
)
{
Log
.
e
(
"CustmizeHooker"
,
"methodBeHooked be hooked"
);
Log
.
e
(
"CustmizeHooker"
,
"methodBeHooked be hooked"
);
return
staticMethodHookedBackup
(
a
,
b
);
}
@HookMethodBackup
(
"methodBeHooked"
)
@MethodParams
({
int
.
class
,
int
.
class
})
public
static
int
staticMethodHookedBackup
(
int
a
,
int
b
)
{
return
0
;
return
0
;
}
}
...
...
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