in Win32/ComStreamProxy.cs [38:53]
public unsafe uint Read(IntPtr buffer, uint numberOfBytesToRead)
{
uint totalRead = 0;
while (numberOfBytesToRead > 0)
{
uint countRead = (uint)Math.Min(numberOfBytesToRead, tempBuffer.Length);
uint count = (uint)sourceStream.Read(tempBuffer, 0, (int)countRead);
if (count == 0)
return totalRead;
MemoryHelpers.Write(new IntPtr(totalRead + (byte*)buffer), new Span<byte>(tempBuffer), (int)count);
numberOfBytesToRead -= count;
totalRead += count;
}
return totalRead;
}