Module: Metasploit::Framework::Compiler::Utils

Defined in:
lib/metasploit/framework/compiler/utils.rb

Class Method Summary collapse

Class Method Details

.normalize_code(code, headers) ⇒ String

Returns the normalized C code (with headers).

Parameters:

  • code (String)

    The C source code.

  • headers (Metasploit::Framework::Compiler::Headers::Win32)

Returns:

  • (String)

    The normalized code.


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/metasploit/framework/compiler/utils.rb', line 11

def self.normalize_code(code, headers)
  code = code.lines.map { |line|
    if line =~ /^\s*#include <([[:print:]]+)>$/
      h = headers.include("#{$1}")
      %Q|#{h}\n|
    else
      line
    end
  }.join

  code
end