Commit 5524b33b authored by swift_gan's avatar swift_gan

if virtual method skip compile

parent c1e5d6e2
...@@ -39,6 +39,11 @@ void setPrivate(art::mirror::ArtMethod* method) { ...@@ -39,6 +39,11 @@ void setPrivate(art::mirror::ArtMethod* method) {
SandHook::CastArtMethod::accessFlag->set(method, accessFlag); SandHook::CastArtMethod::accessFlag->set(method, accessFlag);
} }
bool isAbsMethod(art::mirror::ArtMethod* method) {
uint32_t accessFlags = SandHook::CastArtMethod::accessFlag->get(method);
return ((accessFlags & 0x0400) != 0);
}
void ensureMethodCached(art::mirror::ArtMethod *hookMethod, art::mirror::ArtMethod *backupMethod) { void ensureMethodCached(art::mirror::ArtMethod *hookMethod, art::mirror::ArtMethod *backupMethod) {
if (SDK_INT >= ANDROID_P) if (SDK_INT >= ANDROID_P)
return; return;
...@@ -153,7 +158,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or ...@@ -153,7 +158,7 @@ Java_com_swift_sandhook_SandHook_hookMethod(JNIEnv *env, jclass type, jobject or
if (isInterpreter) { if (isInterpreter) {
if (SDK_INT >= ANDROID_N) { if (SDK_INT >= ANDROID_N) {
Size threadId = getAddressFromJavaByCallMethod(env, "com/swift/sandhook/SandHook", "getThreadId"); Size threadId = getAddressFromJavaByCallMethod(env, "com/swift/sandhook/SandHook", "getThreadId");
if (compileMethod(origin, reinterpret_cast<void *>(threadId)) && SandHook::CastArtMethod::entryPointQuickCompiled->get(origin) != SandHook::CastArtMethod::quickToInterpreterBridge) { if (!isAbsMethod(origin) && compileMethod(origin, reinterpret_cast<void *>(threadId)) && SandHook::CastArtMethod::entryPointQuickCompiled->get(origin) != SandHook::CastArtMethod::quickToInterpreterBridge) {
return static_cast<jboolean>(doHookWithInline(env, origin, hook, backup)); return static_cast<jboolean>(doHookWithInline(env, origin, hook, backup));
} else { } else {
return static_cast<jboolean>(doHookWithReplacement(origin, hook, backup)); return static_cast<jboolean>(doHookWithReplacement(origin, hook, backup));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment