node/lib/metasm/metasm/decompile.rb
def fix_type_overlap(scope)
		varinfo = {}
		scope.symbol.each_value { |var|
			next if not off = var.stackoff
			len = sizeof(var)
			varinfo[var] = [off, len]
		}

		varinfo.each { |v1, (o1, l1)|
			next if not v1.type.integral?
			varinfo.each { |v2, (o2, l2)|
				# XXX o1 may overlap o2 AND another (int32 v_10; int32 v_E; int32 v_C;)
				# TODO should check stuff with aliasing domains
				next if v1.name == v2.name or o1 >= o2+l2 or o1+l1 <= o2 or l1 > l2 or (l2 == l1 and o2 >= o1)
				# v1 => *(&v2+delta)
				p = C::CExpression[:&, v2]
				p = C::CExpression[p, :+,  [o1-o2]]
				p = C::CExpression[p, C::Pointer.new(v1.type)] if v1.type != p.type.type
				p = C::CExpression[:*, p]
				walk_ce(scope) { |ce|
					ce.lexpr = p if ce.lexpr == v1
					ce.rexpr = p if ce.rexpr == v1
				}
			}
		}
	end
# handling of var overlapping (eg __int32 var_10; __int8 var_F  =>  replace all var_F by *(&var_10 + 1))
# must be done before fix_pointer_arithmetic
handling of var overlapping )
must be done before fix_pointer_arithmetic
handling of var overlapping ) must be done before fix_pointer_arithmetic
def fix_type_overlap(scope)
		varinfo = {}
		scope.symbol.each_value { |var|
			next if not off = var.stackoff
			len = sizeof(var)
			varinfo[var] = [off, len]
		}
		varinfo.each { |v1, (o1, l1)|
			next if not v1.type.integral?
			varinfo.each { |v2, (o2, l2)|
				next if v1.name == v2.name or o1 >= o2+l2 or o1+l1 <= o2 or l1 > l2 or (l2 == l1 and o2 >= o1)
				p = C::CExpression[:&, v2]
				p = C::CExpression[p, :+,  [o1-o2]]
				p = C::CExpression[p, C::Pointer.new(v1.type)] if v1.type != p.type.type
				p = C::CExpression[:*, p]
				walk_ce(scope) { |ce|
					ce.lexpr = p if ce.lexpr == v1
					ce.rexpr = p if ce.rexpr == v1
				}
			}
		}
	end
def fix_type_overlap ( scope ) varinfo = { } scope . symbol . each_value { | var | next if not off = var . stackoff len = sizeof ( var ) varinfo [ var ] = [ off , len ] } varinfo . each { | v1 , ( o1 , l1 ) | next if not v1 . type . integral? varinfo . each { | v2 , ( o2 , l2 ) | next if v1 . name == v2 . name or o1 >= o2 + l2 or o1 + l1 <= o2 or l1 > l2 or ( l2 == l1 and o2 >= o1 ) p = C :: CExpression [ :& , v2 ] p = C :: CExpression [ p , :+ , [ o1 - o2 ] ] p = C :: CExpression [ p , C :: Pointer . new ( v1 . type ) ] if v1 . type != p . type . type p = C :: CExpression [ :* , p ] walk_ce ( scope ) { | ce | ce . lexpr = p if ce . lexpr == v1 ce . rexpr = p if ce . rexpr == v1 } } } end
handling of var overlapping (eg __int32 var_10; __int8 var_F  =>  replace all var_F by *(&var_10 + 1))
must be done before fix_pointer_arithmetic
handling of var overlapping ( eg __int32 var_10 ; __int8 var_F = > replace all var_F by * ( &var_10 + 1 )) must be done before fix_pointer_arithmetic
# XXX o1 may overlap o2 AND another (int32 v_10; int32 v_E; int32 v_C;) # TODO should check stuff with aliasing domains # v1 => *(&v2+delta)
scope