Method: Fisk::Helpers::JITBuffer#write_jump

Defined in:
lib/fisk/helpers.rb

#write_jump(to:, at: self.pos, type: :jmp) ⇒ Object

Write a jump instruction at location at that jumps to the location specified by to. type specifies the type of jump. Returns the position in the buffer where the jump instruction was written.

This method does not maintain the current position of the cursor



92
93
94
95
96
97
98
99
100
# File 'lib/fisk/helpers.rb', line 92

def write_jump to:, at: self.pos, type: :jmp
  rel_jump = 0xCAFE
  2.times do
    seek at, IO::SEEK_SET
    Fisk.new { |__| __.public_send(type, __.rel32(rel_jump)) }.write_to(self)
    rel_jump = to - address
  end
  self.pos
end