ISR Being Called with Deleted Device Extension

I have a card that gets swapped.

When the card is started I call IoConnectInterrupt with the context being
the device object’s device extension. All works well.

I then get a STOP_DEVICE or a REMOVE_DEVICE and call IoDisconnectInterrupt
using the InterruptObject from the IoConnectInterrupt call. IRQs stop. Still
everything is ok.

The weird part comes about when the card gets reinserted and I get the
START_DEVICE. I call IoConnectInterrupt again with the new device object’s
device extension, but the ISR routine gets called sometimes with the old
card’s device extension.

Problem in Win2K?

I experienced the same for my DeviceObjects (removable storage volumes).
If a Device, let’s say a USB Zip drive, is removed, in the end the volume
is
removed ( IRP_MN_SURPRISE_REMOVAL, IRP_MN_REMOVE_DEVICE ).
If the thing (or something else) is plugged in again, the new
DeviceExtension
held the old values.
As I relied on what the DDK said (“The returned device extension is
initialized
with zeros.”), I had some trouble, specially if the new device was
different from
the unplugged one.
I now set the DeviceExtension to zero.

Else

“Doug”
To: “NT Developers Interest List”
Sent by: cc:
xxxxx@lis Subject: [ntdev] ISR Being Called with Deleted Device Extension
ts.osr.com

01.11.2002 21:00
Please respond to “NT
Developers Interest
List”

I have a card that gets swapped.

When the card is started I call IoConnectInterrupt with the context being
the device object’s device extension. All works well.

I then get a STOP_DEVICE or a REMOVE_DEVICE and call IoDisconnectInterrupt
using the InterruptObject from the IoConnectInterrupt call. IRQs stop.
Still
everything is ok.

The weird part comes about when the card gets reinserted and I get the
START_DEVICE. I call IoConnectInterrupt again with the new device object’s
device extension, but the ISR routine gets called sometimes with the old
card’s device extension.

Problem in Win2K?


You are currently subscribed to ntdev as: xxxxx@utimaco.de
To unsubscribe send a blank email to %%email.unsub%%

It is not that the device extension is being reused - in fact it isn’t. The
problem is that the ISR is being called with the context being set to the
address of a device extension that was freed. The data in the extension is
bogus (since it was freed). This extension was the extension previously used
by the ISR before it was disconnected and reconnected with a different
context.

“Else Kluger” wrote in message news:xxxxx@ntdev…
>
>
> I experienced the same for my DeviceObjects (removable storage volumes).
> If a Device, let’s say a USB Zip drive, is removed, in the end the volume
> is
> removed ( IRP_MN_SURPRISE_REMOVAL, IRP_MN_REMOVE_DEVICE ).
> If the thing (or something else) is plugged in again, the new
> DeviceExtension
> held the old values.
> As I relied on what the DDK said (“The returned device extension is
> initialized
> with zeros.”), I had some trouble, specially if the new device was
> different from
> the unplugged one.
> I now set the DeviceExtension to zero.
>
> Else
>
>
>
> “Doug”
> To: “NT Developers
Interest List”
> Sent by: cc:
> xxxxx@lis Subject: [ntdev] ISR
Being Called with Deleted Device Extension
> ts.osr.com
>
>

> 01.11.2002 21:00
> Please respond to “NT
> Developers Interest
> List”
>
>
>
>
>
>
> I have a card that gets swapped.
>
> When the card is started I call IoConnectInterrupt with the context being
> the device object’s device extension. All works well.
>
> I then get a STOP_DEVICE or a REMOVE_DEVICE and call IoDisconnectInterrupt
> using the InterruptObject from the IoConnectInterrupt call. IRQs stop.
> Still
> everything is ok.
>
> The weird part comes about when the card gets reinserted and I get the
> START_DEVICE. I call IoConnectInterrupt again with the new device object’s
> device extension, but the ISR routine gets called sometimes with the old
> card’s device extension.
>
> Problem in Win2K?
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@utimaco.de
> To unsubscribe send a blank email to %%email.unsub%%
>
>
>
>
>
>