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
76661ced
Commit
76661ced
authored
Jul 08, 2019
by
swift_gan
Committed by
swift_gan
Jul 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Reconstitution]fix hook 32bit
parent
a1112fb6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
12 deletions
+12
-12
build.gradle
nativehook/build.gradle
+1
-1
decoder_arm32.cpp
...ok/src/main/cpp/archs/arm/arm32/decoder/decoder_arm32.cpp
+8
-7
hook_arm32.cpp
nativehook/src/main/cpp/archs/arm/arm32/hook/hook_arm32.cpp
+1
-2
inst_t16.cpp
nativehook/src/main/cpp/archs/arm/arm32/inst/inst_t16.cpp
+1
-1
decoder_arm64.cpp
...ok/src/main/cpp/archs/arm/arm64/decoder/decoder_arm64.cpp
+1
-1
No files found.
nativehook/build.gradle
View file @
76661ced
...
@@ -17,7 +17,7 @@ android {
...
@@ -17,7 +17,7 @@ android {
cmake
{
cmake
{
arguments
'-DBUILD_TESTING=OFF'
arguments
'-DBUILD_TESTING=OFF'
cppFlags
"-frtti -fexceptions -Wpointer-arith"
cppFlags
"-frtti -fexceptions -Wpointer-arith"
abiFilters
'armeabi-v7a'
,
'arm64-v8a'
abiFilters
'armeabi-v7a'
}
}
}
}
}
}
...
...
nativehook/src/main/cpp/archs/arm/arm32/decoder/decoder_arm32.cpp
View file @
76661ced
...
@@ -11,7 +11,7 @@ using namespace SandHook::AsmA32;
...
@@ -11,7 +11,7 @@ using namespace SandHook::AsmA32;
#define CASE(T, X) \
#define CASE(T, X) \
if (IS_OPCODE_##T(*reinterpret_cast<Inst##T *>(pc), X)) { \
if (IS_OPCODE_##T(*reinterpret_cast<Inst##T *>(pc), X)) { \
unit = reinterpret_cast<
Unit<Base>
*>(new INST_##T(X)(pc)); \
unit = reinterpret_cast<
BaseUnit
*>(new INST_##T(X)(pc)); \
goto label_matched; \
goto label_matched; \
}
}
...
@@ -30,9 +30,9 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
...
@@ -30,9 +30,9 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
}
}
void
*
pc
=
codeStart
;
void
*
pc
=
codeStart
;
Addr
endAddr
=
(
Addr
)
codeStart
+
codeLen
;
Addr
endAddr
=
(
Addr
)
codeStart
+
codeLen
;
Unit
<
Base
>*
unit
=
nullptr
;
BaseUnit
*
unit
=
nullptr
;
while
((
Addr
)
pc
<
endAddr
)
{
while
((
Addr
)
pc
<
endAddr
)
{
bool
thumb32
=
IsThumb32
(
*
reinterpret_cast
<
InstT16
*>
(
pc
));
bool
thumb32
=
IsThumb32
(
*
reinterpret_cast
<
InstT16
*>
(
pc
));
if
(
thumb
&&
thumb32
)
{
if
(
thumb
&&
thumb32
)
{
CASE_T32
(
SUB_IMM
)
CASE_T32
(
SUB_IMM
)
CASE_T32
(
B32
)
CASE_T32
(
B32
)
...
@@ -43,7 +43,7 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
...
@@ -43,7 +43,7 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
CASE_T32
(
MOV_MOVT_IMM
)
CASE_T32
(
MOV_MOVT_IMM
)
}
}
if
(
unit
==
nullptr
)
{
if
(
unit
==
nullptr
)
{
unit
=
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_T32
(
UNKNOW
)(
pc
));
unit
=
reinterpret_cast
<
BaseUnit
*>
(
new
INST_T32
(
UNKNOW
)(
pc
));
}
}
}
else
if
(
thumb
)
{
}
else
if
(
thumb
)
{
CASE_T16
(
B
)
CASE_T16
(
B
)
...
@@ -63,18 +63,19 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
...
@@ -63,18 +63,19 @@ void Arm32Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
CASE_T16
(
PUSH
)
CASE_T16
(
PUSH
)
}
}
if
(
unit
==
nullptr
)
{
if
(
unit
==
nullptr
)
{
unit
=
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_T16
(
UNKNOW
)(
pc
));
unit
=
reinterpret_cast
<
BaseUnit
*>
(
new
INST_T16
(
UNKNOW
)(
pc
));
}
}
}
else
{
}
else
{
//TODO arm32 support
//TODO arm32 support
unit
=
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_T32
(
UNKNOW
)(
pc
));
unit
=
reinterpret_cast
<
BaseUnit
*>
(
new
INST_T32
(
UNKNOW
)(
pc
));
}
}
label_matched
:
label_matched
:
reinterpret_cast
<
BaseInst
*>
(
unit
)
->
Disassemble
();
if
(
!
visitor
.
Visit
(
unit
,
pc
))
{
if
(
!
visitor
.
Visit
(
unit
,
pc
))
{
break
;
break
;
}
}
pc
=
reinterpret_cast
<
InstA64
*>
((
Addr
)
pc
+
unit
->
Size
());
pc
=
reinterpret_cast
<
void
*>
((
Addr
)
pc
+
unit
->
Size
());
unit
=
nullptr
;
unit
=
nullptr
;
}
}
}
}
...
...
nativehook/src/main/cpp/archs/arm/arm32/hook/hook_arm32.cpp
View file @
76661ced
...
@@ -60,8 +60,7 @@ void *InlineHookArm32Android::Hook(void *origin, void *replace) {
...
@@ -60,8 +60,7 @@ void *InlineHookArm32Android::Hook(void *origin, void *replace) {
ALIGN_FOR_LDR
ALIGN_FOR_LDR
__
Ldr
(
PC
,
origin_addr_label
);
__
Ldr
(
PC
,
origin_addr_label
);
__
Emit
(
origin_addr_label
);
__
Emit
(
origin_addr_label
);
__
Emit
((
Addr
)
GetThumbPC
(
__
Emit
((
Addr
)
GetThumbPC
(
reinterpret_cast
<
void
*>
(
reinterpret_cast
<
Addr
>
(
origin_code
)
+
relocate
.
cur_offset
)));
reinterpret_cast
<
void
*>
(
reinterpret_cast
<
Addr
>
(
origin_code
)
+
relocate
.
cur_offset
)));
__
Finish
();
__
Finish
();
#undef __
#undef __
...
...
nativehook/src/main/cpp/archs/arm/arm32/inst/inst_t16.cpp
View file @
76661ced
...
@@ -17,7 +17,7 @@ using namespace SandHook::RegistersA32;
...
@@ -17,7 +17,7 @@ using namespace SandHook::RegistersA32;
//Unknow
//Unknow
T16_UNKNOW
::
T16_UNKNOW
(
void
*
inst
)
:
InstructionT16
(
&
inst
)
{
T16_UNKNOW
::
T16_UNKNOW
(
void
*
inst
)
:
InstructionT16
(
inst
)
{
}
}
//B
//B
...
...
nativehook/src/main/cpp/archs/arm/arm64/decoder/decoder_arm64.cpp
View file @
76661ced
...
@@ -20,7 +20,7 @@ void Arm64Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
...
@@ -20,7 +20,7 @@ void Arm64Decoder::Disassembler(void *codeStart, Addr codeLen, InstVisitor &visi
bool
onlyPcRelInst
)
{
bool
onlyPcRelInst
)
{
InstA64
*
pc
=
reinterpret_cast
<
InstA64
*>
(
codeStart
);
InstA64
*
pc
=
reinterpret_cast
<
InstA64
*>
(
codeStart
);
Addr
end_addr
=
(
Addr
)
codeStart
+
codeLen
;
Addr
end_addr
=
(
Addr
)
codeStart
+
codeLen
;
Unit
<
Base
>
*
unit
=
nullptr
;
BaseUnit
*
unit
=
nullptr
;
while
((
Addr
)
pc
<
end_addr
)
{
while
((
Addr
)
pc
<
end_addr
)
{
// pc relate insts
// pc relate insts
CASE
(
B_BL
)
CASE
(
B_BL
)
...
...
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