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
d72dc917
Commit
d72dc917
authored
May 12, 2019
by
swift_gan
Committed by
swift_gan
May 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Exception Gen & SVC
parent
cbbdfef6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
2 deletions
+93
-2
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+32
-1
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+48
-0
inst_code_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_code_arm64.h
+3
-1
inst_struct_aarch64.h
...ehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
+10
-0
No files found.
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
d72dc917
...
@@ -464,7 +464,9 @@ void A64_MOV_REG::assembler() {
...
@@ -464,7 +464,9 @@ void A64_MOV_REG::assembler() {
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
()
{}
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
()
{}
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
(
STRUCT_A64
(
SUB_EXT_REG
)
&
inst
)
:
InstructionA64
(
&
inst
)
{}
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
(
STRUCT_A64
(
SUB_EXT_REG
)
&
inst
)
:
InstructionA64
(
&
inst
)
{
decode
(
&
inst
);
}
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
(
S
s
,
RegisterA64
&
rd
,
RegisterA64
&
rn
,
const
Operand
&
operand
,
A64_SUB_EXT_REG
::
A64_SUB_EXT_REG
(
S
s
,
RegisterA64
&
rd
,
RegisterA64
&
rn
,
const
Operand
&
operand
,
FlagsUpdate
flagsUpdate
)
:
s
(
s
),
rd
(
&
rd
),
rn
(
&
rn
),
operand
(
operand
),
FlagsUpdate
flagsUpdate
)
:
s
(
s
),
rd
(
&
rd
),
rn
(
&
rn
),
operand
(
operand
),
...
@@ -497,3 +499,32 @@ void A64_SUB_EXT_REG::assembler() {
...
@@ -497,3 +499,32 @@ void A64_SUB_EXT_REG::assembler() {
get
()
->
rn
=
rn
->
getCode
();
get
()
->
rn
=
rn
->
getCode
();
get
()
->
rd
=
rd
->
getCode
();
get
()
->
rd
=
rd
->
getCode
();
}
}
A64_EXCEPTION_GEN
::
A64_EXCEPTION_GEN
()
{}
A64_EXCEPTION_GEN
::
A64_EXCEPTION_GEN
(
STRUCT_A64
(
EXCEPTION_GEN
)
&
inst
)
:
InstructionA64
(
&
inst
)
{
decode
(
&
inst
);
}
A64_EXCEPTION_GEN
::
A64_EXCEPTION_GEN
(
A64_EXCEPTION_GEN
::
OP
op
,
ExceptionLevel
el
,
U16
imme
)
:
op
(
op
),
el
(
el
),
imme
(
imme
)
{}
void
A64_EXCEPTION_GEN
::
decode
(
STRUCT_A64
(
EXCEPTION_GEN
)
*
inst
)
{
op
=
OP
(
inst
->
op
);
el
=
ExceptionLevel
(
inst
->
ll
);
imme
=
static_cast
<
U16
>
(
inst
->
imm16
);
}
void
A64_EXCEPTION_GEN
::
assembler
()
{
SET_OPCODE_MULTI
(
EXCEPTION_GEN
,
1
);
SET_OPCODE_MULTI
(
EXCEPTION_GEN
,
2
);
get
()
->
op
=
op
;
get
()
->
ll
=
el
;
get
()
->
imm16
=
imme
;
}
A64_SVC
::
A64_SVC
(
U16
imme
)
:
A64_EXCEPTION_GEN
(
XXC
,
EL1
,
imme
)
{}
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
d72dc917
...
@@ -94,6 +94,13 @@ namespace SandHook {
...
@@ -94,6 +94,13 @@ namespace SandHook {
LeaveFlags
=
0
LeaveFlags
=
0
};
};
enum
ExceptionLevel
{
EL0
=
0
b00
,
EL1
=
0
b01
,
EL2
=
0
b10
,
EL3
=
0
b11
};
class
Operand
{
class
Operand
{
public
:
public
:
inline
explicit
Operand
(){};
inline
explicit
Operand
(){};
...
@@ -626,6 +633,47 @@ namespace SandHook {
...
@@ -626,6 +633,47 @@ namespace SandHook {
FlagsUpdate
flagsUpdate
;
FlagsUpdate
flagsUpdate
;
};
};
class
INST_A64
(
EXCEPTION_GEN
)
:
public
InstructionA64
<
STRUCT_A64
(
EXCEPTION_GEN
)
>
{
public
:
enum
OP
{
XXC
=
0
b000
,
BRK
=
0
b001
,
HLT
=
0
b010
,
DCP
=
0
b101
};
A64_EXCEPTION_GEN
();
A64_EXCEPTION_GEN
(
STRUCT_A64
(
EXCEPTION_GEN
)
&
inst
);
A64_EXCEPTION_GEN
(
OP
op
,
ExceptionLevel
el
,
U16
imme
);
DEFINE_IS_EXT
(
EXCEPTION_GEN
,
TEST_INST_OPCODE
(
EXCEPTION_GEN
,
1
)
&&
TEST_INST_OPCODE
(
EXCEPTION_GEN
,
2
))
DEFINE_INST_CODE
(
EXCEPTION_GEN
)
void
decode
(
A64_STRUCT_EXCEPTION_GEN
*
inst
)
override
;
void
assembler
()
override
;
public
:
OP
op
;
ExceptionLevel
el
;
U16
imme
;
};
class
INST_A64
(
SVC
)
:
public
INST_A64
(
EXCEPTION_GEN
)
{
public:
A64_SVC
(
U16
imme
);
DEFINE_IS_EXT
(
EXCEPTION_GEN
,
TEST_INST_OPCODE
(
EXCEPTION_GEN
,
1
)
&&
TEST_INST_OPCODE
(
EXCEPTION_GEN
,
2
)
&&
TEST_INST_FIELD
(
op
,
XXC
)
&&
TEST_INST_FIELD
(
ll
,
EL1
))
DEFINE_INST_CODE
(
SVC
)
};
}
}
}
}
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_code_arm64.h
View file @
d72dc917
...
@@ -20,7 +20,9 @@ enum InstCodeA64 {
...
@@ -20,7 +20,9 @@ enum InstCodeA64 {
BR_BLR_RET
,
BR_BLR_RET
,
CBZ_CBNZ
,
CBZ_CBNZ
,
TBZ_TBNZ
,
TBZ_TBNZ
,
SUB_EXT_REG
SUB_EXT_REG
,
EXCEPTION_GEN
,
SVC
};
};
// Generic fields.
// Generic fields.
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
View file @
d72dc917
...
@@ -214,5 +214,15 @@ DEFINE_STRUCT_A64(SUB_EXT_REG) {
...
@@ -214,5 +214,15 @@ DEFINE_STRUCT_A64(SUB_EXT_REG) {
InstA64
sf
:
1
;
InstA64
sf
:
1
;
};
};
DEFINE_OPCODE
(
EXCEPTION_GEN_1
,
0
b11010100
)
DEFINE_OPCODE
(
EXCEPTION_GEN_2
,
0
b11100100
)
DEFINE_STRUCT_A64
(
EXCEPTION_GEN
)
{
InstA64
opcode1
:
8
;
InstA64
op
:
3
;
InstA64
imm16
:
16
;
InstA64
opcode2
:
3
;
InstA64
ll
:
2
;
};
#endif //SANDHOOK_NH_INST_AARCH64_H
#endif //SANDHOOK_NH_INST_AARCH64_H
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