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
48916f5a
Commit
48916f5a
authored
Mar 04, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless code
parent
e084449d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
90 deletions
+0
-90
sandhook.cpp
hooklib/src/main/cpp/sandhook.cpp
+0
-60
SandHook.java
hooklib/src/main/java/com/swift/sandhook/SandHook.java
+0
-30
No files found.
hooklib/src/main/cpp/sandhook.cpp
View file @
48916f5a
...
@@ -58,53 +58,6 @@ void ensureMethodCached(art::mirror::ArtMethod *hookMethod, art::mirror::ArtMeth
...
@@ -58,53 +58,6 @@ void ensureMethodCached(art::mirror::ArtMethod *hookMethod, art::mirror::ArtMeth
}
}
}
}
void
ensureBackupMethod
(
art
::
mirror
::
ArtMethod
*
origin
,
art
::
mirror
::
ArtMethod
*
backup
)
{
if
(
origin
->
getDeclaringClassPtr
()
!=
backup
->
getDeclaringClassPtr
())
{
LOGW
(
"backup method is out to date due to Moving GC!"
);
SandHook
::
HookTrampoline
*
trampoline
=
trampolineManager
.
getHookTrampoline
(
origin
);
if
(
trampoline
==
nullptr
)
return
;
SandHook
::
StopTheWorld
stopTheWorld
;
if
(
trampoline
->
inlineJump
!=
nullptr
)
{
origin
->
backup
(
backup
);
backup
->
setQuickCodeEntry
(
trampoline
->
callOrigin
->
getCode
());
if
(
SDK_INT
>=
ANDROID_N
)
{
backup
->
disableCompilable
();
}
if
(
SDK_INT
>=
ANDROID_O
)
{
backup
->
disableInterpreterForO
();
}
if
(
!
backup
->
isStatic
())
{
backup
->
setPrivate
();
}
backup
->
tryDisableInline
();
}
else
if
(
trampoline
->
replacement
!=
nullptr
)
{
origin
->
backup
(
backup
);
if
(
trampoline
->
callOrigin
!=
nullptr
)
{
backup
->
setQuickCodeEntry
(
trampoline
->
callOrigin
->
getCode
());
}
else
{
backup
->
setQuickCodeEntry
(
trampoline
->
originCode
);
}
if
(
SDK_INT
>=
ANDROID_N
)
{
backup
->
disableCompilable
();
}
if
(
SDK_INT
>=
ANDROID_O
)
{
backup
->
disableInterpreterForO
();
}
if
(
!
backup
->
isStatic
())
{
backup
->
setPrivate
();
}
backup
->
tryDisableInline
();
}
else
{
return
;
}
backup
->
flushCache
();
}
}
bool
doHookWithReplacement
(
JNIEnv
*
env
,
bool
doHookWithReplacement
(
JNIEnv
*
env
,
art
::
mirror
::
ArtMethod
*
originMethod
,
art
::
mirror
::
ArtMethod
*
originMethod
,
art
::
mirror
::
ArtMethod
*
hookMethod
,
art
::
mirror
::
ArtMethod
*
hookMethod
,
...
@@ -264,19 +217,6 @@ Java_com_swift_sandhook_SandHook_ensureMethodCached(JNIEnv *env, jclass type, jo
...
@@ -264,19 +217,6 @@ Java_com_swift_sandhook_SandHook_ensureMethodCached(JNIEnv *env, jclass type, jo
ensureMethodCached
(
hookeMethod
,
backupMethod
);
ensureMethodCached
(
hookeMethod
,
backupMethod
);
}
}
extern
"C"
JNIEXPORT
void
JNICALL
Java_com_swift_sandhook_SandHook_ensureBackupMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
originMethod
,
jobject
backupMethod
)
{
if
(
backupMethod
==
NULL
||
originMethod
==
NULL
)
return
;
art
::
mirror
::
ArtMethod
*
origin
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
FromReflectedMethod
(
originMethod
));
art
::
mirror
::
ArtMethod
*
backup
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
FromReflectedMethod
(
backupMethod
));
ensureBackupMethod
(
origin
,
backup
);
}
extern
"C"
extern
"C"
JNIEXPORT
jboolean
JNICALL
JNIEXPORT
jboolean
JNICALL
Java_com_swift_sandhook_SandHook_compileMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
member
)
{
Java_com_swift_sandhook_SandHook_compileMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
member
)
{
...
...
hooklib/src/main/java/com/swift/sandhook/SandHook.java
View file @
48916f5a
...
@@ -172,37 +172,9 @@ public class SandHook {
...
@@ -172,37 +172,9 @@ public class SandHook {
}
}
}
}
public
static
Object
ensureBackupAndCallOriginMethod
(
Member
originMethod
,
Method
backupMethod
,
Object
thiz
,
Object
[]
args
)
throws
Throwable
{
backupMethod
.
setAccessible
(
true
);
if
(
Modifier
.
isStatic
(
originMethod
.
getModifiers
()))
{
ensureBackupMethod
(
originMethod
,
backupMethod
);
return
backupMethod
.
invoke
(
null
,
args
);
}
else
{
ensureBackupMethod
(
originMethod
,
backupMethod
);
return
backupMethod
.
invoke
(
thiz
,
args
);
}
}
public
static
void
ensureBackupMethod
(
Method
backupMethod
)
{
public
static
void
ensureBackupMethod
(
Method
backupMethod
)
{
if
(
backupMethod
==
null
)
return
;
HookWrapper
.
HookEntity
hookEntity
=
globalBackupMap
.
get
(
backupMethod
);
if
(
hookEntity
==
null
)
return
;
ensureBackupMethod
(
hookEntity
.
target
,
backupMethod
);
}
}
public
static
void
ensureBackupMethodByOrigin
(
Member
originMethod
)
{
if
(
originMethod
==
null
)
return
;
HookWrapper
.
HookEntity
hookEntity
=
globalHookEntityMap
.
get
(
originMethod
);
if
(
hookEntity
==
null
||
hookEntity
.
backup
==
null
)
return
;
ensureBackupMethod
(
originMethod
,
hookEntity
.
backup
);
}
public
static
void
resolveStaticMethod
(
Member
method
)
{
public
static
void
resolveStaticMethod
(
Member
method
)
{
//ignore result, just call to trigger resolve
//ignore result, just call to trigger resolve
if
(
method
==
null
)
if
(
method
==
null
)
...
@@ -330,8 +302,6 @@ public class SandHook {
...
@@ -330,8 +302,6 @@ public class SandHook {
public
static
native
void
ensureMethodCached
(
Method
hook
,
Method
backup
);
public
static
native
void
ensureMethodCached
(
Method
hook
,
Method
backup
);
public
static
native
void
ensureBackupMethod
(
Member
originMethod
,
Method
backupMethod
);
public
static
native
boolean
compileMethod
(
Member
member
);
public
static
native
boolean
compileMethod
(
Member
member
);
public
static
native
boolean
canGetObject
();
public
static
native
boolean
canGetObject
();
...
...
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