mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 04:27:38 +02:00
Add support for the new dey36 odex header
git-svn-id: https://smali.googlecode.com/svn/trunk@725 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
@ -175,6 +175,7 @@ public class DexFile
|
|||||||
*/
|
*/
|
||||||
private boolean isOdex = false;
|
private boolean isOdex = false;
|
||||||
|
|
||||||
|
private OdexHeader odexHeader;
|
||||||
private OdexDependencies odexDependencies;
|
private OdexDependencies odexDependencies;
|
||||||
|
|
||||||
private int dataOffset;
|
private int dataOffset;
|
||||||
@ -332,25 +333,21 @@ public class DexFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] dexMagic, odexMagic;
|
byte[] dexMagic, odexMagic;
|
||||||
|
boolean isDex = false;
|
||||||
|
this.isOdex = false;
|
||||||
|
|
||||||
dexMagic = org.jf.dexlib.HeaderItem.MAGIC;
|
if (Arrays.equals(magic, HeaderItem.MAGIC)) {
|
||||||
odexMagic = OdexHeader.MAGIC;
|
isDex = true;
|
||||||
|
} else if (Arrays.equals(magic, OdexHeader.MAGIC_35)) {
|
||||||
boolean isDex = true;
|
isOdex = true;
|
||||||
this.isOdex = true;
|
} else if (Arrays.equals(magic, OdexHeader.MAGIC_36)) {
|
||||||
for (int i=0; i<8; i++) {
|
isOdex = true;
|
||||||
if (magic[i] != dexMagic[i]) {
|
|
||||||
isDex = false;
|
|
||||||
}
|
|
||||||
if (magic[i] != odexMagic[i]) {
|
|
||||||
isOdex = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOdex) {
|
if (isOdex) {
|
||||||
byte[] odexHeaderBytes = FileUtils.readStream(inputStream, 40);
|
byte[] odexHeaderBytes = FileUtils.readStream(inputStream, 40);
|
||||||
Input odexHeaderIn = new ByteArrayInput(odexHeaderBytes);
|
Input odexHeaderIn = new ByteArrayInput(odexHeaderBytes);
|
||||||
OdexHeader odexHeader = new OdexHeader(odexHeaderIn);
|
odexHeader = new OdexHeader(odexHeaderIn);
|
||||||
|
|
||||||
int dependencySkip = odexHeader.depsOffset - odexHeader.dexOffset - odexHeader.dexLength;
|
int dependencySkip = odexHeader.depsOffset - odexHeader.dexOffset - odexHeader.dexLength;
|
||||||
if (dependencySkip < 0) {
|
if (dependencySkip < 0) {
|
||||||
@ -536,6 +533,14 @@ public class DexFile
|
|||||||
return odexDependencies;
|
return odexDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return An OdexHeader object containing the information from the odex header in this dex file, or null if there
|
||||||
|
* is no odex header
|
||||||
|
*/
|
||||||
|
public OdexHeader getOdexHeader() {
|
||||||
|
return odexHeader;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a boolean value indicating whether items in this dex file should be
|
* Get a boolean value indicating whether items in this dex file should be
|
||||||
* written back out "in-place", or whether the normal layout logic should be
|
* written back out "in-place", or whether the normal layout logic should be
|
||||||
|
@ -30,13 +30,15 @@ package org.jf.dexlib;
|
|||||||
|
|
||||||
import org.jf.dexlib.Util.Input;
|
import org.jf.dexlib.Util.Input;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class OdexHeader {
|
public class OdexHeader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the file format magic number, represented as the
|
* the possible file format magic numbers, represented as the low-order bytes of a string.
|
||||||
* low-order bytes of a string
|
|
||||||
*/
|
*/
|
||||||
public static final byte[] MAGIC = new byte[] {0x64, 0x65, 0x79, 0x0A, 0x30, 0x33, 0x35, 0x00};//"dey\n035" + '\0';
|
public static final byte[] MAGIC_35 = new byte[] {0x64, 0x65, 0x79, 0x0A, 0x30, 0x33, 0x35, 0x00}; //"dey\n035" + '\0';
|
||||||
|
public static final byte[] MAGIC_36 = new byte[] {0x64, 0x65, 0x79, 0x0A, 0x30, 0x33, 0x36, 0x00}; //"dey\n036" + '\0';
|
||||||
|
|
||||||
public final byte[] magic;
|
public final byte[] magic;
|
||||||
public final int dexOffset;
|
public final int dexOffset;
|
||||||
@ -47,13 +49,17 @@ public class OdexHeader {
|
|||||||
public final int auxLength;
|
public final int auxLength;
|
||||||
public final int flags;
|
public final int flags;
|
||||||
|
|
||||||
|
public final int version;
|
||||||
|
|
||||||
public OdexHeader(Input in) {
|
public OdexHeader(Input in) {
|
||||||
magic = in.readBytes(8);
|
magic = in.readBytes(8);
|
||||||
|
|
||||||
for (int i=0; i<8; i++) {
|
if (Arrays.equals(MAGIC_35, magic)) {
|
||||||
if (MAGIC[i] != magic[i]) {
|
version = 35;
|
||||||
throw new RuntimeException("The magic value is not the expected value");
|
} else if (Arrays.equals(MAGIC_36, magic)) {
|
||||||
}
|
version = 36;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("The magic value is not one of the expected values");
|
||||||
}
|
}
|
||||||
|
|
||||||
dexOffset = in.readInt();
|
dexOffset = in.readInt();
|
||||||
@ -65,5 +71,4 @@ public class OdexHeader {
|
|||||||
flags = in.readInt();
|
flags = in.readInt();
|
||||||
in.readInt(); //padding
|
in.readInt(); //padding
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user