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
0aab93f2
Commit
0aab93f2
authored
Feb 22, 2019
by
swift_gan
Committed by
swift_gan
Feb 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logic of resolve dex cache
parent
2beba56b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
3 deletions
+15
-3
SandHook.java
hooklib/src/main/java/com/swift/sandhook/SandHook.java
+4
-2
HookWrapper.java
...src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
+8
-0
DynamicBridge.java
.../swift/sandhook/xposedcompat/methodgen/DynamicBridge.java
+1
-1
HookerDexMaker.java
...swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
+2
-0
No files found.
hooklib/src/main/java/com/swift/sandhook/SandHook.java
View file @
0aab93f2
...
@@ -88,8 +88,8 @@ public class SandHook {
...
@@ -88,8 +88,8 @@ public class SandHook {
throw
new
HookErrorException
(
"method <"
+
entity
.
target
.
getName
()
+
"> has been hooked!"
);
throw
new
HookErrorException
(
"method <"
+
entity
.
target
.
getName
()
+
"> has been hooked!"
);
resolveStaticMethod
(
target
);
resolveStaticMethod
(
target
);
if
(
backup
!=
null
)
{
resolveStaticMethod
(
backup
);
resolveStaticMethod
(
backup
);
if
(
backup
!=
null
&&
entity
.
resolveDexCache
)
{
SandHookMethodResolver
.
resolveMethod
(
hook
,
backup
);
SandHookMethodResolver
.
resolveMethod
(
hook
,
backup
);
}
}
if
(
target
instanceof
Method
)
{
if
(
target
instanceof
Method
)
{
...
@@ -179,6 +179,8 @@ public class SandHook {
...
@@ -179,6 +179,8 @@ public class SandHook {
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
)
return
;
try
{
try
{
if
(
method
instanceof
Method
&&
Modifier
.
isStatic
(
method
.
getModifiers
()))
{
if
(
method
instanceof
Method
&&
Modifier
.
isStatic
(
method
.
getModifiers
()))
{
((
Method
)
method
).
setAccessible
(
true
);
((
Method
)
method
).
setAccessible
(
true
);
...
...
hooklib/src/main/java/com/swift/sandhook/wrapper/HookWrapper.java
View file @
0aab93f2
...
@@ -389,6 +389,7 @@ public class HookWrapper {
...
@@ -389,6 +389,7 @@ public class HookWrapper {
public
Method
backup
;
public
Method
backup
;
public
boolean
hookIsStub
=
false
;
public
boolean
hookIsStub
=
false
;
public
boolean
resolveDexCache
=
true
;
public
Class
[]
pars
;
public
Class
[]
pars
;
public
int
hookMode
;
public
int
hookMode
;
...
@@ -403,6 +404,13 @@ public class HookWrapper {
...
@@ -403,6 +404,13 @@ public class HookWrapper {
this
.
backup
=
backup
;
this
.
backup
=
backup
;
}
}
public
HookEntity
(
Member
target
,
Method
hook
,
Method
backup
,
boolean
resolveDexCache
)
{
this
.
target
=
target
;
this
.
hook
=
hook
;
this
.
backup
=
backup
;
this
.
resolveDexCache
=
resolveDexCache
;
}
public
boolean
isCtor
()
{
public
boolean
isCtor
()
{
return
target
instanceof
Constructor
;
return
target
instanceof
Constructor
;
}
}
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/methodgen/DynamicBridge.java
View file @
0aab93f2
...
@@ -63,7 +63,7 @@ public final class DynamicBridge {
...
@@ -63,7 +63,7 @@ public final class DynamicBridge {
stub
=
HookStubManager
.
getHookMethodEntity
(
hookMethod
);
stub
=
HookStubManager
.
getHookMethodEntity
(
hookMethod
);
}
}
if
(
stub
!=
null
)
{
if
(
stub
!=
null
)
{
SandHook
.
hook
(
new
HookWrapper
.
HookEntity
(
hookMethod
,
stub
.
hook
,
stub
.
backup
));
SandHook
.
hook
(
new
HookWrapper
.
HookEntity
(
hookMethod
,
stub
.
hook
,
stub
.
backup
,
false
));
entityMap
.
put
(
hookMethod
,
stub
);
entityMap
.
put
(
hookMethod
,
stub
);
}
else
{
}
else
{
dexMaker
.
start
(
hookMethod
,
additionalHookInfo
,
dexMaker
.
start
(
hookMethod
,
additionalHookInfo
,
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
View file @
0aab93f2
...
@@ -13,6 +13,7 @@ import com.android.dx.Local;
...
@@ -13,6 +13,7 @@ import com.android.dx.Local;
import
com.android.dx.MethodId
;
import
com.android.dx.MethodId
;
import
com.android.dx.TypeId
;
import
com.android.dx.TypeId
;
import
com.swift.sandhook.SandHook
;
import
com.swift.sandhook.SandHook
;
import
com.swift.sandhook.SandHookMethodResolver
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.xposedcompat.XposedCompat
;
import
com.swift.sandhook.xposedcompat.XposedCompat
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
...
@@ -229,6 +230,7 @@ public class HookerDexMaker {
...
@@ -229,6 +230,7 @@ public class HookerDexMaker {
mBackupMethod
=
mHookClass
.
getMethod
(
METHOD_NAME_BACKUP
,
mActualParameterTypes
);
mBackupMethod
=
mHookClass
.
getMethod
(
METHOD_NAME_BACKUP
,
mActualParameterTypes
);
mCallBackupMethod
=
mHookClass
.
getMethod
(
METHOD_NAME_CALL_BACKUP
,
mActualParameterTypes
);
mCallBackupMethod
=
mHookClass
.
getMethod
(
METHOD_NAME_CALL_BACKUP
,
mActualParameterTypes
);
SandHook
.
resolveStaticMethod
(
mCallBackupMethod
);
SandHook
.
resolveStaticMethod
(
mCallBackupMethod
);
SandHookMethodResolver
.
resolveMethod
(
mCallBackupMethod
,
mBackupMethod
);
SandHook
.
compileMethod
(
mCallBackupMethod
);
SandHook
.
compileMethod
(
mCallBackupMethod
);
mHookClass
.
getMethod
(
METHOD_NAME_SETUP
,
Member
.
class
,
Method
.
class
,
XposedBridge
.
AdditionalHookInfo
.
class
).
invoke
(
null
,
mMember
,
mBackupMethod
,
mHookInfo
);
mHookClass
.
getMethod
(
METHOD_NAME_SETUP
,
Member
.
class
,
Method
.
class
,
XposedBridge
.
AdditionalHookInfo
.
class
).
invoke
(
null
,
mMember
,
mBackupMethod
,
mHookInfo
);
return
new
HookWrapper
.
HookEntity
(
mMember
,
mHookMethod
,
mBackupMethod
);
return
new
HookWrapper
.
HookEntity
(
mMember
,
mHookMethod
,
mBackupMethod
);
...
...
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