diff --git a/baksmali/src/main/java/org/jf/baksmali/AnalysisArguments.java b/baksmali/src/main/java/org/jf/baksmali/AnalysisArguments.java index e7601901..83c4b13f 100644 --- a/baksmali/src/main/java/org/jf/baksmali/AnalysisArguments.java +++ b/baksmali/src/main/java/org/jf/baksmali/AnalysisArguments.java @@ -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); diff --git a/baksmali/src/main/java/org/jf/baksmali/ListVtablesCommand.java b/baksmali/src/main/java/org/jf/baksmali/ListVtablesCommand.java index e7f228a7..c44ae888 100644 --- a/baksmali/src/main/java/org/jf/baksmali/ListVtablesCommand.java +++ b/baksmali/src/main/java/org/jf/baksmali/ListVtablesCommand.java @@ -68,6 +68,12 @@ public class ListVtablesCommand extends DexInputCommand { @ExtendedParameter(argumentNames = "classes") private List 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 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);