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
ebafba80
Commit
ebafba80
authored
May 29, 2019
by
swift_gan
Committed by
swift_gan
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NativeHook]add inst add adds sub subs
parent
f1ff5627
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
133 additions
and
5 deletions
+133
-5
assembler_arm64.cpp
...rc/main/cpp/archs/arm/arm64/assembler/assembler_arm64.cpp
+18
-2
assembler_arm64.h
.../src/main/cpp/archs/arm/arm64/assembler/assembler_arm64.h
+8
-2
decoder_arm64.cpp
...ok/src/main/cpp/archs/arm/arm64/decoder/decoder_arm64.cpp
+2
-0
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_arm64.cpp
+48
-0
inst_arm64.h
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_arm64.h
+40
-0
inst_code_arm64.h
...ehook/src/main/cpp/archs/arm/arm64/inst/inst_code_arm64.h
+1
-0
inst_struct_aarch64.h
...k/src/main/cpp/archs/arm/arm64/inst/inst_struct_aarch64.h
+12
-0
arm_base.h
nativehook/src/main/cpp/archs/arm/arm_base.h
+3
-0
settings.gradle
settings.gradle
+1
-1
No files found.
nativehook/src/main/cpp/archs/arm/arm64/assembler/assembler_arm64.cpp
View file @
ebafba80
...
...
@@ -207,14 +207,30 @@ void AssemblerA64::Subs(RegisterA64 &rd, RegisterA64 &rn, const Operand &operand
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
SUB_EXT_REG
)(
rd
,
rn
,
operand
,
SetFlags
)));
}
void
AssemblerA64
::
s
tp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
)
{
void
AssemblerA64
::
S
tp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
STP_LDP
)(
INST_A64
(
STP_LDP
)
::
STP
,
rt1
,
rt2
,
operand
)));
}
void
AssemblerA64
::
l
dp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
)
{
void
AssemblerA64
::
L
dp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
STP_LDP
)(
INST_A64
(
STP_LDP
)
::
LDP
,
rt1
,
rt2
,
operand
)));
}
void
AssemblerA64
::
Add
(
RegisterA64
&
rd
,
const
Operand
&
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
ADD_SUB_IMM
)(
INST_A64
(
ADD_SUB_IMM
)
::
ADD
,
INST_A64
(
ADD_SUB_IMM
)
::
UnSign
,
rd
,
operand
)));
}
void
AssemblerA64
::
Adds
(
RegisterA64
&
rd
,
const
Operand
&
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
ADD_SUB_IMM
)(
INST_A64
(
ADD_SUB_IMM
)
::
ADD
,
INST_A64
(
ADD_SUB_IMM
)
::
Sign
,
rd
,
operand
)));
}
void
AssemblerA64
::
Sub
(
RegisterA64
&
rd
,
const
Operand
&
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
ADD_SUB_IMM
)(
INST_A64
(
ADD_SUB_IMM
)
::
SUB
,
INST_A64
(
ADD_SUB_IMM
)
::
UnSign
,
rd
,
operand
)));
}
void
AssemblerA64
::
Subs
(
RegisterA64
&
rd
,
const
Operand
&
operand
)
{
Emit
(
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
ADD_SUB_IMM
)(
INST_A64
(
ADD_SUB_IMM
)
::
SUB
,
INST_A64
(
ADD_SUB_IMM
)
::
Sign
,
rd
,
operand
)));
}
nativehook/src/main/cpp/archs/arm/arm64/assembler/assembler_arm64.h
View file @
ebafba80
...
...
@@ -74,8 +74,14 @@ namespace SandHook {
void
Subs
(
RegisterA64
&
rd
,
RegisterA64
&
rn
,
const
Operand
&
operand
);
void
Cmp
(
RegisterA64
&
rn
,
const
Operand
&
operand
);
void
stp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
);
void
ldp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
);
void
Stp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
);
void
Ldp
(
RegisterA64
&
rt1
,
RegisterA64
&
rt2
,
const
MemOperand
operand
);
void
Add
(
RegisterA64
&
rd
,
const
Operand
&
operand
);
void
Adds
(
RegisterA64
&
rd
,
const
Operand
&
operand
);
void
Sub
(
RegisterA64
&
rd
,
const
Operand
&
operand
);
void
Subs
(
RegisterA64
&
rd
,
const
Operand
&
operand
);
public
:
...
...
nativehook/src/main/cpp/archs/arm/arm64/decoder/decoder_arm64.cpp
View file @
ebafba80
...
...
@@ -44,6 +44,8 @@ void Arm64Decoder::decode(void *codeStart, Addr codeLen, InstVisitor &visitor, b
CASE
(
SVC
)
CASE
(
EXCEPTION_GEN
)
CASE
(
STP_LDP
)
CASE
(
ADD_SUB_IMM
)
label_matched
:
if
(
unit
==
nullptr
)
{
unit
=
reinterpret_cast
<
Unit
<
Base
>
*>
(
new
INST_A64
(
UNKNOW
)(
*
reinterpret_cast
<
STRUCT_A64
(
UNKNOW
)
*>
(
pc
)));
...
...
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_arm64.cpp
View file @
ebafba80
...
...
@@ -847,3 +847,51 @@ void A64_STP_LDP::assembler() {
}
get
()
->
imm7
=
TruncateToUint7
(
operand
.
offset
>>
(
rt1
->
isX
()
?
3
:
2
));
}
A64_ADD_SUB_IMM
::
A64_ADD_SUB_IMM
()
{}
A64_ADD_SUB_IMM
::
A64_ADD_SUB_IMM
(
A64_STRUCT_ADD_SUB_IMM
&
inst
)
:
InstructionA64
(
&
inst
)
{
decode
(
&
inst
);
}
A64_ADD_SUB_IMM
::
A64_ADD_SUB_IMM
(
A64_ADD_SUB_IMM
::
OP
op
,
A64_ADD_SUB_IMM
::
S
sign
,
RegisterA64
&
rd
,
const
Operand
&
operand
)
:
op
(
op
),
sign
(
sign
),
rd
(
&
rd
),
operand
(
operand
)
{}
void
A64_ADD_SUB_IMM
::
decode
(
A64_STRUCT_ADD_SUB_IMM
*
inst
)
{
DECODE_OP
;
if
(
inst
->
sf
==
Size64
)
{
DECODE_RD
(
XReg
);
operand
.
reg
=
XReg
(
inst
->
rn
);
}
else
{
DECODE_RD
(
XReg
);
operand
.
reg
=
WReg
(
inst
->
rn
);
}
sign
=
S
(
inst
->
S
);
DECODE_SHIFT
;
if
(
operand
.
shift
==
LSL
)
{
operand
.
immediate
=
get
()
->
imm12
;
}
else
if
(
operand
.
shift
==
LSR
)
{
operand
.
immediate
=
get
()
->
imm12
<<
12
;
}
else
{
valid
=
false
;
}
}
void
A64_ADD_SUB_IMM
::
assembler
()
{
SET_OPCODE
(
ADD_SUB_IMM
);
ENCODE_OP
;
ENCODE_RD
;
get
()
->
rn
=
operand
.
reg
->
getCode
();
get
()
->
sf
=
rd
->
isX
()
?
Size64
:
Size32
;
get
()
->
S
=
sign
;
ENCODE_SHIFT
;
if
(
operand
.
shift
==
LSL
)
{
get
()
->
imm12
=
static_cast
<
InstA64
>
(
operand
.
immediate
);
}
else
if
(
operand
.
shift
==
LSR
)
{
get
()
->
imm12
=
static_cast
<
InstA64
>
(
operand
.
immediate
)
>>
12
;
}
else
{
valid
=
false
;
}
}
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_arm64.h
View file @
ebafba80
...
...
@@ -777,6 +777,46 @@ namespace SandHook {
MemOperand
operand
;
};
class
INST_A64
(
ADD_SUB_IMM
)
:
public
InstructionA64
<
STRUCT_A64
(
ADD_SUB_IMM
)
>
{
public
:
enum
OP
{
ADD
=
0
b0
,
SUB
=
0
b1
};
enum
S
{
Sign
=
0
b0
,
UnSign
=
0
b1
};
enum
Size
{
Size32
=
0
b0
,
Size64
=
0
b1
};
A64_ADD_SUB_IMM
();
A64_ADD_SUB_IMM
(
A64_STRUCT_ADD_SUB_IMM
&
inst
);
A64_ADD_SUB_IMM
(
OP
op
,
S
sign
,
RegisterA64
&
rd
,
const
Operand
&
operand
);
DEFINE_IS
(
ADD_SUB_IMM
)
DEFINE_INST_CODE
(
ADD_SUB_IMM
)
void
decode
(
A64_STRUCT_ADD_SUB_IMM
*
inst
)
override
;
void
assembler
()
override
;
public
:
OP
op
;
S
sign
;
RegisterA64
*
rd
;
Operand
operand
;
};
}
}
...
...
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_code_arm64.h
View file @
ebafba80
...
...
@@ -28,6 +28,7 @@ enum class InstCodeA64 {
EXCEPTION_GEN
,
SVC
,
STP_LDP
,
ADD_SUB_IMM
};
#endif //SANDHOOK_NH_INST_CODE_ARM64_H
nativehook/src/main/cpp/archs/arm/arm64/inst/inst_struct_aarch64.h
View file @
ebafba80
...
...
@@ -215,6 +215,18 @@ DEFINE_STRUCT_A64(STP_LDP) {
InstA64
size
:
2
;
};
DEFINE_OPCODE_A64
(
ADD_SUB_IMM
,
0
b10001
)
DEFINE_STRUCT_A64
(
ADD_SUB_IMM
)
{
InstA64
rd
:
WideReg
;
InstA64
rn
:
WideReg
;
InstA64
imm12
:
12
;
InstA64
shift
:
2
;
InstA64
opcode
:
5
;
InstA64
S
:
2
;
InstA64
op
:
1
;
InstA64
sf
:
1
;
};
#endif //SANDHOOK_NH_INST_AARCH64_H
nativehook/src/main/cpp/archs/arm/arm_base.h
View file @
ebafba80
...
...
@@ -66,5 +66,8 @@ enum AddrMode { Offset, PreIndex, PostIndex, NonAddrMode};
#define DECODE_OP op = OP(inst->op)
#define ENCODE_OP get()->op = op
#define DECODE_SHIFT operand.shift = Shift(inst->shift)
#define ENCODE_SHIFT get()->shift = operand.shift
#endif //SANDHOOK_ARM_BASE_H
settings.gradle
View file @
ebafba80
include
':app'
,
':hooklib'
,
':hookers'
,
':annotation'
,
':xposedcompat'
,
':nativehook'
include
':app'
,
':hooklib'
,
':hookers'
,
':annotation'
,
':xposedcompat'
,
':nativehook'
,
':xposedcompat_new'
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