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
69b9b89f
Commit
69b9b89f
authored
Mar 25, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
62b42c64
1e683c1c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
13 deletions
+24
-13
SandHook.java
hooklib/src/main/java/com/swift/sandhook/SandHook.java
+1
-1
HookBlackList.java
...main/java/com/swift/sandhook/blacklist/HookBlackList.java
+18
-8
HookWrapper.java
...src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
+4
-3
HookStubManager.java
...swift/sandhook/xposedcompat/hookstub/HookStubManager.java
+1
-1
No files found.
hooklib/src/main/java/com/swift/sandhook/SandHook.java
View file @
69b9b89f
...
...
@@ -149,7 +149,7 @@ public class SandHook {
}
public
static
Object
callOriginMethod
(
Member
originMethod
,
Method
backupMethod
,
Object
thiz
,
Object
[]
args
)
throws
Throwable
{
return
callOriginMethod
(
fals
e
,
originMethod
,
backupMethod
,
thiz
,
args
);
return
callOriginMethod
(
tru
e
,
originMethod
,
backupMethod
,
thiz
,
args
);
}
public
static
Object
callOriginMethod
(
boolean
backupIsStub
,
Member
originMethod
,
Method
backupMethod
,
Object
thiz
,
Object
[]
args
)
throws
Throwable
{
...
...
hooklib/src/main/java/com/swift/sandhook/blacklist/HookBlackList.java
View file @
69b9b89f
package
com
.
swift
.
sandhook
.
blacklist
;
import
java.lang.reflect.Member
;
import
java.lang.reflect.Method
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
HookBlackList
{
static
Set
<
String
>
blackList
=
new
HashSet
<>();
public
static
Set
<
String
>
methodBlackList
=
new
HashSet
<>();
public
static
Set
<
Class
>
classBlackList
=
new
HashSet
<>();
static
{
blackList
.
add
(
"java.lang.reflect.Member.getDeclaringClass"
);
blackList
.
add
(
"java.lang.reflect.Method.invoke"
);
blackList
.
add
(
"java.util.Map.get"
);
blackList
.
add
(
"java.lang.reflect.AccessibleObject.setAccessible"
);
blackList
.
add
(
"java.lang.reflect.Member.getModifiers"
);
blackList
.
add
(
"java.lang.reflect.InvocationTargetException.getCause"
);
methodBlackList
.
add
(
"java.lang.reflect.Member.getDeclaringClass"
);
methodBlackList
.
add
(
"java.lang.reflect.Method.invoke"
);
methodBlackList
.
add
(
"java.util.Map.get"
);
methodBlackList
.
add
(
"java.util.concurrent.ConcurrentHashMap.get"
);
methodBlackList
.
add
(
"java.lang.reflect.AccessibleObject.setAccessible"
);
methodBlackList
.
add
(
"java.lang.reflect.Member.getModifiers"
);
methodBlackList
.
add
(
"java.lang.reflect.InvocationTargetException.getCause"
);
methodBlackList
.
add
(
"java.lang.reflect.Method.hashCode"
);
methodBlackList
.
add
(
"java.lang.reflect.Class.getName"
);
methodBlackList
.
add
(
"java.lang.String.hashCode"
);
methodBlackList
.
add
(
"java.lang.String.length"
);
}
public
final
static
boolean
canNotHook
(
Member
origin
)
{
if
(
classBlackList
.
contains
(
origin
.
getDeclaringClass
()))
return
true
;
String
name
=
origin
.
getDeclaringClass
().
getName
()
+
"."
+
origin
.
getName
();
return
b
lackList
.
contains
(
name
);
return
methodB
lackList
.
contains
(
name
);
}
}
hooklib/src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
View file @
69b9b89f
...
...
@@ -69,14 +69,15 @@ public class HookWrapper {
for
(
HookEntity
hookEntity:
hookEntityMap
.
values
())
{
if
(
TextUtils
.
equals
(
hookEntity
.
isCtor
()
?
"<init>"
:
hookEntity
.
target
.
getName
(),
hookMethodBackup
.
value
())
&&
samePars
(
classLoader
,
field
,
hookEntity
.
pars
))
{
field
.
setAccessible
(
true
);
if
(
hookEntity
.
backup
==
null
)
if
(
hookEntity
.
backup
==
null
)
{
hookEntity
.
backup
=
BackupMethodStubs
.
getStubMethod
();
hookEntity
.
hookIsStub
=
true
;
hookEntity
.
resolveDexCache
=
false
;
}
if
(
hookEntity
.
backup
==
null
)
continue
;
try
{
field
.
set
(
null
,
hookEntity
.
backup
);
hookEntity
.
hookIsStub
=
true
;
hookEntity
.
resolveDexCache
=
false
;
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java
View file @
69b9b89f
...
...
@@ -400,7 +400,7 @@ public class HookStubManager {
}
}
public
static
long
callOrigin
(
HookMethodEntity
entity
,
Member
origin
,
Object
thiz
,
Object
[]
args
)
throws
Throwable
{
public
final
static
long
callOrigin
(
HookMethodEntity
entity
,
Member
origin
,
Object
thiz
,
Object
[]
args
)
throws
Throwable
{
Object
res
=
SandHook
.
callOriginMethod
(
origin
,
thiz
,
args
);
return
entity
.
getResultAddress
(
res
);
}
...
...
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