Module: OneGadget::ABI

Defined in:
lib/one_gadget/abi.rb

Overview

Defines the abi of different architectures.

Constant Summary collapse

X86_32 =

Registers of i386.

%w[eax ebx ecx edx edi esi ebp esp] + 0.upto(7).map { |i| "xmm#{i}" }
X86_64 =

Registers of x86_64.

X86_32 +
%w[rax rbx rcx rdx rdi rsi rbp rsp] +
8.upto(15).map { |i| "r#{i}" } +
8.upto(15).map { |i| "xmm#{i}" }
AARCH64 =

Registers of AArch64.

%w[xzr wzr sp] + 0.upto(30).map { |i| ["x#{i}", "w#{i}"] }.flatten

Class Method Summary collapse

Class Method Details

.aarch64Array<String>

Registers' name of aarch64.

Returns:

  • (Array<String>)

    List of registers.


31
32
33
# File 'lib/one_gadget/abi.rb', line 31

def aarch64
  AARCH64
end

.allArray<String>

Returns all names of registers.

Returns:

  • (Array<String>)

    List of registers.


37
38
39
# File 'lib/one_gadget/abi.rb', line 37

def all
  amd64 + aarch64
end

.amd64Array<String>

Registers' name of amd64.

Returns:

  • (Array<String>)

    List of registers.


19
20
21
# File 'lib/one_gadget/abi.rb', line 19

def amd64
  X86_64.uniq
end

.i386Array<String>

Registers' name of i386.

Returns:

  • (Array<String>)

    List of registers.


25
26
27
# File 'lib/one_gadget/abi.rb', line 25

def i386
  X86_32
end

.stack_register?(reg) ⇒ Boolean

Checks if the register is a stack-related pointer.

Parameters:

  • reg (String)

    Register's name.

Returns:

  • (Boolean)

45
46
47
# File 'lib/one_gadget/abi.rb', line 45

def stack_register?(reg)
  %w[esp ebp rsp rbp sp x29].include?(reg)
end