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
91f6050c
Commit
91f6050c
authored
May 08, 2019
by
swift_gan
Committed by
swift_gan
May 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add cbz cbnz
parent
c8ec5259
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
5 deletions
+71
-5
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+33
-2
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+26
-0
inst_struct_aarch64.h
...ehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
+9
-0
instruction.h
nativehook/src/main/cpp/asm/instruction.h
+3
-3
No files found.
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
91f6050c
...
@@ -94,7 +94,7 @@ void A64_MOV_WIDE::decode(aarch64_mov_wide *inst) {
...
@@ -94,7 +94,7 @@ void A64_MOV_WIDE::decode(aarch64_mov_wide *inst) {
imme
=
static_cast
<
U16
>
(
inst
->
imm16
);
imme
=
static_cast
<
U16
>
(
inst
->
imm16
);
shift
=
static_cast
<
U8
>
(
inst
->
hw
*
16
);
shift
=
static_cast
<
U8
>
(
inst
->
hw
*
16
);
op
=
static_cast
<
OP
>
(
inst
->
opc
);
op
=
static_cast
<
OP
>
(
inst
->
opc
);
if
(
inst
->
sf
==
0
)
{
if
(
inst
->
sf
==
1
)
{
rd
=
XRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rd
));
rd
=
XRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rd
));
}
else
{
}
else
{
rd
=
WRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rd
));
rd
=
WRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rd
));
...
@@ -127,5 +127,36 @@ void A64_B_BL::decode(aarch64_b_bl *inst) {
...
@@ -127,5 +127,36 @@ void A64_B_BL::decode(aarch64_b_bl *inst) {
void
A64_B_BL
::
assembler
()
{
void
A64_B_BL
::
assembler
()
{
get
()
->
opcode
=
B_BL_OPCODE
;
get
()
->
opcode
=
B_BL_OPCODE
;
get
()
->
op
=
op
;
get
()
->
op
=
op
;
get
()
->
imm26
=
TruncateToUint
32
(
offset
);
get
()
->
imm26
=
TruncateToUint
26
(
offset
);
}
}
//CBZ CBNZ
A64_CBZ_CBNZ
::
A64_CBZ_CBNZ
()
{}
A64_CBZ_CBNZ
::
A64_CBZ_CBNZ
(
aarch64_cbz_cbnz
*
inst
)
:
A64_INST_PC_REL
(
inst
)
{}
ADDR
A64_CBZ_CBNZ
::
getImmPCOffset
()
{
return
signExtend64
(
19
+
2
,
COMBINE
(
get
()
->
imm19
,
0
b00
,
2
));
}
void
A64_CBZ_CBNZ
::
decode
(
aarch64_cbz_cbnz
*
inst
)
{
op
=
static_cast
<
OP
>
(
get
()
->
op
);
if
(
inst
->
sf
==
1
)
{
rt
=
XRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rt
));
}
else
{
rt
=
WRegister
::
get
(
static_cast
<
U8
>
(
inst
->
rt
));
}
offset
=
getImmPCOffset
();
}
void
A64_CBZ_CBNZ
::
assembler
()
{
get
()
->
opcode
=
CBZ_CBNZ_OPCODE
;
get
()
->
op
=
op
;
get
()
->
rt
=
rt
->
getCode
();
get
()
->
sf
=
rt
->
is64Bit
()
?
1
:
0
;
get
()
->
imm19
=
TruncateToUint19
(
offset
);
}
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
91f6050c
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include "../../../asm/instruction.h"
#include "../../../asm/instruction.h"
#include "../../../includes/base.h"
#include "../../../includes/base.h"
#include "../register/register_a64.h"
#include "../register/register_a64.h"
#include "../../../../../../../hooklib/src/main/cpp/includes/inst.h"
namespace
SandHook
{
namespace
SandHook
{
...
@@ -206,6 +207,31 @@ namespace SandHook {
...
@@ -206,6 +207,31 @@ namespace SandHook {
ADDR
offset
;
ADDR
offset
;
};
};
class
A64_CBZ_CBNZ
:
public
A64_INST_PC_REL
<
aarch64_cbz_cbnz
>
{
public
:
enum
OP
{
CBZ
=
0
,
CBNZ
=
1
};
A64_CBZ_CBNZ
();
A64_CBZ_CBNZ
(
aarch64_cbz_cbnz
*
inst
);
ADDR
getImmPCOffset
()
override
;
void
decode
(
aarch64_cbz_cbnz
*
inst
)
override
;
void
assembler
()
override
;
private
:
OP
op
;
ADDR
offset
;
RegisterA64
*
rt
;
};
}
}
}
}
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
View file @
91f6050c
...
@@ -65,4 +65,13 @@ struct aarch64_b_bl {
...
@@ -65,4 +65,13 @@ struct aarch64_b_bl {
InstA64
imm26
:
26
;
InstA64
imm26
:
26
;
};
};
#define CBZ_CBNZ_OPCODE 0b011010
struct
aarch64_cbz_cbnz
{
InstA64
sf
:
1
;
InstA64
opcode
:
6
;
InstA64
op
:
1
;
InstA64
imm19
:
19
;
InstA64
rt
:
5
;
};
#endif //SANDHOOK_NH_INST_AARCH64_H
#endif //SANDHOOK_NH_INST_AARCH64_H
nativehook/src/main/cpp/asm/instruction.h
View file @
91f6050c
...
@@ -44,11 +44,11 @@ namespace SandHook {
...
@@ -44,11 +44,11 @@ namespace SandHook {
return
raw
;
return
raw
;
}
}
Raw
*
get
()
const
{
inline
Raw
*
get
()
const
{
return
raw
;
return
raw
;
}
}
void
set
(
Raw
raw
)
const
{
inline
void
set
(
Raw
raw
)
const
{
*
this
->
raw
=
raw
;
*
this
->
raw
=
raw
;
}
}
...
@@ -95,7 +95,7 @@ namespace SandHook {
...
@@ -95,7 +95,7 @@ namespace SandHook {
return
false
;
return
false
;
}
}
virtual
void
decode
(
Inst
*
decode
)
{}
virtual
void
decode
(
Inst
*
inst
)
{}
virtual
void
assembler
()
{}
virtual
void
assembler
()
{}
};
};
...
...
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