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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the name of the file that supplied the bytes.long
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()
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
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
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
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
-
getOriginalBytes
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
-
getModifiedBytes
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 databaseIndexOutOfBoundsException
- if the destination offset and length would exceed the size of the buffer b.
-
getOriginalBytes
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 databaseIndexOutOfBoundsException
- if the destination offset and length would exceed the size of the buffer b.
-
toString
-
hashCode
public int hashCode() -
equals
-