"""Exercise sparse scanning with real x86-64 page tables and Volatility layers.""" import struct from volatility3.framework import contexts, exceptions from volatility3.framework.layers.intel import Intel32e from volatility3.framework.layers.physical import BufferDataLayer from mcptrace.core import ScanStats, scan_chunks from mcptrace.memory import readable_chunks PAGE = 4096 HIGH = 1 << 41 def intel_layer(virtual_pages=None): # Virtual pages 0 and 1 are neighbors but physical pages 5 and 7 are not. # Page 2 is absent; page 3 maps to physical page 6. Repeat at 2 TiB to # exercise absent PML4/PDPT/PD branches without allocating a large buffer. data = bytearray(8 * PAGE) for address, value in [ (0x1000, 0x2003), (0x1020, 0x2003), (0x2000, 0x3003), (0x3000, 0x4003), (0x4000, 0x5003), (0x4008, 0x7003), (0x4018, 0x6003), ]: struct.pack_into("