Virtual Disk Drive

We are developing a virtual disk driver, that sometimes requires user interaction (eg changing of a DVD or reconnecting a network connection) to successfully complete an IO request (READ).

We have a framework which is able to pass this status from the driver level code into an normal Windows application, but we have problems opening a Window (via MessageBox) in that status (ie while the READ is pending). The MessageBox call simply hangs and simply does not display anything.

Any ideas?

Ruediger Jungbeck
RSJ Software GmbH

How do yo do all that??? Are you waiting for user response in context of a thread that initiates IRP_MJ_READ request, i.e. right in Dispatch routine??? If this is the case, I am not surprized that the system gets “confused”, and behaves the way you have described - any design that requires waiting in Dispatch routine is flawed in itself…

What you should do here is to signal the event the user app waits on (or complete outstanding IRP if your app-driver communication relies upon the inverted call), mark the target IRP_MJ_READ request as pending one, and return STATUS_PENDING for it. Your app will do what it has to, and then submit some custom IOCTL to your driver (your driver should use some proprietary DEVICE_OBJECT that is not on any stack for communicating with the app). In response to this IOCTL
your driver will proceed to processing IRP_MJ_READ request that it has earlier marked pending…

If you do it this way, there should be no problem whatsoever…

Anton Bassov

We do basicly what you describe:

  1. Queue the request in the Dispatch routine
  2. Mark the Irp as pending (and return STATUS_PENDING)
  3. Have a worker thread (system thread) complete an waiting GUI application IOCtl
  4. Make the worker thread wait (KeWaitForSingleObject)
  5. Have the GUI application display the window
  6. Use another IOCTL (after the MessageBox call completes) to complete the waiting worker thread
  7. Complete the waiting READ IRP from the worker thread

> 4) Make the worker thread wait (KeWaitForSingleObject)

I think this is the only reason for the weird behaviour that you have described…

Anton Bassov

Break into the machine with WinDbg and post the call stack of the hanging
thread here.

wrote news:xxxxx@ntdev…
> We are developing a virtual disk driver, that sometimes requires user
> interaction (eg changing of a DVD or reconnecting a network connection) to
> successfully complete an IO request (READ).
>
> We have a framework which is able to pass this status from the driver
> level code into an normal Windows application, but we have problems
> opening a Window (via MessageBox) in that status (ie while the READ is
> pending). The MessageBox call simply hangs and simply does not display
> anything.
>
> Any ideas?
>
> Ruediger Jungbeck
> RSJ Software GmbH
>
>

Thank you for your help.

The problem was, that we blocked the applications main thread in the READ request, so the MessageBox function did not complete, because the message pump in the main thread was not working.

After we put the READ request into another thread the message box is displayed.