Skip to content

Commit

Permalink
merge local commits
Browse files Browse the repository at this point in the history
  • Loading branch information
rk700 committed Nov 23, 2020
2 parents 9c79260 + 1fbe52b commit 639c7f5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions library/src/main/jni/HookMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,16 @@ static int replaceMethod(void *fromMethod, void *toMethod, int isBackup) {
}

// set the target method to native so that Android O wouldn't invoke it with interpreter
if (SDKVersion >= __ANDROID_API_O__) {
if(SDKVersion >= __ANDROID_API_O__) {
uint32_t access_flags = getFlags(fromMethod);
uint32_t old_flags = access_flags;
access_flags |= kAccNative;
if (SDKVersion >= __ANDROID_API_Q__) {
// On API 29 whether to use the fast path or not is cached in the ART method structure
access_flags &= ~kAccFastInterpreterToInterpreterInvoke;
} else {
// We don't set kAccNative on R+ because they will try to load from real native method pointer instead of entry_point_from_quick_compiled_code_.
// Ref: https://cs.android.com/android/platform/superproject/+/android-11.0.0_r3:art/runtime/art_method.h;l=844;bpv=1;bpt=1
access_flags |= kAccNative;
}
setFlags(fromMethod, access_flags);
LOGI("change access flags from 0x%x to 0x%x", old_flags, access_flags);
Expand Down

0 comments on commit 639c7f5

Please sign in to comment.