Package ghidra.program.database.mem

# Class FileBytes

java.lang.Object
ghidra.program.database.mem.FileBytes

public class FileBytes extends Object
FileBytes provides access to the all the byte values (both original and modified) from an imported file.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FileBytes(ghidra.program.database.mem.FileBytesAdapter adapter, DBRecord record)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `String`
  `getFilename()`
  Returns the name of the file that supplied the bytes.
  `long`
  `getFileOffset()`
  Returns the offset in the original file from where these bytes originated.
  `byte`
  `getModifiedByte(long offset)`
  Returns the (possibly modified) byte at the given offset for this file bytes object.
  `int`
  `getModifiedBytes(long offset, byte[] b)`
  Tries to get b.length (possibly modified) bytes from this FileBytes entry at the given offset into the file bytes.
  `int`
  `getModifiedBytes(long offset, byte[] b, int off, int length)`
  Tries to get length (possibly modified) bytes from the files starting at the given offset and put them into the given byte array at the specified offset into the byte array.
  `byte`
  `getOriginalByte(long offset)`
  Returns the original byte value at the given offset for this file bytes object.
  `int`
  `getOriginalBytes(long offset, byte[] b)`
  Tries to get b.length original bytes from this FileBytes entry at the given offset into the file bytes.
  `int`
  `getOriginalBytes(long offset, byte[] b, int off, int length)`
  Tries to get length (original) bytes from the files starting at the given offset and put them into the given byte array at the specified offset into the byte array.
  `long`
  `getSize()`
  Returns the number of bytes from the original source file that are stored in the database.
  `int`
  `hashCode()`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### FileBytes

    public FileBytes(ghidra.program.database.mem.FileBytesAdapter adapter, DBRecord record) throws IOException
    Throws:
      `IOException`

- ## Method Details

  - ### getFilename

    public String getFilename()
    Returns the name of the file that supplied the bytes.
    Returns:
      the name of the file that supplied the bytes.

  - ### getFileOffset

    public long getFileOffset()
    Returns the offset in the original file from where these bytes originated. Normally this will be 0, but in the case where the program is actually a piece in some other file (e.g. tar,zip), this will be the offset into the file corresponding to the first byte in this FileBytes object.
    Returns:
      the offset in the original file from where these bytes originated.

  - ### getSize

    public long getSize()
    Returns the number of bytes from the original source file that are stored in the database.
    Returns:
      the number of bytes from the original source file that are stored in the database.

  - ### getModifiedByte

    public byte getModifiedByte(long offset) throws IOException, IndexOutOfBoundsException
    Returns the (possibly modified) byte at the given offset for this file bytes object.
    Parameters:
      `offset` - the offset into the file bytes for the byte to retrieve.
    Returns:
      the (possibly modified) byte at the given offset for this file bytes object.
    Throws:
      `IOException` - if there is a problem reading the database.
      `IndexOutOfBoundsException` - if the given offset is invalid.

  - ### getOriginalByte

    public byte getOriginalByte(long offset) throws IOException, IndexOutOfBoundsException
    Returns the original byte value at the given offset for this file bytes object.
    Parameters:
      `offset` - the offset into the file bytes for the byte to retrieve.
    Returns:
      the original byte at the given offset for this file bytes object.
    Throws:
      `IOException` - if there is a problem reading the database.
      `IndexOutOfBoundsException` - if the given offset is invalid.

  - ### getModifiedBytes

    public int getModifiedBytes(long offset, byte[] b) throws IOException, IndexOutOfBoundsException
    Tries to get b.length (possibly modified) bytes from this FileBytes entry at the given offset into the file bytes. May return fewer bytes if the requested length is beyond the end of the file bytes.
    Parameters:
      `offset` - the offset into the files bytes to start.
      `b` - the byte array to populate.
    Returns:
      the number of bytes actually populated.
    Throws:
      `IOException` - if there is an error reading from the database
      `IndexOutOfBoundsException` - if the given offset is invalid.

  - ### getOriginalBytes

    public int getOriginalBytes(long offset, byte[] b) throws IOException, IndexOutOfBoundsException
    Tries to get b.length original bytes from this FileBytes entry at the given offset into the file bytes. May return fewer bytes if the requested length is beyond the end of the file bytes.
    Parameters:
      `offset` - the offset into the files bytes to start.
      `b` - the byte array to populate.
    Returns:
      the number of bytes actually populated.
    Throws:
      `IOException` - if there is an error reading from the database
      `IndexOutOfBoundsException` - if the given offset is invalid.

  - ### getModifiedBytes

    public int getModifiedBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsException
    Tries to get length (possibly modified) bytes from the files starting at the given offset and put them into the given byte array at the specified offset into the byte array. May return fewer bytes if the requested length is beyond the end of the file bytes.
    Parameters:
      `offset` - the offset into the files bytes to start.
      `b` - the byte array to populate.
      `off` - the offset into the byte array.
      `length` - the number of bytes to get.
    Returns:
      the number of bytes actually populated.
    Throws:
      `IOException` - if there is an error reading from the database
      `IndexOutOfBoundsException` - if the destination offset and length would exceed the size of the buffer b.

  - ### getOriginalBytes

    public int getOriginalBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsException
    Tries to get length (original) bytes from the files starting at the given offset and put them into the given byte array at the specified offset into the byte array. May return fewer bytes if the requested length is beyond the end of the file bytes.
    Parameters:
      `offset` - the offset into the files bytes to start.
      `b` - the byte array to populate.
      `off` - the offset into the byte array.
      `length` - the number of bytes to get.
    Returns:
      the number of bytes actually populated.
    Throws:
      `IOException` - if there is an error reading from the database
      `IndexOutOfBoundsException` - if the destination offset and length would exceed the size of the buffer b.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`