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
1e554746
Commit
1e554746
authored
May 10, 2019
by
swift_gan
Committed by
swift_gan
May 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweak label
parent
84178e6e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
91 deletions
+178
-91
data.h
nativehook/src/main/cpp/asm/data.h
+40
-0
instruction.h
nativehook/src/main/cpp/asm/instruction.h
+1
-91
label.h
nativehook/src/main/cpp/asm/label.h
+66
-0
unit.h
nativehook/src/main/cpp/asm/unit.h
+71
-0
No files found.
nativehook/src/main/cpp/asm/data.h
0 → 100644
View file @
1e554746
//
// Created by swift on 2019/5/10.
//
#ifndef SANDHOOK_NH_DATA_H
#define SANDHOOK_NH_DATA_H
#include "unit.h"
namespace
SandHook
{
namespace
Asm
{
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
:
Data32
(
U32
raw
)
:
Data
(
raw
)
{}
};
class
Data64
:
public
Data
<
U64
>
{
public
:
Data64
(
U64
raw
)
:
Data
(
raw
)
{}
};
}
}
#endif //SANDHOOK_NH_DATA_H
nativehook/src/main/cpp/asm/instruction.h
View file @
1e554746
...
@@ -5,8 +5,7 @@
...
@@ -5,8 +5,7 @@
#ifndef SANDHOOK_INSTRUCTION_H
#ifndef SANDHOOK_INSTRUCTION_H
#define SANDHOOK_INSTRUCTION_H
#define SANDHOOK_INSTRUCTION_H
#include <malloc.h>
#include "unit.h"
#include "../includes/base.h"
//aarch64
//aarch64
typedef
U32
InstA64
;
typedef
U32
InstA64
;
...
@@ -36,60 +35,6 @@ if (COND) { \
...
@@ -36,60 +35,6 @@ if (COND) { \
namespace
SandHook
{
namespace
SandHook
{
namespace
Asm
{
namespace
Asm
{
template
<
typename
Raw
>
class
Unit
{
public
:
Unit
()
{
if
(
unitType
()
!=
Void
)
{
raw
=
reinterpret_cast
<
Raw
*>
(
malloc
(
size
()));
memset
(
raw
,
0
,
size
());
auto_alloc
=
true
;
}
}
Unit
<
Raw
>
(
Raw
*
raw
)
:
raw
(
raw
)
{}
Unit
<
Raw
>
(
Raw
raw
)
{
Unit
();
*
this
->
raw
=
raw
;
}
virtual
void
*
getPC
()
{
return
auto_alloc
?
nullptr
:
raw
;
}
inline
Raw
*
get
()
const
{
return
raw
;
}
inline
void
set
(
Raw
raw
)
const
{
*
this
->
raw
=
raw
;
}
inline
void
copy
(
void
*
dest
)
{
memcpy
(
dest
,
getPC
(),
size
());
}
virtual
UnitType
unitType
()
{
return
UnitType
::
Unkown
;
};
virtual
U32
size
()
{
return
sizeof
(
Raw
);
}
virtual
~
Unit
()
{
if
(
auto_alloc
)
{
free
(
raw
);
}
}
private
:
Raw
*
raw
;
bool
auto_alloc
=
false
;
};
template
<
typename
Inst
>
template
<
typename
Inst
>
class
Instruction
:
public
Unit
<
Inst
>
{
class
Instruction
:
public
Unit
<
Inst
>
{
public
:
public
:
...
@@ -130,41 +75,6 @@ namespace SandHook {
...
@@ -130,41 +75,6 @@ namespace SandHook {
bool
valid
=
true
;
bool
valid
=
true
;
};
};
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
:
Data32
(
U32
raw
)
:
Data
(
raw
)
{}
};
class
Data64
:
public
Data
<
U64
>
{
public
:
Data64
(
U64
raw
)
:
Data
(
raw
)
{}
};
class
Label
:
public
Unit
<
None
>
{
public
:
Label
()
{}
inline
UnitType
unitType
()
override
{
return
UnitType
::
Label
;
}
U32
size
()
override
{
return
0
;
}
};
class
Void
:
public
Unit
<
None
>
{
class
Void
:
public
Unit
<
None
>
{
public
:
public
:
Void
(
U32
size
)
:
size_
(
size
)
{}
Void
(
U32
size
)
:
size_
(
size
)
{}
...
...
nativehook/src/main/cpp/asm/label.h
0 → 100644
View file @
1e554746
//
// Created by swift on 2019/5/10.
//
#ifndef SANDHOOK_NH_LABEL_H
#define SANDHOOK_NH_LABEL_H
#include "unit.h"
#include <list>
namespace
SandHook
{
namespace
Asm
{
virtual
class
LabelBinder
{
public
:
virtual
void
bindLabel
(
void
*
pc
)
=
0
;
};
class
Label
:
public
Unit
<
None
>
{
public
:
Label
()
{}
Label
(
void
*
pc
)
:
pc
(
pc
)
{}
inline
UnitType
unitType
()
override
{
return
UnitType
::
Label
;
}
inline
U32
size
()
override
{
return
0
;
}
inline
void
setPC
(
void
*
pc
)
{
this
->
pc
=
pc
;
}
inline
void
*
getPC
()
override
{
return
pc
;
}
inline
void
addBinder
(
LabelBinder
*
binder
)
{
binders
.
push_back
(
binder
);
}
inline
void
removeBinder
(
LabelBinder
*
binder
)
{
binders
.
push_back
(
binder
);
}
inline
void
bindLabel
(
void
*
pc
)
{
setPC
(
pc
);
std
::
list
<
LabelBinder
*>::
iterator
binder
;
for
(
binder
=
binders
.
begin
();
binder
!=
binders
.
end
();
++
binder
)
{
(
*
binder
)
->
bindLabel
(
pc
);
}
}
private
:
void
*
pc
;
std
::
list
<
LabelBinder
*>
binders
=
std
::
list
();
};
}
}
#endif //SANDHOOK_NH_LABEL_H
nativehook/src/main/cpp/asm/unit.h
0 → 100644
View file @
1e554746
//
// Created by swift on 2019/5/10.
//
#ifndef SANDHOOK_NH_UNIT_H
#define SANDHOOK_NH_UNIT_H
#include <malloc.h>
#include "../includes/base.h"
namespace
SandHook
{
namespace
Asm
{
template
<
typename
Raw
>
class
Unit
{
public
:
Unit
()
{
if
(
unitType
()
!=
Void
)
{
raw
=
reinterpret_cast
<
Raw
*>
(
malloc
(
size
()));
memset
(
raw
,
0
,
size
());
auto_alloc
=
true
;
}
}
Unit
<
Raw
>
(
Raw
*
raw
)
:
raw
(
raw
)
{}
Unit
<
Raw
>
(
Raw
raw
)
{
Unit
();
*
this
->
raw
=
raw
;
}
virtual
void
*
getPC
()
{
return
auto_alloc
?
nullptr
:
raw
;
}
inline
Raw
*
get
()
const
{
return
raw
;
}
inline
void
set
(
Raw
raw
)
const
{
*
this
->
raw
=
raw
;
}
inline
void
copy
(
void
*
dest
)
{
memcpy
(
dest
,
getPC
(),
size
());
}
virtual
UnitType
unitType
()
{
return
UnitType
::
Unkown
;
};
virtual
U32
size
()
{
return
sizeof
(
Raw
);
}
virtual
~
Unit
()
{
if
(
auto_alloc
)
{
free
(
raw
);
}
}
private
:
Raw
*
raw
;
bool
auto_alloc
=
false
;
};
}
}
#endif //SANDHOOK_NH_UNIT_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