public ExpressionSimplifier(EvaluationContext ctx, DecompilerEventListener listener) { this.ctx = ctx; this.add2ids = new AddTwoIdsRule(ctx); this.addEcc = new Add_e_c_cRule(ctx); this.addMici = new Add_mul_id_c_id_Rule(ctx); this.dpbConstantRule = new DpbConstantRule(); this.dpbdpbRule = new DpbDpbRule(ctx); this.idConst = new IdConstant(ctx, new Unifier(), listener); this.idCopyPropagation = new IdCopyPropagationRule(ctx); this.idBinIdc = new IdBinIdc_Rule(ctx); this.sliceConst = new SliceConstant_Rule(); this.sliceMem = new SliceMem_Rule(); this.sliceSegPtr = new SliceSegmentedPointer_Rule(ctx); this.negSub = new NegSub_Rule(); this.constConstBin = new ConstConstBin_Rule(); this.shAdd = new Shl_add_Rule(ctx); this.shMul = new Shl_mul_e_Rule(ctx); this.shiftShift = new ShiftShift_c_c_Rule(ctx); this.mpsRule = new Mps_Constant_Rule(ctx); this.sliceShift = new SliceShift(ctx); this.binopWithSelf = new BinOpWithSelf_Rule(); this.constDiv = new ConstDivisionImplementedByMultiplication(ctx); this.selfdpbRule = new SelfDpbRule(ctx); this.idProcConstRule = new IdProcConstRule(ctx); this.castCastRule = new CastCastRule(ctx); }
public ExpressionSimplifier(SegmentMap segmentMap, EvaluationContext ctx, DecompilerEventListener listener) { this.segmentMap = segmentMap ?? throw new ArgumentNullException(nameof(SegmentMap)); this.ctx = ctx; this.cmp = new ExpressionValueComparer(); this.add2ids = new AddTwoIdsRule(ctx); this.addEcc = new Add_e_c_cRule(ctx); this.addMici = new Add_mul_id_c_id_Rule(ctx); this.dpbConstantRule = new DpbConstantRule(); this.dpbdpbRule = new DpbDpbRule(ctx); this.idConst = new IdConstant(ctx, new Unifier(), listener); this.idCopyPropagation = new IdCopyPropagationRule(ctx); this.idBinIdc = new IdBinIdc_Rule(ctx); this.sliceConst = new SliceConstant_Rule(); this.sliceMem = new SliceMem_Rule(); this.sliceSegPtr = new SliceSegmentedPointer_Rule(ctx); this.negSub = new NegSub_Rule(); this.constConstBin = new ConstConstBin_Rule(); this.shAdd = new Shl_add_Rule(ctx); this.shMul = new Shl_mul_e_Rule(ctx); this.shiftShift = new ShiftShift_c_c_Rule(ctx); this.mpsRule = new Mps_Constant_Rule(ctx); this.sliceShift = new SliceShift(ctx); this.binopWithSelf = new BinOpWithSelf_Rule(); this.constDiv = new ConstDivisionImplementedByMultiplication(ctx); this.selfdpbRule = new SelfDpbRule(ctx); this.idProcConstRule = new IdProcConstRule(ctx); this.castCastRule = new CastCastRule(ctx); this.distributedCast = new DistributedCastRule(); this.distributedSlice = new DistributedSliceRule(); this.mkSeqFromSlicesRule = new MkSeqFromSlices_Rule(ctx); this.constOnLeft = new ComparisonConstOnLeft(); this.sliceSeq = new SliceSequence(ctx); }
public void Idc_ConstantReferenceInt() { var dword = new TypeReference("DWORD", PrimitiveType.Int32); Identifier edx = new Identifier("edx", dword, Registers.edx); var ctx = new SymbolicEvaluationContext(null, null); ctx.SetValue(edx, Constant.Int32(321)); IdConstant ic = new IdConstant(ctx, new Unifier(null)); Assert.IsTrue(ic.Match(edx)); Expression e = ic.Transform(); Assert.AreEqual("321", e.ToString()); Assert.AreEqual("int32", e.DataType.ToString()); }
public void ConstantPropagate() { Identifier ds = m.Frame.EnsureRegister(Registers.ds); var c = Constant.Word16(0x1234); m.Assign(ds, c); m.SideEffect(ds); var def = m.Block.Statements[0]; var use = m.Block.Statements[1]; SsaIdentifier sid_ds = ssa.Add(ds, def, c, false); var ass = (Assignment)def.Instruction; ass.Dst = sid_ds.Identifier; ((SideEffect)use.Instruction).Expression = sid_ds.Identifier; sid_ds.Uses.Add(use); IdConstant ic = new IdConstant(new SsaEvaluationContext(ssa), new Unifier(null)); Assert.IsTrue(ic.Match(sid_ds.Identifier)); Expression e = ic.Transform(); Assert.AreEqual("selector", e.DataType.ToString()); }
public ExpressionSimplifier(SegmentMap segmentMap, EvaluationContext ctx, DecompilerEventListener listener) { this.segmentMap = segmentMap ?? throw new ArgumentNullException(nameof(SegmentMap)); this.ctx = ctx; this.cmp = new ExpressionValueComparer(); this.m = new ExpressionEmitter(); this.unifier = new Unifier(); this.add2ids = new AddTwoIdsRule(ctx); this.addEcc = new Add_e_c_cRule(ctx); this.addMici = new Add_mul_id_c_id_Rule(ctx); this.idConst = new IdConstant(ctx, unifier, listener); this.idCopyPropagation = new IdCopyPropagationRule(ctx); this.idBinIdc = new IdBinIdc_Rule(ctx); this.sliceConst = new SliceConstant_Rule(); this.sliceMem = new SliceMem_Rule(); this.sliceSegPtr = new SliceSegmentedPointer_Rule(ctx); this.negSub = new NegSub_Rule(); this.constConstBin = new ConstConstBin_Rule(); this.shAdd = new Shl_add_Rule(ctx); this.shMul = new Shl_mul_e_Rule(ctx); this.shiftShift = new ShiftShift_c_c_Rule(ctx); this.mpsRule = new Mps_Constant_Rule(ctx); this.sliceShift = new SliceShift(ctx); this.binopWithSelf = new BinOpWithSelf_Rule(); this.constDiv = new ConstDivisionImplementedByMultiplication(ctx); this.idProcConstRule = new IdProcConstRule(ctx); this.convertConvertRule = new ConvertConvertRule(ctx); this.distributedConvert = new DistributedConversionRule(); this.distributedCast = new DistributedCastRule(); this.distributedSlice = new DistributedSliceRule(); this.mkSeqFromSlicesRule = new MkSeqFromSlices_Rule(ctx); this.constOnLeft = new ComparisonConstOnLeft(); this.sliceSeq = new SliceSequence(ctx); this.sliceConvert = new SliceConvert(); this.logicalNotFollowedByNeg = new LogicalNotFollowedByNegRule(); this.logicalNotFromBorrow = new LogicalNotFromArithmeticSequenceRule(); this.unaryNegEqZero = new UnaryNegEqZeroRule(); this.scaledIndexRule = new ScaledIndexRule(ctx); }
public ExpressionSimplifier(EvaluationContext ctx) { this.ctx = ctx; this.add2ids = new AddTwoIdsRule(ctx); this.addEcc = new Add_e_c_cRule(ctx); this.addMici = new Add_mul_id_c_id_Rule(ctx); this.dpbConstantRule = new DpbConstantRule(); this.dpbdpbRule = new DpbDpbRule(ctx); this.idConst = new IdConstant(ctx, new Unifier()); this.idCopyPropagation = new IdCopyPropagationRule(ctx); this.idBinIdc = new IdBinIdc_Rule(ctx); this.sliceConst = new SliceConstant_Rule(); this.sliceMem = new SliceMem_Rule(); this.negSub = new NegSub_Rule(); this.constConstBin = new ConstConstBin_Rule(); this.shMul = new Shl_mul_e_Rule(ctx); this.shiftShift = new ShiftShift_c_c_Rule(ctx); this.mpsRule = new Mps_Constant_Rule(ctx); this.sliceShift = new SliceShift(ctx); this.binopWithSelf = new BinOpWithSelf_Rule(); }
public void Idc_ConstantReferencePointerToInt() { var intptr = new TypeReference("INTPTR", new Pointer(PrimitiveType.Int32, 4)); Identifier edx = new Identifier("edx", intptr, Registers.edx); var ctx = new SymbolicEvaluationContext(null, null); ctx.SetValue(edx, Constant.Int32(0x567)); IdConstant ic = new IdConstant(ctx, new Unifier(null)); Assert.IsTrue(ic.Match(edx)); Expression e = ic.Transform(); Assert.AreEqual("00000567", e.ToString()); Assert.AreEqual("(ptr int32)", e.DataType.ToString()); }