public unsafe void Write <T>(ulong byteOffset, T value) where T : struct { if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } uint sizeofT = Marshal.SizeOfType(typeof(T)); byte *ptr = (byte *)((IntPtr)(void *)this.handle + (IntPtr)byteOffset); this.SpaceCheck(ptr, (ulong)sizeofT); bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { this.DangerousAddRef(ref success); SafeBuffer.GenericStructureToPtr <T>(ref value, ptr, sizeofT); } finally { if (success) { this.DangerousRelease(); } } }
public unsafe void Write <T>(ulong byteOffset, T value) where T : struct { if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } uint num = Marshal.SizeOfType(typeof(T)); byte *ptr = (byte *)((void *)this.handle) + byteOffset; this.SpaceCheck(ptr, (ulong)num); bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref flag); SafeBuffer.GenericStructureToPtr <T>(ref value, ptr, num); } finally { if (flag) { base.DangerousRelease(); } } }
public void ReleasePointer() { if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } this.DangerousRelease(); }
public unsafe void WriteArray <T>(ulong byteOffset, T[] array, int index, int count) where T : struct { if (array == null) { throw new ArgumentNullException("array", Environment.GetResourceString("ArgumentNull_Buffer")); } if (index < 0) { throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (array.Length - index < count) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); } if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } uint sizeofT = Marshal.SizeOfType(typeof(T)); uint num = Marshal.AlignedSizeOf <T>(); byte *ptr = (byte *)((IntPtr)(void *)this.handle + (IntPtr)byteOffset); this.SpaceCheck(ptr, checked ((ulong)((long)num * (long)count))); bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { this.DangerousAddRef(ref success); for (int index1 = 0; index1 < count; ++index1) { SafeBuffer.GenericStructureToPtr <T>(ref array[index1 + index], ptr + (long)num * (long)index1, sizeofT); } } finally { if (success) { this.DangerousRelease(); } } }
public unsafe void ReadArray <T>(ulong byteOffset, T[] array, int index, int count) where T : struct { if (array == null) { throw new ArgumentNullException("array", Environment.GetResourceString("ArgumentNull_Buffer")); } if (index < 0) { throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (count < 0) { throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); } if (array.Length - index < count) { throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); } if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } uint sizeofT = Marshal.SizeOfType(typeof(T)); uint num = Marshal.AlignedSizeOf <T>(); byte *ptr = (byte *)((void *)this.handle) + byteOffset; this.SpaceCheck(ptr, checked (unchecked ((ulong)num) * (ulong)(unchecked ((long)count)))); bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref flag); for (int i = 0; i < count; i++) { SafeBuffer.GenericPtrToStructure <T>(ptr + (ulong)num * (ulong)((long)i), out array[i + index], sizeofT); } } finally { if (flag) { base.DangerousRelease(); } } }
public unsafe void AcquirePointer(ref byte *pointer) { if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } pointer = (byte *)null; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { bool success = false; this.DangerousAddRef(ref success); pointer = (byte *)(void *)this.handle; } }
public unsafe void AcquirePointer(ref byte *pointer) { if (this._numBytes == SafeBuffer.Uninitialized) { throw SafeBuffer.NotInitialized(); } pointer = (IntPtr)((UIntPtr)0); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { bool flag = false; base.DangerousAddRef(ref flag); pointer = (void *)this.handle; } }