Hello.
I have a driver which manages volumes of fixed disks and removable media (USB stick).
I have done some tests on both WinXP and Windows Server 2003.
On XP my driver’s AddDevice() is called only one time when USB stick is inserted.
But on Win2003, my driver’s AddDevice() is called 2 or 3 times for a volume. This is noticed only when USB stick is inserted the first time. I mean when Windows is detecting the device and installing driver. When I reinsert USB stick, everything is OK.
My application does not work correctly for first time inserted USB stick.
Do you have ideas what the reason can be ?
Thank you…
What is your driver? A disk class upper or lower filter? And how your
application talks to your driver? I mean what is your application is used
for?
On Thu, Sep 17, 2009 at 5:28 AM, wrote:
> Hello.
> I have a driver which manages volumes of fixed disks and removable media
> (USB stick).
> I have done some tests on both WinXP and Windows Server 2003.
>
> On XP my driver’s AddDevice() is called only one time when USB stick is
> inserted.
>
> But on Win2003, my driver’s AddDevice() is called 2 or 3 times for a
> volume. This is noticed only when USB stick is inserted the first time. I
> mean when Windows is detecting the device and installing driver. When I
> reinsert USB stick, everything is OK.
> My application does not work correctly for first time inserted USB stick.
>
> Do you have ideas what the reason can be ?
>
> Thank you…
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
> What is your driver? A disk class upper or lower filter?
It is an upper filter for DiskDrive class also a lower filter for Volume class.
And how your application talks to your driver? I mean what is your application is used
for?
One thread in my application waits for notifications from my driver about new volumes (Using a Pending IOCTL for Notification). So if AddDevice() is called twice, my application gets two new volumes with names :
\Device\Harddisk1\DP(1)0-0+3
\Device\Harddisk1\DP(1)0-0+5
But in real there is only one volume.
The application is for encryption/decryption.
So you registered you driver as both disk class upper filter and volume
class lower filter. I was doing full disk encryption before at disk class
upper filter. I never met that problem before. I need to do some test on
Windows server 2003.
On Fri, Sep 18, 2009 at 12:47 AM, wrote:
> > What is your driver? A disk class upper or lower filter?
> It is an upper filter for DiskDrive class also a lower filter for Volume
> class.
>
> > And how your application talks to your driver? I mean what is your
> application is used
> > for?
> One thread in my application waits for notifications from my driver about
> new volumes (Using a Pending IOCTL for Notification). So if AddDevice() is
> called twice, my application gets two new volumes with names :
> \Device\Harddisk1\DP(1)0-0+3
> \Device\Harddisk1\DP(1)0-0+5
>
> But in real there is only one volume.
>
> The application is for encryption/decryption.
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
Thank you very much… I hope you can reproduce this issue.
Another thing. Your application is just waiting for new volume rather than
new disk,right? Why you don’t want to do this in user mode by using the
SetupApiXXX? Is that possible that you can trigger that notification from
you disk class upper filter AddDevice() routine?
On Fri, Sep 18, 2009 at 9:05 AM, wrote:
> Thank you very much… I hope you can reproduce this issue.
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
The problem is not in user mode, it is in kernel mode. My driver detects two volumes instead of one.
No, my application also waits for disks.
On XP I get two AddDevice()s for disk and one for volume. But in 2003 I get one for disk, one for volume, then one more for disk, one for volume
What I mean is that you need to think about a better way to do this. What
you’ll do if that is the truth? You need to find a solution for this.
On Fri, Sep 18, 2009 at 10:13 AM, wrote:
> On XP I get two AddDevice()s for disk and one for volume. But in 2003 I get
> one for disk, one for volume, then one more for disk, one for volume
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars
> (including our new fs mini-filter seminar) 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
>
I haven’t seen any article about USB problem in Win2003 SP2, so I think problem in my driver.
I think I have found the root of the problem. It is caused by PnP device enumeration :
http://msdn.microsoft.com/en-us/library/ms798217.aspx#b19312fe-4dea-4e3b-912c-6b9e75600ffa
My driver gets this cycle :
AddDevice() -> IRP_MN_START_DEVICE -> IRP_MN_QUERY_REMOVE_DEVICE -> IRP_MN_QUERY_REMOVE_DEVICE -> AddDevice() -> IRP_MN_START_DEVICE.
Is there any pattern for determining the last invocation of AddDevice() ?
Thank you…
I have added this snip of code at the beginning of my AddDevice() routine :
DEVICE_INSTALL_STATE devInstState;
ULONG resultLength;
status = IoGetDeviceProperty(PhysicalDeviceObject,DevicePropertyInstallState,sizeof(DEVICE_INSTALL_STATE),(void*)(&devInstState),&resultLength);
if (NT_SUCCESS(status) && (devInstState == InstallStateFinishInstall))
{
DbgPrint(“ByPass… \n”);
return STATUS_SUCCESS;
}
And now my driver works correctly.