github.com/tencent/goom@v1.0.1/internal/bytecode/memory/mwrite_unix.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package memory 5 6 import ( 7 "syscall" 8 ) 9 10 // mProtectCrossPage 获取 page 读写权限 11 func mProtectCrossPage(addr uintptr, length int, prot int) error { 12 pageSize := syscall.Getpagesize() 13 for p := PageStart(addr); p < addr+uintptr(length); p += uintptr(pageSize) { 14 page := RawAccess(p, pageSize) 15 if err := syscall.Mprotect(page, prot); err != nil { 16 return err 17 } 18 } 19 return nil 20 }