DeviceIoControl()

I’m building an fsd that uses a user-space helper service. Currently I have
one control code for the service to sit and wait for an IRP to process, and
another to shutdown the driver (yes, I know shutting down an fsd is
unsupported, but it’d be nice while I’m building it…). Anyways, the
worker thread is sitting in DeviceIoControl, waiting for an IRP (in
KeWaitForSingleObject), and I shutdown the service. In the OnStop(), it
calls DeviceIoControl with the shutdown code. My problem is that it appears
that the driver never receives the shutdown IOCTL, unless I do something
else in the driver from another process to make the first one finish the
routine. Am I not allowed to call DeviceIoControl while another thread in
the same process has already called it and is waiting?

Thank you,
Stuart

I’m assuming you are using the Win32 API; this adds (by default)
serialization. Check your CreateFile call on your control device and I
bet you aren’t asking for overlapped I/O - in which case Win32 has asked
for sequenced I/O operations (in turn, the serialization is done by the
I/O Manager).

To resolve this:

  • Use overlapped I/O
  • Use separate file handles on the device (open it twice)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Stuart Turner
Sent: Monday, July 19, 2004 8:03 AM
To: ntfsd redirect
Subject: [ntfsd] DeviceIoControl()

I’m building an fsd that uses a user-space helper service. Currently I
have one control code for the service to sit and wait for an IRP to
process, and another to shutdown the driver (yes, I know shutting down
an fsd is unsupported, but it’d be nice while I’m building it…).
Anyways, the worker thread is sitting in DeviceIoControl, waiting for an
IRP (in KeWaitForSingleObject), and I shutdown the service. In the
OnStop(), it calls DeviceIoControl with the shutdown code. My problem
is that it appears that the driver never receives the shutdown IOCTL,
unless I do something else in the driver from another process to make
the first one finish the routine. Am I not allowed to call
DeviceIoControl while another thread in the same process has already
called it and is waiting?

Thank you,
Stuart


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com

Thanks. You are right, I’ve been using the Win32 API without overlapped. I
was hoping to avoid overlapped, but oh well…
Stuart

“Tony Mason” wrote in message news:xxxxx@ntfsd…
I’m assuming you are using the Win32 API; this adds (by default)
serialization. Check your CreateFile call on your control device and I
bet you aren’t asking for overlapped I/O - in which case Win32 has asked
for sequenced I/O operations (in turn, the serialization is done by the
I/O Manager).

To resolve this:

- Use overlapped I/O
- Use separate file handles on the device (open it twice)

Regards,

Tony

Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Stuart Turner
Sent: Monday, July 19, 2004 8:03 AM
To: ntfsd redirect
Subject: [ntfsd] DeviceIoControl()

I’m building an fsd that uses a user-space helper service. Currently I
have one control code for the service to sit and wait for an IRP to
process, and another to shutdown the driver (yes, I know shutting down
an fsd is unsupported, but it’d be nice while I’m building it…).
Anyways, the worker thread is sitting in DeviceIoControl, waiting for an
IRP (in KeWaitForSingleObject), and I shutdown the service. In the
OnStop(), it calls DeviceIoControl with the shutdown code. My problem
is that it appears that the driver never receives the shutdown IOCTL,
unless I do something else in the driver from another process to make
the first one finish the routine. Am I not allowed to call
DeviceIoControl while another thread in the same process has already
called it and is waiting?

Thank you,
Stuart


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@osr.com To unsubscribe
send a blank email to xxxxx@lists.osr.com