Class MemoryBlockUtil
- java.lang.Object
-
- ghidra.app.util.MemoryBlockUtil
-
public class MemoryBlockUtil extends java.lang.Object
A utility class that encapsulates the creation of different types of memory blocks in a program.
-
-
Constructor Summary
Constructors Constructor Description MemoryBlockUtil(Program program, MemoryConflictHandler handler)
Constructs a new memory block utility.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MemoryBlock
createInitializedBlock(java.lang.String name, Address start, byte[] data, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
Creates an initialized memory block using a byte array.MemoryBlock
createInitializedBlock(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
Creates an initialized memory block using the specified input stream.MemoryBlock
createMappedBlock(boolean isBitMapped, java.lang.String name, Address start, Address base, int length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
Creates a bit or byte mapped memory block.MemoryBlock
createOverlayBlock(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor)
Creates an initialized overlay memory block using the specified input stream.MemoryBlock
createUninitializedBlock(boolean isOverlay, java.lang.String name, Address start, long length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
Creates an uninitialized memory block.void
dispose()
This method performs cleanup with this object is no longer needed.java.lang.String
getMessages()
Return error messages.
-
-
-
Constructor Detail
-
MemoryBlockUtil
public MemoryBlockUtil(Program program, MemoryConflictHandler handler)
Constructs a new memory block utility.- Parameters:
program
- the program having memory blocks createdhandler
- the memory conflict handler
-
-
Method Detail
-
getMessages
public java.lang.String getMessages()
Return error messages.
-
dispose
public void dispose()
This method performs cleanup with this object is no longer needed. This method should be invoked to prevent potential memory leaks.
-
createMappedBlock
public MemoryBlock createMappedBlock(boolean isBitMapped, java.lang.String name, Address start, Address base, int length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
Creates a bit or byte mapped memory block.- Parameters:
isBitMapped
- if true, creates a bit mapped block, otherwise a byte mapped blockname
- name of the blockstart
- start address of the blockbase
- base address for the bit blocklength
- length of the blockcomment
- comment for the blocksource
- source of the block, where it originatedr
- is block read-only?w
- is block writeable?x
- is block executable?- Returns:
- the newly created memory block or null (see messages)
-
createUninitializedBlock
public MemoryBlock createUninitializedBlock(boolean isOverlay, java.lang.String name, Address start, long length, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x)
Creates an uninitialized memory block.- Parameters:
isOverlay
- true if overlay space and block should be createdsname
- name of the blockstart
- start address of the blocklength
- length of the blockcomment
- comment for the blocksource
- source of the block, where it originatedr
- is block read-only?w
- is block writeable?x
- is block executable?- Returns:
- the newly created memory block or null (see messages)
-
createInitializedBlock
public MemoryBlock createInitializedBlock(java.lang.String name, Address start, byte[] data, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor) throws AddressOverflowException
Creates an initialized memory block using a byte array.- Parameters:
name
- name of the blockstart
- start address of the blockdata
- the bytes for the memory blockcomment
- comment for the blocksource
- source of the block, where it originatedr
- is block read-only?w
- is block writeable?x
- is block executable?monitor
- the task monitor- Returns:
- the newly created memory block or null (see messages)
- Throws:
AddressOverflowException
-
createInitializedBlock
public MemoryBlock createInitializedBlock(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor) throws AddressOverflowException
Creates an initialized memory block using the specified input stream. If the length of the block is greater than the maximum size of a memory block (0x40000000), then the block is broken in to multiple blocks. The first block created will have the given name and each subsequent block will have ".1", ".2", etc., appended to the base name. The first block created will be the one returned by this call.The MemoryConflictHandler is responsible for determining how to deal with memory conflict exceptions that occur with initialized memory blocks.
Any uninitialized memory blocks involved in the conflict will be removed and replaced with initialized memory blocks.
If only a portion of the uninitialized memory block has caused a conflict, then only that portion will be removed and replaced. Subsequently, the uninitialized memory blocks boundaries may change.
When other types of memory blocks are involved in a conflict, only the bytes will be replaced. The boundaries will not change. Initialized memory blocks will be created around the existing ones. Also, when bytes change from under an existing memory block, then all code units in the range of the conflict will be cleared.
- Parameters:
name
- name of the blockstart
- start address of the blockdataInput
- an input stream containing the bytes for the blockdataLength
- length of the blockcomment
- comment for the blocksource
- source of the block, where it originatedr
- is block read-only?w
- is block writeable?x
- is block executable?monitor
- the task monitor- Returns:
- new block or null on failure (see messages)
- Throws:
AddressOverflowException
-
createOverlayBlock
public MemoryBlock createOverlayBlock(java.lang.String name, Address start, java.io.InputStream dataInput, long dataLength, java.lang.String comment, java.lang.String source, boolean r, boolean w, boolean x, TaskMonitor monitor) throws AddressOverflowException, DuplicateNameException
Creates an initialized overlay memory block using the specified input stream.- Parameters:
name
- name of the blockstart
- start address of the blockdataInput
- an input stream containing the bytes for the blockdataLength
- length of the blockcomment
- comment for the blocksource
- source of the block, where it originatedr
- is block read-only?w
- is block writeable?x
- is block executable?monitor
- the task monitor- Returns:
- the newly created memory block
- Throws:
AddressOverflowException
DuplicateNameException
-
-