Add the ability to specify the oat version to use when listing vtables

This commit is contained in:
Ben Gruver 2016-09-24 18:26:35 -07:00
parent a54523e080
commit 7cb0937324
2 changed files with 15 additions and 6 deletions

View File

@ -46,8 +46,6 @@ import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.jf.dexlib2.analysis.ClassPath.NOT_ART;
public class AnalysisArguments {
@Parameter(names = {"-a", "--api"},
description = "The numeric api level of the file being disassembled.")
@ -87,7 +85,13 @@ public class AnalysisArguments {
@Nonnull
public ClassPath loadClassPathForDexFile(@Nonnull File dexFileDir, @Nonnull DexFile dexFile,
boolean checkPackagePrivateAccess)
boolean checkPackagePrivateAccess) throws IOException {
return loadClassPathForDexFile(dexFileDir, dexFile, checkPackagePrivateAccess, 0);
}
@Nonnull
public ClassPath loadClassPathForDexFile(@Nonnull File dexFileDir, @Nonnull DexFile dexFile,
boolean checkPackagePrivateAccess, int oatVersion)
throws IOException {
ClassPathResolver resolver;
@ -125,8 +129,7 @@ public class AnalysisArguments {
resolver = new ClassPathResolver(filteredClassPathDirectories, bootClassPath, classPath, dexFile);
}
int oatVersion = NOT_ART;
if (dexFile instanceof OatDexFile) {
if (oatVersion == 0 && dexFile instanceof OatDexFile) {
oatVersion = ((OatDexFile)dexFile).getContainer().getOatVersion();
}
return new ClassPath(resolver.getResolvedClassProviders(), checkPackagePrivateAccess, oatVersion);

View File

@ -68,6 +68,12 @@ public class ListVtablesCommand extends DexInputCommand {
@ExtendedParameter(argumentNames = "classes")
private List<String> classes = null;
@Parameter(names = "--override-oat-version",
description = "Uses a classpath for the given oat version, regardless of the actual oat version. This " +
"can be used, e.g. to list vtables from a dex file, as if they were in an oat file of the given " +
"version.")
private int oatVersion = 0;
public ListVtablesCommand(@Nonnull List<JCommander> commandAncestors) {
super(commandAncestors);
}
@ -139,7 +145,7 @@ public class ListVtablesCommand extends DexInputCommand {
try {
options.classPath = analysisArguments.loadClassPathForDexFile(inputFile.getAbsoluteFile().getParentFile(),
dexFile, checkPackagePrivateArgument.checkPackagePrivateAccess);
dexFile, checkPackagePrivateArgument.checkPackagePrivateAccess, oatVersion);
} catch (Exception ex) {
System.err.println("Error occurred while loading class path files.");
ex.printStackTrace(System.err);