public void TrfCtx_MergeState_Stack() { var state = new Dictionary <Identifier, (Expression, BitRange)>(); var stateOther = new Dictionary <Identifier, (Expression, BitRange)>(); var procFlow = new ProcedureFlow(null); var proc = Procedure.Create(arch, Address.Ptr32(0x00123400), arch.CreateFrame()); var ssa = new SsaState(proc); var ctx = new TrashedRegisterFinder.Context( ssa, null, state, procFlow); var ctxOther = new TrashedRegisterFinder.Context( ssa, null, state, procFlow); var ebp = new Identifier("ebp", PrimitiveType.Word32, new RegisterStorage("ebp", 5, 0, PrimitiveType.Word32)); var esi = new Identifier("esi", PrimitiveType.Word32, new RegisterStorage("esi", 6, 0, PrimitiveType.Word32)); var edi = new Identifier("edi", PrimitiveType.Word32, new RegisterStorage("edi", 7, 0, PrimitiveType.Word32)); ctx.StackState[-4] = ebp; ctx.StackState[-8] = esi; ctx.StackState[-16] = Constant.Word32(0x42); ctx.StackState[-20] = Constant.Word32(0x42); ctxOther.StackState[-4] = ebp; ctxOther.StackState[-12] = edi; ctxOther.StackState[-16] = Constant.Word32(0x42); ctxOther.StackState[-20] = Constant.Word32(0x4711); ctx.MergeWith(ctxOther); Assert.AreEqual(ebp, ctx.StackState[-4]); Assert.AreEqual(esi, ctx.StackState[-8]); Assert.AreEqual(edi, ctx.StackState[-12]); Assert.AreEqual("0x42<32>", ctx.StackState[-16].ToString()); Assert.IsTrue(ctx.StackState[-20] is InvalidConstant); }
public void TrfCtx_MergeState_Stack() { var state = new Dictionary <Identifier, Tuple <Expression, BitRange> >(); var stateOther = new Dictionary <Identifier, Tuple <Expression, BitRange> >(); var procFlow = new ProcedureFlow(null); var ctx = new TrashedRegisterFinder.Context( null, null, state, procFlow); var ctxOther = new TrashedRegisterFinder.Context( null, null, state, procFlow); var ebp = new Identifier("ebp", PrimitiveType.Word32, new RegisterStorage("ebp", 5, 0, PrimitiveType.Word32)); var esi = new Identifier("esi", PrimitiveType.Word32, new RegisterStorage("esi", 6, 0, PrimitiveType.Word32)); var edi = new Identifier("edi", PrimitiveType.Word32, new RegisterStorage("edi", 7, 0, PrimitiveType.Word32)); ctx.StackState[-4] = ebp; ctx.StackState[-8] = esi; ctx.StackState[-16] = Constant.Word32(0x42); ctx.StackState[-20] = Constant.Word32(0x42); ctxOther.StackState[-4] = ebp; ctxOther.StackState[-12] = edi; ctxOther.StackState[-16] = Constant.Word32(0x42); ctxOther.StackState[-20] = Constant.Word32(0x4711); ctx.MergeWith(ctxOther); Assert.AreEqual(ebp, ctx.StackState[-4]); Assert.AreEqual(esi, ctx.StackState[-8]); Assert.AreEqual(edi, ctx.StackState[-12]); Assert.AreEqual("0x00000042", ctx.StackState[-16].ToString()); Assert.AreSame(Constant.Invalid, ctx.StackState[-20]); }