virtualization layer for apps cont'd....

Hi all,

With reference to the previous thread http://www.osronline.com/showthread.cfm?link=261944

We have some queries on device instance id.

We have connected two device with same VID and PID and also tried with different VID PID to the PC and driver loaded (KMDF USB VCP), and when we tried unplugging and connected back to same respective USB ports, and repeating these steps 4 to 5 times, the instance id of the devices are getting changed and sometimes even COM Port numbers also changed.

Currently based on the device instance id, we are routing the request to the device obj and using control device object

Curious to know the reason for change in the value of device instance id

Or is there any unique way to identify the device apart from the device serial number.

Thanks in advance.

There’s no reason to believe the device instance ID would be the same from one session to the next, or after a device is unplugged and plugged-in.

The only thing you can say about the instance ID is that it is unique among all devices of its type (or on the specific bus, depending on the bus driver) currently in existence. HOW a bus driver assigns instance IDs is entirely a function of the bus driver, and is generally a matter of implementation and not of architecture. Some drivers just have a global value they increment for each device that they find and use that…

Peter
OSR
@OSRDrivers

xxxxx@gmail.com wrote:

We have some queries on device instance id.

We have connected two device with same VID and PID and also tried with different VID PID to the PC and driver loaded (KMDF USB VCP), and when we tried unplugging and connected back to same respective USB ports, and repeating these steps 4 to 5 times, the instance id of the devices are getting changed and sometimes even COM Port numbers also changed.

I don’t expect the instance ID to change. For a device without a serial
number, a single VID, PID, slot and hub combination should get the same
ID each time. Can you show us some real-life examples?

The COM port thing is more complicated. If there is but one dangling
request that prevents the previous COM port from closing and cleaning
up, then the new device will have to use a new number.

Or is there any unique way to identify the device apart from the device serial number.

How would you do that? Without serial numbers, there is simply no way
to tell them apart.


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

Thanks Peter, Tim.

@Tim
Here are the values of changed Instance Ids

old
??\USB#VID_1123&PID_0912#0123456?789ABCD#{a5dcbf10-65?30-11d2-901f-00c04fb?951ed}
new
??\USB#VID_1123&PID_0912#6&6f1b3ab&0&3#{a5dcbf10-6530?-11d2-901f-00c04fb95?1ed}

Based on the instance id, we are changing the file name and the part of the Code snippet

// Copy the device instance id to file name during DeviceFileCreate;

PIO_STACK_LOCATION irpStack = IoGetCurrentIrpStackLocation(Irp);
PFILE_OBJECT fileObject = irpStack->FileObject;

RtlUnicodeStrin?gCopy(&fileObject->FileName, &DevinstanceId);

// Compare the device instance id and file name before forwarding the request.

(RtlCompareUnic?odeString(&fileObject->FileName, &getTargetDO[Index].TargetInstanceId, TRUE) == 0)

> Based on the instance id, we are changing the file name

Why not use PnP devinterfaces? it is the same, but implemented by the kernel itself and you’re free from the gory details.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

xxxxx@gmail.com wrote:

@Tim
Here are the values of changed Instance Ids

old
??\USB#VID_1123&PID_0912#0123456?789ABCD#{a5dcbf10-65?30-11d2-901f-00c04fb?951ed}
new
??\USB#VID_1123&PID_0912#6&6f1b3ab&0&3#{a5dcbf10-6530?-11d2-901f-00c04fb95?1ed}

Based on the instance id, we are changing the file name and the part of the Code snippet

That suggests the system was unable to read the serial number in the new
device. Does your device take a long time to initialize?


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

>Why not use PnP devinterfaces? it is the same, but implemented by the kernel
itself and you’re free from the gory details.

These names ARE devinterfaces.