Exemplo n.º 1
0
        /// <summary>
        /// Reads a unsigned integer from the memory block at the <paramref name="byteOffset"/>.
        /// </summary>
        /// <param name="byteOffset">An offset from the start of the memory block where the writing should start.
        /// Make sure the <paramref name="byteOffset"/> is properly aligned (usually 16-bits).</param>
        /// <returns>Returns the value.</returns>
        public uint ReadUintAt(int byteOffset)
        {
            Check.IfArgumentOutOfRange(byteOffset, 0, int.MaxValue, nameof(byteOffset));

            var size = MemoryUtil.SizeOf(typeof(uint));

            ValidateAccess(byteOffset, size);

            IntPtr location = IntPtr.Add(_memory, byteOffset);

            return(*(uint *)location.ToPointer());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads a unsigned integer from the memory block at the <paramref name="byteOffset"/>.
        /// </summary>
        /// <param name="byteOffset">An offset from the start of the memory block where the writing should start.
        /// Make sure the <paramref name="byteOffset"/> is properly aligned (usually 16-bits).</param>
        /// <returns>Returns the value.</returns>
        public uint ReadUintAt(int byteOffset)
        {
            Contract.Requires(byteOffset >= 0);

            var size = MemoryUtil.SizeOf(typeof(uint));

            this.ValidateAccess(byteOffset, size);

            IntPtr location = IntPtr.Add(this.memory, byteOffset);

            return(*(uint *)location.ToPointer());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes a <paramref name="value"/> to the specified <paramref name="byteOffset"/>.
        /// </summary>
        /// <param name="byteOffset">An offset from the start of the memory block where the writing should start.
        /// Make sure the <paramref name="byteOffset"/> is properly aligned (usually 16-bits).</param>
        /// <param name="value">The value to write.</param>
        public void WriteUintAt(int byteOffset, uint value)
        {
            Check.IfArgumentOutOfRange(byteOffset, 0, int.MaxValue, nameof(byteOffset));

            var size = MemoryUtil.SizeOf(typeof(uint));

            ValidateAccess(byteOffset, size);

            IntPtr location = IntPtr.Add(_memory, byteOffset);

            *(uint *)location.ToPointer() = value;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Writes a <paramref name="value"/> to the specified <paramref name="byteOffset"/>.
        /// </summary>
        /// <param name="byteOffset">An offset from the start of the memory block where the writing should start.
        /// Make sure the <paramref name="byteOffset"/> is properly aligned (usually 16-bits).</param>
        /// <param name="value">The value to write.</param>
        public void WriteUintAt(int byteOffset, uint value)
        {
            Contract.Requires(byteOffset >= 0);

            var size = MemoryUtil.SizeOf(typeof(uint));

            this.ValidateAccess(byteOffset, size);

            IntPtr location = IntPtr.Add(this.memory, byteOffset);

            *(uint *)location.ToPointer() = value;
        }