Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

31
vendor/github.com/bouk/monkey/replace.go generated vendored Normal file
View File

@@ -0,0 +1,31 @@
package monkey
import (
"reflect"
"syscall"
"unsafe"
)
func rawMemoryAccess(p uintptr, length int) []byte {
return *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
Data: p,
Len: length,
Cap: length,
}))
}
func pageStart(ptr uintptr) uintptr {
return ptr & ^(uintptr(syscall.Getpagesize() - 1))
}
// from is a pointer to the actual function
// to is a pointer to a go funcvalue
func replaceFunction(from, to uintptr) (original []byte) {
jumpData := jmpToFunctionValue(to)
f := rawMemoryAccess(from, len(jumpData))
original = make([]byte, len(f))
copy(original, f)
copyToLocation(from, jumpData)
return
}