mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
Add AnalysisArguments.loadClassPathForDexFile
This commit is contained in:
parent
7e8afc4d8a
commit
fb10b5731c
@ -33,9 +33,13 @@ package org.jf.baksmali;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.jf.dexlib2.analysis.ClassPath;
|
||||
import org.jf.dexlib2.iface.DexFile;
|
||||
import org.jf.util.jcommander.ColonParameterSplitter;
|
||||
import org.jf.util.jcommander.ExtendedParameter;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class AnalysisArguments {
|
||||
@ -45,17 +49,17 @@ public class AnalysisArguments {
|
||||
public int apiLevel = 15;
|
||||
|
||||
@Parameter(names = {"-b", "--bootclasspath", "--bcp"},
|
||||
description = "A colon separated list of the jar/oat files to include in the " +
|
||||
"bootclasspath when analyzing the dex file. If not specified, baksmali will attempt to choose an " +
|
||||
"appropriate default. This is analogous to Android's BOOTCLASSPATH environment variable.",
|
||||
description = "A colon separated list of the files to include in the bootclasspath when analyzing the dex " +
|
||||
"file. If not specified, baksmali will attempt to choose an " +
|
||||
"appropriate default. When analyzing oat files, this can simply be the path to the device's " +
|
||||
"boot.oat file. See baksmali help classpath for more information.",
|
||||
splitter = ColonParameterSplitter.class)
|
||||
@ExtendedParameter(argumentNames = "classpath")
|
||||
public List<String> bootClassPath = null;
|
||||
|
||||
@Parameter(names = {"-c", "--classpath", "--cp"},
|
||||
description = "A colon separated list of additional jar/oat files to include in the classpath " +
|
||||
"when analyzing the dex file. These will be added to the classpath after any bootclasspath " +
|
||||
"entries.",
|
||||
description = "A colon separated list of additional files to include in the classpath when analyzing the " +
|
||||
"dex file. These will be added to the classpath after any bootclasspath entries.",
|
||||
splitter = ColonParameterSplitter.class)
|
||||
@ExtendedParameter(argumentNames = "classpath")
|
||||
public List<String> classPath = Lists.newArrayList();
|
||||
@ -72,4 +76,10 @@ public class AnalysisArguments {
|
||||
"only be needed for 4.2.0 odexes. It was reverted in 4.2.1.")
|
||||
public boolean checkPackagePrivateAccess = false;
|
||||
}
|
||||
|
||||
public ClassPath loadClassPathForDexFile(@Nonnull DexFile dexFile, boolean checkPackagePrivateAccess)
|
||||
throws IOException {
|
||||
return ClassPath.loadClassPath(classPathDirectories, bootClassPath, classPath, dexFile, apiLevel,
|
||||
checkPackagePrivateAccess);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ import com.beust.jcommander.ParametersDelegate;
|
||||
import com.beust.jcommander.validators.PositiveInteger;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jf.dexlib2.analysis.ClassPath;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
import org.jf.dexlib2.iface.DexFile;
|
||||
import org.jf.dexlib2.util.SyntheticAccessorResolver;
|
||||
@ -191,9 +190,8 @@ public class DisassembleCommand extends DexInputCommand {
|
||||
|
||||
if (needsClassPath()) {
|
||||
try {
|
||||
options.classPath = ClassPath.loadClassPath(analysisArguments.classPathDirectories,
|
||||
analysisArguments.bootClassPath, analysisArguments.classPath, dexFile,
|
||||
analysisArguments.apiLevel, shouldCheckPackagePrivateAccess());
|
||||
options.classPath = analysisArguments.loadClassPathForDexFile(dexFile,
|
||||
shouldCheckPackagePrivateAccess());
|
||||
} catch (Exception ex) {
|
||||
System.err.println("\n\nError occurred while loading class path files. Aborting.");
|
||||
ex.printStackTrace(System.err);
|
||||
|
@ -35,7 +35,6 @@ import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.ParametersDelegate;
|
||||
import org.jf.dexlib2.analysis.ClassPath;
|
||||
import org.jf.dexlib2.analysis.ClassProto;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
import org.jf.dexlib2.iface.ClassDef;
|
||||
@ -106,9 +105,7 @@ public class ListFieldOffsetsCommand extends DexInputCommand {
|
||||
options.apiLevel = analysisArguments.apiLevel;
|
||||
|
||||
try {
|
||||
options.classPath = ClassPath.loadClassPath(analysisArguments.classPathDirectories,
|
||||
analysisArguments.bootClassPath, analysisArguments.classPath, dexFile, analysisArguments.apiLevel,
|
||||
false);
|
||||
options.classPath = analysisArguments.loadClassPathForDexFile(dexFile, false);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Error occurred while loading class path files.");
|
||||
ex.printStackTrace(System.err);
|
||||
|
@ -36,7 +36,6 @@ import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.beust.jcommander.ParametersDelegate;
|
||||
import org.jf.baksmali.AnalysisArguments.CheckPackagePrivateArgument;
|
||||
import org.jf.dexlib2.analysis.ClassPath;
|
||||
import org.jf.dexlib2.analysis.ClassProto;
|
||||
import org.jf.dexlib2.dexbacked.DexBackedDexFile;
|
||||
import org.jf.dexlib2.iface.ClassDef;
|
||||
@ -134,8 +133,7 @@ public class ListVtablesCommand extends DexInputCommand {
|
||||
options.apiLevel = analysisArguments.apiLevel;
|
||||
|
||||
try {
|
||||
options.classPath = ClassPath.loadClassPath(analysisArguments.classPathDirectories,
|
||||
analysisArguments.bootClassPath, analysisArguments.classPath, dexFile, analysisArguments.apiLevel,
|
||||
options.classPath = analysisArguments.loadClassPathForDexFile(dexFile,
|
||||
checkPackagePrivateArgument.checkPackagePrivateAccess);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("Error occurred while loading class path files.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user