Can NtWriteFile() produce a short write?

282 Views Asked by At

Consider this snippet (handle was opened with FILE_SYNCHRONOUS_IO_NONALERT flag):

IO_STATUS_BLOCK io;
NTSTATUS r = NtWriteFile(h, NULL, NULL, NULL, &io, data, data_len, &pos, NULL);

if NT_SUCCESS(r)
    assert(io.Information == data_len);      // can we succeed with short write?
else
    // is IO_STATUS_BLOCK filled?
    assert(io.Information == 0);             // can we fail and yet write some data?

Is it possible for NtWriteFile() to succeed and yet write less than requested?

Is it possible for NtWriteFile() to fail and yet write some of data? If yes -- how to determine amount of data written?

0

There are 0 best solutions below