Class: OneGadget::Emulators::Amd64

Inherits:
X86 show all
Defined in:
lib/one_gadget/emulators/amd64.rb

Overview

Emulator of amd64 instruction set.

Constant Summary

Constants inherited from X86

X86::COMPARES, X86::JCC, X86::SEGMENT_OPERAND

Constants inherited from Processor

Processor::ADDRESS_TYPES, Processor::CLOBBERED, Processor::NULLABLE_REQUIREMENTS, Processor::POINTER_REQUIREMENTS, Processor::TERMINAL_CALL_RE

Constants included from Conditional

Conditional::COMPARE_OPS, Conditional::NEGATE, Conditional::RELATION

Instance Attribute Summary

Attributes inherited from Processor

#bp, #pc, #refused_line, #registers, #sp

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from X86

#instructions, #process!

Methods inherited from Processor

#address_deref0?, #bp_based_stack, #closed_fds, #constraint_key, #constraints, #drop_implied_nonzero, #drop_restated_null, #get_corresponding_stack, instruction_table, #instructions, line_memo, #parse, #process, #process!, #reach_terminal_call, #render_constraint, #resolve_address, #setup_frame_pointer, #sp_based_stack, #terminal_call?

Methods included from Conditional

#branch_on_bit, #branch_on_compare, #branch_on_zero, #comparisons_on, #handle_compare, #mnemonic, #operand_str, #record_compare, #resolve_pending_branch, #satisfiable?, #value_str

Constructor Details

#initializeAmd64

Instantiate an OneGadget::Emulators::Amd64 object.



18
19
20
# File 'lib/one_gadget/emulators/amd64.rb', line 18

def initialize
  super(OneGadget::ABI.amd64, 'rsp', 'rbp', 'rip')
end

Class Method Details

.bitsObject

Bits.



12
13
14
# File 'lib/one_gadget/emulators/amd64.rb', line 12

def bits
  64
end

Instance Method Details

#argument(idx) ⇒ Lambda, Integer

Return the argument value of calling a function.

Parameters:

  • idx (Integer)

    The 0-based index of the argument.

Returns:

  • (Lambda, Integer)

    The value held in the register used for the +idx+-th argument.



25
26
27
28
29
30
31
32
33
34
# File 'lib/one_gadget/emulators/amd64.rb', line 25

def argument(idx)
  case idx
  when 0 then registers['rdi']
  when 1 then registers['rsi']
  when 2 then registers['rdx']
  when 3 then registers['rcx']
  when 4 then registers['r8']
  when 5 then registers['r9']
  end
end