Class: Ragweed::Wraposx::ThreadContext::State64

Inherits:
FFI::Struct
  • Object
show all
Includes:
FFIStructInclude
Defined in:
lib/ragweed/wraposx/thread_context.rb

Overview

_STRUCT_X86_THREAD_STATE64

__uint64_t      rax;
__uint64_t      rbx;
__uint64_t      rcx;
__uint64_t      rdx;
__uint64_t      rdi;
__uint64_t      rsi;
__uint64_t      rbp;
__uint64_t      rsp;
__uint64_t      r8;
__uint64_t      r9;
__uint64_t      r10;
__uint64_t      r11;
__uint64_t      r12;
__uint64_t      r13;
__uint64_t      r14;
__uint64_t      r15;
__uint64_t      rip;
__uint64_t      rflags;
__uint64_t      cs;
__uint64_t      fs;
__uint64_t      gs;

;

Defined Under Namespace

Modules: Flags

Constant Summary collapse

FLAVOR =
4

Instance Method Summary collapse

Methods included from FFIStructInclude

#method_missing, #methods, #respond_to?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ragweed::FFIStructInclude

Instance Method Details

#dump(&block) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/ragweed/wraposx/thread_context.rb', line 238

def dump(&block)
  maybe_hex = lambda {|a| begin; "\n" + (" " * 9) + block.call(a, 16).hexdump(true)[10..-2]; rescue; ""; end }
  maybe_dis = lambda {|a| begin; "\n" + block.call(a, 16).distorm.map {|i| "         " + i.mnem}.join("\n"); rescue; ""; end }

  string =<<EOM
  -----------------------------------------------------------------------
  CONTEXT:
  RIP: #{self.rip.to_s(16).rjust(16, "0")} #{maybe_dis.call(self.rip)}

  RAX: #{self.rax.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rax)}
  RBX: #{self.rbx.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rbx)}
  RCX: #{self.rcx.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rcx)}
  RDX: #{self.rdx.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rdx)}
  RDI: #{self.rdi.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rdi)}
  RSI: #{self.rsi.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rsi)}
  RBP: #{self.rbp.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rbp)}
  RSP: #{self.rsp.to_s(16).rjust(16, "0")} #{maybe_hex.call(self.rsp)}
  RFL: #{(self.rflags & 0xffffffff).to_s(2).rjust(32, "0")} #{Flags.flag_dump(self.rflags & 0xffffffff)}
EOM
end

#single_step(v = true) ⇒ Object

sets/clears the TRAP flag



260
261
262
263
264
265
266
# File 'lib/ragweed/wraposx/thread_context.rb', line 260

def single_step(v=true)
  if v
    @rflags |= Flags::TRAP
  else
    @rflags &= ~(Flags::TRAP)
  end
end