Package envi :: Module memory :: Class IMemory
[hide private]
[frames] | no frames]

Class IMemory

source code

Known Subclasses:

This is the interface spec (and a few helper utils) for the unified memory object interface.

NOTE: If your actual underlying memory format is such that over-riding anything (like isValidPointer!) can be faster than the default implementation, DO IT!

Instance Methods [hide private]
 
__init__(self, archmod=None) source code
 
addMemoryMap(self, mapva, perms, fname, bytes) source code
 
allocateMemory(self, size, perms=7, suggestaddr=0) source code
 
getMemoryMap(self, va)
Return a tuple of mapva,size,perms,filename for the memory map which contains the specified address (or None).
source code
 
getMemoryMaps(self) source code
 
getPointerSize(self) source code
 
getSegmentInfo(self, id) source code
 
isExecutable(self, va) source code
 
isReadable(self, va) source code
 
isShared(self, va) source code
 
isValidPointer(self, va) source code
 
isWriteable(self, va) source code
 
parseOpcode(self, va)
Parse an opcode from the specified virtual address.
source code
 
probeMemory(self, va, size, perm)
Check to be sure that the given virtual address and size is contained within one memory map, and check that the perms are contained within the permission bits for the memory map.
source code
 
protectMemory(self, va, size, perms)
Change the protections for the given memory map.
source code
 
readMemValue(self, addr, size) source code
 
readMemory(self, va, size)
Read memory from the specified virtual address for size bytes and return it as a python string.
source code
 
readMemoryFormat(self, va, fmt) source code
 
searchMemory(self, needle, regex=False)
A quick cheater way to searchMemoryRange() for each of the current memory maps.
source code
 
searchMemoryRange(self, needle, address, size, regex=False)
Search the specified memory range (address -> size) for the string needle.
source code
 
writeMemory(self, va, bytes)
Write the given bytes to the specified virtual address.
source code
 
writeMemoryFormat(self, va, fmt, *args)
Write a python format sequence of variables out to memory after serializing using struct pack...
source code
Method Details [hide private]

parseOpcode(self, va)

source code 

Parse an opcode from the specified virtual address.

Example: op = m.parseOpcode(0x7c773803)

probeMemory(self, va, size, perm)

source code 

Check to be sure that the given virtual address and size is contained within one memory map, and check that the perms are contained within the permission bits for the memory map. (MM_READ | MM_WRITE | MM_EXEC | ...)

Example probeMemory(0x41414141, 20, envi.memory.MM_WRITE) (check if the memory for 20 bytes at 0x41414141 is writable)

protectMemory(self, va, size, perms)

source code 

Change the protections for the given memory map. On most platforms the va/size *must* exactly match an existing memory map.

readMemory(self, va, size)

source code 

Read memory from the specified virtual address for size bytes and return it as a python string.

Example: mem.readMemory(0x41414141, 20) -> "A..."

searchMemoryRange(self, needle, address, size, regex=False)

source code 

Search the specified memory range (address -> size) for the string needle. Return a list of addresses where the match occurs.

writeMemory(self, va, bytes)

source code 

Write the given bytes to the specified virtual address.

Example: mem.writeMemory(0x41414141, "VISI")

writeMemoryFormat(self, va, fmt, *args)

source code 

Write a python format sequence of variables out to memory after
serializing using struct pack...

Example:
    trace.writeMemoryFormat(va, '<PBB', 10, 30, 99)