Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 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);
 }