Re: Reading until no more data is available.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Anton,

I tried that first and was advised to not do it (see the post titled: "Re:
How does GetFileSize() interact with a driver?" dated 8/21/06 8:48 PM.) It
didn't work either. Whether I complete the request with STATUS_SUCCESS,
STATUS_UNSUCCESSFUL, or STATUS_END_OF_FILE, the user mode process hangs.
Since I'm fairly new to Windows device driver development I have no idea
what is causing this.

Matt

<soviet_bloke@xxxxxxxxxxx> wrote in message
news:1156292615.224041.131000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi mate

.... I have a problem because when my driver completes a
IRP_MJ_READ request with STATUS_SUCCESS and Information == 0 the user
mode
call to ReadFile() never returns. Instead the process hangs and I
cannot
terminate it with Task Manager. (Reads that don't return 0 appear to
work
fine.)


I am afraid you make a logical mistake here - on one hand, you tell
the system that read operation was successfull, but, on the other hand,
you say that you haven't read any data. In other words, you tell the
system that you have successfully read 0 bytes, which just does not
make sense. As a result, the system gets so confused that your process
just hangs.

The moral of the story: return STATUS_END_OF_FILE, rather than
STATUS_SUCCESS

Anton Bassov




Matt Ervin wrote:
I forgot to mention that the user mode test application opens the driver
in
synchronous (non-overlapped) mode. How does this affect the behavior of
ReadFile()? I assumed that ReadFile() would return because the request
was
completed (with Information set to zero) and once that happens there's no
way for the driver to inform the I/O manager that new data has arrived
without another read request. Is this correct?

"Matt Ervin" <matt.ervin@xxxxxxxxxxxx> wrote in message
news:Ol7YdKhxGHA.1272@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I've given up on trying making my driver support Win32 file system
functions as several of you have advised. If it's that much trouble
then
it's not worth it for what I'm doing. I appreciate everyone's advice.

My objective is to allow a user mode process to read from my driver
until
ReadFile() either returns zero bytes or fails.

Is this the correct approach? Should I be using ReadFile()at all or
should I be using my own driver defined set of IOCTL 's? If ReadFile()
is
okay to use then I have a problem because when my driver completes a
IRP_MJ_READ request with STATUS_SUCCESS and Information == 0 the user
mode
call to ReadFile() never returns. Instead the process hangs and I
cannot
terminate it with Task Manager. (Reads that don't return 0 appear to
work
fine.)

Is there anything about WDF that may be causing the problem? Something
I
haven't configured properly or an event I'm not handling?

The user mode test application opens my driver with CreateFile(),
allocates a small buffer, and enters a read loop. The read loop calls
ReadFile() until it either fails by returning FALSE or returns zero for
the number of bytes read.

Matt





.



Relevant Pages

  • Re: Reading until no more data is available.
    ... Matt Ervin wrote: ... Since I'm fairly new to Windows device driver development I have no idea ... call to ReadFile() never returns. ... Instead the process hangs and I ...
    (microsoft.public.development.device.drivers)
  • Re: Reading until no more data is available.
    ... Matt Ervin wrote: ... Since I'm fairly new to Windows device driver development I have no idea ... call to ReadFile() never returns. ... Instead the process hangs and I ...
    (microsoft.public.development.device.drivers)
  • Re: Reading until no more data is available.
    ... Since I've had so much trouble getting my WDF driver to work properly I ... Win32 API's GetFileSize, SetFilePointer, and ReadFile() are all working ... Instead the process hangs and I ...
    (microsoft.public.development.device.drivers)
  • Re: Reading until no more data is available.
    ... call to ReadFile() never returns. ... Instead the process hangs and I cannot ... terminate it with Task Manager. ... I've given up on trying making my driver support Win32 file system ...
    (microsoft.public.development.device.drivers)
  • 2.6.0-test7: suspend to disk: no mouse or sound after suspend
    ... Using Gentoo with kernel 2.6.0-test7. ... Sound, no output after suspend. ... completing PM request, suspend ... registered new driver usbfs ...
    (Linux-Kernel)