Question about using DPC in unloadable driver

Is it possible to synchronize driver unloading with a DPC queued by the
driver, to avoid execution of unloaded code? It seems to me, there is the
same issue there that lead to replacement of ExQueueWorkItem with
IoQueueWorkItem.

If you are on XP SP2 or later, KeFlushQueuedDpcs is available for this
purpose if KeRemoveQueueDpc returns FALSE.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Thursday, November 10, 2005 2:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about using DPC in unloadable driver

Is it possible to synchronize driver unloading with a DPC queued by the
driver, to avoid execution of unloaded code? It seems to me, there is
the
same issue there that lead to replacement of ExQueueWorkItem with
IoQueueWorkItem.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

I asked this same question a while ago, and the answer was mostly
KeFlushQueuedDpcs().

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Thursday, November 10, 2005 5:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about using DPC in unloadable driver

Is it possible to synchronize driver unloading with a DPC queued by the
driver, to avoid execution of unloaded code? It seems to me, there is the
same issue there that lead to replacement of ExQueueWorkItem with
IoQueueWorkItem.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

I see. So, in earlier versions, it is indeed a problem.

In the KeCancelTimer doc the DDK says: “Drivers do not need to synchronize
for data stored in global variables or driver object extensions. The system
automatically calls KeFlushQueuedDpcs before deallocating either of these
regions.”

Does this perhaps mean that I don’t really need to call KeFlushQueuedDpcs
before unload?

“Doron Holan” wrote in message
news:xxxxx@ntdev…
If you are on XP SP2 or later, KeFlushQueuedDpcs is available for this
purpose if KeRemoveQueueDpc returns FALSE.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Thursday, November 10, 2005 2:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about using DPC in unloadable driver

Is it possible to synchronize driver unloading with a DPC queued by the
driver, to avoid execution of unloaded code? It seems to me, there is
the
same issue there that lead to replacement of ExQueueWorkItem with
IoQueueWorkItem.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

It would appear so, but you need to be careful that the DPC not requeue
itself from the DPC routine.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Thursday, November 10, 2005 3:32 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Question about using DPC in unloadable driver

I see. So, in earlier versions, it is indeed a problem.

In the KeCancelTimer doc the DDK says: “Drivers do not need to
synchronize
for data stored in global variables or driver object extensions. The
system
automatically calls KeFlushQueuedDpcs before deallocating either of
these
regions.”

Does this perhaps mean that I don’t really need to call
KeFlushQueuedDpcs
before unload?

“Doron Holan” wrote in message
news:xxxxx@ntdev…
If you are on XP SP2 or later, KeFlushQueuedDpcs is available for this
purpose if KeRemoveQueueDpc returns FALSE.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ivan Bublikov
Sent: Thursday, November 10, 2005 2:47 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about using DPC in unloadable driver

Is it possible to synchronize driver unloading with a DPC queued by the
driver, to avoid execution of unloaded code? It seems to me, there is
the
same issue there that lead to replacement of ExQueueWorkItem with
IoQueueWorkItem.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

What kind of driver? The WDM one?

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Ivan Bublikov”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Friday, November 11, 2005 1:46 AM
Subject: [ntdev] Question about using DPC in unloadable driver

> Is it possible to synchronize driver unloading with a DPC queued by the
> driver, to avoid execution of unloaded code? It seems to me, there is the
> same issue there that lead to replacement of ExQueueWorkItem with
> IoQueueWorkItem.
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

WDM is of primary interest, but would there be a difference with NT4?

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
> What kind of driver? The WDM one?
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Ivan Bublikov”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Friday, November 11, 2005 1:46 AM
> Subject: [ntdev] Question about using DPC in unloadable driver
>
>
>> Is it possible to synchronize driver unloading with a DPC queued by the
>> driver, to avoid execution of unloaded code? It seems to me, there is the
>> same issue there that lead to replacement of ExQueueWorkItem with
>> IoQueueWorkItem.
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>

Pend the MN_REMOVE_DEVICE IRP till you have the DPCs in progress.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Ivan Bublikov”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Friday, November 11, 2005 10:58 PM
Subject: Re:[ntdev] Question about using DPC in unloadable driver

> WDM is of primary interest, but would there be a difference with NT4?
>
>
> “Maxim S. Shatskih” wrote in message
> news:xxxxx@ntdev…
> > What kind of driver? The WDM one?
> >
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > xxxxx@storagecraft.com
> > http://www.storagecraft.com
> >
> > ----- Original Message -----
> > From: “Ivan Bublikov”
> > Newsgroups: ntdev
> > To: “Windows System Software Devs Interest List”
> > Sent: Friday, November 11, 2005 1:46 AM
> > Subject: [ntdev] Question about using DPC in unloadable driver
> >
> >
> >> Is it possible to synchronize driver unloading with a DPC queued by the
> >> driver, to avoid execution of unloaded code? It seems to me, there is the
> >> same issue there that lead to replacement of ExQueueWorkItem with
> >> IoQueueWorkItem.
> >>
> >>
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >>
> >> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> >> To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

That’s the problem. The DPC is in progress in my code until the CPU has
executed the final RET instruction in the DPC routine, and I don’t know of a
way for getting notified about the execution. Hopefully, KeFlushQueuedDpcs
will take care of this issue.

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
> Pend the MN_REMOVE_DEVICE IRP till you have the DPCs in progress.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Ivan Bublikov”
> Newsgroups: ntdev
> To: “Windows System Software Devs Interest List”
> Sent: Friday, November 11, 2005 10:58 PM
> Subject: Re:[ntdev] Question about using DPC in unloadable driver
>
>
>> WDM is of primary interest, but would there be a difference with NT4?
>>
>>
>> “Maxim S. Shatskih” wrote in message
>> news:xxxxx@ntdev…
>> > What kind of driver? The WDM one?
>> >
>> > Maxim Shatskih, Windows DDK MVP
>> > StorageCraft Corporation
>> > xxxxx@storagecraft.com
>> > http://www.storagecraft.com
>> >
>> > ----- Original Message -----
>> > From: “Ivan Bublikov”
>> > Newsgroups: ntdev
>> > To: “Windows System Software Devs Interest List”
>> > Sent: Friday, November 11, 2005 1:46 AM
>> > Subject: [ntdev] Question about using DPC in unloadable driver
>> >
>> >
>> >> Is it possible to synchronize driver unloading with a DPC queued by
>> >> the
>> >> driver, to avoid execution of unloaded code? It seems to me, there is
>> >> the
>> >> same issue there that lead to replacement of ExQueueWorkItem with
>> >> IoQueueWorkItem.
>> >>
>> >>
>> >> —
>> >> Questions? First check the Kernel Driver FAQ at
>> > http://www.osronline.com/article.cfm?id=256
>> >>
>> >> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> >> To unsubscribe send a blank email to xxxxx@lists.osr.com
>> >
>> >
>> >
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
>> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>