Package ghidra.program.model.mem
Class ByteMemBufferImpl
java.lang.Object
ghidra.program.model.mem.ByteMemBufferImpl
- All Implemented Interfaces:
MemBuffer
Simple byte buffer implementation of the memBuffer. Even if a Memory is
provided, the available bytes will be limited to the bytes provided during
construction.
-
Constructor Summary
ConstructorDescriptionByteMemBufferImpl
(Address addr, byte[] bytes, boolean isBigEndian) Construct a ByteMemBufferImpl objectByteMemBufferImpl
(Memory memory, Address addr, byte[] bytes, boolean isBigEndian) Construct a ByteMemBufferImpl object -
Method Summary
Modifier and TypeMethodDescriptionGet the Address which corresponds to the offset 0.getBigInteger
(int offset, int size, boolean signed) returns the value at the given offset, taking into account the endianness.byte
getByte
(int offset) Get one byte from memory at the current position plus offset.int
getBytes
(byte[] b, int offset) Readsb.length
bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position.int
getInt
(int offset) returns the int at the given offset, taking into account the endianness.int
Get number of bytes contained within bufferlong
getLong
(int offset) returns the long at the given offset, taking into account the endianness.Get the Memory object actually used by the MemBuffer.short
getShort
(int offset) returns the short at the given offset, taking into account the endianness.boolean
Returns true if the underlying bytes are in big-endian order, false if they are little endian.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.program.model.mem.MemBuffer
getInputStream, getInputStream, getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isInitializedMemory
-
Constructor Details
-
ByteMemBufferImpl
Construct a ByteMemBufferImpl object- Parameters:
addr
- the address to associate with the bytesbytes
- the data that normally would be coming from memory.isBigEndian
- true for BigEndian, false for LittleEndian.
-
ByteMemBufferImpl
Construct a ByteMemBufferImpl object- Parameters:
memory
- the memory in case getMemory() is called to get associated things like address spacesaddr
- the address to associate with the bytesbytes
- the data that normally would be coming from memory.isBigEndian
- true for BigEndian, false for LittleEndian.
-
-
Method Details
-
getLength
public int getLength()Get number of bytes contained within buffer- Returns:
- byte count
-
getAddress
Description copied from interface:MemBuffer
Get the Address which corresponds to the offset 0.- Specified by:
getAddress
in interfaceMemBuffer
- Returns:
- the current address of offset 0.
-
getByte
Description copied from interface:MemBuffer
Get one byte from memory at the current position plus offset.- Specified by:
getByte
in interfaceMemBuffer
- Parameters:
offset
- the displacement from the current position.- Returns:
- the data at offset from the current position.
- Throws:
MemoryAccessException
- if memory cannot be read at the specified offset
-
getMemory
Description copied from interface:MemBuffer
Get the Memory object actually used by the MemBuffer. -
getBytes
public int getBytes(byte[] b, int offset) Description copied from interface:MemBuffer
Readsb.length
bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position. The actual number of bytes may be fewer if bytes can't be read.- Specified by:
getBytes
in interfaceMemBuffer
- Parameters:
b
- the buffer into which bytes will be placedoffset
- the offset in this memory buffer from which to start reading bytes.- Returns:
- the number of bytes read which may be fewer than b.length if available bytes are exhausted or no bytes are available at the specified offset.
-
isBigEndian
public boolean isBigEndian()Description copied from interface:MemBuffer
Returns true if the underlying bytes are in big-endian order, false if they are little endian.- Specified by:
isBigEndian
in interfaceMemBuffer
- Returns:
- true if the underlying bytes are in big-endian order, false if they are little endian.
-
getShort
Description copied from interface:MemBuffer
returns the short at the given offset, taking into account the endianness.- Specified by:
getShort
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the short at the given offset, taking into account the endianness.
- Throws:
MemoryAccessException
- if a 2-byte short value cannot be read at the specified offset
-
getInt
Description copied from interface:MemBuffer
returns the int at the given offset, taking into account the endianness.- Specified by:
getInt
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the int at the given offset, taking into account the endianness.
- Throws:
MemoryAccessException
- if a 4-byte integer value cannot be read at the specified offset
-
getLong
Description copied from interface:MemBuffer
returns the long at the given offset, taking into account the endianness.- Specified by:
getLong
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the long at the given offset, taking into account the endianness.
- Throws:
MemoryAccessException
- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
Description copied from interface:MemBuffer
returns the value at the given offset, taking into account the endianness.- Specified by:
getBigInteger
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)size
- the number of bytes to include in the valuesigned
- true if value should be treated as a signed twos-compliment value.- Returns:
- the value at the given offset, taking into account the endianness.
- Throws:
MemoryAccessException
- if the request size value cannot be read at the specified offset
-