The memory plugin provides symbolic memory operations for angr states. It’s accessible viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/angr/angr/llms.txt
Use this file to discover all available pages before exploring further.
state.memory and provides methods for reading, writing, and manipulating memory.
Overview
The memory plugin is implemented as a paged memory system that supports symbolic addresses and values. It’s built using theDefaultMemory class which combines multiple mixins to provide a full-featured memory subsystem.
Accessing Memory
Memory can be accessed directly throughstate.memory or through the convenient state.mem interface.
Core Methods
load
The address to load from. Can be a concrete integer or symbolic bitvector.
The number of bytes to load.
The endianness to use (‘Iend_LE’ or ‘Iend_BE’). Defaults to the architecture’s memory endness.
Whether to trigger SimInspect breakpoints for this operation.
Whether to disable creating SimActions for this operation.
The loaded value as a claripy bitvector.
store
The address to store to. Can be a concrete integer or symbolic bitvector.
The data to store. Can be a bitvector, integer, or bytes.
The number of bytes to store. Required if data is not a bitvector.
The endianness to use (‘Iend_LE’ or ‘Iend_BE’).
find
The address to start searching from.
The pattern to search for.
Maximum number of bytes to search.
Maximum number of symbolic bytes to allow in search.
The address where the pattern was found, or the default value if not found.
copy_contents
Destination address.
Source address.
Number of bytes to copy.
Memory Regions
map_region
The starting address of the region.
The length of the region in bytes.
Permission flags (1=read, 2=write, 4=execute). Can be combined with bitwise OR.
Whether to initialize the region with zeros.
unmap_region
The starting address of the region to unmap.
The length of the region in bytes.
permissions
The address to query or modify.
If provided, sets the permissions. If None, returns current permissions.
The number of bytes affected.
Current permissions if querying, None if setting.
Advanced Features
Concrete Store
For performance-critical code, you can use concrete stores that bypass symbolic execution:Replace All
The AST to replace.
The AST to replace it with.
Memory Backing
Memory can be initialized from various sources:Properties
Unique identifier for this memory region (e.g., ‘mem’, ‘reg’).
Default endianness for memory operations.
The state this memory belongs to.
Memory Types
angr provides several memory implementations optimized for different use cases:DefaultMemory
DefaultMemory
Full-featured paged memory with support for symbolic addresses, permissions, and all memory operations. This is the standard memory type used in most analyses.
FastMemory
FastMemory
Simplified memory implementation optimized for concrete execution. Lacks some features but provides better performance.
AbstractMemory
AbstractMemory
Memory implementation for static analysis with abstract interpretation. Stores abstract values instead of concrete bitvectors.
RegionedMemory
RegionedMemory
Memory divided into named regions (stack, heap, global, etc.) for better organization and analysis.
Examples
Reading and Writing Strings
Working with Symbolic Memory
Memory Search
See Also
- SimMemView - Convenient typed memory interface
- Registers Plugin - Register file access
- Solver Plugin - Constraint solving