Class: Ragweed::Wraposx::ThreadContext::State32

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

Overview

_STRUCT_X86_THREAD_STATE32

unsigned int        eax;
unsigned int        ebx;
unsigned int        ecx;
unsigned int        edx;
unsigned int        edi;
unsigned int        esi;
unsigned int        ebp;
unsigned int        esp;
unsigned int        ss;
unsigned int        eflags;
unsigned int        eip;
unsigned int        cs;
unsigned int        ds;
unsigned int        es;
unsigned int        fs;
unsigned int        gs;

;

Defined Under Namespace

Modules: Flags

Constant Summary collapse

FLAVOR =
1

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



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/ragweed/wraposx/thread_context.rb', line 133

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:
  EIP: #{self.eip.to_s(16).rjust(8, "0")} #{maybe_dis.call(self.eip)}

  EAX: #{self.eax.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.eax)}
  EBX: #{self.ebx.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.ebx)}
  ECX: #{self.ecx.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.ecx)}
  EDX: #{self.edx.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.edx)}
  EDI: #{self.edi.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.edi)}
  ESI: #{self.esi.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.esi)}
  EBP: #{self.ebp.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.ebp)}
  ESP: #{self.esp.to_s(16).rjust(8, "0")} #{maybe_hex.call(self.esp)}
  EFL: #{self.eflags.to_s(2).rjust(32, "0")} #{Flags.flag_dump(self.eflags)}
EOM
end

#single_step(v = true) ⇒ Object

sets/clears the TRAP flag



155
156
157
158
159
160
161
# File 'lib/ragweed/wraposx/thread_context.rb', line 155

def single_step(v=true)
  if v
    self.eflags |= Flags::TRAP
  else
    self.eflags &= ~(Flags::TRAP)
  end
end