Package ghidra.program.database.mem
Class FileBytes
- java.lang.Object
-
- ghidra.program.database.mem.FileBytes
-
public class FileBytes extends java.lang.ObjectFileBytes provides access to the all the byte values (both original and modified) from an imported file.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetFilename()Returns the name of the file that supplied the bytes.longgetFileOffset()Returns the offset in the original file from where these bytes originated.bytegetModifiedByte(long offset)Returns the (possibly modified) byte at the given offset for this file bytes object.intgetModifiedBytes(long offset, byte[] b)Tries to get b.length (possibly modified) bytes from this FileBytes entry at the given offset into the file bytes.intgetModifiedBytes(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.bytegetOriginalByte(long offset)Returns the original byte value at the given offset for this file bytes object.intgetOriginalBytes(long offset, byte[] b)Tries to get b.length original bytes from this FileBytes entry at the given offset into the file bytes.intgetOriginalBytes(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.longgetSize()Returns the number of bytes from the original source file that are stored in the database.inthashCode()java.lang.StringtoString()
-
-
-
Constructor Detail
-
FileBytes
public FileBytes(ghidra.program.database.mem.FileBytesAdapter adapter, Record record) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getFilename
public java.lang.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 java.io.IOExceptionReturns 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:
java.io.IOException- if there is a problem reading the database.java.lang.IndexOutOfBoundsException- if the given offset is invalid.
-
getOriginalByte
public byte getOriginalByte(long offset) throws java.io.IOExceptionReturns 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:
java.io.IOException- if there is a problem reading the database.java.lang.IndexOutOfBoundsException- if the given offset is invalid.
-
getModifiedBytes
public int getModifiedBytes(long offset, byte[] b) throws java.io.IOExceptionTries 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:
java.io.IOException- if there is an error reading from the database
-
getOriginalBytes
public int getOriginalBytes(long offset, byte[] b) throws java.io.IOExceptionTries 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:
java.io.IOException- if there is an error reading from the database
-
getModifiedBytes
public int getModifiedBytes(long offset, byte[] b, int off, int length) throws java.io.IOExceptionTries 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:
java.io.IOException- if there is an error reading from the databasejava.lang.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 java.io.IOExceptionTries 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:
java.io.IOException- if there is an error reading from the databasejava.lang.IndexOutOfBoundsException- if the destination offset and length would exceed the size of the buffer b.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-