Class: Ragweed::Wrap32::ThreadContext

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

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

#context_flagsObject

This is defined in WinNt.h



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ragweed/wrap32/thread_context.rb', line 46

layout :context_flags, :long,
:dr0, :long,
:dr1, :long,
:dr2, :long,
:dr3, :long,
:dr6, :long,
:dr7, :long,
:floating_save, [:uint8, 112], ## XXX need a structure for this
:seg_gs, :long,
:seg_fs, :long,
:seg_es, :long,
:seg_ds, :long,
:edi, :long,
:esi, :long,
:ebx, :long,
:edx, :long,
:ecx, :long,
:eax, :long,
:ebp, :long,
:eip, :long,
:seg_cs, :long,
:eflags, :long,
:esp, :long,
:seg_ss, :long,
:spill, [:uint8, 512 ]

#dump(&block) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ragweed/wrap32/thread_context.rb', line 82

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")}
EAX: #{self.eax.to_s(16).rjust(8, "0")}
EBX: #{self.ebx.to_s(16).rjust(8, "0")}
ECX: #{self.ecx.to_s(16).rjust(8, "0")}
EDX: #{self.edx.to_s(16).rjust(8, "0")}
EDI: #{self.edi.to_s(16).rjust(8, "0")}
ESI: #{self.esi.to_s(16).rjust(8, "0")}
EBP: #{self.ebp.to_s(16).rjust(8, "0")}
ESP: #{self.esp.to_s(16).rjust(8, "0")}
EFL: #{self.eflags.to_s(2).rjust(32, "0")} #{Ragweed::Wrap32::EFlags.flag_dump(self.eflags)}
EOM
end

#inspectObject

XXX more helper methods here are needed



74
75
76
77
78
79
80
# File 'lib/ragweed/wrap32/thread_context.rb', line 74

def inspect
    body = lambda do
        self.members.each_with_index do |m,i|
            "#{self.members[i].to_s(16)} #{self.values[i].to_s.hexify}"
        end.join(", ")
    end
end

#single_step(v = true) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/ragweed/wrap32/thread_context.rb', line 102

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