This commit is contained in:
root
2019-04-22 02:59:20 +00:00
commit beccf3fe43
25440 changed files with 4054998 additions and 0 deletions

26
vendor/github.com/bouk/monkey/replace_unix.go generated vendored Normal file
View File

@ -0,0 +1,26 @@
//+build !windows
package monkey
import (
"syscall"
)
// this function is super unsafe
// aww yeah
// It copies a slice to a raw memory location, disabling all memory protection before doing so.
func copyToLocation(location uintptr, data []byte) {
f := rawMemoryAccess(location, len(data))
page := rawMemoryAccess(pageStart(location), syscall.Getpagesize())
err := syscall.Mprotect(page, syscall.PROT_READ|syscall.PROT_WRITE|syscall.PROT_EXEC)
if err != nil {
panic(err)
}
copy(f, data[:])
err = syscall.Mprotect(page, syscall.PROT_READ|syscall.PROT_EXEC)
if err != nil {
panic(err)
}
}