/// <summary>
        /// Reads a sequence of bytes from the current stream and advances the position
        /// within the stream by the number of bytes read.
        /// </summary>
        /// <param name="buffer">An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.</param>
        /// <param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream.</param>
        /// <param name="count">The maximum number of bytes to be read from the current stream.</param>
        /// <returns>The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.</returns>
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (TheIStream != null)
            {
                if (offset != 0)
                {
                    throw new NotSupportedException("Only a zero offset is supported.");
                }

                var bytesRead = 0;
                var br        = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)));
                Marshal.WriteInt32(br, 0);

                // Include try catch for c++ eh exceptions. are they the same as comexceptions?
                TheIStream.Read(buffer, count, br);
                bytesRead = Marshal.ReadInt32(br);

                Marshal.FreeHGlobal(br);

                return(bytesRead);
            }
            else
            {
                return(TheStream.Read(buffer, offset, count));
            }
        }
 /// <summary>
 /// Reads a specified number of bytes from the stream object
 /// into memory starting at the current seek pointer.
 /// </summary>
 /// <param name="pv">The buffer which the stream data is read into.</param>
 /// <param name="cb">The number of bytes of data to read from the stream object.</param>
 /// <param name="pcbRead">
 /// A pointer to a ULONG variable that receives the actual number of bytes read from the stream object.
 /// It can be set to IntPtr.Zero.
 /// In this case, this method does not return the number of bytes read.
 /// </param>
 /// <typeparam name="pcbRead">Native UInt32</typeparam>
 /// <returns>
 /// The actual number of bytes read (<paramref name="pcbRead"/>) from the source.
 /// </returns>
 ///<exception cref="ArgumentException">The sum of offset and count is larger than the buffer length.</exception>
 ///<exception cref="ArgumentNullException">buffer is a null reference.</exception>
 ///<exception cref="ArgumentOutOfRangeException">offset or count is negative.</exception>
 ///<exception cref="IOException">An I/O error occurs.</exception>
 ///<exception cref="NotSupportedException">The stream does not support reading.</exception>
 ///<exception cref="ObjectDisposedException">Methods were called after the stream was closed.</exception>
 public void Read(byte[] pv, int cb, IntPtr pcbRead)
 {
     if (TheStream != null)
     {
         if (pcbRead == IntPtr.Zero)
         {
             // User isn't interested in how many bytes were read
             TheStream.Read(pv, 0, cb);
         }
         else
         {
             Marshal.WriteInt32(pcbRead, TheStream.Read(pv, 0, cb));
         }
     }
     else
     {
         TheIStream.Read(pv, cb, pcbRead);
     }
 }