Class MemoryPage

java.lang.Object
ghidra.pcode.memstate.MemoryPage

public class MemoryPage extends Object
MemoryPage is allows the contents/data of a memory page to be maintained along with an initializedMask. Each bit within the initializedMask corresponds to a data byte within the page. A null mask indicates that all data within the page is initialized. A one-bit within the mask indicates that the corresponding data byte is initialized.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    MemoryPage(byte[] bytes)
    Construct a memory page with an existing data bytes buffer
    MemoryPage(int pageSize)
    Construct a new fully initialized page containing all zero (0) byte data.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    getInitializedByteCount(byte[] initializedMask, int pageOffset, int size)
    Determine how many leading bytes of a specified page region is marked as initialized.
    int
    getInitializedByteCount(int pageOffset, int size)
    Get number of leading bytes within page range which have been initialized.
    byte[]
     
    static byte[]
    getInitializedMask(int pageSize, boolean initialized)
    Generate an initialized mask for the specified page size
    static byte[]
    getInitializedMask(int pageSize, int offset, int size, boolean initialized)
    Generate an initialized mask for the specified page size.
    void
    Mark entire page as uninitialized
    static void
    setInitialized(byte[] initializedMask, int pageOffset, int size)
    Mark specified page region as initialized.
    void
    setInitialized(int pageOffset, int size)
    Mark specified page region as initialized.
    void
    setInitialized(int pageOffset, int size, byte[] maskUpdate)
    Update initialization mask
    void
    Mark entire page as uninitialized
    static void
    setUninitialized(byte[] initializedMask, int pageOffset, int size)
    Mark specified page region as uninitialized.
    void
    setUninitialized(int pageOffset, int size)
    Mark specified page region as uninitialized.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • data

      public final byte[] data
  • Constructor Details

    • MemoryPage

      public MemoryPage(int pageSize)
      Construct a new fully initialized page containing all zero (0) byte data.
    • MemoryPage

      public MemoryPage(byte[] bytes)
      Construct a memory page with an existing data bytes buffer
      Parameters:
      bytes - buffer
  • Method Details

    • getInitializedMask

      public byte[] getInitializedMask()
    • setUninitialized

      public void setUninitialized()
      Mark entire page as uninitialized
    • setInitialized

      public void setInitialized()
      Mark entire page as uninitialized
    • setInitialized

      public void setInitialized(int pageOffset, int size, byte[] maskUpdate)
      Update initialization mask
      Parameters:
      pageOffset -
      size -
      maskUpdate -
    • setInitialized

      public void setInitialized(int pageOffset, int size)
      Mark specified page region as initialized.
      Parameters:
      pageOffset -
      size -
    • setUninitialized

      public void setUninitialized(int pageOffset, int size)
      Mark specified page region as uninitialized.
      Parameters:
      pageOffset -
      size -
    • getInitializedByteCount

      public int getInitializedByteCount(int pageOffset, int size)
      Get number of leading bytes within page range which have been initialized.
      Parameters:
      pageOffset -
      size -
      Returns:
      number of leading bytes within page range which have been initialized.
    • getInitializedMask

      public static byte[] getInitializedMask(int pageSize, boolean initialized)
      Generate an initialized mask for the specified page size
      Parameters:
      pageSize -
      initialized -
      Returns:
    • getInitializedMask

      public static byte[] getInitializedMask(int pageSize, int offset, int size, boolean initialized)
      Generate an initialized mask for the specified page size. The region is identified by offset and size. The remaining portions of the mask will be set based upon !initialized.
      Parameters:
      pageSize -
      offset -
      size -
      initialized -
      Returns:
    • setInitialized

      public static void setInitialized(byte[] initializedMask, int pageOffset, int size)
      Mark specified page region as initialized.
      Parameters:
      initializedMask -
      pageOffset -
      size -
    • setUninitialized

      public static void setUninitialized(byte[] initializedMask, int pageOffset, int size)
      Mark specified page region as uninitialized.
      Parameters:
      initializedMask -
      pageOffset -
      size -
    • getInitializedByteCount

      public static int getInitializedByteCount(byte[] initializedMask, int pageOffset, int size)
      Determine how many leading bytes of a specified page region is marked as initialized. Valid page region defined by pageOffset and size is assumed.
      Parameters:
      initializedMask -
      pageOffset -
      size -
      Returns:
      number of leading bytes at pageOffset (upto size) are initialized.