lib/ronin/arch.rb in ronin-0.2.4 vs lib/ronin/arch.rb in ronin-0.3.0
- old
+ new
@@ -1,9 +1,7 @@
#
-#--
-# Ronin - A Ruby platform designed for information security and data
-# exploration tasks.
+# Ronin - A Ruby platform for exploit development and security research.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,11 +14,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#++
#
require 'ronin/extensions/meta'
require 'ronin/extensions/string'
require 'ronin/model'
@@ -52,36 +49,84 @@
endian == 'big' || endian == 'little'
}
validates_is_number :address_length
#
- # Returns the name of the arch as a String.
+ # Converts the architecture to a String.
#
+ # @return [String]
+ # The name of the architecture.
+ #
def to_s
- @name.to_s
+ self.name.to_s
end
#
# Defines a new builtin Arch with the specified _name_ and the given
# _options_.
#
- def self.define(name,options={})
+ # @param [Symbol, String] name
+ # The name of the architecture.
+ #
+ # @param [Hash] options
+ # Additional options.
+ #
+ # @option options [Symbol, String] :endian
+ # The endianness of the architecture.
+ #
+ # @option options [Integer] :address_length
+ # The address-length of the architecture.
+ #
+ # @example Defining a builtin Arch
+ # Arch.predefine :alpha, :endian => :big, :address_length => 8
+ #
+ # @example Retrieving a predefined Arch
+ # Arch.alpha
+ #
+ def self.predefine(name,options={})
super(name,options.merge(:name => name))
end
- define :i386, :endian => :little, :address_length => 4
- define :i486, :endian => :little, :address_length => 4
- define :i686, :endian => :little, :address_length => 4
- define :i986, :endian => :little, :address_length => 4
- define :x86_64, :endian => :little, :address_length => 8
- define :ia64, :endian => :little, :address_length => 8
- define :ppc, :endian => :big, :address_length => 4
- define :ppc64, :endian => :big, :address_length => 8
- define :sparc, :endian => :big, :address_length => 4
- define :sparc64, :endian => :big, :address_length => 8
- define :mips_le, :endian => :little, :address_length => 4
- define :mips_be, :endian => :big, :address_length => 4
- define :arm_le, :endian => :little, :address_length => 4
- define :arm_be, :endian => :big, :address_length => 4
+ # The i386 Architecture
+ predefine :i386, :endian => :little, :address_length => 4
+
+ # The i486 Architecture
+ predefine :i486, :endian => :little, :address_length => 4
+
+ # The i686 Architecture
+ predefine :i686, :endian => :little, :address_length => 4
+
+ # The i986 Architecture
+ predefine :i986, :endian => :little, :address_length => 4
+
+ # The x86_64 Architecture
+ predefine :x86_64, :endian => :little, :address_length => 8
+
+ # The ia64 Architecture
+ predefine :ia64, :endian => :little, :address_length => 8
+
+ # The 32-bit PowerPC Architecture
+ predefine :ppc, :endian => :big, :address_length => 4
+
+ # The 64-bit PowerPC Architecture
+ predefine :ppc64, :endian => :big, :address_length => 8
+
+ # The 32-bit SPARC Architecture
+ predefine :sparc, :endian => :big, :address_length => 4
+
+ # The 64-bit SPARC Architecture
+ predefine :sparc64, :endian => :big, :address_length => 8
+
+ # The MIPS (little-endian) Architecture
+ predefine :mips_le, :endian => :little, :address_length => 4
+
+ # The MIPS (big-endian) Architecture
+ predefine :mips_be, :endian => :big, :address_length => 4
+
+ # The ARM (little-endian) Architecture
+ predefine :arm_le, :endian => :little, :address_length => 4
+
+ # The ARM (big-endian) Architecture
+ predefine :arm_be, :endian => :big, :address_length => 4
end
end