diff --git a/native/jni/zygisk/gen_jni_hooks.py b/native/jni/zygisk/gen_jni_hooks.py index 665673397..8a5b70d19 100755 --- a/native/jni/zygisk/gen_jni_hooks.py +++ b/native/jni/zygisk/gen_jni_hooks.py @@ -271,6 +271,7 @@ def gen_jni_hook(): with open('jni_hooks.hpp', 'w') as f: f.write('// Generated by gen_jni_hooks.py\n') + f.write('\nnamespace {\n') zygote = 'com/android/internal/os/Zygote' @@ -285,4 +286,4 @@ with open('jni_hooks.hpp', 'w') as f: f.write(gen_jni_hook()) - f.write('\n') + f.write('\n\n} // namespace\n') diff --git a/native/jni/zygisk/hook.cpp b/native/jni/zygisk/hook.cpp index 79fd156c0..1d237eed6 100644 --- a/native/jni/zygisk/hook.cpp +++ b/native/jni/zygisk/hook.cpp @@ -79,6 +79,8 @@ HookContext *g_ctx; const JNINativeInterface *old_functions; JNINativeInterface *new_functions; +} // namespace + #define HOOK_JNI(method) \ if (methods[i].name == #method##sv) { \ int j = 0; \ @@ -103,6 +105,8 @@ if (methods[i].name == #method##sv) { #undef HOOK_JNI +namespace { + jclass gClassRef; jmethodID class_getName; string get_class_name(JNIEnv *env, jclass clazz) { diff --git a/native/jni/zygisk/jni_hooks.hpp b/native/jni/zygisk/jni_hooks.hpp index 1eab79fa9..6d25a1b26 100644 --- a/native/jni/zygisk/jni_hooks.hpp +++ b/native/jni/zygisk/jni_hooks.hpp @@ -1,5 +1,7 @@ // Generated by gen_jni_hooks.py +namespace { + void *nativeForkAndSpecialize_orig = nullptr; jint nativeForkAndSpecialize_l(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring nice_name, jintArray fds_to_close, jstring instruction_set, jstring app_data_dir) { AppSpecializeArgs_v3 args(uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, nice_name, instruction_set, app_data_dir); @@ -318,3 +320,5 @@ unique_ptr hookAndSaveJNIMethods(const char *className, const } return newMethods; } + +} // namespace