From abfb3bb3bbab0f5d8cef0946681160c92e65df7e Mon Sep 17 00:00:00 2001 From: LoveSy Date: Sun, 17 Oct 2021 20:00:31 +0800 Subject: [PATCH] Fix always log hook fails --- native/jni/zygisk/hook.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/native/jni/zygisk/hook.cpp b/native/jni/zygisk/hook.cpp index 4925add99..d5f7ddaeb 100644 --- a/native/jni/zygisk/hook.cpp +++ b/native/jni/zygisk/hook.cpp @@ -76,20 +76,23 @@ HookContext *g_ctx; const JNINativeInterface *old_functions; JNINativeInterface *new_functions; -#define HOOK_JNI(method) \ -if (methods[i].name == #method##sv) { \ - for (int j = 0; j < method##_methods_num; ++j) { \ - if (strcmp(methods[i].signature, method##_methods[j].signature) == 0) { \ - jni_hook_list->try_emplace(className).first->second.push_back(methods[i]); \ - method##_orig = methods[i].fnPtr; \ - newMethods[i] = method##_methods[j]; \ - ZLOGI("replaced %s#" #method "\n", className); \ - --hook_cnt; \ - break; \ - } \ - } \ - ZLOGE("unknown signature of %s#" #method ": %s\n", className, methods[i].signature); \ - continue; \ +#define HOOK_JNI(method) \ +if (methods[i].name == #method##sv) { \ + int j = 0; \ + for (; j < method##_methods_num; ++j) { \ + if (strcmp(methods[i].signature, method##_methods[j].signature) == 0) { \ + jni_hook_list->try_emplace(className).first->second.push_back(methods[i]); \ + method##_orig = methods[i].fnPtr; \ + newMethods[i] = method##_methods[j]; \ + ZLOGI("replaced %s#" #method "\n", className); \ + --hook_cnt; \ + break; \ + } \ + } \ + if (j == method##_methods_num) { \ + ZLOGE("unknown signature of %s#" #method ": %s\n", className, methods[i].signature); \ + } \ + continue; \ } // JNI method hook definitions, auto generated