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
68be7414
Commit
68be7414
authored
Feb 17, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error sandhooker class desc & add hook in log
parent
912f76cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
HookerDexMaker.java
...swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
+9
-2
DexLog.java
...in/java/com/swift/sandhook/xposedcompat/utils/DexLog.java
+8
-5
No files found.
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
View file @
68be7414
...
...
@@ -13,6 +13,7 @@ import com.android.dx.MethodId;
import
com.android.dx.TypeId
;
import
com.swift.sandhook.SandHook
;
import
com.swift.sandhook.wrapper.HookWrapper
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
import
java.io.File
;
import
java.lang.reflect.Constructor
;
...
...
@@ -36,6 +37,7 @@ public class HookerDexMaker {
public
static
final
String
METHOD_NAME_HOOK
=
"hook"
;
public
static
final
String
METHOD_NAME_CALL_BACKUP
=
"callBackup"
;
public
static
final
String
METHOD_NAME_SETUP
=
"setup"
;
public
static
final
String
METHOD_NAME_LOG
=
"printMethodHookIn"
;
public
static
final
TypeId
<
Object
[]>
objArrayTypeId
=
TypeId
.
get
(
Object
[].
class
);
private
static
final
String
CLASS_DESC_PREFIX
=
"L"
;
private
static
final
String
CLASS_NAME_PREFIX
=
"SandHooker"
;
...
...
@@ -80,6 +82,7 @@ public class HookerDexMaker {
private
MethodId
<?,
?>
mBackupMethodId
;
private
MethodId
<?,
?>
mCallBackupMethodId
;
private
MethodId
<?,
?>
mHookMethodId
;
private
MethodId
<?,
?>
mPrintLogMethodId
;
private
TypeId
<?>
mHookerTypeId
;
private
TypeId
<?>[]
mParameterTypeIds
;
...
...
@@ -221,7 +224,7 @@ public class HookerDexMaker {
}
private
String
getClassName
(
Member
originMethod
)
{
return
CLASS_NAME_PREFIX
+
"_"
+
originMethod
.
getName
()
+
"_"
+
MD5
(
originMethod
.
toString
());
return
CLASS_NAME_PREFIX
+
"_"
+
MD5
(
originMethod
.
toString
());
}
public
Method
getHookMethod
()
{
...
...
@@ -300,6 +303,7 @@ public class HookerDexMaker {
private
void
generateHookMethod
()
{
mHookMethodId
=
mHookerTypeId
.
getMethod
(
mReturnTypeId
,
METHOD_NAME_HOOK
,
mParameterTypeIds
);
mPrintLogMethodId
=
TypeId
.
get
(
DexLog
.
class
).
getMethod
(
TypeId
.
get
(
Void
.
TYPE
),
METHOD_NAME_LOG
,
TypeId
.
get
(
Member
.
class
));
Code
code
=
mDexMaker
.
declare
(
mHookMethodId
,
Modifier
.
PUBLIC
|
Modifier
.
STATIC
);
// code starts
...
...
@@ -356,6 +360,10 @@ public class HookerDexMaker {
code
.
loadConstant
(
snapshotLen
,
0
);
code
.
loadConstant
(
nullObj
,
null
);
code
.
sget
(
mMethodFieldId
,
method
);
//print log
code
.
invokeStatic
(
mPrintLogMethodId
,
null
,
method
);
// check XposedBridge.disableHooks flag
FieldId
<
XposedBridge
,
Boolean
>
disableHooksField
=
...
...
@@ -400,7 +408,6 @@ public class HookerDexMaker {
// create param
code
.
newInstance
(
param
,
paramTypeId
.
getConstructor
());
// set method, thisObject, args
code
.
sget
(
mMethodFieldId
,
method
);
code
.
iput
(
paramTypeId
.
getField
(
memberTypeId
,
PARAMS_FIELD_NAME_METHOD
),
param
,
method
);
code
.
iput
(
paramTypeId
.
getField
(
TypeId
.
OBJECT
,
PARAMS_FIELD_NAME_THIS_OBJECT
),
param
,
thisObject
);
code
.
iput
(
paramTypeId
.
getField
(
objArrayTypeId
,
PARAMS_FIELD_NAME_ARGS
),
param
,
args
);
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/utils/DexLog.java
View file @
68be7414
...
...
@@ -2,7 +2,7 @@ package com.swift.sandhook.xposedcompat.utils;
import
android.util.Log
;
import
com.swift.sandhook.xposedcompat.BuildConfig
;
import
java.lang.reflect.Member
;
public
class
DexLog
{
...
...
@@ -18,10 +18,13 @@ public class DexLog {
}
public
static
int
d
(
String
s
)
{
if
(
BuildConfig
.
DEBUG
)
{
return
Log
.
d
(
TAG
,
s
);
}
return
0
;
return
Log
.
d
(
TAG
,
s
);
}
public
static
void
printMethodHookIn
(
Member
member
)
{
if
(
member
==
null
)
return
;
Log
.
d
(
"SandHook-Xposed"
,
"method <"
+
member
.
toString
()
+
"> hook in"
);
}
public
static
int
w
(
String
s
)
{
...
...
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