Class: OneGadget::Emulators::AArch64
- Defined in:
- lib/one_gadget/emulators/aarch64.rb
Overview
Emulator of aarch64.
Instance Attribute Summary
Attributes inherited from Processor
#pc, #registers, #sp, #stack
Class Method Summary collapse
-
.bits ⇒ Object
AArch64 is 64-bit.
Instance Method Summary collapse
-
#argument(idx) ⇒ Lambda, Integer
Return the argument value of calling a function.
-
#initialize ⇒ AArch64
constructor
Instantiate a AArch64 object.
-
#instructions ⇒ Array<Instruction>
Supported instruction set.
- #process!(cmd) ⇒ Object
Methods inherited from Processor
#constraints, #parse, #process
Constructor Details
#initialize ⇒ AArch64
Instantiate a OneGadget::Emulators::AArch64 object.
12 13 14 15 16 17 |
# File 'lib/one_gadget/emulators/aarch64.rb', line 12 def initialize super(OneGadget::ABI.aarch64, 'sp') # Constant registers %w[xzr wzr].each { |r| @registers[r] = 0 } @pc = 'pc' end |
Class Method Details
.bits ⇒ Object
AArch64 is 64-bit.
164 165 166 |
# File 'lib/one_gadget/emulators/aarch64.rb', line 164 def bits 64 end |
Instance Method Details
#argument(idx) ⇒ Lambda, Integer
Return the argument value of calling a function.
43 44 45 |
# File 'lib/one_gadget/emulators/aarch64.rb', line 43 def argument(idx) registers["x#{idx}"] end |
#instructions ⇒ Array<Instruction>
Supported instruction set.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/one_gadget/emulators/aarch64.rb', line 28 def instructions [ Instruction.new('add', 3..4), Instruction.new('adrp', 2), Instruction.new('bl', 1), Instruction.new('ldr', 2..3), Instruction.new('mov', 2), Instruction.new('stp', 3), Instruction.new('str', 2..3) ] end |
#process!(cmd) ⇒ Object
20 21 22 23 24 |
# File 'lib/one_gadget/emulators/aarch64.rb', line 20 def process!(cmd) inst, args = parse(cmd.gsub(/#-?(0x)?[0-9a-f]+/) { |v| v[1..-1] }) sym = "inst_#{inst.inst}".to_sym __send__(sym, *args) != :fail end |