Class ExtendedByteSequence
java.lang.Object
ghidra.features.base.memsearch.bytesequence.ExtendedByteSequence
- All Implemented Interfaces:
ByteSequence
A class for accessing a contiguous sequence of bytes from some underlying byte source to
be used for searching for a byte pattern within the byte source. This sequence of bytes
consists of two parts; the primary sequence and an extended sequence. Search matches
must begin in the primary sequence, but may extend into the extended sequence.
Searching large ranges of memory can be partitioned into searching smaller chunks. But to handle search sequences that span chunks, two chunks are presented at a time, with the second chunk being the extended bytes. On the next iteration of the search loop, the extended chunk will become the primary chunk, with the next chunk after that becoming the extended sequence and so on.
-
Constructor Summary
ConstructorDescriptionExtendedByteSequence
(ByteSequence main, ByteSequence extended, int extendedLimit) Constructs an extended byte sequence from twoByteSequence
s. -
Method Summary
Modifier and TypeMethodDescriptionbyte
getByte
(int i) Returns the byte at the given index.byte[]
getBytes
(int index, int size) Returns a byte array containing the bytes from the given range.int
Returns the overall length of sequence of available bytes.int
Returns the length of available bytes.boolean
hasAvailableBytes
(int index, int length) A convenience method for checking if this sequence can provide a range of bytes from some offset.
-
Constructor Details
-
ExtendedByteSequence
Constructs an extended byte sequence from twoByteSequence
s.- Parameters:
main
- the byte sequence where search matches may startextended
- the byte sequence where search matches may extend intoextendedLimit
- specifies how much of the extended byte sequence to allow search matches to extend into. (The extended buffer will be the primary buffer next time, so it is a full size buffer, but we only need to use a portion of it to support overlap.
-
-
Method Details
-
getLength
public int getLength()Description copied from interface:ByteSequence
Returns the length of available bytes.- Specified by:
getLength
in interfaceByteSequence
- Returns:
- the length of the sequence of bytes
-
getExtendedLength
public int getExtendedLength()Returns the overall length of sequence of available bytes. This will be the length of the primary sequence as returned bygetLength()
plus the length of the available extended bytes, if any.- Returns:
- the
-
getByte
public byte getByte(int i) Description copied from interface:ByteSequence
Returns the byte at the given index. The index must between 0 and the extended length.- Specified by:
getByte
in interfaceByteSequence
- Parameters:
i
- the index in the byte sequence to retrieve a byte value- Returns:
- the byte at the given index
-
getBytes
public byte[] getBytes(int index, int size) Description copied from interface:ByteSequence
Returns a byte array containing the bytes from the given range.- Specified by:
getBytes
in interfaceByteSequence
- Parameters:
index
- the start index of the range to get bytessize
- the number of bytes to get- Returns:
- a byte array containing the bytes from the given range
-
hasAvailableBytes
public boolean hasAvailableBytes(int index, int length) Description copied from interface:ByteSequence
A convenience method for checking if this sequence can provide a range of bytes from some offset.- Specified by:
hasAvailableBytes
in interfaceByteSequence
- Parameters:
index
- the index of the start of the range to check for available byteslength
- the length of the range to check for available bytes- Returns:
- true if bytes are available for the given range
-