Hi, I had the same issue reading from a sata disk, even passing wait = FALSE to GetOverlappedResult().
Then I found this statement which made me think:
"If the hEvent member of the OVERLAPPED structure is NULL, the system uses the state of the hFile handle to signal when the operation has been completed."
(ref.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms683209%28v=vs.85%29.aspx)
"...the system uses the state of the hFile handle..." appears to be false under Win7,
The issue seems to be fixed by setting hEvent with an event (manual reset) created on purpose:
{
OVERLAPPED overlapped;
{
DWORD i = 1 + sizeof overlapped;
do {
((BYTE*)&overlapped)[--i] = 0;
} while (i);
}
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
...
ReadFile(..., &overlapped);
...
GetOverlappedResult(..., &overlapped, ...);
}
Note:
if file is created with FILE_FLAG_NO_BUFFERING, nNumberOfBytesToRead in ReadFile() MUST be a multiple of sys mem page (i.e. 4KB)