github.com/gbl08ma/monkey@v1.1.0/monkey_amd64.go (about)

     1  package monkey
     2  
     3  // Assembles a jump to a function value
     4  func jmpToFunctionValue(to uintptr) []byte {
     5  	return []byte{
     6  		0x48, 0xBA,
     7  		byte(to),
     8  		byte(to >> 8),
     9  		byte(to >> 16),
    10  		byte(to >> 24),
    11  		byte(to >> 32),
    12  		byte(to >> 40),
    13  		byte(to >> 48),
    14  		byte(to >> 56), // movabs rdx,to
    15  		0xFF, 0x22,     // jmp QWORD PTR [rdx]
    16  	}
    17  }