Which hub is the USB device plugged-in?

All,

I have a USB filter driver and hope to know the hub information (such as
DevicePropertyHardwareID: (USB\ROOT_HUB&VID8086&PID24DE&REV0002)) under
which this device is connected. Can anyone advise how to get such
information in the context of a filter driver?

Best Regards,
Raymond

You could try:

0: kd> !drvobj usbhub
Driver object (88ca6550) is for:
\Driver\usbhub
Driver Extension List: (id , addr)

Device Object list:
88ca3b50

Then do a !devstack on every Device Object found

0: kd> !devstack 88ca3b50
!DevObj !DrvObj !DevExt ObjectName

88ca3b50 \Driver\usbhub 88ca3c08 0000001f
88d23610 \Driver\openhci 88d236c8 USBPDO-0
!DevNode 88ca6628 :
DeviceInst is “USB\ROOT_HUB\4&af5358c&0”
ServiceName is “usbhub”

Daniel

From: “Zhang, Raymond”
>Reply-To: “Kernel Debugging Interest List”
>To: “Kernel Debugging Interest List”
>Subject: [windbg] Which hub is the USB device plugged-in?
>Date: Mon, 14 Feb 2005 15:35:26 +0800
>
>All,
>
>I have a USB filter driver and hope to know the hub information (such as
>DevicePropertyHardwareID: (USB\ROOT_HUB&VID8086&PID24DE&REV0002)) under
>which this device is connected. Can anyone advise how to get such
>information in the context of a filter driver?
>
>Best Regards,
>Raymond
>
>—
>You are currently subscribed to windbg as: unknown lmsubst tag argument: ‘’
>To unsubscribe send a blank email to xxxxx@lists.osr.com

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

Daniel,

Many thanks for your reply. But I am still confused where comes the
parameter (88ca6628) for the devnode command? Why for some device
instance of usbhub it does not generate a display about hub, but a
device (like below)?

0: kd> !devstack 8558f228
!DevObj !DrvObj !DevExt ObjectName
85734b48 \Driver\HidUsb 85734c00 _HID00000000
855bdeb0 \Driver\antitft 855bdf68 00000073

8558f228 \Driver\usbhub 8558f2e0 USBPDO-6
!DevNode 85583008 :
DeviceInst is “USB\Vid_046d&Pid_c00e\5&3774e5ba&0&2”
ServiceName is “HidUsb”

Best Regards,
Raymond

Zhang, Raymond wrote:

All,

I have a USB filter driver and hope to know the hub information (such as
DevicePropertyHardwareID: (USB\ROOT_HUB&VID8086&PID24DE&REV0002)) under
which this device is connected. Can anyone advise how to get such
information in the context of a filter driver?

For my own information, what do you plan to do with this information?

Are you sure this question belongs on thins list and not NTDEV?
I’ve never tried it but I believe sending IOCTL_INTERNAL_USB_GET_HUB_NAME to
your device stack will give you a symbolic link name to the root hub.
When you have the symbolic link name all you have to do is
IoGetDeviceObjectPointer(), get the PDO by sending the device
IRP_MN_QUERY_DEVICE_RELATIONS with TargetDeviceRelation and call
IoGetDeviceProperty() with the PDO and DevicePropertyHardwareID.
Don’t forget to dereference the file object you got from
IoGetDeviceObjectPointer() and to derefence the PDO and free the relations
structure you got from the IRP.

Simple, huh?

Did I get your question right or were you asking for a way to do this with
the debugger and not programatically using a filter driver?
I hope this IOCTL works, I bet using IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO will
save you some work but the DDK says this one is for microsoft’s internal use
only…

Cheers,
Shahar

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Zhang, Raymond
Sent: Monday, February 14, 2005 9:35 AM
To: Kernel Debugging Interest List
Subject: [windbg] Which hub is the USB device plugged-in?

All,

I have a USB filter driver and hope to know the hub information (such as
DevicePropertyHardwareID: (USB\ROOT_HUB&VID8086&PID24DE&REV0002)) under
which this device is connected. Can anyone advise how to get such
information in the context of a filter driver?

Best Regards,
Raymond


You are currently subscribed to windbg as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Shahar,

Thanks for your ideas. I believe your method can meet my requirement.
But I got a failure when sending IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME
(controller name is more helpful to me) to the top device using
following code. I am debugging the failure. If you see any wrong, please
let me know.

pHubName = ExAllocatePool(NonPagedPool, sizeof(struct _USB_HUB_NAME));

KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = IoBuildDeviceIoControlRequest(
IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME,
deviceExtension->topDevObj,
NULL,
0,
NULL,
0,
TRUE,
&event,
&ioStatus);
if(NULL == irp) {
DBGOUT((“memory alloc for irp failed\n”));
ExFreePool(pHubName);
return STATUS_INSUFFICIENT_RESOURCES;
}
nextStack = IoGetNextIrpStackLocation(irp);
ASSERT(nextStack != NULL);
nextStack->Parameters.Others.Argument1 = pHubName;
nextStack->Parameters.Others.Argument2 = (PVOID)sizeof(struct
_USB_HUB_NAME);
ntStatus = IoCallDriver(deviceExtension->topDevObj, irp);
if(STATUS_PENDING == ntStatus) {
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,
NULL);
}
else {
ioStatus.Status = ntStatus;
}
ntStatus = ioStatus.Status;
ExFreePool(pHubName);

The status returned is ntStatus = -1073741637.

Best Regards,
Raymond

ntStatus = -1073741637 - That’s STATUS_NOT_SUPPORTED.
Are you sure you are calling this from a USB client device stack? Did you
try also sending IOCTL_INTERNAL_USB_GET_HUB_NAME?

Shahar

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Zhang, Raymond
Sent: Tuesday, February 15, 2005 10:56 AM
To: Kernel Debugging Interest List
Subject: RE: [windbg] Which hub is the USB device plugged-in?

Shahar,

Thanks for your ideas. I believe your method can meet my requirement.
But I got a failure when sending IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME
(controller name is more helpful to me) to the top device using following
code. I am debugging the failure. If you see any wrong, please let me know.

pHubName = ExAllocatePool(NonPagedPool, sizeof(struct _USB_HUB_NAME));

KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = IoBuildDeviceIoControlRequest(
IOCTL_INTERNAL_USB_GET_CONTROLLER_NAME,
deviceExtension->topDevObj,
NULL,
0,
NULL,
0,
TRUE,
&event,
&ioStatus);
if(NULL == irp) {
DBGOUT((“memory alloc for irp failed\n”));
ExFreePool(pHubName);
return STATUS_INSUFFICIENT_RESOURCES;
}
nextStack = IoGetNextIrpStackLocation(irp);
ASSERT(nextStack != NULL);
nextStack->Parameters.Others.Argument1 = pHubName;
nextStack->Parameters.Others.Argument2 = (PVOID)sizeof(struct
_USB_HUB_NAME);
ntStatus = IoCallDriver(deviceExtension->topDevObj, irp);
if(STATUS_PENDING == ntStatus) {
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
}
else {
ioStatus.Status = ntStatus;
}
ntStatus = ioStatus.Status;
ExFreePool(pHubName);

The status returned is ntStatus = -1073741637.

Best Regards,
Raymond


You are currently subscribed to windbg as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Zhang, Raymond wrote:

The status returned is ntStatus = -1073741637.

As a general rule for you, ntStatus values should always be printed out
as an unsigned hexadecimal value. The signed integer value is useless.

-1073741637 in hex is C00000BB. You can search for that in ntstatus.h
in the DDK.

C:\Dev\Client\Src>grep C00000BB \DDK\3790\inc\wxp\ntstatus.h
#define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL)

C:\Dev\Client\Src>

After fixed two errors in my code, I got the controller name as
expected.

I also tried to get root hub name by sending
IOCTL_INTERNAL_USB_GET_HUB_NAME to same PDO. The status returned is
SUCCESS but the name buffer is empty.

As for the IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO, I got the PDO for
controller in argument2 and PDO for root hub is NULL.

Thanks again to Shahar and Roberts!

Best Regards,
Raymond