Package ghidra.program.database.mem
Class MemoryBlockDB
java.lang.Object
ghidra.program.database.mem.MemoryBlockDB
- All Implemented Interfaces:
MemoryBlock,Serializable,Comparable<MemoryBlock>
- See Also:
-
Field Summary
FieldsFields inherited from interface ghidra.program.model.mem.MemoryBlock
ARTIFICIAL, EXECUTE, EXTERNAL_BLOCK_NAME, READ, VOLATILE, WRITE -
Method Summary
Modifier and TypeMethodDescriptionintbooleanReturn whether addr is contained in this block.Get the address range that corresponds to this block.protected longgetBlockOffset(Address addr) bytegetByte(long offset) byteReturns the byte at the given address in this block.intgetBytes(long offset, byte[] b, int off, int len) intTries to get b.length bytes from this block at the given address.intTries 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.intgetFlags()Returns block flags (i.e., permissions and attributes) as a bit mask.getName()Get the name of this blocklonggetSize()Get the number of bytes in this block.Get the number of bytes in this block.Returns a list ofMemoryBlockSourceInfoobjects 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).voidbooleanReturns the artificial attribute state of this block.booleanReturns the value of the execute property associated with this blockbooleanReturn 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 blockbooleanReturns true if this is an overlay block (i.e., contained within overlay space).booleanisRead()Returns the value of the read property associated with this blockbooleanReturns the volatile attribute state of this block.booleanisWrite()Returns the value of the write property associated with this blockvoidPuts the given byte at the given address in this block.intTries to put b.length bytes from the specified byte array to this block.intTries to put len bytes from the specified byte array to this block.voidsetArtificial(boolean a) Sets the artificial attribute state associated with this block.voidsetComment(String comment) Set the comment associated with this block.voidsetExecute(boolean x) Sets the execute property associated with this block.voidSet the name for this block (SeeNamingUtilities.isValidName(String)for naming rules).voidsetPermissions(boolean read, boolean write, boolean execute) Sets the read, write, execute permissions on this blockvoidsetRead(boolean r) Sets the read property associated with this block.voidsetSourceName(String sourceName) Sets the name of the source file that provided the data.voidsetVolatile(boolean v) Sets the volatile attribute state associated of this block.voidsetWrite(boolean w) Sets the write property associated with this block.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.mem.MemoryBlock
isExternalBlock
-
Field Details
-
record
-
memMap
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<MemoryBlock>
-
getFlags
public int getFlags()Description copied from interface:MemoryBlockReturns block flags (i.e., permissions and attributes) as a bit mask. These bits defined asMemoryBlock.READ,MemoryBlock.WRITE,MemoryBlock.EXECUTE,MemoryBlock.VOLATILE,MemoryBlock.ARTIFICIAL.- Specified by:
getFlagsin interfaceMemoryBlock- Returns:
- block flag bits
-
getData
Description copied from interface:MemoryBlockGet memory data in the form of an InputStream. Null is returned for thos memory blocks which have no data.- Specified by:
getDatain interfaceMemoryBlock
-
contains
Description copied from interface:MemoryBlockReturn whether addr is contained in this block.- Specified by:
containsin interfaceMemoryBlock- Parameters:
addr- address
-
getStart
Description copied from interface:MemoryBlockReturn the starting address for this block.- Specified by:
getStartin interfaceMemoryBlock- Returns:
- block's start address
-
getEnd
Description copied from interface:MemoryBlockReturn the end address of this block.- Specified by:
getEndin interfaceMemoryBlock- Returns:
- end address of the block
-
getSize
public long getSize()Description copied from interface:MemoryBlockGet the number of bytes in this block.- Specified by:
getSizein interfaceMemoryBlock- Returns:
- number of bytes in the block
-
getSizeAsBigInteger
Description copied from interface:MemoryBlockGet the number of bytes in this block.- Specified by:
getSizeAsBigIntegerin interfaceMemoryBlock- Returns:
- the number of bytes in this block as a BigInteger
-
getAddressRange
Description copied from interface:MemoryBlockGet the address range that corresponds to this block.- Specified by:
getAddressRangein interfaceMemoryBlock- Returns:
- block address range
-
getName
Description copied from interface:MemoryBlockGet the name of this block- Specified by:
getNamein interfaceMemoryBlock- Returns:
- block name
-
setName
Description copied from interface:MemoryBlockSet the name for this block (SeeNamingUtilities.isValidName(String)for naming rules). Specified name must not conflict with an address space name.- Specified by:
setNamein interfaceMemoryBlock- Parameters:
name- the new name for this block.- Throws:
LockException- renaming an Overlay block without exclusive access
-
getComment
Description copied from interface:MemoryBlockGet the comment associated with this block.- Specified by:
getCommentin interfaceMemoryBlock- Returns:
- block comment string
-
setComment
Description copied from interface:MemoryBlockSet the comment associated with this block.- Specified by:
setCommentin interfaceMemoryBlock- Parameters:
comment- the comment to associate with this block.
-
isRead
public boolean isRead()Description copied from interface:MemoryBlockReturns the value of the read property associated with this block- Specified by:
isReadin interfaceMemoryBlock- Returns:
- true if enabled else false
-
setRead
public void setRead(boolean r) Description copied from interface:MemoryBlockSets the read property associated with this block.- Specified by:
setReadin interfaceMemoryBlock- Parameters:
r- the value to set the read property to.
-
isWrite
public boolean isWrite()Description copied from interface:MemoryBlockReturns the value of the write property associated with this block- Specified by:
isWritein interfaceMemoryBlock- Returns:
- true if enabled else false
-
setWrite
public void setWrite(boolean w) Description copied from interface:MemoryBlockSets the write property associated with this block.- Specified by:
setWritein interfaceMemoryBlock- Parameters:
w- the value to set the write property to.
-
isExecute
public boolean isExecute()Description copied from interface:MemoryBlockReturns the value of the execute property associated with this block- Specified by:
isExecutein interfaceMemoryBlock- Returns:
- true if enabled else false
-
setExecute
public void setExecute(boolean x) Description copied from interface:MemoryBlockSets the execute property associated with this block.- Specified by:
setExecutein interfaceMemoryBlock- Parameters:
x- the value to set the execute property to.
-
setPermissions
public void setPermissions(boolean read, boolean write, boolean execute) Description copied from interface:MemoryBlockSets the read, write, execute permissions on this block- Specified by:
setPermissionsin interfaceMemoryBlock- Parameters:
read- the read permissionwrite- the write permissionexecute- the execute permission
-
isVolatile
public boolean isVolatile()Description copied from interface:MemoryBlockReturns the volatile attribute state of this block. This attribute is generally associated with block of I/O regions of memory.- Specified by:
isVolatilein interfaceMemoryBlock- Returns:
- true if enabled else false
-
setVolatile
public void setVolatile(boolean v) Description copied from interface:MemoryBlockSets the volatile attribute state associated of this block. This attribute is generally associated with block of I/O regions of memory.- Specified by:
setVolatilein interfaceMemoryBlock- Parameters:
v- the volatile attribute state.
-
isArtificial
public boolean isArtificial()Description copied from interface:MemoryBlockReturns 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.- Specified by:
isArtificialin interfaceMemoryBlock- Returns:
- true if enabled else false
-
setArtificial
public void setArtificial(boolean a) Description copied from interface:MemoryBlockSets 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.- Specified by:
setArtificialin interfaceMemoryBlock- Parameters:
a- the artificial attribute state.
-
getSourceName
Description copied from interface:MemoryBlockGet the name of the source of this memory block.- Specified by:
getSourceNamein interfaceMemoryBlock- Returns:
- source name
-
setSourceName
Description copied from interface:MemoryBlockSets the name of the source file that provided the data.- Specified by:
setSourceNamein interfaceMemoryBlock- Parameters:
sourceName- the name of the source file.
-
getByte
Description copied from interface:MemoryBlockReturns the byte at the given address in this block.- Specified by:
getBytein interfaceMemoryBlock- Parameters:
addr- the address.- Returns:
- byte value from this block and specified address
- Throws:
MemoryAccessException- if any of the requested bytes are uninitialized.
-
getBytes
Description copied from interface:MemoryBlockTries 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.- Specified by:
getBytesin interfaceMemoryBlock- 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.
-
getBytes
public int getBytes(Address addr, byte[] b, int off, int len) throws IndexOutOfBoundsException, MemoryAccessException Description copied from interface:MemoryBlockTries 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.- Specified by:
getBytesin interfaceMemoryBlock- 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.
-
putByte
Description copied from interface:MemoryBlockPuts the given byte at the given address in this block.- Specified by:
putBytein interfaceMemoryBlock- Parameters:
addr- the address.b- byte value- Throws:
MemoryAccessException- if the block is uninitialized
-
putBytes
Description copied from interface:MemoryBlockTries 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.- Specified by:
putBytesin interfaceMemoryBlock- 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 uninitialized
-
putBytes
public int putBytes(Address addr, byte[] b, int off, int len) throws IndexOutOfBoundsException, MemoryAccessException Description copied from interface:MemoryBlockTries 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.- Specified by:
putBytesin interfaceMemoryBlock- 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 uninitialized
-
isInitialized
public boolean isInitialized()Description copied from interface:MemoryBlockReturn 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.
- Specified by:
isInitializedin interfaceMemoryBlock- Returns:
- true if block is fully initialized and not a memory-mapped-block, else false
-
isMapped
public boolean isMapped()Description copied from interface:MemoryBlockReturns true if this is either a bit-mapped or byte-mapped block- Specified by:
isMappedin interfaceMemoryBlock- Returns:
- true if this is either a bit-mapped or byte-mapped block
-
isLoaded
public boolean isLoaded()Description copied from interface:MemoryBlockReturns 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.- Specified by:
isLoadedin interfaceMemoryBlock- Returns:
- true if this is a loaded block and not a "special" block such as a file header.
-
getType
Description copied from interface:MemoryBlockGet the type for this block: DEFAULT, BIT_MAPPED, or BYTE_MAPPED (seeMemoryBlockType).- Specified by:
getTypein interfaceMemoryBlock- Returns:
- memory block type
-
isOverlay
public boolean isOverlay()Description copied from interface:MemoryBlockReturns true if this is an overlay block (i.e., contained within overlay space).- Specified by:
isOverlayin interfaceMemoryBlock- Returns:
- true if this is an overlay block
-
getByte
- Throws:
MemoryAccessException
-
getBytes
public int getBytes(long offset, byte[] b, int off, int len) throws IndexOutOfBoundsException, MemoryAccessException -
getBlockOffset
- Throws:
MemoryAccessException
-
invalidate
public void invalidate() -
getSourceInfos
Description copied from interface:MemoryBlockReturns a list ofMemoryBlockSourceInfoobjects 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.- Specified by:
getSourceInfosin interfaceMemoryBlock- Returns:
- a list of SourceInfo objects, one for each different source of bytes in this block.
-
toString
-