There is no concept of EOF; for file systems, a successful read of 0 bytes
means EOF.
Most devices have no concept of EOF. EOF means “this device will never,
ever again return data for this handle”.
You need to show us a better spec of the nature of your device.
If you have a buffer that has 60 bytes in it, and there are no more bytes,
then *independent of the buffer size* you return a successful read of 60
bytes. Now, if you know there cannot ever be any more bytes, and the user
does another ReadFile, you return successfully with 0 bytes. This is at
least consistent with the file system behavior.
ERROR_HANDLE_EOF is an error code passed to an asynchronous callback handler
(ReadFileEx) when there is an end of file.
It is odd to have STATUS_CANCELLED returned for any reason other than the
IRP being cancelled, and that is done in the cancellation routine (and WDF
drivers use cancel-safe queues, and that’s a deeper question)
I have no idea what the code below is supposed to do.
joe
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, March 01, 2011 3:28 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] End-of-File and driver behavior
What returns end of file?
All driver code that i read so far, reads irp’s relevant locations and
starts device, returns STATUS_CANCELLED or STATUS_SUCCESS.
But there is an error value in user-mode: ERROR_HANDLE_EOF:
if (!bResult)
{
switch (dwError)
{
case ERROR_HANDLE_EOF:
{
printf("\nReadFile returned FALSE and EOF condition,
async EOF not triggered.\n");
break;
}
case ERROR_IO_PENDING:
{
BOOL bPending=TRUE;
// Loop until the I/O is complete, that is: the
overlapped
// event is signaled.
while( bPending )
If user wants to read 100 bytes, but there are only 60 bytes in our device.
Does I|O Man. or driver return eof?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
–
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.