Know which device is in the AddDevice function

Hello all,

I am developing a filter driver disk and I need to know if the device is an HardDisk or not (like a USB storage device for example). I need to know this inside the AddDevice function because I want to attach my driver only with de HardDisk.

I do not have much experience developing drivers, so if I said something wrong please correct me.

And I’m developing based in the diskperf source from WDK.

Thanks…

Well USB storage can be a hard disk. You can detect the Bus that the
device is on, but AFAIK you can’t detect the exact type of storage. So
what are you trying to do that needs this requirement?

Don Burn
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@gmail.com” wrote in message
news:xxxxx@ntdev:

> Hello all,
>
> I am developing a filter driver disk and I need to know if the device is an HardDisk or not (like a USB storage device for example). I need to know this inside the AddDevice function because I want to attach my driver only with de HardDisk.
>
> I do not have much experience developing drivers, so if I said something wrong please correct me.
>
> And I’m developing based in the diskperf source from WDK.
>
> Thanks…

My driver keeps track of the read / write requests, and redirects to a raw partition, so the windows partition is never changed. Today, it is working perfectly, but when I put a USB flash drive, sometime the windows freeze.

So I want to attach this filter only with the harddisk to test if the problems ends.

This freezing is occurring rarely, and I can’t track with windbg because it doesn’t cause a BSOD.

This is a common question on here - “How can I only attach to a specific
disk in my filter ?”

The answer is that for a disk filter that you attach to ALL disks when
AddDevice is called and at a minimum you treat each disk instance as a
pass-thru. Where you can decide if you want a specific instance to be
more than a pass-thru is during IRP_MN_START_DEVICE. When this returns
from the lower device object the stack below you is operational and can
accept any ioctl you want to send to it that will aid discovery of
fabric type or other disk parameters. If this discovery confirms the
disk as one you’re interested in, then you flag it in the device
extension so it is recognised as such for subsequent IRPs.

Never fail AddDevice in a disk filter.

Mark.

On 29/09/2011 16:48, xxxxx@gmail.com wrote:

My driver keeps track of the read / write requests, and redirects to a raw partition, so the windows partition is never changed. Today, it is working perfectly, but when I put a USB flash drive, sometime the windows freeze.

So I want to attach this filter only with the harddisk to test if the problems ends.

This freezing is occurring rarely, and I can’t track with windbg because it doesn’t cause a BSOD.

Let me get this straight.

In the AddDevice I will attach all disks, but in the IRP_MN_START_DEVICE I can get some information through IOCTLs. Thus, in the read / write function I check the flag to know if I send to the lower or I redirects my IRP.

Exactly so.

Peter
OSR

>device for example). I need to know this inside the AddDevice function

IoGetDeviceProperty. This is the only thing which will work in AddDevice.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> Never fail AddDevice in a disk filter.

To skip attaching, just return STATUS_SUCCESS from AddDevice without doing anything.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com