Example #1
0
        /// <summary>
        /// Copies data from source to destination.
        /// </summary>
        /// <param name="destination">The destination memory pointer.</param>
        /// <param name="source">The source memory pointer.</param>
        /// <param name="length">The length of data.</param>
        public static void Copy(IntPtr destination, IntPtr source, ulong length)
        {
            var is32 = IntPtr.Size == 4;

            if (is32)
            {
                // Note: if this is run, length should always be in range of a uint
                // (it should be impossible to allocate a buffer bigger than that range
                // on a 32-bit system)
                NativeMethods32.RtlCopyMemory(destination, source, (uint)length);
            }
            else
            {
                NativeMethods64.RtlCopyMemory(destination, source, (ulong)length);
            }
        }