Package ghidra.program.model.mem
Interface MemoryBlock
-
- All Superinterfaces:
java.lang.Comparable<MemoryBlock>,java.io.Serializable
- All Known Subinterfaces:
MappedMemoryBlock
- All Known Implementing Classes:
MemoryBlockStub
public interface MemoryBlock extends java.io.Serializable, java.lang.Comparable<MemoryBlock>
Interface that defines a block in memory.
-
-
Field Summary
Fields Modifier and Type Field Description static intEXECUTEstatic java.lang.StringEXTERNAL_BLOCK_NAMEA special EXTERNAL block may be created by certain program loaders (e.g., Elf) to act as a stand-in for unknown external symbol locations.static intREADstatic intVOLATILEstatic intWRITE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontains(Address addr)Return whether addr is contained in this block.bytegetByte(Address addr)Returns the byte at the given address in this block.intgetBytes(Address addr, byte[] b)Tries to get b.length bytes from this block at the given address.intgetBytes(Address addr, byte[] b, int off, int len)Tries to get len bytes from this block at the given address and put them into the given byte array at the specified offet.java.lang.StringgetComment()Get the comment associated with this block.java.io.InputStreamgetData()Get memory data in the form of an InputStream.AddressgetEnd()Return the end address of this block.java.lang.StringgetName()Get the name of this blockintgetPermissions()Returns block permissions as a bit mask.longgetSize()Get the number of bytes in this block.java.lang.StringgetSourceName()Get the name of the source of this memory block.AddressgetStart()Return the starting address for this block.MemoryBlockTypegetType()Get the type for this block: TYPE_DEFAULT, TYPE_OVERLAY, TYPE_BIT_MAPPED, or TYPE_BYTE_MAPPEDbooleanisExecute()Returns the value of the execute property associated with this blockstatic booleanisExternalBlockAddress(Address address, Program program)Determine if the specified address is contained within the reserved EXTERNAL block.booleanisInitialized()Return whether this block has been initialized.booleanisLoaded()Returns true if this memory block is a real loaded block (i.e.booleanisMapped()Returns true if this is either a bit-mapped or byte-mapped blockbooleanisRead()Returns the value of the read property associated with this blockbooleanisVolatile()Returns the value of the volatile property associated with this block.booleanisWrite()Returns the value of the write property associated with this blockvoidputByte(Address addr, byte b)Puts the given byte at the given address in this block.intputBytes(Address addr, byte[] b)Tries to put b.length bytes from the specified byte array to this block.intputBytes(Address addr, byte[] b, int off, int len)Tries to put len bytes from the specified byte array to this block.voidsetComment(java.lang.String comment)Set the comment associated with this block.voidsetExecute(boolean e)Sets the execute property associated with this block.voidsetName(java.lang.String name)Set the name for this block.voidsetRead(boolean r)Sets the read property associated with this block.voidsetSourceName(java.lang.String sourceName)Sets the name of the source file that provided the data.voidsetVolatile(boolean v)Sets the volatile property associated with this block.voidsetWrite(boolean w)Sets the write property associated with this block.
-
-
-
Field Detail
-
EXTERNAL_BLOCK_NAME
static final java.lang.String EXTERNAL_BLOCK_NAME
A special EXTERNAL block may be created by certain program loaders (e.g., Elf) to act as a stand-in for unknown external symbol locations.- See Also:
- Constant Field Values
-
VOLATILE
static final int VOLATILE
- See Also:
- Constant Field Values
-
READ
static final int READ
- See Also:
- Constant Field Values
-
WRITE
static final int WRITE
- See Also:
- Constant Field Values
-
EXECUTE
static final int EXECUTE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getPermissions
int getPermissions()
Returns block permissions as a bit mask. Permission bits defined as READ, WRITE, EXECUTE and VOLATILE
-
getData
java.io.InputStream getData()
Get memory data in the form of an InputStream. Null is returned for thos memory blocks which have no data.
-
contains
boolean contains(Address addr)
Return whether addr is contained in this block.- Parameters:
addr- address
-
getStart
Address getStart()
Return the starting address for this block.- Returns:
- block's start address
-
getEnd
Address getEnd()
Return the end address of this block.- Returns:
- end address of the block
-
getSize
long getSize()
Get the number of bytes in this block.- Returns:
- number of bytes in the block
-
getName
java.lang.String getName()
Get the name of this block
-
setName
void setName(java.lang.String name) throws DuplicateNameException, LockExceptionSet the name for this block.- Parameters:
name- the new name for this block.- Throws:
DuplicateNameExceptionLockException- renaming an Overlay block without exclusive access
-
getComment
java.lang.String getComment()
Get the comment associated with this block.
-
setComment
void setComment(java.lang.String comment)
Set the comment associated with this block.- Parameters:
comment- the comment to associate with this block.
-
isRead
boolean isRead()
Returns the value of the read property associated with this block
-
setRead
void setRead(boolean r)
Sets the read property associated with this block.- Parameters:
r- the value to set the read property to.
-
isWrite
boolean isWrite()
Returns the value of the write property associated with this block
-
setWrite
void setWrite(boolean w)
Sets the write property associated with this block.- Parameters:
w- the value to set the write property to.
-
isExecute
boolean isExecute()
Returns the value of the execute property associated with this block
-
setExecute
void setExecute(boolean e)
Sets the execute property associated with this block.- Parameters:
e- the value to set the execute property to.
-
isVolatile
boolean isVolatile()
Returns the value of the volatile property associated with this block. This attribute is generally associated with block of I/O regions of memory.
-
setVolatile
void setVolatile(boolean v)
Sets the volatile property associated with this block.- Parameters:
v- the value to set the volatile property to.
-
getSourceName
java.lang.String getSourceName()
Get the name of the source of this memory block.- Returns:
- source name
-
setSourceName
void setSourceName(java.lang.String sourceName)
Sets the name of the source file that provided the data.- Parameters:
sourceName- the name of the source file.
-
getByte
byte getByte(Address addr) throws MemoryAccessException
Returns the byte at the given address in this block.- Parameters:
addr- the address.- Throws:
MemoryAccessException- if any of the requested bytes are uninitialized.java.lang.IllegalArgumentException- if the Address is not in this block.
-
getBytes
int getBytes(Address addr, byte[] b) throws MemoryAccessException
Tries to get b.length bytes from this block at the given address. May return fewer bytes if the requested length is beyond the end of the block.- Parameters:
addr- the address from which to get the bytes.b- the byte array to populate.- Returns:
- the number of bytes actually populated.
- Throws:
MemoryAccessException- if any of the requested bytes are uninitialized.java.lang.IllegalArgumentException- if the Address is not in this block.
-
getBytes
int getBytes(Address addr, byte[] b, int off, int len) throws MemoryAccessException
Tries to get len bytes from this block at the given address and put them into the given byte array at the specified offet. May return fewer bytes if the requested length is beyond the end of the block.- Parameters:
addr- the address from which to get the bytes.b- the byte array to populate.off- the offset into the byte array.len- the number of bytes to get.- Returns:
- the number of bytes actually populated.
- Throws:
MemoryAccessException- if any of the requested bytes are uninitialized.java.lang.IllegalArgumentException- if the Address is not in this block.
-
putByte
void putByte(Address addr, byte b) throws MemoryAccessException
Puts the given byte at the given address in this block.- Parameters:
addr- the address.- Throws:
MemoryAccessException- if the block is uninitializedjava.lang.IllegalArgumentException- if the Address is not in this block.
-
putBytes
int putBytes(Address addr, byte[] b) throws MemoryAccessException
Tries to put b.length bytes from the specified byte array to this block. All the bytes may not be put if the requested length is beyond the end of the block.- Parameters:
addr- the address of where to put the bytes.b- the byte array containing the bytes to write.- Returns:
- the number of bytes actually written.
- Throws:
MemoryAccessException- if the block is uninitializedjava.lang.IllegalArgumentException- if the Address is not in this block.
-
putBytes
int putBytes(Address addr, byte[] b, int off, int len) throws MemoryAccessException
Tries to put len bytes from the specified byte array to this block. All the bytes may not be written if the requested length is beyond the end of the block.- Parameters:
addr- the address of where to put the bytes.b- the byte array containing the bytes to write.off- the offset into the byte array.len- the number of bytes to write.- Returns:
- the number of bytes actually written.
- Throws:
MemoryAccessException- if the block is uninitializedjava.lang.IllegalArgumentException- if the Address is not in this block.
-
getType
MemoryBlockType getType()
Get the type for this block: TYPE_DEFAULT, TYPE_OVERLAY, TYPE_BIT_MAPPED, or TYPE_BYTE_MAPPED
-
isInitialized
boolean isInitialized()
Return whether this block has been initialized.
-
isMapped
boolean isMapped()
Returns true if this is either a bit-mapped or byte-mapped block
-
isLoaded
boolean isLoaded()
Returns true if this memory block is a real loaded block (i.e. RAM) and not a special block containing file header data such as debug sections.
-
isExternalBlockAddress
static boolean isExternalBlockAddress(Address address, Program program)
Determine if the specified address is contained within the reserved EXTERNAL block.- Parameters:
address- address of interestprogram-- Returns:
- true if address is contained within the reserved EXTERNAL block, else false.
-
-