mirror of
https://github.com/revanced/smali.git
synced 2025-04-30 06:34:25 +02:00
Add a --classes option for disassemble/deodex commands
This commit is contained in:
parent
43669ecc6e
commit
22e85fc3ff
@ -36,12 +36,20 @@ import org.jf.dexlib2.iface.DexFile;
|
|||||||
import org.jf.util.ClassFileNameHandler;
|
import org.jf.util.ClassFileNameHandler;
|
||||||
import org.jf.util.IndentingWriter;
|
import org.jf.util.IndentingWriter;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
public class Baksmali {
|
public class Baksmali {
|
||||||
public static boolean disassembleDexFile(DexFile dexFile, File outputDir, int jobs, final BaksmaliOptions options) {
|
public static boolean disassembleDexFile(DexFile dexFile, File outputDir, int jobs, final BaksmaliOptions options) {
|
||||||
|
return disassembleDexFile(dexFile, outputDir, jobs, options, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean disassembleDexFile(DexFile dexFile, File outputDir, int jobs, final BaksmaliOptions options,
|
||||||
|
@Nullable List<String> classes) {
|
||||||
|
|
||||||
//sort the classes, so that if we're on a case-insensitive file system and need to handle classes with file
|
//sort the classes, so that if we're on a case-insensitive file system and need to handle classes with file
|
||||||
//name collisions, then we'll use the same name for each class, if the dex file goes through multiple
|
//name collisions, then we'll use the same name for each class, if the dex file goes through multiple
|
||||||
@ -54,7 +62,15 @@ public class Baksmali {
|
|||||||
ExecutorService executor = Executors.newFixedThreadPool(jobs);
|
ExecutorService executor = Executors.newFixedThreadPool(jobs);
|
||||||
List<Future<Boolean>> tasks = Lists.newArrayList();
|
List<Future<Boolean>> tasks = Lists.newArrayList();
|
||||||
|
|
||||||
|
Set<String> classSet = null;
|
||||||
|
if (classes != null) {
|
||||||
|
classSet = new HashSet<String>(classes);
|
||||||
|
}
|
||||||
|
|
||||||
for (final ClassDef classDef: classDefs) {
|
for (final ClassDef classDef: classDefs) {
|
||||||
|
if (classSet != null && !classSet.contains(classDef.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tasks.add(executor.submit(new Callable<Boolean>() {
|
tasks.add(executor.submit(new Callable<Boolean>() {
|
||||||
@Override public Boolean call() throws Exception {
|
@Override public Boolean call() throws Exception {
|
||||||
return disassembleClass(classDef, fileNameHandler, options);
|
return disassembleClass(classDef, fileNameHandler, options);
|
||||||
|
@ -133,6 +133,11 @@ public class DisassembleCommand extends DexInputCommand {
|
|||||||
"fields from the current class.")
|
"fields from the current class.")
|
||||||
private boolean implicitReferences = false;
|
private boolean implicitReferences = false;
|
||||||
|
|
||||||
|
@Parameter(names = "--classes",
|
||||||
|
description = "A comma separated list of classes. Only disassemble these classes")
|
||||||
|
@ExtendedParameter(argumentNames = "classes")
|
||||||
|
private List<String> classes = null;
|
||||||
|
|
||||||
public DisassembleCommand(@Nonnull List<JCommander> commandAncestors) {
|
public DisassembleCommand(@Nonnull List<JCommander> commandAncestors) {
|
||||||
super(commandAncestors);
|
super(commandAncestors);
|
||||||
}
|
}
|
||||||
@ -170,7 +175,7 @@ public class DisassembleCommand extends DexInputCommand {
|
|||||||
analysisArguments.classPathDirectories = Lists.newArrayList(inputFile.getAbsoluteFile().getParent());
|
analysisArguments.classPathDirectories = Lists.newArrayList(inputFile.getAbsoluteFile().getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Baksmali.disassembleDexFile(dexFile, outputDirectoryFile, jobs, getOptions())) {
|
if (!Baksmali.disassembleDexFile(dexFile, outputDirectoryFile, jobs, getOptions(), classes)) {
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user