-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprocessor_mode.rb
72 lines (54 loc) · 2.43 KB
/
processor_mode.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
71
72
require 'relyze/core'
class Plugin < Relyze::Plugin::Analysis
def initialize
super( {
:guid => '{FF5D7775-55F9-449F-8A86-DA46B540FF7F}',
:name => 'Processor Mode',
:description => 'Get or set the processor mode at the currently selected location.',
:authors => [ 'Relyze Software Limited' ],
:license => 'Relyze Plugin License',
:shortcuts => {
:get_processor_mode => nil,
:set_processor_mode => nil
},
:min_application_version => '2.0.0'
} )
end
def get_processor_mode
rva = @relyze.tab_current_rva( cm )
if( rva.nil? )
@relyze.message_dialog( self.name, "Please select a location first.", [ :Ok ], :error )
return
end
mode = cm.get_processor_mode( rva )
message = "Processor mode at 0x%08X is '%s'" % [ cm.rva2address( rva ), mode.nil? ? 'normal' : mode ]
@relyze.message_dialog( self.name, message, [ :Ok ] )
end
def set_processor_mode
modes = nil
if( cm.arch == :arm )
modes = [ :arm, :thumb ]
end
if( modes.nil? )
@relyze.message_dialog( self.name, "No alternative processor modes available for this architecture.", [ :Ok ] )
return
end
rva = @relyze.tab_current_rva( cm )
if( rva.nil? )
@relyze.message_dialog( self.name, "Please select a location first.", [ :Ok ], :error )
return
end
mode = @relyze.list_dialog( self.name, "Set processor mode at 0x%08X" % [ cm.rva2address( rva ) ], modes )
if( mode.nil? or mode == cm.get_processor_mode( rva ) )
return
end
if( not cm.set_processor_mode( rva, mode ) )
@relyze.message_dialog( self.name, "Failed to set the processor mode.", [ :Ok ], :error )
elsif( @relyze.gui? )
@relyze.update_gui
end
end
def run
print_message( "To run this plugin, right click on some code in the GUI and select Plugins -> Processor Mode" )
end
end