Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


completion of pending create doesn't wake up caller

OSR_Community_UserOSR_Community_User Member Posts: 110,217
Hi,
I'm trying to implement a network FS FSD. Since create involves network
communication, I am marking the requesting Irp as pending and returning
STATUS_PENDING from the create dispatch routine. I use driver queueing
(keep a queue of requests), and when the response comes back I find the
appropriate Irp and mark it as complete. Using printfs all this seems to be
working correctly, but the user program that invoked the create never wakes
up. Any hints as to what I should look at to figure out what I'm doing wrong?

Relevant code to mark Irp pending:
IoSetCancelRoutine(Irp, MyCancel);
IoMarkIrpPending(Irp);
return STATUS_PENDING;

(cancel is never called. by the way, how can I force a cancel? killing the
program doesn't seem to work -- in fact it doesn't kill the program)

Relevant code to waking the irp up again:
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = FILE_OPENED;
IoSetCancelRoutine(irp, NULL);
IoCompleteRequest(irp, IO_NO_INCREMENT);

Both sections of code should be running at PASSIVE and shouldn't be holding
any locks.

thanks,

david

Comments

  • OSR_Community_UserOSR_Community_User Member Posts: 110,217
    Okay, I learned something (thanks in part to Jamey): Pending should only be used for operations that can be run asynchronously wrt the application thread that invoked them. A quick look at the Win32 API indicates that CreateFile isn't one of them. So the answer to my question is that I should put the thread to sleep on a dispatcher object.

    I have 2 related questions:
    1. It seems to me that any request should be allowed to be marked as Pending, as that simply forces the I/OMgr to handle synchronization. Since there fields in the FileObject that I suppose I'm not supposed to use (is the FileObject opaque to FSDs?), it seems reasonable that the I/OMgr would be able to handle pending creates.

    2. I setup a KEVENT, cause the user thread to wait, and wake it up when the create has completed. This works if my user (console) program is running by itself, but if it runs under the VC++ debugger the CreateFile never returns. Any ideas why this might be the case?
    (I sleep via KeWaitForSingleObject(MyEvent, UserRequest, UserMode, TRUE, 0)
    and wake it up via (KeSetState(MyEvent, 0, TRUE); )

    any help appreciated,

    thanks

    david.

    At 11:50 AM 4/19/00 -0700, David C. Steere wrote:
    >Hi,
    > I'm trying to implement a network FS FSD. Since create involves network communication, I am marking the requesting Irp as pending and returning STATUS_PENDING from the create dispatch routine. I use driver queueing (keep a queue of requests), and when the response comes back I find the appropriate Irp and mark it as complete. Using printfs all this seems to be working correctly, but the user program that invoked the create never wakes up. Any hints as to what I should look at to figure out what I'm doing wrong?
    >
    >Relevant code to mark Irp pending:
    > IoSetCancelRoutine(Irp, MyCancel);
    > IoMarkIrpPending(Irp);
    > return STATUS_PENDING;
    >
    >(cancel is never called. by the way, how can I force a cancel? killing the program doesn't seem to work -- in fact it doesn't kill the program)
    >
    >Relevant code to waking the irp up again:
    > irp->IoStatus.Status = STATUS_SUCCESS;
    > irp->IoStatus.Information = FILE_OPENED;
    > IoSetCancelRoutine(irp, NULL);
    > IoCompleteRequest(irp, IO_NO_INCREMENT);
    >
    >Both sections of code should be running at PASSIVE and shouldn't be holding any locks.
    >
    >thanks,
    >
    >david
    >
    >
    >---
    >You are currently subscribed to ntfsd as: [email protected]
    >To unsubscribe send a blank email to $subst('Email.Unsub')
  • Hello !!

    According to the Rajeev Nagar's book (File System Internals) the
    create(open)/close requests are inherently always synchronous.


    Martin
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Writing WDF Drivers 7 Dec 2020 LIVE ONLINE
Internals & Software Drivers 25 Jan 2021 LIVE ONLINE
Developing Minifilters 8 March 2021 LIVE ONLINE