Class: Ragweed::Wrap32::DebugEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/ragweed/wrap32/debugging.rb

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ DebugEvent

Returns a new instance of DebugEvent.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ragweed/wrap32/debugging.rb', line 62

def initialize(str)
  @code, @pid, @tid = str.unpack("LLL")
  str.shift 12
  case @code
  when Wrap32::DebugCodes::CREATE_PROCESS 
    @file_handle, @process_handle, @thread_handle,
    @base, @offset,
    @info_size, @thread_base, @start_address,
    @image_name, @unicode = str.unpack("LLLLLLLLLH")
  when Wrap32::DebugCodes::CREATE_THREAD 
    @thread_handle, @thread_base, @start_address = str.unpack("LLL")
  when Wrap32::DebugCodes::EXCEPTION 
    @exception_code, @exception_flags,
    @exception_record, @exception_address, @parameter_count = str.unpack("LLLLL")
    str = str[20..-1]
    @parameters = []
    @parameter_count.times do
      begin
        @parameters << (str.unpack("L").first)
        str = str[4..-1]
      rescue;end
    end
  when Wrap32::DebugCodes::EXIT_PROCESS 
    @exit_code = str.unpack("L").first
  when Wrap32::DebugCodes::EXIT_THREAD 
    @exit_code = str.unpack("L").first
  when Wrap32::DebugCodes::LOAD_DLL 
    @file_handle, @dll_base, @offset,
    @info_size, @image_name, @unicode = str.unpack("LLLLLH")
  when Wrap32::DebugCodes::OUTPUT_DEBUG_STRING 
  when Wrap32::DebugCodes::RIP 
    @rip_error, @rip_type = str.unpack("LL")
  when Wrap32::DebugCodes::UNLOAD_DLL 
    @dll_base = str.unpack("L").first
  else
    raise WinX.new(:wait_for_debug_event)
  end
end

Instance Method Details

#inspectObject



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/ragweed/wrap32/debugging.rb', line 113

def inspect
  body = lambda do 
    FIELDS.map do |f| 
      if (v = send(f))
        f.to_s + "=" + (try("inspect_#{f.to_s}".intern, v) || v.to_i.to_s(16))
      end
    end.compact.join(" ")
  end
  
  "#<DebugEvent #{body.call}>"
end

#inspect_code(c) ⇒ Object



101
102
103
# File 'lib/ragweed/wrap32/debugging.rb', line 101

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

#inspect_exception_code(c) ⇒ Object



105
106
107
# File 'lib/ragweed/wrap32/debugging.rb', line 105

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

#inspect_parameters(p) ⇒ Object



109
110
111
# File 'lib/ragweed/wrap32/debugging.rb', line 109

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