Module: Rex::Arch
- Defined in:
- lib/rex/arch.rb,
lib/rex/arch/x86.rb,
lib/rex/arch/sparc.rb
Overview
This module provides generalized methods for performing operations that are architecture specific. Furthermore, the modules contained within this module provide features that are specific to a given architecture.
Defined Under Namespace
Class Method Summary collapse
-
.adjust_stack_pointer(arch, adjustment) ⇒ Object
This routine adjusts the stack pointer for a given architecture.
-
.endian(arch) ⇒ Object
This routine reports the endianess of a given architecture.
-
.pack_addr(arch, addr) ⇒ Object
This route provides address packing for the specified arch.
Class Method Details
.adjust_stack_pointer(arch, adjustment) ⇒ Object
This routine adjusts the stack pointer for a given architecture.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rex/arch.rb', line 25 def self.adjust_stack_pointer(arch, adjustment) if ( arch.is_a?(::Array)) arch = arch[0] end case arch when /x86/ Rex::Arch::X86.adjust_reg(Rex::Arch::X86::ESP, adjustment) else nil end end |
.endian(arch) ⇒ Object
This routine reports the endianess of a given architecture
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 100 101 |
# File 'lib/rex/arch.rb', line 73 def self.endian(arch) if ( arch.is_a?(::Array)) arch = arch[0] end case arch when ARCH_X86 return ENDIAN_LITTLE when ARCH_X86_64 return ENDIAN_LITTLE when ARCH_MIPS # ambiguous return ENDIAN_BIG when ARCH_MIPSLE return ENDIAN_LITTLE when ARCH_MIPSBE return ENDIAN_BIG when ARCH_PPC # ambiguous return ENDIAN_BIG when ARCH_SPARC return ENDIAN_BIG when ARCH_ARMLE return ENDIAN_LITTLE when ARCH_ARMBE return ENDIAN_BIG end return ENDIAN_LITTLE end |
.pack_addr(arch, addr) ⇒ Object
This route provides address packing for the specified arch
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 |
# File 'lib/rex/arch.rb', line 42 def self.pack_addr(arch, addr) if ( arch.is_a?(::Array)) arch = arch[0] end case arch when ARCH_X86 [addr].pack('V') when ARCH_X86_64, ARCH_X64 [addr].pack('Q<') when ARCH_MIPS # ambiguous [addr].pack('N') when ARCH_MIPSBE [addr].pack('N') when ARCH_MIPSLE [addr].pack('V') when ARCH_PPC # ambiguous [addr].pack('N') when ARCH_SPARC [addr].pack('N') when ARCH_ARMLE [addr].pack('V') when ARCH_ARMBE [addr].pack('N') end end |