I have a weird device mapping problem and need to consult the list.
Actually I really have two problems:
1 - Given the name of a hub, (how) can I use config manager functions to get
the names of the devices connected to it?
2 - Given the name of a device, (how) can I use config manager functions to
get the name of the hub it is connected to?
I am not sure if the config manager even “knows” about device connections to
hubs, etc., or if it just tracks relations between different classes of
devices and their drivers, e.g. a disk drive is a subtype of a usb storage
device is a kind of usb device, etc.
Thanks again
Eric
Configuration manager knows the entire device tree and provides an API to navigate it (see Device Manager’s ability to show devices by connection, and presumably also OSR’s Device Tree utility). The standard hub drivers ought to be reporting the bus topology properly, although I can’t say I’ve checked it, since I haven’t even had a need for an external hub in years. If you’ve got one, use one of those and see if the toplogy is displayed correctly.
Since WdfVerifier potentially takes lists of devices affected by changes to settings for multiple KMDF drivers for the purpose of disabling and enabling them so the changes take effect, and since disabling a bus is going to disable all its children, I had to prune any children out of the list. That means I’ve got recent experience, so I don’t have to worry about remembering it for once:).
Useful tips:
CM_Get_Child, CM_Get_Sibling and CM_Get_Parent are your basic tools (there are _Ex versions if you want to work remotely [which WdfVerifier can also do]).
If you use SetupDi functions in your initial code to find a device of interest, then if you have an SP_DEVINFO_DATA for your device (such as from SetupDiEnumDeviceInfo), the DevInst member is the dhDevInst value passed to the CM_ functions.
I’ve considered posting some of the relevant code from WdfVerifier in my blog, but since it’s not an official sample, there are permissions and advice to be sought [haven’t had time for that]…
But hopefully, this is enough to get you started.
Thank you, Robert, that is very helpful.
I hate to keep pinging you, but I have not been able to find an -overview-
of the CM_*() functions. I found the headers, and OSR has some boilerplate,
but can’t find a web page with the Big Picture. Do you know if it exists?
Thanks
Eric
On Nov 15, 2007 4:58 AM, wrote:
> Configuration manager knows the entire device tree and provides an API to
> navigate it (see Device Manager’s ability to show devices by connection, and
> presumably also OSR’s Device Tree utility). The standard hub drivers ought
> to be reporting the bus topology properly, although I can’t say I’ve checked
> it, since I haven’t even had a need for an external hub in years. If you’ve
> got one, use one of those and see if the toplogy is displayed correctly.
>
> Since WdfVerifier potentially takes lists of devices affected by changes
> to settings for multiple KMDF drivers for the purpose of disabling and
> enabling them so the changes take effect, and since disabling a bus is going
> to disable all its children, I had to prune any children out of the list.
> That means I’ve got recent experience, so I don’t have to worry about
> remembering it for once:).
>
> Useful tips:
>
> CM_Get_Child, CM_Get_Sibling and CM_Get_Parent are your basic tools (there
> are Ex versions if you want to work remotely [which WdfVerifier can also
> do]).
>
> If you use SetupDi functions in your initial code to find a device of
> interest, then if you have an SP_DEVINFO_DATA for your device (such as from
> SetupDiEnumDeviceInfo), the DevInst member is the dhDevInst value passed to
> the CM functions.
>
> I’ve considered posting some of the relevant code from WdfVerifier in my
> blog, but since it’s not an official sample, there are permissions and
> advice to be sought [haven’t had time for that]…
>
> But hopefully, this is enough to get you started.
>
> —
> 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
>
Eric Fowler wrote:
I hate to keep pinging you, but I have not been able to find an
-overview- of the CM_*() functions. I found the headers, and
OSR has some boilerplate, but can’t find a web page with the
Big Picture. Do you know if it exists?
http://msdn2.microsoft.com/en-us/library/ms790838.aspx
I have not been able to find an -overview-
of the CM_*() functions.
There’s no really good overview I know of- they’re really old (I remember using them [hope it was them] on Win95 in the pre-WDM days when CM was 16-bit), and most of the function can be done at a higher level with SetupDi (which is basically built on top of these, whch is why so many are documented “don’t call this”).
I think some of the older DDKs had a bit more documentation on them, but it’s always been sketchy.
> There’s no really good overview I know of- they’re really old (I remember using them [hope it was them] on Win95 in the pre-WDM days when CM was 16-bit), and most of the function can be done at a higher level with SetupDi (which is basically built on top of these, whch is why so many are documented “don’t call this”).
Really? I always thought CM functions were replaced by SetupDi calls because weren’t obscure enough 
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
Look at the UsbView application in the WDK. This maps the entire USB
device tree. It is the best documentation I know of for how to do this
stuff.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@microsoft.com
Sent: Thursday, November 15, 2007 3:49 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Mapping devices to hubs using configuration manager
functions
I have not been able to find an -overview-
of the CM_*() functions.
There’s no really good overview I know of- they’re really old (I
remember using them [hope it was them] on Win95 in the pre-WDM days when
CM was 16-bit), and most of the function can be done at a higher level
with SetupDi (which is basically built on top of these, whch is why so
many are documented “don’t call this”).
I think some of the older DDKs had a bit more documentation on them, but
it’s always been sketchy.
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
From what I know, SetupDiXxx are based on CM_xxx, and are not the complete
replacement for the latter, since some CM_xxx have no SetupDiXxx counterparts.
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
“Michal Vodicka” wrote in message news:xxxxx@ntdev…
> There’s no really good overview I know of- they’re really old (I remember
using them [hope it was them] on Win95 in the pre-WDM days when CM was 16-bit),
and most of the function can be done at a higher level with SetupDi (which is
basically built on top of these, whch is why so many are documented “don’t call
this”).
>
Really? I always thought CM functions were replaced by SetupDi calls because
weren’t obscure enough 
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
Eeek! I’m back!
All is well, but I am stumped on this:
Given the name of a device, how can I get the devnode?
For example, I have something that looks like this, that came in from
device change notification:
“\?\USB#Vid_0547&Pid_1002#6&37364359&0&3#{a5dcbf10-6530-11d2-901f-00c04fb951ed}”
And need to get the dnDevInst param to feed to this guy:
CMAPI CONFIGRET WINAPI
CM_Get_Parent(
OUT PDEVINST pdnDevInst,
IN DEVINST dnDevInst,
IN ULONG ulFlags
);
How can I get that? I am stumped.
Thanks
Eric
On Nov 16, 2007 5:30 AM, Maxim S. Shatskih wrote:
> From what I know, SetupDiXxx are based on CM_xxx, and are not the complete
> replacement for the latter, since some CM_xxx have no SetupDiXxx counterparts.
>
> –
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> “Michal Vodicka” wrote in message news:xxxxx@ntdev…
>
> > There’s no really good overview I know of- they’re really old (I remember
> using them [hope it was them] on Win95 in the pre-WDM days when CM was 16-bit),
> and most of the function can be done at a higher level with SetupDi (which is
> basically built on top of these, whch is why so many are documented “don’t call
> this”).
> >
>
> Really? I always thought CM functions were replaced by SetupDi calls because
> weren’t obscure enough 
>
> Best regards,
>
> Michal Vodicka
> UPEK, Inc.
> [xxxxx@upek.com, http://www.upek.com]
>
>
> —
>
>
>
> 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
>
Eric Fowler wrote:
Eeek! I’m back!
All is well, but I am stumped on this:
Given the name of a device, how can I get the devnode?
For example, I have something that looks like this, that came in from
device change notification:
“\?\USB#Vid_0547&Pid_1002#6&37364359&0&3#{a5dcbf10-6530-11d2-901f-00c04fb951ed}”
And need to get the dnDevInst param to feed to this guy:
CMAPI CONFIGRET WINAPI
CM_Get_Parent(
OUT PDEVINST pdnDevInst,
IN DEVINST dnDevInst,
IN ULONG ulFlags
);
How can I get that? I am stumped.
See the devcon source code for an example of how to enumerate all of the
devices in the USB device class (which is what a5dcbf10-6530-etc is)
using the SetupDi APIs. Check “devcon listclass usb” to see what you
need to do. It’s GUID_DEVINTERFACE_USB_DEVICE.
Once you have an SP_DEVINFO_DATA, you can fetch the P&P name and compare
it to what you have, and that structure gives you the DEVINST.
Also, don’t forget that you have to change the VID and PID to one for
you own company before shipping. You can’t use the Cypress default VID
and PID in a production device.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
It’s me again.
Now I have a DevInst that I got back from a call to CM_Get_Parent().
Now I want an HDEVINFO that I can use in the SetupDi*() functions to
fish for (among other things) the name of the device.
And, as usual, I am stuck.
Anyone know this off the top of his head?
Thanks again.
Eric
On Nov 19, 2007 4:52 PM, Tim Roberts wrote:
> Eric Fowler wrote:
> > Eeek! I’m back!
> >
> > All is well, but I am stumped on this:
> > Given the name of a device, how can I get the devnode?
> >
> > For example, I have something that looks like this, that came in from
> > device change notification:
> > “\?\USB#Vid_0547&Pid_1002#6&37364359&0&3#{a5dcbf10-6530-11d2-901f-00c04fb951ed}”
> >
> > And need to get the dnDevInst param to feed to this guy:
> >
> > CMAPI CONFIGRET WINAPI
> > CM_Get_Parent(
> > OUT PDEVINST pdnDevInst,
> > IN DEVINST dnDevInst,
> > IN ULONG ulFlags
> > );
> >
> > How can I get that? I am stumped.
> >
>
> See the devcon source code for an example of how to enumerate all of the
> devices in the USB device class (which is what a5dcbf10-6530-etc is)
> using the SetupDi APIs. Check “devcon listclass usb” to see what you
> need to do. It’s GUID_DEVINTERFACE_USB_DEVICE.
>
> Once you have an SP_DEVINFO_DATA, you can fetch the P&P name and compare
> it to what you have, and that structure gives you the DEVINST.
>
> Also, don’t forget that you have to change the VID and PID to one for
> you own company before shipping. You can’t use the Cypress default VID
> and PID in a production device.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
>
> —
> 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
>