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
3235b9da
Commit
3235b9da
authored
Feb 21, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add compile method
parent
6637f8ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
10 deletions
+28
-10
sandhook.cpp
hooklib/src/main/cpp/sandhook.cpp
+16
-5
SandHook.java
hooklib/src/main/java/com/swift/sandhook/SandHook.java
+1
-1
HookStubManager.java
...swift/sandhook/xposedcompat/hookstub/HookStubManager.java
+11
-4
No files found.
hooklib/src/main/cpp/sandhook.cpp
View file @
3235b9da
...
...
@@ -282,18 +282,29 @@ Java_com_swift_sandhook_SandHook_ensureMethodDeclaringClass(JNIEnv *env, jclass
}
extern
"C"
JNIEXPORT
void
JNICALL
JNIEXPORT
jboolean
JNICALL
Java_com_swift_sandhook_SandHook_compileMethod
(
JNIEnv
*
env
,
jclass
type
,
jobject
member
)
{
if
(
member
==
NULL
)
return
;
return
JNI_FALSE
;
art
::
mirror
::
ArtMethod
*
method
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
FromReflectedMethod
(
member
));
if
(
method
!=
nullptr
&&
!
method
->
isCompiled
())
{
if
(
method
==
nullptr
)
return
JNI_FALSE
;
if
(
!
method
->
isCompiled
())
{
SandHook
::
StopTheWorld
stopTheWorld
;
if
(
!
method
->
compile
(
env
)
&&
SDK_INT
>=
ANDROID_N
)
{
method
->
disableCompilable
();
if
(
!
method
->
compile
(
env
))
{
if
(
SDK_INT
>=
ANDROID_N
)
{
method
->
disableCompilable
();
method
->
flushCache
();
}
return
JNI_FALSE
;
}
else
{
return
JNI_TRUE
;
}
}
else
{
return
JNI_TRUE
;
}
}
...
...
hooklib/src/main/java/com/swift/sandhook/SandHook.java
View file @
3235b9da
...
...
@@ -304,7 +304,7 @@ public class SandHook {
public
static
native
void
ensureMethodDeclaringClass
(
Member
originMethod
,
Method
backupMethod
);
public
static
native
void
compileMethod
(
Member
member
);
public
static
native
boolean
compileMethod
(
Member
member
);
public
static
native
boolean
canGetObject
();
public
static
native
Object
getObjectNative
(
long
thread
,
long
address
);
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java
View file @
3235b9da
package
com
.
swift
.
sandhook
.
xposedcompat
.
hookstub
;
import
com.swift.sandhook.SandHook
;
import
com.swift.sandhook.SandHookMethodResolver
;
import
com.swift.sandhook.utils.ParamWrapper
;
import
java.lang.reflect.Constructor
;
...
...
@@ -93,8 +94,11 @@ public class HookStubManager {
int
id
=
getMethodId
(
stubMethodInfo
.
args
,
stubMethodInfo
.
index
);
originMethods
[
id
]
=
origin
;
hookMethodEntities
[
id
]
=
entity
;
tryCompileCallOriginMethod
(
stubMethodInfo
.
args
,
stubMethodInfo
.
index
);
return
entity
;
if
(
tryCompileAndResolveCallOriginMethod
(
entity
.
backup
,
stubMethodInfo
.
args
,
stubMethodInfo
.
index
))
{
return
entity
;
}
else
{
return
null
;
}
}
}
...
...
@@ -174,10 +178,13 @@ public class HookStubManager {
}
}
public
static
void
tryCompileCallOriginMethod
(
int
args
,
int
index
)
{
public
static
boolean
tryCompileAndResolveCallOriginMethod
(
Method
backupMethod
,
int
args
,
int
index
)
{
Method
method
=
getCallOriginMethod
(
args
,
index
);
if
(
method
!=
null
)
{
SandHook
.
compileMethod
(
method
);
SandHookMethodResolver
.
resolveMethod
(
method
,
backupMethod
);
return
SandHook
.
compileMethod
(
method
);
}
else
{
return
false
;
}
}
...
...
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