Esempio n. 1
0
        public int ReadMemory(ulong address, uint size, out byte[] buf)
        {
            buf = new byte[size];

            _debugDataSpace.ReadVirtual(address, buf, (uint)buf.Length, out uint readBytes);
            return((int)readBytes);
        }
Esempio n. 2
0
        internal int ReadVirtual(ulong address, byte[] buffer, int bytesRequested, out int bytesRead)
        {
            SetClientInstance();
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (buffer.Length < bytesRequested)
            {
                bytesRequested = buffer.Length;
            }

            int res = _spaces.ReadVirtual(address, buffer, (uint)bytesRequested, out uint read);

            bytesRead = (int)read;
            return(res);
        }
Esempio n. 3
0
        private byte[] ReadValue(_DEBUG_TYPED_DATA typedData)
        {
            var valueBuffer = new byte[typedData.Size];
            uint bytesRead;
            _spaces.ReadVirtual(typedData.Offset, valueBuffer, typedData.Size, out bytesRead);
            var valueTrimmed = new byte[bytesRead];
            Array.Copy(valueBuffer, valueTrimmed, bytesRead);

            return valueTrimmed;
        }
Esempio n. 4
0
        public byte[] ReadValue(ulong offset, uint size)
        {
            var  buffer = new byte[size];
            uint actualBytes;
            var  hr = _spaces.ReadVirtual(offset, buffer, size, out actualBytes);

            if (hr != HResult.Ok)
            {
                return(new byte[0]);
            }

            return(buffer);
        }
Esempio n. 5
0
        /// <summary>
        ///     Reads virtual memory from the trace file
        /// </summary>
        /// <param name="low">The low memory address of the range</param>
        /// <param name="high">The high memory address of the range</param>
        /// <param name="dataSpaces">The data spaces COM interface allowing access to the memory</param>
        /// <returns>System.Byte[].</returns>
        /// <exception cref="ArgumentOutOfRangeException">When low >= high</exception>
        /// <exception cref="ApplicationException">If the debugging engine cannot perform the request</exception>
        public byte[] ReadMemory(ulong low, ulong high, IDebugDataSpaces dataSpaces)
        {
            if (low >= high)
            {
                throw new ArgumentOutOfRangeException($"Low must be less than high, but {low} >= {high}");
            }
            var length = high - low;
            var buffer = new byte[length];
            var hr     = dataSpaces.ReadVirtual(low, buffer, buffer.Length.ToUInt(), out var bytesRead);

            if (hr != 0)
            {
                throw new ApplicationException($"Unable to read virtual memory at {low:X16}, error code: {hr}");
            }

            return(buffer.Take(bytesRead.ToInt()).ToArray()); // todo: bounds checking
        }