@@ -47,10 +47,10 @@ static __typeof__(&dvmThreadSelf) g_dvmThreadSelf;
47
47
48
48
// -------------------------------------------------------------------------
49
49
50
- static int __native_hook (JNIEnv *env, Method *vm_origin, jobject target )
50
+ static int __native_hook (JNIEnv *env, Method *vm_origin, Method *vm_target )
51
51
{
52
52
// Method *vm_origin = reinterpret_cast<Method *>(env->FromReflectedMethod(origin));
53
- Method *vm_target = reinterpret_cast <Method *>(env->FromReflectedMethod (target));
53
+ // Method *vm_target = reinterpret_cast<Method *>(env->FromReflectedMethod(target));
54
54
55
55
// Dalvik puts private, static, and constructors into non-virtual table
56
56
// g_dvmIsDirectMethod(vm_origin)
@@ -86,7 +86,8 @@ static int __native_hook(JNIEnv *env, Method *vm_origin, jobject target)
86
86
static void JNICALL dvmHookNativeNoBackup (JNIEnv *env, jclass, jobject origin, jobject target)
87
87
{
88
88
Method *vm_origin = reinterpret_cast <Method *>(env->FromReflectedMethod (origin));
89
- __native_hook (env, vm_origin, target);
89
+ Method *vm_target = reinterpret_cast <Method *>(env->FromReflectedMethod (target));
90
+ __native_hook (env, vm_origin, vm_target);
90
91
}
91
92
92
93
// -------------------------------------------------------------------------
@@ -101,10 +102,14 @@ static jint JNICALL dvmHookNative(JNIEnv *env, jclass, jobject origin, jobject t
101
102
102
103
Method *vm_origin = reinterpret_cast <Method *>(env->FromReflectedMethod (origin));
103
104
g_backups[slot] = *vm_origin;
104
-
105
- if (__native_hook (env, vm_origin, target ) == 0 ) {
105
+ Method *vm_target = reinterpret_cast <Method *>(env-> FromReflectedMethod (target));
106
+ if (__native_hook (env, vm_origin, vm_target ) == 0 ) {
106
107
CLEAR_METHOD_FLAG (&g_backups[slot], ACC_PUBLIC);
107
108
SET_METHOD_FLAG (&g_backups[slot], ACC_PRIVATE);
109
+
110
+ // fixs for Java.NullPointerException when looking for
111
+ // backup method by stack method name, but target method may not be found later
112
+ vm_target->name = vm_origin->name ;
108
113
} // if
109
114
110
115
return slot;
0 commit comments