public void 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 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 Decompiler.Evaluation.ExpressionSimplifier(state)); //$TODO: hm. Move simplification out of state. Assert.IsNotNull(reportedError); }