[UMDF] Maintain properties while device is unplugged

Hello again.

I’m still developing UMDF USB driver (including virtual COM port) for Windows 7 64 bit and there are some uncertainties about nontransient registry access in UMDF. At last for me.

I have a config application, where all of our connected USB devices are shown. These devices are differentiated by a special hardware ID, which are unique for every device from our company. You can add/change/delete properties of a hardware ID. These properties have to be stored in a persistent way, so that a device can be unplugged anytime and can read its configuration (dependend on its hardware ID) when it is plugged in again. In short, we need a place in the registry, where information concerning a special device is stored and not deleted, when the device is unplugged from host.

Our older WDM driver and the former config app had wide access to registry and there was no problem. In UMDF I have only “RetrieveDevicePropertyStore”, which supports four special paths in the registry. Hardware and device interface keys are not persistent for absent devices. DEVICEMAP key is an older key and for the serial/parallel devices, which should not be used (even to think about compatibility).

So there is only the “software key”. I tried to get readable access to this key in the UMDF driver and it worked fine. The problem is now to get the path to the key from inside the configuration application (which is a normal windows MFC 64 bit application). SetupDiCreateDevRegKey/SetupDiOpenDevRegKey (with DIREG_DRV) work fine, as long as there is at last ONE device connected. If not, there is no possibility to fill the needed PSP_DEVINFO_DATA structure.

Questions:

  1. Is there a clean way to store device specific properties, which stay intact, even if the device is unplugged and can be accessed in a general way from the UMDF driver and from an outer application?

  2. If it is correct, as i did it for know, how can I get the registry path to the driver from an application?

Many thanks in advance,
Tristan.

Why do you believe that the hardware key isn’t persistent across unplug/replug? Do your devices not implement serial numbers?

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ifak-system.com
Sent: Wednesday, November 09, 2011 7:17 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] [UMDF] Maintain properties while device is unplugged

Hello again.

I’m still developing UMDF USB driver (including virtual COM port) for Windows 7 64 bit and there are some uncertainties about nontransient registry access in UMDF. At last for me.

I have a config application, where all of our connected USB devices are shown. These devices are differentiated by a special hardware ID, which are unique for every device from our company. You can add/change/delete properties of a hardware ID. These properties have to be stored in a persistent way, so that a device can be unplugged anytime and can read its configuration (dependend on its hardware ID) when it is plugged in again. In short, we need a place in the registry, where information concerning a special device is stored and not deleted, when the device is unplugged from host.

Our older WDM driver and the former config app had wide access to registry and there was no problem. In UMDF I have only “RetrieveDevicePropertyStore”, which supports four special paths in the registry. Hardware and device interface keys are not persistent for absent devices. DEVICEMAP key is an older key and for the serial/parallel devices, which should not be used (even to think about compatibility).

So there is only the “software key”. I tried to get readable access to this key in the UMDF driver and it worked fine. The problem is now to get the path to the key from inside the configuration application (which is a normal windows MFC 64 bit application). SetupDiCreateDevRegKey/SetupDiOpenDevRegKey (with DIREG_DRV) work fine, as long as there is at last ONE device connected. If not, there is no possibility to fill the needed PSP_DEVINFO_DATA structure.

Questions:

  1. Is there a clean way to store device specific properties, which stay intact, even if the device is unplugged and can be accessed in a general way from the UMDF driver and from an outer application?

  2. If it is correct, as i did it for know, how can I get the registry path to the driver from an application?

Many thanks in advance,
Tristan.


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

Thank you for your help, Peter.

[Why do you believe that the hardware key isn’t persistent across unplug/replug?]

My fault, sorry. I thought, the keys would at least gone, when the system restarts. It was not imaginable for me, because some of our customers have hundreds devices in use in a plant, so I didn’t thought, that the registry would be grown so much. (And I think also of our test computer, where all devices pass the last test). But it really makes sense, how else should be the system know, that this device is already installed.

[Do your devices not implement serial numbers?]

Sadly not. I am the driver developer and have not much to do with the hardware development. After quick test with the USB view app from wdk I have to admit, that we have neither a product string index, nor a vendor string index and not even a serial number string index in the device descriptor (all bytes ar zero).

Because we have of course a hardware ID, but inside the USB device (and only available throug special DeviceControlIO functions) we can provide unique registry keys for every device. But we need a persistent place in the registry, which both, the USB device and the configuration application, can access. Exists such a location? Or do you have another suggestion?

Many thanks,
Tristan.

> Sadly not. I am the driver developer and have not much to do with the hardware development.

First trace of the failed mismanaged project.

Hardware is not developed in itself. It is developed for the OS. So, driver developer must participate in HW development from the beginning.

Yes, it is possible to create Windows-incompatible hardware and scenarios. Nothing fancy.

Let’s look at concepts level. If you have no ways to unique identify the device - then how can you store per-device data? what value will be the key for this data store?

And, if you have some special non-standard ways (via IOCTL or such) - then go away from UMDF with all of this, maintain the per-device database in the app itself, and, from the app, do the following:

  • device arrived
  • get its ID via your IOCTL
  • lookup the database entry and load its data
  • apply this data to the device by more IOCTLs, thus completing its initialization.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

A hardware ID is supposed to be used to determine the type of device, not which device this is. For USB devices a serial number would let the system know which device this is, and would allow the configuration settings under the hardware key to follow it as it gets plugged into various ports on the system.

Other than the hardware key there’s not really a suitable key in the system now. You would need to create one. Have your installer create a registry key under HKLM that is writable by LocalService and you can store the settings under there. You will need to trust other LocalService services not to muck with those settings.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@ifak-system.com
Sent: Wednesday, November 09, 2011 11:53 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] [UMDF] Maintain properties while device is unplugged

Thank you for your help, Peter.

[Why do you believe that the hardware key isn’t persistent across unplug/replug?]

My fault, sorry. I thought, the keys would at least gone, when the system restarts. It was not imaginable for me, because some of our customers have hundreds devices in use in a plant, so I didn’t thought, that the registry would be grown so much. (And I think also of our test computer, where all devices pass the last test). But it really makes sense, how else should be the system know, that this device is already installed.

[Do your devices not implement serial numbers?]

Sadly not. I am the driver developer and have not much to do with the hardware development. After quick test with the USB view app from wdk I have to admit, that we have neither a product string index, nor a vendor string index and not even a serial number string index in the device descriptor (all bytes ar zero).

Because we have of course a hardware ID, but inside the USB device (and only available throug special DeviceControlIO functions) we can provide unique registry keys for every device. But we need a persistent place in the registry, which both, the USB device and the configuration application, can access. Exists such a location? Or do you have another suggestion?

Many thanks,
Tristan.


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