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?
Someone on osronline explained to me that the filter driver that is
under mine should take care of that if it's unloaded, but I couldn't
understand how is it supposed to change the pointer in my extension
(AttachedToDeviceObject)?
any help would be greatly appreciated.
thanks.