Class: Ragweed::Detour::Dbreak
Overview
A breakpoint implemented as a Detour. TODO not tested.
Instance Attribute Summary collapse
-
#ev1 ⇒ Object
readonly
Returns the value of attribute ev1.
-
#ev2 ⇒ Object
readonly
Returns the value of attribute ev2.
Attributes inherited from Detour
Instance Method Summary collapse
-
#initialize(*args) ⇒ Dbreak
constructor
accepts: :ev1: reuse events from somewhere else :ev2:.
- #inner_block ⇒ Object
-
#on(&block) ⇒ Object
in theory, loop on this breakpoint.
Methods inherited from Detour
Constructor Details
#initialize(*args) ⇒ Dbreak
accepts: :ev1: reuse events from somewhere else :ev2:
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ragweed/detour.rb', line 168 def initialize(*args) super @ev1 = @opts[:ev1] || WinEvent.new @ev2 = @opts[:ev2] || WinEvent.new # create the state block that the eventpair shim wants: mem = @a.alloc(100) @data = mem # ghetto vtbl swch = ["OpenProcess", "DuplicateHandle", "ResetEvent", "SetEvent", "WaitForSingleObject", "GetCurrentThreadId"]. map {|x| @p.get_proc("kernel32!#{x}").to_i}. pack("LLLLLL") # ghetto instance vars state = [@p.w.get_current_process_id, @ev1.handle, @ev2.handle]. pack("LLL") @data.write(swch + state) end |
Instance Attribute Details
#ev1 ⇒ Object (readonly)
Returns the value of attribute ev1.
163 164 165 |
# File 'lib/ragweed/detour.rb', line 163 def ev1 @ev1 end |
#ev2 ⇒ Object (readonly)
Returns the value of attribute ev2.
163 164 165 |
# File 'lib/ragweed/detour.rb', line 163 def ev2 @ev2 end |
Instance Method Details
#inner_block ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/ragweed/detour.rb', line 193 def inner_block i = Ragweed::Rasm::Subprogram.new i.<< Push(eax) i.<< Xor(eax, eax) i.<< Or(eax, @data) i.<< Push(eax) i.<< Call(1) # cheesy in the extreme: fake a call # so I don't have to change my event shim i.<< Nop.new i.<< Nop.new i.<< Nop.new i.<< Nop.new i.<< Nop.new s = event_pair_stub s[-1] = Add(esp, 4) i.concat(s) i.<< Pop(eax) return i end |
#on(&block) ⇒ Object
in theory, loop on this breakpoint
214 215 216 217 218 219 220 221 |
# File 'lib/ragweed/detour.rb', line 214 def on(&block) puts "#{ @p.pid }: #{ @ev1.handle }" # in case we need to release loop do @ev1.wait yield @ev2.signal end end |