Skip to content

Commit

Permalink
fix 5
Browse files Browse the repository at this point in the history
  • Loading branch information
ggsasda authored Oct 24, 2024
1 parent 7e2a709 commit b7ba834
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions loader/src/injector/gen_jni_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def ind(i):
jstring = JType('jstring', 'Ljava/lang/String;')
jboolean = JType('jboolean', 'Z')
jlong = JType('jlong', 'J')
jlongArray = JArray(jlong)
void = JType('void', 'V')

class ForkAndSpec(JNIHook):
Expand Down Expand Up @@ -213,9 +214,8 @@ def init_args(self):
# GrapheneOS Android 14 Support

fas_grapheneos_u = ForkAndSpec('grapheneos_u', [uid, gid, gids, runtime_flags, rlimits, mount_external,
se_info, nice_name, fds_to_close, fds_to_ignore, is_child_zygote, instruction_set, app_data_dir,
is_top_app, pkg_data_info_list, whitelisted_data_info_list, mount_data_dirs, mount_storage_dirs,
mount_sysprop_overrides, Anon(jlongArray)])
se_info, nice_name, fds_to_close, fds_to_ignore, is_child_zygote, instruction_set, app_data_dir,
is_top_app, pkg_data_info_list, whitelisted_data_info_list, mount_data_dirs, mount_storage_dirs, mount_sysprop_overrides, Anon(jlongArray)])

spec_grapheneos_u = SpecApp('grapheneos_u', [uid, gid, gids, runtime_flags, rlimits, mount_external,
se_info, nice_name, is_child_zygote, instruction_set, app_data_dir, is_top_app, pkg_data_info_list,
Expand Down
18 changes: 7 additions & 11 deletions loader/src/injector/jni_hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,36 +359,32 @@ static void do_hook_zygote(JNIEnv *env) {
vector<JNINativeMethod> hooks;
const char *clz = "com/android/internal/os/Zygote";

// Hook nativeForkAndSpecialize methods
hookJniNativeMethods(env, clz, nativeForkAndSpecialize_methods.data(), nativeForkAndSpecialize_methods.size());
for (auto &method : nativeForkAndSpecialize_methods) {
if (method.fnPtr) {
nativeForkAndSpecialize_orig = method.fnPtr; // Store original method pointer
hooks.emplace_back(method); // Add to hooks vector
nativeForkAndSpecialize_orig = method.fnPtr;
hooks.emplace_back(method);
break;
}
}

// Hook nativeSpecializeAppProcess methods
hookJniNativeMethods(env, clz, nativeSpecializeAppProcess_methods.data(), nativeSpecializeAppProcess_methods.size());
for (auto &method : nativeSpecializeAppProcess_methods) {
if (method.fnPtr) {
nativeSpecializeAppProcess_orig = method.fnPtr; // Store original method pointer
hooks.emplace_back(method); // Add to hooks vector
nativeSpecializeAppProcess_orig = method.fnPtr;
hooks.emplace_back(method);
break;
}
}

// Hook nativeForkSystemServer methods
hookJniNativeMethods(env, clz, nativeForkSystemServer_methods.data(), nativeForkSystemServer_methods.size());
for (auto &method : nativeForkSystemServer_methods) {
if (method.fnPtr) {
nativeForkSystemServer_orig = method.fnPtr; // Store original method pointer
hooks.emplace_back(method); // Add to hooks vector
nativeForkSystemServer_orig = method.fnPtr;
hooks.emplace_back(method);
break;
}
}

// Store all hooks in a list for further use
jni_hook_list->emplace(clz, std::move(hooks));
}
}

0 comments on commit b7ba834

Please sign in to comment.