Ejemplo n.º 1
0
        public T[] ToArray()
        {
            T[] vs = new T[Length];
            VirtualProtect(_lpaddr, _dwsize, PAGE_READWRITE, out _);

            fixed(T *ptr = vs)
            NativeClass.Internal_memcpyff((byte *)_lpaddr, 0, (byte *)ptr, 0, (uint)_dwsize);

            VirtualProtect(_lpaddr, _dwsize, PAGE_NOACCESS, out _);
            return(vs);
        }
Ejemplo n.º 2
0
 public void SetBlock(int offset, byte[] datas)
 {
     if (datas == null)
     {
         throw new ArgumentNullException();
     }
     if (offset + datas.Length > Size)
     {
         throw new ArgumentOutOfRangeException();
         fixed(byte *ptr = datas)
         NativeClass.Internal_memcpyff(ptr, 0, this[offset], 0, (uint)datas.Length);
 }
 public void WriteBytes(int idx, byte[] bytes)
 {
     if (bytes == null)
     {
         throw new ArgumentNullException(nameof(bytes));
     }
     if (idx < 0 || datas.Length <= idx + bytes.Length)
     {
         throw new ArgumentOutOfRangeException(nameof(idx));
         fixed(byte *ptr = bytes)
         fixed(byte *ptr2 = datas)
         NativeClass.Internal_memcpyff(ptr, 0, ptr2, (uint)idx, (uint)bytes.Length);
 }
        public byte[] ReadBytes(int idx, int count)
        {
            if (count < 0 || idx < 0 || datas.Length <= idx + count)
            {
                throw new ArgumentOutOfRangeException();
            }
            byte[] nres = new byte[count];

            fixed(byte *ptr = datas)
            fixed(byte *dst = nres)
            NativeClass.Internal_memcpyff(ptr, 0U, dst, (uint)idx, (uint)count);

            return(nres);
        }
Ejemplo n.º 5
0
        public byte[] ReadBlock(int offset, int count)
        {
            if (offset < 0)
            {
                throw new InvalidOperationException();
            }
            if (offset + count > Size)
            {
                throw new ArgumentOutOfRangeException();
            }
            byte[] res = new byte[count];

            fixed(byte *ptr = res)
            NativeClass.Internal_memcpyff(this[offset], 0, ptr, 0, *(uint *)&count);

            return(res);
        }