Files
metasploit-gs/lib/metasploit/framework/compiler/utils.rb
T

26 lines
659 B
Ruby
Raw Normal View History

module Metasploit
module Framework
module Compiler
module Utils
# Returns the normalized C code (with headers).
#
# @param code [String] The C source code.
# @param headers [Metasploit::Framework::Compiler::Headers::Win32]
# @return [String] The normalized code.
def self.normalize_code(code, headers)
code = code.lines.map { |line|
2018-05-10 22:39:49 -05:00
if line =~ /^#include <([[:print:]]+)>$/
%Q|<%= headers.include('#{$1}') %>\n|
else
line
end
}.join
ERB.new(code).result(binding)
end
end
end
end
end