node/lib/metasm/samples/peldr.rb
# similar to DL.new_api_c for the mapped PE
similar to DL.new_api_c for the mapped PE
similar to DL . new_api_c for the mapped PE
def new_api_c(proto)
		proto += ';'    
		cp = DL.host_cpu.new_cparser
		cp.parse(proto)
		cp.toplevel.symbol.each_value { |v|
			next if not v.kind_of? Metasm::C::Variable      
			if e = pe.export.exports.find { |e_| e_.name == v.name and e_.target }
				DL.new_caller_for(cp, v, v.name.downcase, @load_address + pe.label_rva(e.target))
			end
		}
		cp.numeric_constants.each { |k, v, f|
			n = k.upcase
			n = "C#{n}" if n !~ /^[A-Z]/
			DL.const_set(n, v) if not DL.const_defined?(n) and v.kind_of? Integer
		}
	end
def new_api_c ( proto ) proto += ';' cp = DL . host_cpu . new_cparser cp . parse ( proto ) cp . toplevel . symbol . each_value { | v | next if not v . kind_of? Metasm :: C :: Variable if e = pe . export . exports . find { | e_ | e_ . name == v . name and e_ . target } DL . new_caller_for ( cp , v , v . name . downcase , @load_address + pe . label_rva ( e . target ) ) end } cp . numeric_constants . each { | k , v , f | n = k . upcase n = "C#{n}" if n !~ / ^[A-Z] / DL . const_set ( n , v ) if not DL . const_defined? ( n ) and v . kind_of? Integer } end
similar to DL.new_api_c for the mapped PE
similar to DL . new_api_c for the mapped PE
# allow 'int foo()' # enums
proto