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
43a453e8
Commit
43a453e8
authored
Feb 18, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add call origin check switcher
parent
3e4cf9aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
HookerDexMaker.java
...swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
+35
-1
No files found.
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/methodgen/HookerDexMaker.java
View file @
43a453e8
...
...
@@ -14,6 +14,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.XposedCompat
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
import
java.io.File
;
...
...
@@ -204,7 +205,11 @@ public class HookerDexMaker {
mDexMaker
.
declare
(
mHookerTypeId
,
className
+
".generated"
,
Modifier
.
PUBLIC
,
TypeId
.
OBJECT
);
generateFields
();
generateSetupMethod
();
generateBackupMethod
();
if
(
XposedCompat
.
retryWhenCallOriginError
)
{
generateBackupAndCallOriginCheckMethod
();
}
else
{
generateBackupMethod
();
}
generateHookMethod
();
generateCallBackupMethod
();
...
...
@@ -273,6 +278,35 @@ public class HookerDexMaker {
}
private
void
generateBackupMethod
()
{
mBackupMethodId
=
mHookerTypeId
.
getMethod
(
mReturnTypeId
,
METHOD_NAME_BACKUP
,
mParameterTypeIds
);
Code
code
=
mDexMaker
.
declare
(
mBackupMethodId
,
Modifier
.
PUBLIC
|
Modifier
.
STATIC
);
Local
<
Member
>
method
=
code
.
newLocal
(
memberTypeId
);
Map
<
TypeId
,
Local
>
resultLocals
=
createResultLocals
(
code
);
MethodId
<?,
?>
errLogMethod
=
TypeId
.
get
(
DexLog
.
class
).
getMethod
(
TypeId
.
get
(
Void
.
TYPE
),
"printCallOriginError"
,
TypeId
.
get
(
Member
.
class
));
//very very important!!!!!!!!!!!
//add a try cache block avoid inline
Label
tryCatchBlock
=
new
Label
();
code
.
addCatchClause
(
throwableTypeId
,
tryCatchBlock
);
code
.
sget
(
mMethodFieldId
,
method
);
code
.
invokeStatic
(
errLogMethod
,
null
,
method
);
// start of try
code
.
mark
(
tryCatchBlock
);
// do nothing
if
(
mReturnTypeId
.
equals
(
TypeId
.
VOID
))
{
code
.
returnVoid
();
}
else
{
// we have limited the returnType to primitives or Object, so this should be safe
code
.
returnValue
(
resultLocals
.
get
(
mReturnTypeId
));
}
}
private
void
generateBackupAndCallOriginCheckMethod
()
{
mBackupMethodId
=
mHookerTypeId
.
getMethod
(
mReturnTypeId
,
METHOD_NAME_BACKUP
,
mParameterTypeIds
);
mSandHookCallOriginMethodId
=
TypeId
.
get
(
ErrorCatch
.
class
).
getMethod
(
TypeId
.
get
(
Object
.
class
),
"callOriginError"
,
memberTypeId
,
methodTypeId
,
TypeId
.
get
(
Object
.
class
),
TypeId
.
get
(
Object
[].
class
));
MethodId
<?,
?>
errLogMethod
=
TypeId
.
get
(
DexLog
.
class
).
getMethod
(
TypeId
.
get
(
Void
.
TYPE
),
"printCallOriginError"
,
TypeId
.
get
(
Member
.
class
));
...
...
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