Class: FFI::UDis86::Operand

Inherits:
Struct
  • Object
show all
Defined in:
lib/ffi/udis86/operand.rb

Instance Method Summary collapse

Instance Method Details

#base ⇒ Symbol Also known as: reg

The base register used by the operand.

Returns:

  • (Symbol) —

    The base register of the operand.



122
123
124
# File 'lib/ffi/udis86/operand.rb', line 122

def base
  REGS[self[:base]]
end

#index ⇒ Symbol

The index register used by the operand.

Returns:

  • (Symbol) —

    The index register of the operand.



134
135
136
# File 'lib/ffi/udis86/operand.rb', line 134

def index
  REGS[self[:index]]
end

#is_const? ⇒ Boolean

Determines if the operand is a data constant.

Returns:

  • (Boolean) —

    Specifies whether the operand is a data constant.



74
75
76
# File 'lib/ffi/udis86/operand.rb', line 74

def is_const?
  self[:type] == :ud_op_const
end

#is_imm? ⇒ Boolean

Determines if the operand is immediate data.

Returns:

  • (Boolean) —

    Specifies whether the operand is immediate data.



54
55
56
# File 'lib/ffi/udis86/operand.rb', line 54

def is_imm?
  self[:type] == :ud_op_imm
end

#is_jmp_imm? ⇒ Boolean

Determines if the operand is a relative offset used in a jump.

Returns:

  • (Boolean) —

    Specifies whether the operand is a relative offset.



64
65
66
# File 'lib/ffi/udis86/operand.rb', line 64

def is_jmp_imm?
  self[:type] == :ud_op_jimm
end

#is_mem? ⇒ Boolean

Determines if the operand is a memory access.

Returns:

  • (Boolean) —

    Specifies whether the operand is a memory access.



34
35
36
# File 'lib/ffi/udis86/operand.rb', line 34

def is_mem?
  self[:type] == :ud_op_mem
end

#is_reg? ⇒ Boolean

Determines if the operand is a register.

Returns:

  • (Boolean) —

    Specifies whether the operand is a register.



84
85
86
# File 'lib/ffi/udis86/operand.rb', line 84

def is_reg?
  self[:type] == :ud_op_reg
end

#is_seg_ptr? ⇒ Boolean

Determines if the operand is Segment:Offset pointer.

Returns:

  • (Boolean) —

    Specifies whether the operand is Segment:Offset pointer.



44
45
46
# File 'lib/ffi/udis86/operand.rb', line 44

def is_seg_ptr?
  self[:type] == :ud_op_ptr
end

#offset ⇒ OperandValue, 0

The offset value used by the operand.

Returns:



144
145
146
147
148
149
150
# File 'lib/ffi/udis86/operand.rb', line 144

def offset
  if self[:offset] > 0
    return self[:value]
  else
    return 0
  end
end

#offset_size ⇒ Integer

The word-length of the offset used with the operand.

Returns:

  • (Integer) —

    Word-length of the offset being used.



158
159
160
# File 'lib/ffi/udis86/operand.rb', line 158

def offset_size
  self[:offset]
end

#scale ⇒ Integer

The scale value used by the operand.

Returns:

  • (Integer) —

    The scale value of the operand.



168
169
170
# File 'lib/ffi/udis86/operand.rb', line 168

def scale
  self[:scale]
end

#size ⇒ Integer

The size of the operand.

Returns:

  • (Integer) —

    The size of the operand in bytes.



94
95
96
# File 'lib/ffi/udis86/operand.rb', line 94

def size
  self[:size]
end

#type ⇒ Symbol

The type of the operand.

Returns:

  • (Symbol) —

    The type of the operand.



24
25
26
# File 'lib/ffi/udis86/operand.rb', line 24

def type
  self[:type]
end

#value ⇒ OperandValue, OperandPointer

The value of the operand.

Returns:

  • (OperandValue, OperandPointer) —

    The value of the operand. If the operand represents a pointer, an OperandPointer object will be returned.



105
106
107
108
109
110
111
112
113
114
# File 'lib/ffi/udis86/operand.rb', line 105

def value
  case type
  when :ud_op_ptr
    return self[:value].ptr
  when :ud_op_reg
    return nil
  else
    return self[:value]
  end
end