mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 22:10:40 +00:00
Bypass DexFile's security check for RootService (#5911)
Old Android (pre 8.0) enforces `optimizedDirectory` to have the same uid with the process. If repackaged, root service (uid=0) will crash when trying to load current.apk. So we set `optimizedDirectory` to null to bypass the check.
This commit is contained in:
parent
351e094440
commit
a3381da7ed
@ -5,18 +5,19 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import dalvik.system.DexClassLoader;
|
||||
import dalvik.system.BaseDexClassLoader;
|
||||
|
||||
public class DynamicClassLoader extends DexClassLoader {
|
||||
public class DynamicClassLoader extends BaseDexClassLoader {
|
||||
|
||||
private static final ClassLoader base = Object.class.getClassLoader();
|
||||
|
||||
public DynamicClassLoader(File apk) {
|
||||
super(apk.getPath(), apk.getParent(), null, base);
|
||||
this(apk, base);
|
||||
}
|
||||
|
||||
public DynamicClassLoader(File apk, ClassLoader parent) {
|
||||
super(apk.getPath(), apk.getParent(), null, parent);
|
||||
// Set optimizedDirectory to null to bypass DexFile's security checks
|
||||
super(apk.getPath(), null, null, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user