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
b9946009
Commit
b9946009
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 inst SUBS Reg
parent
e8b846a7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
1 deletion
+89
-1
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+35
-0
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+37
-0
inst_code_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_code_arm64.h
+1
-0
inst_struct_aarch64.h
...ehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
+11
-0
register_list_a64.cpp
...k/src/main/cpp/archs/arm64/register/register_list_a64.cpp
+4
-1
instruction.h
nativehook/src/main/cpp/asm/instruction.h
+1
-0
No files found.
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
b9946009
...
...
@@ -459,3 +459,38 @@ void A64_MOV_REG::assembler() {
get
()
->
rd
=
rd
->
getCode
();
get
()
->
rm
=
rm
->
getCode
();
}
A64_SUBS_EXT_REG
::
A64_SUBS_EXT_REG
()
{}
A64_SUBS_EXT_REG
::
A64_SUBS_EXT_REG
(
STRUCT_A64
(
SUBS_EXT_REG
)
&
inst
)
:
InstructionA64
(
&
inst
)
{}
A64_SUBS_EXT_REG
::
A64_SUBS_EXT_REG
(
RegisterA64
&
rd
,
RegisterA64
&
rn
,
const
Operand
&
operand
,
FlagsUpdate
flagsUpdate
)
:
rd
(
&
rd
),
rn
(
&
rn
),
operand
(
operand
),
flagsUpdate
(
flagsUpdate
)
{}
void
A64_SUBS_EXT_REG
::
decode
(
STRUCT_A64
(
SUBS_EXT_REG
)
*
inst
)
{
if
(
inst
->
sf
==
1
)
{
rd
=
XReg
(
static_cast
<
U8
>
(
inst
->
rd
));
rn
=
XReg
(
static_cast
<
U8
>
(
inst
->
rn
));
operand
.
reg
=
XReg
(
static_cast
<
U8
>
(
inst
->
rm
));
}
else
{
rd
=
WReg
(
static_cast
<
U8
>
(
inst
->
rd
));
rn
=
WReg
(
static_cast
<
U8
>
(
inst
->
rn
));
operand
.
reg
=
XReg
(
static_cast
<
U8
>
(
inst
->
rm
));
}
operand
.
extend
=
Extend
(
inst
->
option
);
INST_ASSERT
(
inst
->
imm3
>
4
);
operand
.
shift
=
Shift
(
inst
->
imm3
);
}
void
A64_SUBS_EXT_REG
::
assembler
()
{
SET_OPCODE
(
SUBS_EXT_REG
);
get
()
->
sf
=
rd
->
isX
()
?
1
:
0
;
get
()
->
option
=
operand
.
extend
;
get
()
->
imm3
=
operand
.
shift
;
get
()
->
rm
=
operand
.
reg
->
getCode
();
get
()
->
rn
=
rn
->
getCode
();
get
()
->
rd
=
rd
->
getCode
();
}
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
b9946009
...
...
@@ -84,8 +84,19 @@ namespace SandHook {
enum
MemOp
{
MemOp_LOAD
,
MemOp_STORE
,
MemOp_PREFETCH
};
enum
FPTrapFlags
{
EnableTrap
=
1
,
DisableTrap
=
0
};
enum
FlagsUpdate
{
SetFlags
=
1
,
LeaveFlags
=
0
};
class
Operand
{
public
:
inline
explicit
Operand
(){};
inline
explicit
Operand
(
S64
imm
)
:
immediate
(
imm
),
reg
(
&
UnknowRegiser
),
shift
(
NO_SHIFT
),
extend
(
NO_EXTEND
),
shift_extend_imm
(
0
)
{}
inline
Operand
(
RegisterA64
*
reg
,
Shift
shift
=
LSL
,
int32_t
imm
=
0
)
...
...
@@ -581,6 +592,32 @@ namespace SandHook {
RegisterA64
*
rm
;
};
class
INST_A64
(
SUBS_EXT_REG
)
:
InstructionA64
<
STRUCT_A64
(
SUBS_EXT_REG
)
>
{
public
:
A64_SUBS_EXT_REG
();
A64_SUBS_EXT_REG
(
STRUCT_A64
(
SUBS_EXT_REG
)
&
inst
);
A64_SUBS_EXT_REG
(
RegisterA64
&
rd
,
RegisterA64
&
rn
,
const
Operand
&
operand
,
FlagsUpdate
flagsUpdate
);
DEFINE_IS
(
SUBS_EXT_REG
)
DEFINE_INST_CODE
(
SUBS_EXT_REG
)
void
decode
(
A64_STRUCT_SUBS_EXT_REG
*
inst
)
override
;
void
assembler
()
override
;
public
:
RegisterA64
*
rd
;
RegisterA64
*
rn
;
Operand
operand
=
Operand
();
FlagsUpdate
flagsUpdate
;
};
}
}
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_code_arm64.h
View file @
b9946009
...
...
@@ -20,6 +20,7 @@ enum InstCodeA64 {
BR_BLR_RET
,
CBZ_CBNZ
,
TBZ_TBNZ
,
SUBS_EXT_REG
};
// Generic fields.
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
View file @
b9946009
...
...
@@ -200,5 +200,16 @@ DEFINE_STRUCT_A64(STR_UIMM) {
InstA64
size
:
2
;
};
DEFINE_OPCODE
(
SUBS_EXT_REG
,
0
b1101011001
)
DEFINE_STRUCT_A64
(
SUBS_EXT_REG
)
{
InstA64
rd
:
WideReg
;
InstA64
rn
:
WideReg
;
InstA64
imm3
:
3
;
InstA64
option
:
3
;
InstA64
rm
:
WideReg
;
InstA64
opcode
:
10
;
InstA64
sf
:
1
;
};
#endif //SANDHOOK_NH_INST_AARCH64_H
nativehook/src/main/cpp/archs/arm64/register/register_list_a64.cpp
View file @
b9946009
...
...
@@ -18,4 +18,7 @@ XRegister LR = X30;
//zero reg
XRegister
XZR
=
X31
;
WRegister
WZR
=
W31
;
RegisterA64
UnknowRegiser
=
RegisterA64
(
38
);
\ No newline at end of file
RegisterA64
UnknowRegiser
=
RegisterA64
(
38
);
//cmp....
#define ZeroRegFor(X) X.isX() ? XZR : WZR
\ No newline at end of file
nativehook/src/main/cpp/asm/instruction.h
View file @
b9946009
...
...
@@ -31,6 +31,7 @@ DCHECK(X,V, valid = false;)
#define INST_ASSERT(COND) \
if (COND) { \
valid = false; \
return; \
}
namespace
SandHook
{
...
...
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