Beispiel #1
0
        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
        {
            Operand result = context.Result;

            RegisterOperand tmp = new RegisterOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EDX);
            MemoryOperand operand = new MemoryOperand(context.Operand1.Type, GeneralPurposeRegister.EDX, new System.IntPtr(0));

            context.SetInstruction(X86.Mov, tmp, context.Operand1);
            context.AppendInstruction(X86.Mov, result, operand);
        }
Beispiel #2
0
        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
        {
            Operand dest = context.Operand1;
            Operand value = context.Operand2;

            RegisterOperand edx = new RegisterOperand(dest.Type, GeneralPurposeRegister.EDX);
            RegisterOperand eax = new RegisterOperand(value.Type, GeneralPurposeRegister.EAX);
            MemoryOperand memory = new MemoryOperand(new SigType(context.InvokeTarget.Signature.Parameters[1].Type), GeneralPurposeRegister.EDX, new IntPtr(0));

            context.SetInstruction(X86.Mov, edx, dest);
            context.AppendInstruction(X86.Mov, eax, value);
            context.AppendInstruction(X86.Mov, memory, eax);
        }
Beispiel #3
0
        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
        {
            MemoryOperand operand = new MemoryOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EAX, new System.IntPtr(0));
            context.SetInstruction(X86.Mov, new RegisterOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EAX), context.Operand1);
            context.AppendInstruction(X86.Lgdt, null, operand);

            RegisterOperand ax = new RegisterOperand(BuiltInSigType.Int16, GeneralPurposeRegister.EAX);
            RegisterOperand ds = new RegisterOperand(BuiltInSigType.Int16, SegmentRegister.DS);
            RegisterOperand es = new RegisterOperand(BuiltInSigType.Int16, SegmentRegister.ES);
            RegisterOperand fs = new RegisterOperand(BuiltInSigType.Int16, SegmentRegister.FS);
            RegisterOperand gs = new RegisterOperand(BuiltInSigType.Int16, SegmentRegister.GS);
            RegisterOperand ss = new RegisterOperand(BuiltInSigType.Int16, SegmentRegister.SS);

            context.AppendInstruction(X86.Mov, ax, new ConstantOperand(BuiltInSigType.Int32, (int)0x00000010));
            context.AppendInstruction(X86.Mov, ds, ax);
            context.AppendInstruction(X86.Mov, es, ax);
            context.AppendInstruction(X86.Mov, fs, ax);
            context.AppendInstruction(X86.Mov, gs, ax);
            context.AppendInstruction(X86.Mov, ss, ax);
            context.AppendInstruction(X86.FarJmp);
        }
        private static void SplitFromNonConstantOperand(Operand operand, out Operand operandLow, out Operand operandHigh)
        {
            SigType HighType = (operand.Type.Type == CilElementType.I8) ? BuiltInSigType.Int32 : BuiltInSigType.UInt32;

            // No, could be a member or a plain memory operand
            MemberOperand memberOperand = operand as MemberOperand;
            if (memberOperand != null)
            {
                // We need to keep the member reference, otherwise the linker can't fixup
                // the member address.
                operandLow = new MemberOperand(memberOperand.Member, BuiltInSigType.UInt32, memberOperand.Offset);
                operandHigh = new MemberOperand(memberOperand.Member, HighType, new IntPtr(memberOperand.Offset.ToInt64() + 4));
            }
            else
            {
                // Plain memory, we can handle it here
                MemoryOperand memoryOperand = (MemoryOperand)operand;
                operandLow = new MemoryOperand(BuiltInSigType.UInt32, memoryOperand.Base, memoryOperand.Offset);
                operandHigh = new MemoryOperand(HighType, memoryOperand.Base, new IntPtr(memoryOperand.Offset.ToInt64() + 4));
            }
        }
Beispiel #5
0
 /// <summary>
 /// Replaces the intrinsic call site
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="typeSystem">The type system.</param>
 void IIntrinsicMethod.ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem, IList<RuntimeParameter> parameters)
 {
     MemoryOperand operand = new MemoryOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EAX, new System.IntPtr(0));
     context.SetInstruction(X86.Mov, new RegisterOperand(BuiltInSigType.Ptr, GeneralPurposeRegister.EAX), context.Operand1);
     context.AppendInstruction(X86.Lidt, null, operand);
 }