From: unclepauly on
hello,

i have created an UpperFilter driver for the DiskDrive class. the purpose is
to enable/disable usb sticks. i have created a control device object and
created a couple of IOCTRLs, so that my user app can do the
enabling/disabling. to disable, in AddDevice, i do IoGetDeviceProperty on
the DeviceObject's DevicePropertyHardwareID. if it begins with USBSTOR then i
set a 'isUsb' flag on the DeviceExtension. then, in the IRP_MJ_CREATE
handler, i get this flag back, and if set, i just do IoCompleteRequest and
return success. this works just fine - when i insert a usb stick, nothing
happens, ie it does not even appear in explorer (and DbgView shows the filter
driver doing the above).

however, this does not affect already inserted usb sticks. they still stay
in explorer. i have sort of got round this by again checking for the isUsb
flag in the IRP_MJ_READ/WRITE handlers, and again just doing IoComplete. this
does prevent read/write access to the stick, but you are still able to see it
in explorer.

so what i really need is, when my filter driver receives the 'disable'
IOCTRL, to sort of send an 'eject' or 'remove' message to already inserted
sticks. now i *think* the answer is for my filter driver to create an
IRP_MJ_REMOVE and send this down the stack to all the inserted devices...but
then i will have to know the DeviceObjects for all inserted sticks. i guess i
could do this by having a global array of the DeviceObjects that i get in
AddDevice ?

i guess im looking for someone to tell me if this logic sounds right or
whether theres a better way.

thank you.