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
30c986ac
Commit
30c986ac
authored
May 09, 2019
by
swift_gan
Committed by
swift_gan
May 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak code
parent
d3ff754d
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
147 additions
and
12 deletions
+147
-12
CMakeLists.txt
nativehook/CMakeLists.txt
+3
-0
inst_arm64.cpp
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
+1
-1
inst_arm64.h
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
+1
-1
instruction.h
nativehook/src/main/cpp/asm/instruction.h
+52
-10
assembler.cpp
nativehook/src/main/cpp/assembler/assembler.cpp
+4
-0
elf.cpp
nativehook/src/main/cpp/elf/elf.cpp
+5
-0
assembler.h
nativehook/src/main/cpp/includes/assembler.h
+0
-0
base.h
nativehook/src/main/cpp/includes/base.h
+11
-0
code_relocate.h
nativehook/src/main/cpp/includes/code_relocate.h
+28
-0
decoder.h
nativehook/src/main/cpp/includes/decoder.h
+0
-0
elf.h
nativehook/src/main/cpp/includes/elf.h
+8
-0
exception.h
nativehook/src/main/cpp/includes/exception.h
+29
-0
code_relocate.cpp
nativehook/src/main/cpp/relocate/code_relocate.cpp
+5
-0
No files found.
nativehook/CMakeLists.txt
View file @
30c986ac
...
...
@@ -23,6 +23,9 @@ add_library( # Sets the name of the library.
src/main/cpp/archs/arm64/register/register_a64.cpp
src/main/cpp/archs/arm64/register/register_list_a64.cpp
src/main/cpp/archs/arm64/decoder/decoder_arm64.cpp
src/main/cpp/relocate/code_relocate.cpp
src/main/cpp/elf/elf.cpp
src/main/cpp/assembler/assembler.cpp
)
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.cpp
View file @
30c986ac
...
...
@@ -9,7 +9,7 @@
using
namespace
SandHook
::
Asm
;
template
<
typename
InstStruct
>
U
8
InstructionA64
<
InstStruct
>::
size
()
{
U
32
InstructionA64
<
InstStruct
>::
size
()
{
return
sizeof
(
InstA64
);
}
...
...
nativehook/src/main/cpp/archs/arm64/inst/inst_arm64.h
View file @
30c986ac
...
...
@@ -42,7 +42,7 @@ namespace SandHook {
return
raw
&
*
(
this
->
get
());
}
U
8
size
()
override
;
U
32
size
()
override
;
static
inline
U32
extend32
(
unsigned
int
bits
,
U32
value
)
{
return
value
<<
(
32
-
bits
);
...
...
nativehook/src/main/cpp/asm/instruction.h
View file @
30c986ac
...
...
@@ -29,9 +29,11 @@ namespace SandHook {
public
:
Unit
()
{
raw
=
reinterpret_cast
<
Raw
*>
(
malloc
(
size
()));
memset
(
raw
,
0
,
size
());
auto_alloc
=
true
;
if
(
unitType
()
!=
Void
)
{
raw
=
reinterpret_cast
<
Raw
*>
(
malloc
(
size
()));
memset
(
raw
,
0
,
size
());
auto_alloc
=
true
;
}
}
Unit
<
Raw
>
(
Raw
*
raw
)
:
raw
(
raw
)
{}
...
...
@@ -57,7 +59,11 @@ namespace SandHook {
memcpy
(
dest
,
getPC
(),
size
());
}
virtual
U8
size
()
{
virtual
UnitType
unitType
()
{
return
UnitType
::
Unkown
;
};
virtual
U32
size
()
{
return
sizeof
(
Raw
);
}
...
...
@@ -80,6 +86,10 @@ namespace SandHook {
Instruction
(
Inst
*
inst
)
:
Unit
<
Inst
>
(
inst
)
{}
UnitType
unitType
()
override
{
return
UnitType
::
Inst
;
};
virtual
InstType
instType
()
{
return
unkownInst
;
}
...
...
@@ -101,19 +111,51 @@ namespace SandHook {
virtual
void
assembler
()
{}
};
class
Data16
:
public
Unit
<
U16
>
{
template
<
typename
DType
>
class
Data
:
public
Unit
<
DType
>
{
public
:
Data
(
DType
raw
)
:
Unit
<
DType
>
(
raw
)
{}
inline
UnitType
unitType
()
override
{
return
UnitType
::
Data
;
};
};
class
Data16
:
public
Data
<
U16
>
{
public
:
Data16
(
U16
raw
)
:
Data
(
raw
)
{}
};
class
Data32
:
public
Data
<
U32
>
{
public
:
Data
16
(
U16
raw
)
:
Unit
(
raw
)
{}
Data
32
(
U32
raw
)
:
Data
(
raw
)
{}
};
class
Data
32
:
public
Unit
<
U32
>
{
class
Data
64
:
public
Data
<
U64
>
{
public
:
Data
32
(
U32
raw
)
:
Unit
(
raw
)
{}
Data
64
(
U64
raw
)
:
Data
(
raw
)
{}
};
class
Data64
:
public
Unit
<
U64
>
{
class
Label
:
public
Unit
<
None
>
{
public
:
Data64
(
U64
raw
)
:
Unit
(
raw
)
{}
Label
()
{}
inline
UnitType
unitType
()
override
{
return
UnitType
::
Label
;
}
U32
size
()
override
{
return
0
;
}
};
class
Void
:
public
Unit
<
None
>
{
public
:
Void
(
U32
size
)
:
size_
(
size
)
{}
U32
size
()
override
{
return
size_
;
}
private
:
U32
size_
;
};
}
...
...
nativehook/src/main/cpp/assembler/assembler.cpp
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
nativehook/src/main/cpp/elf/elf.cpp
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
#include "elf.h"
nativehook/src/main/cpp/
assembler
/assembler.h
→
nativehook/src/main/cpp/
includes
/assembler.h
View file @
30c986ac
File moved
nativehook/src/main/cpp/includes/base.h
View file @
30c986ac
...
...
@@ -35,6 +35,14 @@ enum Arch {
unkownArch
};
enum
UnitType
{
Inst
,
Data
,
Label
,
Void
,
Unkown
};
enum
InstType
{
A32
,
thumb16
,
...
...
@@ -61,6 +69,9 @@ struct Unsigned<64> {
typedef
U64
type
;
};
class
None
{};
template
<
typename
T
>
T
AlignDown
(
T
pointer
,
typename
Unsigned
<
sizeof
(
T
)
*
BITS_OF_BYTE
>::
type
alignment
)
{
...
...
nativehook/src/main/cpp/includes/code_relocate.h
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
#ifndef SANDHOOK_NH_CODE_RELOCATE_H
#define SANDHOOK_NH_CODE_RELOCATE_H
#include "exception.h"
#include "../asm/instruction.h"
namespace
SandHook
{
namespace
Asm
{
template
<
typename
Raw
>
class
CodeRelocateCallback
{
public
:
virtual
bool
result
(
Unit
<
Raw
>*
unit
,
bool
end
)
throw
(
ErrorCodeException
)
=
0
;
};
template
<
typename
Raw
>
class
CodeRelocate
{
virtual
bool
relocate
(
ADDR
toPc
,
CodeRelocateCallback
<
Raw
>&
callback
)
throw
(
ErrorCodeException
)
=
0
;
};
}
}
#endif //SANDHOOK_NH_CODE_RELOCATE_H
nativehook/src/main/cpp/
decoder
/decoder.h
→
nativehook/src/main/cpp/
includes
/decoder.h
View file @
30c986ac
File moved
nativehook/src/main/cpp/includes/elf.h
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
#ifndef SANDHOOK_NH_ELF_H
#define SANDHOOK_NH_ELF_H
#endif //SANDHOOK_NH_ELF_H
nativehook/src/main/cpp/includes/exception.h
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
#include "exception"
#ifndef SANDHOOK_NH_EXCEPTION_H
#define SANDHOOK_NH_EXCEPTION_H
namespace
SandHook
{
namespace
Asm
{
class
ErrorCodeException
:
public
std
::
exception
{
public
:
ErrorCodeException
(
const
char
*
what_
)
:
what_
(
what_
)
{}
const
char
*
what
()
const
noexcept
override
{
return
what_
;
}
private
:
const
char
*
what_
;
};
}
}
#endif //SANDHOOK_NH_EXCEPTION_H
nativehook/src/main/cpp/relocate/code_relocate.cpp
0 → 100644
View file @
30c986ac
//
// Created by swift on 2019/5/10.
//
#include "code_relocate.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