@@ -86,22 +86,11 @@ static void loadDex(JNIEnv *env, jstring jdexPath, jstring jodexPath, jstring jc
8686 LOGD (" target method(%s) not found" , methodName);
8787 return ;
8888 }
89-
89+
9090 env->CallStaticVoidMethod (javaClientClass, targetMethod, jarg1);
9191}
9292
93-
94- // You can remove functions you don't need
95-
96- extern " C" {
97- #define EXPORT __attribute__ ((visibility(" default" ))) __attribute__((used))
98- EXPORT void nativeForkAndSpecializePre(
99- JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
100- jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
101- jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
102- jstring *instructionSet, jstring *appDataDir, jstring *packageName,
103- jobjectArray *packagesForUID, jstring *sandboxId) {
104- // packageName, packagesForUID, sandboxId are added from Android Q beta 2, removed from beta 5
93+ static void pre (JNIEnv *env, jstring *appDataDir, jstring *niceName) {
10594 char *cAppDataDir = jstringToC (env, *appDataDir);
10695 if (cAppDataDir == NULL ) {
10796 LOGD (" MEM ERR" );
@@ -120,25 +109,43 @@ EXPORT void nativeForkAndSpecializePre(
120109 }
121110}
122111
123- EXPORT int nativeForkAndSpecializePost (JNIEnv *env, jclass clazz, jint res) {
124- if (res == 0 ) {
125- // in app process
126- if (sHookEnable ) {
127- char appCacheDir[PATH_MAX] = {0 };
128- snprintf (appCacheDir, PATH_MAX - 1 , " %s/cache" , sAppDataDir );
112+ static void post (JNIEnv *env) {
113+ if (sHookEnable ) {
114+ char appCacheDir[PATH_MAX] = {0 };
115+ snprintf (appCacheDir, PATH_MAX - 1 , " %s/cache" , sAppDataDir );
129116
130- const char *dexPath = " /data/local/tmp/libriru_module_xfingerprint_pay_wechat.dex" ;
131- if (access (dexPath, 0 ) != 0 ) {
132- dexPath = " /system/framework/libriru_module_xfingerprint_pay_wechat.dex" ;
133- }
134- loadDex (env,
117+ const char *dexPath = " /data/local/tmp/libriru_module_xfingerprint_pay_wechat.dex" ;
118+ if (access (dexPath, 0 ) != 0 ) {
119+ dexPath = " /system/framework/libriru_module_xfingerprint_pay_wechat.dex" ;
120+ }
121+ loadDex (env,
135122 env->NewStringUTF (dexPath),
136123 env->NewStringUTF (appCacheDir),
137124 env->NewStringUTF (" com.yyxx.wechatfp.xposed.plugin.XposedWeChatPlugin" ),
138125 " main" ,
139126 env->NewStringUTF (sAppDataDir )
140- );
141- }
127+ );
128+ }
129+ }
130+
131+ // You can remove functions you don't need
132+
133+ extern " C" {
134+ #define EXPORT __attribute__ ((visibility(" default" ))) __attribute__((used))
135+ EXPORT void nativeForkAndSpecializePre(
136+ JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
137+ jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
138+ jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
139+ jstring *instructionSet, jstring *appDataDir, jboolean *isTopApp, jobjectArray *pkgDataInfoList,
140+ jobjectArray *whitelistedDataInfoList, jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs) {
141+ // packageName, packagesForUID, sandboxId are added from Android Q beta 2, removed from beta 5
142+ pre (env, appDataDir, niceName);
143+ }
144+
145+ EXPORT int nativeForkAndSpecializePost (JNIEnv *env, jclass clazz, jint res) {
146+ if (res == 0 ) {
147+ // in app process
148+ post (env);
142149 } else {
143150 // in zygote process, res is child pid
144151 // don't print log here, see https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66
@@ -150,15 +157,16 @@ EXPORT __attribute__((visibility("default"))) void specializeAppProcessPre(
150157 JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
151158 jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
152159 jboolean *startChildZygote, jstring *instructionSet, jstring *appDataDir,
153- jstring *packageName , jobjectArray *packagesForUID, jstring *sandboxId) {
154- // this is added from Android Q beta, but seems Google disabled this in following updates
155-
156- // packageName, packagesForUID, sandboxId are added from Android Q beta 2, removed from beta 5
160+ jboolean *isTopApp , jobjectArray *pkgDataInfoList, jobjectArray *whitelistedDataInfoList,
161+ jboolean *bindMountAppDataDirs, jboolean *bindMountAppStorageDirs) {
162+ // added from Android 10, but disabled at least in Google Pixel devices
163+ pre (env, appDataDir, niceName);
157164}
158165
159166EXPORT __attribute__ ((visibility(" default" ))) int specializeAppProcessPost(
160167 JNIEnv *env, jclass clazz) {
161- // this is added from Android Q beta, but seems Google disabled this in following updates
168+ // added from Android 10, but disabled at least in Google Pixel devices
169+ post (env);
162170 return 0 ;
163171}
164172
0 commit comments