[Q]pnp device remove and re-install without reboot

Hello everyone,

I am executing windows driver certification test case which is related with driver uninstall and install cycle. However this case not tolerated with Windows reboot request. I found some logs in the setupapi.app.log same as below;

cmd: cscript.exe “Reinstall_With_IO.wsf” /WDTF /DeviceID:“PCI\VEN_000A&DEV_0001&SUBSYS_00000A&REV_01\3&11583659&0&10” /IOPeriod:20000 /Cycles:3 /logo
! dvi: Query-removal was vetoed by PCI\PCI\VEN_000A&DEV_0001&SUBSYS_00000A&REV_01\3&11583659&0&10 (veto type 5: PNP_VetoOutstandingOpen)
! dvi: Setting needs reboot
! dvi: Query-and-Remove failed: 0x17: CR_REMOVE_VETOED

Driver Unload() function has already frees allocated buffers with IoDeleteDevice() but I am not sure that is enough. So, how can I easily bypass this issue ?

Cheers

Also I collected debug log:

[addr=A4E3CB78] WskProAPIFreeAddressInfo freed addrinfo.
AVRF: cscript.exe: pid 0x16D0: flags 0x80C43266: application verifier enabled
AVRF: verifier.dll provider initialized for cscript.exe with flags 0x80C43266
AVRF: DrvInst.exe: pid 0x1550: flags 0x80C43266: application verifier enabled
AVRF: verifier.dll provider initialized for DrvInst.exe with flags 0x80C43266
CriticalDeviceCoInstaller: DIF_INSTALLDEVICE called

debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_DEVICE_RELATIONS…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_REMOVE_DEVICE…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_CANCEL_REMOVE_DEVICE…CriticalDeviceCoInstaller: DIF_INSTALLDEVICE called
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_DEVICE_RELATIONS…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_REMOVE_DEVICE…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_CANCEL_REMOVE_DEVICE…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device_Trace.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device_Trace.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device_Trace.
DispatchPnP()::IRP_MN_QUERY_CAPABILITIES…
debug: DispatchPnP() for \DosDevices\Device00.
DispatchPnP()::IRP_MN_QUERY_DEVICE_RELATIONS…
debug: DispatchPnP() for \DosDevices\Device_Trace.
DispatchPnP()::IRP_MN_QUERY_DEVICE_RELATIONS…[82A872A8] WskProIRPGetAddrInfo is called

May I handle IRP_MN_QUERY_DEVICE_RELATIONS, IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE and IRP_MN_QUERY_CAPABILITIES ?

You have to handle IRP_MN_QUERY_REMOVE_DEVICE,
IRP_MN_CANCEL_REMOVE_DEVICE, IRP_MN_ REMOVE_DEVICE,
IRP_MN_SURPRISE_REMOVAL. Of course if you are not doing this, the
easiest thing is to throw out the current driver and rewrite it in KMDF.

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:

> May I handle IRP_MN_QUERY_DEVICE_RELATIONS, IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE and IRP_MN_QUERY_CAPABILITIES ?

Hi Don ,

Thanks for your answer.

These IRP’s has no routine it seems in the source file as below;

IoSkipCurrentIrpStackLocation(Irp);
status = IoCallDriver(pdx->pldo, Irp);

That is your problem then. If you are not indicating you can remove the
device correctly, you will fail you test. Take a look at
http://msdn.microsoft.com/en-us/library/windows/hardware/ff546674(v=vs.85).aspx
you have to handle all the stuff they describe.

If you have this as part of your state machine, I urge you to run not
walk to KMDF and throw out the current driver.

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:

> Hi Don ,
>
> Thanks for your answer.
>
> These IRP’s has no routine it seems in the source file as below;
>
> IoSkipCurrentIrpStackLocation(Irp);
> status = IoCallDriver(pdx->pldo, Irp);

xxxxx@gmail.com wrote:

May I handle IRP_MN_QUERY_DEVICE_RELATIONS, IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE and IRP_MN_QUERY_CAPABILITIES ?

That’s not the right question. The question you want to ask is “MUST I
handle…”. The answer to that question is “yes, except for
IRP_MN_QUERY_DEVICE_RELATIONS”.

Have you read any of the documentation?
http://msdn.microsoft.com/en-us/library/windows/hardware/ff558807.aspx

Actually, the right question is “why didn’t you use KMDF?” KMDF handles
these details for you, and does so correctly.


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