Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Support Android 14 QPR2 Beta 2
Browse files Browse the repository at this point in the history
  • Loading branch information
canyie authored and RikkaW committed Dec 24, 2023
1 parent 03a52e5 commit ec0fbd6
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 4 deletions.
57 changes: 53 additions & 4 deletions riru/src/main/cpp/jni_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ onRegisterZygote(const char *className, const JNINativeMethod *methods, int numM
jni::zygote::nativeForkAndSpecialize = new JNINativeMethod{method.name,
method.signature,
method.fnPtr};

if (strcmp(nativeForkAndSpecialize_r_sig, method.signature) == 0)
if (strcmp(nativeForkAndSpecialize_u_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_u;
else if (strcmp(nativeForkAndSpecialize_r_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_r;
else if (strcmp(nativeForkAndSpecialize_p_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeForkAndSpecialize_p;
Expand Down Expand Up @@ -87,8 +88,9 @@ onRegisterZygote(const char *className, const JNINativeMethod *methods, int numM
jni::zygote::nativeSpecializeAppProcess = new JNINativeMethod{method.name,
method.signature,
method.fnPtr};

if (strcmp(nativeSpecializeAppProcess_r_sig, method.signature) == 0)
if (strcmp(nativeSpecializeAppProcess_u_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_u;
else if (strcmp(nativeSpecializeAppProcess_r_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_r;
else if (strcmp(nativeSpecializeAppProcess_q_sig, method.signature) == 0)
newMethods[i].fnPtr = (void *) nativeSpecializeAppProcess_q;
Expand Down Expand Up @@ -605,6 +607,32 @@ jint nativeForkAndSpecialize_r_dp2(
return res;
}

[[clang::no_stack_protector]]
jint nativeForkAndSpecialize_u(
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 fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote,
jstring instructionSet, jstring appDataDir, jboolean isTopApp,
jobjectArray pkgDataInfoList, jobjectArray whitelistedDataInfoList,
jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs,
jboolean mountSyspropOverrides) {

nativeForkAndSpecialize_pre(env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external,
se_info, se_name, fdsToClose, fdsToIgnore, is_child_zygote,
instructionSet, appDataDir, isTopApp, pkgDataInfoList,
whitelistedDataInfoList,
bindMountAppDataDirs, bindMountAppStorageDirs);

jint res = ((nativeForkAndSpecialize_u_t *) jni::zygote::nativeForkAndSpecialize->fnPtr)(
env, clazz, uid, gid, gids, runtime_flags, rlimits, mount_external, se_info, se_name,
fdsToClose, fdsToIgnore, is_child_zygote, instructionSet, appDataDir, isTopApp,
pkgDataInfoList, whitelistedDataInfoList, bindMountAppDataDirs,
bindMountAppStorageDirs, mountSyspropOverrides);

nativeForkAndSpecialize_post(env, clazz, uid, is_child_zygote, res);
return res;
}

[[clang::no_stack_protector]]
jint nativeForkAndSpecialize_samsung_p(
JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags,
Expand Down Expand Up @@ -834,6 +862,27 @@ void nativeSpecializeAppProcess_r_dp2(
nativeSpecializeAppProcess_post(env, clazz, uid, startChildZygote);
}

[[clang::no_stack_protector]]
void nativeSpecializeAppProcess_u(
JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags,
jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName,
jboolean startChildZygote, jstring instructionSet, jstring appDataDir,
jboolean isTopApp, jobjectArray pkgDataInfoList,
jobjectArray whitelistedDataInfoList, jboolean bindMountAppDataDirs,
jboolean bindMountAppDataDirs, jboolean mountSyspropOverrides) {
nativeSpecializeAppProcess_pre(
env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName,
startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList,
whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs);

((nativeSpecializeAppProcess_u_t *) jni::zygote::nativeSpecializeAppProcess->fnPtr)(
env, clazz, uid, gid, gids, runtimeFlags, rlimits, mountExternal, seInfo, niceName,
startChildZygote, instructionSet, appDataDir, isTopApp, pkgDataInfoList,
whitelistedDataInfoList, bindMountAppDataDirs, bindMountAppStorageDirs, mountSyspropOverrides);

nativeSpecializeAppProcess_post(env, clazz, uid, startChildZygote);
}

[[clang::no_stack_protector]]
void nativeSpecializeAppProcess_samsung_q(
JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags,
Expand Down
28 changes: 28 additions & 0 deletions riru/src/main/cpp/jni_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ using nativeForkAndSpecialize_r_dp3_t = jint(
jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList,
jboolean bindMountAppStorageDirs);

const static char *nativeForkAndSpecialize_u_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZZ)I";

using nativeForkAndSpecialize_u_t = jint(
JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring,
jintArray, jintArray, jboolean, jstring, jstring, jboolean, jobjectArray, jobjectArray,
jboolean, jboolean, jboolean);

[[clang::no_stack_protector]] jint nativeForkAndSpecialize_u(
JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtime_flags,
jobjectArray rlimits, jint mount_external, jstring se_info, jstring se_name,
jintArray fdsToClose, jintArray fdsToIgnore, jboolean is_child_zygote,
jstring instructionSet, jstring appDataDir, jboolean isTopApp, jobjectArray pkgDataInfoList,
jobjectArray whitelistedDataInfoList, jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs,
jboolean mountSyspropOverrides);

const static char *nativeForkAndSpecialize_samsung_p_sig = "(II[II[[IILjava/lang/String;IILjava/lang/String;[I[IZLjava/lang/String;Ljava/lang/String;)I";

using nativeForkAndSpecialize_samsung_p_t = jint(
Expand Down Expand Up @@ -199,6 +214,19 @@ using nativeSpecializeAppProcess_r_dp3_t = void(
jboolean startChildZygote, jstring instructionSet, jstring appDataDir,
jboolean isTopApp, jobjectArray pkgDataInfoList, jboolean bindMountAppStorageDirs);

const static char *nativeSpecializeAppProcess_u_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z[Ljava/lang/String;[Ljava/lang/String;ZZZ)V";

using nativeSpecializeAppProcess_u_t = void(
JNIEnv *, jclass, jint, jint, jintArray, jint, jobjectArray, jint, jstring, jstring,
jboolean, jstring, jstring, jboolean, jobjectArray, jobjectArray, jboolean, jboolean, jboolean);

[[clang::no_stack_protector]] void nativeSpecializeAppProcess_u(
JNIEnv *env, jclass clazz, jint uid, jint gid, jintArray gids, jint runtimeFlags,
jobjectArray rlimits, jint mountExternal, jstring seInfo, jstring niceName,
jboolean startChildZygote, jstring instructionSet, jstring appDataDir,
jboolean isTopApp, jobjectArray pkgDataInfoList, jobjectArray whitelistedDataInfoList,
jboolean bindMountAppDataDirs, jboolean bindMountAppStorageDirs, jboolean mountSyspropOverrides);

const static char *nativeSpecializeAppProcess_q_alternative_sig = "(II[II[[IILjava/lang/String;Ljava/lang/String;ZLjava/lang/String;Ljava/lang/String;Z)V";

using nativeSpecializeAppProcess_q_alternative_t = void(
Expand Down

0 comments on commit ec0fbd6

Please sign in to comment.