github.com/undefinedlabs/go-mpatch@v1.0.8-0.20230904093002-fbac8a0d7853/patcher_x64.go (about)

     1  //go:build amd64
     2  // +build amd64
     3  
     4  package mpatch
     5  
     6  import "unsafe"
     7  
     8  // Gets the jump function rewrite bytes
     9  //
    10  //go:nosplit
    11  func getJumpFuncBytes(to unsafe.Pointer) ([]byte, error) {
    12  	return []byte{
    13  		0x48, 0xBA,
    14  		byte(uintptr(to)),
    15  		byte(uintptr(to) >> 8),
    16  		byte(uintptr(to) >> 16),
    17  		byte(uintptr(to) >> 24),
    18  		byte(uintptr(to) >> 32),
    19  		byte(uintptr(to) >> 40),
    20  		byte(uintptr(to) >> 48),
    21  		byte(uintptr(to) >> 56),
    22  		0xFF, 0x22,
    23  	}, nil
    24  }