Dealing with add hardware wizard delays

I have a bus driver that creates virtual disks. A disk is created when the aplication sends an ioctl to the bus. The function that wraps the drive creation returns a handle to the new drive. Since the process of creating the drive is asynchronous and takes some time, I loop on CreateFile every second and then time out after 10 seconds. The drives are enumerated as bus\drive1, bus\drive2… etc. the first time a numbered device is enumerated, the add hardware wizard is invoked. Unless you’re real fast, the 10 second timeout expires - which is undesirable. Is there any way to tell if the add hardware wizard is active from a user mode app? How should I correctly be dealing with this?

You should be dealinmg with this by splitting the functionality of the function apart. The function should continue to request the disk be created and then the caller should asynchronously be notified if and when the disk appears via registerdevicenotification

d

tiny phone keyboard + fat thumbs = you do the muth

-----Original Message-----
From: xxxxx@hotmail.com
Sent: Friday, January 15, 2010 4:16 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Dealing with add hardware wizard delays

I have a bus driver that creates virtual disks. A disk is created when the aplication sends an ioctl to the bus. The function that wraps the drive creation returns a handle to the new drive. Since the process of creating the drive is asynchronous and takes some time, I loop on CreateFile every second and then time out after 10 seconds. The drives are enumerated as bus\drive1, bus\drive2… etc. the first time a numbered device is enumerated, the add hardware wizard is invoked. Unless you’re real fast, the 10 second timeout expires - which is undesirable. Is there any way to tell if the add hardware wizard is active from a user mode app? How should I correctly be dealing with this?


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

Doron, that’s really somewhat of a braindead idea and I would have expected more out of a Microsoft architect

Just kidding! haha! of course - async operation should have async processing… thanks for the info!

>

I have a bus driver that creates virtual disks. A disk is created
when the
aplication sends an ioctl to the bus. The function that wraps the
drive
creation returns a handle to the new drive. Since the process of
creating the
drive is asynchronous and takes some time, I loop on CreateFile every
second
and then time out after 10 seconds. The drives are enumerated as
bus\drive1,
bus\drive2… etc. the first time a numbered device is enumerated,
the add
hardware wizard is invoked. Unless you’re real fast, the 10 second
timeout
expires - which is undesirable. Is there any way to tell if the add
hardware
wizard is active from a user mode app? How should I correctly be
dealing with
this?

I had a similar problem just recently and someone suggested a call to
CMP_WaitNoPendingInstallEvents which worked perfectly.

In my case, I check if my device exists yet (via wmi), and if it doesn’t
I wait until it does, then I call CMP_WaitNoPendingInstallEvents to make
sure the wizard stuff is all complete before moving on.

James

While Doron’s idea is really the right way to do it, as time is short and the operation is generally very quick, CMP_WaitNoPendingInstallEvents is perfect - thank you James.