While the sample might check for the dev caps in the add device routine, that means that it is sending its on IRP w/its own dev caps to the PDO. For this to work, you must do this for a query capabilities that the PNP subsystem sends you (ie set the completion routine when you receive the appropriate PNP irp from above and then set the value in the completion routine then).
As for the query remove, you will get a query remove when you disable or uninstall the device from device manager. Furthermore, if you are not surprise removalable, you will also get a query remove from the hot unplug applet if you bring it up and try to manually “stop” a device (which is different then a PNP query stop / stop which is a resource rebalance).
You don’t get the remove device until all outstanding create files have been closed, you can register for pnp notifications and do this properly in your app via the same API you used to register for device interface notifications.
d
-----Original Message-----
From: HyungJune Kim [mailto:xxxxx@hynix.com]
Sent: Wednesday, July 10, 2002 3:44 AM
To: NT Developers Interest List
Subject: [ntdev] Re: W2K’s BulkUsb example causes an error when disconnect a device
Thanks for answers!
I modified the code as your instruction.
In the W2k’s BulkUsb example, the driver checks the DeviceCapabilities in AddDevice routine.
I modify the completion routine as follow.
{
PDEVICE_EXTENSION dx = context;
dx->DeviceCapabilities.SurpriseRemovalOK = TRUE;
KeSetEvent(&dx->EventDevCap, 1, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
The flag is set correctly, but when I disconnect the device Windows2000 still
tells the warning message “the device removal is not safe. You should stop the device before
removing”.
Also, as disconneting, pnp routine is called in the order of IRP_MN_SURPRISE_REMOVAL -> IRP_MN_REMOVE, but isn’t called IRP_MN_QUERY_REMOVE. Is this right?
When does IRP_MN_QUERY_REMOVE? Is this related to above warning message?
Thanks in advance!
Best Regards,
HyungJune Kim
----- Original Message -----
From: “Bill McKenzie”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Wednesday, July 10, 2002 2:13 PM
Subject: [ntdev] Re: W2K’s BulkUsb example causes an error when disconnect a device
> Do NOT bother setting the SurpriseRemovalOK field to TRUE in your dispatch
> routine, as this will do nothing. Rather, stick a completion routine in the
> IRP, and in your completion routine set the SurpriseRemovalOK field to TRUE.
> This is a bug in the USB stack in that the USB bus drivers do not check this
> field to see what is set by higher drivers in the stack.
>
> Also, this sample could be better. One thing you should definitely consider
> is using a lookaside list for the URBs you allocate memory for in your
> driver. This list will minimize fragmention of NonPagedPool memory caused
> by your driver.
>
> –
> Bill McKenzie
>
>
>
> “Doron Holan” wrote in message
> news:xxxxx@ntdev…
>
> When you get the query device capabilities irp in your PNP dispatch routine,
> set the SurpriseRemovalOK field to TRUE. This indicates that the device
> need not be stopped before hot removing it.
>
> D
>
> This posting is provided “AS IS” with no warranties, and confers no rights.
>
> -----Original Message-----
> From: HyungJune Kim [mailto:xxxxx@hynix.com]
> Sent: Tuesday, July 09, 2002 2:58 AM
> To: NT Developers Interest List
> Subject: [ntdev] W2K’s BulkUsb example causes an error when disconnect a
> device
>
> Hi Guru,
>
> I have a USB device which transfers data in BULK mode.
>
> I use W2K DDK’s “bulkusb” example.
>
> The problem is
> when I disconnect the device, following error message always occurrs.
>
> “You removed a device without stopping. You should stop the device
> before remove.”
>
> So I haven’t seen PnP for this device.
>
> I didn’t modify the source.
> I’m wondering if the “bulkusb” example has bugs.
>
> If you know why, please let me know.
> Any help would be appreciated!
>
> Regards,
> HyungJune Kim
>
>
>
>
>
> b???v?j???r???i?j??u??
>
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@hynix.com
> To unsubscribe send a blank email to %%email.unsub%%
>
>
b???v?j???r???i?j??u?