private void Translate_Not(CflowStack stack, Instruction instr) { var val1 = stack.Pop(); if (val1 is BitVecExpr) { stack.Push(ctx.MkBVNot(val1 as BitVecExpr)); } else { stack.PushUnknown(); } }
private void Translate_Ldind_I4(CflowStack stack, Instruction instr) { var addr = stack.Pop(); if (addr is Address && (addr as Address).Value is BitVecExpr) { stack.Push((addr as Address).Value); } else { stack.PushUnknown(); } }
private void Translate_Clt_Un(CflowStack stack, Instruction instr) { var val2 = stack.Pop(); var val1 = stack.Pop(); if (val1 is BitVecExpr && (val1 as BitVecExpr).Simplify().IsNumeral&& val2 is BitVecExpr && (val2 as BitVecExpr).Simplify().IsNumeral) { stack.Push((BitVecExpr)ctx.MkITE(ctx.MkBVULT(val1 as BitVecExpr, val2 as BitVecExpr), ctx.MkBV(1, 32), ctx.MkBV(0, 32))); } else { stack.PushUnknown(); } }
private void Translate_Shr_Un(CflowStack stack, Instruction instr) { var val2 = stack.Pop(); var val1 = stack.Pop(); if (val1 is BitVecExpr && val2 is BitVecExpr) { stack.Push(ctx.MkBVLSHR(val1 as BitVecExpr, val2 as BitVecExpr)); } else { stack.PushUnknown(); } }
private void Translate_Mul_Ovf_Un(CflowStack stack, Instruction instr) { var val2 = stack.Pop(); var val1 = stack.Pop(); if (val1 is BitVecExpr && val2 is BitVecExpr) { stack.Push((BitVecExpr)ctx.MkITE(ctx.MkBVMulNoOverflow(val1 as BitVecExpr, val2 as BitVecExpr, false), ctx.MkBVMul(val1 as BitVecExpr, val2 as BitVecExpr), stack.Unknown() as BitVecExpr)); } else { stack.PushUnknown(); } }
private void Translate_Sub_Ovf(CflowStack stack, Instruction instr) { var val2 = stack.Pop(); var val1 = stack.Pop(); if (val1 is BitVecExpr && val2 is BitVecExpr) { stack.Push((BitVecExpr)ctx.MkITE(ctx.MkBVSubNoUnderflow(val1 as BitVecExpr, val2 as BitVecExpr, true), ctx.MkBVSub(val1 as BitVecExpr, val2 as BitVecExpr), stack.Unknown() as BitVecExpr)); } else { stack.PushUnknown(); } }
private void Translate_Ldlen(CflowStack stack, Instruction instr) { var val = stack.Pop(); if (val is IField) { if ((val as IField).FullName == "System.Type[] System.Type::EmptyTypes") { stack.Push(ctx.MkBV(0, 32)); return; } } stack.PushUnknown(); }
private void UpdateStack(CflowStack stack, Instruction instr) { int pushes, pops; instr.CalculateStackUsage(out pushes, out pops); if (pops == -1) { stack.Clear(); } else { stack.Pop(pops); stack.Push(pushes); } }
private void Translate_Ldloca(CflowStack stack, List <BitVecExpr> locals, Local local) { stack.Push(new Address(GetLocal(stack, locals, local))); SetLocal(locals, local == null ? -1 : local.Index, GetUnknownLocal(stack)); }
private void Translate_Sizeof(CflowStack stack, Instruction instr) { if (instr.Operand is TypeRef) { if ((instr.Operand as TypeRef).FullName == "System.Boolean") { stack.Push(ctx.MkBV(sizeof(System.Boolean), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Byte") { stack.Push(ctx.MkBV(sizeof(System.Byte), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.SByte") { stack.Push(ctx.MkBV(sizeof(System.SByte), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Char") { stack.Push(ctx.MkBV(sizeof(System.Char), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Int16") { stack.Push(ctx.MkBV(sizeof(System.Int16), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Int32") { stack.Push(ctx.MkBV(sizeof(System.Int32), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Int64") { stack.Push(ctx.MkBV(sizeof(System.Int64), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.UInt16") { stack.Push(ctx.MkBV(sizeof(System.UInt16), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.UInt32") { stack.Push(ctx.MkBV(sizeof(System.UInt32), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.UInt64") { stack.Push(ctx.MkBV(sizeof(System.UInt64), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Single") { stack.Push(ctx.MkBV(sizeof(System.Single), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Double") { stack.Push(ctx.MkBV(sizeof(System.Double), 32)); return; } else if ((instr.Operand as TypeRef).FullName == "System.Guid") { stack.Push(ctx.MkBV(0x10, 32)); return; } } stack.PushUnknown(); }
private void Translate_Ldsfld(CflowStack stack, Instruction instr) { stack.Push(instr.Operand as IField); }