public override long Seek(long offset, SeekOrigin origin) { _Validate(); IntPtr plibNewPosition = IntPtr.Zero; try { plibNewPosition = Marshal.AllocHGlobal(sizeof(Int64)); _source.Seek(offset, (int)origin, plibNewPosition); return(Marshal.ReadInt64(plibNewPosition)); } finally { Utility.SafeFreeHGlobal(ref plibNewPosition); } }
public override long Seek(long offset, SeekOrigin origin) { long num; this._Validate(); IntPtr zero = IntPtr.Zero; try { zero = Marshal.AllocHGlobal(8); this._source.Seek(offset, (int)origin, zero); num = Marshal.ReadInt64(zero); } finally { Utility.SafeFreeHGlobal(ref zero); } return(num); }
public override int Read(byte[] buffer, int offset, int count) { int num; this._Validate(); IntPtr zero = IntPtr.Zero; try { zero = Marshal.AllocHGlobal(4); byte[] numArray = new byte[count]; this._source.Read(numArray, count, zero); Array.Copy(numArray, 0, buffer, offset, Marshal.ReadInt32(zero)); num = Marshal.ReadInt32(zero); } finally { Utility.SafeFreeHGlobal(ref zero); } return(num); }
public override int Read(byte[] buffer, int offset, int count) { _Validate(); IntPtr pcbRead = IntPtr.Zero; try { pcbRead = Marshal.AllocHGlobal(sizeof(Int32)); // PERFORMANCE NOTE: This buffer doesn't need to be allocated if offset == 0 var tempBuffer = new byte[count]; _source.Read(tempBuffer, count, pcbRead); Array.Copy(tempBuffer, 0, buffer, offset, Marshal.ReadInt32(pcbRead)); return(Marshal.ReadInt32(pcbRead)); } finally { Utility.SafeFreeHGlobal(ref pcbRead); } }