AttachedToDeviceObject

Hi All.

I’m making my first steps in the File System Drivers programming world, so this question might not be very intelligent or challenging.

I’ve followed the SFilter sample from IFS Kit in order to build my driver.
In the sample, I’ve noticed the use of IoAttachDeviceToDeviceStack (or IoAttachDeviceToDeviceStackSafe).
This function, if I understand correctly, is supposed to return the actual device that is directly “below” mine in the device stack. This device can be different from the device I was initially trying to hook, if other devices were already layered on top of it.

Let’s say I initialize the AttachedToDeviceObject member of my device’s extension with the value returned from IoAttachDeviceToDeviceStack, like I understood I should. I Later pass my AttachedToDeviceObject value to IoCreateFileSpecifyDeviceObjectHint .

What I couldn’t figure out, is what happens if the device pointed to by AttachedToDeviceObject, which is the one that was between me and my target device when I hooked, gets unloaded.
Does my AttachedToDeviceObject value reference uninitialized memory, and is therefore likely to cause a blue screen?
As I have failed to find a way to discover the next device in stack dynamically, how can I overcome this hazard?

thanks,
S.G


Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!

If the filter driver that is under yours is unloaded, it should take care of
the device object link. It seems like you remove an item in a list. After
the item is removed, the list is still linked by remained items.

“Steven Gerrard” wrote in message
news:xxxxx@ntfsd…
> Hi All.
>
> I’m making my first steps in the File System Drivers programming world, so
> this question might not be very intelligent or challenging.
>
> I’ve followed the SFilter sample from IFS Kit in order to build my driver.
> In the sample, I’ve noticed the use of IoAttachDeviceToDeviceStack (or
> IoAttachDeviceToDeviceStackSafe).
> This function, if I understand correctly, is supposed to return the actual
> device that is directly “below” mine in the device stack. This device can
> be different from the device I was initially trying to hook, if other
> devices were already layered on top of it.
>
> Let’s say I initialize the AttachedToDeviceObject member of my device’s
> extension with the value returned from IoAttachDeviceToDeviceStack, like I
> understood I should. I Later pass my AttachedToDeviceObject value to
> IoCreateFileSpecifyDeviceObjectHint .
>
> What I couldn’t figure out, is what happens if the device pointed to by
> AttachedToDeviceObject, which is the one that was between me and my target
> device when I hooked, gets unloaded.
> Does my AttachedToDeviceObject value reference uninitialized memory, and
> is therefore likely to cause a blue screen?
> As I have failed to find a way to discover the next device in stack
> dynamically, how can I overcome this hazard?
>
> thanks,
> S.G
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!

Thanks for your reply, but I still don’t understand.

How can a driver (that is layered beneath me) change the pointer in my extension (AttachedToDeviceObject) ?

Thanks,
SG.

Shangwu wrote:
If the filter driver that is under yours is unloaded, it should take care of
the device object link. It seems like you remove an item in a list. After
the item is removed, the list is still linked by remained items.

“Steven Gerrard” wrote in message
news:xxxxx@ntfsd…
> Hi All.
>
> I’m making my first steps in the File System Drivers programming world, so
> this question might not be very intelligent or challenging.
>
> I’ve followed the SFilter sample from IFS Kit in order to build my driver.
> In the sample, I’ve noticed the use of IoAttachDeviceToDeviceStack (or
> IoAttachDeviceToDeviceStackSafe).
> This function, if I understand correctly, is supposed to return the actual
> device that is directly “below” mine in the device stack. This device can
> be different from the device I was initially trying to hook, if other
> devices were already layered on top of it.
>
> Let’s say I initialize the AttachedToDeviceObject member of my device’s
> extension with the value returned from IoAttachDeviceToDeviceStack, like I
> understood I should. I Later pass my AttachedToDeviceObject value to
> IoCreateFileSpecifyDeviceObjectHint .
>
> What I couldn’t figure out, is what happens if the device pointed to by
> AttachedToDeviceObject, which is the one that was between me and my target
> device when I hooked, gets unloaded.
> Does my AttachedToDeviceObject value reference uninitialized memory, and
> is therefore likely to cause a blue screen?
> As I have failed to find a way to discover the next device in stack
> dynamically, how can I overcome this hazard?
>
> thanks,
> S.G
>
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!


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

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

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com