Package ghidra.app.util.bin
Class UnlimitedByteProviderWrapper
java.lang.Object
ghidra.app.util.bin.ByteProviderWrapper
ghidra.app.util.bin.UnlimitedByteProviderWrapper
- All Implemented Interfaces:
ByteProvider
,Closeable
,AutoCloseable
A
ByteProvider
constrained to a sub-section of an existing ByteProvider
although reads beyond the specified sub-section are permitted but will return zero byte
values. The methods ByteProviderWrapper.length()
and ByteProvider.getInputStream(long)
remain
bounded by the specified sub-section.-
Field Summary
Fields inherited from class ghidra.app.util.bin.ByteProviderWrapper
fsrl, provider, subLength, subOffset
Fields inherited from interface ghidra.app.util.bin.ByteProvider
EMPTY_BYTEPROVIDER
-
Constructor Summary
ConstructorDescriptionUnlimitedByteProviderWrapper
(ByteProvider provider) Creates a wrapper around aByteProvider
that contains the same bytes as the specified provider.UnlimitedByteProviderWrapper
(ByteProvider provider, long subOffset, long subLength) Constructs aUnlimitedByteProviderWrapper
around the specifiedByteProvider
, constrained to a subsection of the provider.UnlimitedByteProviderWrapper
(ByteProvider provider, long subOffset, long subLength, FSRL fsrl) Constructs aUnlimitedByteProviderWrapper
around the specifiedByteProvider
, constrained to a subsection of the provider.UnlimitedByteProviderWrapper
(ByteProvider provider, FSRL fsrl) Creates a wrapper around aByteProvider
that contains the same bytes as the specified provider, but with a newFSRL
identity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isValidIndex
(long index) Returns true if the specified index is valid.byte
readByte
(long index) Reads a byte at the specified indexbyte[]
readBytes
(long index, long length) Reads a byte array at the specified indexMethods inherited from class ghidra.app.util.bin.ByteProviderWrapper
close, getAbsolutePath, getFile, getFSRL, getName, length
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.app.util.bin.ByteProvider
getInputStream, isEmpty
-
Constructor Details
-
UnlimitedByteProviderWrapper
Creates a wrapper around aByteProvider
that contains the same bytes as the specified provider.- Parameters:
provider
-ByteProvider
to wrap- Throws:
IOException
- if error
-
UnlimitedByteProviderWrapper
Creates a wrapper around aByteProvider
that contains the same bytes as the specified provider, but with a newFSRL
identity.- Parameters:
provider
-ByteProvider
to wrapfsrl
-FSRL
identity for the instance- Throws:
IOException
- if error
-
UnlimitedByteProviderWrapper
Constructs aUnlimitedByteProviderWrapper
around the specifiedByteProvider
, constrained to a subsection of the provider.- Parameters:
provider
- theByteProvider
to wrapsubOffset
- the offset in theByteProvider
of where to start the newUnlimitedByteProviderWrapper
subLength
- the length of the newUnlimitedByteProviderWrapper
-
UnlimitedByteProviderWrapper
public UnlimitedByteProviderWrapper(ByteProvider provider, long subOffset, long subLength, FSRL fsrl) Constructs aUnlimitedByteProviderWrapper
around the specifiedByteProvider
, constrained to a subsection of the provider.- Parameters:
provider
- theByteProvider
to wrapsubOffset
- the offset in theByteProvider
of where to start the newUnlimitedByteProviderWrapper
subLength
- the length of the newUnlimitedByteProviderWrapper
fsrl
-FSRL
identity of the file this ByteProvider represents
-
-
Method Details
-
isValidIndex
public boolean isValidIndex(long index) Description copied from interface:ByteProvider
Returns true if the specified index is valid.- Specified by:
isValidIndex
in interfaceByteProvider
- Overrides:
isValidIndex
in classByteProviderWrapper
- Parameters:
index
- the index in the byte provider to check- Returns:
- true if the specified index is valid
-
readByte
Description copied from interface:ByteProvider
Reads a byte at the specified index- Specified by:
readByte
in interfaceByteProvider
- Overrides:
readByte
in classByteProviderWrapper
- Parameters:
index
- the index of the byte to read- Returns:
- the byte read from the specified index
- Throws:
IOException
- if an I/O error occurs
-
readBytes
Description copied from interface:ByteProvider
Reads a byte array at the specified index- Specified by:
readBytes
in interfaceByteProvider
- Overrides:
readBytes
in classByteProviderWrapper
- Parameters:
index
- the index of the byte to readlength
- the number of bytes to read- Returns:
- the byte array read from the specified index
- Throws:
IOException
- if an I/O error occurs
-