ReactOS  0.4.13-dev-52-g0efcfec
ioctl.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS USB Hub Driver
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: USBHub I/O control functions
5  * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6  */
7 
8 #include "usbhub.h"
9 
10 #define NDEBUG
11 #include <debug.h>
12 
13 #define NDEBUG_USBHUB_IOCTL
14 #include "dbg_uhub.h"
15 
17 NTAPI
19  IN PIRP Irp,
21 {
22  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
23  PUSBHUB_FDO_EXTENSION HubExtension;
24  PVOID TimeoutContext; // PUSBHUB_BANDWIDTH_TIMEOUT_CONTEXT
25  PUSBHUB_PORT_DATA PortData = NULL;
27  KIRQL OldIrql;
28 
29  DPRINT("USBH_SelectConfigOrInterfaceComplete ... \n");
30 
31  if (Irp->PendingReturned)
32  {
34  }
35 
36  PortExtension = Context;
37  HubExtension = PortExtension->HubExtension;
38 
39  ASSERT(PortExtension->PortNumber > 0);
40 
41  if (HubExtension)
42  {
43  PortData = &HubExtension->PortData[PortExtension->PortNumber - 1];
44  }
45 
46  Status = Irp->IoStatus.Status;
47 
48  if (NT_SUCCESS(Irp->IoStatus.Status))
49  {
51 
52  TimeoutContext = PortExtension->BndwTimeoutContext;
53 
54  if (TimeoutContext)
55  {
56  DPRINT1("USBH_SelectConfigOrInterfaceComplete: TimeoutContext != NULL. FIXME\n");
57  DbgBreakPoint();
58  }
59 
61 
64 
65  if (PortData && PortData->ConnectionStatus != DeviceHubNestedTooDeeply)
66  {
68  }
69  }
70  else
71  {
72  DPRINT1("USBH_SelectConfigOrInterfaceComplete: Status != STATUS_SUCCESS. FIXME\n");
73  DbgBreakPoint();
74  }
75 
76  return Status;
77 }
78 
80 NTAPI
82  IN PIRP Irp)
83 {
84  PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor;
85  PUSBHUB_FDO_EXTENSION HubExtension;
87  PURB Urb;
89  ULONG MaxPower;
90  USBD_STATUS UrbStatus;
91  BOOLEAN IsValidConfig;
92 
93  HubExtension = PortExtension->HubExtension;
94  DeviceObject = PortExtension->Common.SelfDevice;
95 
96  Urb = URB_FROM_IRP(Irp);
97 
98  DPRINT_IOCTL("USBH_PdoUrbFilter: Device - %p, Irp - %p, Urb - %p\n",
100  Irp,
101  Urb);
102 
103  if (PortExtension->PortPdoFlags & (USBHUB_PDO_FLAG_PORT_RESTORE_FAIL |
105  {
109  }
110 
111  Function = Urb->UrbHeader.Function;
112 
113  switch (Function)
114  {
116  {
117  ConfigDescriptor = Urb->UrbSelectConfiguration.ConfigurationDescriptor;
118 
119  if (ConfigDescriptor)
120  {
121  IsValidConfig = TRUE;
122 
123  if (ConfigDescriptor->bDescriptorType != USB_CONFIGURATION_DESCRIPTOR_TYPE)
124  {
125  DPRINT1("USBH_PdoUrbFilter: Not valid Cfg. bDescriptorType\n");
126  IsValidConfig = FALSE;
128  }
129 
130  if (ConfigDescriptor->bLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))
131  {
132  DPRINT1("USBH_PdoUrbFilter: Size Cfg. descriptor is too small\n");
133  IsValidConfig = FALSE;
135  }
136 
137  if (!IsValidConfig)
138  {
139  Urb->UrbHeader.Status = UrbStatus;
142  }
143 
144  MaxPower = 2 * ConfigDescriptor->MaxPower;
145  PortExtension->MaxPower = MaxPower;
146 
147  if (HubExtension->MaxPowerPerPort < MaxPower)
148  {
149  PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_INSUFFICIENT_PWR;
150 
151  DPRINT1("USBH_PdoUrbFilter: USBH_InvalidatePortDeviceState() UNIMPLEMENTED. FIXME\n");
152  DbgBreakPoint();
153 
156  }
157  }
158  }
159 
160  /* fall through */
161 
163  {
165 
168  PortExtension,
169  TRUE,
170  TRUE,
171  TRUE);
172 
173  return IoCallDriver(HubExtension->RootHubPdo2, Irp);
174  }
175 
179  {
180  if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_DELETE_PENDING)
181  {
184  return STATUS_DELETE_PENDING;
185  }
186 
187  break;
188  }
189 
190  case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR:
191  DPRINT1("USBH_PdoUrbFilter: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR UNIMPLEMENTED. FIXME\n");
193  return STATUS_NOT_IMPLEMENTED;
194 
195  default:
196  break;
197  }
198 
199  return USBH_PassIrp(HubExtension->RootHubPdo2, Irp);
200 }
201 
202 NTSTATUS
203 NTAPI
205  IN PIRP Irp)
206 {
207  PUSBHUB_FDO_EXTENSION HubExtension;
208  PURB Urb;
210 
211  DPRINT_IOCTL("USBH_PdoIoctlSubmitUrb ... \n");
212 
213  HubExtension = PortExtension->HubExtension;
214 
215  Urb = URB_FROM_IRP(Irp);
216 
217  if (PortExtension->DeviceHandle == NULL)
218  {
219  Urb->UrbHeader.UsbdDeviceHandle = NULL;
220  Status = USBH_PassIrp(HubExtension->RootHubPdo2, Irp);
221  }
222  else
223  {
224  Urb->UrbHeader.UsbdDeviceHandle = PortExtension->DeviceHandle;
225  Status = USBH_PdoUrbFilter(PortExtension, Irp);
226  }
227 
228  return Status;
229 }
230 
231 NTSTATUS
232 NTAPI
234  IN PIRP Irp)
235 {
236  PUSBHUB_FDO_EXTENSION HubExtension;
237  PUSBHUB_PORT_DATA PortData;
238  PIO_STACK_LOCATION IoStack;
241 
242  DPRINT("USBH_PdoIoctlGetPortStatus ... \n");
243 
244  HubExtension = PortExtension->HubExtension;
245 
247 
248  KeWaitForSingleObject(&HubExtension->HubSemaphore,
249  Executive,
250  KernelMode,
251  FALSE,
252  NULL);
253 
254  ASSERT(PortExtension->PortNumber > 0);
255  PortData = &HubExtension->PortData[PortExtension->PortNumber - 1];
256 
257  Status = USBH_SyncGetPortStatus(HubExtension,
258  PortExtension->PortNumber,
259  &PortData->PortStatus,
261 
263  PortStatus = IoStack->Parameters.Others.Argument1;
264 
265  *PortStatus = 0;
266 
267  if (PortExtension->Common.SelfDevice == PortData->DeviceObject)
268  {
270  {
272  }
273 
275  {
277  }
278  }
279 
280  KeReleaseSemaphore(&HubExtension->HubSemaphore,
282  1,
283  FALSE);
284 
285  if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
286  {
287  KeSetEvent(&HubExtension->PendingRequestEvent,
289  FALSE);
290  }
291 
293 
294  return Status;
295 }
296 
297 VOID
298 NTAPI
300  IN PVOID Context)
301 {
302  PUSBHUB_RESET_PORT_CONTEXT WorkItemReset;
303  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
306  USHORT Port;
307 
308  DPRINT("USBH_ResetPortWorker ... \n");
309 
310  WorkItemReset = Context;
311 
312  PortExtension = WorkItemReset->PortExtension;
313 
314  if (!HubExtension)
315  {
317  goto Exit;
318  }
319 
320  InterlockedIncrement(&HubExtension->PendingRequestCount);
321 
322  KeWaitForSingleObject(&HubExtension->HubSemaphore,
323  Executive,
324  KernelMode,
325  FALSE,
326  NULL);
327 
328  Port = PortExtension->PortNumber;
329  DeviceHandle = PortExtension->DeviceHandle;
330 
331  ASSERT(Port > 0);
332 
333  if (PortExtension->Common.SelfDevice == HubExtension->PortData[Port-1].DeviceObject &&
334  DeviceHandle != NULL)
335  {
336  USBD_RemoveDeviceEx(HubExtension,
337  DeviceHandle,
339 
340  Status = USBH_ResetDevice(HubExtension,
341  Port,
342  TRUE,
343  FALSE);
344  }
345  else
346  {
348  }
349 
350  KeReleaseSemaphore(&HubExtension->HubSemaphore,
352  1,
353  FALSE);
354 
355  if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
356  {
357  KeSetEvent(&HubExtension->PendingRequestEvent,
359  FALSE);
360  }
361 
362 Exit:
363 
364  PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_PORT_RESSETING;
365 
366  USBH_CompleteIrp(WorkItemReset->Irp, Status);
367 
369 }
370 
371 NTSTATUS
372 NTAPI
374  IN PIRP Irp)
375 {
376  PUSBHUB_FDO_EXTENSION HubExtension;
377  PUSBHUB_RESET_PORT_CONTEXT HubWorkItemBuffer;
378  PUSBHUB_IO_WORK_ITEM HubIoWorkItem;
380 
381  HubExtension = PortExtension->HubExtension;
382 
383  DPRINT("USBH_PdoIoctlResetPort ... \n");
384 
385  if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_PORT_RESSETING)
386  {
389  return Status;
390  }
391 
392  Status = USBH_AllocateWorkItem(HubExtension,
393  &HubIoWorkItem,
396  (PVOID *)&HubWorkItemBuffer,
398 
399  if (!NT_SUCCESS(Status))
400  {
403  return Status;
404  }
405 
406  PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_PORT_RESSETING;
408 
409  HubWorkItemBuffer->PortExtension = PortExtension;
410  HubWorkItemBuffer->Irp = Irp;
411 
413 
414  USBH_QueueWorkItem(PortExtension->HubExtension, HubIoWorkItem);
415 
416  return Status;
417 }
418 
419 VOID
420 NTAPI
422  IN PIRP Irp)
423 {
424  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
425  PUSBHUB_FDO_EXTENSION HubExtension;
426  PIRP PendingIdleIrp = NULL;
427  PUSBHUB_IO_WORK_ITEM HubIoWorkItem;
428  PUSBHUB_IDLE_PORT_CANCEL_CONTEXT HubWorkItemBuffer;
430 
431  DPRINT("USBH_PortIdleNotificationCancelRoutine ... \n");
432 
433  PortExtension = Device->DeviceExtension;
435 
436  HubExtension = PortExtension->HubExtension;
437  ASSERT(HubExtension);
438 
439  PortExtension->IdleNotificationIrp = NULL;
440 
441  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST)
442  {
443  PendingIdleIrp = HubExtension->PendingIdleIrp;
444  HubExtension->PendingIdleIrp = NULL;
445  }
446 
447  IoReleaseCancelSpinLock(Irp->CancelIrql);
448 
449  if (PendingIdleIrp)
450  {
451  USBH_HubCancelIdleIrp(HubExtension, PendingIdleIrp);
452  }
453 
454  if (HubExtension->CurrentPowerState.DeviceState == PowerDeviceD0)
455  {
456  goto ErrorExit;
457  }
458 
459  Status = USBH_AllocateWorkItem(HubExtension,
460  &HubIoWorkItem,
463  (PVOID *)&HubWorkItemBuffer,
465 
466  if (NT_SUCCESS(Status))
467  {
468  HubWorkItemBuffer->Irp = Irp;
469  USBH_QueueWorkItem(HubExtension, HubIoWorkItem);
470  return;
471  }
472 
473 ErrorExit:
474 
475  Irp->IoStatus.Status = STATUS_CANCELLED;
477 }
478 
479 NTSTATUS
480 NTAPI
482  IN PIRP Irp)
483 {
484  PUSBHUB_FDO_EXTENSION HubExtension;
485  PIO_STACK_LOCATION IoStack;
486  PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
488  KIRQL Irql;
489 
490  DPRINT("USBH_PortIdleNotificationRequest ... \n");
491 
492  HubExtension = PortExtension->HubExtension;
493 
495 
496  if (PortExtension->IdleNotificationIrp)
497  {
499  Irp->IoStatus.Status = STATUS_DEVICE_BUSY;
501  return STATUS_DEVICE_BUSY;
502  }
503 
505  IdleCallbackInfo = IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
506 
507  if (!IdleCallbackInfo || !IdleCallbackInfo->IdleCallback)
508  {
510 
512  Irp->IoStatus.Status = Status;
514 
515  return Status;
516  }
517 
519 
520  if (Irp->Cancel)
521  {
523  {
526  Irp->IoStatus.Status = STATUS_CANCELLED;
528  }
529  else
530  {
534  }
535  }
536  else
537  {
538  PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_IDLE_NOTIFICATION;
539 
540  PortExtension->IdleNotificationIrp = Irp;
542 
545 
546  DPRINT("USBH_PortIdleNotificationRequest: IdleNotificationIrp - %p\n",
547  PortExtension->IdleNotificationIrp);
548 
549  USBH_CheckIdleDeferred(HubExtension);
550  }
551 
552  return Status;
553 }
554 
555 NTSTATUS
556 NTAPI
558  IN PIRP Irp)
559 {
560  PUSB_NODE_CONNECTION_NAME ConnectionName;
561  PDEVICE_OBJECT PortDevice;
562  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
563  size_t LengthSkip;
564  PWCHAR Buffer;
568  size_t LengthName;
569  ULONG Length;
571  PIO_STACK_LOCATION IoStack;
573 
574  DPRINT("USBH_IoctlGetNodeName ... \n");
575 
577 
578  ConnectionName = Irp->AssociatedIrp.SystemBuffer;
579 
581  Length = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
582 
583  if (Length < sizeof(USB_NODE_CONNECTION_NAME))
584  {
586  Information = Irp->IoStatus.Information;
587  goto Exit;
588  }
589 
590  if (ConnectionName->ConnectionIndex == 0 ||
591  ConnectionName->ConnectionIndex > HubExtension->HubDescriptor->bNumberOfPorts)
592  {
594  Information = Irp->IoStatus.Information;
595  goto Exit;
596  }
597 
598  PortDevice = HubExtension->PortData[ConnectionName->ConnectionIndex - 1].DeviceObject;
599 
600  if (!PortDevice)
601  {
602  ConnectionName->NodeName[0] = 0;
603  ConnectionName->ActualLength = sizeof(USB_NODE_CONNECTION_NAME);
604 
606  goto Exit;
607  }
608 
609  PortExtension = PortDevice->DeviceExtension;
610 
611  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE) ||
612  !(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_DEVICE_STARTED) ||
614  {
615  ConnectionName->NodeName[0] = 0;
616  ConnectionName->ActualLength = sizeof(USB_NODE_CONNECTION_NAME);
617 
619  goto Exit;
620  }
621 
622  Buffer = PortExtension->SymbolicLinkName.Buffer;
623  BufferLength = PortExtension->SymbolicLinkName.Length;
624 
626 
627  LengthSkip = 0;
628 
629  if (*Buffer == L'\\')
630  {
631  BufferEnd = wcschr(Buffer + 1, L'\\');
632 
633  if (BufferEnd != NULL)
634  {
635  LengthSkip = (BufferEnd + 1 - Buffer) * sizeof(WCHAR);
636  }
637  else
638  {
639  LengthSkip = PortExtension->SymbolicLinkName.Length;
640  }
641  }
642 
643  LengthName = BufferLength - LengthSkip;
644 
645  ConnectionName->ActualLength = 0;
646 
647  RtlZeroMemory(ConnectionName->NodeName,
649 
650  LengthReturned = sizeof(USB_NODE_CONNECTION_NAME) + LengthName;
651 
652  if (Length < LengthReturned)
653  {
654  ConnectionName->NodeName[0] = 0;
655  ConnectionName->ActualLength = LengthReturned;
656 
658  goto Exit;
659  }
660 
661  RtlCopyMemory(&ConnectionName->NodeName[0],
662  &Buffer[LengthSkip / sizeof(WCHAR)],
663  LengthName);
664 
665  ConnectionName->ActualLength = LengthReturned;
666 
669 
670 Exit:
671  Irp->IoStatus.Information = Information;
673  return Status;
674 }
675 
676 NTSTATUS
677 NTAPI
679  IN PIRP Irp)
680 {
681  PUSB_NODE_INFORMATION NodeInfo;
682  PIO_STACK_LOCATION IoStack;
685  BOOLEAN HubIsBusPowered;
686 
687  DPRINT("USBH_IoctlGetNodeInformation ... \n");
688 
690 
691  NodeInfo = Irp->AssociatedIrp.SystemBuffer;
692 
694  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
695 
696  RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, BufferLength);
697 
698  if (BufferLength < sizeof(USB_NODE_INFORMATION))
699  {
702  return Status;
703  }
704 
705  NodeInfo->NodeType = UsbHub;
706 
708  HubExtension->HubDescriptor,
709  sizeof(USB_HUB_DESCRIPTOR));
710 
711  HubIsBusPowered = USBH_HubIsBusPowered(HubExtension->Common.SelfDevice,
712  HubExtension->HubConfigDescriptor);
713 
714  NodeInfo->u.HubInformation.HubIsBusPowered = HubIsBusPowered;
715 
716  Irp->IoStatus.Information = sizeof(USB_NODE_INFORMATION);
717 
719 
720  return Status;
721 }
722 
723 NTSTATUS
724 NTAPI
726  IN PIRP Irp)
727 {
728  PUSB_HUB_CAPABILITIES Capabilities;
729  PIO_STACK_LOCATION IoStack;
731  ULONG Length;
732  USB_HUB_CAPABILITIES HubCaps;
733 
734  DPRINT("USBH_IoctlGetHubCapabilities ... \n");
735 
736  Capabilities = Irp->AssociatedIrp.SystemBuffer;
737 
738  HubCaps.HubIs2xCapable = (HubExtension->HubFlags & USBHUB_FDO_FLAG_USB20_HUB) ==
740 
742 
743  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
744 
745  if (BufferLength == 0)
746  {
747  Irp->IoStatus.Information = BufferLength;
750  }
751 
752  if (BufferLength <= sizeof(HubCaps))
753  {
754  Length = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
755  }
756  else
757  {
758  Length = sizeof(HubCaps);
759  }
760 
762  RtlCopyMemory(Capabilities, &HubCaps, Length);
763 
764  Irp->IoStatus.Information = Length;
765 
767 
768  return STATUS_SUCCESS;
769 }
770 
771 NTSTATUS
772 NTAPI
774  IN PIRP Irp)
775 {
776  PUSB_NODE_CONNECTION_ATTRIBUTES Attributes;
777  ULONG ConnectionIndex;
778  ULONG NumPorts;
780  PUSBHUB_PORT_DATA PortData;
781  PIO_STACK_LOCATION IoStack;
783 
784  DPRINT("USBH_IoctlGetNodeConnectionAttributes ... \n");
785 
787  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
788 
789  if (BufferLength < sizeof(USB_NODE_CONNECTION_ATTRIBUTES))
790  {
792  goto Exit;
793  }
794 
795  Attributes = Irp->AssociatedIrp.SystemBuffer;
796 
797  ConnectionIndex = Attributes->ConnectionIndex;
799  Attributes->ConnectionIndex = ConnectionIndex;
800 
802 
803  NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
804 
805  if (NumPorts == 0 ||
806  ConnectionIndex == 0 ||
807  ConnectionIndex > NumPorts)
808  {
809  goto Exit;
810  }
811 
812  PortData = HubExtension->PortData + (ConnectionIndex - 1);
813 
814  Attributes->ConnectionStatus = PortData->ConnectionStatus;
815  Attributes->PortAttributes = PortData->PortAttributes;
816 
817  Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_ATTRIBUTES);
819 
820 Exit:
821 
823  return Status;
824 }
825 
826 NTSTATUS
827 NTAPI
829  IN PIRP Irp,
830  IN BOOLEAN IsExt)
831 {
832  PUSBHUB_PORT_DATA PortData;
834  PUSB_NODE_CONNECTION_INFORMATION_EX Info;
835  ULONG ConnectionIndex;
836  ULONG NumPorts;
839  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
840  PIO_STACK_LOCATION IoStack;
841 
842  DPRINT("USBH_IoctlGetNodeConnectionInformation ... \n");
843 
845  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
846 
847  if (BufferLength < (ULONG)FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
848  PipeList))
849  {
851  goto Exit;
852  }
853 
854  Info = Irp->AssociatedIrp.SystemBuffer;
855 
856  ConnectionIndex = Info->ConnectionIndex;
858  Info->ConnectionIndex = ConnectionIndex;
859 
861 
862  NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
863 
864  if (NumPorts == 0 ||
865  ConnectionIndex == 0 ||
866  ConnectionIndex > NumPorts)
867  {
868  goto Exit;
869  }
870 
871  PortData = HubExtension->PortData + (ConnectionIndex - 1);
872  DeviceObject = PortData->DeviceObject;
873 
874  if (!DeviceObject)
875  {
876  Info->ConnectionStatus = PortData->ConnectionStatus;
877 
878  Irp->IoStatus.Information = FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
879  PipeList);
881  goto Exit;
882  }
883 
884  PortExtension = DeviceObject->DeviceExtension;
885 
886  Info->ConnectionStatus = PortData->ConnectionStatus;
887 
888  Info->DeviceIsHub = (PortExtension->PortPdoFlags &
891 
892  RtlCopyMemory(&Info->DeviceDescriptor,
893  &PortExtension->DeviceDescriptor,
894  sizeof(USB_DEVICE_DESCRIPTOR));
895 
896  if (PortExtension->DeviceHandle)
897  {
898  Status = USBD_GetDeviceInformationEx(PortExtension,
899  HubExtension,
900  Info,
901  BufferLength,
902  PortExtension->DeviceHandle);
903  }
904  else
905  {
907  }
908 
909  if (NT_SUCCESS(Status))
910  {
911  if (!IsExt)
912  {
913  /* IOCTL_USB_GET_NODE_CONNECTION_INFORMATION request reports
914  only low and full speed connections. Info->Speed member
915  is Info->LowSpeed in the non-EX version of the structure */
916 
917  Info->Speed = (Info->Speed == UsbLowSpeed);
918  }
919 
920  Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_INFORMATION_EX) +
921  (Info->NumberOfOpenPipes - 1) * sizeof(USB_PIPE_INFO);
922  goto Exit;
923  }
924 
926  {
927  goto Exit;
928  }
929 
930  Irp->IoStatus.Information = FIELD_OFFSET(USB_NODE_CONNECTION_INFORMATION_EX,
931  PipeList);
933 
934 Exit:
936  return Status;
937 }
938 
939 NTSTATUS
940 NTAPI
942  IN PIRP Irp)
943 {
944  PUSBHUB_PORT_DATA PortData;
945  PDEVICE_OBJECT PortDevice;
946  ULONG Length;
949  PIO_STACK_LOCATION IoStack;
952  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
953 
954  DPRINT("USBH_IoctlGetNodeConnectionDriverKeyName ... \n");
955 
957  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
958 
960  HubExtension->HubDescriptor->bNumberOfPorts == 0)
961  {
963  goto Exit;
964  }
965 
966  KeyName = Irp->AssociatedIrp.SystemBuffer;
968 
969  PortData = &HubExtension->PortData[KeyName->ConnectionIndex - 1];
970  PortDevice = PortData->DeviceObject;
971 
972  if (!PortDevice)
973  {
974  goto Exit;
975  }
976 
977  PortExtension = PortDevice->DeviceExtension;
978 
979  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_ENUMERATED))
980  {
982  goto Exit;
983  }
984 
986 
987  Status = IoGetDeviceProperty(PortDevice,
990  &KeyName->DriverKeyName,
991  &ResultLength);
992 
994  {
996  }
997 
999  KeyName->ActualLength = Length;
1000 
1001  if (BufferLength < Length)
1002  {
1003  KeyName->DriverKeyName[0] = 0;
1004  Irp->IoStatus.Information = sizeof(USB_NODE_CONNECTION_DRIVERKEY_NAME);
1005  }
1006  else
1007  {
1008  Irp->IoStatus.Information = Length;
1009  }
1010 
1011 Exit:
1013  return Status;
1014 }
1015 
1016 NTSTATUS
1017 NTAPI
1019  IN PIRP Irp)
1020 {
1022  PUSBHUB_PORT_DATA PortData;
1023  PUSB_DESCRIPTOR_REQUEST UsbRequest;
1024  PDEVICE_OBJECT PortDevice;
1025  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
1026  struct _URB_CONTROL_TRANSFER * Urb;
1027  NTSTATUS Status;
1028  ULONG RequestBufferLength;
1029  PIO_STACK_LOCATION IoStack;
1030  ULONG NumPorts;
1031 
1032  IoStack = IoGetCurrentIrpStackLocation(Irp);
1033  BufferLength = IoStack->Parameters.DeviceIoControl.OutputBufferLength;
1034 
1035  DPRINT("USBH_IoctlGetDescriptor: BufferLength - %x\n", BufferLength);
1036 
1037  if (BufferLength < sizeof(USB_DESCRIPTOR_REQUEST))
1038  {
1040  goto Exit;
1041  }
1042 
1043  UsbRequest = Irp->AssociatedIrp.SystemBuffer;
1044  RequestBufferLength = UsbRequest->SetupPacket.wLength;
1045 
1046  if (RequestBufferLength > BufferLength -
1048  {
1049  DPRINT("USBH_IoctlGetDescriptor: RequestBufferLength - %x\n",
1050  RequestBufferLength);
1051 
1053  goto Exit;
1054  }
1055 
1057 
1058  NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
1059 
1060  if (NumPorts == 0 ||
1061  UsbRequest->ConnectionIndex == 0 ||
1062  UsbRequest->ConnectionIndex > NumPorts)
1063  {
1064  goto Exit;
1065  }
1066 
1067  PortData = HubExtension->PortData + (UsbRequest->ConnectionIndex - 1);
1068  PortDevice = PortData->DeviceObject;
1069 
1070  if (!PortDevice)
1071  {
1072  goto Exit;
1073  }
1074 
1075  PortExtension = PortDevice->DeviceExtension;
1076 
1077  if (UsbRequest->SetupPacket.bmRequest == USB_CONFIGURATION_DESCRIPTOR_TYPE &&
1078  RequestBufferLength == sizeof(USB_CONFIGURATION_DESCRIPTOR))
1079  {
1081 
1082  RtlCopyMemory(&UsbRequest->Data[0],
1083  &PortExtension->ConfigDescriptor,
1085 
1086  Irp->IoStatus.Information = sizeof(USB_DESCRIPTOR_REQUEST) - sizeof(UCHAR) +
1088  goto Exit;
1089  }
1090 
1092  sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
1093  USB_HUB_TAG);
1094 
1095  if (!Urb)
1096  {
1098  goto Exit;
1099  }
1100 
1101  RtlZeroMemory(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));
1102 
1104  Urb->Hdr.Length = sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST);
1105 
1106  Urb->TransferBuffer = &UsbRequest->Data[0];
1107  Urb->TransferBufferLength = RequestBufferLength;
1108  Urb->TransferBufferMDL = NULL;
1109  Urb->UrbLink = NULL;
1110 
1112  &UsbRequest->SetupPacket,
1114 
1115  Status = USBH_SyncSubmitUrb(PortExtension->Common.SelfDevice,
1116  (PURB)Urb);
1117 
1118  Irp->IoStatus.Information = (sizeof(USB_DESCRIPTOR_REQUEST) - sizeof(UCHAR)) +
1119  Urb->TransferBufferLength;
1120 
1122 
1123 Exit:
1125  return Status;
1126 }
1127 
1128 NTSTATUS
1129 NTAPI
1131  IN PIRP Irp)
1132 {
1134  PIO_STACK_LOCATION IoStack;
1136  BOOLEAN IsCheckHubIdle = FALSE;
1137 
1138  DPRINT("USBH_DeviceControl: HubExtension - %p, Irp - %p\n",
1139  HubExtension,
1140  Irp);
1141 
1142  IoStack = IoGetCurrentIrpStackLocation(Irp);
1143  ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1144  DPRINT("USBH_DeviceControl: ControlCode - %lX\n", ControlCode);
1145 
1146  if ((HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0) &&
1147  (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED))
1148  {
1149  IsCheckHubIdle = TRUE;
1150  USBH_HubSetD0(HubExtension);
1151  }
1152 
1153  switch (ControlCode)
1154  {
1155  case IOCTL_USB_GET_HUB_CAPABILITIES:
1156  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_HUB_CAPABILITIES\n");
1157  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1158  {
1159  Status = USBH_IoctlGetHubCapabilities(HubExtension, Irp);
1160  break;
1161  }
1162 
1164  break;
1165 
1166  case IOCTL_USB_HUB_CYCLE_PORT:
1167  DPRINT1("USBH_DeviceControl: IOCTL_USB_HUB_CYCLE_PORT UNIMPLEMENTED. FIXME\n");
1168  DbgBreakPoint();
1169  break;
1170 
1172  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_INFORMATION\n");
1173  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1174  {
1175  Status = USBH_IoctlGetNodeInformation(HubExtension, Irp);
1176  break;
1177  }
1178 
1180  break;
1181 
1183  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION\n");
1184  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1185  {
1187  Irp,
1188  FALSE);
1189  break;
1190  }
1191 
1193  break;
1194 
1195  case IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX:
1196  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX\n");
1197  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1198  {
1200  Irp,
1201  TRUE);
1202  break;
1203  }
1204 
1206  break;
1207 
1208  case IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES:
1209  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES\n");
1210  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1211  {
1213  break;
1214  }
1215 
1217  break;
1218 
1220  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_NAME\n");
1221  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1222  {
1223  Status = USBH_IoctlGetNodeName(HubExtension, Irp);
1224  break;
1225  }
1226 
1228  break;
1229 
1231  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME\n");
1232  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1233  {
1235  break;
1236  }
1237 
1239  break;
1240 
1242  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION\n");
1243  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1244  {
1245  Status = USBH_IoctlGetDescriptor(HubExtension, Irp);
1246  break;
1247  }
1248 
1250  break;
1251 
1252  case IOCTL_KS_PROPERTY:
1253  DPRINT("USBH_DeviceControl: IOCTL_KS_PROPERTY\n");
1256  break;
1257 
1258  default:
1259  DPRINT1("USBH_DeviceControl: Unhandled IOCTL_ - %lX\n", ControlCode);
1260  Status = USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1261  break;
1262  }
1263 
1264  if (IsCheckHubIdle)
1265  {
1266  USBH_CheckHubIdle(HubExtension);
1267  }
1268 
1269  return Status;
1270 }
1271 
1272 NTSTATUS
1273 NTAPI
1275  IN PIRP Irp)
1276 {
1277  PUSBHUB_FDO_EXTENSION HubExtension;
1280  PIO_STACK_LOCATION IoStack;
1281  PULONG HubCount;
1282 
1283  DPRINT_IOCTL("USBH_PdoInternalControl: PortExtension - %p, Irp - %p\n",
1284  PortExtension,
1285  Irp);
1286 
1287  HubExtension = PortExtension->HubExtension;
1288 
1289  if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_NOT_CONNECTED)
1290  {
1292  goto Exit;
1293  }
1294 
1295  if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD0)
1296  {
1298  goto Exit;
1299  }
1300 
1301  IoStack = IoGetCurrentIrpStackLocation(Irp);
1302  ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1303 
1305  {
1306  HubExtension = PortExtension->RootHubExtension;
1307  DPRINT("USBH_PdoInternalControl: HubExtension - %p\n", HubExtension);
1308  }
1309 
1310  if (!HubExtension)
1311  {
1313  goto Exit;
1314  }
1315 
1316  switch (ControlCode)
1317  {
1319  return USBH_PdoIoctlSubmitUrb(PortExtension, Irp);
1320 
1321  case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION:
1322  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
1323  return USBH_PortIdleNotificationRequest(PortExtension, Irp);
1324 
1326  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
1327  return USBH_PdoIoctlGetPortStatus(PortExtension, Irp);
1328 
1330  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_RESET_PORT\n");
1331  return USBH_PdoIoctlResetPort(PortExtension, Irp);
1332 
1334  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_ENABLE_PORT\n");
1335  DbgBreakPoint();
1336  break;
1337 
1339  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_CYCLE_PORT\n");
1340  DbgBreakPoint();
1341  break;
1342 
1343  case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE:
1344  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
1345  *(PVOID *)IoStack->Parameters.Others.Argument1 = PortExtension->DeviceHandle;
1347  break;
1348 
1350  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_COUNT. PortPdoFlags - %lX\n",
1351  PortExtension->PortPdoFlags);
1352 
1353  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1354  {
1356  break;
1357  }
1358 
1359  HubCount = IoStack->Parameters.Others.Argument1;
1360 
1361  ++*HubCount;
1362 
1363  Status = USBH_SyncGetHubCount(HubExtension->LowerDevice,
1364  HubCount);
1365 
1366  DPRINT("USBH_PdoInternalControl: *HubCount - %x\n", *HubCount);
1367  break;
1368 
1370  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO. PortPdoFlags - %lX\n",
1371  PortExtension->PortPdoFlags);
1372 
1373  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1374  {
1375  DbgBreakPoint();
1377 
1378  *(PVOID *)IoStack->Parameters.Others.Argument1 = NULL;
1379 
1381  break;
1382  }
1383 
1384  ASSERT(HubExtension->RootHubPdo);
1385  return USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1386 
1388  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_NAME\n");
1389  DbgBreakPoint();
1390  break;
1391 
1393  DPRINT1("USBH_PdoInternalControl: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
1394  DbgBreakPoint();
1395  break;
1396 
1398  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_BUS_INFO\n");
1399  DbgBreakPoint();
1400  break;
1401 
1403  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
1404  DbgBreakPoint();
1405  break;
1406 
1407  default:
1408  DPRINT1("USBH_PdoInternalControl: unhandled IOCTL_ - %lX\n", ControlCode);
1409  break;
1410  }
1411 
1412 Exit:
1414  return Status;
1415 }
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
USB_20_PORT_STATUS Usb20PortStatus
Definition: usb200.h:223
#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
Definition: usbioctl.h:175
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4693
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
CPPORT Port[4]
Definition: headless.c:34
#define IN
Definition: typedefs.h:38
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:308
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION
Definition: usbioctl.h:172
PUSB_DEVICE_HANDLE DeviceHandle
Definition: usbhub.h:211
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR
Definition: usbhub.h:77
#define URB_FROM_IRP(Irp)
Definition: usb.h:85
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
NTSTATUS NTAPI USBH_ResetDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN BOOLEAN IsKeepDeviceData, IN BOOLEAN IsWait)
Definition: usbhub.c:4534
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
#define USBD_MARK_DEVICE_BUSY
Definition: hubbusif.h:30
#define IOCTL_GET_HCD_DRIVERKEY_NAME
Definition: usbioctl.h:165
_In_ PIRP Irp
Definition: csq.h:116
#define USBD_PORT_ENABLED
Definition: usbioctl.h:41
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
Definition: usbioctl.h:68
#define USBHUB_PDO_FLAG_ENUMERATED
Definition: usbhub.h:82
USB_PORT_STATUS_AND_CHANGE PortStatus
Definition: usbhub.h:118
#define USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED
Definition: usbhub.h:78
#define IOCTL_INTERNAL_USB_ENABLE_PORT
Definition: usbioctl.h:47
#define IOCTL_INTERNAL_USB_GET_HUB_NAME
Definition: usbioctl.h:56
PUSBHUB_FDO_EXTENSION HubExtension
Definition: usbhub.h:209
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING SymbolicLinkName
Definition: usbhub.h:207
BOOLEAN HubIsBusPowered
Definition: usbioctl.h:225
NTSTATUS NTAPI USBH_DeviceControl(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:1130
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
USHORT CurrentConnectStatus
Definition: usb200.h:133
USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor
Definition: usbhub.h:218
#define USBHUB_FDO_FLAG_USB20_HUB
Definition: usbhub.h:47
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME
Definition: usbioctl.h:187
#define LOW_REALTIME_PRIORITY
uint16_t * PWCHAR
Definition: typedefs.h:54
USB_CONNECTION_STATUS ConnectionStatus
Definition: usbhub.h:120
#define IOCTL_INTERNAL_USB_GET_BUS_INFO
Definition: usbioctl.h:59
IoSetCancelRoutine(Irp, CancelRoutine)
void DbgBreakPoint()
Definition: mach.c:558
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _USB_NODE_CONNECTION_DRIVERKEY_NAME USB_NODE_CONNECTION_DRIVERKEY_NAME
_Out_ PKIRQL Irql
Definition: csq.h:179
USB_HUB_DESCRIPTOR HubDescriptor
Definition: usbioctl.h:224
struct _USB_DESCRIPTOR_REQUEST USB_DESCRIPTOR_REQUEST
NTSTATUS NTAPI USBH_PdoInternalControl(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:1274
struct _URB * UrbLink
Definition: usb.h:473
struct TraceInfo Info
BOOLEAN NTAPI USBH_HubIsBusPowered(IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor)
Definition: usbhub.c:1538
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
#define USBHUB_PDO_FLAG_NOT_CONNECTED
Definition: usbhub.h:67
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
#define DPRINT_IOCTL(...)
Definition: dbg_uhub.h:107
UCHAR KIRQL
Definition: env_spec_w32.h:591
PDEVICE_OBJECT DeviceObject
Definition: kstypes.h:153
VOID NTAPI USBH_ResetPortWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: ioctl.c:299
NTSTATUS NTAPI USBH_IoctlGetNodeName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:557
NTSTATUS NTAPI USBH_IoctlGetDescriptor(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:1018
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define STATUS_DEVICE_POWERED_OFF
Definition: ntstatus.h:183
struct _URB_HEADER Hdr
Definition: usb.h:467
#define UNICODE_NULL
static LPOVERLAPPED_COMPLETION_ROUTINE Function
Definition: sync.c:684
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
_In_ ULONG BufferLength
Definition: usbdlib.h:225
PDEVICE_OBJECT RootHubPdo2
Definition: usbhub.h:152
VOID NTAPI USBH_CompleteIrp(IN PIRP Irp, IN NTSTATUS CompleteStatus)
Definition: usbhub.c:63
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
NTSTATUS NTAPI USBH_SelectConfigOrInterfaceComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: ioctl.c:18
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
VOID NTAPI USBH_HubCancelIdleIrp(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP IdleIrp)
Definition: usbhub.c:3125
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3876
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FILE_INFORMATION_CLASS _Out_opt_ PULONG LengthReturned
Definition: fltkernel.h:1306
#define IoCompleteRequest
Definition: irp.c:1240
#define IOCTL_USB_GET_NODE_CONNECTION_NAME
Definition: usbioctl.h:178
#define USBHUB_PDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:70
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4202
void DPRINT(...)
Definition: polytest.cpp:61
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
struct _USB_NODE_CONNECTION_NAME USB_NODE_CONNECTION_NAME
#define USB_HUB_TAG
Definition: usbhub.h:9
LONG PendingRequestCount
Definition: usbhub.h:180
#define USBHUB_PDO_FLAG_IDLE_NOTIFICATION
Definition: usbhub.h:80
#define IOCTL_INTERNAL_USB_CYCLE_PORT
Definition: usbioctl.h:53
#define USBHUB_PDO_FLAG_HUB_DEVICE
Definition: usbhub.h:61
USB_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: usbhub.h:216
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
WCHAR NodeName[ANYSIZE_ARRAY]
Definition: usbioctl.h:310
struct _URB_HEADER UrbHeader
Definition: usb.h:531
PMDL TransferBufferMDL
Definition: usb.h:472
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
static void Exit(void)
Definition: sock.c:1331
PDEVICE_OBJECT LowerDevice
Definition: usbhub.h:150
#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE
Definition: usbhub.h:72
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionAttributes(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:773
#define USBHUB_PDO_FLAG_PORT_RESSETING
Definition: usbhub.h:79
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT
Definition: usbioctl.h:50
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
#define USBD_STATUS_INVALID_PARAMETER
Definition: usb.h:192
NTSTATUS NTAPI USBD_RemoveDeviceEx(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
Definition: usbhub.c:2457
NTSTATUS NTAPI USBH_PdoIoctlResetPort(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:373
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI USBH_AllocateWorkItem(PUSBHUB_FDO_EXTENSION HubExtension, PUSBHUB_IO_WORK_ITEM *OutHubIoWorkItem, PUSBHUB_WORKER_ROUTINE WorkerRoutine, SIZE_T BufferLength, PVOID *OutHubWorkItemBuffer, WORK_QUEUE_TYPE Type)
Definition: usbhub.c:2710
struct _USB_PIPE_INFO USB_PIPE_INFO
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionDriverKeyName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:941
KEVENT PendingRequestEvent
Definition: usbhub.h:181
unsigned char UCHAR
Definition: xmlstorage.h:181
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
VOID NTAPI USBH_QueueWorkItem(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem)
Definition: usbhub.c:2836
static const char * NodeName(const NOTIFICATIONLIST *item)
Definition: changenotify.c:145
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
Definition: usbioctl.h:38
static const WCHAR L[]
Definition: oid.c:1250
#define InterlockedDecrement
Definition: armddk.h:52
#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL
Definition: usbhub.h:73
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
LONG USBD_STATUS
Definition: usb.h:165
struct _USB_DESCRIPTOR_REQUEST::@3127 SetupPacket
NTSTATUS NTAPI USBH_SyncSubmitUrb(IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
Definition: usbhub.c:250
NTSTATUS NTAPI USBH_SyncGetPortStatus(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus, IN ULONG Length)
Definition: usbhub.c:1363
VOID NTAPI USBH_IdleCancelPowerHubWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: power.c:135
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:40
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:176
VOID NTAPI USBH_PortIdleNotificationCancelRoutine(IN PDEVICE_OBJECT Device, IN PIRP Irp)
Definition: ioctl.c:421
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define URB_FUNCTION_SELECT_INTERFACE
Definition: usb.h:87
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
Status
Definition: gdiplustypes.h:24
#define USBD_PORT_CONNECTED
Definition: usbioctl.h:42
KSPIN_LOCK PortTimeoutSpinLock
Definition: usbhub.h:226
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI USBH_PdoUrbFilter(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:81
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_NO_CALLBACK_ACTIVE
Definition: ntstatus.h:712
#define USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR
Definition: usb.h:203
POWER_STATE CurrentPowerState
Definition: usbhub.h:160
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define EVENT_INCREMENT
Definition: iotypes.h:564
struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration
Definition: usb.h:533
#define InterlockedIncrement
Definition: armddk.h:53
UCHAR SetupPacket[8]
Definition: usb.h:475
Definition: usb.h:529
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
#define URB_FUNCTION_ISOCH_TRANSFER
Definition: usb.h:96
unsigned short USHORT
Definition: pedump.c:61
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
union _USB_NODE_INFORMATION::@3126 u
UCHAR Data[ANYSIZE_ARRAY]
Definition: usbioctl.h:337
KSEMAPHORE HubSemaphore
Definition: usbhub.h:196
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
NTSTATUS NTAPI USBD_GetDeviceInformationEx(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_NODE_CONNECTION_INFORMATION_EX Info, IN ULONG Length, IN PUSB_DEVICE_HANDLE DeviceHandle)
Definition: usbhub.c:2558
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN BOOLEAN IsExt)
Definition: ioctl.c:828
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
USHORT PortEnabledDisabled
Definition: usb200.h:134
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI USBH_IoctlGetHubCapabilities(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:725
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
NTSTATUS NTAPI USBH_PdoIoctlSubmitUrb(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:204
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define IOCTL_INTERNAL_USB_RESET_PORT
Definition: usbioctl.h:35
#define IOCTL_INTERNAL_USB_GET_PORT_STATUS
Definition: usbioctl.h:44
NTSTATUS NTAPI USBH_SyncGetHubCount(IN PDEVICE_OBJECT DeviceObject, IN OUT PULONG OutHubCount)
Definition: usbhub.c:781
#define DPRINT1
Definition: precomp.h:8
USB_HUB_INFORMATION HubInformation
Definition: usbioctl.h:235
NTSTATUS NTAPI USBH_IoctlGetNodeInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:678
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
#define URB_FUNCTION_CONTROL_TRANSFER
Definition: usb.h:94
struct tagContext Context
Definition: acpixf.h:1012
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
PUSBHUB_PORT_PDO_EXTENSION PortExtension
Definition: usbhub.h:270
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
struct _USB_NODE_INFORMATION USB_NODE_INFORMATION
VOID NTAPI USBH_CheckHubIdle(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3727
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
NTSTATUS NTAPI USBH_PdoIoctlGetPortStatus(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:233
PUSBHUB_PORT_DATA PortData
Definition: usbhub.h:167
USB_PORT_STATUS PortStatus
Definition: usb200.h:240
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2725
IoMarkIrpPending(Irp)
PVOID TransferBuffer
Definition: usb.h:471
NTSTATUS NTAPI USBH_PortIdleNotificationRequest(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:481
#define USBHUB_PDO_FLAG_DELETE_PENDING
Definition: usbhub.h:68
ULONG TransferBufferLength
Definition: usb.h:470
ULONG PortAttributes
Definition: usbhub.h:121
USB_HUB_NODE NodeType
Definition: usbioctl.h:233
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Definition: usb.h:95
#define IOCTL_USB_GET_NODE_INFORMATION
Definition: usbioctl.h:169
Iosb Information
Definition: create.c:4377