node/lib/metasm/metasm/decompile.rb
# patch scope to transform :frameoff-x into &var_x
patch scope to transform :frameoff-x into &var_x
patch scope to transform : frameoff - x into &var_x
def namestackvars(scope)
		off2var = {}
		newvar = lambda { |o, n|
			if not v = off2var[o]
				v = off2var[o] = C::Variable.new
				v.type = C::BaseType.new(:void)
				v.name = n
				v.stackoff = o
				scope.symbol[v.name] = v
				scope.statements << C::Declaration.new(v)
			end
			v
		}
		scope.decompdata[:stackoff_name].each { |o, n| newvar[o, n] }
		scope.decompdata[:stackoff_type].each { |o, t| newvar[o, stackoff_to_varname(o)] }
		walk_ce(scope) { |e|
			next if e.op != :+ and e.op != :-
			next if not e.lexpr.kind_of? C::Variable or e.lexpr.name != 'frameptr'
			next if not e.rexpr.kind_of? C::CExpression or e.rexpr.op or not e.rexpr.rexpr.kind_of? ::Integer
			off = e.rexpr.rexpr
			off = -off if e.op == :-
			v = newvar[off, stackoff_to_varname(off)]
			e.replace C::CExpression[:&, v]
		}
	end
def namestackvars ( scope ) off2var = { } newvar = lambda { | o , n | if not v = off2var [ o ] v = off2var [ o ] = C :: Variable . new v . type = C :: BaseType . new ( :void ) v . name = n v . stackoff = o scope . symbol [ v . name ] = v scope . statements << C :: Declaration . new ( v ) end v } scope . decompdata [ :stackoff_name ] . each { | o , n | newvar [ o , n ] } scope . decompdata [ :stackoff_type ] . each { | o , t | newvar [ o , stackoff_to_varname ( o ) ] } walk_ce ( scope ) { | e | next if e . op != :+ and e . op != :- next if not e . lexpr . kind_of? C :: Variable or e . lexpr . name != 'frameptr' next if not e . rexpr . kind_of? C :: CExpression or e . rexpr . op or not e . rexpr . rexpr . kind_of? :: Integer off = e . rexpr . rexpr off = - off if e . op == :- v = newvar [ off , stackoff_to_varname ( off ) ] e . replace C :: CExpression [ :& , v ] } end
patch scope to transform :frameoff-x into &var_x
patch scope to transform : frameoff - x into &var_x
scope