Package ghidra.program.database.mem
Class FileBytes
java.lang.Object
ghidra.program.database.mem.FileBytes
FileBytes provides access to the all the byte values (both original and modified) from an
imported file.
-
Constructor Summary
Constructors -
Method Summary
ChangeModifier and TypeMethodDescriptionbooleanReturns the name of the file that supplied the bytes.longReturns the offset in the original file from where these bytes originated.MODIFIEDbytegetModifiedByte(long offset) Returns the (possibly modified) byte at the given offset for this file bytes object.MODIFIEDintgetModifiedBytes(long offset, byte[] b) Tries to get b.length (possibly modified) bytes from this FileBytes entry at the given offset into the file bytes.MODIFIEDintgetModifiedBytes(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.MODIFIEDbytegetOriginalByte(long offset) Returns the original byte value at the given offset for this file bytes object.MODIFIEDintgetOriginalBytes(long offset, byte[] b) Tries to get b.length original bytes from this FileBytes entry at the given offset into the file bytes.MODIFIEDintgetOriginalBytes(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()toString()
-
Constructor Details
-
FileBytes
public FileBytes(ghidra.program.database.mem.FileBytesAdapter adapter, DBRecord record) throws IOException - Throws:
IOException
-
-
Method Details
-
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 MODIFIED
added throws IndexOutOfBoundsException-byte getModifiedByte(long offset) throws IOException+byte getModifiedByte(long offset) throws IOException, IndexOutOfBoundsExceptionReturns 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 MODIFIED
added throws IndexOutOfBoundsException-byte getOriginalByte(long offset) throws IOException+byte getOriginalByte(long offset) throws IOException, IndexOutOfBoundsExceptionReturns 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 MODIFIED
added throws IndexOutOfBoundsException-int getModifiedBytes(long offset, byte[] b) throws IOException+int getModifiedBytes(long offset, byte[] b) throws IOException, IndexOutOfBoundsExceptionTries 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 databaseIndexOutOfBoundsException- if the given offset is invalid.
-
getOriginalBytes MODIFIED
added throws IndexOutOfBoundsException-int getOriginalBytes(long offset, byte[] b) throws IOException+int getOriginalBytes(long offset, byte[] b) throws IOException, IndexOutOfBoundsExceptionTries 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 databaseIndexOutOfBoundsException- if the given offset is invalid.
-
getModifiedBytes MODIFIED
public int getModifiedBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsException added throws IndexOutOfBoundsException-int getModifiedBytes(long offset, byte[] b, int off, int length) throws IOException+int getModifiedBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsExceptionTries 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 databaseIndexOutOfBoundsException- if the destination offset and length would exceed the size of the buffer b.
-
getOriginalBytes MODIFIED
public int getOriginalBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsException added throws IndexOutOfBoundsException-int getOriginalBytes(long offset, byte[] b, int off, int length) throws IOException+int getOriginalBytes(long offset, byte[] b, int off, int length) throws IOException, IndexOutOfBoundsExceptionTries 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 databaseIndexOutOfBoundsException- if the destination offset and length would exceed the size of the buffer b.
-
toString
-
hashCode
public int hashCode() -
equals
-