public void MallocCall() { const uint INITIAL_INSTRUCTION_POINTER = 0x804838f; // TODO: need to reconcile with esp/ebp handling state = state.PushOntoStack(new AbstractValue(16)); state.InstructionPointer = INITIAL_INSTRUCTION_POINTER; code = new Byte[] { 0xe8, 0x14, 0xff, 0xff, 0xff }; state = X86Emulator.Run(reportItems, state, code); Assert.AreEqual(INITIAL_INSTRUCTION_POINTER + code.Length, state.InstructionPointer); Assert.AreEqual(16, state.ReturnValue.PointsTo.Length); }
public void PushPopThenAssignToTop() { var buffer = AbstractValue.GetNewBuffer(0x20); esp = new AbstractValue(buffer); state = state.PushOntoStack(one); // TODO(matt_hargett): extract into state.PopOffStack() state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x4)); state = state.DoOperation(RegisterName.ESP, 0, OperatorEffect.Assignment, two); Assert.AreEqual(two, state.TopOfStack); }
public void Execute() { var address = new AbstractValue(0xdeadbabe); state = state.PushOntoStack(address); state = contract.Execute(state); Assert.AreEqual(address.Value, state.InstructionPointer); }
public void PushTwiceThenManuallyAdjustStackThenAssignToEbp() { var buffer = AbstractValue.GetNewBuffer(0x20); esp = new AbstractValue(buffer); state = state.PushOntoStack(one); state = state.PushOntoStack(two); state = state.DoOperation(RegisterName.ESP, OperatorEffect.Sub, new AbstractValue(0x4)); Assert.AreEqual(one, state.TopOfStack); }