Class: Ragweed::Wrap32::DebugEvent

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/ragweed/wrap32/debugging.rb', line 253

def method_missing meth, *args
  super unless self.respond_to? meth
  if meth.to_s =~ /=$/
    mth = meth.to_s.gsub(/=$/,'').intern
    if self.members.include? mth
      # don't proxy
      self.__send__(:[]=, mth, *args)
    else
      case self[:DebugEventCode]
      when Ragweed::Wrap32::DebugCodes::CREATE_PROCESS
        self[:u][:create_process_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::CREATE_THREAD
        self[:u][:create_thread_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::EXIT_PROCESS
        self[:u][:exit_process_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::EXIT_THREAD
        self[:u][:exit_thread_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::LOAD_DLL
        self[:u][:load_dll_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::OUTPUT_DEBUG_STRING
        self[:u][:output_debug_string_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::RIP
        self[:u][:rip_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::UNLOAD_DLL
        self[:u][:unload_dll_debug_info].__send__(:[]=, mth, *args)
      when Ragweed::Wrap32::DebugCodes::EXCEPTION
        case mth
        when :exception_record, :first_chance
          self[:u][:exception_debug_info].__send__(:[]=, mth, *args)
        else # it's in the exception_record -- gross, I know but...
          self[:u][:exception_debug_info][:exception_record].__send__(meth, *args)
        end
      end
    end
  else
    if self.members.include? meth
      # don't proxy
      self.__send__(:[], meth, *args)
    else
      case self[:DebugEventCode]
      when Ragweed::Wrap32::DebugCodes::CREATE_PROCESS
        self[:u][:create_process_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::CREATE_THREAD
        self[:u][:create_thread_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::EXIT_PROCESS
        self[:u][:exit_process_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::EXIT_THREAD
        self[:u][:exit_thread_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::LOAD_DLL
        self[:u][:load_dll_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::OUTPUT_DEBUG_STRING
        self[:u][:output_debug_string_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::RIP
        self[:u][:rip_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::UNLOAD_DLL
        self[:u][:unload_dll_debug_info].__send__(:[], meth, *args)
      when Ragweed::Wrap32::DebugCodes::EXCEPTION
        case meth
        when :exception_record, :first_chance
          self[:u][:exception_debug_info].__send__(:[], meth, *args)
        else # it's in the exception_record -- gross, I know but...
          self[:u][:exception_debug_info][:exception_record].__send__(meth, *args)
        end
      end
    end
  end
end

Instance Method Details

#codeObject

backwards compatability



186
# File 'lib/ragweed/wrap32/debugging.rb', line 186

def code; self[:DebugEventCode]; end

#code=(cd) ⇒ Object



187
# File 'lib/ragweed/wrap32/debugging.rb', line 187

def code=(cd); self[:DebugEventCode] = cd; end

#inspectObject



338
339
340
341
342
343
344
345
# File 'lib/ragweed/wrap32/debugging.rb', line 338

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

#inspect_code(c) ⇒ Object



326
327
328
# File 'lib/ragweed/wrap32/debugging.rb', line 326

def inspect_code(c)
  Ragweed::Wrap32::DebugCodes.to_key_hash[c].to_s || c.to_i
end

#inspect_exception_code(c) ⇒ Object



330
331
332
# File 'lib/ragweed/wrap32/debugging.rb', line 330

def inspect_exception_code(c)
  Ragweed::Wrap32::ExceptionCodes.to_key_hash[c].to_s || c.to_i.to_s(16)
end

#inspect_parameters(p) ⇒ Object



334
335
336
# File 'lib/ragweed/wrap32/debugging.rb', line 334

def inspect_parameters(p)
  "[ " + p.map {|x| x.to_i.to_s}.join(", ") + " ]"
end

#methods(regular = true) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/ragweed/wrap32/debugging.rb', line 198

def methods regular=true
  ret = super + self.members.map{|x| [x.to_s, x.to_s + "="]}
  ret += case self[:DebugEventCode]
  when Ragweed::Wrap32::DebugCodes::CREATE_PROCESS
    self[:u][:create_process_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::CREATE_THREAD
    self[:u][:create_thread_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::EXIT_PROCESS
    self[:u][:exit_process_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::EXIT_THREAD
    self[:u][:exit_thread_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::LOAD_DLL
    self[:u][:load_dll_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::OUTPUT_DEBUG_STRING
    self[:u][:output_debug_string_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::RIP
    self[:u][:rip_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::UNLOAD_DLL
    self[:u][:unload_dll_debug_info].members.map{|x| [x.to_s, x.to_s + "="]}
  when Ragweed::Wrap32::DebugCodes::EXCEPTION
    self[:u][:exception_debug_info].members.map{|x| [x.to_s, x.to_s + "="]} + self[:u][:exception_debug_info][:exception_record].members.map{|x| [x.to_s, x.to_s + "="]}
  else
    []
  end
  ret.flatten
end

#pidObject



188
# File 'lib/ragweed/wrap32/debugging.rb', line 188

def pid; self[:ProcessId]; end

#pid=(pd) ⇒ Object



189
# File 'lib/ragweed/wrap32/debugging.rb', line 189

def pid=(pd); self[:ProcessId]= pd; end

#respond_to?(meth, include_priv = false) ⇒ Boolean

Returns:

  • (Boolean)


321
322
323
324
# File 'lib/ragweed/wrap32/debugging.rb', line 321

def respond_to? meth, include_priv=false
  # mth = meth.to_s.gsub(/=$/,'')
  !((self.methods & [meth, meth.to_s]).empty?) || super
end

#tidObject



190
# File 'lib/ragweed/wrap32/debugging.rb', line 190

def tid; self[:ThreadId]; end

#tid=(td) ⇒ Object



191
# File 'lib/ragweed/wrap32/debugging.rb', line 191

def tid=(td); self[:ThreadId] = td; end