Skip to content

Commit c932102

Browse files
author
weishu.tws
committed
Merge branch 'master' of github.com:android-hacker/exposed
# Conflicts: # exposed-core/src/main/java/me/weishu/exposed/ExposedBridge.java
2 parents 046844b + 5a3c98a commit c932102

File tree

2 files changed

+48
-32
lines changed

2 files changed

+48
-32
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.8'
34+
version = '0.5.9'
3535

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

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

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class ExposedBridge {
7070
public static final String BASE_DIR = Build.VERSION.SDK_INT >= 24
7171
? "/data/user_de/0/de.robv.android.xposed.installer/" : BASE_DIR_LEGACY;
7272

73-
private static final String WECHAT = decodeFromBase64("Y29tLnRlbmNlbnQubW0=");
73+
final static String WECHAT = decodeFromBase64("Y29tLnRlbmNlbnQubW0=");
7474

7575
private static final int FAKE_XPOSED_VERSION = 91;
7676
private static final String VERSION_KEY = "version";
@@ -81,6 +81,9 @@ public class ExposedBridge {
8181
private static ClassLoader xposedClassLoader;
8282

8383
private static Context appContext;
84+
private static String currentPackage;
85+
private static boolean yieldMode = false;
86+
8487
private static ModuleLoadListener sModuleLoadListener = new ModuleLoadListener() {
8588
@Override
8689
public void onLoadingModule(String moduleClassName, ApplicationInfo applicationInfo, ClassLoader appClassLoader) {
@@ -108,6 +111,8 @@ public static void initOnce(Context context, ApplicationInfo applicationInfo, Cl
108111
// SYSTEM_CLASSLOADER_INJECT = patchSystemClassLoader();
109112
XposedBridge.XPOSED_BRIDGE_VERSION = FAKE_XPOSED_VERSION;
110113
appContext = context;
114+
initForPackage(context, applicationInfo);
115+
111116
ReLinker.loadLibrary(context, "epic");
112117
ExposedHelper.initSeLinux(applicationInfo.processName);
113118
XSharedPreferences.setPackageBaseDirectory(new File(applicationInfo.dataDir).getParentFile());
@@ -118,6 +123,31 @@ public static void initOnce(Context context, ApplicationInfo applicationInfo, Cl
118123
initForQQ(context, applicationInfo, appClassLoader);
119124
}
120125

126+
private static void initForPackage(Context context, ApplicationInfo applicationInfo) {
127+
do {
128+
if (applicationInfo == null) {
129+
break;
130+
}
131+
String pkg = applicationInfo.packageName;
132+
if (pkg == null) {
133+
break;
134+
}
135+
currentPackage = pkg;
136+
137+
} while (false);
138+
139+
if (currentPackage == null) {
140+
currentPackage = context.getPackageName();
141+
}
142+
143+
String yieldModeConfig = System.getProperty("yieldMode");
144+
if ("true".equals(yieldModeConfig)) {
145+
yieldMode = true;
146+
XposedBridge.log("yield mode take effect");
147+
}
148+
System.setProperty("vxp", "1");
149+
}
150+
121151
private static boolean patchSystemClassLoader() {
122152
// 1. first create XposedClassLoader -> BootstrapClassLoader
123153
ClassLoader xposedClassLoader = new XposedClassLoader(ExposedBridge.class.getClassLoader());
@@ -212,10 +242,6 @@ public static ModuleLoadResult loadModule(final String moduleApkPath, String mod
212242
if (moduleClassName.isEmpty() || moduleClassName.startsWith("#"))
213243
continue;
214244

215-
if (filterModuleForApp(currentApplicationInfo, moduleClassName)) {
216-
XposedBridge.log("ignore module: " + moduleClassName + " for application: " + currentApplicationInfo.packageName);
217-
continue;
218-
}
219245
try {
220246
log(" Loading class " + moduleClassName);
221247
Class<?> moduleClass = mcl.loadClass(moduleClassName);
@@ -270,6 +296,22 @@ public static ModuleLoadResult loadModule(final String moduleApkPath, String mod
270296
}
271297

272298
private static boolean ignoreHooks(Member member) {
299+
if (member == null) {
300+
return false;
301+
}
302+
303+
if (!yieldMode) {
304+
return false;
305+
}
306+
307+
String name = member.getDeclaringClass().getName();
308+
if (WECHAT.equals(currentPackage)) {
309+
if (name.contains("wcdb")) {
310+
Log.i("mylog", "ignore hook for: " + name);
311+
return true;
312+
}
313+
}
314+
273315
return false;
274316
}
275317

@@ -330,32 +372,6 @@ private static boolean filterApplication(ApplicationInfo applicationInfo) {
330372
return false;
331373
}
332374

333-
private static boolean filterModuleForApp(ApplicationInfo applicationInfo, String moduleEntry) {
334-
if (applicationInfo == null || applicationInfo.packageName == null) {
335-
return false;
336-
}
337-
338-
final String WECHAT_JUMP_HELPER = "com.emily.mmjumphelper.xposed.XposedMain";
339-
340-
if (WECHAT.equals(applicationInfo.packageName)) {
341-
if (applicationInfo.processName.contains("appbrand")) {
342-
// wechat app brand
343-
if (WECHAT_JUMP_HELPER.equals(moduleEntry)) {
344-
// now only load module for appbrand.
345-
return false;
346-
} else {
347-
return true;
348-
}
349-
} else {
350-
if (WECHAT_JUMP_HELPER.equals(moduleEntry)) {
351-
return true;
352-
}
353-
}
354-
}
355-
356-
return false;
357-
}
358-
359375
private static void initForXposedInstaller(Context context, ApplicationInfo applicationInfo, ClassLoader appClassLoader) {
360376
if (!isXposedInstaller(applicationInfo)) {
361377
return;

0 commit comments

Comments
 (0)