node/lib/metasm/metasm/gui/dasm_main.rb
def prompt_constant(di=curobj)
		return if not di.kind_of?(DecodedInstruction)
		di.each_expr { |e|
			next unless e.kind_of?(Expression)
			if (e.lexpr.kind_of?(Integer) or e.lexpr.kind_of?(ExpressionString)) and
					(!curview.hl_word or curview.hl_word == Expression[e.lexpr].to_s)
				v = Expression[e.lexpr].reduce
				lst = []
				dasm.c_constants.each { |cn, cv, fm| lst << [cn, fm] if v == cv }
				if not lst.empty?
					default = Expression[v].to_s
					lst << [default]
					listwindow("constant for #{Expression[v]}", [['name', 'enum']] + lst) { |a|
						if a[0] == default
							e.lexpr = v
						else
							e.lexpr = ExpressionString.new(v, a[0], :constant)
						end
						session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.lexpr = #{e.lexpr.inspect} if e.kind_of?(Expression) and e.lexpr and Expression[e.lexpr].reduce == #{v.inspect} } ; end"
						gui_update
					}
				end
			end
			if (e.rexpr.kind_of? Integer or e.rexpr.kind_of?(ExpressionString)) and
					(!curview.hl_word or curview.hl_word == Expression[e.rexpr].to_s)
				v = Expression[e.rexpr].reduce
				lst = []
				dasm.c_constants.each { |cn, cv, fm| lst << [cn, fm] if v == cv }
				if not lst.empty?
					default = Expression[v].to_s
					lst << [default]
					listwindow("constant for #{Expression[v]}", [['name', 'enum']] + lst) { |a|
						if a[0] == default
							e.rexpr = v
						else
							e.rexpr = ExpressionString.new(v, a[0], :constant)
						end
						session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.rexpr = #{e.rexpr.inspect} if e.kind_of?(Expression) and e.rexpr and Expression[e.rexpr].reduce == #{v.inspect} } ; end"
						gui_update
					}
				end
			end
		}
	end
# prompt the contant to use in place of some numeric value
prompt the contant to use in place of some numeric value
prompt the contant to use in place of some numeric value
def prompt_constant(di=curobj)
		return if not di.kind_of?(DecodedInstruction)
		di.each_expr { |e|
			next unless e.kind_of?(Expression)
			if (e.lexpr.kind_of?(Integer) or e.lexpr.kind_of?(ExpressionString)) and
					(!curview.hl_word or curview.hl_word == Expression[e.lexpr].to_s)
				v = Expression[e.lexpr].reduce
				lst = []
				dasm.c_constants.each { |cn, cv, fm| lst << [cn, fm] if v == cv }
				if not lst.empty?
					default = Expression[v].to_s
					lst << [default]
					listwindow("constant for #{Expression[v]}", [['name', 'enum']] + lst) { |a|
						if a[0] == default
							e.lexpr = v
						else
							e.lexpr = ExpressionString.new(v, a[0], :constant)
						end
						session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.lexpr = #{e.lexpr.inspect} if e.kind_of?(Expression) and e.lexpr and Expression[e.lexpr].reduce == #{v.inspect} } ; end"
						gui_update
					}
				end
			end
			if (e.rexpr.kind_of? Integer or e.rexpr.kind_of?(ExpressionString)) and
					(!curview.hl_word or curview.hl_word == Expression[e.rexpr].to_s)
				v = Expression[e.rexpr].reduce
				lst = []
				dasm.c_constants.each { |cn, cv, fm| lst << [cn, fm] if v == cv }
				if not lst.empty?
					default = Expression[v].to_s
					lst << [default]
					listwindow("constant for #{Expression[v]}", [['name', 'enum']] + lst) { |a|
						if a[0] == default
							e.rexpr = v
						else
							e.rexpr = ExpressionString.new(v, a[0], :constant)
						end
						session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.rexpr = #{e.rexpr.inspect} if e.kind_of?(Expression) and e.rexpr and Expression[e.rexpr].reduce == #{v.inspect} } ; end"
						gui_update
					}
				end
			end
		}
	end
def prompt_constant ( di = curobj ) return if not di . kind_of? ( DecodedInstruction ) di . each_expr { | e | next unless e . kind_of? ( Expression ) if ( e . lexpr . kind_of? ( Integer ) or e . lexpr . kind_of? ( ExpressionString ) ) and ( ! curview . hl_word or curview . hl_word == Expression [ e . lexpr ] . to_s ) v = Expression [ e . lexpr ] . reduce lst = [ ] dasm . c_constants . each { | cn , cv , fm | lst << [ cn , fm ] if v == cv } if not lst . empty? default = Expression [ v ] . to_s lst << [ default ] listwindow ( "constant for #{Expression[v]}" , [ [ 'name' , 'enum' ] ] + lst ) { | a | if a [ 0 ] == default e . lexpr = v else e . lexpr = ExpressionString . new ( v , a [ 0 ] , :constant ) end session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.lexpr = #{e.lexpr.inspect} if e.kind_of?(Expression) and e.lexpr and Expression[e.lexpr].reduce == #{v.inspect} } ; end" gui_update } end end if ( e . rexpr . kind_of? Integer or e . rexpr . kind_of? ( ExpressionString ) ) and ( ! curview . hl_word or curview . hl_word == Expression [ e . rexpr ] . to_s ) v = Expression [ e . rexpr ] . reduce lst = [ ] dasm . c_constants . each { | cn , cv , fm | lst << [ cn , fm ] if v == cv } if not lst . empty? default = Expression [ v ] . to_s lst << [ default ] listwindow ( "constant for #{Expression[v]}" , [ [ 'name' , 'enum' ] ] + lst ) { | a | if a [ 0 ] == default e . rexpr = v else e . rexpr = ExpressionString . new ( v , a [ 0 ] , :constant ) end session_append "if di = dasm.di_at(#{di.address.inspect}) ; di.each_expr { |e| e.rexpr = #{e.rexpr.inspect} if e.kind_of?(Expression) and e.rexpr and Expression[e.rexpr].reduce == #{v.inspect} } ; end" gui_update } end end } end
prompt the contant to use in place of some numeric value
prompt the contant to use in place of some numeric value
di
curobj