Class: Relyze::Application
- Inherits:
-
Object
- Object
- Relyze::Application
- Defined in:
- C:/Program Files/Relyze/lib/relyze/core/application.rb
Overview
The Application is a singleton instance and is always available to a plugin via the @relyze variable.
Instance Attribute Summary collapse
-
#library ⇒ Object
Get the Library object.
-
#plugins ⇒ Object
Get a Hash of every plugin available in the application.
Instance Method Summary collapse
-
#active_tab ⇒ Relyze::FileModel?
Gets the model for the currently selected tab in the GUI.
-
#add_plugin_thread(plugin, thread) ⇒ Object
A helper method to manage a plugins threads.
-
#analyze_buffer(buffer, options = {}) ⇒ Relyze::FileModel?
(also: #analyse_buffer)
Analyze a raw buffer and return the resulting model.
-
#analyze_buffer_dialog(buffer, pseudo_file_path = 'file.bin') ⇒ Relyze::FileModel?
(also: #analyse_buffer_dialog)
Display the analyze file dialog and returns the model if analysis is successful.
-
#analyze_file(file_path, options = {}) ⇒ Relyze::FileModel?
(also: #analyse_file)
Analyze a file and return the resulting model.
-
#analyze_file_dialog(file_path) ⇒ Relyze::FileModel?
(also: #analyse_file_dialog)
Display the analyze file dialog and returns the model if analysis is successful.
-
#analyze_peek_buffer(buffer) ⇒ Hash?
(also: #analyse_peek_buffer)
Determine the type of model the analysis would generate without performing analysis on the buffer.
-
#analyze_peek_file(file_path) ⇒ Hash?
(also: #analyse_peek_file)
Determine the type of model the analysis would generate without performing analysis on the file.
-
#archs ⇒ Array<Symbol>
Get all supported architectures.
-
#color_dialog ⇒ Integer?
Displays a color dialog.
-
#console_print(plugin, type, message) ⇒ Object
Prints a message to the console.
-
#diff_text(text1, text2, level = :word) {|package| ... } ⇒ Array<Hash>
A helper to diff two strings.
-
#file_dialog(options = { :file => nil, :title => 'Open...', :button => 'Open', :display => 'All Files', :mask => '*.*' }) ⇒ String?
Display a file dialog to the user.
-
#get_persistent_value(plugin, name) ⇒ Object
See get_persistent_value instead.
-
#get_plugin_guid(name) ⇒ String
Get the GUID of a plugin based on the plugin name.
-
#get_plugin_thread(thread) ⇒ Object
A helper method to manage a plugins threads.
-
#graph_dialog(graph) ⇒ true, false
Display a Graph::Graph object in a new dialog.
-
#gui? ⇒ true, false
Determine if the application is currently running in GUI mode.
-
#has_plugin_threads? ⇒ Boolean
A helper method to manage a plugins threads.
-
#initialize ⇒ Application
constructor
A new instance of Application.
-
#input_dialog(title, message, value = '') ⇒ Object
Display an dialog box to the user and return the value entered.
-
#kill_plugin_threads ⇒ Object
A helper method to manage a plugins threads.
-
#list_dialog(title, message, values) ⇒ Object
Display an dialog box to the user containing several values and return the value the user selects.
-
#load_all_plugins(plugin_path) ⇒ Object
A helper method to manage plugins.
-
#load_plugin_file(plugin_file) ⇒ Object
A helper method to manage plugins.
-
#message_dialog(title, message, buttons = [ :ok, :cancel ], icon = :info) ⇒ Symbol
Display an dialog box to the user with customisable buttons.
-
#refresh_static_library_packages ⇒ true, false
Force the packages to be refreshed from all symbol origin locations.
-
#remove_plugin_thread(thread) ⇒ Object
A helper method to manage a plugins threads.
-
#rgb(red, green, blue) ⇒ Integer
Converts RGB values into a color value.
-
#set_persistent_value(plugin, name, value) ⇒ Object
See set_persistent_value instead.
-
#static_library_packages {|package| ... } ⇒ Array<Relyze::Symbols::StaticLibraryPackage>
Gets every StaticLibraryPackage available.
-
#tab_current_diff(model = self.active_tab) ⇒ Relyze::DiffResults::DiffModelResult?
For the tab associated with the given model, returns the current differential analysis result, if any, for every item.
-
#tab_current_diff_item(model = self.active_tab) ⇒ Relyze::DiffResults::DiffBaseResult?
For the tab associated with the given model, returns the current differential analysis result, containing only the currently displayed item, if any.
-
#tab_current_function_rva(model = self.active_tab) ⇒ Integer?
For the tab associated with the given model, returns the RVA of the function for the users currently selected RVA value.
-
#tab_current_model(model = self.active_tab) ⇒ Relyze::FileModel?
For the tab associated with the given model, returns the active model in that tab.
-
#tab_current_rva(model = self.active_tab) ⇒ Integer?
For the tab associated with the given model, returns the users currently selected RVA value.
-
#tab_display_graph(graph, model = self.active_tab) ⇒ true, false
Display a Graph::Graph object in the GUI.
-
#tab_goto_rva(model, rva, function_rva = nil) ⇒ true, false
For the tab associated with the given model, go to a given rva location.
-
#tabs {|model| ... } ⇒ Array<Relyze::FileModel>
Gets the model for each tab in the GUI.
-
#update_gui ⇒ Object
Force the application GUI to update.
-
#version ⇒ String
Get the current application version in the format of major.minor.patch.
-
#version_major ⇒ Integer
The application major number.
-
#version_minor ⇒ Integer
The application minor number.
-
#version_patch ⇒ Integer
The application patch number.
-
#wait_plugin_threads ⇒ Object
A helper method to manage a plugins threads.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application
273 274 275 276 277 278 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 273 def initialize @threads = {} @threads_mutex = ::Mutex.new @library = nil @plugins = {} end |
Instance Attribute Details
#library ⇒ Object
Get the Library object.
249 250 251 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 249 def library @library end |
#plugins ⇒ Object
Get a Hash of every plugin available in the application. The key is the plugin GUID and the value is an Hash of information about the plugin.
271 272 273 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 271 def plugins @plugins end |
Instance Method Details
#active_tab ⇒ Relyze::FileModel?
Gets the model for the currently selected tab in the GUI
720 721 722 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 720 def active_tab return nil end |
#add_plugin_thread(plugin, thread) ⇒ Object
A helper method to manage a plugins threads. Not to be called directly.
281 282 283 284 285 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 281 def add_plugin_thread( plugin, thread ) @threads_mutex.synchronize do @threads[thread] = plugin end end |
#analyze_buffer(buffer, options = {}) ⇒ Relyze::FileModel? Also known as: analyse_buffer
Analyze a raw buffer and return the resulting model. No dialogs are displayed and the model is not displayed in the GUI.
662 663 664 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 662 def analyze_buffer( buffer, ={} ) return nil end |
#analyze_buffer_dialog(buffer, pseudo_file_path = 'file.bin') ⇒ Relyze::FileModel? Also known as: analyse_buffer_dialog
Display the analyze file dialog and returns the model if analysis is successful. The analyzed buffer will be displayed in the GUI.
569 570 571 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 569 def analyze_buffer_dialog( buffer, pseudo_file_path='file.bin' ) return nil end |
#analyze_file(file_path, options = {}) ⇒ Relyze::FileModel? Also known as: analyse_file
Analyze a file and return the resulting model. No dialogs are displayed and the model is not displayed in the GUI.
626 627 628 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 626 def analyze_file( file_path, ={} ) return nil end |
#analyze_file_dialog(file_path) ⇒ Relyze::FileModel? Also known as: analyse_file_dialog
Display the analyze file dialog and returns the model if analysis is successful. The analyzed file will be displayed in the GUI.
550 551 552 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 550 def analyze_file_dialog( file_path ) return nil end |
#analyze_peek_buffer(buffer) ⇒ Hash? Also known as: analyse_peek_buffer
Determine the type of model the analysis would generate without performing analysis on the buffer.
695 696 697 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 695 def analyze_peek_buffer( buffer ) return nil end |
#analyze_peek_file(file_path) ⇒ Hash? Also known as: analyse_peek_file
Determine the type of model the analysis would generate without performing analysis on the file.
678 679 680 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 678 def analyze_peek_file( file_path ) return nil end |
#archs ⇒ Array<Symbol>
Get all supported architectures.
840 841 842 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 840 def archs return nil end |
#color_dialog ⇒ Integer?
Displays a color dialog.
493 494 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 493 def color_dialog end |
#console_print(plugin, type, message) ⇒ Object
Prints a message to the console. A plugin should use print_message, print_error, print_warning or print_exception instead.
445 446 447 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 445 def console_print( plugin, type, ) return false end |
#diff_text(text1, text2, level = :word) {|package| ... } ⇒ Array<Hash>
A helper to diff two strings.
833 834 835 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 833 def diff_text( text1, text2, level=:word ) return nil end |
#file_dialog(options = { :file => nil, :title => 'Open...', :button => 'Open', :display => 'All Files', :mask => '*.*' }) ⇒ String?
Display a file dialog to the user.
529 530 531 532 533 534 535 536 537 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 529 def file_dialog( ={ :file => nil, :title => 'Open...', :button => 'Open', :display => 'All Files', :mask => '*.*' } ) return nil end |
#get_persistent_value(plugin, name) ⇒ Object
See get_persistent_value instead.
398 399 400 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 398 def get_persistent_value( plugin, name ) return nil end |
#get_plugin_guid(name) ⇒ String
Get the GUID of a plugin based on the plugin name.
390 391 392 393 394 395 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 390 def get_plugin_guid( name ) result = @plugins.find do | guid, hash | hash[:name] == name end return (result.nil? ? nil : result[0]) end |
#get_plugin_thread(thread) ⇒ Object
A helper method to manage a plugins threads. Not to be called directly.
288 289 290 291 292 293 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 288 def get_plugin_thread( thread ) @threads_mutex.synchronize do return @threads[thread] end return nil end |
#graph_dialog(graph) ⇒ true, false
Display a Graph::Graph object in a new dialog.
506 507 508 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 506 def graph_dialog( graph ) return false end |
#gui? ⇒ true, false
Determine if the application is currently running in GUI mode.
417 418 419 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 417 def gui? return false end |
#has_plugin_threads? ⇒ Boolean
A helper method to manage a plugins threads. Not to be called directly.
303 304 305 306 307 308 309 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 303 def has_plugin_threads? result = nil @threads_mutex.synchronize do result = !@threads.empty? end return result end |
#input_dialog(title, message, value = '') ⇒ Object
Display an dialog box to the user and return the value entered.
455 456 457 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 455 def input_dialog( title, , value='' ) return false end |
#kill_plugin_threads ⇒ Object
A helper method to manage a plugins threads. Not to be called directly.
322 323 324 325 326 327 328 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 322 def kill_plugin_threads @threads_mutex.synchronize do @threads.each do | thread, plugin | thread.kill if thread end end end |
#list_dialog(title, message, values) ⇒ Object
Display an dialog box to the user containing several values and return the value the user selects.
465 466 467 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 465 def list_dialog( title, , values ) return false end |
#load_all_plugins(plugin_path) ⇒ Object
A helper method to manage plugins. Not to be called directly.
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 331 def load_all_plugins( plugin_path ) return false if not ::Dir.exists?( plugin_path ) ::Dir.foreach( plugin_path ) do | file | if( file == '.' or file == '..' ) next end file = ::File.join( plugin_path, file ) if( ::File.directory?( file ) ) self.load_all_plugins( file ) elsif( File.extname( file ) == '.rb' ) begin self.load_plugin_file( file ) rescue ::Exception => e console_print( nil, :error, "Failed to add plugin '%s'" % file ) console_print( nil, :error, "\t%s" % e. ) console_print( nil, :error, "\r\n\r\n\t\t%s" % e.backtrace.join( "\r\n\t\t" ) ) end end end return true end |
#load_plugin_file(plugin_file) ⇒ Object
A helper method to manage plugins. Not to be called directly.
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 354 def load_plugin_file( plugin_file ) ::File.open( plugin_file, 'rb' ) do | f | plugin_source = f.read( f.stat.size ) raise "Unable to load empty plugin." if plugin_source.empty? mod = ::Module.new mod.module_eval( plugin_source, plugin_file ) plugin = mod.const_get( :Plugin ) raise "Unable to locate Plugin class." if plugin.class != ::Class p = plugin.new if( self.add_plugin( p, plugin_file ) ) @plugins[p.guid] = { :file_path => plugin_file, :name => p.name, :description => p.description, :authors => p., :license => p.license, :type => p.type, :version => p.version } end end end |
#message_dialog(title, message, buttons = [ :ok, :cancel ], icon = :info) ⇒ Symbol
Display an dialog box to the user with customisable buttons.
486 487 488 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 486 def ( title, , =[ :ok, :cancel ], icon=:info ) return :cancel end |
#refresh_static_library_packages ⇒ true, false
Force the packages to be refreshed from all symbol origin locations.
796 797 798 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 796 def refresh_static_library_packages return false end |
#remove_plugin_thread(thread) ⇒ Object
A helper method to manage a plugins threads. Not to be called directly.
296 297 298 299 300 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 296 def remove_plugin_thread( thread ) @threads_mutex.synchronize do @threads.delete( thread ) end end |
#rgb(red, green, blue) ⇒ Integer
Converts RGB values into a color value.
516 517 518 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 516 def rgb( red, green, blue ) return ( ((blue & 0xFF) << 16) | ((green & 0xFF) << 8) | (red & 0xFF) ) end |
#set_persistent_value(plugin, name, value) ⇒ Object
See set_persistent_value instead.
403 404 405 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 403 def set_persistent_value( plugin, name, value ) return false end |
#static_library_packages {|package| ... } ⇒ Array<Relyze::Symbols::StaticLibraryPackage>
Gets every StaticLibraryPackage available.
814 815 816 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 814 def static_library_packages return [] end |
#tab_current_diff(model = self.active_tab) ⇒ Relyze::DiffResults::DiffModelResult?
For the tab associated with the given model, returns the current differential analysis result, if any, for every item.
755 756 757 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 755 def tab_current_diff( model=self.active_tab ) return nil end |
#tab_current_diff_item(model = self.active_tab) ⇒ Relyze::DiffResults::DiffBaseResult?
For the tab associated with the given model, returns the current differential analysis result, containing only the currently displayed item, if any.
764 765 766 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 764 def tab_current_diff_item( model=self.active_tab ) return nil end |
#tab_current_function_rva(model = self.active_tab) ⇒ Integer?
For the tab associated with the given model, returns the RVA of the function for the users currently selected RVA value.
747 748 749 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 747 def tab_current_function_rva( model=self.active_tab ) return nil end |
#tab_current_model(model = self.active_tab) ⇒ Relyze::FileModel?
For the tab associated with the given model, returns the active model in that tab. Typically the return value is the same as the first parameter. This may not be the case if the user has selected the second analysis in the diff view.
730 731 732 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 730 def tab_current_model( model=self.active_tab ) return nil end |
#tab_current_rva(model = self.active_tab) ⇒ Integer?
For the tab associated with the given model, returns the users currently selected RVA value.
739 740 741 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 739 def tab_current_rva( model=self.active_tab ) return nil end |
#tab_display_graph(graph, model = self.active_tab) ⇒ true, false
Display a Graph::Graph object in the GUI.
779 780 781 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 779 def tab_display_graph( graph, model=self.active_tab ) return false end |
#tab_goto_rva(model, rva, function_rva = nil) ⇒ true, false
For the tab associated with the given model, go to a given rva location.
789 790 791 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 789 def tab_goto_rva( model, rva, function_rva=nil ) return false end |
#tabs {|model| ... } ⇒ Array<Relyze::FileModel>
Gets the model for each tab in the GUI
713 714 715 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 713 def tabs return [] end |
#update_gui ⇒ Object
Force the application GUI to update. This is useful if your plugin has made changes that you wish to see immediately.
423 424 425 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 423 def update_gui return false end |
#version ⇒ String
Get the current application version in the format of major.minor.patch
410 411 412 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 410 def version return '0.0.0' end |
#version_major ⇒ Integer
Returns The application major number.
428 429 430 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 428 def version_major return /(\d{1,}).(\d{1,}).(\d{1,})/.match( self.version )[1].to_i end |
#version_minor ⇒ Integer
Returns The application minor number.
433 434 435 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 433 def version_minor return /(\d{1,}).(\d{1,}).(\d{1,})/.match( self.version )[2].to_i end |
#version_patch ⇒ Integer
Returns The application patch number.
438 439 440 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 438 def version_patch return /(\d{1,}).(\d{1,}).(\d{1,})/.match( self.version )[3].to_i end |
#wait_plugin_threads ⇒ Object
A helper method to manage a plugins threads. Not to be called directly.
312 313 314 315 316 317 318 319 |
# File 'C:/Program Files/Relyze/lib/relyze/core/application.rb', line 312 def wait_plugin_threads @threads_mutex.synchronize do @threads.each do | thread, plugin | thread.join if thread end @threads.clear end end |