Class: Trevil

Inherits:
Object show all
Defined in:
lib/ragweed/trampoline.rb

Instance Method Summary collapse

Constructor Details

#initialize(p) ⇒ Trevil

Returns a new instance of Trevil.



73
74
75
76
77
# File 'lib/ragweed/trampoline.rb', line 73

def initialize(p)
  @p = p
  @ev1, @ev2 = [WinEvent.new, WinEvent.new]
  @a = @p.arena
end

Instance Method Details

#clear!Object



79
80
81
# File 'lib/ragweed/trampoline.rb', line 79

def clear!
  @a.release
end

#goObject



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

def go
  mem = @a.alloc(1024)
  base = @p.ptr(mem)
  data = base + 512
  swch = ["OpenProcess",
          "DuplicateHandle",
          "ResetEvent",
          "SetEvent",
          "WaitForSingleObject"].
    map {|x| @p.get_proc("kernel32!#{x}").to_i}.
    pack("LLLLL")
  state = [Ragweed::Wrap32::get_current_process_id, @ev1.handle, @ev2.handle].
    pack("LLL")

  data.write(swch + state)
  base.write(event_pair_stub(:debug => false).assemble)
  Ragweed::Wrap32::create_remote_thread(@p.handle, base, data)
  @ev1.wait
  @ev2
end