废话不多说,开门见山,上干货,原理请自行百度:
function set_read_write_break(addr, size, pattern)
{
//设置异常
Process.setExceptionHandler(function(details){
//打印信息,e.g. 打印堆栈,打印发生异常的地址,打印引发异常的地址
/* type: string specifying one of: abort access-violation guard-page illegal-instruction stack-overflow arithmetic breakpoint single-step system address: address where the exception occurred, as a NativePointer memory: if present, is an object containing: operation: the kind of operation that triggered the exception, as a string specifying either read, write, or execute address: address that was accessed when the exception occurred, as a NativePointer context: object with the keys pc and sp, which are NativePointer objects specifying EIP/RIP/PC and ESP/RSP/SP, respectively, for ia32/x64/arm. Other processor-specific keys are also available, e.g. eax, rax, r0, x0, etc. You may also update register values by assigning to these keys. nativeContext: address of the OS and architecture-specific CPU context struct, as a NativePointer. This is only exposed as a last resort for edge-cases where context isn’t providing enough details. We would however discourage using this and rather submit a pull-request to add the missing bits needed for your use-case.