public void X86St_Simple() { var arch = new IntelArchitecture(ProcessorMode.Real); X86State st = new X86State(arch); st.SetRegister(Registers.cs, Constant.Word16(0xC00)); st.SetRegister(Registers.ax, Constant.Word16(0x1234)); Assert.IsTrue(!st.GetRegister(Registers.bx).IsValid); Assert.IsTrue(st.GetRegister(Registers.ax).IsValid); Assert.IsTrue(st.GetRegister(Registers.al).IsValid); Assert.AreEqual(0x34, st.GetRegister(Registers.al).ToUInt32()); Assert.IsTrue(st.GetRegister(Registers.ah).IsValid); Assert.AreEqual(0x12, st.GetRegister(Registers.ah).ToUInt32()); }
public void X86St_SetAhRegisterFileValue() { var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.ah, Constant.Byte(0x3A)); Assert.IsFalse(state.IsValid(Registers.ax)); Assert.IsTrue(state.IsValid(Registers.ah)); }
public void X86St_OnBeforeCall_DecrementStackRegister() { var arch = new IntelArchitecture(ProcessorMode.Protected32); var state = new X86State(arch); var esp = CreateId(Registers.esp); state.SetRegister(Registers.esp, Constant.Word32(-4)); state.OnProcedureEntered(); var site = state.OnBeforeCall(esp, 4); Assert.AreEqual(4, site.SizeOfReturnAddressOnStack); Assert.AreEqual("0xFFFFFFFC", state.GetValue(esp).ToString()); }
public void StackUnderflow_ReportError() { var arch = new IntelArchitecture(ProcessorMode.Protected32); string reportedError = null; var state = new X86State(arch) { ErrorListener = (err) => { reportedError = err; } }; state.OnProcedureEntered(); state.SetRegister(Registers.esp, Constant.Word32(-4)); // Push only 4 bytes var esp = CreateId(Registers.esp); var site = state.OnBeforeCall(esp, 4); state.OnAfterCall(esp, new ProcedureSignature { StackDelta = 16, // ...but pop 16 bytes }, new Reko.Evaluation.ExpressionSimplifier(state)); //$TODO: hm. Move simplification out of state. Assert.IsNotNull(reportedError); }
public void X86St_SetBp() { var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.bp, Constant.Word16(0x1234)); Assert.IsFalse(state.IsValid(Registers.ebp)); Assert.IsTrue(state.IsValid(Registers.bp)); }
public void X86St_SetAhThenAl() { var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.ah, Constant.Byte(0x12)); state.SetRegister(Registers.al, Constant.Byte(0x34)); Assert.IsTrue(state.IsValid(Registers.ax)); Assert.IsTrue(state.IsValid(Registers.al)); Assert.IsTrue(state.IsValid(Registers.ah)); }
public void X86St_SetDhSymbolic_Invalid() { var ctx = new Dictionary<Storage, Expression> { { Registers.dl, Constant.Byte(3) } }; var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.dh, Constant.Invalid); Assert.IsFalse(state.IsValid(Registers.dh)); Assert.IsFalse(state.IsValid(Registers.dx)); Assert.IsFalse(state.IsValid(Registers.edx)); Assert.AreEqual("0x03", ctx[Registers.dl].ToString()); }
public void X86St_SetCxSymbolic_Invalid() { var ctx = new Dictionary<Storage, Expression> { { Registers.cl, Constant.Byte(0) } }; var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.cx, Constant.Invalid); Assert.IsFalse(state.IsValid(Registers.cx)); Assert.IsFalse(state.IsValid(Registers.cl)); Assert.IsFalse(state.IsValid(Registers.ch)); Assert.IsFalse(state.IsValid(Registers.ecx)); }
public void X86St_SetEdx() { var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.edx, Constant.Word32(0x12345678)); Assert.AreEqual(0x12345678, (long)state.GetRegister(Registers.edx).ToUInt64()); Assert.AreEqual(0x5678, (int)state.GetRegister(Registers.dx).ToUInt32()); Assert.AreEqual(0x78, (int)state.GetRegister(Registers.dl).ToUInt32()); Assert.AreEqual(0x56, (int)state.GetRegister(Registers.dh).ToUInt32()); }
public void X86St_SetCx() { var state = new X86State(new X86ArchitectureFlat64()); state.SetRegister(Registers.cx, Constant.Word16(0x1234)); Assert.AreEqual(0x1234, (int)state.GetRegister(Registers.cx).ToUInt16()); Assert.AreEqual(0x34, (int)state.GetRegister(Registers.cl).ToByte()); Assert.AreEqual(0x12, (int)state.GetRegister(Registers.ch).ToByte()); Assert.IsTrue(state.IsValid(Registers.cx)); Assert.IsTrue(state.IsValid(Registers.cl)); Assert.IsTrue(state.IsValid(Registers.ch)); }