Class StubMemory
- All Implemented Interfaces:
AddressSetView,Memory,Iterable<AddressRange>
-
Field Summary
Fields inherited from interface ghidra.program.model.mem.Memory
GBYTE, GBYTE_SHIFT_FACTOR, MAX_BINARY_SIZE, MAX_BINARY_SIZE_GB, MAX_BLOCK_SIZE, MAX_BLOCK_SIZE_GB -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToInitialized(MemoryBlock uninitializedBlock, byte initialValue) Convert an existing uninitialized block with an initialized block.convertToUninitialized(MemoryBlock initializedBlock) 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.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 aFileBytesobject.createInitializedBlock(String name, Address start, InputStream is, long length, TaskMonitor monitor, boolean overlay) Create an initialized memory block based upon a dataInputStreamand 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.booleandeleteFileBytes(FileBytes descriptor) 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.Finds the first address in this collection that is also in the given addressSet.getAddresses(boolean forward) Returns an iterator over all addresses in this set.getAddresses(Address start, boolean forward) Returns an iterator over the addresses in this address set starting at the start addressgetAddressRanges(boolean forward) Returns an iterator over the ranges in the specified ordergetAddressRanges(Address start, boolean forward) Returns an iterator of address ranges starting with the range that contains the given address.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.byteGet byte at addr.intGet dest.length number of bytes starting at the given address.intGet 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.Returns the first range in this set or null if the set is emptyUseMemory.getLoadedAndInitializedAddressSet()instead.intGet the int at addr.intGet the int at addr using the specified endian order.intGet dest.length number of ints starting at the given address.intGet dest.length number of ints starting at the given address.intGet dest.length number of ints starting at the given address.Returns the last range in this set or null if the set is emptyReturns the set of addresses which correspond to all the "loaded" memory blocks that have initialized data.longGet the long at addr.longGet the long at addr in the specified endian order.intGet dest.length number of longs starting at the given address.intGet dest.length number of longs starting at the given address.intGet dest.length number of longs starting at the given address.Get the maximum address for this address set.Get the minimum address for this address set.longintReturns the program that this memory belongs to.getRangeContaining(Address address) Returns the range that contains the given addressshortGet the short at addr.shortGet the short at addr using the specified endian order.intGet dest.length number of shorts starting at the given address.intGet dest.length number of shorts starting at the given address.intGet dest.length number of shorts starting at the given address.longgetSize()Get the memory size in bytes.booleanintersects(Address start, Address end) Determine if the start and end range intersects with the specified address set.booleanintersects(AddressSetView addrSet) Determine if this address set intersects with the specified address set.booleanReturns true if the memory is bigEndian, false otherwise.booleanisEmpty()iterator()Returns an iterator over the address ranges in this address set.iterator(boolean forward) Returns an iterator over the ranges in the specified orderReturns an iterator of address ranges starting with the range that contains the given address.join(MemoryBlock blockOne, MemoryBlock blockTwo) Join the two blocks to create a single memory block.voidmoveBlock(MemoryBlock block, Address newStartAddr, TaskMonitor monitor) Move the memory block containing source address to the destination address.voidremoveBlock(MemoryBlock block, TaskMonitor monitor) Remove the memory block.voidWrite byte at addr.voidWrite size bytes from values at addr.voidWrite an array of bytes.voidWrite int at addr in the default endian order.voidWrite int at addr in the specified endian order.voidWrite long at addr in the default endian order.voidWrite long at addr in the specified endian order.voidWrite short at addr in default endian order.voidWrite short at addr in the specified endian order.voidsplit(MemoryBlock block, Address addr) Split a block at the given addr and create a new block starting at addr.xor(AddressSetView addrSet) Computes the exclusive-or of this address set with the given set.Methods inherited from class ghidra.program.model.address.AddressSet
add, add, add, add, addRange, addRange, clear, contains, contains, contains, delete, delete, delete, deleteFromMin, deleteRange, deleteToMax, equals, hashCode, hasSameAddresses, intersect, intersectRange, printRanges, subtract, toList, toString, unionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.address.AddressSetView
contains, contains, contains, getAddressCountBefore, hasSameAddresses, intersect, intersectRange, spliterator, spliterator, spliterator, stream, stream, stream, subtract, unionMethods inherited from interface ghidra.program.model.mem.Memory
createByteMappedBlock, isExternalBlockAddress, locateAddressesForFileBytesOffset, locateAddressesForFileOffset
-
Constructor Details
-
StubMemory
public StubMemory() -
StubMemory
public StubMemory(byte[] bytes)
-
-
Method Details
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAddressSetView- Overrides:
isEmptyin classAddressSet- Returns:
- true if this set is empty.
-
getMinAddress
Description copied from interface:AddressSetViewGet the minimum address for this address set.NOTE: An
AddressRangeshould generally not be formed using this address andAddressSetView.getMaxAddress()since it may span multipleAddressSpaces.- Specified by:
getMinAddressin interfaceAddressSetView- Overrides:
getMinAddressin classAddressSet- Returns:
- the minimum address for this set. Returns null if the set is empty.
-
getMaxAddress
Description copied from interface:AddressSetViewGet the maximum address for this address set.NOTE: An
AddressRangeshould generally not be formed using this address andAddressSetView.getMaxAddress()since it may span multipleAddressSpaces.- Specified by:
getMaxAddressin interfaceAddressSetView- Overrides:
getMaxAddressin classAddressSet- Returns:
- the maximum address for this set. Returns null if the set is empty.
-
getNumAddressRanges
public int getNumAddressRanges()- Specified by:
getNumAddressRangesin interfaceAddressSetView- Overrides:
getNumAddressRangesin classAddressSet- Returns:
- the number of address ranges in this set.
-
getAddressRanges
- Specified by:
getAddressRangesin interfaceAddressSetView- Overrides:
getAddressRangesin classAddressSet- Returns:
- an iterator over the address ranges in this address set.
-
getAddressRanges
Description copied from interface:AddressSetViewReturns an iterator over the ranges in the specified order- Specified by:
getAddressRangesin interfaceAddressSetView- Overrides:
getAddressRangesin classAddressSet- Parameters:
forward- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the addresse ranges in the set.
-
getAddressRanges
Description copied from interface:AddressSetViewReturns an iterator of address ranges starting with the range that contains the given address.If there is no range containing the start address, then the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address
- Specified by:
getAddressRangesin interfaceAddressSetView- Overrides:
getAddressRangesin classAddressSet- Parameters:
start- the address the first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
iterator
Description copied from interface:AddressSetViewReturns an iterator over the address ranges in this address set.- Specified by:
iteratorin interfaceAddressSetView- Specified by:
iteratorin interfaceIterable<AddressRange>- Overrides:
iteratorin classAddressSet
-
iterator
Description copied from interface:AddressSetViewReturns an iterator over the ranges in the specified order- Specified by:
iteratorin interfaceAddressSetView- Overrides:
iteratorin classAddressSet- Parameters:
forward- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the address ranges in the set.
-
iterator
Description copied from interface:AddressSetViewReturns an iterator of address ranges starting with the range that contains the given address.If there is no range containing the start address, then the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address
- Specified by:
iteratorin interfaceAddressSetView- Overrides:
iteratorin classAddressSet- Parameters:
start- the address that the first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
getNumAddresses
public long getNumAddresses()- Specified by:
getNumAddressesin interfaceAddressSetView- Overrides:
getNumAddressesin classAddressSet- Returns:
- the number of addresses in this set.
-
getAddresses
Description copied from interface:AddressSetViewReturns an iterator over all addresses in this set.- Specified by:
getAddressesin interfaceAddressSetView- Overrides:
getAddressesin classAddressSet- Parameters:
forward- if true the address are return in increasing order, otherwise in decreasing order.- Returns:
- an iterator over all addresses in this set.
-
getAddresses
Description copied from interface:AddressSetViewReturns an iterator over the addresses in this address set starting at the start address- Specified by:
getAddressesin interfaceAddressSetView- Overrides:
getAddressesin classAddressSet- Parameters:
start- address to start iterating at in the address setforward- if true address are return from lowest to highest, else from highest to lowest- Returns:
- an iterator over the addresses in this address set starting at the start address
-
intersects
Description copied from interface:AddressSetViewDetermine if this address set intersects with the specified address set.- Specified by:
intersectsin interfaceAddressSetView- Overrides:
intersectsin classAddressSet- Parameters:
addrSet- address set to check intersection with.- Returns:
- true if this set intersects the specified addrSet else false
-
intersects
Description copied from interface:AddressSetViewDetermine if the start and end range intersects with the specified address set.The specified start and end addresses must form a valid range within a single
AddressSpace.- Specified by:
intersectsin interfaceAddressSetView- Overrides:
intersectsin classAddressSet- Parameters:
start- start of rangeend- end of range- Returns:
- true if the given range intersects this address set.
-
xor
Description copied from interface:AddressSetViewComputes the exclusive-or of this address set with the given set.This method does not modify this address set.
- Specified by:
xorin interfaceAddressSetView- Overrides:
xorin classAddressSet- Parameters:
addrSet- address set to exclusive-or with.- Returns:
- AddressSet a new address set containing all addresses that are in either this set or the given set, but not in both sets
-
getFirstRange
Description copied from interface:AddressSetViewReturns the first range in this set or null if the set is empty- Specified by:
getFirstRangein interfaceAddressSetView- Overrides:
getFirstRangein classAddressSet- Returns:
- the first range in this set or null if the set is empty
-
getLastRange
Description copied from interface:AddressSetViewReturns the last range in this set or null if the set is empty- Specified by:
getLastRangein interfaceAddressSetView- Overrides:
getLastRangein classAddressSet- Returns:
- the last range in this set or null if the set is empty
-
getRangeContaining
Description copied from interface:AddressSetViewReturns the range that contains the given address- Specified by:
getRangeContainingin interfaceAddressSetView- Overrides:
getRangeContainingin classAddressSet- Parameters:
address- the address for which to find a range.- Returns:
- the range that contains the given address.
-
getProgram
Description copied from interface:MemoryReturns the program that this memory belongs to.- Specified by:
getProgramin interfaceMemory
-
getLoadedAndInitializedAddressSet
Description copied from interface:MemoryReturns 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.- Specified by:
getLoadedAndInitializedAddressSetin interfaceMemory
-
getAllInitializedAddressSet
Description copied from interface:MemoryReturns 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. UseMemory.getLoadedAndInitializedAddressSet()if you only want the addressed of the loaded in memory blocks.- Specified by:
getAllInitializedAddressSetin interfaceMemory
-
getInitializedAddressSet
Description copied from interface:MemoryUseMemory.getLoadedAndInitializedAddressSet()instead.- Specified by:
getInitializedAddressSetin interfaceMemory
-
getExecuteSet
Description copied from interface:MemoryReturns the set of addresses which correspond to the executable memory.- Specified by:
getExecuteSetin interfaceMemory
-
isBigEndian
public boolean isBigEndian()Description copied from interface:MemoryReturns true if the memory is bigEndian, false otherwise.- Specified by:
isBigEndianin interfaceMemory
-
createInitializedBlock
public MemoryBlock createInitializedBlock(String name, Address start, InputStream is, long length, TaskMonitor monitor, boolean overlay) Description copied from interface:MemoryCreate an initialized memory block based upon a dataInputStreamand add it to this Memory.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createInitializedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(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 thestartaddress 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 specifiedstartaddress is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Specifying a
-
createInitializedBlock
public MemoryBlock createInitializedBlock(String name, Address start, long size, byte initialValue, TaskMonitor monitor, boolean overlay) Description copied from interface:MemoryCreate 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
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createInitializedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(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 thestartaddress 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 specifiedstartaddress is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Specifying a
-
createUninitializedBlock
Description copied from interface:MemoryCreate an uninitialized memory block and add it to this Memory.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createUninitializedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(String)for naming rules)start- start of the blocksize- block lengthoverlay- if true, the block will be created as an OVERLAY block. If thestartaddress 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 specifiedstartaddress is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Uninitialized Memory Block
- Specifying a
-
createBitMappedBlock
public MemoryBlock createBitMappedBlock(String name, Address start, Address mappedAddress, long length, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException Description copied from interface:MemoryCreate 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
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createBitMappedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(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 thestartaddress 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 specifiedstartaddress 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 space
- Specifying a
-
createByteMappedBlock
public MemoryBlock createByteMappedBlock(String name, Address start, Address mappedAddress, long length, ByteMappingScheme byteMappingScheme, boolean overlay) throws LockException, MemoryConflictException, AddressOverflowException, IllegalArgumentException Description copied from interface:MemoryCreate 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
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createByteMappedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(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 thestartaddress 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 specifiedstartaddress 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
public MemoryBlock createBlock(MemoryBlock block, String name, Address start, long length) throws LockException, MemoryConflictException, AddressOverflowException Description copied from interface:MemoryCreates 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.- Specified by:
createBlockin interfaceMemory- Parameters:
block- source blockname- block name (SeeMemory.isValidMemoryBlockName(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 space
-
removeBlock
Description copied from interface:MemoryRemove the memory block.- Specified by:
removeBlockin interfaceMemory- 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
public long getSize()Description copied from interface:MemoryGet the memory size in bytes. -
getBlock
Description copied from interface:MemoryReturns the Block which contains addr. -
getBlock
Description copied from interface:MemoryReturns the Block with the specified blockName -
getBlocks
Description copied from interface:MemoryReturns an array containing all the memory blocks. -
moveBlock
public void moveBlock(MemoryBlock block, Address newStartAddr, TaskMonitor monitor) throws LockException, MemoryBlockException, MemoryConflictException, AddressOverflowException, NotFoundException Description copied from interface:MemoryMove the memory block containing source address to the destination address.- Specified by:
moveBlockin interfaceMemory- 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())MemoryBlockException- if block movement is not permittedMemoryConflictException- if move would cause blocks to overlap.AddressOverflowException- if block movement would violate bounds of address spaceNotFoundException- if memoryBlock does not exist in this memory.
-
split
public void split(MemoryBlock block, Address addr) throws MemoryBlockException, LockException, NotFoundException Description copied from interface:MemorySplit a block at the given addr and create a new block starting at addr.- Specified by:
splitin interfaceMemory- Parameters:
block- block to be split into twoaddr- address (within block) that will be the start of new block- Throws:
MemoryBlockException- memory split not permittedLockException- if exclusive lock not in place (see haveLock())NotFoundException- thrown if block does not exist in memory
-
join
public MemoryBlock join(MemoryBlock blockOne, MemoryBlock blockTwo) throws LockException, MemoryBlockException, NotFoundException Description copied from interface:MemoryJoin the two blocks to create a single memory block. IMPORTANT! When done, both blockOne and blockTwo should no longer be used.- Specified by:
joinin interfaceMemory- 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
public MemoryBlock convertToInitialized(MemoryBlock uninitializedBlock, byte initialValue) throws LockException, MemoryBlockException, NotFoundException Description copied from interface:MemoryConvert an existing uninitialized block with an initialized block.- Specified by:
convertToInitializedin interfaceMemory- 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
public MemoryBlock convertToUninitialized(MemoryBlock initializedBlock) throws MemoryBlockException, NotFoundException, LockException - Specified by:
convertToUninitializedin interfaceMemory- Throws:
MemoryBlockExceptionNotFoundExceptionLockException
-
findBytes
public Address findBytes(Address addr, byte[] bytes, byte[] masks, boolean forward, TaskMonitor monitor) Description copied from interface:MemoryFinds 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.- Specified by:
findBytesin interfaceMemory- 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
public Address findBytes(Address startAddr, Address endAddr, byte[] bytes, byte[] masks, boolean forward, TaskMonitor monitor) Description copied from interface:MemoryFinds 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.- Specified by:
findBytesin interfaceMemory- 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
Description copied from interface:MemoryGet byte at addr.- Specified by:
getBytein interfaceMemory- Parameters:
addr- the Address of the byte.- Returns:
- the byte.
- Throws:
MemoryAccessException- if the address is not contained in any memory block.
-
getBytes
Description copied from interface:MemoryGet dest.length number of bytes starting at the given address.- Specified by:
getBytesin interfaceMemory- 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
Description copied from interface:MemoryGet size number of bytes starting at the given address and populates dest starting at dIndex.- Specified by:
getBytesin interfaceMemory- Parameters:
addr- the starting Address.dest- the byte array to populate.dIndex- 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:
MemoryAccessException- if the starting address is not contained in any memory block or is an uninitialized location.
-
getShort
Description copied from interface:MemoryGet the short at addr.- Specified by:
getShortin interfaceMemory- Parameters:
addr- the Address where the short starts.- Returns:
- the short.
- Throws:
MemoryAccessException- if not all needed bytes are contained in initialized memory.
-
getShort
Description copied from interface:MemoryGet the short at addr using the specified endian order.- Specified by:
getShortin interfaceMemory- 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
Description copied from interface:MemoryGet dest.length number of shorts starting at the given address.- Specified by:
getShortsin interfaceMemory- 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
public int getShorts(Address addr, short[] dest, int dIndex, int nElem) throws MemoryAccessException Description copied from interface:MemoryGet dest.length number of shorts starting at the given address.- Specified by:
getShortsin interfaceMemory- 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
public int getShorts(Address addr, short[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Description copied from interface:MemoryGet dest.length number of shorts starting at the given address.- Specified by:
getShortsin interfaceMemory- 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
Description copied from interface:MemoryGet the int at addr.- Specified by:
getIntin interfaceMemory- Parameters:
addr- the Address where the int starts.- Returns:
- the int.
- Throws:
MemoryAccessException- if not all needed bytes are contained in initialized memory.
-
getInt
Description copied from interface:MemoryGet the int at addr using the specified endian order.- Specified by:
getIntin interfaceMemory- 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
Description copied from interface:MemoryGet dest.length number of ints starting at the given address.- Specified by:
getIntsin interfaceMemory- 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
Description copied from interface:MemoryGet dest.length number of ints starting at the given address.- Specified by:
getIntsin interfaceMemory- 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
public int getInts(Address addr, int[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Description copied from interface:MemoryGet dest.length number of ints starting at the given address.- Specified by:
getIntsin interfaceMemory- 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
Description copied from interface:MemoryGet the long at addr.- Specified by:
getLongin interfaceMemory- Parameters:
addr- the Address where the long starts.- Returns:
- the long.
- Throws:
MemoryAccessException- if not all needed bytes are contained in initialized memory.
-
getLong
Description copied from interface:MemoryGet the long at addr in the specified endian order.- Specified by:
getLongin interfaceMemory- 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
Description copied from interface:MemoryGet dest.length number of longs starting at the given address.- Specified by:
getLongsin interfaceMemory- 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
Description copied from interface:MemoryGet dest.length number of longs starting at the given address.- Specified by:
getLongsin interfaceMemory- 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
public int getLongs(Address addr, long[] dest, int dIndex, int nElem, boolean isBigEndian) throws MemoryAccessException Description copied from interface:MemoryGet dest.length number of longs starting at the given address.- Specified by:
getLongsin interfaceMemory- 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
Description copied from interface:MemoryWrite byte at addr.- Specified by:
setBytein interfaceMemory- Parameters:
addr- the Address of the byte.value- the data to write.- Throws:
MemoryAccessException- if writing is not allowed.
-
setBytes
Description copied from interface:MemoryWrite size bytes from values at addr.- Specified by:
setBytesin interfaceMemory- Parameters:
addr- the starting Address.source- the bytes to write.- Throws:
MemoryAccessException- if writing is not allowed.
-
setBytes
public void setBytes(Address addr, byte[] source, int sIndex, int size) throws MemoryAccessException Description copied from interface:MemoryWrite an array of bytes. This should copy size bytes or fail!- Specified by:
setBytesin interfaceMemory- 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
Description copied from interface:MemoryWrite short at addr in default endian order.- Specified by:
setShortin interfaceMemory- Parameters:
addr- the Address of the short.value- the data to write.- Throws:
MemoryAccessException- if writing is not allowed.
-
setShort
Description copied from interface:MemoryWrite short at addr in the specified endian order.- Specified by:
setShortin interfaceMemory- 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
Description copied from interface:MemoryWrite int at addr in the default endian order.- Specified by:
setIntin interfaceMemory- Parameters:
addr- the Address of the int.value- the data to write.- Throws:
MemoryAccessException- if writing is not allowed.
-
setInt
Description copied from interface:MemoryWrite int at addr in the specified endian order.- Specified by:
setIntin interfaceMemory- 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
Description copied from interface:MemoryWrite long at addr in the default endian order.- Specified by:
setLongin interfaceMemory- Parameters:
addr- the Address of the long.value- the data to write.- Throws:
MemoryAccessException- if writing is not allowed.
-
setLong
Description copied from interface:MemoryWrite long at addr in the specified endian order.- Specified by:
setLongin interfaceMemory- 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.
-
findFirstAddressInCommon
Description copied from interface:AddressSetViewFinds the first address in this collection that is also in the given addressSet.- Specified by:
findFirstAddressInCommonin interfaceAddressSetView- Overrides:
findFirstAddressInCommonin classAddressSet- Parameters:
set- the addressSet to search for the first (lowest) common address.- Returns:
- the first address that is contained in this set and the given set.
-
createFileBytes
public FileBytes createFileBytes(String filename, long offset, long size, InputStream is, TaskMonitor monitor) throws IOException Description copied from interface:MemoryStores a sequence of bytes into the program. Typically, this method is used by importers to store the original raw program bytes.- Specified by:
createFileBytesin interfaceMemory- 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.
-
getAllFileBytes
Description copied from interface:MemoryReturns a list of all the stored original file bytes objects- Specified by:
getAllFileBytesin interfaceMemory- Returns:
- a list of all the stored original file bytes objects
-
deleteFileBytes
Description copied from interface:MemoryDeletes a stored sequence of file bytes. The file bytes can only be deleted if there are no memory block references to the file bytes.- Specified by:
deleteFileBytesin interfaceMemory- Parameters:
descriptor- 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.
-
createInitializedBlock
public MemoryBlock createInitializedBlock(String name, Address start, FileBytes fileBytes, long offset, long size, boolean overlay) Description copied from interface:MemoryCreate an initialized memory block using bytes from aFileBytesobject.Overlay Blocks: An overlay memory block may be created in two ways:
- Specifying a
startaddress within an existing overlay address space (overlayparameter is ignored), or - Specifying a
startaddress within a physical memory address space and passingoverlay=true. This use case will force the creation of a new unique overlay address space.
- Specified by:
createInitializedBlockin interfaceMemory- Parameters:
name- block name (SeeMemory.isValidMemoryBlockName(String)for naming rules)start- starting address of the blockfileBytes- theFileBytesobject 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 thestartaddress 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 specifiedstartaddress is an overlay address an overlay block will be created at that overlay address.- Returns:
- new Initialized Memory Block
- Specifying a
-
getAddressSourceInfo
Description copied from interface:MemoryReturns information (AddressSourceInfo) about the byte source at the given address.- Specified by:
getAddressSourceInfoin interfaceMemory- 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.
-