Lower filter driver help (storage)

Hello;

I am new to the Windows driver framework and not making much progress with my attempt to create a lower filter driver for disk stack. I’m sure I have left out some important details so I’ll treat this as a first pass. This is what I have done so far.

Config:
My target platform is windows server 2003. I’ve downloaded Win DDK 7600.16385.1 and installed it on a windows XP system with service pack 3. Both systems have the latest MS updates and patches. Visual studio 2008 is also installed on the XP system. I’ve connected both PCs via serial line so I can run windbg.

Set up:
Initially I installed the diskperf DDK example as an upper filter and I was able to create a program that displayed the disk stats. I created a new IOCTL value for diskperf and was able to switch between either diskperf or partMgr for extracting the disk performance. I’m using \.\PHYSICALDRIVE0, 1… N etc to create a handle for each drive.

Code changes:
I cleared out the diskperf entries in the registry and edited the INF file to load the diskperf
driver as a lower filter driver that I can verify with DevView. DevView is a tool that comes with “Programming the Microsoft windows Driver model” CD. I duplicated the DiskPerfReadWrite function and associated it with IRP_MJ_INTERNAL_DEVICE_CONTROL and commented out the line that associate the original DiskPerfReadWrite with IRP_MJ_READ and IRP_MJ_WRITE. I pretty much had to gut the code that does checking for driver init since it was depending IOCTL calls that are now above the driver and also commented out the code that was changing stack content because it was trashing
the SRB information.

The driver loads and the system boots. Both seem drives act normal, I can copy files around etc. What I’ve noticed is now the new IOCTL value fails with error 31, “A device attached to the system is not functioning.” with both drives. The SCSI address for the first drive is pathID 0 Target 0 and Lun 0, the second is Target 1. I only see SRBs with addresses for the first drive. Looking at the driver stack for both drives using DevView again show that DiskPerf is in the chain.

I tried looking for initialization failures but turning on the logging and adding counters that I
can inspect with the debugger show that the init calls (AddDevice, IRP_MN_START_DEVICE in DispatchPnP)
seem to be okay.

I’m learning that the DDK Doc is a great reference but not the best guide and unless I know the correct term I won’t find what I’m looking for. With luck I’ll be taking a class very soon.

Does anyone have some initial pointers so that I can:
Get the initialization correct so I see SRBs for the second drive.
Correctly add an IOCTL for a lower filter.

Thank you
-john

xxxxx@gmail.com wrote:

The driver loads and the system boots. Both seem drives act normal, I can copy files around etc. What I’ve noticed is now the new IOCTL value fails with error 31, “A device attached to the system is not functioning.” with both drives.

Right, because your request is going to the top of the stack, and the
disk driver rejects your new ioctl as unrecognized.

Does anyone have some initial pointers so that I can:
Get the initialization correct so I see SRBs for the second drive.
Correctly add an IOCTL for a lower filter.

You can’t handle a custom ioctl in a lower filter. A lower filter can
only intercept requests being sent by the FDO. You either need to use
an upper/lower filter pair and have a private communication channel
between them, or use a “control PDO” that only you know about.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Or a rae pdo instead of the control device, the kbdfiltr example demonstrates this.

d

Bent from my phone


From: Tim Robertsmailto:xxxxx
Sent: ?3/?1/?2013 1:55 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: Re: [ntdev] Lower filter driver help (storage)

xxxxx@gmail.com wrote:
> The driver loads and the system boots. Both seem drives act normal, I can copy files around etc. What I’ve noticed is now the new IOCTL value fails with error 31, “A device attached to the system is not functioning.” with both drives.

Right, because your request is going to the top of the stack, and the
disk driver rejects your new ioctl as unrecognized.

> Does anyone have some initial pointers so that I can:
> Get the initialization correct so I see SRBs for the second drive.
> Correctly add an IOCTL for a lower filter.

You can’t handle a custom ioctl in a lower filter. A lower filter can
only intercept requests being sent by the FDO. You either need to use
an upper/lower filter pair and have a private communication channel
between them, or use a “control PDO” that only you know about.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

Okay, Thank you for the quick replies. I remember seeing the code at the bottom of switch of DiskDeviceControl() provided in the DDK. Now I know what it means.