Ghidra is a software reverse engineering (SRE) framework
Renamed and reorganized VDEX classes.
lazybinding-dev957589183720
diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/oat/bundle/FullOatBundle.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/oat/bundle/FullOatBundle.javaindex 52e89f8895..ee5daa49bf 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/oat/bundle/FullOatBundle.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/oat/bundle/FullOatBundle.java@@ -306,7 +306,7 @@ public class FullOatBundle implements OatBundle {return true;}case VDEX: {- VdexHeader vdexHeader = VdexFactory.getVdexHeader(reader);+ VdexHeader vdexHeader = VdexHeaderFactory.getVdexHeader(reader);vdexHeader.parse(reader, monitor);this.vdexHeader = vdexHeader;return true;diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/UnsupportedVdexVersionException.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/UnsupportedVdexVersionException.javaindex a8cefe4efd..5861a8cd99 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/UnsupportedVdexVersionException.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/UnsupportedVdexVersionException.java@@ -17,11 +17,11 @@ package ghidra.file.formats.android.vdex;public final class UnsupportedVdexVersionException extends Exception {- UnsupportedVdexVersionException(String magic, String version) {+ public UnsupportedVdexVersionException(String magic, String version) {super("Unsupported VDEX version: " + version);}- UnsupportedVdexVersionException(String message) {+ public UnsupportedVdexVersionException(String message) {super(message);}}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexConstants.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexConstants.javaindex 6874a245b6..a5d558768c 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexConstants.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexConstants.java@@ -29,7 +29,7 @@ import ghidra.program.model.mem.MemoryBlock;* VDEX files contain extracted DEX files. The VdexFile class maps the file to* memory and provides tools for accessing its individual sections.*- * https://android.googlesource.com/platform/art/+/master/runtime/vdex_file.h+ * <a href="https://android.googlesource.com/platform/art/+/master/runtime/vdex_file.h">master/runtime/vdex_file.h</a>*/public final class VdexConstants {@@ -40,24 +40,38 @@ public final class VdexConstants {*/public final static String MAGIC = "vdex";- /** https://android.googlesource.com/platform/art/+/refs/heads/o-preview/runtime/vdex_file.h#64 */- public final static String version_o_preview = "003";- /** https://android.googlesource.com/platform/art/+/refs/heads/oreo-release/runtime/vdex_file.h#69 */- public final static String VERSION_OREO_RELEASE = "006";- /** https://android.googlesource.com/platform/art/+/refs/heads/oreo-m2-release/runtime/vdex_file.h#76 */- public final static String VERSION_OREO_M2_RELEASE = "010";- /** https://android.googlesource.com/platform/art/+/refs/heads/o-iot-preview-5/runtime/vdex_file.h#76 */- public final static String version_o_iot_preview_5 = "010";- /** https://android.googlesource.com/platform/art/+/refs/heads/o-mr1-iot-preview-6/runtime/vdex_file.h#76 */- public final static String version_o_mr1_iot_preview_6 = "011";- /** https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h#96 */- public final static String VERSION_PIE_RELEASE = "019";- /** https://android.googlesource.com/platform/art/+/refs/heads/android10-release/runtime/vdex_file.h#118 */- public final static String VERSION_10_RELEASE = "021";- /** https://android.googlesource.com/platform/art/+/refs/heads/android11-release/runtime/vdex_file.h#118 */- public final static String VERSION_11_RELEASE = "021";- /** https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#127 */- public final static String VERSION_12_RELEASE = "027";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/o-preview/runtime/vdex_file.h#64">o-preview/runtime/vdex_file.h</a>+ */+ public final static String vdex_version_003 = "003";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/oreo-release/runtime/vdex_file.h#69">oreo-release/runtime/vdex_file.h</a>+ */+ public final static String VDEX_VERSION_006 = "006";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/oreo-m2-release/runtime/vdex_file.h#76">oreo-m2-release/runtime/vdex_file.h</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/o-iot-preview-5/runtime/vdex_file.h#76">o-iot-preview-5/runtime/vdex_file.h</a>+ */+ public final static String VDEX_VERSION_010 = "010";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/o-mr1-iot-preview-6/runtime/vdex_file.h#76">o-mr1-iot-preview-6/runtime/vdex_file.h</a>+ */+ public final static String vdex_version_011 = "011";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h#96">pie-release/runtime/vdex_file.h</a>+ */+ public final static String VDEX_VERSION_019 = "019";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android10-release/runtime/vdex_file.h#118">android10-release/runtime/vdex_file.h</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android11-release/runtime/vdex_file.h#118">android11-release/runtime/vdex_file</a>+ */+ public final static String VDEX_VERSION_021 = "021";+ /**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#127">android12-release/runtime/vdex_file.h</a>+ */+ public final static String VDEX_VERSION_027 = "027";/*** The format version of the dex section header and the dex section,@@ -84,12 +98,11 @@ public final class VdexConstants {*///@formatter:offpublic final static String[] SUPPORTED_VERSIONS = new String[] {- VERSION_OREO_RELEASE,- VERSION_OREO_M2_RELEASE,- VERSION_PIE_RELEASE,- VERSION_10_RELEASE,- VERSION_11_RELEASE,- VERSION_12_RELEASE,+ VDEX_VERSION_006,+ VDEX_VERSION_010,+ VDEX_VERSION_019,+ VDEX_VERSION_021,+ VDEX_VERSION_027,};//@formatter:ondiff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFileSystem.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFileSystem.javaindex 1d731a869c..612d62da55 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFileSystem.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFileSystem.java@@ -55,7 +55,7 @@ public class VdexFileSystem extends GFileSystemBase {monitor.setMessage("Parsing VDEX header...");BinaryReader reader = new BinaryReader(provider, true /* TODO always LE??? */ );try {- header = VdexFactory.getVdexHeader(reader);+ header = VdexHeaderFactory.getVdexHeader(reader);header.parse(reader, monitor);for (int i = 0; i < header.getDexHeaderList().size(); ++i) {diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader.javaindex 0523aa00b2..bbdb825b8e 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader.java@@ -22,13 +22,15 @@ import java.util.List;import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.StructConverter;import ghidra.file.formats.android.dex.format.DexHeader;+import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;+import ghidra.program.model.data.*;import ghidra.util.exception.CancelledException;+import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;public abstract class VdexHeader implements StructConverter {protected String magic_;- protected String verifier_deps_version_;protected VdexStringTable stringTable;protected List<Long> dexHeaderStartsList = new ArrayList<>();@@ -38,32 +40,30 @@ public abstract class VdexHeader implements StructConverter {magic_ = new String(reader.readNextByteArray(VdexConstants.MAGIC.length()));}- final public String getMagic() {+ public final String getMagic() {return magic_;}- final public String getVerifierDepsVersion() {- return verifier_deps_version_;- }+ public abstract String getVersion();- abstract public void parse(BinaryReader reader, TaskMonitor monitor)+ public abstract void parse(BinaryReader reader, TaskMonitor monitor)throws IOException, CancelledException;- final public long getDexStartOffset(int index) {+ public final long getDexStartOffset(int index) {return dexHeaderStartsList.get(index);}- abstract public int getVerifierDepsSize();+ public abstract int getVerifierDepsSize();- abstract public int getQuickeningInfoSize();+ public abstract int getQuickeningInfoSize();- abstract public int[] getDexChecksums();+ public abstract int[] getDexChecksums();/*** Returns the list of DEX headers contained in this VDEX.* Could return empty list depending on version of VDEX.*/- final public List<DexHeader> getDexHeaderList() {+ public final List<DexHeader> getDexHeaderList() {return dexHeaderList;}@@ -71,11 +71,20 @@ public abstract class VdexHeader implements StructConverter {* Returns the VDEX String Table.* Note: Could be NULL.*/- final public VdexStringTable getStringTable() {+ public final VdexStringTable getStringTable() {return stringTable;}- abstract public boolean isDexHeaderEmbeddedInDataType();+ public abstract boolean isDexHeaderEmbeddedInDataType();++ public abstract DexSectionHeader_002 getDexSectionHeader_002();- abstract public DexSectionHeader_002 getDexSectionHeader_002();+ @Override+ public DataType toDataType() throws DuplicateNameException, IOException {+ Structure structure = new StructureDataType(+ magic_ + "_" + getVersion(), 0);+ structure.add(STRING, 4, "magic_", null);+ structure.setCategoryPath(new CategoryPath("/vdex"));+ return structure;+ }}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderAnalyzer.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderAnalyzer.javaindex 2f70e0d3a3..1ca1352e6f 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderAnalyzer.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderAnalyzer.java@@ -22,6 +22,7 @@ import ghidra.app.util.importer.MessageLog;import ghidra.file.analyzers.FileFormatAnalyzer;import ghidra.file.formats.android.dex.format.DexHeader;import ghidra.file.formats.android.oat.OatUtilities;+import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;import ghidra.program.model.address.Address;import ghidra.program.model.address.AddressSetView;import ghidra.program.model.data.ArrayDataType;@@ -77,7 +78,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {ByteProvider provider = new MemoryByteProvider(program.getMemory(), address);BinaryReader reader = new BinaryReader(provider, !program.getLanguage().isBigEndian());try {- VdexHeader vdexHeader = VdexFactory.getVdexHeader(reader);+ VdexHeader vdexHeader = VdexHeaderFactory.getVdexHeader(reader);vdexHeader.parse(reader, monitor);DataType vdexHeaderDataType = vdexHeader.toDataType();@@ -139,7 +140,7 @@ public class VdexHeaderAnalyzer extends FileFormatAnalyzer {private Address createVerifierDepsSize(Program program, Address address, VdexHeader vdexHeader)throws Exception {- if (vdexHeader.getVerifierDepsVersion() != VdexConstants.VERSION_10_RELEASE) {+ if (vdexHeader.getVersion() != VdexConstants.VDEX_VERSION_021) {return address;}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFactory.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderFactory.javasimilarity index 68%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFactory.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderFactory.javaindex 3d7a2cc80a..869cbb73a7 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexFactory.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeaderFactory.java@@ -18,9 +18,9 @@ package ghidra.file.formats.android.vdex;import java.io.IOException;import ghidra.app.util.bin.BinaryReader;-import ghidra.file.formats.android.vdex.android12.VdexHeader_12;+import ghidra.file.formats.android.vdex.headers.*;-public final class VdexFactory {+public final class VdexHeaderFactory {/*** Returns an VDEX Header for the specified version.@@ -35,21 +35,20 @@ public final class VdexFactory {String version = reader.readAsciiString(4, 4);if (magic.equals(VdexConstants.MAGIC)) {if (VdexConstants.isSupportedVersion(version)) {- if (version.equals(VdexConstants.VERSION_OREO_RELEASE) ||- version.equals(VdexConstants.VERSION_OREO_M2_RELEASE)) {- return new VdexHeader_Oreo(reader);+ if (version.equals(VdexConstants.VDEX_VERSION_006)) {+ return new VdexHeader_006(reader);}- if (version.equals(VdexConstants.VERSION_PIE_RELEASE)) {- return new VdexHeader_Pie(reader);+ else if (version.equals(VdexConstants.VDEX_VERSION_010)) {+ return new VdexHeader_010(reader);}- if (version.equals(VdexConstants.VERSION_10_RELEASE)) {- return new VdexHeader_10(reader);+ else if (version.equals(VdexConstants.VDEX_VERSION_019)) {+ return new VdexHeader_019(reader);}- if (version.equals(VdexConstants.VERSION_11_RELEASE)) {- return new VdexHeader_11(reader);+ else if (version.equals(VdexConstants.VDEX_VERSION_021)) {+ return new VdexHeader_021(reader);}- if (version.equals(VdexConstants.VERSION_12_RELEASE)) {- return new VdexHeader_12(reader);+ else if (version.equals(VdexConstants.VDEX_VERSION_027)) {+ return new VdexHeader_027(reader);}}}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexStringTable.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexStringTable.javaindex 1453c7ac0f..8b6a850893 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexStringTable.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexStringTable.java@@ -19,7 +19,8 @@ import java.io.IOException;import java.util.ArrayList;import java.util.List;-import ghidra.app.util.bin.*;+import ghidra.app.util.bin.BinaryReader;+import ghidra.app.util.bin.StructConverter;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;@@ -28,7 +29,7 @@ public class VdexStringTable implements StructConverter {private int stringCount;//note only 1 byte in sizeprivate List<String> strings = new ArrayList<>();- VdexStringTable(BinaryReader reader) throws IOException {+ public VdexStringTable(BinaryReader reader) throws IOException {stringCount = Byte.toUnsignedInt(reader.readNextByte());for (int i = 0; i < stringCount; ++i) {strings.add(reader.readNextAsciiString());diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Oreo.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_006.javasimilarity index 86%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Oreo.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_006.javaindex 14d24799e9..26dacc3daf 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Oreo.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_006.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex;+package ghidra.file.formats.android.vdex.headers;import java.io.IOException;@@ -21,16 +21,19 @@ import ghidra.app.util.bin.*;import ghidra.file.formats.android.dex.DexHeaderFactory;import ghidra.file.formats.android.dex.format.DexHeader;import ghidra.file.formats.android.dex.format.DexHeaderQuickMethods;+import ghidra.file.formats.android.vdex.VdexHeader;+import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;import ghidra.program.model.data.*;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;/**- * https://android.googlesource.com/platform/art/+/refs/heads/oreo-release/runtime/vdex_file.h- * https://android.googlesource.com/platform/art/+/refs/heads/oreo-m2-release/runtime/vdex_file.h+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/oreo-release/runtime/vdex_file.h">oreo-release/runtime/vdex_file.h</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/oreo-m2-release/runtime/vdex_file.h">oreo-m2-release/runtime/vdex_file.h</a>*/-public class VdexHeader_Oreo extends VdexHeader {+public class VdexHeader_006 extends VdexHeader {private String version_;private int number_of_dex_files_;@@ -39,7 +42,7 @@ public class VdexHeader_Oreo extends VdexHeader {private int quickening_info_size_;private int[] dex_checksums_;- public VdexHeader_Oreo(BinaryReader reader) throws IOException {+ public VdexHeader_006(BinaryReader reader) throws IOException {super(reader);version_ = reader.readNextAsciiString(4);number_of_dex_files_ = reader.readNextInt();@@ -111,9 +114,8 @@ public class VdexHeader_Oreo extends VdexHeader {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- Structure structure = new StructureDataType(- VdexHeader_Oreo.class.getSimpleName() + "_" + number_of_dex_files_, 0);- structure.add(STRING, 4, "magic_", null);+ Structure structure = (Structure) super.toDataType();+structure.add(STRING, 4, "version_", null);structure.add(DWORD, "number_of_dex_files_", null);structure.add(DWORD, "dex_size_", null);@@ -139,7 +141,6 @@ public class VdexHeader_Oreo extends VdexHeader {if (stringTable != null) {structure.add(stringTable.toDataType(), "strings", null);}- structure.setCategoryPath(new CategoryPath("/vdex"));return structure;}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_11.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_010.javasimilarity index 55%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_11.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_010.javaindex d5fc7cb06c..91cb4b1480 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_11.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_010.java@@ -13,29 +13,19 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex;+package ghidra.file.formats.android.vdex.headers;import java.io.IOException;import ghidra.app.util.bin.BinaryReader;-import ghidra.program.model.data.DataType;-import ghidra.util.exception.DuplicateNameException;-public class VdexHeader_11 extends VdexHeader_10 {-- public VdexHeader_11(BinaryReader reader) throws IOException, UnsupportedVdexVersionException {+/**+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/oreo-m2-release/runtime/vdex_file.h#76">oreo-m2-release/runtime/vdex_file.h</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/o-iot-preview-5/runtime/vdex_file.h#76">o-iot-preview-5/runtime/vdex_file.h</a>+ */+public class VdexHeader_010 extends VdexHeader_006 {+ public VdexHeader_010(BinaryReader reader) throws IOException {super(reader);}-- @Override- public DataType toDataType() throws DuplicateNameException, IOException {- DataType dataType = super.toDataType();- try {- dataType.setName(VdexHeader_11.class.getSimpleName());- }- catch (Exception e) {- //ignore...- }- return dataType;- }}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Pie.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_019.javasimilarity index 87%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Pie.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_019.javaindex 84b29a35c6..dc8cb3f677 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_Pie.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_019.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex;+package ghidra.file.formats.android.vdex.headers;import java.io.IOException;import java.util.ArrayList;@@ -23,16 +23,19 @@ import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.ByteProviderWrapper;import ghidra.file.formats.android.dex.DexHeaderFactory;import ghidra.file.formats.android.dex.format.DexHeader;+import ghidra.file.formats.android.vdex.*;+import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;import ghidra.program.model.data.*;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;/**- * https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h">pie-release/runtime/vdex_file.h</a>*/-public class VdexHeader_Pie extends VdexHeader {+public class VdexHeader_019 extends VdexHeader {+ private String verifier_deps_version_;private String dex_section_version_;private int number_of_dex_files_;private int verifier_deps_size_;@@ -40,7 +43,7 @@ public class VdexHeader_Pie extends VdexHeader {private DexSectionHeader_002 sectionHeader;private List<Integer> quickenTableOffsetList = new ArrayList<>();- public VdexHeader_Pie(BinaryReader reader) throws IOException, UnsupportedVdexVersionException {+ public VdexHeader_019(BinaryReader reader) throws IOException, UnsupportedVdexVersionException {super(reader);verifier_deps_version_ = reader.readNextAsciiString(4);@@ -83,6 +86,11 @@ public class VdexHeader_Pie extends VdexHeader {}}+ @Override+ public String getVersion() {+ return verifier_deps_version_;+ }+public void parse(BinaryReader reader, TaskMonitor monitor)throws IOException, CancelledException {//do nothing@@ -124,9 +132,8 @@ public class VdexHeader_Pie extends VdexHeader {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- Structure structure = new StructureDataType(- VdexHeader_Pie.class.getSimpleName() + "_" + number_of_dex_files_, 0);- structure.add(STRING, 4, "magic_", null);+ Structure structure = (Structure) super.toDataType();+structure.add(STRING, 4, "verifier_deps_version_", null);structure.add(STRING, 4, "dex_section_version_", null);structure.add(DWORD, "number_of_dex_files_", null);@@ -140,7 +147,6 @@ public class VdexHeader_Pie extends VdexHeader {if (stringTable != null) {structure.add(stringTable.toDataType(), "strings", null);}- structure.setCategoryPath(new CategoryPath("/vdex"));return structure;}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_10.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_021.javasimilarity index 87%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_10.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_021.javaindex 51070a2589..b3b58c3922 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/VdexHeader_10.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_021.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex;+package ghidra.file.formats.android.vdex.headers;import java.io.IOException;import java.util.ArrayList;@@ -23,16 +23,19 @@ import ghidra.app.util.bin.BinaryReader;import ghidra.app.util.bin.ByteProviderWrapper;import ghidra.file.formats.android.dex.DexHeaderFactory;import ghidra.file.formats.android.dex.format.DexHeader;+import ghidra.file.formats.android.vdex.*;+import ghidra.file.formats.android.vdex.sections.DexSectionHeader_002;import ghidra.program.model.data.*;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;/**- * https://android.googlesource.com/platform/art/+/refs/heads/android10-release/runtime/vdex_file.h+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android10-release/runtime/vdex_file.h">android10-release/runtime/vdex_file.h</a>*/-public class VdexHeader_10 extends VdexHeader {+public class VdexHeader_021 extends VdexHeader {+ private String verifier_deps_version_;private String dex_section_version_;private int number_of_dex_files_;private int verifier_deps_size_;@@ -42,7 +45,7 @@ public class VdexHeader_10 extends VdexHeader {private DexSectionHeader_002 sectionHeader;private List<Integer> quickenTableOffsetList = new ArrayList<>();- public VdexHeader_10(BinaryReader reader) throws IOException, UnsupportedVdexVersionException {+ public VdexHeader_021(BinaryReader reader) throws IOException, UnsupportedVdexVersionException {super(reader);verifier_deps_version_ = reader.readNextAsciiString(4);dex_section_version_ = reader.readNextAsciiString(4);@@ -88,6 +91,11 @@ public class VdexHeader_10 extends VdexHeader {}}+ @Override+ public String getVersion() {+ return verifier_deps_version_;+ }+public void parse(BinaryReader reader, TaskMonitor monitor)throws IOException, CancelledException {//do nothing@@ -137,9 +145,8 @@ public class VdexHeader_10 extends VdexHeader {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- Structure structure = new StructureDataType(- VdexHeader_10.class.getSimpleName() + "_" + number_of_dex_files_, 0);- structure.add(STRING, 4, "magic_", null);+ Structure structure = (Structure) super.toDataType();+structure.add(STRING, 4, "verifier_deps_version_", null);structure.add(STRING, 4, "dex_section_version_", null);structure.add(DWORD, "number_of_dex_files_", null);@@ -155,7 +162,6 @@ public class VdexHeader_10 extends VdexHeader {if (stringTable != null && stringTable.getStringCount() > 0) {structure.add(stringTable.toDataType(), "strings", null);}- structure.setCategoryPath(new CategoryPath("/vdex"));return structure;}diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexHeader_12.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_027.javasimilarity index 75%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexHeader_12.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_027.javaindex 1b462c12be..1f24a8c867 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexHeader_12.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/headers/VdexHeader_027.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex.android12;+package ghidra.file.formats.android.vdex.headers;import java.io.IOException;import java.util.ArrayList;@@ -26,39 +26,45 @@ import ghidra.app.util.bin.ByteProviderWrapper;import ghidra.file.formats.android.dex.DexHeaderFactory;import ghidra.file.formats.android.dex.format.DexHeader;import ghidra.file.formats.android.vdex.*;+import ghidra.file.formats.android.vdex.sections.*;import ghidra.program.model.data.*;import ghidra.util.exception.CancelledException;import ghidra.util.exception.DuplicateNameException;import ghidra.util.task.TaskMonitor;/**- * https://android.googlesource.com/platform/art/+/refs/heads/android-s-beta-5/runtime/vdex_file.h#129- *- * https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#129- *- * https://android.googlesource.com/platform/art/+/refs/heads/android13-release/runtime/vdex_file.h#129+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android-s-beta-5/runtime/vdex_file.h#129">android-s-beta-5/runtime/vdex_file.h#129</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#129">android12-release/runtime/vdex_file.h#129</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android13-release/runtime/vdex_file.h#129">android13-release/runtime/vdex_file.h#129</a>*/-public class VdexHeader_12 extends VdexHeader {+public class VdexHeader_027 extends VdexHeader {private String vdex_version_;private int number_of_sections_;- private List<VdexSectionHeader_12> sections = new ArrayList<>();+ private List<VdexSectionHeader_S_T> sections = new ArrayList<>();private List<Integer> checksums = new ArrayList<>();- public VdexHeader_12(BinaryReader reader)+ public VdexHeader_027(BinaryReader reader)throws IOException, UnsupportedVdexVersionException {super(reader);vdex_version_ = reader.readNextAsciiString(4);number_of_sections_ = reader.readNextInt();}+ @Override+ public String getVersion() {+ return vdex_version_;+ }+@Overridepublic void parse(BinaryReader reader, TaskMonitor monitor)throws IOException, CancelledException {for (int i = 0; i < number_of_sections_; ++i) {monitor.checkCanceled();- sections.add(new VdexSectionHeader_12(reader));+ sections.add(new VdexSectionHeader_S_T(reader));}parseChecksums(reader, monitor);@@ -69,8 +75,8 @@ public class VdexHeader_12 extends VdexHeader {private void parseChecksums(BinaryReader reader, TaskMonitor monitor)throws CancelledException, IOException {- VdexSectionHeader_12 checksumSection =- sections.get(VdexSection_12.kChecksumSection.ordinal());+ VdexSectionHeader_S_T checksumSection =+ sections.get(VdexSection_S_T.kChecksumSection.ordinal());if (checksumSection.getSectionSize() > 0) {reader.setPointerIndex(checksumSection.getSectionOffset());for (int i = 0; i < checksumSection.getSectionSize() / 4; ++i) {@@ -82,8 +88,8 @@ public class VdexHeader_12 extends VdexHeader {private void parseDexFiles(BinaryReader reader, TaskMonitor monitor)throws CancelledException, IOException {- VdexSectionHeader_12 dexFileSection =- sections.get(VdexSection_12.kDexFileSection.ordinal());+ VdexSectionHeader_S_T dexFileSection =+ sections.get(VdexSection_S_T.kDexFileSection.ordinal());if (dexFileSection.getSectionSize() > 0) {reader.setPointerIndex(dexFileSection.getSectionOffset());@@ -103,8 +109,8 @@ public class VdexHeader_12 extends VdexHeader {private void parseVerifierDeps(BinaryReader reader, TaskMonitor monitor)throws CancelledException, IOException {- VdexSectionHeader_12 verifierDepsSection =- sections.get(VdexSection_12.kVerifierDepsSection.ordinal());+ VdexSectionHeader_S_T verifierDepsSection =+ sections.get(VdexSection_S_T.kVerifierDepsSection.ordinal());if (verifierDepsSection.getSectionSize() > 0) {reader.setPointerIndex(verifierDepsSection.getSectionOffset());//TODO@@ -113,8 +119,8 @@ public class VdexHeader_12 extends VdexHeader {private void parseTypeLookupTable(BinaryReader reader, TaskMonitor monitor)throws CancelledException, IOException {- VdexSectionHeader_12 typeLookupTableSection =- sections.get(VdexSection_12.kTypeLookupTableSection.ordinal());+ VdexSectionHeader_S_T typeLookupTableSection =+ sections.get(VdexSection_S_T.kTypeLookupTableSection.ordinal());if (typeLookupTableSection.getSectionSize() > 0) {reader.setPointerIndex(typeLookupTableSection.getSectionOffset());//TODO@@ -152,8 +158,8 @@ public class VdexHeader_12 extends VdexHeader {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- Structure structure = new StructureDataType(VdexHeader_12.class.getSimpleName(), 0);- structure.add(STRING, 4, "magic_", null);+ Structure structure = (Structure) super.toDataType();+structure.add(STRING, 4, "vdex_version_", null);structure.add(DWORD, "number_of_sections_", null);@@ -173,8 +179,8 @@ public class VdexHeader_12 extends VdexHeader {}private void toDataTypeDexFile(Structure structure) {- VdexSectionHeader_12 dexFileSection =- sections.get(VdexSection_12.kDexFileSection.ordinal());+ VdexSectionHeader_S_T dexFileSection =+ sections.get(VdexSection_S_T.kDexFileSection.ordinal());if (dexFileSection.getSectionSize() > 0) {DataType array =new ArrayDataType(BYTE, dexFileSection.getSectionSize(), BYTE.getLength());@@ -183,8 +189,8 @@ public class VdexHeader_12 extends VdexHeader {}private void toDataTypeVerifierDeps(Structure structure) {- VdexSectionHeader_12 verifierDepsSection =- sections.get(VdexSection_12.kVerifierDepsSection.ordinal());+ VdexSectionHeader_S_T verifierDepsSection =+ sections.get(VdexSection_S_T.kVerifierDepsSection.ordinal());if (verifierDepsSection.getSectionSize() > 0) {DataType array =new ArrayDataType(BYTE, verifierDepsSection.getSectionSize(), BYTE.getLength());@@ -193,8 +199,8 @@ public class VdexHeader_12 extends VdexHeader {}private void toDataTypeTypeLookupTable(Structure structure) {- VdexSectionHeader_12 typeLookupTableSection =- sections.get(VdexSection_12.kTypeLookupTableSection.ordinal());+ VdexSectionHeader_S_T typeLookupTableSection =+ sections.get(VdexSection_S_T.kTypeLookupTableSection.ordinal());if (typeLookupTableSection.getSectionSize() > 0) {DataType array =new ArrayDataType(BYTE, typeLookupTableSection.getSectionSize(), BYTE.getLength());diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/DexSectionHeader_002.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/DexSectionHeader_002.javasimilarity index 85%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/DexSectionHeader_002.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/DexSectionHeader_002.javaindex f88734cc49..601960eec8 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/DexSectionHeader_002.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/DexSectionHeader_002.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex;+package ghidra.file.formats.android.vdex.sections;import java.io.IOException;@@ -23,7 +23,7 @@ import ghidra.program.model.data.DataType;import ghidra.util.exception.DuplicateNameException;/**- * https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h#114+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/pie-release/runtime/vdex_file.h#114">pie-release/runtime/vdex_file.h#114</a>*/public class DexSectionHeader_002 implements StructConverter {@@ -31,7 +31,7 @@ public class DexSectionHeader_002 implements StructConverter {private int dex_shared_data_size_;private int quickening_info_size_;- DexSectionHeader_002(BinaryReader reader) throws IOException {+ public DexSectionHeader_002(BinaryReader reader) throws IOException {dex_size_ = reader.readNextInt();dex_shared_data_size_ = reader.readNextInt();quickening_info_size_ = reader.readNextInt();diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSectionHeader_12.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSectionHeader_S_T.javasimilarity index 65%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSectionHeader_12.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSectionHeader_S_T.javaindex 7203dde307..11c7d27a92 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSectionHeader_12.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSectionHeader_S_T.java@@ -13,7 +13,7 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex.android12;+package ghidra.file.formats.android.vdex.sections;import java.io.IOException;@@ -23,25 +23,23 @@ import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;/**- * https://android.googlesource.com/platform/art/+/refs/heads/android-s-beta-5/runtime/vdex_file.h#92- *- * https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#92- *- * https://android.googlesource.com/platform/art/+/refs/heads/android13-release/runtime/vdex_file.h#92+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#92">android12-release/runtime/vdex_file.h#92</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android13-release/runtime/vdex_file.h#92">android13-release/runtime/vdex_file.h#92</a>*/-public class VdexSectionHeader_12 implements StructConverter {+public class VdexSectionHeader_S_T implements StructConverter {- private VdexSection_12 section_kind;+ private VdexSection_S_T section_kind;private int section_offset;private int section_size;- public VdexSectionHeader_12(BinaryReader reader) throws IOException {- section_kind = VdexSection_12.values()[reader.readNextInt()];+ public VdexSectionHeader_S_T(BinaryReader reader) throws IOException {+ section_kind = VdexSection_S_T.values()[reader.readNextInt()];section_offset = reader.readNextInt();section_size = reader.readNextInt();}- public VdexSection_12 getSectionKind() {+ public VdexSection_S_T getSectionKind() {return section_kind;}@@ -55,7 +53,7 @@ public class VdexSectionHeader_12 implements StructConverter {@Overridepublic DataType toDataType() throws DuplicateNameException, IOException {- String className = VdexSectionHeader_12.class.getSimpleName();+ String className = VdexSectionHeader_S_T.class.getSimpleName();Structure structure = new StructureDataType(className, 0);structure.add(DWORD, "section_kind", null);structure.add(DWORD, "section_offset", null);diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSection_12.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSection_S_T.javasimilarity index 63%rename from Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSection_12.javarename to Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSection_S_T.javaindex 1d8f7f0d08..f3217a8b82 100644--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/android12/VdexSection_12.java+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/vdex/sections/VdexSection_S_T.java@@ -13,13 +13,14 @@* See the License for the specific language governing permissions and* limitations under the License.*/-package ghidra.file.formats.android.vdex.android12;+package ghidra.file.formats.android.vdex.sections;/**- * https://android.googlesource.com/platform/art/+/refs/heads/android-s-beta-5/runtime/vdex_file.h#80- *+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android12-release/runtime/vdex_file.h#80">android12-release/runtime/vdex_file.h#80</a>+ * <br>+ * <a href="https://android.googlesource.com/platform/art/+/refs/heads/android13-release/runtime/vdex_file.h#80">android13-release/runtime/vdex_file.h#80</a>*/-public enum VdexSection_12 {+public enum VdexSection_S_T {kChecksumSection,kDexFileSection,kVerifierDepsSection,