Class DexUtil

java.lang.Object
org.jf.dexlib2.util.DexUtil

public class DexUtil extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    verifyCdexHeader(byte[] buf, int offset)
    Verifies that the cdex header is valid and a supported version
    static int
    verifyDexHeader(byte[] buf, int offset)
    Verifies that the dex header is valid and a supported version
    static int
    Reads in the dex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
    static void
    verifyOdexHeader(byte[] buf, int offset)
    Verifies that the odex header is valid and a supported version
    static void
    Reads in the odex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DexUtil

      public DexUtil()
  • Method Details

    • verifyDexHeader

      public static int verifyDexHeader(@Nonnull InputStream inputStream) throws IOException
      Reads in the dex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
      Parameters:
      inputStream - An input stream that is positioned at a dex header
      Returns:
      The dex version
      Throws:
      DexBackedDexFile.NotADexFile - If the file is not a dex file
      DexUtil.InvalidFile - If the header appears to be a dex file, but is not valid for some reason
      DexUtil.UnsupportedFile - If the dex header is valid, but uses unsupported functionality
      IOException
    • verifyDexHeader

      public static int verifyDexHeader(@Nonnull byte[] buf, int offset)
      Verifies that the dex header is valid and a supported version
      Parameters:
      buf - A byte array containing at least the first 44 bytes of a dex file
      offset - The offset within the array to the dex header
      Returns:
      The dex version
      Throws:
      DexBackedDexFile.NotADexFile - If the file is not a dex file
      DexUtil.InvalidFile - If the header appears to be a dex file, but is not valid for some reason
      DexUtil.UnsupportedFile - If the dex header is valid, but uses unsupported functionality
    • verifyCdexHeader

      public static int verifyCdexHeader(@Nonnull byte[] buf, int offset)
      Verifies that the cdex header is valid and a supported version
      Parameters:
      buf - A byte array containing at least the first 44 bytes of a cdex file
      offset - The offset within the array to the dex header
      Returns:
      The dex version
      Throws:
      DexBackedDexFile.NotADexFile - If the file is not a cdex file
      DexUtil.InvalidFile - If the header appears to be a cdex file, but is not valid for some reason
      DexUtil.UnsupportedFile - If the cdex header is valid, but uses unsupported functionality
    • verifyOdexHeader

      public static void verifyOdexHeader(@Nonnull InputStream inputStream) throws IOException
      Reads in the odex header from the given input stream and verifies that it is valid and a supported version The inputStream must support mark(), and will be reset to initial position upon exiting the method
      Parameters:
      inputStream - An input stream that is positioned at an odex header
      Throws:
      DexBackedOdexFile.NotAnOdexFile - If the file is not an odex file
      DexUtil.UnsupportedFile - If the odex header is valid, but is an unsupported version
      IOException
    • verifyOdexHeader

      public static void verifyOdexHeader(@Nonnull byte[] buf, int offset)
      Verifies that the odex header is valid and a supported version
      Parameters:
      buf - A byte array containing at least the first 8 bytes of an odex file
      offset - The offset within the array to the odex header
      Throws:
      DexBackedOdexFile.NotAnOdexFile - If the file is not an odex file
      DexUtil.UnsupportedFile - If the odex header is valid, but uses unsupported functionality