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
8aa1f24a
Commit
8aa1f24a
authored
Mar 21, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix method stub on 64bit
parent
6e652fbf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
248 additions
and
125 deletions
+248
-125
genhookstubs.py
xposedcompat/genhookstubs.py
+20
-10
HookStubManager.java
...swift/sandhook/xposedcompat/hookstub/HookStubManager.java
+10
-4
MethodHookerStubs64.java
...t/sandhook/xposedcompat/hookstub/MethodHookerStubs64.java
+211
-109
XposedBridge.java
...at/src/main/java/de/robv/android/xposed/XposedBridge.java
+7
-2
No files found.
xposedcompat/genhookstubs.py
View file @
8aa1f24a
...
...
@@ -60,7 +60,8 @@ TEMP_STUB_INFO = """
"""
STUB_SIZES
=
[
10
,
20
,
30
,
30
,
30
,
30
,
30
,
20
,
10
,
10
,
5
,
5
,
3
]
STUB_SIZES_32
=
[
10
,
20
,
30
,
30
,
30
,
30
,
30
,
20
,
10
,
10
,
5
,
5
,
3
]
STUB_SIZES_64
=
[
10
,
20
,
30
,
30
,
30
,
30
,
50
,
50
]
HAS_BACKUP
=
False
...
...
@@ -126,20 +127,29 @@ def genCallOriginClass(is64Bit, args, index):
method
=
TEMP_STUB_CALL_ORIGIN_CLASS
%
(
getCallOriginClassName
(
args
,
index
),
getMethodBackupName
(
index
),
genArgsListForCallOriginMethod
(
is64Bit
,
args
))
return
method
def
genStubInfo
():
def
genStubInfo
32
():
hasStub
=
"true"
if
HAS_BACKUP
else
"false"
stubSizes
=
""
for
args
in
range
(
len
(
STUB_SIZES
)):
for
args
in
range
(
len
(
STUB_SIZES
_32
)):
if
(
args
!=
0
):
stubSizes
+=
", "
stubSizes
+=
str
(
STUB_SIZES
[
args
])
stubSizes
+=
str
(
STUB_SIZES
_32
[
args
])
return
TEMP_STUB_INFO
%
(
hasStub
,
stubSizes
)
def
genStubInfo64
():
hasStub
=
"true"
if
HAS_BACKUP
else
"false"
stubSizes
=
""
for
args
in
range
(
len
(
STUB_SIZES_64
)):
if
(
args
!=
0
):
stubSizes
+=
", "
stubSizes
+=
str
(
STUB_SIZES_64
[
args
])
return
TEMP_STUB_INFO
%
(
hasStub
,
stubSizes
)
def
gen32Stub
(
packageDir
):
class_content
=
genStubInfo
()
class_content
=
genStubInfo
32
()
class_name
=
STUB_FILE_NAME
+
"32"
for
args
in
range
(
len
(
STUB_SIZES
)):
for
index
in
range
(
STUB_SIZES
[
args
]):
for
args
in
range
(
len
(
STUB_SIZES
_32
)):
for
index
in
range
(
STUB_SIZES
_32
[
args
]):
class_content
+=
"""
\n\n\t
//stub of arg size
%
d, index
%
d"""
%
(
args
,
index
)
class_content
+=
genHookMethod
(
False
,
args
,
index
)
if
HAS_BACKUP
:
...
...
@@ -155,10 +165,10 @@ def gen32Stub(packageDir):
def
gen64Stub
(
packageDir
):
class_content
=
genStubInfo
()
class_content
=
genStubInfo
64
()
class_name
=
STUB_FILE_NAME
+
"64"
for
args
in
range
(
len
(
STUB_SIZES
)):
for
index
in
range
(
STUB_SIZES
[
args
]):
for
args
in
range
(
len
(
STUB_SIZES
_64
)):
for
index
in
range
(
STUB_SIZES
_64
[
args
]):
class_content
+=
"""
\n\n\t
//stub of arg size
%
d, index
%
d"""
%
(
args
,
index
)
class_content
+=
genHookMethod
(
True
,
args
,
index
)
if
HAS_BACKUP
:
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/HookStubManager.java
View file @
8aa1f24a
...
...
@@ -24,12 +24,15 @@ import static de.robv.android.xposed.XposedBridge.sHookedMethodCallbacks;
public
class
HookStubManager
{
public
static
volatile
boolean
is64Bit
;
//64bits arg0 - arg7 is in reg x1 - x7 and > 7 is in stack, but can not match
public
final
static
int
MAX_64_ARGS
=
7
;
public
static
int
MAX_STUB_ARGS
=
0
;
public
static
int
[]
stubSizes
;
public
static
boolean
hasStubBackup
=
false
;
public
static
boolean
hasStubBackup
;
public
static
AtomicInteger
[]
curUseStubIndexes
;
...
...
@@ -42,7 +45,8 @@ public class HookStubManager {
=
sHookedMethodCallbacks
;
static
{
Class
stubClass
=
SandHook
.
is64Bit
()
?
MethodHookerStubs64
.
class
:
MethodHookerStubs32
.
class
;
is64Bit
=
SandHook
.
is64Bit
();
Class
stubClass
=
is64Bit
?
MethodHookerStubs64
.
class
:
MethodHookerStubs32
.
class
;
stubSizes
=
(
int
[])
XposedHelpers
.
getStaticObjectField
(
stubClass
,
"stubSizes"
);
Boolean
hasBackup
=
(
Boolean
)
XposedHelpers
.
getStaticObjectField
(
stubClass
,
"hasStubBackup"
);
hasStubBackup
=
hasBackup
!=
null
&&
(
hasBackup
&&
!
XposedCompat
.
useNewCallBackup
);
...
...
@@ -90,6 +94,8 @@ public class HookStubManager {
needStubArgCount
+=
parType
.
length
;
if
(
needStubArgCount
>
MAX_STUB_ARGS
)
return
null
;
if
(
is64Bit
&&
needStubArgCount
>
MAX_64_ARGS
)
return
null
;
for
(
Class
par:
parType
)
{
if
(!
ParamWrapper
.
support
(
par
))
return
null
;
...
...
@@ -99,7 +105,7 @@ public class HookStubManager {
}
synchronized
(
HookStubManager
.
class
)
{
StubMethodsInfo
stubMethodInfo
=
getStubMethodPair
(
SandHook
.
is64Bit
()
,
needStubArgCount
);
StubMethodsInfo
stubMethodInfo
=
getStubMethodPair
(
is64Bit
,
needStubArgCount
);
if
(
stubMethodInfo
==
null
)
return
null
;
HookMethodEntity
entity
=
new
HookMethodEntity
(
origin
,
stubMethodInfo
.
hook
,
stubMethodInfo
.
backup
);
...
...
@@ -181,7 +187,7 @@ public class HookStubManager {
}
public
static
Method
getCallOriginMethod
(
int
args
,
int
index
)
{
Class
stubClass
=
SandHook
.
is64Bit
()
?
MethodHookerStubs64
.
class
:
MethodHookerStubs32
.
class
;
Class
stubClass
=
is64Bit
?
MethodHookerStubs64
.
class
:
MethodHookerStubs32
.
class
;
String
className
=
stubClass
.
getName
();
className
+=
"$"
;
className
+=
getCallOriginClassName
(
args
,
index
);
...
...
xposedcompat/src/main/java/com/swift/sandhook/xposedcompat/hookstub/MethodHookerStubs64.java
View file @
8aa1f24a
This diff is collapsed.
Click to expand it.
xposedcompat/src/main/java/de/robv/android/xposed/XposedBridge.java
View file @
8aa1f24a
...
...
@@ -5,6 +5,7 @@ import android.util.Log;
import
com.swift.sandhook.xposedcompat.methodgen.DynamicBridge
;
import
com.swift.sandhook.xposedcompat.utils.DexLog
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -122,7 +123,9 @@ public final class XposedBridge {
* @param text The log message.
*/
public
synchronized
static
void
log
(
String
text
)
{
Log
.
i
(
TAG
,
text
);
if
(
DexLog
.
DEBUG
)
{
Log
.
i
(
TAG
,
text
);
}
}
/**
...
...
@@ -134,7 +137,9 @@ public final class XposedBridge {
* @param t The Throwable object for the stack trace.
*/
public
synchronized
static
void
log
(
Throwable
t
)
{
Log
.
e
(
TAG
,
Log
.
getStackTraceString
(
t
));
if
(
DexLog
.
DEBUG
)
{
Log
.
e
(
TAG
,
Log
.
getStackTraceString
(
t
));
}
}
/**
...
...
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