After I complete the IRP_MN_START_DEVICE in my upper disk filter driver for the first disk, I see that startDevice is not called for any other disks in the system.
StartDevice just gets called only once. Any clue why this is happening? Following is the code of my startDevice, output of !locks -v and !devstack. Thanks.
NTSTATUS MyFltrIdentifyDevices (IN PDEVICE_OBJECT DeviceObject)
{
PDEVICE_EXTENSION deviceExtension = DeviceObject->DeviceExtension;
ANSI_STRING signature;
PAGED_CODE ();
/* get disk IDENTIFY DATA using IOCTL_ATA_PASS_THROUGH
*/
if (!MyFltrGetIdentifyData (DeviceObject, &signature)) {
return (STATUS_SUCCESS);
}
/* now examine the IDENTIFY DATA
*/
ExAcquireFastMutexUnsafe (&MyFltrGlobal->DevicesLookupMutex);
if (MyFltrGlobal->Dev1) {
goto DEV2_LOOKUP;
}
if (!RtlEqualString (&MyFltrDataG->Dev1Signature,
&signature,
TRUE)) {
goto DEV2_LOOKUP;
}
MyDbgPrint (DPFLTR_INFO_LEVEL, “DEV1 [0x%x] found !!!\n”, DeviceObject);
MyFltrGlobal->Dev1 = DeviceObject;
/* Dev1 & Dev2 cannot be the same device
*/
goto END;
DEV2_LOOKUP:
if (MyFltrGlobal->Dev2) {
goto END;
}
if (!RtlEqualString (&MyFltrGlobal->Dev2Signature,
&signature,
TRUE)) {
goto END;
}
MyDbgPrint (DPFLTR_ERROR_LEVEL,
“DEV2 [0x%x] found !!!\n”,
DeviceObject);
MyFltrGlobal->Dev2 = DeviceObject;
END:
ExReleaseFastMutexUnsafe (&MyFltrGlobal->DevicesLookupMutex);
return (STATUS_SUCCESS);
}
NTSTATUS MyFltrStartDevice (IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
PDEVICE_EXTENSION deviceExtension;
NTSTATUS status;
PAGED_CODE ();
deviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
// copied from diskperf.c
status = MyFltrForwardIrpSynchronous (DeviceObject, Irp);
// copied from diskperf.c
MyFltrSyncFilterWithTarget (DeviceObject,
deviceExtension->TargetDeviceObject);
// copied from diskperf.c
MyFltrRegisterDevice (DeviceObject);
/* check if this the device I 'm looking for
*/
MyFltrIdentifyDevices (DeviceObject);
/* Complete the Irp
*/
Irp->IoStatus.Status = status;
IoCompleteRequest (Irp, IO_NO_INCREMENT);
return (status);
}
0: kd> !locks -v
**** DUMP OF ALL RESOURCE OBJECTS ****
Resource @ nt!ExpFirmwareTableResource (0x8278e880) Available
Resource @ nt!PsLoadedModuleResource (0x827a1860) Available
Resource @ nt!MmSectionExtendResource (0x827a16e0) Available
Resource @ nt!MmSectionExtendSetResource (0x827a1720) Available
Resource @ nt!SepRmDbLock (0x8278bf98) Available
Resource @ nt!SepRmDbLock (0x8278bfd0) Available
Resource @ nt!SepRmDbLock (0x8278c008) Available
Resource @ nt!SepRmDbLock (0x8278c040) Available
Resource @ nt!SepRmGlobalSaclLock (0x8278c098) Available
Resource @ nt!SepLsaAuditQueueInfo (0x8278bf20) Available
Resource @ nt!SepLsaDeletedLogonQueueInfo (0x8278be70) Available
Resource @ 0x85238c38 Available
Resource @ nt!VdmIoListCreationResource (0x82799b80) Available
Resource @ nt!PnpRegistryDeviceResource (0x827bfda0) Available
Resource @ nt!PopPolicyLock (0x8279a4e0) Available
Resource @ 0x85275920 Available
Resource @ 0x85281650 Available
Resource @ CI!g_StoreLock (0x806ca8c0) Available
Resource @ nt!CmpRegistryLock (0x82785500) Available
Resource @ 0x852a2b60 Available
Resource @ 0x852a2ac0 Available
Resource @ 0x852a2a20 Available
Resource @ nt!ExpTimeRefreshLock (0x8278e900) Available
Resource @ 0x852a0008 Available
Resource @ 0x852a0040 Available
Resource @ 0x852a0078 Available
Resource @ 0x852a00b0 Available
Resource @ 0x852a00e8 Available
Resource @ 0x852a0120 Available
Resource @ 0x852a0158 Available
Resource @ 0x852a0190 Available
Resource @ 0x852a01c8 Available
Resource @ 0x852a0200 Available
Resource @ 0x852a0238 Available
Resource @ 0x852a0270 Available
Resource @ 0x852a02a8 Available
Resource @ 0x852a02e0 Available
Resource @ 0x852a0318 Available
Resource @ 0x852a0350 Available
Resource @ nt!IopDriverLoadResource (0x827c0720) Available
Resource @ nt!IopDatabaseResource (0x827c0760) Available
Resource @ nt!IopSecurityResource (0x827c06e0) Available
Resource @ nt!IopCrashDumpLock (0x827c0320) Available
Resource @ nt!PiDDBLock (0x827bfd00) Available
Resource @ nt!IopDeviceTreeLock (0x827bff00) Shared 1 owning threads
Threads: 85202a30-01<*>
THREAD 85202a30 Cid 0004.0008 Teb: 00000000 Win32Thread: 00000000 WAIT: (Executive) KernelMode Non-Alertable
80598600 NotificationEvent
IRP List:
8603dc18: (0006,01d8) Flags: 00060000 Mdl: 8603ddf8
Not impersonating
DeviceMap 8d005800
Owning Process 0 Image:
Attached Process 85202d08 Image: System
Wait Start TickCount 507 Ticks: 1027 (0:00:00:16.046)
Context Switch Count 527
UserTime 00:00:00.000
KernelTime 00:00:03.906
Win32 Start Address nt!Phase1Initialization (0x827df365)
Stack Init 80598fd0 Current 80598438 Base 80599000 Limit 80596000 Call 0
Priority 31 BasePriority 8 PriorityDecrement 0 IoPriority 2 PagePriority 5
ChildEBP RetAddr
80598450 8269a51d nt!KiSwapContext+0x26 (FPO: [Uses EBP] [0,0,4])
80598494 826e0460 nt!KiSwapThread+0x57b
805984e8 8269dcaf nt!KiCommitThreadWait+0x340
805985c4 8264b565 nt!KeWaitForSingleObject+0x3ee
80598610 827d279a nt!HalExamineMBR+0xb7
80598768 827c7398 nt!IopCreateArcName+0x170
80598770 8c098a91 nt!IoCreateArcName+0x10
805987d4 8c09dce1 partmgr!PmStartDevice+0x139 (FPO: [Non-Fpo])
805987f4 8c0971cc partmgr!PmPnp+0xe4 (FPO: [Non-Fpo])
80598808 826997ce partmgr!PmGlobalDispatch+0x1d (FPO: [Non-Fpo])
80598820 8281d987 nt!IofCallDriver+0x63
8059883c 8265e9bb nt!PnpAsynchronousCall+0x95
805988a0 82819ccd nt!PnpStartDevice+0xe1
805988fc 82819a46 nt!PnpStartDeviceNode+0x27c
80598918 8281c59e nt!PipProcessStartPhase1+0x65
80598b14 8265f837 nt!PipProcessDevNodeTree+0x188
80598b5c 8265f705 nt!PnpDeviceActionWorker+0x123
80598b74 829fcf2a nt!PnpRequestDeviceAction+0x11f
80598bec 829fed72 nt!IopInitializeBootDrivers+0x3bd
80598c64 82a04008 nt!IoInitSystem+0x5af
80598d44 827df372 nt!Phase1InitializationDiscard+0xbee
80598d4c 82849aad nt!Phase1Initialization+0xd
80598d90 82692535 nt!PspSystemThreadStartup+0x9e
00000000 00000000 nt!KiThreadStartup+0x19
Resource @ nt!IopSurpriseRemoveListLock (0x827bfec0) Available
Resource @ nt!PnpDevicePropertyLock (0x827bdde0) Available
Resource @ nt!PiEngineLock (0x827bfe80) Exclusively owned
Threads: 85202a30-01<*>
THREAD 85202a30 Cid 0004.0008 Teb: 00000000 Win32Thread: 00000000 WAIT: (Executive) KernelMode Non-Alertable
80598600 NotificationEvent
IRP List:
8603dc18: (0006,01d8) Flags: 00060000 Mdl: 8603ddf8
Not impersonating
DeviceMap 8d005800
Owning Process 0 Image:
Attached Process 85202d08 Image: System
Wait Start TickCount 507 Ticks: 1027 (0:00:00:16.046)
Context Switch Count 527
UserTime 00:00:00.000
KernelTime 00:00:03.906
Win32 Start Address nt!Phase1Initialization (0x827df365)
Stack Init 80598fd0 Current 80598438 Base 80599000 Limit 80596000 Call 0
Priority 31 BasePriority 8 PriorityDecrement 0 IoPriority 2 PagePriority 5
ChildEBP RetAddr
80598450 8269a51d nt!KiSwapContext+0x26 (FPO: [Uses EBP] [0,0,4])
80598494 826e0460 nt!KiSwapThread+0x57b
805984e8 8269dcaf nt!KiCommitThreadWait+0x340
805985c4 8264b565 nt!KeWaitForSingleObject+0x3ee
80598610 827d279a nt!HalExamineMBR+0xb7
80598768 827c7398 nt!IopCreateArcName+0x170
80598770 8c098a91 nt!IoCreateArcName+0x10
805987d4 8c09dce1 partmgr!PmStartDevice+0x139 (FPO: [Non-Fpo])
805987f4 8c0971cc partmgr!PmPnp+0xe4 (FPO: [Non-Fpo])
80598808 826997ce partmgr!PmGlobalDispatch+0x1d (FPO: [Non-Fpo])
80598820 8281d987 nt!IofCallDriver+0x63
8059883c 8265e9bb nt!PnpAsynchronousCall+0x95
805988a0 82819ccd nt!PnpStartDevice+0xe1
805988fc 82819a46 nt!PnpStartDeviceNode+0x27c
80598918 8281c59e nt!PipProcessStartPhase1+0x65
80598b14 8265f837 nt!PipProcessDevNodeTree+0x188
80598b5c 8265f705 nt!PnpDeviceActionWorker+0x123
80598b74 829fcf2a nt!PnpRequestDeviceAction+0x11f
80598bec 829fed72 nt!IopInitializeBootDrivers+0x3bd
80598c64 82a04008 nt!IoInitSystem+0x5af
80598d44 827df372 nt!Phase1InitializationDiscard+0xbee
80598d4c 82849aad nt!Phase1Initialization+0xd
80598d90 82692535 nt!PspSystemThreadStartup+0x9e
00000000 00000000 nt!KiThreadStartup+0x19
Resource @ nt!PiDependencyRelationsLock (0x827bfe20) Available
Resource @ 0x8525cb10 Available
Resource @ 0x852afa70 Available
Resource @ 0x852afa30 Available
Resource @ 0x852af9f0 Available
Resource @ 0x852af9b0 Available
Resource @ 0x852af970 Available
Resource @ nt!g_CacheLock (0x8278dec0) Available
Resource @ nt!g_ServiceLock (0x8278de80) Available
Resource @ WDFLDR!WdfLdrGlobals (0x807e815c) Available
Resource @ NETIO!NsipCachedRegistryKeyListLock (0x8c361420) Available
Resource @ 0x851a7e98 Available
Resource @ 0x85b841d0 Available
Resource @ 0x85201ad0 Available
Resource @ 0x85efa500 Available
Resource @ 0x85f152e0 Available
Resource @ 0x85f1b600 Available
Resource @ 0x851fe728 Available
Resource @ 0x85f2d748 Available
Resource @ fltmgr!FltGlobals (0x8c168900) Available
Resource @ 0x85f2bdd4 Available
Resource @ 0x85f2bce4 Available
Resource @ 0x85f2bd28 Available
Resource @ 0x85f5b5f0 Available
Resource @ 0x85f6774c Available
Resource @ 0x85f2ae04 Available
Resource @ 0x85f2ae44 Available
Resource @ 0x85f2ae84 Available
Resource @ 0x85f2aec4 Available
Resource @ 0x85f2af04 Available
Resource @ 0x85f2af44 Available
Resource @ 0x85f2af84 Available
Resource @ 0x85f2afc4 Available
Resource @ cng!g_PrvReg (0x8c262ef8) Available
Resource @ 0x85f20218 Available
Resource @ cng!g_PrvReg (0x8c262eb8) Available
Resource @ cng!g_CfgReg (0x8c262e70) Available
Resource @ 0x85f201d8 Available
Resource @ ndis!SharedMemoryResource (0x8c2b9f88) Available
Resource @ 0x85f74700 Available
Resource @ 0x85286000 Available
Resource @ 0x85282000 Available
Resource @ Ntfs!NtfsData (0x8c6475e8) Available
Resource @ Ntfs!NtfsData (0x8c647694) Available
Resource @ Ntfs!NtfsData (0x8c647414) Available
Resource @ Ntfs!SqmData (0x8c646718) Available
Resource @ Ntfs!LfsData (0x8c64b710) Available
Resource @ mup!MupProviderTable (0x8c7a7214) Available
Resource @ mup!MupiSurrogateList (0x8c7a7194) Available
Resource @ 0x8527c9f8 Available
Resource @ 0x8527cc9c Available
Resource @ 0x8527cce0 Available
Resource @ 0x8527cdc0 Available
101 total locks, 2 locks currently held
!devstack 8603A5C0
!DevObj !DrvObj !DevExt ObjectName
8603b020 \Driver\partmgr 8603b0d8
> 8603a5c0 \Driver\myfltr 8603a678
8603a9d0 \Driver\Disk 8603aa88
85294660 \Driver\ACPI 85201cb8
85f5b940 \Driver\atapi 85f5b9f8
!DevNode 85f66e88 :
DeviceInst is “IDE\DiskST3160815AS __________________________4.AAB \5&2b98b2e5&0&0.0.0”
ServiceName is “disk”