The answer is in the output you gave, look at your query remove code (you wait for an event) and then look at the output of !locks -v. do you see your code in the stack blocking, waiting for the event? You are never completing the q.r. irp. I strongly suggest you rewrite using KMDF, all of these issues will go away.
kd> !locks -v 0x805586e0
Resource @ nt!IopDeviceTreeLock (0x805586e0) Shared 1 owning threads
Contention Count = 1
Threads: 81348da8-01<*>
THREAD 81348da8 Cid 0004.0034 Teb: 00000000 Win32Thread: 00000000 WAIT: (Executive) KernelMode Non-Alertable
81251400 SynchronizationEvent
IRP List:
fe9a8e28: (0006,01d8) Flags: 00000000 Mdl: 00000000
Not impersonating
DeviceMap e1000090
Owning Process 8134a020 Image: System
Wait Start TickCount 185997 Ticks: 769 (0:00:00:12.015)
Context Switch Count 4810
UserTime 00:00:00.0000
KernelTime 00:00:01.0687
Start Address nt!ExpWorkerThread (0x804e4196)
Stack Init f9716000 Current f9715b28 Base f9716000 Limit f9713000 Call 0
Priority 12 BasePriority 12 PriorityDecrement 0 DecrementCount 16
ChildEBP RetAddr
f9715b40 804dc0f7 nt!KiSwapContext+0x2e (FPO: [EBP 0xf9715b74] [0,0,4])
f9715b4c 804dc143 nt!KiSwapThread+0x46 (FPO: [0,0,0])
f9715b74 f23a278a nt!KeWaitForSingleObject+0x1c2 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
f9715b9c 804e37f7 JinSdDesigner+0x578a <== right here!!! <==
f9715bac 805dc5ff nt!IopfCallDriver+0x31 (FPO: [0,0,0])
f9715bd8 8061a94e nt!IopSynchronousCall+0xb7 (FPO: [Non-Fpo])
f9715c2c 805314d1 nt!IopRemoveDevice+0x93 (FPO: [Non-Fpo])
f9715c54 8061bac3 nt!IopRemoveLockedDeviceNode+0x160 (FPO: [Non-Fpo])
f9715c6c 8061bb2f nt!IopDeleteLockedDeviceNode+0x34 (FPO: [Non-Fpo])
f9715ca0 8061d8f6 nt!IopDeleteLockedDeviceNodes+0x3f (FPO: [Non-Fpo])
f9715d34 805ec82d nt!PiProcessQueryRemoveAndEject+0x76b (FPO: [Non-Fpo])
f9715d50 8059fbb1 nt!PiProcessTargetDeviceEvent+0x2a (FPO: [Non-Fpo])
f9715d74 804e426b nt!PiWalkDeviceList+0x122 (FPO: [Non-Fpo])
f9715dac 8057d0f1 nt!ExpWorkerThread+0x100 (FPO: [Non-Fpo])
f9715ddc 804f827a nt!PspSystemThreadStartup+0x34 (FPO: [Non-Fpo])
00000000 00000000 nt!KiThreadStartup+0x16
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of nayan kumar
Sent: Monday, October 22, 2007 4:05 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Why Remove Event is not getting signaled while uninstalling the driver
Hi,
Thanks for your input.
I am modifiying the toaster func featured 2 code according to my requirment.
According to me yes i am completing the query remove irp but possibility of doing something wrong is always there .
following is the code please point out if i am doing anything wrong .
case IRP_MN_QUERY_REMOVE_DEVICE:
status = SdHostCanRemoveDevice(pDeviceObject, pIrp);
if (NT_SUCCESS(status))
{
SET_NEW_PNP_STATE(pSdHostFdoData, SdHostRemovePending);
pSdHostFdoData->SdHostQueueState = HoldRequests;
ToasterDisarmWake(pSdHostFdoData, TRUE);
KeWaitForSingleObject(
&pSdHostFdoData->StopEvent,
Executive,
KernelMode,
FALSE,
NULL);
pIrp->IoStatus.Status = STATUS_SUCCESS;
IoSkipCurrentIrpStackLocation (pIrp);
status = IoCallDriver (pSdHostFdoData->NextLowerDriver, pIrp);
return status;
}
break;
There is no any filter in my device stack;
Following is the detailed output of devnod and locks command that i issued when uninstallationpreocess halted in the midle.
Although i am able to see the warning in these detailed ouput of these command but i am unable to locate the problem in my code if you can help me in locating the problem i would be very thankfull to you.
kd> !devnode 0 1 JinSdDesigner
Dumping IopRootDeviceNode (= 0x8136d808)
DevNode 0x812ff350 for PDO 0x812ff928
InstancePath is “PCI\VEN_1947&DEV_4743&SUBSYS_44332211&REV_09\4&2af9ed5&0&00F0”
ServiceName is “JinSdDesigner”
State = DeviceNodeQueryRemoved (0x310)
Previous State = DeviceNodeStarted (0x308)
kd> !locks
**** DUMP OF ALL RESOURCE OBJECTS ****
KD: Scanning for held locks…
Resource @ nt!IopDeviceTreeLock (0x805586e0) Shared 1 owning threads
Contention Count = 1
Threads: 81348da8-01<*>
KD: Scanning for held locks.
Resource @ nt!PiEngineLock (0x80558660) Exclusively owned
Contention Count = 3
Threads: 81348da8-01<*>
KD: Scanning for held locks…
Resource @ 0xfeb10980 Shared 1 owning threads
Threads: 8134a473-01<*> *** Actual Thread 8134a470
2818 total locks, 3 locks currently held
kd> !locks -v 0x805586e0
Resource @ nt!IopDeviceTreeLock (0x805586e0) Shared 1 owning threads
Contention Count = 1
Threads: 81348da8-01<*>
THREAD 81348da8 Cid 0004.0034 Teb: 00000000 Win32Thread: 00000000 WAIT: (Executive) KernelMode Non-Alertable
81251400 SynchronizationEvent
IRP List:
fe9a8e28: (0006,01d8) Flags: 00000000 Mdl: 00000000
Not impersonating
DeviceMap e1000090
Owning Process 8134a020 Image: System
Wait Start TickCount 185997 Ticks: 769 (0:00:00:12.015)
Context Switch Count 4810
UserTime 00:00:00.0000
KernelTime 00:00:01.0687
Start Address nt!ExpWorkerThread (0x804e4196)
Stack Init f9716000 Current f9715b28 Base f9716000 Limit f9713000 Call 0
Priority 12 BasePriority 12 PriorityDecrement 0 DecrementCount 16
ChildEBP RetAddr
f9715b40 804dc0f7 nt!KiSwapContext+0x2e (FPO: [EBP 0xf9715b74] [0,0,4])
f9715b4c 804dc143 nt!KiSwapThread+0x46 (FPO: [0,0,0])
f9715b74 f23a278a nt!KeWaitForSingleObject+0x1c2 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
f9715b9c 804e37f7 JinSdDesigner+0x578a
f9715bac 805dc5ff nt!IopfCallDriver+0x31 (FPO: [0,0,0])
f9715bd8 8061a94e nt!IopSynchronousCall+0xb7 (FPO: [Non-Fpo])
f9715c2c 805314d1 nt!IopRemoveDevice+0x93 (FPO: [Non-Fpo])
f9715c54 8061bac3 nt!IopRemoveLockedDeviceNode+0x160 (FPO: [Non-Fpo])
f9715c6c 8061bb2f nt!IopDeleteLockedDeviceNode+0x34 (FPO: [Non-Fpo])
f9715ca0 8061d8f6 nt!IopDeleteLockedDeviceNodes+0x3f (FPO: [Non-Fpo])
f9715d34 805ec82d nt!PiProcessQueryRemoveAndEject+0x76b (FPO: [Non-Fpo])
f9715d50 8059fbb1 nt!PiProcessTargetDeviceEvent+0x2a (FPO: [Non-Fpo])
f9715d74 804e426b nt!PiWalkDeviceList+0x122 (FPO: [Non-Fpo])
f9715dac 8057d0f1 nt!ExpWorkerThread+0x100 (FPO: [Non-Fpo])
f9715ddc 804f827a nt!PspSystemThreadStartup+0x34 (FPO: [Non-Fpo])
00000000 00000000 nt!KiThreadStartup+0x16
1 total locks, 1 locks currently held
kd> !locks -v 0x80558660
Resource @ nt!PiEngineLock (0x80558660) Exclusively owned
Contention Count = 3
Threads: 81348da8-01<*>
THREAD 81348da8 Cid 0004.0034 Teb: 00000000 Win32Thread: 00000000 WAIT: (Executive) KernelMode Non-Alertable
81251400 SynchronizationEvent
IRP List:
fe9a8e28: (0006,01d8) Flags: 00000000 Mdl: 00000000
Not impersonating
DeviceMap e1000090
Owning Process 8134a020 Image: System
Wait Start TickCount 185997 Ticks: 769 (0:00:00:12.015)
Context Switch Count 4810
UserTime 00:00:00.0000
KernelTime 00:00:01.0687
Start Address nt!ExpWorkerThread (0x804e4196)
Stack Init f9716000 Current f9715b28 Base f9716000 Limit f9713000 Call 0
Priority 12 BasePriority 12 PriorityDecrement 0 DecrementCount 16
ChildEBP RetAddr
f9715b40 804dc0f7 nt!KiSwapContext+0x2e (FPO: [EBP 0xf9715b74] [0,0,4])
f9715b4c 804dc143 nt!KiSwapThread+0x46 (FPO: [0,0,0])
f9715b74 f23a278a nt!KeWaitForSingleObject+0x1c2 (FPO: [Non-Fpo])
WARNING: Stack unwind information not available. Following frames may be wrong.
f9715b9c 804e37f7 JinSdDesigner+0x578a
f9715bac 805dc5ff nt!IopfCallDriver+0x31 (FPO: [0,0,0])
f9715bd8 8061a94e nt!IopSynchronousCall+0xb7 (FPO: [Non-Fpo])
f9715c2c 805314d1 nt!IopRemoveDevice+0x93 (FPO: [Non-Fpo])
f9715c54 8061bac3 nt!IopRemoveLockedDeviceNode+0x160 (FPO: [Non-Fpo])
f9715c6c 8061bb2f nt!IopDeleteLockedDeviceNode+0x34 (FPO: [Non-Fpo])
f9715ca0 8061d8f6 nt!IopDeleteLockedDeviceNodes+0x3f (FPO: [Non-Fpo])
f9715d34 805ec82d nt!PiProcessQueryRemoveAndEject+0x76b (FPO: [Non-Fpo])
f9715d50 8059fbb1 nt!PiProcessTargetDeviceEvent+0x2a (FPO: [Non-Fpo])
f9715d74 804e426b nt!PiWalkDeviceList+0x122 (FPO: [Non-Fpo])
f9715dac 8057d0f1 nt!ExpWorkerThread+0x100 (FPO: [Non-Fpo])
f9715ddc 804f827a nt!PspSystemThreadStartup+0x34 (FPO: [Non-Fpo])
00000000 00000000 nt!KiThreadStartup+0x16
1 total locks, 1 locks currently held
kd> !locks -v feb10980
Resource @ 0xfeb10980 Shared 1 owning threads
Threads: 8134a473-01<*> *** Actual Thread 8134a470
THREAD 8134a470 Cid 0004.0014 Teb: 00000000 Win32Thread: 00000000 WAIT: (WrQueue) UserMode Non-Alertable
80561640 Unknown
Not impersonating
DeviceMap e1000090
Owning Process 8134a020 Image: System
Wait Start TickCount 186763 Ticks: 3 (0:00:00:00.046)
Context Switch Count 5332
UserTime 00:00:00.0000
KernelTime 00:00:01.0140
Start Address nt!ExpWorkerThread (0x804e4196)
Stack Init f96f6000 Current f96f5d1c Base f96f6000 Limit f96f3000 Call 0
Priority 13 BasePriority 13 PriorityDecrement 0 DecrementCount 16
ChildEBP RetAddr
f96f5d34 804dc0f7 nt!KiSwapContext+0x2e (FPO: [EBP 0xf96f5d6c] [0,0,4])
f96f5d40 804e407e nt!KiSwapThread+0x46 (FPO: [0,0,0])
f96f5d6c 804e423d nt!KeRemoveQueue+0x20e (FPO: [Non-Fpo])
f96f5dac 8057d0f1 nt!ExpWorkerThread+0xd6 (FPO: [Non-Fpo])
f96f5ddc 804f827a nt!PspSystemThreadStartup+0x34 (FPO: [Non-Fpo])
00000000 00000000 nt!KiThreadStartup+0x16
1 total locks, 1 locks currently held
Regards
Call friends with PC-to-PC calling – FREE Try it now!http:
—
NTDEV is sponsored by OSR
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</http:>