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

     1  //go:build 386
     2  // +build 386
     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  		0xBA,
    14  		byte(uintptr(to)),
    15  		byte(uintptr(to) >> 8),
    16  		byte(uintptr(to) >> 16),
    17  		byte(uintptr(to) >> 24),
    18  		0xFF, 0x22,
    19  	}, nil
    20  }