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
729a53fa
Commit
729a53fa
authored
Jan 21, 2019
by
swift_gan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
c9260188
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
4 deletions
+50
-4
art.h
app/src/main/cpp/casts/art/art.h
+43
-1
cast_art_method.h
app/src/main/cpp/casts/cast_art_method.h
+3
-3
native-lib.cpp
app/src/main/cpp/native-lib.cpp
+4
-0
No files found.
app/src/main/cpp/casts/art/art.h
View file @
729a53fa
...
...
@@ -41,7 +41,49 @@ public:
class
ArtMethod
{
public
:
uint16_t
palceholder
[
32
];
uint32_t
declaring_class_
;
// Access flags; low 16 bits are defined by spec.
// Getting and setting this flag needs to be atomic when concurrency is
// possible, e.g. after this method's class is linked. Such as when setting
// verifier flags and single-implementation flag.
uint32_t
access_flags_
;
/* Dex file fields. The defining dex file is available via declaring_class_->dex_cache_ */
// Offset to the CodeItem.
uint32_t
dex_code_item_offset_
;
// Index into method_ids of the dex file associated with this method.
uint32_t
dex_method_index_
;
/* End of dex file fields. */
// Entry within a dispatch table for this method. For static/direct methods the index is into
// the declaringClass.directMethods, for virtual methods the vtable and for interface methods the
// ifTable.
uint16_t
method_index_
;
// The hotness we measure for this method. Managed by the interpreter. Not atomic, as we allow
// missing increments: if the method is hot, we will see it eventually.
uint16_t
hotness_count_
;
// Fake padding field gets inserted here.
// Must be the last fields in the method.
struct
PtrSizedFields
{
// Short cuts to declaring_class_->dex_cache_ member for fast compiled code access.
void
*
dex_cache_resolved_methods_
;
// Pointer to JNI function registered to this method, or a function to resolve the JNI function,
// or the profiling data for non-native methods, or an ImtConflictTable, or the
// single-implementation of an abstract/interface method.
void
*
data_
;
// Method dispatch from quick compiled code invokes this pointer which may cause bridging into
// the interpreter.
void
*
entry_point_from_quick_compiled_code_
;
}
ptr_sized_fields_
;
};
}
...
...
app/src/main/cpp/casts/cast_art_method.h
View file @
729a53fa
...
...
@@ -110,7 +110,7 @@ namespace SandHook {
static
ArrayMember
<
art
::
mirror
::
ArtMethod
>*
dexCacheResolvedMethods
;
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
dexMethodIndex
;
static
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
accessFlag
;
static
Code
quickToInterpreterBridge
;
static
void
*
quickToInterpreterBridge
;
static
void
init
(
JNIEnv
*
env
,
int
sdk
)
{
...
...
@@ -142,7 +142,7 @@ namespace SandHook {
jclass
neverCallTestClass
=
env
->
FindClass
(
"com/swift/sandhook/ClassNeverCall"
);
art
::
mirror
::
ArtMethod
*
neverCall
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
GetMethodID
(
neverCallTestClass
,
"neverCall"
,
"()V"
));
quickToInterpreterBridge
=
reinterpret_cast
<
Code
>
(
entryPointQuickCompiled
->
get
(
*
neverCall
)
);
quickToInterpreterBridge
=
entryPointQuickCompiled
->
get
(
*
neverCall
);
// //test
// art::mirror::ArtMethod** mArray = reinterpret_cast<art::mirror::ArtMethod**>(m1.dex_cache_resolved_methods_);
...
...
@@ -164,7 +164,7 @@ namespace SandHook {
ArrayMember
<
art
::
mirror
::
ArtMethod
>*
CastArtMethod
::
dexCacheResolvedMethods
=
nullptr
;
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
dexMethodIndex
=
nullptr
;
IMember
<
art
::
mirror
::
ArtMethod
,
uint32_t
>*
CastArtMethod
::
accessFlag
=
nullptr
;
Code
CastArtMethod
::
quickToInterpreterBridge
=
nullptr
;
void
*
CastArtMethod
::
quickToInterpreterBridge
=
nullptr
;
}
...
...
app/src/main/cpp/native-lib.cpp
View file @
729a53fa
...
...
@@ -25,6 +25,10 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
art
::
mirror
::
ArtMethod
*
hook
=
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
FromReflectedMethod
(
hookMethod
));
art
::
mirror
::
ArtMethod
*
backup
=
backupMethod
==
NULL
?
nullptr
:
reinterpret_cast
<
art
::
mirror
::
ArtMethod
*>
(
env
->
FromReflectedMethod
(
backupMethod
));
if
(
SandHook
::
CastArtMethod
::
entryPointQuickCompiled
->
get
(
*
origin
)
==
SandHook
::
CastArtMethod
::
quickToInterpreterBridge
)
{
return
JNI_FALSE
;
}
trampolineManager
.
installInlineTrampoline
(
origin
,
hook
,
backup
);
return
JNI_TRUE
;
...
...
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