Skip to content

Commit 9696683

Browse files
author
weishu.tws
committed
[VXP]: There is a bug in VA: /proc/<pid>/cmdline is incorrect, but can not fix it in short, so just bypass it by hook.
1 parent f1248a7 commit 9696683

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

exposed-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
}
3232

3333
group = 'me.weishu.exposed'
34-
version = '0.5.5'
34+
version = '0.5.6'
3535

3636
apply plugin: 'com.novoda.bintray-release'
3737

exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.content.pm.ApplicationInfo;
1010
import android.os.Build;
1111
import android.os.IBinder;
12+
import android.os.Process;
1213
import android.text.TextUtils;
1314
import android.util.Base64;
1415
import android.util.Log;
@@ -32,6 +33,7 @@
3233
import java.lang.reflect.Constructor;
3334
import java.lang.reflect.Field;
3435
import java.lang.reflect.Member;
36+
import java.util.Arrays;
3537
import java.util.HashMap;
3638
import java.util.HashSet;
3739
import java.util.Map;
@@ -156,7 +158,7 @@ public static synchronized ClassLoader getXposedClassLoader(ClassLoader hostClas
156158
}
157159

158160
public static ModuleLoadResult loadModule(final String moduleApkPath, String moduleOdexDir, String moduleLibPath,
159-
final ApplicationInfo currentApplicationInfo, ClassLoader appClassLoader) {
161+
final ApplicationInfo currentApplicationInfo, ClassLoader appClassLoader) {
160162

161163
if (isXposedInstaller(currentApplicationInfo)) {
162164
return ModuleLoadResult.IGNORED;
@@ -360,7 +362,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
360362
@Override
361363
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
362364
super.beforeHookedMethod(param);
363-
final String path = (String)param.args[0];
365+
final String path = (String) param.args[0];
364366
if (path.startsWith(BASE_DIR)) {
365367
param.args[0] = path.replace(BASE_DIR, path.equals(BASE_DIR) ? dataDir : dataDir + "/exposed_");
366368
}
@@ -370,7 +372,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
370372
@Override
371373
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
372374
super.beforeHookedMethod(param);
373-
final String path = (String)param.args[0];
375+
final String path = (String) param.args[0];
374376
if (path.startsWith(BASE_DIR)) {
375377
param.args[0] = path.replace(BASE_DIR, path.equals(BASE_DIR) ? dataDir : dataDir + "/exposed_");
376378
}
@@ -386,7 +388,7 @@ private static void initForWeChatTranslate(String moduleClassName, ApplicationIn
386388
return;
387389
}
388390

389-
if (!("com.hiwechart.translate".equals(applicationInfo.processName) || "com.tencent.mm".equals(applicationInfo.processName))){
391+
if (!("com.hiwechart.translate".equals(applicationInfo.processName) || "com.tencent.mm".equals(applicationInfo.processName))) {
390392
return;
391393
}
392394

@@ -457,6 +459,31 @@ private static void initForWechat(Context context, ApplicationInfo applicationIn
457459
deleteDir(tinker);
458460
deleteDir(tinker_temp);
459461
deleteDir(tinker_server);
462+
463+
final int mainProcessId = Process.myPid();
464+
XposedHelpers.findAndHookMethod(Process.class, "killProcess", int.class, new XC_MethodHook() {
465+
@Override
466+
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
467+
super.beforeHookedMethod(param);
468+
int pid = (int) param.args[0];
469+
if (pid != mainProcessId) {
470+
return;
471+
}
472+
// try kill main process, find stack
473+
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
474+
if (stackTrace == null) {
475+
return;
476+
}
477+
478+
for (StackTraceElement stackTraceElement : stackTrace) {
479+
if (stackTraceElement.getClassName().contains("com.tencent.mm.app")) {
480+
XposedBridge.log("do not suicide..." + Arrays.toString(stackTrace));
481+
param.setResult(null);
482+
break;
483+
}
484+
}
485+
}
486+
});
460487
}
461488
}
462489

@@ -478,6 +505,7 @@ public static boolean deleteDir(File dir) {
478505

479506
/**
480507
* avoid from being searched by google.
508+
*
481509
* @param base64
482510
* @return
483511
*/
@@ -487,9 +515,10 @@ private static String decodeFromBase64(String base64) {
487515

488516
/**
489517
* write xposed property file to fake xposedinstaller
518+
*
490519
* @param propertyFile the property file used by XposedInstaller
491-
* @param version to fake version
492-
* @param retry need retry, when retry, delete file and try again
520+
* @param version to fake version
521+
* @param retry need retry, when retry, delete file and try again
493522
*/
494523
private static void writeXposedProperty(File propertyFile, String version, boolean retry) {
495524
Properties properties = new Properties();
@@ -528,6 +557,7 @@ private static String getXposedVersionFromProperty(File propertyFile) {
528557

529558
/**
530559
* try read module config fules.
560+
*
531561
* @return is need check module
532562
*/
533563
private static boolean loadModuleConfig(String rootDir, String processName) {

0 commit comments

Comments
 (0)