diff --git a/native/jni/zygisk/gen_jni_hooks.py b/native/jni/zygisk/gen_jni_hooks.py index c6f4fa166..f5e3e80bc 100755 --- a/native/jni/zygisk/gen_jni_hooks.py +++ b/native/jni/zygisk/gen_jni_hooks.py @@ -255,16 +255,14 @@ def gen_jni_hook(): decl += ind(1) + 'auto &class_map = (*jni_method_map)[className];' decl += ind(1) + 'for (int i = 0; i < numMethods; ++i) {' - decl += ind(2) + 'class_map[methods[i].name][methods[i].signature] = methods[i].fnPtr;' - decl += ind(2) + 'if (hook_cnt == 0) continue;' for index, methods in enumerate(hook_map.values()): - decl += ind(2) + f'if (clz_id == {index}) {{' + decl += ind(2) + f'if (hook_cnt && clz_id == {index}) {{' for m in methods: decl += ind(3) + f'HOOK_JNI({m})' - decl += ind(3) + 'continue;' decl += ind(2) + '}' + decl += ind(2) + 'class_map[methods[i].name][methods[i].signature] = methods[i].fnPtr;' decl += ind(1) + '}' decl += ind(1) + 'return newMethods;' diff --git a/native/jni/zygisk/hook.cpp b/native/jni/zygisk/hook.cpp index 042be5747..59c3b5f16 100644 --- a/native/jni/zygisk/hook.cpp +++ b/native/jni/zygisk/hook.cpp @@ -88,6 +88,7 @@ if (methods[i].name == #method##sv) { \ break; \ } \ } \ + ZLOGE("unknown signature of %s#" #method ": %s\n", className, methods[i].signature); \ continue; \ } diff --git a/native/jni/zygisk/jni_hooks.hpp b/native/jni/zygisk/jni_hooks.hpp index aee068ba8..972c5a294 100644 --- a/native/jni/zygisk/jni_hooks.hpp +++ b/native/jni/zygisk/jni_hooks.hpp @@ -303,14 +303,12 @@ unique_ptr hookAndSaveJNIMethods(const char *className, const } auto &class_map = (*jni_method_map)[className]; for (int i = 0; i < numMethods; ++i) { - class_map[methods[i].name][methods[i].signature] = methods[i].fnPtr; - if (hook_cnt == 0) continue; - if (clz_id == 0) { + if (hook_cnt && clz_id == 0) { HOOK_JNI(nativeForkAndSpecialize) HOOK_JNI(nativeSpecializeAppProcess) HOOK_JNI(nativeForkSystemServer) - continue; } + class_map[methods[i].name][methods[i].signature] = methods[i].fnPtr; } return newMethods; }