This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function monitorMemory(base, length, interceptedInstructions = new Set()) { | |
const baseAddress = ptr(base.toString()); | |
MemoryAccessMonitor.enable({base: baseAddress, size: length}, { | |
onAccess: function(details) { | |
let baseOffset = details.address.sub(baseAddress); | |
console.log(`${details.address} (offset in range ${baseAddress} = ${baseOffset}) accessed for ${details.operation} from address ${DebugSymbol.fromAddress(details.from)}. Page ${details.pageIndex + 1} of ${details.pagesTotal}`); | |
let instruction = Instruction.parse(details.from); | |
const nextInstr = ptr(instruction.next.toString()); | |
if (interceptedInstructions.has(nextInstr.toString())) { | |
return; |