WriteFile API returns TRUE and succeeds, but data is not written to the SAN Drive. In such a scenario, the lpNumberOfBytesWritten parameter returns Zero, but WriteFile indicates that it has succeeded in writing the data.

Under what conditions WriteFile API might return TRUE, but lpNumberOfBytesWritten  returns Zero? Is this an expected behavior?

Under no conditions should a synchronous IO request with WriteFile to a file system complete successfully and the data not be written to the disk. This problem is very likely because of a hardware failure or a problem with the device driver of the concerned device to where we are writing to. We are at the mercy of the hardware.

When this condition occurs, the workaround is to retry the write operation until the condition that WriteFile returns TRUE and lpNumberOfBytesWritten is equal to the number of bytes which you are writing. If the problem keeps on persisting, you may need to contact the appropriate vendor for the hardware.

Balajee P
Windows SDK