mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +02:00
Add support for specifying a base dir for the BOOTCLASSPATH files
git-svn-id: https://smali.googlecode.com/svn/trunk@629 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -50,7 +50,7 @@ public class baksmali {
|
|||||||
public static DeodexUtil deodexUtil = null;
|
public static DeodexUtil deodexUtil = null;
|
||||||
|
|
||||||
public static void disassembleDexFile(DexFile dexFile, Deodexerant deodexerant, String outputDirectory,
|
public static void disassembleDexFile(DexFile dexFile, Deodexerant deodexerant, String outputDirectory,
|
||||||
String bootClassPath, boolean noParameterRegisters,
|
String bootClassPathDir, String bootClassPath, boolean noParameterRegisters,
|
||||||
boolean useLocalsDirective, boolean useSequentialLabels,
|
boolean useLocalsDirective, boolean useSequentialLabels,
|
||||||
boolean outputDebugInfo, int registerInfo)
|
boolean outputDebugInfo, int registerInfo)
|
||||||
{
|
{
|
||||||
@ -62,7 +62,7 @@ public class baksmali {
|
|||||||
baksmali.bootClassPath = bootClassPath;
|
baksmali.bootClassPath = bootClassPath;
|
||||||
|
|
||||||
if (registerInfo != 0) {
|
if (registerInfo != 0) {
|
||||||
ClassPath.InitializeClassPath(bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
ClassPath.InitializeClassPath(bootClassPathDir, bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deodexerant != null) {
|
if (deodexerant != null) {
|
||||||
|
@ -92,6 +92,7 @@ public class main {
|
|||||||
String inputDexFileName = null;
|
String inputDexFileName = null;
|
||||||
String deodexerantHost = null;
|
String deodexerantHost = null;
|
||||||
String bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
String bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
||||||
|
String bootClassPathDir = ".";
|
||||||
int deodexerantPort = 0;
|
int deodexerantPort = 0;
|
||||||
|
|
||||||
String[] remainingArgs = commandLine.getArgs();
|
String[] remainingArgs = commandLine.getArgs();
|
||||||
@ -192,6 +193,10 @@ public class main {
|
|||||||
bootClassPath = commandLine.getOptionValue("c");
|
bootClassPath = commandLine.getOptionValue("c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commandLine.hasOption("C")) {
|
||||||
|
bootClassPathDir = commandLine.getOptionValue("C");
|
||||||
|
}
|
||||||
|
|
||||||
if (commandLine.hasOption("x")) {
|
if (commandLine.hasOption("x")) {
|
||||||
String deodexerantAddress = commandLine.getOptionValue("x");
|
String deodexerantAddress = commandLine.getOptionValue("x");
|
||||||
String[] parts = deodexerantAddress.split(":");
|
String[] parts = deodexerantAddress.split(":");
|
||||||
@ -247,8 +252,8 @@ public class main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (disassemble) {
|
if (disassemble) {
|
||||||
baksmali.disassembleDexFile(dexFile, deodexerant, outputDirectory, bootClassPath, noParameterRegisters,
|
baksmali.disassembleDexFile(dexFile, deodexerant, outputDirectory, bootClassPathDir, bootClassPath,
|
||||||
useLocalsDirective, useSequentialLabels, outputDebugInfo, registerInfo);
|
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, registerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((doDump || write) && !dexFile.isOdex()) {
|
if ((doDump || write) && !dexFile.isOdex()) {
|
||||||
@ -373,11 +378,19 @@ public class main {
|
|||||||
.create("r");
|
.create("r");
|
||||||
|
|
||||||
Option classPathOption = OptionBuilder.withLongOpt("bootclasspath")
|
Option classPathOption = OptionBuilder.withLongOpt("bootclasspath")
|
||||||
.withDescription("the bootclasspath jars to use, for analysis")
|
.withDescription("the bootclasspath jars to use, for analysis. Defaults to " +
|
||||||
|
"core.jar:ext.jar:framework.jar:android.policy.jar:services.jar")
|
||||||
.hasOptionalArg()
|
.hasOptionalArg()
|
||||||
.withArgName("BOOTCLASSPATH")
|
.withArgName("BOOTCLASSPATH")
|
||||||
.create("c");
|
.create("c");
|
||||||
|
|
||||||
|
Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir")
|
||||||
|
.withDescription("the base folder to look for the bootclasspath files in. Defaults to the current " +
|
||||||
|
"directory")
|
||||||
|
.hasArg()
|
||||||
|
.withArgName("DIR")
|
||||||
|
.create("C");
|
||||||
|
|
||||||
options.addOption(versionOption);
|
options.addOption(versionOption);
|
||||||
options.addOption(helpOption);
|
options.addOption(helpOption);
|
||||||
options.addOption(dumpOption);
|
options.addOption(dumpOption);
|
||||||
@ -393,5 +406,6 @@ public class main {
|
|||||||
options.addOption(noDebugInfoOption);
|
options.addOption(noDebugInfoOption);
|
||||||
options.addOption(registerInfoOption);
|
options.addOption(registerInfoOption);
|
||||||
options.addOption(classPathOption);
|
options.addOption(classPathOption);
|
||||||
|
options.addOption(classPathDirOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,23 +17,23 @@ public class ClassPath {
|
|||||||
private final HashMap<String, ClassDef> classDefs;
|
private final HashMap<String, ClassDef> classDefs;
|
||||||
protected ClassDef javaLangObjectClassDef; //Ljava/lang/Object;
|
protected ClassDef javaLangObjectClassDef; //Ljava/lang/Object;
|
||||||
|
|
||||||
public static void InitializeClassPath(String[] bootClassPath, DexFile dexFile) {
|
public static void InitializeClassPath(String bootClassPathDir, String[] bootClassPath, DexFile dexFile) {
|
||||||
if (theClassPath != null) {
|
if (theClassPath != null) {
|
||||||
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
|
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
|
||||||
}
|
}
|
||||||
|
|
||||||
theClassPath = new ClassPath();
|
theClassPath = new ClassPath();
|
||||||
theClassPath.initClassPath(bootClassPath, dexFile);
|
theClassPath.initClassPath(bootClassPathDir, bootClassPath, dexFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClassPath() {
|
private ClassPath() {
|
||||||
classDefs = new HashMap<String, ClassDef>();
|
classDefs = new HashMap<String, ClassDef>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initClassPath(String[] bootClassPath, DexFile dexFile) {
|
private void initClassPath(String bootClassPathDir, String[] bootClassPath, DexFile dexFile) {
|
||||||
if (bootClassPath != null) {
|
if (bootClassPath != null) {
|
||||||
for (String bootClassPathEntry: bootClassPath) {
|
for (String bootClassPathEntry: bootClassPath) {
|
||||||
loadBootClassPath(bootClassPathEntry);
|
loadBootClassPath(bootClassPathDir, bootClassPathEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ public class ClassPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBootClassPath(String bootClassPathEntry) {
|
private void loadBootClassPath(String bootClassPathDir, String bootClassPathEntry) {
|
||||||
File file = new File(bootClassPathEntry);
|
File file = new File(bootClassPathDir, bootClassPathEntry);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new ExceptionWithContext("ClassPath entry \"" + bootClassPathEntry + "\" does not exist.");
|
throw new ExceptionWithContext("ClassPath entry \"" + bootClassPathEntry + "\" does not exist.");
|
||||||
|
Reference in New Issue
Block a user