public MachineState(MachineState copyMe) { instructionPointer = copyMe.instructionPointer; registers = new RegisterCollection(copyMe.registers); dataSegment = new Dictionary<UInt32, AbstractValue>(copyMe.dataSegment); zeroFlag = copyMe.zeroFlag; }
private static RegisterCollection createRegistersForLinuxStart() { var linuxMainDefaultValues = new RegisterCollection(); var arg0 = new AbstractValue(1).AddTaint(); var argvBuffer = new[] { arg0 }; var argvPointer = new AbstractValue(argvBuffer); var argvPointerBuffer = new[] { argvPointer }; var argvPointerPointer = new AbstractValue(argvPointerBuffer); var stackBuffer = AbstractValue.GetNewBuffer(0x200); var buffer = new AbstractBuffer(stackBuffer); var modifiedBuffer = buffer.DoOperation(OperatorEffect.Add, new AbstractValue(0x100)); // linux ABI dictates modifiedBuffer[5] = argvPointerPointer; // gcc generates code that accesses this at some optimization levels modifiedBuffer[0xfc] = new AbstractValue(1); var stackPointer = new AbstractValue(modifiedBuffer); linuxMainDefaultValues[RegisterName.ESP] = stackPointer; return(linuxMainDefaultValues); }
public MachineState(RegisterCollection registers) { dataSegment = new Dictionary<UInt32, AbstractValue>(); this.registers = registers; instructionPointer = 0x00; zeroFlag = false; }
public void SetUp() { var registers = new RegisterCollection(); registers[RegisterName.ESP] = new AbstractValue(AbstractValue.GetNewBuffer(1)); state = new MachineState(registers); contract = new GLibcStartMainContract(); }
public MachineState(RegisterCollection registers) { dataSegment = new Dictionary <UInt32, AbstractValue>(); this.registers = registers; instructionPointer = 0x00; zeroFlag = false; }
public MachineState(MachineState copyMe) { instructionPointer = copyMe.instructionPointer; registers = new RegisterCollection(copyMe.registers); dataSegment = new Dictionary <UInt32, AbstractValue>(copyMe.dataSegment); zeroFlag = copyMe.zeroFlag; }
public RegisterCollection(RegisterCollection _copyMe) { registers = new AbstractValue[8]; for (UInt32 i = 0; i < registers.Length; ++i) { registers[i] = new AbstractValue(_copyMe.registers[i]); } }
public void InitialRegisters() { var registers = new RegisterCollection(); registers[RegisterName.EAX] = one; state = new MachineState(registers); var newState = X86Emulator.Run(reportItems, state, new byte[] { 0x90 }); Assert.AreEqual(one, newState.Registers[RegisterName.EAX]); Assert.AreNotSame(state, newState); Assert.AreNotEqual(state, newState); }
public void Copy() { registers[RegisterName.ESP] = new AbstractValue(new AbstractBuffer(AbstractValue.GetNewBuffer(10))); var newRegisters = new RegisterCollection(registers); for (UInt32 i = 0; i < 7; i++) { var register = (RegisterName)i; Assert.AreNotSame(newRegisters[register], registers[register]); } Assert.AreNotSame(newRegisters[RegisterName.ESP].PointsTo, registers[RegisterName.ESP].PointsTo); }
public void Equality() { var same = new MachineState(new RegisterCollection()); same.DataSegment[0] = new AbstractValue(2); var same2 = new MachineState(new RegisterCollection()); same2.DataSegment[0] = new AbstractValue(2); var registers = new RegisterCollection(); registers[RegisterName.EAX] = new AbstractValue(1); var differentViaRegisters = new MachineState(registers); differentViaRegisters.DataSegment[0] = new AbstractValue(2); Assert.IsTrue(same.Equals(same2)); Assert.IsFalse(differentViaRegisters.Equals(same)); Assert.IsTrue(same == same2); Assert.IsTrue(same != differentViaRegisters); Assert.AreEqual(same.GetHashCode(), same2.GetHashCode()); Assert.AreNotEqual(same.GetHashCode(), differentViaRegisters.GetHashCode()); registers = new RegisterCollection(); var differentViaDataSegmentKey = new MachineState(registers); differentViaDataSegmentKey.DataSegment[1] = new AbstractValue(2); Assert.IsFalse(same.Equals(differentViaDataSegmentKey)); registers = new RegisterCollection(); var differentViaDataSegmentValue = new MachineState(registers); differentViaDataSegmentValue.DataSegment[0] = new AbstractValue(1); Assert.IsFalse(same.Equals(differentViaDataSegmentValue)); }
public void SetUp() { registers = new RegisterCollection(); }
public void InitialRegisters() { var registers = new RegisterCollection(); registers[RegisterName.EAX] = one; state = new MachineState(registers); var newState = X86Emulator.Run(reportItems, state, new byte[] {0x90}); Assert.AreEqual(one, newState.Registers[RegisterName.EAX]); Assert.AreNotSame(state, newState); Assert.AreNotEqual(state, newState); }