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
3d7db2a9
Commit
3d7db2a9
authored
Jan 14, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix resolve cache
parent
8775fed6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
CastArtMethod.h
app/src/main/cpp/casts/CastArtMethod.h
+2
-2
MainActivity.java
app/src/main/java/com/swift/sandhook/MainActivity.java
+1
-1
SandHookMethodResolver.java
.../main/java/com/swift/sandhook/SandHookMethodResolver.java
+7
-8
No files found.
app/src/main/cpp/casts/CastArtMethod.h
View file @
3d7db2a9
...
@@ -91,8 +91,8 @@ namespace SandHook {
...
@@ -91,8 +91,8 @@ namespace SandHook {
//test
//test
art
::
mirror
::
ArtMethod
**
mArray
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
**>
(
m1
.
dex_cache_resolved_methods_
);
art
::
mirror
::
ArtMethod
**
mArray
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
**>
(
m1
.
dex_cache_resolved_methods_
);
art
::
mirror
::
ArtMethod
m1B
=
*
(
mArray
+
8
)
[
m1
.
dex_method_index_
];
art
::
mirror
::
ArtMethod
m1B
=
*
mArray
[
m1
.
dex_method_index_
];
art
::
mirror
::
ArtMethod
m1C
=
*
(
mArray
+
8
)
[
m2
.
dex_method_index_
];
art
::
mirror
::
ArtMethod
m1C
=
*
mArray
[
m2
.
dex_method_index_
];
}
}
...
...
app/src/main/java/com/swift/sandhook/MainActivity.java
View file @
3d7db2a9
...
@@ -57,7 +57,7 @@ public class MainActivity extends AppCompatActivity {
...
@@ -57,7 +57,7 @@ public class MainActivity extends AppCompatActivity {
artMethodField
.
setAccessible
(
true
);
artMethodField
.
setAccessible
(
true
);
long
artMethod
=
(
long
)
artMethodField
.
get
(
method1
);
long
artMethod
=
(
long
)
artMethodField
.
get
(
method1
);
//
methods[dexMethodIndex] = artMethod;
methods
[
dexMethodIndex
]
=
artMethod
;
initHook
();
initHook
();
// SandHook.init();
// SandHook.init();
...
...
app/src/main/java/com/swift/sandhook/SandHookMethodResolver.java
View file @
3d7db2a9
...
@@ -46,11 +46,11 @@ public class SandHookMethodResolver {
...
@@ -46,11 +46,11 @@ public class SandHookMethodResolver {
}
}
}
}
public
static
void
resolveMethod
(
Method
method
)
{
public
static
void
resolveMethod
(
Method
hook
,
Method
backup
)
{
if
(
canResolvedInJava
&&
artMethodField
!=
null
)
{
if
(
canResolvedInJava
&&
artMethodField
!=
null
)
{
// in java
// in java
try
{
try
{
resolveInJava
(
method
);
resolveInJava
(
hook
,
backup
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// in native
// in native
}
}
...
@@ -59,17 +59,16 @@ public class SandHookMethodResolver {
...
@@ -59,17 +59,16 @@ public class SandHookMethodResolver {
}
}
}
}
private
static
void
resolveInJava
(
Method
method
)
throws
Exception
{
private
static
void
resolveInJava
(
Method
hook
,
Method
backup
)
throws
Exception
{
Object
dexCache
=
dexCacheField
.
get
(
method
.
getDeclaringClass
());
Object
dexCache
=
dexCacheField
.
get
(
hook
.
getDeclaringClass
());
resolvedMethodsField
.
setAccessible
(
true
);
int
dexMethodIndex
=
(
int
)
dexMethodIndexField
.
get
(
backup
);
int
dexMethodIndex
=
(
int
)
dexMethodIndexField
.
get
(
method
);
Object
resolvedMethods
=
resolvedMethodsField
.
get
(
dexCache
);
Object
resolvedMethods
=
resolvedMethodsField
.
get
(
dexCache
);
if
(
resolvedMethods
instanceof
long
[])
{
if
(
resolvedMethods
instanceof
long
[])
{
long
artMethod
=
(
long
)
artMethodField
.
get
(
method
);
long
artMethod
=
(
long
)
artMethodField
.
get
(
backup
);
((
long
[])
resolvedMethods
)[
dexMethodIndex
]
=
artMethod
;
((
long
[])
resolvedMethods
)[
dexMethodIndex
]
=
artMethod
;
}
else
if
(
resolvedMethods
instanceof
Object
[])
{
}
else
if
(
resolvedMethods
instanceof
Object
[])
{
Object
artMethod
=
artMethodField
.
get
(
method
);
Object
artMethod
=
artMethodField
.
get
(
backup
);
((
Object
[])
resolvedMethods
)[
dexMethodIndex
]
=
artMethod
;
((
Object
[])
resolvedMethods
)[
dexMethodIndex
]
=
artMethod
;
}
else
{
}
else
{
throw
new
UnsupportedOperationException
(
"unsupport"
);
throw
new
UnsupportedOperationException
(
"unsupport"
);
...
...
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