Class LEB128Info

java.lang.Object
ghidra.app.util.bin.LEB128Info

public class LEB128Info extends Object
Class to hold result of reading a LEB128 value, along with size and position metadata.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    int
    Returns the value as an signed int32.
    long
    Returns the value as a 64bit primitive long.
    int
    Returns the value as an unsigned int32.
    int
    Returns the number of bytes that were used to store the LEB128 value in the stream it was read from.
    long
    Returns the offset of the LEB128 value in the stream it was read from.
    static LEB128Info
    readValue(BinaryReader reader, boolean isSigned)
    Reads a LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.
    static LEB128Info
    Reads an signed LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.
     
    static LEB128Info
    Reads an unsigned LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details Link icon

    • unsigned Link icon

      public static LEB128Info unsigned(BinaryReader reader) throws IOException
      Reads an unsigned LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.

      Parameters:
      reader - BinaryReader to read bytes from
      Returns:
      a LEB128Info instance with the read LEB128 value with metadata
      Throws:
      IOException - if an I/O error occurs or value is outside the range of a java 64 bit int
    • signed Link icon

      public static LEB128Info signed(BinaryReader reader) throws IOException
      Reads an signed LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.

      Parameters:
      reader - BinaryReader to read bytes from
      Returns:
      a LEB128Info instance with the read LEB128 value with metadata
      Throws:
      IOException - if an I/O error occurs or value is outside the range of a java 64 bit int
    • asUInt32 Link icon

      public int asUInt32() throws IOException
      Returns the value as an unsigned int32. If the actual value is outside the positive range of a java int (ie. 0.. Integer.MAX_VALUE), an exception is thrown.
      Returns:
      int in the range of 0 to Integer.MAX_VALUE
      Throws:
      IOException - if value is outside range
    • asInt32 Link icon

      public int asInt32() throws IOException
      Returns the value as an signed int32. If the actual value is outside the range of a java int (ie. Integer.MIN_VALUE.. Integer.MAX_VALUE), an exception is thrown.
      Returns:
      int in the range of Integer.MIN_VALUE to Integer.MAX_VALUE
      Throws:
      IOException - if value is outside range
    • asLong Link icon

      public long asLong()
      Returns the value as a 64bit primitive long. Interpreting the signed-ness of the value will depend on the way the value was read (ie. if signed(BinaryReader) vs. unsigned(BinaryReader) was used).
      Returns:
      long value.
    • getOffset Link icon

      public long getOffset()
      Returns the offset of the LEB128 value in the stream it was read from.
      Returns:
      stream offset of the LEB128 value
    • getLength Link icon

      public int getLength()
      Returns the number of bytes that were used to store the LEB128 value in the stream it was read from.
      Returns:
      number of bytes used to store the read LEB128 value
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • readValue Link icon

      public static LEB128Info readValue(BinaryReader reader, boolean isSigned) throws IOException
      Reads a LEB128 value from the BinaryReader and returns a LEB128Info instance that contains the value along with size and position metadata.

      Parameters:
      reader - BinaryReader to read bytes from
      isSigned - true if the value is signed
      Returns:
      a LEB128Info instance with the read LEB128 value with metadata
      Throws:
      IOException - if an I/O error occurs or value is outside the range of a java 64 bit int