Created
November 13, 2018 17:45
-
-
Save MCMrARM/33a178daf05b6107ca08adb79ea643ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void extractInfo(ClassLoader loader) throws Exception { | |
BaseDexClassLoader dexLoader = (BaseDexClassLoader) loader; | |
Field pathListField = BaseDexClassLoader.class.getDeclaredField("pathList"); | |
pathListField.setAccessible(true); | |
Object pathList = pathListField.get(dexLoader); | |
Field dexElementsField = pathList.getClass().getDeclaredField("dexElements"); | |
dexElementsField.setAccessible(true); | |
Object[] dexElements = (Object[]) dexElementsField.get(pathList); | |
Field elementFileField = null; | |
for (Object dexElement : dexElements) { | |
if (elementFileField == null) { | |
try { | |
elementFileField = dexElement.getClass().getDeclaredField("path"); | |
} catch (NoSuchFieldException exception) { | |
elementFileField = dexElement.getClass().getDeclaredField("file"); | |
} | |
} | |
elementFileField.setAccessible(true); | |
Log.i("ClassLoaderHelper", "Path list entry: " + elementFileField.get(dexElement)); | |
} | |
Field nativeLibDirsField = pathList.getClass().getDeclaredField("nativeLibraryDirectories"); | |
nativeLibDirsField.setAccessible(true); | |
List<File> nativeLibDirs = (List<File>) nativeLibDirsField.get(pathList); | |
for (File dir : nativeLibDirs) { | |
Log.i("ClassLoaderHelper", "Native path list entry: " + dir); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment