mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-05 02:22:55 +01:00
Implement dex entry for non classes.dex files
Conflicts: brut.apktool.smali/dexlib2/src/main/java/org/jf/dexlib2/DexFileFactory.java
This commit is contained in:
parent
6b6c2c09b6
commit
89e6b06521
@ -56,6 +56,7 @@ public class baksmaliOptions {
|
||||
|
||||
public int apiLevel = 15;
|
||||
public String outputDirectory = "out";
|
||||
public String dexEntry = "classes.dex";
|
||||
public List<String> bootClassPathDirs = Lists.newArrayList();
|
||||
|
||||
public List<String> bootClassPathEntries = Lists.newArrayList();
|
||||
|
@ -208,6 +208,9 @@ public class main {
|
||||
case 't':
|
||||
options.useImplicitReferences = false;
|
||||
break;
|
||||
case 'e':
|
||||
options.dexEntry = commandLine.getOptionValue("e");
|
||||
break;
|
||||
case 'N':
|
||||
disassemble = false;
|
||||
break;
|
||||
@ -251,7 +254,7 @@ public class main {
|
||||
}
|
||||
|
||||
//Read in and parse the dex file
|
||||
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile, options.apiLevel);
|
||||
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile, options.dexEntry, options.apiLevel);
|
||||
|
||||
if (dexFile.isOdexFile()) {
|
||||
if (!options.deodex) {
|
||||
@ -450,6 +453,12 @@ public class main {
|
||||
.withArgName("FILE")
|
||||
.create("T");
|
||||
|
||||
Option dexEntryOption = OptionBuilder.withLongOpt("dex-file")
|
||||
.withDescription("looks for dex file named DEX_FILE, defaults to classes.dex")
|
||||
.withArgName("DEX_FILE")
|
||||
.hasArg()
|
||||
.create("e");
|
||||
|
||||
basicOptions.addOption(versionOption);
|
||||
basicOptions.addOption(helpOption);
|
||||
basicOptions.addOption(outputDirOption);
|
||||
@ -467,6 +476,7 @@ public class main {
|
||||
basicOptions.addOption(jobsOption);
|
||||
basicOptions.addOption(resourceIdFilesOption);
|
||||
basicOptions.addOption(noImplicitReferencesOption);
|
||||
basicOptions.addOption(dexEntryOption);
|
||||
|
||||
debugOptions.addOption(dumpOption);
|
||||
debugOptions.addOption(ignoreErrorsOption);
|
||||
|
@ -60,7 +60,7 @@ public final class DexFileFactory {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static DexBackedDexFile loadDexFile(File dexFile, String filename, @Nonnull Opcodes opcodes) throws IOException {
|
||||
public static DexBackedDexFile loadDexFile(File dexFile, String dexEntry, @Nonnull Opcodes opcodes) throws IOException {
|
||||
ZipFile zipFile = null;
|
||||
boolean isZipFile = false;
|
||||
try {
|
||||
@ -68,16 +68,16 @@ public final class DexFileFactory {
|
||||
// if we get here, it's safe to assume we have a zip file
|
||||
isZipFile = true;
|
||||
|
||||
ZipEntry zipEntry = zipFile.getEntry(filename);
|
||||
ZipEntry zipEntry = zipFile.getEntry(dexEntry);
|
||||
if (zipEntry == null) {
|
||||
throw new NoClassesDexException("zip file %s does not contain a classes.dex file", dexFile.getName());
|
||||
}
|
||||
long fileLength = zipEntry.getSize();
|
||||
if (fileLength < 40) {
|
||||
throw new ExceptionWithContext(
|
||||
"The " + filename + " file in %s is too small to be a valid dex file", dexFile.getName());
|
||||
"The " + dexEntry + " file in %s is too small to be a valid dex file", dexFile.getName());
|
||||
} else if (fileLength > Integer.MAX_VALUE) {
|
||||
throw new ExceptionWithContext("The " + filename + " file in %s is too large to read in", dexFile.getName());
|
||||
throw new ExceptionWithContext("The " + dexEntry + " file in %s is too large to read in", dexFile.getName());
|
||||
}
|
||||
byte[] dexBytes = new byte[(int)fileLength];
|
||||
ByteStreams.readFully(zipFile.getInputStream(zipEntry), dexBytes);
|
||||
|
Loading…
Reference in New Issue
Block a user