Esempio n. 1
0
        /// <summary>
        /// Reads the string from CodePointer with length specified as number of bytes.
        /// </summary>
        /// <param name="codePointer">The code pointer.</param>
        /// <param name="length">The length in bytes.</param>
        /// <returns>Read string from CodePointer.</returns>
        public static string ReadStringByteLength(this CodePointer <char> codePointer, uint length)
        {
            if (length > int.MaxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            return(ReadStringByteLength(codePointer, (int)length));
        }
Esempio n. 2
0
        /// <summary>
        /// Reads the string from CodePointer with length specified as number of bytes.
        /// </summary>
        /// <param name="codePointer">The code pointer.</param>
        /// <param name="length">The length in bytes. If length is -1, string is null terminated</param>
        /// <returns>Read string from CodePointer.</returns>
        public static string ReadStringByteLength(this CodePointer <char> codePointer, int length = -1)
        {
            int charSize = (int)codePointer.GetCodeType().ElementType.Size;

            if (length % charSize != 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            return(UserType.ReadString(codePointer.GetCodeType().Module.Process, codePointer.GetPointerAddress(), charSize, length / charSize));
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes this instance of the <see cref="CodeArray{T}"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <param name="length">The array length.</param>
        private void Initialize(Variable variable, int length)
        {
            variable = CodePointer <T> .CastIfNecessary(variable);

            this.variable      = variable;
            Length             = length;
            preCalculatedArray = ReadArray();
            if (preCalculatedArray == null && variable.GetCodeType().ElementType.IsPointer&& length > 0)
            {
                var process     = variable.GetCodeType().Module.Process;
                var pointerSize = process.GetPointerSize();
                var buffer      = Debugger.ReadMemory(process, variable.GetPointerAddress(), (uint)Length * pointerSize);

                addressesArray = UserType.ReadPointerArray(buffer, 0, Length, pointerSize);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Reads the string from CodePointer.
 /// </summary>
 /// <param name="codePointer">The code pointer.</param>
 /// <param name="length">The length in characters. If length is -1, string is null terminated</param>
 /// <returns>Read string from CodePointer.</returns>
 public static string ReadString(this CodePointer <char> codePointer, int length = -1)
 {
     return(UserType.ReadString(codePointer.GetCodeType().Module.Process, codePointer.GetPointerAddress(), (int)codePointer.GetCodeType().ElementType.Size, length));
 }