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
12e606a5
Commit
12e606a5
authored
May 11, 2019
by
swift_gan
Committed by
swift_gan
May 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add inst str unsign imm
parent
0283ee7b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
5 deletions
+93
-5
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+47
-1
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+32
-0
inst_struct_aarch64.h
...ehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
+9
-0
sandhook_native.cpp
nativehook/src/main/cpp/sandhook_native.cpp
+5
-4
No files found.
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
12e606a5
...
@@ -310,6 +310,10 @@ A64_STR_IMM::A64_STR_IMM(STRUCT_A64(STR_IMM) &inst) : InstructionA64(&inst) {
...
@@ -310,6 +310,10 @@ A64_STR_IMM::A64_STR_IMM(STRUCT_A64(STR_IMM) &inst) : InstructionA64(&inst) {
decode
(
&
inst
);
decode
(
&
inst
);
}
}
A64_STR_IMM
::
A64_STR_IMM
(
RegisterA64
&
rt
,
const
MemOperand
&
operand
)
:
rt
(
&
rt
),
operand
(
operand
)
{
}
void
A64_STR_IMM
::
decode
(
STRUCT_A64
(
STR_IMM
)
*
inst
)
{
void
A64_STR_IMM
::
decode
(
STRUCT_A64
(
STR_IMM
)
*
inst
)
{
regSize
=
Size
(
inst
->
size
);
regSize
=
Size
(
inst
->
size
);
switch
(
regSize
)
{
switch
(
regSize
)
{
...
@@ -376,6 +380,48 @@ void A64_STR_IMM::assembler() {
...
@@ -376,6 +380,48 @@ void A64_STR_IMM::assembler() {
}
}
}
}
A64_STR_
IMM
::
A64_STR_IMM
(
RegisterA64
&
rt
,
const
MemOperand
&
operand
)
:
rt
(
&
rt
),
operand
(
operand
)
{
A64_STR_
UIMM
::
A64_STR_UIMM
()
{}
A64_STR_UIMM
::
A64_STR_UIMM
(
STRUCT_A64
(
STR_UIMM
)
&
inst
)
:
InstructionA64
(
&
inst
)
{
decode
(
&
inst
);
}
}
A64_STR_UIMM
::
A64_STR_UIMM
(
RegisterA64
&
rt
,
const
MemOperand
&
operand
)
:
rt
(
&
rt
),
operand
(
operand
)
{
}
void
A64_STR_UIMM
::
decode
(
STRUCT_A64
(
STR_UIMM
)
*
inst
)
{
regSize
=
Size
(
inst
->
size
);
switch
(
regSize
)
{
case
Size64
:
rt
=
XReg
(
static_cast
<
U8
>
(
inst
->
rt
));
operand
.
base
=
XReg
(
static_cast
<
U8
>
(
inst
->
rn
));
break
;
case
Size32
:
rt
=
WReg
(
static_cast
<
U8
>
(
inst
->
rt
));
operand
.
base
=
WReg
(
static_cast
<
U8
>
(
inst
->
rn
));
break
;
default
:
valid
=
false
;
return
;
}
operand
.
addr_mode
=
AddrMode
::
Offset
;
scale
=
static_cast
<
U8
>
(
inst
->
size
);
offset
=
inst
->
imm12
<<
regSize
;
operand
.
offset
=
offset
;
}
void
A64_STR_UIMM
::
assembler
()
{
SET_OPCODE
(
STR_IMM
);
get
()
->
rt
=
rt
->
getCode
();
get
()
->
rn
=
operand
.
base
->
getCode
();
if
(
rt
->
isX
())
{
get
()
->
size
=
Size64
;
}
else
if
(
rt
->
isW
())
{
get
()
->
size
=
Size32
;
}
else
{
valid
=
false
;
return
;
}
get
()
->
imm12
=
operand
.
offset
>>
get
()
->
size
;
}
\ No newline at end of file
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
12e606a5
...
@@ -543,6 +543,38 @@ namespace SandHook {
...
@@ -543,6 +543,38 @@ namespace SandHook {
Off
offset
;
Off
offset
;
};
};
class
INST_A64
(
STR_UIMM
)
:
public
InstructionA64
<
STRUCT_A64
(
STR_UIMM
)
>
{
public
:
enum
Size
{
Size32
=
0
b10
,
Size64
=
0
b11
};
A64_STR_UIMM
();
A64_STR_UIMM
(
STRUCT_A64
(
STR_UIMM
)
&
inst
);
A64_STR_UIMM
(
RegisterA64
&
rt
,
const
MemOperand
&
operand
);
DEFINE_IS
(
STR_UIMM
)
void
decode
(
STRUCT_A64
(
STR_UIMM
)
*
inst
)
override
;
void
assembler
()
override
;
public
:
RegisterA64
*
rt
;
MemOperand
operand
=
MemOperand
();
private
:
Size
regSize
;
U8
scale
;
bool
wback
=
false
;
bool
postindex
=
false
;
Off
offset
;
};
}
}
}
}
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_struct_aarch64.h
View file @
12e606a5
...
@@ -177,5 +177,14 @@ DEFINE_STRUCT_A64(STR_IMM) {
...
@@ -177,5 +177,14 @@ DEFINE_STRUCT_A64(STR_IMM) {
InstA64
size
:
2
;
InstA64
size
:
2
;
};
};
DEFINE_OPCODE
(
STR_UIMM
,
0
b11100100
)
DEFINE_STRUCT_A64
(
STR_UIMM
)
{
InstA64
rt
:
5
;
InstA64
rn
:
5
;
InstA64
imm12
:
12
;
InstA64
opcode
:
8
;
InstA64
size
:
2
;
};
#endif //SANDHOOK_NH_INST_AARCH64_H
#endif //SANDHOOK_NH_INST_AARCH64_H
nativehook/src/main/cpp/sandhook_native.cpp
View file @
12e606a5
...
@@ -31,8 +31,8 @@ JNIEXPORT void JNICALL
...
@@ -31,8 +31,8 @@ JNIEXPORT void JNICALL
Java_com_swift_sandhook_nativehook_NativeHook_test
(
JNIEnv
*
env
,
jclass
jclass1
)
{
Java_com_swift_sandhook_nativehook_NativeHook_test
(
JNIEnv
*
env
,
jclass
jclass1
)
{
union
{
union
{
InstA64
raw
=
0xF
8020C
43
;
InstA64
raw
=
0xF
90010
43
;
STRUCT_A64
(
STR_IMM
)
str
;
STRUCT_A64
(
STR_
U
IMM
)
str
;
}
test
;
}
test
;
InstA64
*
codebl
=
reinterpret_cast
<
InstA64
*>
((
Addr
)
do1
+
8
);
InstA64
*
codebl
=
reinterpret_cast
<
InstA64
*>
((
Addr
)
do1
+
8
);
...
@@ -54,8 +54,9 @@ Java_com_swift_sandhook_nativehook_NativeHook_test(JNIEnv *env, jclass jclass1)
...
@@ -54,8 +54,9 @@ Java_com_swift_sandhook_nativehook_NativeHook_test(JNIEnv *env, jclass jclass1)
}
}
if
(
IS_OPCODE
(
test
.
raw
,
STR_IMM
))
{
if
(
IS_OPCODE
(
test
.
raw
,
STR_UIMM
))
{
A64_STR_IMM
str
(
test
.
str
);
A64_STR_UIMM
str
(
test
.
str
);
str
.
assembler
();
str
.
get
();
str
.
get
();
}
}
...
...
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