Interface Memory
- All Superinterfaces:
AddressSetView
,Iterable<AddressRange>
- All Known Implementing Classes:
MemoryMapDB
,StubMemory
Memory
provides the ability to inspect and manage the memory model for a Program
.
In addition to conventional MemoryBlock
s defined within physical memory
AddressSpace
s other special purpose memory block types may be defined (e.g.,
byte-mapped, bit-mapped, overlays, etc.).
All memory block manipulations require excusive access (see DomainObject.hasExclusiveAccess()
)
and all memory changes should generally be completed prior to analysis. In particular, adding
additional overlay blocks to an existing overlay space that has already been analyzed should be
avoided. Code references discovered during analysis from an overlay block will give preference
to remaining within the corresponding overlay address space provided a block exists at the
referenced offset.
Block Types
- Initialized - a memory block which defines a memory region with specific data.
Data may be initialized from defined
FileBytes
, anInputStream
, or set to all zeros. - Uninitialized - a memory block which defines a memory region whose data is unknown.
- Byte-Mapped - a memory block whose bytes are mapped to another memory region using
either a 1:1 byte-mapping or other specified mapping scheme (see
ByteMappingScheme
). Byte read/write operations are passed-through the mapped region. - Bit-Mapped - a memory block whose bytes are mapped to a corresponding bit in another memory region where a mapped byte has a value of 0 or 1 only. Byte read/write operations are passed-through to the corresponding bit within the mapped region.
Overlay Blocks An overlay memory block provides the ability to define alternate content for a physical memory region. Any of the Block Types above may be created as an overlay block. The use of an overlay block and its corresponding overlay address space can be used to reflect a different execution context. Use of overlays during analysis has limitations that must be considered.
Loaded vs. Non-Loaded
A special purpose AddressSpace.OTHER_SPACE
has been established for storing adhoc
non-loaded data as a memory block. This is frequently used for storing portions of a file
that never actually get loaded into memory. All blocks created using the
AddressSpace.OTHER_SPACE
must be created as an overlay memory block. All other
blocks based upon a memory address space, including overlays, are treated as Loaded and
use offsets into a physical memory space.
Sub-Blocks When a memory block is first created it corresponds to a single sub-block. When a block join operation is performed the resulting block will consist of multiple sub-blocks. However, the join operation is restricted to default block types only and does not support byte/bit-mapped types.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final int
static final long
static final int
Maximum size of all memory blocks, 16-GByte (seegetAllInitializedAddressSet()
).static final long
static final int
The current max size of a memory block. -
Method Summary
Modifier and TypeMethodDescriptionconvertToInitialized
(MemoryBlock uninitializedBlock, byte initialValue) Convert an existing uninitialized block with an initialized block.convertToUninitialized
(MemoryBlock itializedBlock) createBitMappedBlock
(String name, Address start, Address mappedAddress, long length, boolean overlay) Create a bit-mapped overlay memory block and add it to this Memory.createBlock
(MemoryBlock block, String name, Address start, long length) Creates a MemoryBlock at the given address with the same properties as block, and adds it to this Memory.default MemoryBlock
createByteMappedBlock
(String name, Address start, Address mappedAddress, long length, boolean overlay) Create a byte-mapped memory block and add it to this memory.createByteMappedBlock
(String name, Address start, Address mappedAddress, long length, ByteMappingScheme byteMappingScheme, boolean overlay) Create a byte-mapped memory block and add it to this memory.createFileBytes
(String filename, long offset, long size, InputStream is, TaskMonitor monitor) Stores a sequence of bytes into the program.createInitializedBlock
(String name, Address start, long size, byte initialValue, TaskMonitor monitor, boolean overlay) Create an initialized memory block initialized and add it to this Memory.createInitializedBlock
(String name, Address start, FileBytes fileBytes, long offset, long size, boolean overlay) Create an initialized memory block using bytes from aFileBytes
object.createInitializedBlock
(String name, Address start, InputStream is, long length, TaskMonitor monitor, boolean overlay) Create an initialized memory block based upon a dataInputStream
and add it to this Memory.createUninitializedBlock
(String name, Address start, long size, boolean overlay) Create an uninitialized memory block and add it to this Memory.boolean
deleteFileBytes
(FileBytes fileBytes) Deletes a stored sequence of file bytes.findBytes
(Address addr, byte[] bytes, byte[] masks, boolean forward, TaskMonitor monitor) Finds a sequence of contiguous bytes that match the given byte array at all bit positions where the mask contains an "on" bit.findBytes
(Address startAddr, Address endAddr, byte[] bytes, byte[] masks, boolean forward, TaskMonitor monitor) Finds a sequence of contiguous bytes that match the given byte array at all bit positions where the mask contains an "on" bit.getAddressSourceInfo
(Address address) Returns information (AddressSourceInfo
) about the byte source at the given address.Returns a list of all the stored original file bytes objectsReturns the set of addresses which correspond to all memory blocks that have initialized data.Returns the Block which contains addr.Returns the Block with the specified blockNameReturns an array containing all the memory blocks.byte
Get byte at addr.int
Get dest.length number of bytes starting at the given address.int
Get size number of bytes starting at the given address and populates dest starting at dIndex.Returns the set of addresses which correspond to the executable memory.Deprecated.int
Get the int at addr.int
Get the int at addr using the specified endian order.int
Get dest.length number of ints starting at the given address.int
Get dest.length number of ints starting at the given address.int
Get dest.length number of ints starting at the given address.Returns the live memory handler instance used by this memory.Returns the set of addresses which correspond to all the "loaded" memory blocks that have initialized data.long
Get the long at addr.long
Get the long at addr in the specified endian order.int
Get dest.length number of longs starting at the given address.int
Get dest.length number of longs starting at the given address.int
Get dest.length number of longs starting at the given address.Returns the program that this memory belongs to.short
Get the short at addr.short
Get the short at addr using the specified endian order.int
Get dest.length number of shorts starting at the given address.int
Get dest.length number of shorts starting at the given address.int
Get dest.length number of shorts starting at the given address.long
getSize()
Get the memory size in bytes.boolean
Returns true if the memory is bigEndian, false otherwise.default boolean
Determine if the specified address is contained within the reserved EXTERNAL block (seeMemoryBlock.EXTERNAL_BLOCK_NAME
).static boolean
isValidMemoryBlockName
(String name) Validate the given block name: cannot be null, cannot be an empty string, cannot contain control characters (ASCII 0..0x19).join
(MemoryBlock blockOne, MemoryBlock blockTwo) Join the two blocks to create a single memory block.locateAddressesForFileBytesOffset
(FileBytes fileBytes, long offset) Gets a list of addresses where the byte at the given offset from the given FileBytes was loaded into memory.locateAddressesForFileOffset
(long fileOffset) void
moveBlock
(MemoryBlock block, Address newStartAddr, TaskMonitor monitor) Move the memory block containing source address to the destination address.void
removeBlock
(MemoryBlock block, TaskMonitor monitor) Remove the memory block.void
Write byte at addr.void
Write size bytes from values at addr.void
Write an array of bytes.void
Write int at addr in the default endian order.void
Write int at addr in the specified endian order.void
setLiveMemoryHandler
(LiveMemoryHandler handler) Sets the live memory handlervoid
Write long at addr in the default endian order.void
Write long at addr in the specified endian order.void
Write short at addr in default endian order.void
Write short at addr in the specified endian order.void
split
(MemoryBlock block, Address addr) Split a block at the given addr and create a new block starting at addr.Methods inherited from interface ghidra.program.model.address.AddressSetView
contains, contains, contains, findFirstAddressInCommon, getAddressCountBefore, getAddresses, getAddresses, getAddressRanges, getAddressRanges, getAddressRanges, getFirstRange, getLastRange, getMaxAddress, getMinAddress, getNumAddresses, getNumAddressRanges, getRangeContaining, hasSameAddresses, intersect, intersectRange, intersects, intersects, isEmpty, iterator, iterator, iterator, subtract, union, xor
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
GBYTE_SHIFT_FACTOR
static final int GBYTE_SHIFT_FACTOR- See Also:
-
GBYTE
static final long GBYTE- See Also:
-
MAX_BINARY_SIZE_GB
static final int MAX_BINARY_SIZE_GBMaximum size of all memory blocks, 16-GByte (seegetAllInitializedAddressSet()
). This restriction is somewhat arbitrary but is established to prevent an excessive number of memory map segments which can have a negative impact on performance.- See Also:
-
MAX_BINARY_SIZE
static final long MAX_BINARY_SIZE- See Also:
-
MAX_BLOCK_SIZE_GB
static final int MAX_BLOCK_SIZE_GBThe current max size of a memory block.- See Also:
-
MAX_BLOCK_SIZE
static final long MAX_BLOCK_SIZE- See Also:
-
-
Method Details
-
getProgram
Program getProgram()Returns the program that this memory belongs to. -
getLoadedAndInitializedAddressSet
AddressSetView getLoadedAndInitializedAddressSet()Returns the set of addresses which correspond to all the "loaded" memory blocks that have initialized data. This does not include initialized memory blocks that contain data from the program's file header such as debug sections. -
getAllInitializedAddressSet
AddressSetView getAllInitializedAddressSet()Returns the set of addresses which correspond to all memory blocks that have initialized data. This includes initialized memory blocks that contain data from the program's file header that are not actually in the running in memory image, such as debug sections. UsegetLoadedAndInitializedAddressSet()
if you only want the addressed of the loaded in memory blocks. -
getInitializedAddressSet
Deprecated.UsegetLoadedAndInitializedAddressSet()
instead. -
getExecuteSet
AddressSetView getExecuteSet()Returns the set of addresses which correspond to the executable memory. -
isBigEndian
boolean isBigEndian()Returns true if the memory is bigEndian, false otherwise. -
isExternalBlockAddress
Determine if the specified address is contained within the reserved EXTERNAL block (seeMemoryBlock.EXTERNAL_BLOCK_NAME
). This artificial memory block has certain limitations that may require associated addresses to be properly identified. All data access/referencing has the biggest exposure since the importers generally allocate a fixed and possibly insufficient amount of memory to corresponding data symbols. Any pointer math performed based upon an EXTERNAL block symbol address is likely to produce an unuseable address that may collide with unrelated symbols stored within the memory block (e.g.,OffsetReference
is one such example).- Parameters:
addr
- address- Returns:
- true if address is contained within EXTERNAL memory block, else false.
-
setLiveMemoryHandler
Sets the live memory handler- Parameters:
handler
- the live memory handler
-
getLiveMemoryHandler
LiveMemoryHandler getLiveMemoryHandler()Returns the live memory handler instance used by this memory.- Returns:
- the live memory handler
-
createInitializedBlock
MemoryBlock createInitializedBlock(String name, Address start, InputStream is, long length, TaskMonitor monitor, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException, CancelledException, IllegalArgumentException Create an initialized memory block based upon a dataInputStream
and add it to this Memory.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start address of the blockis
- source of the data used to fill the block or null for zero initialization.length
- the size of the blockmonitor
- task monitoroverlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceCancelledException
- user cancelled operationIllegalArgumentException
- if invalid block name specified
- Specifying a
-
createInitializedBlock
MemoryBlock createInitializedBlock(String name, Address start, long size, byte initialValue, TaskMonitor monitor, boolean overlay) throws LockException, IllegalArgumentException, MemoryConflictException, AddressOverflowException, CancelledException Create an initialized memory block initialized and add it to this Memory. All bytes will be initialized to the specified value (NOTE: use of zero as the initial value is encouraged for reduced storage).Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start of the blocksize
- block length (positive non-zero value required)initialValue
- initialization value for every byte in the block.monitor
- progress monitor, may be null.overlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name specifiedCancelledException
- user cancelled operation
- Specifying a
-
createInitializedBlock
MemoryBlock createInitializedBlock(String name, Address start, FileBytes fileBytes, long offset, long size, boolean overlay) throws LockException, IllegalArgumentException, MemoryConflictException, AddressOverflowException Create an initialized memory block using bytes from aFileBytes
object.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- starting address of the blockfileBytes
- theFileBytes
object to use as the underlying source of bytes.offset
- the offset into the FileBytes for the first byte of this memory block.size
- block length (positive non-zero value required)overlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIndexOutOfBoundsException
- if file bytes range specified by offset and size is out of bounds for the specified fileBytes.IllegalArgumentException
- if invalid block name specified
- Specifying a
-
createUninitializedBlock
MemoryBlock createUninitializedBlock(String name, Address start, long size, boolean overlay) throws LockException, IllegalArgumentException, MemoryConflictException, AddressOverflowException Create an uninitialized memory block and add it to this Memory.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start of the blocksize
- block lengthoverlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Uninitialized Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name specified
- Specifying a
-
createBitMappedBlock
MemoryBlock createBitMappedBlock(String name, Address start, Address mappedAddress, long length, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException, IllegalArgumentException Create a bit-mapped overlay memory block and add it to this Memory. Each byte address within the resulting memory block will correspond to a single bit location within the mapped region specified bymappedAddress
.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start of the blockmappedAddress
- start address in the source block for the beginning of this blocklength
- block lengthoverlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Bit Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockMemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name specified
- Specifying a
-
createByteMappedBlock
MemoryBlock createByteMappedBlock(String name, Address start, Address mappedAddress, long length, ByteMappingScheme byteMappingScheme, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException, IllegalArgumentException Create a byte-mapped memory block and add it to this memory. Each byte address within the resulting memory block will correspond to a byte within the mapped region specified bymappedAddress
. While a 1:1 byte-mapping is the default, a specific byte-mapping ratio may be specified.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start of the blockmappedAddress
- start address in the source block for the beginning of this blocklength
- block lengthbyteMappingScheme
- byte mapping scheme (may be null for 1:1 mapping)overlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Bit Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name
- Specifying a
-
createByteMappedBlock
default MemoryBlock createByteMappedBlock(String name, Address start, Address mappedAddress, long length, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException, IllegalArgumentException Create a byte-mapped memory block and add it to this memory. Each byte address within the resulting memory block will correspond to a byte within the mapped region specified bymappedAddress
using a 1:1 byte-mapping.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
start
address within an existing overlay address space (overlay
parameter is ignored), or - Specifying a
start
address within a physical memory address space and passingoverlay=true
. This use case will force the creation of a new unique overlay address space.
- Parameters:
name
- block name (SeeisValidMemoryBlockName(String)
for naming rules)start
- start of the blockmappedAddress
- start address in the source block for the beginning of this blocklength
- block lengthoverlay
- if true, the block will be created as an OVERLAY block. If thestart
address is a non-overlay memory address a new overlay address space will be created and the block will have a starting address at the same offset within the new overlay space. If the specifiedstart
address is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Bit Memory Block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if the new block overlaps with a previous blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name
- Specifying a
-
createBlock
MemoryBlock createBlock(MemoryBlock block, String name, Address start, long length) throws LockException, IllegalArgumentException, MemoryConflictException, AddressOverflowException Creates a MemoryBlock at the given address with the same properties as block, and adds it to this Memory. Initialized Default blocks will have block filled with 0's. Method will only create physical space blocks and will not create an overlay block.- Parameters:
block
- source blockname
- block name (SeeisValidMemoryBlockName(String)
for naming rules).start
- start of the blocklength
- the size of the new block.- Returns:
- new block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if block specification conflicts with an existing blockAddressOverflowException
- if block specification exceeds bounds of address spaceIllegalArgumentException
- if invalid block name specifiede
-
removeBlock
Remove the memory block.- Parameters:
block
- the block to be removed.monitor
- monitor that is used to cancel the remove operation- Throws:
LockException
- if exclusive lock not in place (see haveLock())
-
getSize
long getSize()Get the memory size in bytes. -
getBlock
Returns the Block which contains addr.- Parameters:
addr
- a valid data Address.- Returns:
- the block containing addr; null if addr is not a valid location.
-
getBlock
Returns the Block with the specified blockName- Parameters:
blockName
- the name of the requested block- Returns:
- the Block with the specified blockName
-
getBlocks
MemoryBlock[] getBlocks()Returns an array containing all the memory blocks. -
moveBlock
void moveBlock(MemoryBlock block, Address newStartAddr, TaskMonitor monitor) throws LockException, MemoryBlockException, MemoryConflictException, AddressOverflowException, NotFoundException Move the memory block containing source address to the destination address.- Parameters:
block
- block to be movednewStartAddr
- new start address for blockmonitor
- task monitor so the move block can be canceled- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryConflictException
- if move would cause blocks to overlap.MemoryBlockException
- if block movement is not permittedAddressOverflowException
- if block movement would violate bounds of address spaceNotFoundException
- if memoryBlock does not exist in this memory.
-
split
void split(MemoryBlock block, Address addr) throws MemoryBlockException, LockException, NotFoundException Split a block at the given addr and create a new block starting at addr.- Parameters:
block
- block to be split into twoaddr
- address (within block) that will be the start of new block- Throws:
LockException
- if exclusive lock not in place (see haveLock())NotFoundException
- thrown if block does not exist in memoryMemoryBlockException
- memory split not permittedAddressOutOfBoundsException
- thrown if address is not in the block
-
join
MemoryBlock join(MemoryBlock blockOne, MemoryBlock blockTwo) throws LockException, MemoryBlockException, NotFoundException Join the two blocks to create a single memory block. IMPORTANT! When done, both blockOne and blockTwo should no longer be used.- Parameters:
blockOne
- block to be combined with blockTwoblockTwo
- block to be combined with blockOne- Returns:
- new block
- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryBlockException
- thrown if the blocks are not contiguous in the address space,NotFoundException
-
convertToInitialized
MemoryBlock convertToInitialized(MemoryBlock uninitializedBlock, byte initialValue) throws LockException, MemoryBlockException, NotFoundException Convert an existing uninitialized block with an initialized block.- Parameters:
uninitializedBlock
- uninitialized block to convertinitialValue
- initial value for the bytes- Throws:
LockException
- if exclusive lock not in place (see haveLock())MemoryBlockException
- if there is no block in memory at the same address as block or if the block lengths are not the same.NotFoundException
-
convertToUninitialized
MemoryBlock convertToUninitialized(MemoryBlock itializedBlock) throws MemoryBlockException, NotFoundException, LockException -
findBytes
Finds a sequence of contiguous bytes that match the given byte array at all bit positions where the mask contains an "on" bit. Search is performed over loaded memory only.- Parameters:
addr
- The beginning address in memory to search.bytes
- the array of bytes to search for.masks
- the array of masks. (One for each byte in the byte array) if all bits of each byte is to be checked (ie: all mask bytes are 0xff), then pass a null for masks.forward
- if true, search in the forward direction.- Returns:
- The address of where the first match is found. Null is returned if there is no match.
-
findBytes
Address findBytes(Address startAddr, Address endAddr, byte[] bytes, byte[] masks, boolean forward, TaskMonitor monitor) Finds a sequence of contiguous bytes that match the given byte array at all bit positions where the mask contains an "on" bit. Starts at startAddr and ends at endAddr. If forward is true, search starts at startAddr and will end if startAddr ">" endAddr. If forward is false, search starts at start addr and will end if startAddr "<" endAddr.- Parameters:
startAddr
- The beginning address in memory to search.endAddr
- The ending address in memory to search (inclusive).bytes
- the array of bytes to search for.masks
- the array of masks. (One for each byte in the byte array) if all bits of each byte is to be checked (ie: all mask bytes are 0xff), then pass a null for masks.forward
- if true, search in the forward direction.- Returns:
- The address of where the first match is found. Null is returned if there is no match.
-
getByte
Get byte at addr.- Parameters:
addr
- the Address of the byte.- Returns:
- the byte.
- Throws:
MemoryAccessException
- if the address is not contained in any memory block.
-
getBytes
Get dest.length number of bytes starting at the given address.- Parameters:
addr
- the starting Address.dest
- the byte array to populate.- Returns:
- the number of bytes put into dest. May be less than dest.length if the requested number extends beyond available memory.
- Throws:
MemoryAccessException
- if the starting address is not contained in any memory block.
-
getBytes
Get size number of bytes starting at the given address and populates dest starting at dIndex.- Parameters:
addr
- the starting Address.dest
- the byte array to populate.destIndex
- the offset into dest to place the bytes.size
- the number of bytes to get.- Returns:
- the number of bytes put into dest. May be less than size if the requested number extends beyond initialized / available memory.
- Throws:
IndexOutOfBoundsException
- if an invalid index is specifiedMemoryAccessException
- if the starting address is not contained in any memory block or is an uninitialized location.
-
getShort
Get the short at addr.- Parameters:
addr
- the Address where the short starts.- Returns:
- the short.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getShort
Get the short at addr using the specified endian order.- Parameters:
addr
- the Address where the short starts.bigEndian
- true means to get the short in bigEndian order- Returns:
- the short.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getShorts
Get dest.length number of shorts starting at the given address.- Parameters:
addr
- the starting Address.dest
- the short array to populate.- Returns:
- the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getShorts
Get dest.length number of shorts starting at the given address.- Parameters:
addr
- the starting Address.dest
- the short array to populate.dIndex
- the offset into dest to place the shorts.nElem
- the number of shorts to get.- Returns:
- the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getShorts
int getShorts(Address addr, short[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Get dest.length number of shorts starting at the given address.- Parameters:
addr
- the starting Address.dest
- the short array to populate.dIndex
- the offset into dest to place the shorts.nElem
- the number of shorts to get.isBigEndian
- true means to get the shorts in bigEndian order- Returns:
- the number of shorts put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is odd, the final byte will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getInt
Get the int at addr.- Parameters:
addr
- the Address where the int starts.- Returns:
- the int.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getInt
Get the int at addr using the specified endian order.- Parameters:
addr
- the Address where the int starts.bigEndian
- true means to get the int in big endian order- Returns:
- the int.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getInts
Get dest.length number of ints starting at the given address.- Parameters:
addr
- the starting Address.dest
- the int array to populate.- Returns:
- the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if the starting address is not contained in any memory block.
-
getInts
Get dest.length number of ints starting at the given address.- Parameters:
addr
- the starting Address.dest
- the int array to populate.dIndex
- the offset into dest to place the ints.nElem
- the number of ints to get.- Returns:
- the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getInts
int getInts(Address addr, int[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Get dest.length number of ints starting at the given address.- Parameters:
addr
- the starting Address.dest
- the int array to populate.dIndex
- the offset into dest to place the ints.nElem
- the number of ints to get.isBigEndian
- true means to get the ints in bigEndian order- Returns:
- the number of ints put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 4, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getLong
Get the long at addr.- Parameters:
addr
- the Address where the long starts.- Returns:
- the long.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getLong
Get the long at addr in the specified endian order.- Parameters:
addr
- the Address where the long starts.bigEndian
- true means to get the long in big endian order- Returns:
- the long.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getLongs
Get dest.length number of longs starting at the given address.- Parameters:
addr
- the starting Address.dest
- the long array to populate.- Returns:
- the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getLongs
Get dest.length number of longs starting at the given address.- Parameters:
addr
- the starting Address.dest
- the long array to populate.dIndex
- the offset into dest to place the longs.nElem
- the number of longs to get.- Returns:
- the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
getLongs
int getLongs(Address addr, long[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Get dest.length number of longs starting at the given address.- Parameters:
addr
- the starting Address.dest
- the long array to populate.dIndex
- the offset into dest to place the longs.nElem
- the number of longs to get.isBigEndian
- true means to get the longs in bigEndian order- Returns:
- the number of longs put into dest. May be less than dest.length if the requested number extends beyond available memory. If the number of retrievable bytes is not 0 mod 8, the final byte(s) will be discarded.
- Throws:
MemoryAccessException
- if not all needed bytes are contained in initialized memory.
-
setByte
Write byte at addr.- Parameters:
addr
- the Address of the byte.value
- the data to write.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setBytes
Write size bytes from values at addr.- Parameters:
addr
- the starting Address.source
- the bytes to write.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setBytes
Write an array of bytes. This should copy size bytes or fail!- Parameters:
addr
- the starting Address of the bytes.source
- an array to get bytes from.sIndex
- the starting source index.size
- the number of bytes to fill.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setShort
Write short at addr in default endian order.- Parameters:
addr
- the Address of the short.value
- the data to write.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setShort
Write short at addr in the specified endian order.- Parameters:
addr
- the Address of the short.value
- the data to write.bigEndian
- true means to write short in big endian order- Throws:
MemoryAccessException
- if writing is not allowed.
-
setInt
Write int at addr in the default endian order.- Parameters:
addr
- the Address of the int.value
- the data to write.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setInt
Write int at addr in the specified endian order.- Parameters:
addr
- the Address of the int.value
- the data to write.bigEndian
- true means to write the short in bigEndian order- Throws:
MemoryAccessException
- if writing is not allowed.
-
setLong
Write long at addr in the default endian order.- Parameters:
addr
- the Address of the long.value
- the data to write.- Throws:
MemoryAccessException
- if writing is not allowed.
-
setLong
Write long at addr in the specified endian order.- Parameters:
addr
- the Address of the long.value
- the data to write.bigEndian
- true means to write the long in bigEndian order- Throws:
MemoryAccessException
- if writing is not allowed.
-
createFileBytes
FileBytes createFileBytes(String filename, long offset, long size, InputStream is, TaskMonitor monitor) throws IOException, CancelledException Stores a sequence of bytes into the program. Typically, this method is used by importers to store the original raw program bytes.- Parameters:
filename
- the name of the file from where the bytes originatedoffset
- the offset into the file for the first byte in the input stream.size
- the number of bytes to store from the input stream.is
- the input stream that will supply the bytes to store in the program. Caller is responsible for closing input stream upon return.monitor
- task monitor- Returns:
- a FileBytes that was created to access the bytes.
- Throws:
IOException
- if there was an IOException saving the bytes to the program database.CancelledException
- if the user cancelled this operation. Note: the database will be stable, but the buffers may contain 0s instead of the actual bytes.
-
getAllFileBytes
Returns a list of all the stored original file bytes objects- Returns:
- a list of all the stored original file bytes objects
-
deleteFileBytes
Deletes a stored sequence of file bytes. The file bytes can only be deleted if there are no memory block references to the file bytes.- Parameters:
fileBytes
- the FileBytes for the file bytes to be deleted.- Returns:
- true if the FileBytes was deleted. If any memory blocks are referenced by this FileBytes or it is invalid then it will not be deleted and false will be returned.
- Throws:
IOException
- if there was an error updating the database.
-
getAddressSourceInfo
Returns information (AddressSourceInfo
) about the byte source at the given address.- Parameters:
address
- the address to query. Returns null if the address is not in memory.- Returns:
- information (
AddressSourceInfo
) about the byte source at the given address or null if the address is not in memory.
-
isValidMemoryBlockName
Validate the given block name: cannot be null, cannot be an empty string, cannot contain control characters (ASCII 0..0x19).
NOTE: When producing an overlay memory space which corresponds to a block, the space name will be modified to be consistent with address space name restrictions and to ensure uniqueness.- Parameters:
name
- memory block name- Returns:
- true if name is valid else false
-
locateAddressesForFileOffset
-
locateAddressesForFileBytesOffset
Gets a list of addresses where the byte at the given offset from the given FileBytes was loaded into memory.- Parameters:
fileBytes
- the FileBytesobject whose byte is to be located in memoryoffset
- the file offset in the given FileBytes of the byte that is to be located in memory- Returns:
- a list of addresses that are associated with the given FileBytes and offset
-