Class: Metasploit::Framework::Compiler::Headers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/metasploit/framework/compiler/headers/base.rb

Direct Known Subclasses

Windows

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Initializes the Base class for headers.



10
11
12
13
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 10

def initialize
  # This is used to avoid loading the same dependency code twice
  @loaded_dep = []
end

Instance Attribute Details

#loaded_depObject

Returns the value of attribute loaded_dep.



7
8
9
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 7

def loaded_dep
  @loaded_dep
end

Instance Method Details

#include(lib_name) ⇒ String

Returns the header source code.

Parameters:

  • lib_name (String)

    The file name of the header.

Returns:

  • (String)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/metasploit/framework/compiler/headers/base.rb', line 19

def include(lib_name)
  lib = lib_dep_map[lib_name]
  unless lib
    raise RuntimeError, "#{lib_name} not found"
  end

  # Load the dependencies first, and only once
  dep = ''
  lib.each do |f|
    unless loaded_dep.include?(f)
      dep_path = File.join(headers_path, f)
      dep << File.read(dep_path) << "\n"
      loaded_dep << f
    end
  end

  # Load the headers
  lib_path = File.join(headers_path, lib_name)
  "#{dep}#{File.read(lib_path)}"
end