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
74316b18
Commit
74316b18
authored
Feb 12, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into xposed_compat
parents
c39baed1
ae558836
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
10 deletions
+21
-10
insts_arm32.cpp
hooklib/src/main/cpp/inst/insts_arm32.cpp
+5
-4
sandhook.cpp
hooklib/src/main/cpp/sandhook.cpp
+1
-3
trampoline_manager.cpp
hooklib/src/main/cpp/trampoline/trampoline_manager.cpp
+15
-3
No files found.
hooklib/src/main/cpp/inst/insts_arm32.cpp
View file @
74316b18
...
@@ -92,8 +92,8 @@ namespace SandHook {
...
@@ -92,8 +92,8 @@ namespace SandHook {
return
(
codeAddr
&
0x1
)
==
0x1
;
return
(
codeAddr
&
0x1
)
==
0x1
;
}
}
bool
isThumb32
(
uint
32
_t
code
)
{
bool
isThumb32
(
uint
16
_t
code
)
{
return
code
>>
16
!=
0
;
return
((
code
&
0xF000
)
==
0xF000
)
||
((
code
&
0xF800
)
==
0xE800
)
;
}
}
void
InstDecode
::
decode
(
void
*
codeStart
,
Size
codeLen
,
InstVisitor
*
visitor
)
{
void
InstDecode
::
decode
(
void
*
codeStart
,
Size
codeLen
,
InstVisitor
*
visitor
)
{
...
@@ -103,13 +103,14 @@ namespace SandHook {
...
@@ -103,13 +103,14 @@ namespace SandHook {
codeStart
=
Trampoline
::
getThumbCodeAddress
(
static_cast
<
Code
>
(
codeStart
));
codeStart
=
Trampoline
::
getThumbCodeAddress
(
static_cast
<
Code
>
(
codeStart
));
Size
codeAddr
=
reinterpret_cast
<
Size
>
(
codeStart
);
Size
codeAddr
=
reinterpret_cast
<
Size
>
(
codeStart
);
while
(
offset
<=
codeLen
)
{
while
(
offset
<=
codeLen
)
{
uint16_t
ram16
=
*
reinterpret_cast
<
uint16_t
*>
(
codeAddr
+
offset
);
uint32_t
ram32
=
*
reinterpret_cast
<
uint32_t
*>
(
codeAddr
+
offset
);
uint32_t
ram32
=
*
reinterpret_cast
<
uint32_t
*>
(
codeAddr
+
offset
);
if
(
isThumb32
(
ram
32
))
{
if
(
isThumb32
(
ram
16
))
{
//thumb32
//thumb32
inst
=
new
InstThumb32
(
ram32
);
inst
=
new
InstThumb32
(
ram32
);
}
else
{
}
else
{
//thumb16
//thumb16
inst
=
new
InstThumb16
(
static_cast
<
uint16_t
>
(
ram32
)
);
inst
=
new
InstThumb16
(
ram16
);
}
}
if
(
!
visitor
->
visit
(
inst
,
offset
,
codeLen
))
{
if
(
!
visitor
->
visit
(
inst
,
offset
,
codeLen
))
{
delete
inst
;
delete
inst
;
...
...
hooklib/src/main/cpp/sandhook.cpp
View file @
74316b18
...
@@ -165,9 +165,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
...
@@ -165,9 +165,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
}
}
if
(
SDK_INT
>=
ANDROID_P
&&
BYTE_POINT
==
4
)
{
if
(
origin
->
isAbstract
())
{
isInlineHook
=
false
;
}
else
if
(
origin
->
isAbstract
())
{
isInlineHook
=
false
;
isInlineHook
=
false
;
}
else
if
(
!
origin
->
isCompiled
())
{
}
else
if
(
!
origin
->
isCompiled
())
{
if
(
SDK_INT
>=
ANDROID_N
)
{
if
(
SDK_INT
>=
ANDROID_N
)
{
...
...
hooklib/src/main/cpp/trampoline/trampoline_manager.cpp
View file @
74316b18
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "../includes/inst.h"
#include "../includes/inst.h"
extern
int
SDK_INT
;
extern
int
SDK_INT
;
#define SWITCH_SETX0 false
namespace
SandHook
{
namespace
SandHook
{
...
@@ -25,12 +26,23 @@ namespace SandHook {
...
@@ -25,12 +26,23 @@ namespace SandHook {
public
:
public
:
bool
pcRelated
=
false
;
bool
pcRelated
=
false
;
bool
canSafeBackup
=
true
;
int
instSize
=
0
;
bool
visit
(
Inst
*
inst
,
Size
offset
,
Size
length
)
override
{
bool
visit
(
Inst
*
inst
,
Size
offset
,
Size
length
)
override
{
instSize
+=
inst
->
instLen
();
if
(
inst
->
pcRelated
())
{
if
(
inst
->
pcRelated
())
{
pcRelated
=
true
;
pcRelated
=
true
;
return
false
;
return
false
;
}
}
if
(
instSize
>
SIZE_DIRECT_JUMP_TRAMPOLINE
)
{
canSafeBackup
=
false
;
}
return
true
;
return
true
;
}
}
};
};
...
@@ -44,12 +56,12 @@ namespace SandHook {
...
@@ -44,12 +56,12 @@ namespace SandHook {
}
}
}
}
//check pc relate inst
//check pc relate inst
& backup inst len
PCRelatedCheckVisitor
visitor
;
PCRelatedCheckVisitor
visitor
;
InstDecode
::
decode
(
method
->
getQuickCodeEntry
(),
SIZE_DIRECT_JUMP_TRAMPOLINE
,
&
visitor
);
InstDecode
::
decode
(
method
->
getQuickCodeEntry
(),
SIZE_DIRECT_JUMP_TRAMPOLINE
,
&
visitor
);
return
!
visitor
.
pcRelated
;
return
(
!
visitor
.
pcRelated
)
&&
visitor
.
canSafeBackup
;
}
}
Code
TrampolineManager
::
allocExecuteSpace
(
Size
size
)
{
Code
TrampolineManager
::
allocExecuteSpace
(
Size
size
)
{
...
@@ -103,7 +115,7 @@ namespace SandHook {
...
@@ -103,7 +115,7 @@ namespace SandHook {
replacementHookTrampoline
->
setHookMethod
(
reinterpret_cast
<
Code
>
(
hookMethod
));
replacementHookTrampoline
->
setHookMethod
(
reinterpret_cast
<
Code
>
(
hookMethod
));
hookTrampoline
->
replacement
=
replacementHookTrampoline
;
hookTrampoline
->
replacement
=
replacementHookTrampoline
;
if
(
backupMethod
!=
nullptr
)
{
if
(
SWITCH_SETX0
&&
backupMethod
!=
nullptr
)
{
callOriginTrampoline
=
new
CallOriginTrampoline
();
callOriginTrampoline
=
new
CallOriginTrampoline
();
checkThumbCode
(
callOriginTrampoline
,
getEntryCode
(
originMethod
));
checkThumbCode
(
callOriginTrampoline
,
getEntryCode
(
originMethod
));
callOriginTrampoline
->
init
();
callOriginTrampoline
->
init
();
...
...
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