Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodePointer{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public CodePointer(Variable variable)
            : base(variable)
        {
            if (!GetCodeType().IsPointer)
            {
                throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name);
            }

            element = UserMember.Create(() => variable.DereferencePointer().CastAs <T>());
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodePointer{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        public CodePointer(Variable variable)
            : base(variable)
        {
            if (!GetCodeType().IsPointer)
            {
                throw new WrongCodeTypeException(variable, nameof(variable), "pointer");
            }

            element = UserMember.Create(() => variable.DereferencePointer().CastAs <T>());
        }
Beispiel #3
0
        /// <summary>
        /// Reads the pointer and casts it to the type.
        /// </summary>
        /// <typeparam name="T">Type to be casted to</typeparam>
        /// <param name="thisClass">Variable that contains UserMember of the this class.</param>
        /// <param name="classFieldName">Name of the class field.</param>
        /// <param name="buffer">The memory buffer.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pointerSize">Size of the pointer.</param>
        public static T ReadPointer <T>(UserMember <Variable> thisClass, string classFieldName, MemoryBuffer buffer, int offset, int pointerSize)
        {
            ulong pointer = ReadPointer(buffer, offset, pointerSize);

            if (pointer == 0)
            {
                return(default(T));
            }

            return(Variable.CreatePointerNoCast(thisClass.Value.GetCodeType().GetClassFieldType(classFieldName), pointer, classFieldName).CastAs <T>());
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenericsElementCaster{T}"/> class.
 /// </summary>
 /// <param name="thisClass">The thisClass variable in generated UserType.</param>
 /// <param name="argumentNumber">The argument number in original user type.</param>
 public GenericsElementCaster(UserMember <Variable> thisClass, int argumentNumber)
     : this(thisClass.Value, argumentNumber)
 {
 }