Calling WriteFile with both lpOverlapped and lpNumberOfBytesWritten set to null is invalid combination on Windows 7
[tfs-changeset: 1472978]
m_hasher.HashMore(pv, cb);
+ // We are calling with lpOverlapped == NULL so pcbWritten has to be present
+ // to prevent crashes in Win7 and below.
+ _ASSERTE(pcbWritten);
+
if (!::WriteFile(m_hFile, pv, cb, pcbWritten, NULL))
{
hr = HRESULT_FROM_GetLastError();
while (dwSize >= WRITE_BUFFER_SIZE)
{
+ ULONG cbWritten;
cbAvailable = min(WRITE_BUFFER_SIZE, dwSize);
- IfFailThrow(m_pStream->Write(m_pBuffer, cbAvailable, NULL));
+ IfFailThrow(m_pStream->Write(m_pBuffer, cbAvailable, &cbWritten));
+ _ASSERTE(cbWritten == cbAvailable);
+
dwSize -= cbAvailable;
}