Interface MemoryBlock
- All Superinterfaces:
Comparable<MemoryBlock>
,Serializable
- All Known Implementing Classes:
MemoryBlockDB
,MemoryBlockStub
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final String
A special purpose EXTERNAL block may be created by certain program loaders (e.g., Elf) to act as a stand-in for unknown external symbol locations when relocation support is required using a valid memory address.static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return whether addr is contained in this block.Get the address range that corresponds to this block.byte
Returns the byte at the given address in this block.int
Tries to get b.length bytes from this block at the given address.int
Tries to get len bytes from this block at the given address and put them into the given byte array at the specified offet.Get the comment associated with this block.getData()
Get memory data in the form of an InputStream.getEnd()
Return the end address of this block.int
getFlags()
Returns block flags (i.e., permissions and attributes) as a bit mask.getName()
Get the name of this blocklong
getSize()
Get the number of bytes in this block.Get the number of bytes in this block.Returns a list ofMemoryBlockSourceInfo
objects for this block.Get the name of the source of this memory block.getStart()
Return the starting address for this block.getType()
Get the type for this block: DEFAULT, BIT_MAPPED, or BYTE_MAPPED (seeMemoryBlockType
).boolean
Returns the artificial attribute state of this block.boolean
Returns the value of the execute property associated with this blockdefault boolean
Returns true if this is a reserved EXTERNAL memory block based upon its name (seeEXTERNAL_BLOCK_NAME
).boolean
Return whether this block has been initialized.boolean
isLoaded()
Returns true if this memory block is a real loaded block (i.e.boolean
isMapped()
Returns true if this is either a bit-mapped or byte-mapped blockboolean
Returns true if this is an overlay block (i.e., contained within overlay space).boolean
isRead()
Returns the value of the read property associated with this blockboolean
Returns the volatile attribute state of this block.boolean
isWrite()
Returns the value of the write property associated with this blockvoid
Puts the given byte at the given address in this block.int
Tries to put b.length bytes from the specified byte array to this block.int
Tries to put len bytes from the specified byte array to this block.void
setArtificial
(boolean a) Sets the artificial attribute state associated with this block.void
setComment
(String comment) Set the comment associated with this block.void
setExecute
(boolean e) Sets the execute property associated with this block.void
Set the name for this block (SeeNamingUtilities.isValidName(String)
for naming rules).void
setPermissions
(boolean read, boolean write, boolean execute) Sets the read, write, execute permissions on this blockvoid
setRead
(boolean r) Sets the read property associated with this block.void
setSourceName
(String sourceName) Sets the name of the source file that provided the data.void
setVolatile
(boolean v) Sets the volatile attribute state associated of this block.void
setWrite
(boolean w) Sets the write property associated with this block.Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
EXTERNAL_BLOCK_NAME
A special purpose EXTERNAL block may be created by certain program loaders (e.g., Elf) to act as a stand-in for unknown external symbol locations when relocation support is required using a valid memory address. While the EXTERNAL block is created out of neccessity for relocation processing it introduces a number of limitations when used to carry data symbols where pointer math and offset-references may occur.The method
Memory.isExternalBlockAddress(Address)
may be used to determine if a specific address is contained within an EXTERNAL memory block.NOTE: Close proximity to the end of an address space should be avoided to allow for
OffsetReference
use.- See Also:
-
ARTIFICIAL
static final int ARTIFICIAL- See Also:
-
VOLATILE
static final int VOLATILE- See Also:
-
READ
static final int READ- See Also:
-
WRITE
static final int WRITE- See Also:
-
EXECUTE
static final int EXECUTE- See Also:
-
-
Method Details
-
getFlags
int getFlags()Returns block flags (i.e., permissions and attributes) as a bit mask. These bits defined asREAD
,WRITE
,EXECUTE
,VOLATILE
,ARTIFICIAL
.- Returns:
- block flag bits
-
getData
InputStream getData()Get memory data in the form of an InputStream. Null is returned for thos memory blocks which have no data. -
contains
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
-
getAddressRange
AddressRange getAddressRange()Get the address range that corresponds to this block.- Returns:
- block address range
-
getSize
long getSize()Get the number of bytes in this block.- Returns:
- number of bytes in the block
-
getSizeAsBigInteger
BigInteger getSizeAsBigInteger()Get the number of bytes in this block.- Returns:
- the number of bytes in this block as a BigInteger
-
getName
String getName()Get the name of this block- Returns:
- block name
-
setName
Set the name for this block (SeeNamingUtilities.isValidName(String)
for naming rules). Specified name must not conflict with an address space name.- Parameters:
name
- the new name for this block.- Throws:
IllegalArgumentException
- if invalid name specifiedLockException
- renaming an Overlay block without exclusive access
-
getComment
String getComment()Get the comment associated with this block.- Returns:
- block comment string
-
setComment
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- Returns:
- true if enabled else false
-
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- Returns:
- true if enabled else false
-
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- Returns:
- true if enabled else false
-
setExecute
void setExecute(boolean e) Sets the execute property associated with this block.- Parameters:
e
- the value to set the execute property to.
-
setPermissions
void setPermissions(boolean read, boolean write, boolean execute) Sets the read, write, execute permissions on this block- Parameters:
read
- the read permissionwrite
- the write permissionexecute
- the execute permission
-
isVolatile
boolean isVolatile()Returns the volatile attribute state of this block. This attribute is generally associated with block of I/O regions of memory.- Returns:
- true if enabled else false
-
setVolatile
void setVolatile(boolean v) Sets the volatile attribute state associated of this block. This attribute is generally associated with block of I/O regions of memory.- Parameters:
v
- the volatile attribute state.
-
isArtificial
boolean isArtificial()Returns the artificial attribute state of this block. This attribute is generally associated with blocks which have been fabricated to facilitate analysis but do not exist in the same form within a running/loaded process state.- Returns:
- true if enabled else false
-
setArtificial
void setArtificial(boolean a) Sets the artificial attribute state associated with this block. This attribute is generally associated with blocks which have been fabricated to facilitate analysis but do not exist in the same form within a running/loaded process state.- Parameters:
a
- the artificial attribute state.
-
getSourceName
String getSourceName()Get the name of the source of this memory block.- Returns:
- source name
-
setSourceName
Sets the name of the source file that provided the data.- Parameters:
sourceName
- the name of the source file.
-
getByte
Returns the byte at the given address in this block.- Parameters:
addr
- the address.- Returns:
- byte value from this block and specified address
- Throws:
MemoryAccessException
- if any of the requested bytes are uninitialized.IllegalArgumentException
- if the Address is not in this block.
-
getBytes
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.IllegalArgumentException
- if the Address is not in this block.
-
getBytes
int getBytes(Address addr, byte[] b, int off, int len) throws IndexOutOfBoundsException, 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:
IndexOutOfBoundsException
- if invalid offset is specifiedMemoryAccessException
- if any of the requested bytes are uninitialized.IllegalArgumentException
- if the Address is not in this block.
-
putByte
Puts the given byte at the given address in this block.- Parameters:
addr
- the address.b
- byte value- Throws:
MemoryAccessException
- if the block is uninitializedIllegalArgumentException
- if the Address is not in this block.
-
putBytes
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 uninitializedIllegalArgumentException
- if the Address is not in this block.
-
putBytes
int putBytes(Address addr, byte[] b, int off, int len) throws IndexOutOfBoundsException, 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:
IndexOutOfBoundsException
- if invalid offset is specifiedMemoryAccessException
- if the block is uninitializedIllegalArgumentException
- if the Address is not in this block.
-
getType
MemoryBlockType getType()Get the type for this block: DEFAULT, BIT_MAPPED, or BYTE_MAPPED (seeMemoryBlockType
).- Returns:
- memory block type
-
isInitialized
boolean isInitialized()Return whether this block has been initialized.WARNING: A mapped memory block may have a mix of intialized, uninitialized, and undefined regions. The value returned by this method for a mapped memory block is always false even if some regions are initialized.
- Returns:
- true if block is fully initialized and not a memory-mapped-block, else false
-
isMapped
boolean isMapped()Returns true if this is either a bit-mapped or byte-mapped block- Returns:
- true if this is either a bit-mapped or byte-mapped block
-
isExternalBlock
default boolean isExternalBlock()Returns true if this is a reserved EXTERNAL memory block based upon its name (seeEXTERNAL_BLOCK_NAME
). Checks for individual addresses may be done usingMemory.isExternalBlockAddress(Address)
.Note that EXTERNAL blocks always resides within a memory space and never within the artifial
AddressSpace.EXTERNAL_SPACE
which is not a memory space. This can be a source of confusion. An EXTERNAL memory block exists to facilitate relocation processing for some external symbols which require a real memory address.- Returns:
- true if this is a reserved EXTERNAL memory block
-
isOverlay
boolean isOverlay()Returns true if this is an overlay block (i.e., contained within overlay space).- Returns:
- true if this is an overlay 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.- Returns:
- true if this is a loaded block and not a "special" block such as a file header.
-
getSourceInfos
List<MemoryBlockSourceInfo> getSourceInfos()Returns a list ofMemoryBlockSourceInfo
objects for this block. A block may consist of multiple sequences of bytes from different sources. Each such source of bytes is described by its respective SourceInfo object. Blocks may have multiple sources after two or more memory blocks have been joined together and the underlying byte sources can't be joined.- Returns:
- a list of SourceInfo objects, one for each different source of bytes in this block.
-