Writing the device Co-installer.

Hi, i am newbie in windows device drivers.

we have usb driver which is generating three virtual port(creating three
PDO’s), resulting in creating three com port (COMX) in device manager along
with our device friendly name.
Like XXXserial virtual port(COM5), XXXserial virtual port(COM4), XXXserial
virtual port(COM6).
we have multiport serial adaptor class and ports class in device manager.
similarly like EDGE port drivers.like one is parent driver and another
child drivers.

now my problem is what ever com ports got allocated for my device is not
sequential with ports in device side(firmware).

i have google it and found, which port got enumerated first that will get
the first freed port number from the COMDB. is it like that?

in order to reslove this issue i decided to write coinstaller and started
implementing the coinstaller.

i am able get COMX numbers and firm ware port numbers whiile including the
coinstaller to child drivers .inf file . where as if included the
coinstaller to parent drivers .inf file the api’s returning failures.

Can some one help me in implementation of coinstaller. so that i can get
the all COMports and reallocate the COM ports in sequential manner ?

thanks in advance.

The coinstaller would have to be for each child. Basically for each one you would have to look at the siblings and see if they have a com port number, and if so, grab the next one. Are you saying that the com port numbers being assigned are not sequential? As the only thing being installed, your ports will get the next three numbers and assuming there aren’t holes in the map, they will be sequential. Are you seeing the issue in your lab/testing or in the field? In the lab with many install/uninstalls as you develop the driver you can easily fragment the allocated map and see this problem normal users don’t see it though.

Get Outlook for Androidhttps:

On Mon, Sep 12, 2016 at 8:50 AM -0700, “johnny basha” > wrote:

Hi, i am newbie in windows device drivers.

we have usb driver which is generating three virtual port(creating three PDO’s), resulting in creating three com port (COMX) in device manager along with our device friendly name.
Like XXXserial virtual port(COM5), XXXserial virtual port(COM4), XXXserial virtual port(COM6).
we have multiport serial adaptor class and ports class in device manager. similarly like EDGE port drivers.like one is parent driver and another child drivers.

now my problem is what ever com ports got allocated for my device is not sequential with ports in device side(firmware).

i have google it and found, which port got enumerated first that will get the first freed port number from the COMDB. is it like that?

in order to reslove this issue i decided to write coinstaller and started implementing the coinstaller.

i am able get COMX numbers and firm ware port numbers whiile including the coinstaller to child drivers .inf file . where as if included the coinstaller to parent drivers .inf file the api’s returning failures.

Can some one help me in implementation of coinstaller. so that i can get the all COMports and reallocate the COM ports in sequential manner ?

thanks in advance.

— NTDEV is sponsored by OSR Visit the list online at: MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at To unsubscribe, visit the List Server section of OSR Online at</https:>

hi Doron ,

i have written only one co-installer and added to the child driver’s .inf, the coinstaller getting invoked three times and able to get the COMX numbers of the serial ports.

can u please provide more clarity or information on how to look for siblings any api or any information for that or any links.

here i mean the sequential means, we have a device with RTOS running. when we connect the device with any of applications(like hyperternimal or terra term) it shows some port numbers in device side to which port we connected with respect to device.

For example pc generated the three ports like 3,4,5 and i connected the port 3 with terra term,then the port from the device side it is showing like we are connected to USB2.

now i want ports numbers needed to be generated like port3—USB1,port4—USB2,port5-USB3.
port3,port4,port5 are the pc side ports where as USB1,USB2,USB3 are the device side ports.

i have seen the device side ports numbers are also stored in the registry, so i thought we can do some thing to solve the problem and started working on coinstaller.

i have seen this issue in many of the pc 's not only in test machines.

am i going in right way? is there any solution for this? please suggest me since i am newbie in windows device drivers.
thanks in advances.

Device side port numbers is something completely private to your device. The OS has no idea about them. If they are written in the registry, it is most likely your driver writing them there The ports class installer only writes out the PC side name.

So I think by sequential you mean order of install. USB1 gets the first com port number, USB2 next, USB3 last. Pnp doesn’t provide any ordering guarantees, so the same advice as before applies. Each child install needs to figure out which device it is and where it is in the order. You can find sibling devices with CM_xxx APIs (config manager)

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, September 14, 2016 8:38 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Writing the device Co-installer.

hi Doron ,

i have written only one co-installer and added to the child driver’s .inf, the coinstaller getting invoked three times and able to get the COMX numbers of the serial ports.

can u please provide more clarity or information on how to look for siblings any api or any information for that or any links.

here i mean the sequential means, we have a device with RTOS running. when we connect the device with any of applications(like hyperternimal or terra term) it shows some port numbers in device side to which port we connected with respect to device.

For example pc generated the three ports like 3,4,5 and i connected the port 3 with terra term,then the port from the device side it is showing like we are connected to USB2.

now i want ports numbers needed to be generated like port3—USB1,port4—USB2,port5-USB3.
port3,port4,port5 are the pc side ports where as USB1,USB2,USB3 are the device side ports.

i have seen the device side ports numbers are also stored in the registry, so i thought we can do some thing to solve the problem and started working on coinstaller.

i have seen this issue in many of the pc 's not only in test machines.

am i going in right way? is there any solution for this? please suggest me since i am newbie in windows device drivers.
thanks in advances.


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:>

Hi Doron thank u for your valuable information .

i have used the CM_xxx Api to get the siblings of the virtual serial ports and successfully got the instance path of the all virtual ports. but i was failed in getting the port names(COMXX) of the virtual ports.

here i am copying the small part of my code find the com port of the first sibling.please let me know if i have done any mistakes.

status=CM_Get_Device_ID(DeviceInfoData>DevInst,szDeviceInstanceID,sizeof(szDeviceInstanceID),0); //from here got first child instance path.(o/p:szDeviceInstanceID=NGPSUSB\USBPORT-115\7&2A8C7356&1&USB_1)

status=CM_Get_Sibling(&pdnDevInstNext,DeviceInfoData>DevInst,0);
if (status != CR_SUCCESS){
DbgOut(“cm get sibling failed”);
}
status=CM_Get_Device_ID(pdnDevInst,szDeviceInstanceID2,sizeof(szDeviceInstanceID2),0);
if (status != CR_SUCCESS){
DbgOut(“cm get sibling device id failed”);}// got first sibling instance path.(o/p:szDeviceInstanceID2=NGPSUSB\USBPORT-115\7&2A8C7356&1&USB_2)

hDevInfo = SetupDiCreateDeviceInfoList( NULL, NULL );
if ( hDevInfo == INVALID_HANDLE_VALUE )
{
DbgOut(“empty list fail”);
//return cstrParameterValue;
}
stInterfaceData1.cbSize = sizeof(stInterfaceData1);

if ( SetupDiOpenDeviceInterface ( hDevInfo, szDeviceInstanceID2, 0, &stInterfaceData1 ) )
{
stDevData.cbSize = sizeof(stDevData);

if ( SetupDiGetDeviceInterfaceDetail ( hDevInfo, &stInterfaceData1, NULL, 0, NULL, &stDevData ) || GetLastError() == ERROR_INSUFFICIENT_BUFFER )
{
HKEY hRegKey = SetupDiOpenDevRegKey ( hDevInfo, &stDevData, DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ );
if ( hRegKey != INVALID_HANDLE_VALUE )
{

ZeroMemory ( szParameterBuffer, dwLength );

if ( RegQueryValueEx ( hRegKey, m_szPortName, NULL, &dwType, (LPBYTE)szParameterBuffer, &dwLength ) == ERROR_SUCCESS ){
OutputDebugString(szParameterBuffer);
}
RegCloseKey ( hRegKey );
}
}
else{DbgOut(“get device interface failed”);}

}
else{DbgOut(“open device interface failed”);
sprintf(debugbuf,“%d”,GetLastError());
OutputDebugString(debugbuf);
}

// Destroy the device information set

SetupDiDestroyDeviceInfoList ( hDevInfo );

}

here SetupDiOpenDeviceInterface APi failed with error number 161. this error saying that “bad path”. but i gave what ever path as i got. is it there any api which will work for me?

i am not getting how to proceed further. can some one help me to implement in this.

thank you in advance.