mirror of
https://github.com/revanced/smali.git
synced 2025-05-05 00:54:25 +02:00
Allow multiple class path directories to be specified
git-svn-id: https://smali.googlecode.com/svn/trunk@639 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
e9b722eab0
commit
819e8b92a0
@ -50,7 +50,7 @@ public class baksmali {
|
||||
public static String bootClassPath;
|
||||
|
||||
public static void disassembleDexFile(DexFile dexFile, boolean deodex, String outputDirectory,
|
||||
String bootClassPathDir, String bootClassPath, boolean noParameterRegisters,
|
||||
String[] classPathDirs, String bootClassPath, boolean noParameterRegisters,
|
||||
boolean useLocalsDirective, boolean useSequentialLabels,
|
||||
boolean outputDebugInfo, boolean addCodeOffsets, int registerInfo)
|
||||
{
|
||||
@ -65,7 +65,7 @@ public class baksmali {
|
||||
|
||||
if (registerInfo != 0 || deodex) {
|
||||
try {
|
||||
ClassPath.InitializeClassPath(bootClassPathDir, bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
||||
ClassPath.InitializeClassPath(classPathDirs, bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
||||
} catch (Exception ex) {
|
||||
System.err.println("\n\nError occured while loading boot class path files. Aborting.");
|
||||
ex.printStackTrace(System.err);
|
||||
|
@ -3,6 +3,9 @@ package org.jf.baksmali;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.jf.dexlib.Code.Analysis.ClassPath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class deodexCheck {
|
||||
public static void main(String[] args) {
|
||||
CommandLineParser parser = new PosixParser();
|
||||
@ -18,7 +21,8 @@ public class deodexCheck {
|
||||
}
|
||||
|
||||
String bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
||||
String bootClassPathDir = ".";
|
||||
List<String> bootClassPathDirs = new ArrayList<String>();
|
||||
bootClassPathDirs.add(".");
|
||||
String deodexerantHost = null;
|
||||
int deodexerantPort = 0;
|
||||
int classStartIndex = 0;
|
||||
@ -59,8 +63,8 @@ public class deodexCheck {
|
||||
}
|
||||
}
|
||||
|
||||
if (commandLine.hasOption("C")) {
|
||||
bootClassPathDir = commandLine.getOptionValue("C");
|
||||
if (commandLine.hasOption("d")) {
|
||||
bootClassPathDirs.add(commandLine.getOptionValue("d"));
|
||||
}
|
||||
|
||||
if (commandLine.hasOption("x")) {
|
||||
@ -83,7 +87,12 @@ public class deodexCheck {
|
||||
}
|
||||
}
|
||||
|
||||
ClassPath.InitializeClassPath(bootClassPathDir, bootClassPath==null?null:bootClassPath.split(":"), null);
|
||||
String[] bootClassPathDirsArray = new String[bootClassPathDirs.size()];
|
||||
for (int i=0; i<bootClassPathDirsArray.length; i++) {
|
||||
bootClassPathDirsArray[i] = bootClassPathDirs.get(i);
|
||||
}
|
||||
|
||||
ClassPath.InitializeClassPath(bootClassPathDirsArray, bootClassPath==null?null:bootClassPath.split(":"), null);
|
||||
|
||||
ClassPath.validateAgainstDeodexerant(deodexerantHost, deodexerantPort, classStartIndex);
|
||||
}
|
||||
@ -119,10 +128,10 @@ public class deodexCheck {
|
||||
|
||||
Option classPathDirOption = OptionBuilder.withLongOpt("bootclasspath-dir")
|
||||
.withDescription("the base folder to look for the bootclasspath files in. Defaults to the current " +
|
||||
"directory")
|
||||
"directory.")
|
||||
.hasArg()
|
||||
.withArgName("DIR")
|
||||
.create("C");
|
||||
.create("d");
|
||||
|
||||
Option deodexerantOption = OptionBuilder.withLongOpt("deodexerant")
|
||||
.isRequired()
|
||||
|
@ -22,6 +22,8 @@ import org.jf.dexlib.DexFile;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class main {
|
||||
@ -96,7 +98,8 @@ public class main {
|
||||
String outputDexFileName = null;
|
||||
String inputDexFileName = null;
|
||||
String bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
||||
String bootClassPathDir = ".";
|
||||
List<String> bootClassPathDirs = new ArrayList<String>();
|
||||
bootClassPathDirs.add(".");
|
||||
|
||||
|
||||
String[] remainingArgs = commandLine.getArgs();
|
||||
@ -136,7 +139,7 @@ public class main {
|
||||
outputDebugInfo = false;
|
||||
break;
|
||||
case 'd':
|
||||
bootClassPathDir = commandLine.getOptionValue("d");
|
||||
bootClassPathDirs.add(option.getValue());
|
||||
break;
|
||||
case 'f':
|
||||
addCodeOffsets = true;
|
||||
@ -240,7 +243,12 @@ public class main {
|
||||
}
|
||||
|
||||
if (disassemble) {
|
||||
baksmali.disassembleDexFile(dexFile, deodex, outputDirectory, bootClassPathDir, bootClassPath,
|
||||
String[] bootClassPathDirsArray = new String[bootClassPathDirs.size()];
|
||||
for (int i=0; i<bootClassPathDirsArray.length; i++) {
|
||||
bootClassPathDirsArray[i] = bootClassPathDirs.get(i);
|
||||
}
|
||||
|
||||
baksmali.disassembleDexFile(dexFile, deodex, outputDirectory, bootClassPathDirsArray, bootClassPath,
|
||||
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, addCodeOffsets,
|
||||
registerInfo);
|
||||
}
|
||||
|
@ -17,23 +17,23 @@ public class ClassPath {
|
||||
private final HashMap<String, ClassDef> classDefs;
|
||||
protected ClassDef javaLangObjectClassDef; //Ljava/lang/Object;
|
||||
|
||||
public static void InitializeClassPath(String bootClassPathDir, String[] bootClassPath, DexFile dexFile) {
|
||||
public static void InitializeClassPath(String[] classPathDirs, String[] bootClassPath, DexFile dexFile) {
|
||||
if (theClassPath != null) {
|
||||
throw new ExceptionWithContext("Cannot initialize ClassPath multiple times");
|
||||
}
|
||||
|
||||
theClassPath = new ClassPath();
|
||||
theClassPath.initClassPath(bootClassPathDir, bootClassPath, dexFile);
|
||||
theClassPath.initClassPath(classPathDirs, bootClassPath, dexFile);
|
||||
}
|
||||
|
||||
private ClassPath() {
|
||||
classDefs = new HashMap<String, ClassDef>();
|
||||
}
|
||||
|
||||
private void initClassPath(String bootClassPathDir, String[] bootClassPath, DexFile dexFile) {
|
||||
private void initClassPath(String[] classPathDirs, String[] bootClassPath, DexFile dexFile) {
|
||||
if (bootClassPath != null) {
|
||||
for (String bootClassPathEntry: bootClassPath) {
|
||||
loadBootClassPath(bootClassPathDir, bootClassPathEntry);
|
||||
loadBootClassPath(classPathDirs, bootClassPathEntry);
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,11 +47,12 @@ public class ClassPath {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadBootClassPath(String bootClassPathDir, String bootClassPathEntry) {
|
||||
File file = new File(bootClassPathDir, bootClassPathEntry);
|
||||
private void loadBootClassPath(String[] classPathDirs, String bootClassPathEntry) {
|
||||
for (String classPathDir: classPathDirs) {
|
||||
File file = new File(classPathDir, bootClassPathEntry);
|
||||
|
||||
if (!file.exists()) {
|
||||
throw new ExceptionWithContext("ClassPath entry \"" + bootClassPathEntry + "\" does not exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!file.canRead()) {
|
||||
@ -62,11 +63,14 @@ public class ClassPath {
|
||||
try {
|
||||
dexFile = new DexFile(file, false, true);
|
||||
} catch (Exception ex) {
|
||||
throw ExceptionWithContext.withContext(ex, "Error while reading ClassPath entry \"" +
|
||||
throw ExceptionWithContext.withContext(ex, "Error while reading boot class path entry \"" +
|
||||
bootClassPathEntry + "\".");
|
||||
}
|
||||
|
||||
loadDexFile(dexFile);
|
||||
return;
|
||||
}
|
||||
throw new ExceptionWithContext(String.format("Cannot locate boot class path file %s", bootClassPathEntry));
|
||||
}
|
||||
|
||||
private void loadDexFile(DexFile dexFile) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user