Module: Ronin::Support::Binary::CTypes::Mixin

Included in:
Array, Buffer, Stack, Stream, Struct, Template
Defined in:
lib/ronin/support/binary/ctypes/mixin.rb

Overview

Adds a type system that can be used by Memory objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arch:x86, ... (readonly)

The desired architecture of the binary format.

Returns:

  • (:x86, :x86_64, :ppc, :ppc64, :arm, :arm_be, :arm64, :arm64_be, :mips, :mips_le, :mips64, :mips64_le, nil)


44
45
46
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 44

def arch
  @arch
end

#endian:little, ... (readonly)

The endianness of the binary format.

Returns:

  • (:little, :big, :net, nil)


36
37
38
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 36

def endian
  @endian
end

#os:linux, ... (readonly)

The desired Operating System (OS) of the binary format.

Returns:

  • (:linux, :macos, :windows, :android, :apple_ios, :bsd, :freebsd, :openbsd, :netbsd, nil)


53
54
55
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 53

def os
  @os
end

#type_resolverResolver (readonly)

The type resolver.

Returns:

  • (Resolver)


80
81
82
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 80

def type_resolver
  @type_resolver
end

#type_systemNative, ... (readonly)

The type system module or object to lookup type names in.



73
74
75
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 73

def type_system
  @type_system
end

Instance Method Details

#initialize_type_system(type_system: nil, endian: nil, arch: nil, os: nil) ⇒ Object (protected)

Initializes the type system.

Optional type system to use instead.

The desired architecture to use.

The Operating System (OS) to use.

Parameters:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ronin/support/binary/ctypes/mixin.rb', line 119

def initialize_type_system(type_system: nil,
                           endian:      nil,
                           arch:        nil,
                           os:          nil)
  @endian = endian
  @arch   = arch
  @os     = os

  @type_system = type_system || CTypes.platform(
                                  endian: endian,
                                  arch:   arch,
                                  os:     os
                                )

  @type_resolver = CTypes::TypeResolver.new(@type_system)
end