q/src/arch/x64/Call.go

31 lines
726 B
Go

package x64
// Call places the return address on the top of the stack and continues
// program flow at the new address.
// The address is relative to the next instruction.
func Call(code []byte, address uint32) []byte {
return append(
code,
0xE8,
byte(address),
byte(address>>8),
byte(address>>16),
byte(address>>24),
)
}
// CallAtAddress places the return address on the top of the stack and
// continues program flow at the address stored at the given memory address.
// The memory address is relative to the next instruction.
func CallAtAddress(code []byte, address uint32) []byte {
return append(
code,
0xFF,
0x15,
byte(address),
byte(address>>8),
byte(address>>16),
byte(address>>24),
)
}