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
6595df95
Commit
6595df95
authored
Jun 09, 2019
by
swift_gan
Committed by
swift_gan
Jun 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NativeHook]remove test code
parent
edcfd3f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
135 deletions
+0
-135
sandhook_native.cpp
nativehook/src/main/cpp/sandhook_native.cpp
+0
-135
No files found.
nativehook/src/main/cpp/sandhook_native.cpp
View file @
6595df95
...
...
@@ -3,8 +3,6 @@
//
#include <jni.h>
#include <sys/mman.h>
#include <log.h>
#include "sandhook_native.h"
#include "hook.h"
#include "elf.h"
...
...
@@ -12,139 +10,6 @@
using
namespace
SandHook
::
Hook
;
using
namespace
SandHook
::
Elf
;
int
m1
=
5
;
int
m3
=
1036
;
int
m2
=
1035
;
int
m4
=
5
;
void
(
*
dosth3Backup
)(
int
,
int
)
=
nullptr
;
void
(
*
dosth4Backup
)()
=
nullptr
;
void
(
*
dosth4Backup2
)()
=
nullptr
;
void
(
*
innerSuspendVM
)()
=
nullptr
;
static
void
(
*
heapPreForkBackup
)(
void
*
)
=
nullptr
;
static
void
myHeapPreFork
(
void
*
heap
)
{
heapPreForkBackup
(
heap
);
}
void
SuspendVMReplace
()
{
LOGE
(
"VM Suspend!"
);
innerSuspendVM
();
}
void
do2
()
{
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
}
void
do3
(
int
x
,
int
y
)
{
do2
();
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
a
+
b
+
c
;
LOGE
(
"do3 = %d"
,
y
);
}
void
do5
()
{
LOGE
(
"x = %d"
,
5
);
}
void
do4
()
{
do5
();
int
a
=
1
+
1
;
int
b
=
a
+
1
;
int
d
=
a
+
1
;
int
e
=
a
+
1
;
LOGE
(
"x = %d"
,
7
);
}
void
do4replace
()
{
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
dosth4Backup
();
}
void
do4replace2
()
{
int
a
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
dosth4Backup2
();
}
void
do3replace
(
int
x
,
int
y
)
{
int
a
=
1
+
1
;
int
b
=
1
+
1
;
int
c
=
1
+
1
;
int
d
=
1
+
1
;
dosth3Backup
(
x
,
y
);
}
void
do1
()
{
do2
();
}
void
breakCallback
(
REG
regs
[])
{
LOGE
(
"breakCallback = %d SP = %d"
,
regs
[
0
],
regs
);
}
class
Visitor
:
public
InstVisitor
{
bool
visit
(
Unit
<
Base
>
*
unit
,
void
*
pc
)
override
{
Instruction
<
Base
>*
instruction
=
reinterpret_cast
<
Instruction
<
Base
>
*>
(
unit
);
instruction
->
assembler
();
return
true
;
}
};
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_nativehook_NativeHook_test
(
JNIEnv
*
env
,
jclass
jclass1
)
{
dosth4Backup
=
reinterpret_cast
<
void
(
*
)()
>
(
InlineHook
::
instance
->
inlineHook
(
reinterpret_cast
<
void
*>
(
do4
),
reinterpret_cast
<
void
*>
(
do4replace
)));
// dosth4Backup2 = reinterpret_cast<void (*)()>(InlineHook::instance->inlineHook(
// reinterpret_cast<void *>(do4),
// reinterpret_cast<void *>(do4replace2)));
do4
();
if
(
sizeof
(
void
*
)
==
8
)
{
heapPreForkBackup
=
reinterpret_cast
<
void
(
*
)(
void
*
)
>
(
SandInlineHookSym
(
"/system/lib64/libart.so"
,
"_ZN3art2gc4Heap13PreZygoteForkEv"
,
reinterpret_cast
<
void
*>
(
myHeapPreFork
)));
innerSuspendVM
=
reinterpret_cast
<
void
(
*
)()
>
(
SandInlineHookSym
(
"/system/lib64/libart.so"
,
"_ZN3art3Dbg9SuspendVMEv"
,
reinterpret_cast
<
void
*>
(
SuspendVMReplace
)));
}
else
{
heapPreForkBackup
=
reinterpret_cast
<
void
(
*
)(
void
*
)
>
(
SandInlineHookSym
(
"/system/lib/libart.so"
,
"_ZN3art2gc4Heap13PreZygoteForkEv"
,
reinterpret_cast
<
void
*>
(
myHeapPreFork
)));
innerSuspendVM
=
reinterpret_cast
<
void
(
*
)()
>
(
SandInlineHookSym
(
"/system/lib/libart.so"
,
"_ZN3art3Dbg9SuspendVMEv"
,
reinterpret_cast
<
void
*>
(
SuspendVMReplace
)));
}
void
*
do3P
=
reinterpret_cast
<
void
*>
(
do3
);
InlineHook
::
instance
->
breakPoint
(
reinterpret_cast
<
void
*>
((
Addr
)
do3
+
16
),
breakCallback
);
LOGE
(
"ok"
);
do3
(
100
,
2
);
}
extern
"C"
EXPORT
void
*
SandGetSym
(
const
char
*
so
,
const
char
*
symb
)
{
...
...
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