public abstract class

AbstractVirtualMemory

extends Object
implements IVirtualMemory
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.memory.AbstractVirtualMemory

Class Overview

A skeleton implementation for virtual memory classes. Most trivial methods are implemented here.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory
Public Constructors
AbstractVirtualMemory()
Public Methods
void addAllocListener(IMemoryAllocListener listener)
void addFreeListener(IMemoryFreeListener listener)
void addPreWriteListener(IMemoryWriteListener listener)
Note: The callback is invoked before the write operation takes place.
void addPropertyListener(IMemoryPropertyListener listener)
void addProtectionListener(IMemoryProtectionListener listener)
void addWriteListener(IMemoryWriteListener listener)
void allocatePage(long address, int protection)
Allocate a single page.
void freePage(long address)
Free a single page.
int getAproximateFootprint()
Determine the approximate memory footprint of this object, in kilobytes.
synchronized int readBEInt(long address)
Read a big-endian 32-bit integer.
synchronized long readBELong(long address)
Read a big-endian 64-bit integer.
synchronized short readBEShort(long address)
Read a big-endian 16-bit integer.
synchronized byte readByte(long address)
Convenience method.
synchronized int readInt(long address, Endianness end)
Read a 32-bit integer.
synchronized int readInt(long address)
Read a 32-bit integer using the standard endianness.
synchronized int readLEInt(long address)
Read a little-endian 32-bit integer.
synchronized long readLELong(long address)
Read a little-endian 64-bit integer.
synchronized short readLEShort(long address)
Read a little-endian 16-bit integer.
synchronized long readLong(long address, Endianness end)
Read a 64-bit integer.
synchronized long readLong(long address)
Read a 64-bit integer using the standard endianness.
long readPointer(long address)
@return
synchronized short readShort(long address, Endianness end)
Read a 16-bit integer.
synchronized short readShort(long address)
Read a 16-bit integer using the standard endianness.
void removeAllocListener(IMemoryAllocListener listener)
void removeFreeListener(IMemoryFreeListener listener)
void removePreWriteListener(IMemoryWriteListener listener)
void removePropertyListener(IMemoryPropertyListener listener)
void removeProtectionListener(IMemoryProtectionListener listener)
void removeWriteListener(IMemoryWriteListener listener)
long roundToPage(long address)
Round an address to the page this address currently resides in, that is the highest page so that boundary ≤ address.
long roundToSize(long address)
Round an address to the lowest page boundary so that address ≤ boundary.
void setLazyMemoryProvider(ILazyMemoryProvider lazyMemoryProvider, boolean skipFailedAllocations)
Set a lazy memory provider.
synchronized void writeBEInt(long address, int v)
Write a big-endian 32-bit integer.
synchronized void writeBELong(long address, long v)
Write a big-endian 64-bit integer.
synchronized void writeBEShort(long address, short v)
Write a big-endian 16-bit integer.
synchronized void writeByte(long address, byte v)
Write a byte.
synchronized void writeInt(long address, int v, Endianness end)
Write a 32-bit integer.
synchronized void writeInt(long address, int v)
Write a 32-bit integer using the standard endianness.
synchronized void writeLEInt(long address, int v)
Write a little-endian 32-bit integer.
synchronized void writeLELong(long address, long v)
Write a little-endian 64-bit integer.
synchronized void writeLEShort(long address, short v)
Write a little-endian 16-bit integer.
synchronized void writeLong(long address, long v)
Write a 64-bit integer using the standard endianness.
synchronized void writeLong(long address, long v, Endianness end)
Write a 64-bit integer.
void writePointer(long address, long ptr)
synchronized void writeShort(long address, short v)
Write a 16-bit integer using the standard endianness.
synchronized void writeShort(long address, short v, Endianness end)
Write a 16-bit integer.
Protected Methods
List<IMemoryAllocListener> getAllocListeners()
List<IMemoryFreeListener> getFreeListeners()
List<IMemoryWriteListener> getPreWriteListeners()
List<IMemoryPropertyListener> getPropertyListeners()
List<IMemoryProtectionListener> getProtectionListeners()
List<IMemoryWriteListener> getWriteListeners()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory

Public Constructors

public AbstractVirtualMemory ()

Public Methods

public void addAllocListener (IMemoryAllocListener listener)

public void addFreeListener (IMemoryFreeListener listener)

public void addPreWriteListener (IMemoryWriteListener listener)

Note: The callback is invoked before the write operation takes place.

public void addPropertyListener (IMemoryPropertyListener listener)

public void addProtectionListener (IMemoryProtectionListener listener)

public void addWriteListener (IMemoryWriteListener listener)

public void allocatePage (long address, int protection)

Allocate a single page. See allocate(long, int, int).

public void freePage (long address)

Free a single page. See free(long, int).

public int getAproximateFootprint ()

Determine the approximate memory footprint of this object, in kilobytes.

Returns
  • a size in Kb

public synchronized int readBEInt (long address)

Read a big-endian 32-bit integer. This method does not do partial reads.@return

public synchronized long readBELong (long address)

Read a big-endian 64-bit integer. This method does not do partial reads.@return

public synchronized short readBEShort (long address)

Read a big-endian 16-bit integer. This method does not do partial reads.@return

public synchronized byte readByte (long address)

Convenience method. Read a byte.@return

public synchronized int readInt (long address, Endianness end)

Read a 32-bit integer. This method does not do partial reads.@return

public synchronized int readInt (long address)

Read a 32-bit integer using the standard endianness. This method does not do partial reads.@return

public synchronized int readLEInt (long address)

Read a little-endian 32-bit integer. This method does not do partial reads.@return

public synchronized long readLELong (long address)

Read a little-endian 64-bit integer. This method does not do partial reads.@return

public synchronized short readLEShort (long address)

Read a little-endian 16-bit integer. This method does not do partial reads.@return

public synchronized long readLong (long address, Endianness end)

Read a 64-bit integer. This method does not do partial reads.@return

public synchronized long readLong (long address)

Read a 64-bit integer using the standard endianness. This method does not do partial reads.@return

public long readPointer (long address)

@return

public synchronized short readShort (long address, Endianness end)

Read a 16-bit integer. This method does not do partial reads.@return

public synchronized short readShort (long address)

Read a 16-bit integer using the standard endianness. This method does not do partial reads.@return

public void removeAllocListener (IMemoryAllocListener listener)

public void removeFreeListener (IMemoryFreeListener listener)

public void removePreWriteListener (IMemoryWriteListener listener)

public void removePropertyListener (IMemoryPropertyListener listener)

public void removeProtectionListener (IMemoryProtectionListener listener)

public void removeWriteListener (IMemoryWriteListener listener)

public long roundToPage (long address)

Round 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.

Parameters
address an address
Returns
  • the containing page address

public long roundToSize (long address)

Round 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.

Parameters
address an address or a size

public void setLazyMemoryProvider (ILazyMemoryProvider lazyMemoryProvider, boolean skipFailedAllocations)

Set a lazy memory provider. This operation is optional. If the memory object supports it, the 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).

Parameters
lazyMemoryProvider a non-null lazy memory provider
skipFailedAllocations 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
UnsupportedOperationException

public synchronized void writeBEInt (long address, int v)

Write a big-endian 32-bit integer. This method does not do partial writes.

public synchronized void writeBELong (long address, long v)

Write a big-endian 64-bit integer. This method does not do partial writes.

public synchronized void writeBEShort (long address, short v)

Write a big-endian 16-bit integer. This method does not do partial writes.

public synchronized void writeByte (long address, byte v)

Write a byte.

public synchronized void writeInt (long address, int v, Endianness end)

Write a 32-bit integer. This method does not do partial writes.

public synchronized void writeInt (long address, int v)

Write a 32-bit integer using the standard endianness. This method does not do partial writes.

public synchronized void writeLEInt (long address, int v)

Write a little-endian 32-bit integer. This method does not do partial writes.

public synchronized void writeLELong (long address, long v)

Write a little-endian 64-bit integer. This method does not do partial writes.

public synchronized void writeLEShort (long address, short v)

Write a little-endian 16-bit integer. This method does not do partial writes.

public synchronized void writeLong (long address, long v)

Write a 64-bit integer using the standard endianness. This method does not do partial writes.

public synchronized void writeLong (long address, long v, Endianness end)

Write a 64-bit integer. This method does not do partial writes.

public void writePointer (long address, long ptr)

public synchronized void writeShort (long address, short v)

Write a 16-bit integer using the standard endianness. This method does not do partial writes.

public synchronized void writeShort (long address, short v, Endianness end)

Write a 16-bit integer. This method does not do partial writes.

Protected Methods

protected List<IMemoryAllocListener> getAllocListeners ()

protected List<IMemoryFreeListener> getFreeListeners ()

protected List<IMemoryWriteListener> getPreWriteListeners ()

protected List<IMemoryPropertyListener> getPropertyListeners ()

protected List<IMemoryProtectionListener> getProtectionListeners ()

protected List<IMemoryWriteListener> getWriteListeners ()