Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Call"/> class.
 /// </summary>
 /// <param name="target">The target <see cref="RelativeOffset"/>.</param>
 public Call(RelativeOffset target)
     : this((Operand)target)
 {
     #region Contract
     Contract.Requires<ArgumentNullException>(target != null);
     #endregion
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JmpNear"/> class.
 /// </summary>
 /// <param name="target">The relative offset to the jump target.</param>
 public JmpNear(RelativeOffset target)
     : this((Operand)target)
 {
     #region Contract
     Contract.Requires <ArgumentNullException>(target != null);
     #endregion
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Jcxz"/> class.
 /// </summary>
 /// <param name="target">The target.</param>
 public Jcxz(RelativeOffset target)
     : this(target, DataSize.None)
 {
     #region Contract
     Contract.Requires<ArgumentNullException>(target != null);
     #endregion
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Jcxz"/> class.
 /// </summary>
 /// <param name="target">The target.</param>
 public Jcxz(RelativeOffset target)
     : this(target, DataSize.None)
 {
     #region Contract
     Contract.Requires <ArgumentNullException>(target != null);
     #endregion
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Loopz"/> class.
        /// </summary>
        /// <param name="target">The loop target.</param>
        public Loopz(RelativeOffset target)
        {
            #region Contract
            Contract.Requires<ArgumentNullException>(target != null);
            #endregion

            this.target = target;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Loopz"/> class.
        /// </summary>
        /// <param name="target">The loop target.</param>
        public Loopz(RelativeOffset target)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(target != null);
            #endregion

            this.target = target;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="J"/> class.
        /// </summary>
        /// <param name="offset">The jump offset.</param>
        /// <param name="condition">The condition on which this instruction executes.</param>
        public J(RelativeOffset offset, InstructionCondition condition)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(offset != null);
            Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(InstructionCondition), condition));
            Contract.Requires <ArgumentException>(condition != InstructionCondition.None);
            #endregion

            this.offset = offset;

            this.condition = condition;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Jcxz"/> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="operandSize">The operand size.</param>
        public Jcxz(RelativeOffset target, DataSize operandSize)
        {
            #region Contract
            Contract.Requires<ArgumentNullException>(target != null);
            Contract.Requires<InvalidEnumArgumentException>(Enum.IsDefined(typeof(DataSize), operandSize));
            Contract.Requires<ArgumentException>(operandSize == DataSize.None || operandSize == DataSize.Bit16 ||
                operandSize == DataSize.Bit32 || operandSize == DataSize.Bit64,
                "The size must be either None, 16, 32 or 64-bits.");
            #endregion

            this.target = target;
            this.OperandSize = operandSize;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Jcxz"/> class.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="operandSize">The operand size.</param>
        public Jcxz(RelativeOffset target, DataSize operandSize)
        {
            #region Contract
            Contract.Requires <ArgumentNullException>(target != null);
            Contract.Requires <InvalidEnumArgumentException>(Enum.IsDefined(typeof(DataSize), operandSize));
            Contract.Requires <ArgumentException>(operandSize == DataSize.None || operandSize == DataSize.Bit16 ||
                                                  operandSize == DataSize.Bit32 || operandSize == DataSize.Bit64,
                                                  "The size must be either None, 16, 32 or 64-bits.");
            #endregion

            this.target      = target;
            this.OperandSize = operandSize;
        }
        private GameObject CreateWeaponTemplate()
        {
            var copy = WeaponTemplate.CreateInstance();

            var weaponBehavior = copy.GetComponent <WeaponBehavior>();

            MuzzleOffset = weaponBehavior.MuzzleOffset;
            HeldPosition = weaponBehavior.HeldPosition;

            UnityExtensions.Destroy(weaponBehavior);
            copy.AddComponent <ProjectileWeaponBehavior>();
            return(copy);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Writes an effective address operand.
        /// </summary>
        /// <returns>The number of characters written.</returns>
        private int WriteOperand(RelativeOffset operand, bool writeSize)
        {
            #region Contract
            if (operand == null)
            {
                return(0);
            }
            #endregion
            int length = 0;

            if (writeSize)
            {
                switch (operand.RequestedSize)
                {
                case DataSize.Bit8:
                    Writer.Write("byte ");
                    length += 5;
                    break;

                case DataSize.Bit16:
                    Writer.Write("word ");
                    length += 5;
                    break;

                case DataSize.Bit32:
                    Writer.Write("dword ");
                    length += 6;
                    break;

                case DataSize.Bit64:
                    Writer.Write("qword ");
                    length += 6;
                    break;

                case DataSize.None:
                    break;

                default:
                    throw new LanguageException(ExceptionStrings.UnknownRequestedSize);
                }
            }

            length += WriteExpression(operand.Expression);
            return(length);
        }
 /// <summary>
 /// Creates a new CALL (Near Procedure Call) instruction.
 /// </summary>
 /// <param name="displacement">A relative offset.</param>
 /// <returns>The created instruction.</returns>
 public static X86Instruction Call(RelativeOffset displacement)
 {
     return X86Opcode.Call.CreateInstruction(displacement);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="J"/> class.
        /// </summary>
        /// <param name="offset">The jump offset.</param>
        /// <param name="condition">The condition on which this instruction executes.</param>
        public J(RelativeOffset offset, InstructionCondition condition)
        {
            #region Contract
            Contract.Requires<ArgumentNullException>(offset != null);
            Contract.Requires<InvalidEnumArgumentException>(Enum.IsDefined(typeof(InstructionCondition), condition));
            Contract.Requires<ArgumentException>(condition != InstructionCondition.None);
            #endregion

            this.offset = offset;

            this.condition = condition;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Writes an effective address operand.
        /// </summary>
        /// <returns>The number of characters written.</returns>
        private int WriteOperand(RelativeOffset operand, bool writeSize)
        {
            #region Contract
            if (operand == null) return 0;
            #endregion
            int length = 0;

            if (writeSize)
            {
                switch (operand.RequestedSize)
                {
                    case DataSize.Bit8:
                        Writer.Write("byte ");
                        length += 5;
                        break;
                    case DataSize.Bit16:
                        Writer.Write("word ");
                        length += 5;
                        break;
                    case DataSize.Bit32:
                        Writer.Write("dword ");
                        length += 6;
                        break;
                    case DataSize.Bit64:
                        Writer.Write("qword ");
                        length += 6;
                        break;
                    case DataSize.None:
                        break;
                    default:
                        throw new LanguageException(ExceptionStrings.UnknownRequestedSize);
                }
            }

            length += WriteExpression(operand.Expression);
            return length;
        }
        public bool Match(Operand operand)
        {
            switch (operandType)
            {
            case OperandType.FixedRegister:
            {
                RegisterOperand castoperand = operand as RegisterOperand;
                if (castoperand != null)
                {
                    return(castoperand.Register == fixedRegister);
                }
                return(false);
            }

            case OperandType.Immediate:
            {
                Immediate castoperand = operand as Immediate;
                if (castoperand != null)
                {
                    return(castoperand.Size == DataSize.None || castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.RegisterOperand:
            {
                RegisterOperand castoperand = operand as RegisterOperand;
                if (castoperand != null)
                {
                    return(/*castoperand.Size == size &&*/ registerType.HasFlag(castoperand.Register.GetRegisterType()));
                }
                return(false);
            }

            case OperandType.RegisterOrMemoryOperand:
            {
                RegisterOperand  castoperand1 = operand as RegisterOperand;
                EffectiveAddress castoperand2 = operand as EffectiveAddress;
                if (castoperand1 != null)
                {
                    return(/*castoperand1.Size == size &&*/ registerType.HasFlag(castoperand1.Register.GetRegisterType()));
                }
                if (castoperand2 != null)
                {
                    return(/*castoperand2.Size == size*/ registerType.HasFlag(castoperand2.Size));
                }
                return(false);
            }

            case OperandType.MemoryOperand:
            {
                EffectiveAddress castoperand = operand as EffectiveAddress;
                if (castoperand != null)
                {
                    return(castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.MemoryOffset:
                // TODO: Implement!
                return(false);

            case OperandType.FarPointer:
            {
                FarPointer castoperand = operand as FarPointer;
                if (castoperand != null)
                {
                    return(castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.RelativeOffset:
            {
                // A relative offset matches when the Size of the operand
                // equals DataSize.None. The Size will be set when the
                // operand has been preprocessed, after which it is tested
                // again.
                RelativeOffset castoperand = operand as RelativeOffset;
                if (castoperand != null)
                {
                    return(castoperand.Size == DataSize.None || castoperand.Size == size);
                }
                return(false);
            }

            case OperandType.None:
                return(operand == null);

            default:
                throw new NotSupportedException();
            }
        }
 /// <summary>
 /// Creates a new CALL (Near Procedure Call) instruction.
 /// </summary>
 /// <param name="displacement">A relative offset.</param>
 /// <returns>The created instruction.</returns>
 public static X86Instruction Call(RelativeOffset displacement)
 {
     return(X86Opcode.Call.CreateInstruction(displacement));
 }