Class AbstractVirtualMemory
java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.memory.AbstractVirtualMemory
- All Implemented Interfaces:
IVirtualMemory
A skeleton implementation for virtual memory classes. Most trivial methods are implemented here.
-
Field Summary
Fields inherited from interface com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory
ACCESS_EXECUTE, ACCESS_NONE, ACCESS_READ, ACCESS_RW, ACCESS_RWX, ACCESS_RX, ACCESS_WRITE, AM_ARM64_48BIT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllocListener(IMemoryAllocListener listener) voidaddFreeListener(IMemoryFreeListener listener) voidaddPreWriteListener(IMemoryWriteListener listener) Note: The callback is invoked before the write operation takes place.voidaddPropertyListener(IMemoryPropertyListener listener) voidvoidaddWriteListener(IMemoryWriteListener listener) voidallocatePage(long address, int protection) Allocate a single page.voidfreePage(long address) Free a single page.protected List<IMemoryAllocListener>intDetermine the approximate memory footprint of this object, in kilobytes.protected List<IMemoryFreeListener>protected List<IMemoryWriteListener>protected List<IMemoryPropertyListener>protected List<IMemoryProtectionListener>protected List<IMemoryWriteListener>intreadBEInt(long address) Read a big-endian 32-bit integer.longreadBELong(long address) Read a big-endian 64-bit integer.shortreadBEShort(long address) Read a big-endian 16-bit integer.bytereadByte(long address) Convenience method.intreadInt(long address) Read a 32-bit integer using thestandard endianness.intreadInt(long address, Endianness end) Read a 32-bit integer.intreadLEInt(long address) Read a little-endian 32-bit integer.longreadLELong(long address) Read a little-endian 64-bit integer.shortreadLEShort(long address) Read a little-endian 16-bit integer.longreadLong(long address) Read a 64-bit integer using thestandard endianness.longreadLong(long address, Endianness end) Read a 64-bit integer.longreadPointer(long address) shortreadShort(long address) Read a 16-bit integer using thestandard endianness.shortreadShort(long address, Endianness end) Read a 16-bit integer.voidremoveAllocListener(IMemoryAllocListener listener) voidremoveFreeListener(IMemoryFreeListener listener) voidremovePreWriteListener(IMemoryWriteListener listener) voidvoidvoidremoveWriteListener(IMemoryWriteListener listener) longroundToPage(long address) Round an address to the page this address currently resides in, that is the highest page so that boundary ≤ address.longroundToSize(long address) Round an address to the lowest page boundary so that address ≤ boundary.voidsetLazyMemoryProvider(ILazyMemoryProvider lazyMemoryProvider, boolean skipFailedAllocations) Set a lazy memory provider.voidwriteBEInt(long address, int v) Write a big-endian 32-bit integer.voidwriteBELong(long address, long v) Write a big-endian 64-bit integer.voidwriteBEShort(long address, short v) Write a big-endian 16-bit integer.voidwriteByte(long address, byte v) Write a byte.voidwriteInt(long address, int v) Write a 32-bit integer using thestandard endianness.voidwriteInt(long address, int v, Endianness end) Write a 32-bit integer.voidwriteLEInt(long address, int v) Write a little-endian 32-bit integer.voidwriteLELong(long address, long v) Write a little-endian 64-bit integer.voidwriteLEShort(long address, short v) Write a little-endian 16-bit integer.voidwriteLong(long address, long v) Write a 64-bit integer using thestandard endianness.voidwriteLong(long address, long v, Endianness end) Write a 64-bit integer.voidwritePointer(long address, long ptr) voidwriteShort(long address, short v) Write a 16-bit integer using thestandard endianness.voidwriteShort(long address, short v, Endianness end) Write a 16-bit integer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory
allocate, check, duplicate, free, getAddressMassager, getAllocatedPageBases, getAllocatedPageCount, getPageBits, getPageProtection, getPageSize, getSpaceBits, getStandardEndianess, isAllocatedPage, isValidAddress, read, read, setAddressMassagerType, setPageProtection, setStandardEndianness, write, write
-
Constructor Details
-
AbstractVirtualMemory
public AbstractVirtualMemory()
-
-
Method Details
-
roundToPage
public long roundToPage(long address) Description copied from interface:IVirtualMemoryRound an address to the page this address currently resides in, that is the highest page so that boundary ≤ address. This method does not raise, even if the address is invalid for this memory space.- Specified by:
roundToPagein interfaceIVirtualMemory- Parameters:
address- an address- Returns:
- the containing page address
-
roundToSize
public long roundToSize(long address) Description copied from interface:IVirtualMemoryRound an address to the lowest page boundary so that address ≤ boundary. This method does not raise, even if the address is invalid for this memory space.- Specified by:
roundToSizein interfaceIVirtualMemory- Parameters:
address- an address or a size- Returns:
-
allocatePage
Description copied from interface:IVirtualMemoryAllocate a single page. SeeIVirtualMemory.allocate(long, int, int).- Specified by:
allocatePagein interfaceIVirtualMemory- Throws:
MemoryException
-
freePage
Description copied from interface:IVirtualMemoryFree a single page. SeeIVirtualMemory.free(long, int).- Specified by:
freePagein interfaceIVirtualMemory- Throws:
MemoryException
-
readByte
Description copied from interface:IVirtualMemoryConvenience method. Read a byte.- Specified by:
readBytein interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeByte
Description copied from interface:IVirtualMemoryWrite a byte.- Specified by:
writeBytein interfaceIVirtualMemory- Throws:
MemoryException
-
readLEShort
Description copied from interface:IVirtualMemoryRead a little-endian 16-bit integer. This method does not do partial reads.- Specified by:
readLEShortin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeLEShort
Description copied from interface:IVirtualMemoryWrite a little-endian 16-bit integer. This method does not do partial writes.- Specified by:
writeLEShortin interfaceIVirtualMemory- Throws:
MemoryException
-
readLEInt
Description copied from interface:IVirtualMemoryRead a little-endian 32-bit integer. This method does not do partial reads.- Specified by:
readLEIntin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeLEInt
Description copied from interface:IVirtualMemoryWrite a little-endian 32-bit integer. This method does not do partial writes.- Specified by:
writeLEIntin interfaceIVirtualMemory- Throws:
MemoryException
-
readLELong
Description copied from interface:IVirtualMemoryRead a little-endian 64-bit integer. This method does not do partial reads.- Specified by:
readLELongin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeLELong
Description copied from interface:IVirtualMemoryWrite a little-endian 64-bit integer. This method does not do partial writes.- Specified by:
writeLELongin interfaceIVirtualMemory- Throws:
MemoryException
-
readBEShort
Description copied from interface:IVirtualMemoryRead a big-endian 16-bit integer. This method does not do partial reads.- Specified by:
readBEShortin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeBEShort
Description copied from interface:IVirtualMemoryWrite a big-endian 16-bit integer. This method does not do partial writes.- Specified by:
writeBEShortin interfaceIVirtualMemory- Throws:
MemoryException
-
readBEInt
Description copied from interface:IVirtualMemoryRead a big-endian 32-bit integer. This method does not do partial reads.- Specified by:
readBEIntin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeBEInt
Description copied from interface:IVirtualMemoryWrite a big-endian 32-bit integer. This method does not do partial writes.- Specified by:
writeBEIntin interfaceIVirtualMemory- Throws:
MemoryException
-
readBELong
Description copied from interface:IVirtualMemoryRead a big-endian 64-bit integer. This method does not do partial reads.- Specified by:
readBELongin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeBELong
Description copied from interface:IVirtualMemoryWrite a big-endian 64-bit integer. This method does not do partial writes.- Specified by:
writeBELongin interfaceIVirtualMemory- Throws:
MemoryException
-
readShort
Description copied from interface:IVirtualMemoryRead a 16-bit integer using thestandard endianness. This method does not do partial reads.- Specified by:
readShortin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeShort
Description copied from interface:IVirtualMemoryWrite a 16-bit integer using thestandard endianness. This method does not do partial writes.- Specified by:
writeShortin interfaceIVirtualMemory- Throws:
MemoryException
-
readInt
Description copied from interface:IVirtualMemoryRead a 32-bit integer using thestandard endianness. This method does not do partial reads.- Specified by:
readIntin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeInt
Description copied from interface:IVirtualMemoryWrite a 32-bit integer using thestandard endianness. This method does not do partial writes.- Specified by:
writeIntin interfaceIVirtualMemory- Throws:
MemoryException
-
readLong
Description copied from interface:IVirtualMemoryRead a 64-bit integer using thestandard endianness. This method does not do partial reads.- Specified by:
readLongin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeLong
Description copied from interface:IVirtualMemoryWrite a 64-bit integer using thestandard endianness. This method does not do partial writes.- Specified by:
writeLongin interfaceIVirtualMemory- Throws:
MemoryException
-
readShort
Description copied from interface:IVirtualMemoryRead a 16-bit integer. This method does not do partial reads.- Specified by:
readShortin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeShort
Description copied from interface:IVirtualMemoryWrite a 16-bit integer. This method does not do partial writes.- Specified by:
writeShortin interfaceIVirtualMemory- Throws:
MemoryException
-
readInt
Description copied from interface:IVirtualMemoryRead a 32-bit integer. This method does not do partial reads.- Specified by:
readIntin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeInt
Description copied from interface:IVirtualMemoryWrite a 32-bit integer. This method does not do partial writes.- Specified by:
writeIntin interfaceIVirtualMemory- Throws:
MemoryException
-
readLong
Description copied from interface:IVirtualMemoryRead a 64-bit integer. This method does not do partial reads.- Specified by:
readLongin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writeLong
Description copied from interface:IVirtualMemoryWrite a 64-bit integer. This method does not do partial writes.- Specified by:
writeLongin interfaceIVirtualMemory- Throws:
MemoryException
-
readPointer
- Specified by:
readPointerin interfaceIVirtualMemory- Returns:
- Throws:
MemoryException
-
writePointer
- Specified by:
writePointerin interfaceIVirtualMemory- Throws:
MemoryException
-
getPropertyListeners
-
getAllocListeners
-
getFreeListeners
-
getProtectionListeners
-
getPreWriteListeners
-
getWriteListeners
-
addPropertyListener
- Specified by:
addPropertyListenerin interfaceIVirtualMemory
-
removePropertyListener
- Specified by:
removePropertyListenerin interfaceIVirtualMemory
-
addAllocListener
- Specified by:
addAllocListenerin interfaceIVirtualMemory
-
removeAllocListener
- Specified by:
removeAllocListenerin interfaceIVirtualMemory
-
addFreeListener
- Specified by:
addFreeListenerin interfaceIVirtualMemory
-
removeFreeListener
- Specified by:
removeFreeListenerin interfaceIVirtualMemory
-
addProtectionListener
- Specified by:
addProtectionListenerin interfaceIVirtualMemory
-
removeProtectionListener
- Specified by:
removeProtectionListenerin interfaceIVirtualMemory
-
addPreWriteListener
Description copied from interface:IVirtualMemoryNote: The callback is invoked before the write operation takes place.- Specified by:
addPreWriteListenerin interfaceIVirtualMemory
-
removePreWriteListener
- Specified by:
removePreWriteListenerin interfaceIVirtualMemory
-
addWriteListener
- Specified by:
addWriteListenerin interfaceIVirtualMemory
-
removeWriteListener
- Specified by:
removeWriteListenerin interfaceIVirtualMemory
-
setLazyMemoryProvider
public void setLazyMemoryProvider(ILazyMemoryProvider lazyMemoryProvider, boolean skipFailedAllocations) throws MemoryException, UnsupportedOperationException Description copied from interface:IVirtualMemorySet a lazy memory provider. This operation is optional. If the memory object supports it, theILazyMemoryProvider.getRanges()method will be called to reserve the ranges of memory that the provider can provide. A lazy provider provides memory data on demand, i.e. when the data bytes are accessed (read or write).- Specified by:
setLazyMemoryProviderin interfaceIVirtualMemory- Parameters:
lazyMemoryProvider- a non-null lazy memory providerskipFailedAllocations- if true, the provider will not hard-fail if it provides data for a range for which data already exists in the virtual memory; else, the method will throw- Throws:
MemoryException- if a page reservation failed and skipFailedAllocations isfalse(example: the memory provider requests to allocate an already allocated range)UnsupportedOperationException- if the implementation does not support that feature
-
getAproximateFootprint
public int getAproximateFootprint()Description copied from interface:IVirtualMemoryDetermine the approximate memory footprint of this object, in kilobytes.- Specified by:
getAproximateFootprintin interfaceIVirtualMemory- Returns:
- a size in Kb
-