title: Can Windows ReadFile returns success without reading everything you asked for?
body: <p>In the unix world, it is a well known gotchya that reading from a file descriptor may succeed and not yield you all the data you asked for. You have to specifically check.</p>
  
  <p>I'm wondering if the same is true in windows.
  We're doing synchronous reads, nothing async going on, but we're using the overlapped structure so we can specify and offset and length to read.</p>
  
  <p>This...</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365467(v=vs.85).aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/windows/desktop/aa365467(v=vs.85).aspx</a></p>
  
  <p>says:</p>
  
  <p>The ReadFile function returns when one of the following conditions occur:
      The number of bytes requested is read.</p>
  
  <p>and it also says:</p>
  
  <p>If lpOverlapped is not NULL, the read operation starts at the offset that is specified in the OVERLAPPED structure and ReadFile does not return until the read operation is complete. The system updates the OVERLAPPED offset before ReadFile returns.</p>
  
  <p>And it finally says:</p>
  
  <p>The lpNumberOfBytesRead parameter should be set to NULL. Use the GetOverlappedResult function to get the actual number of bytes read.</p>
  
  <p>But what's actually happening is we're getting a successful return but the number of bytes read (from calling GetOverlappedResult) is less than what we asked for.</p>
  
  <p>Nowhere in this documentation does it even imply that could possibly happen, yet it is surely happening.</p>
  
  <p>What am I doing wrong?</p>