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
0ac2a058
Commit
0ac2a058
authored
May 14, 2019
by
swift_gan
Committed by
swift_gan
May 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix MOV_WIDE
parent
01661bfa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
26 deletions
+43
-26
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+1
-4
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+2
-2
code_relocate_a64.cpp
...k/src/main/cpp/archs/arm64/relocate/code_relocate_a64.cpp
+1
-1
base.h
nativehook/src/main/cpp/includes/base.h
+8
-8
sandhook_native.cpp
nativehook/src/main/cpp/sandhook_native.cpp
+31
-11
No files found.
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
0ac2a058
...
@@ -58,7 +58,6 @@ A64_ADR_ADRP::A64_ADR_ADRP(STRUCT_A64(ADR_ADRP) &inst) : A64_INST_PC_REL(&inst)
...
@@ -58,7 +58,6 @@ A64_ADR_ADRP::A64_ADR_ADRP(STRUCT_A64(ADR_ADRP) &inst) : A64_INST_PC_REL(&inst)
A64_ADR_ADRP
::
A64_ADR_ADRP
(
A64_ADR_ADRP
::
OP
op
,
XRegister
&
rd
,
S64
offset
)
:
op
(
op
),
rd
(
&
rd
),
A64_ADR_ADRP
::
A64_ADR_ADRP
(
A64_ADR_ADRP
::
OP
op
,
XRegister
&
rd
,
S64
offset
)
:
op
(
op
),
rd
(
&
rd
),
offset
(
offset
)
{
offset
(
offset
)
{
assembler
();
}
}
A64_ADR_ADRP
::
A64_ADR_ADRP
(
A64_ADR_ADRP
::
OP
op
,
XRegister
&
rd
,
Label
&
label
)
{
A64_ADR_ADRP
::
A64_ADR_ADRP
(
A64_ADR_ADRP
::
OP
op
,
XRegister
&
rd
,
Label
&
label
)
{
...
@@ -99,9 +98,7 @@ A64_MOV_WIDE::A64_MOV_WIDE(STRUCT_A64(MOV_WIDE) &inst) : InstructionA64(&inst) {
...
@@ -99,9 +98,7 @@ A64_MOV_WIDE::A64_MOV_WIDE(STRUCT_A64(MOV_WIDE) &inst) : InstructionA64(&inst) {
}
}
A64_MOV_WIDE
::
A64_MOV_WIDE
(
A64_MOV_WIDE
::
OP
op
,
RegisterA64
*
rd
,
U16
imme
,
U8
shift
)
A64_MOV_WIDE
::
A64_MOV_WIDE
(
A64_MOV_WIDE
::
OP
op
,
RegisterA64
*
rd
,
U16
imme
,
U8
shift
)
:
shift
(
shift
),
op
(
op
),
imme
(
imme
),
rd
(
rd
)
{
:
shift
(
shift
),
op
(
op
),
imme
(
imme
),
rd
(
rd
)
{}
assembler
();
}
void
A64_MOV_WIDE
::
assembler
()
{
void
A64_MOV_WIDE
::
assembler
()
{
SET_OPCODE
(
MOV_WIDE
);
SET_OPCODE
(
MOV_WIDE
);
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
0ac2a058
...
@@ -256,11 +256,11 @@ namespace SandHook {
...
@@ -256,11 +256,11 @@ namespace SandHook {
enum
OP
{
enum
OP
{
// Move and keep.
// Move and keep.
MOV_WideOp_K
=
0
b
00
,
MOV_WideOp_K
=
0
b
11
,
// Move with zero.
// Move with zero.
MOV_WideOp_Z
=
0
b10
,
MOV_WideOp_Z
=
0
b10
,
// Move with non-zero.
// Move with non-zero.
MOV_WideOp_N
=
0
b
11
,
MOV_WideOp_N
=
0
b
00
,
};
};
enum
Shift
{
enum
Shift
{
...
...
nativehook/src/main/cpp/archs/arm64/relocate/code_relocate_a64.cpp
View file @
0ac2a058
...
@@ -52,7 +52,7 @@ void* CodeRelocateA64::relocate(Instruction<Base> *instruction, void *toPc) thro
...
@@ -52,7 +52,7 @@ void* CodeRelocateA64::relocate(Instruction<Base> *instruction, void *toPc) thro
IMPL_RELOCATE
(
B_BL
)
{
IMPL_RELOCATE
(
B_BL
)
{
Addr
targetAddr
=
inst
->
getImmPCOffsetTarget
();
Addr
targetAddr
=
inst
->
getImmPCOffsetTarget
();
if
(
inst
->
op
==
inst
->
BL
)
{
if
(
inst
->
op
==
inst
->
BL
)
{
__
Mov
(
LR
,
targetAddr
+
inst
->
size
());
__
Mov
(
LR
,
(
Addr
)
inst
->
getPC
()
+
inst
->
size
());
}
}
__
Mov
(
IP1
,
targetAddr
);
__
Mov
(
IP1
,
targetAddr
);
__
Br
(
IP1
);
__
Br
(
IP1
);
...
...
nativehook/src/main/cpp/includes/base.h
View file @
0ac2a058
...
@@ -188,20 +188,20 @@ inline int32_t ExtractSignedBitfield32(int msb, int lsb, U32 x) {
...
@@ -188,20 +188,20 @@ inline int32_t ExtractSignedBitfield32(int msb, int lsb, U32 x) {
}
}
inline
int16_t
BITS16L
(
int32_t
value
)
{
inline
U16
BITS16L
(
U32
value
)
{
return
static_cast
<
int16_t
>
(
value
);
return
static_cast
<
U16
>
(
value
&
0xffff
);
}
}
inline
int16_t
BITS16H
(
int32_t
value
)
{
inline
U16
BITS16H
(
U32
value
)
{
return
static_cast
<
int16_t
>
(
value
>>
16
);
return
static_cast
<
U16
>
(
value
>>
16
);
}
}
inline
int32_t
BITS32L
(
int64_t
value
)
{
inline
U32
BITS32L
(
U64
value
)
{
return
static_cast
<
int32_t
>
(
value
);
return
static_cast
<
U32
>
(
value
);
}
}
inline
int32_t
BITS32H
(
int64_t
value
)
{
inline
U32
BITS32H
(
U64
value
)
{
return
static_cast
<
int32_t
>
(
value
>>
32
);
return
static_cast
<
U32
>
(
value
>>
32
);
}
}
#define COMBINE(hi, lo, lowide) (hi << lowide) | lo
#define COMBINE(hi, lo, lowide) (hi << lowide) | lo
...
...
nativehook/src/main/cpp/sandhook_native.cpp
View file @
0ac2a058
...
@@ -14,7 +14,9 @@ using namespace SandHook::Asm;
...
@@ -14,7 +14,9 @@ using namespace SandHook::Asm;
using
namespace
SandHook
::
Decoder
;
using
namespace
SandHook
::
Decoder
;
using
namespace
SandHook
::
Hook
;
using
namespace
SandHook
::
Hook
;
void
(
*
dosth3Backup
)(
int
)
=
nullptr
;
void
(
*
dosth3Backup
)(
int
,
int
)
=
nullptr
;
void
(
*
dosth4Backup
)()
=
nullptr
;
bool
memUnprotect
(
Addr
addr
,
Addr
len
)
{
bool
memUnprotect
(
Addr
addr
,
Addr
len
)
{
long
pagesize
=
4096
;
long
pagesize
=
4096
;
...
@@ -34,10 +36,8 @@ void do2() {
...
@@ -34,10 +36,8 @@ void do2() {
int
d
=
1
+
1
;
int
d
=
1
+
1
;
}
}
void
do3
(
int
x
)
{
void
do3
(
int
x
,
int
y
)
{
if
(
x
>
0
)
{
do2
();
return
;
}
int
a
=
1
+
1
;
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
c
=
1
+
1
;
...
@@ -45,12 +45,30 @@ void do3(int x) {
...
@@ -45,12 +45,30 @@ void do3(int x) {
LOGE
(
"x = %d"
,
x
);
LOGE
(
"x = %d"
,
x
);
}
}
void
do3replace
(
int
x
)
{
void
do5
()
{
LOGE
(
"x = %d"
,
5
);
}
void
do4
()
{
do5
();
LOGE
(
"x = %d"
,
6
);
LOGE
(
"x = %d"
,
7
);
}
void
do4replace
()
{
int
a
=
1
+
1
;
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
int
d
=
1
+
1
;
dosth3Backup
(
x
);
dosth4Backup
();
}
void
do3replace
(
int
x
,
int
y
)
{
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
dosth3Backup
(
x
,
y
);
}
}
void
do1
()
{
void
do1
()
{
...
@@ -105,10 +123,12 @@ Java_com_swift_sandhook_nativehook_NativeHook_test(JNIEnv *env, jclass jclass1)
...
@@ -105,10 +123,12 @@ Java_com_swift_sandhook_nativehook_NativeHook_test(JNIEnv *env, jclass jclass1)
InlineHookArm64Android
inlineHookArm64Android
=
InlineHookArm64Android
();
InlineHookArm64Android
inlineHookArm64Android
=
InlineHookArm64Android
();
dosth3Backup
=
reinterpret_cast
<
void
(
*
)(
int
)
>
(
inlineHookArm64Android
.
inlineHook
(
do4
();
reinterpret_cast
<
void
*>
(
do3
),
reinterpret_cast
<
void
*>
(
do3replace
)));
dosth4Backup
=
reinterpret_cast
<
void
(
*
)()
>
(
inlineHookArm64Android
.
inlineHook
(
reinterpret_cast
<
void
*>
(
do4
),
reinterpret_cast
<
void
*>
(
do4replace
)));
do
3
(
3
);
do
4
(
);
}
}
\ No newline at end of file
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