Magisk/native/jni/zygisk/jni_hooks.hpp

317 lines
18 KiB
C++
Raw Normal View History

2021-08-02 03:20:19 -07:00
// Generated by gen_jni_hooks.py
2021-08-20 23:40:57 -07:00
void *nativeForkAndSpecialize_orig = nullptr;
2021-08-11 22:56:18 -07:00
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) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_l)>(nativeForkAndSpecialize_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, nice_name, fds_to_close, instruction_set, app_data_dir
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
jint nativeForkAndSpecialize_o(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, jintArray fds_to_ignore, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_o)>(nativeForkAndSpecialize_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, nice_name, fds_to_close, fds_to_ignore, instruction_set, app_data_dir
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
jint nativeForkAndSpecialize_p(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, jintArray fds_to_ignore, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_p)>(nativeForkAndSpecialize_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, 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
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
jint nativeForkAndSpecialize_q_alt(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, jintArray fds_to_ignore, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir, jboolean is_top_app) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
args.is_top_app = &is_top_app;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_q_alt)>(nativeForkAndSpecialize_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, 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
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
jint nativeForkAndSpecialize_r(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, jintArray fds_to_ignore, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir, jboolean is_top_app, jobjectArray pkg_data_info_list, jobjectArray whitelisted_data_info_list, jboolean mount_data_dirs, jboolean mount_storage_dirs) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
args.is_top_app = &is_top_app;
args.pkg_data_info_list = &pkg_data_info_list;
args.whitelisted_data_info_list = &whitelisted_data_info_list;
args.mount_data_dirs = &mount_data_dirs;
args.mount_storage_dirs = &mount_storage_dirs;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_r)>(nativeForkAndSpecialize_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, 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
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
jint nativeForkAndSpecialize_samsung_m(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jint _0, jint _1, jstring nice_name, jintArray fds_to_close, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_samsung_m)>(nativeForkAndSpecialize_orig)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, _0, _1, nice_name, fds_to_close, instruction_set, app_data_dir
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
jint nativeForkAndSpecialize_samsung_n(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jint _2, jint _3, jstring nice_name, jintArray fds_to_close, jstring instruction_set, jstring app_data_dir, jint _4) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_samsung_n)>(nativeForkAndSpecialize_orig)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, _2, _3, nice_name, fds_to_close, instruction_set, app_data_dir, _4
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
jint nativeForkAndSpecialize_samsung_o(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jint _5, jint _6, jstring nice_name, jintArray fds_to_close, jintArray fds_to_ignore, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_samsung_o)>(nativeForkAndSpecialize_orig)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, _5, _6, nice_name, fds_to_close, fds_to_ignore, instruction_set, app_data_dir
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
jint nativeForkAndSpecialize_samsung_p(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jint _7, jint _8, jstring nice_name, jintArray fds_to_close, jintArray fds_to_ignore, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkAndSpecialize_samsung_p)>(nativeForkAndSpecialize_orig)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, _7, _8, nice_name, fds_to_close, fds_to_ignore, is_child_zygote, instruction_set, app_data_dir
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkAndSpecialize_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-02 03:20:19 -07:00
const JNINativeMethod nativeForkAndSpecialize_methods[] = {
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[ILjava/lang/String;Ljava/lang/String;)I",
2021-08-11 17:14:22 -07:00
(void *) &nativeForkAndSpecialize_l
2021-08-02 03:20:19 -07:00
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[ILjava/lang/String;Ljava/lang/String;)I",
(void *) &nativeForkAndSpecialize_o
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;)I",
(void *) &nativeForkAndSpecialize_p
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z)I",
(void *) &nativeForkAndSpecialize_q_alt
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZ)I",
(void *) &nativeForkAndSpecialize_r
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;IILjava/lang/String;[ILjava/lang/String;Ljava/lang/String;)I",
(void *) &nativeForkAndSpecialize_samsung_m
},
{
"nativeForkAndSpecialize",
"(II[II[[IILjava/lang/String;IILjava/lang/String;[ILjava/lang/String;Ljava/lang/String;I)I",
(void *) &nativeForkAndSpecialize_samsung_n
},
{
"nativeForkAndSpecialize",
2021-01-09 04:28:26 -08:00
"(II[II[[IILjava/lang/String;IILjava/lang/String;[I[ILjava/lang/String;Ljava/lang/String;)I",
2021-08-02 03:20:19 -07:00
(void *) &nativeForkAndSpecialize_samsung_o
},
{
"nativeForkAndSpecialize",
2021-01-09 04:28:26 -08:00
"(II[II[[IILjava/lang/String;IILjava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;)I",
2021-08-02 03:20:19 -07:00
(void *) &nativeForkAndSpecialize_samsung_p
},
};
2021-08-11 22:56:18 -07:00
constexpr int nativeForkAndSpecialize_methods_num = std::size(nativeForkAndSpecialize_methods);
2021-08-02 03:20:19 -07:00
2021-08-20 23:40:57 -07:00
void *nativeSpecializeAppProcess_orig = nullptr;
2021-08-11 22:56:18 -07:00
void nativeSpecializeAppProcess_q(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring nice_name, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeSpecializeAppProcess_q)>(nativeSpecializeAppProcess_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, nice_name, is_child_zygote, instruction_set, app_data_dir
);
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_post();
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
void nativeSpecializeAppProcess_q_alt(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring nice_name, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir, jboolean is_top_app) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
args.is_top_app = &is_top_app;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeSpecializeAppProcess_q_alt)>(nativeSpecializeAppProcess_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, nice_name, is_child_zygote, instruction_set, app_data_dir, is_top_app
);
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_post();
2021-01-08 05:25:44 -08:00
}
2021-08-11 22:56:18 -07:00
void nativeSpecializeAppProcess_r(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jstring nice_name, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir, jboolean is_top_app, jobjectArray pkg_data_info_list, jobjectArray whitelisted_data_info_list, jboolean mount_data_dirs, jboolean mount_storage_dirs) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
args.is_top_app = &is_top_app;
args.pkg_data_info_list = &pkg_data_info_list;
args.whitelisted_data_info_list = &whitelisted_data_info_list;
args.mount_data_dirs = &mount_data_dirs;
args.mount_storage_dirs = &mount_storage_dirs;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeSpecializeAppProcess_r)>(nativeSpecializeAppProcess_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, 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, whitelisted_data_info_list, mount_data_dirs, mount_storage_dirs
);
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_post();
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
void nativeSpecializeAppProcess_samsung_q(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jint mount_external, jstring se_info, jint _9, jint _10, jstring nice_name, jboolean is_child_zygote, jstring instruction_set, jstring app_data_dir) {
2021-08-02 03:20:19 -07:00
SpecializeAppProcessArgs args(uid, gid, gids, runtime_flags, mount_external, se_info, nice_name, instruction_set, app_data_dir);
args.is_child_zygote = &is_child_zygote;
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeSpecializeAppProcess_samsung_q)>(nativeSpecializeAppProcess_orig)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, _9, _10, nice_name, is_child_zygote, instruction_set, app_data_dir
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeSpecializeAppProcess_post();
2021-01-08 05:25:44 -08:00
}
2021-08-02 03:20:19 -07:00
const JNINativeMethod nativeSpecializeAppProcess_methods[] = {
{
"nativeSpecializeAppProcess",
"(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;)V",
(void *) &nativeSpecializeAppProcess_q
},
{
"nativeSpecializeAppProcess",
"(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z)V",
(void *) &nativeSpecializeAppProcess_q_alt
},
{
"nativeSpecializeAppProcess",
2021-01-09 04:28:26 -08:00
"(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZ)V",
2021-08-02 03:20:19 -07:00
(void *) &nativeSpecializeAppProcess_r
},
{
"nativeSpecializeAppProcess",
2021-01-09 04:28:26 -08:00
"(II[II[[IILjava/lang/String;IILjava/lang/String;ZLjava/lang/String;Ljava/lang/String;)V",
2021-08-02 03:20:19 -07:00
(void *) &nativeSpecializeAppProcess_samsung_q
},
};
2021-08-11 22:56:18 -07:00
constexpr int nativeSpecializeAppProcess_methods_num = std::size(nativeSpecializeAppProcess_methods);
2021-08-02 03:20:19 -07:00
2021-08-20 23:40:57 -07:00
void *nativeForkSystemServer_orig = nullptr;
2021-08-19 01:54:12 -07:00
jint nativeForkSystemServer_l(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jobjectArray rlimits, jlong permitted_capabilities, jlong effective_capabilities) {
2021-08-02 03:20:19 -07:00
ForkSystemServerArgs args(uid, gid, gids, runtime_flags, permitted_capabilities, effective_capabilities);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkSystemServer_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkSystemServer_l)>(nativeForkSystemServer_orig)(
2021-08-02 03:20:19 -07:00
env, clazz, uid, gid, gids, runtime_flags, rlimits, permitted_capabilities, effective_capabilities
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkSystemServer_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
2021-08-20 23:40:57 -07:00
jint nativeForkSystemServer_samsung_q(JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags, jint _11, jint _12, jobjectArray rlimits, jlong permitted_capabilities, jlong effective_capabilities) {
2021-08-02 03:20:19 -07:00
ForkSystemServerArgs args(uid, gid, gids, runtime_flags, permitted_capabilities, effective_capabilities);
2021-08-19 01:54:12 -07:00
HookContext ctx;
ctx.env = env;
2021-08-02 03:20:19 -07:00
ctx.raw_args = &args;
2021-08-19 01:54:12 -07:00
ctx.nativeForkSystemServer_pre();
2021-08-20 23:40:57 -07:00
reinterpret_cast<decltype(&nativeForkSystemServer_samsung_q)>(nativeForkSystemServer_orig)(
env, clazz, uid, gid, gids, runtime_flags, _11, _12, rlimits, permitted_capabilities, effective_capabilities
2021-08-02 03:20:19 -07:00
);
2021-08-19 01:54:12 -07:00
ctx.nativeForkSystemServer_post();
2021-08-02 03:20:19 -07:00
return ctx.pid;
2021-01-08 05:25:44 -08:00
}
const JNINativeMethod nativeForkSystemServer_methods[] = {
2021-08-02 03:20:19 -07:00
{
"nativeForkSystemServer",
"(II[II[[IJJ)I",
2021-08-19 01:54:12 -07:00
(void *) &nativeForkSystemServer_l
2021-08-02 03:20:19 -07:00
},
{
"nativeForkSystemServer",
"(II[IIII[[IJJ)I",
(void *) &nativeForkSystemServer_samsung_q
},
};
2021-08-11 22:56:18 -07:00
constexpr int nativeForkSystemServer_methods_num = std::size(nativeForkSystemServer_methods);
2021-08-20 23:40:57 -07:00
unique_ptr<JNINativeMethod[]> hookAndSaveJNIMethods(const char *className, const JNINativeMethod *methods, int numMethods) {
unique_ptr<JNINativeMethod[]> newMethods;
int clz_id = -1;
int hook_cnt = 0;
do {
if (className == "com/android/internal/os/Zygote"sv) {
clz_id = 0;
hook_cnt = 3;
break;
}
} while (false);
if (hook_cnt) {
newMethods = make_unique<JNINativeMethod[]>(numMethods);
memcpy(newMethods.get(), methods, sizeof(JNINativeMethod) * numMethods);
}
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) {
HOOK_JNI(nativeForkAndSpecialize)
HOOK_JNI(nativeSpecializeAppProcess)
HOOK_JNI(nativeForkSystemServer)
continue;
}
}
return newMethods;
}