From 19d8a4526db14099b10ba01db0c53d318a097062 Mon Sep 17 00:00:00 2001 From: Moritz Horstmann Date: Sun, 28 Jun 2015 03:40:08 +0200 Subject: [PATCH] Fix registering of hooked native methods through AndroidRuntime::registerNativeMethods --- runtime/jni_internal.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index bdda5c87077..c9f9d0b384f 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -2413,7 +2413,7 @@ class JNI { << c->GetDexCache()->GetLocation()->ToModifiedUtf8(); ThrowNoSuchMethodError(soa, c, name, sig, "static or non-static"); return JNI_ERR; - } else if (!m->IsNative()) { + } else if (!m->IsNative() && !(m->IsXposedHookedMethod() && m->GetXposedOriginalMethod()->IsNative())) { LOG(return_errors ? ERROR : FATAL) << "Failed to register non-native method " << PrettyDescriptor(c) << "." << name << sig << " as native"; @@ -2438,14 +2438,14 @@ class JNI { size_t unregistered_count = 0; for (size_t i = 0; i < c->NumDirectMethods(); ++i) { mirror::ArtMethod* m = c->GetDirectMethod(i); - if (m->IsNative()) { + if (m->IsNative() || (m->IsXposedHookedMethod() && m->GetXposedOriginalMethod()->IsNative())) { m->UnregisterNative(soa.Self()); unregistered_count++; } } for (size_t i = 0; i < c->NumVirtualMethods(); ++i) { mirror::ArtMethod* m = c->GetVirtualMethod(i); - if (m->IsNative()) { + if (m->IsNative() || (m->IsXposedHookedMethod() && m->GetXposedOriginalMethod()->IsNative())) { m->UnregisterNative(soa.Self()); unregistered_count++; }