ReactOS 0.4.17-dev-1190-g4c812f4
hidusb.h File Reference
#include <ntddk.h>
#include <hidport.h>
#include <debug.h>
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbioctl.h>
#include <usb.h>
#include <usbdlib.h>
Include dependency graph for hidusb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HID_USB_DEVICE_EXTENSION
 
struct  HID_USB_RESET_CONTEXT
 

Macros

#define _HIDPI_
 
#define _HIDPI_NO_FUNCTION_MACROS_
 
#define NDEBUG
 
#define USB_SET_IDLE_REQUEST   0xA
 
#define USB_GET_PROTOCOL_REQUEST   0x3
 
#define HIDUSB_TAG   'UdiH'
 
#define HIDUSB_URB_TAG   'rUiH'
 

Typedefs

typedef struct HID_USB_DEVICE_EXTENSION * PHID_USB_DEVICE_EXTENSION
 
typedef struct HID_USB_RESET_CONTEXT * PHID_USB_RESET_CONTEXT
 

Functions

NTSTATUS Hid_GetDescriptor (IN PDEVICE_OBJECT DeviceObject, IN USHORT UrbFunction, IN USHORT UrbLength, IN OUT PVOID *UrbBuffer, IN OUT PULONG UrbBufferLength, IN UCHAR DescriptorType, IN UCHAR Index, IN USHORT LanguageIndex)
 
NTSTATUS Hid_DispatchUrb (IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
 

Macro Definition Documentation

◆ _HIDPI_

#define _HIDPI_

Definition at line 3 of file hidusb.h.

◆ _HIDPI_NO_FUNCTION_MACROS_

#define _HIDPI_NO_FUNCTION_MACROS_

Definition at line 4 of file hidusb.h.

◆ HIDUSB_TAG

#define HIDUSB_TAG   'UdiH'

Definition at line 90 of file hidusb.h.

◆ HIDUSB_URB_TAG

#define HIDUSB_URB_TAG   'rUiH'

Definition at line 91 of file hidusb.h.

◆ NDEBUG

#define NDEBUG

Definition at line 5 of file hidusb.h.

◆ USB_GET_PROTOCOL_REQUEST

#define USB_GET_PROTOCOL_REQUEST   0x3

Definition at line 88 of file hidusb.h.

◆ USB_SET_IDLE_REQUEST

#define USB_SET_IDLE_REQUEST   0xA

Definition at line 87 of file hidusb.h.

Typedef Documentation

◆ PHID_USB_DEVICE_EXTENSION

◆ PHID_USB_RESET_CONTEXT

Function Documentation

◆ Hid_DispatchUrb()

NTSTATUS Hid_DispatchUrb ( IN PDEVICE_OBJECT  DeviceObject,
IN PURB  Urb 
)

Definition at line 962 of file hidusb.c.

965{
966 PIRP Irp;
968 PHID_DEVICE_EXTENSION DeviceExtension;
970 PIO_STACK_LOCATION IoStack;
972
973 //
974 // init event
975 //
977
978 //
979 // get device extension
980 //
981 DeviceExtension = DeviceObject->DeviceExtension;
982
983 //
984 // build irp
985 //
987 DeviceExtension->NextDeviceObject,
988 NULL,
989 0,
990 NULL,
991 0,
992 TRUE,
993 &Event,
994 &IoStatus);
995 if (!Irp)
996 {
997 //
998 // no memory
999 //
1001 }
1002
1003 //
1004 // get next stack location
1005 //
1006 IoStack = IoGetNextIrpStackLocation(Irp);
1007
1008 //
1009 // store urb
1010 //
1011 IoStack->Parameters.Others.Argument1 = Urb;
1012
1013 //
1014 // set completion routine
1015 //
1017
1018 //
1019 // call driver
1020 //
1021 Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
1022
1023 //
1024 // wait for the request to finish
1025 //
1026 if (Status == STATUS_PENDING)
1027 {
1029 }
1030
1031 //
1032 // complete request
1033 //
1035
1036 if (Status == STATUS_PENDING)
1037 {
1038 //
1039 // get final status
1040 //
1041 Status = IoStatus.Status;
1042 }
1043
1044 DPRINT("[HIDUSB] DispatchUrb %x\n", Status);
1045
1046
1047 //
1048 // done
1049 //
1050 return Status;
1051}
LONG NTSTATUS
Definition: precomp.h:26
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI Hid_PnpCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: hidusb.c:945
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
_In_ PIRP Irp
Definition: kse.h:79
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define KernelMode
Definition: asm.h:38
@ NotificationEvent
#define IoCompleteRequest
Definition: irp.c:1272
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:913
#define IoCallDriver
Definition: irp.c:1257
#define DPRINT
Definition: sndvol32.h:73
PDEVICE_OBJECT NextDeviceObject
Definition: hidport.h:18
struct _IO_STACK_LOCATION::@5020::@5059 Others
union _IO_STACK_LOCATION::@1814 Parameters
#define STATUS_PENDING
Definition: telnetd.h:14
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIO_STACK_LOCATION _In_ PURB Urb
Definition: usbdlib.h:294
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2702
#define IO_NO_INCREMENT
Definition: iotypes.h:598
@ Executive
Definition: ketypes.h:467

Referenced by Hid_DisableConfiguration(), Hid_GetDescriptor(), Hid_GetProtocol(), Hid_SelectConfiguration(), Hid_SetIdle(), HidUsb_AbortPipe(), and HidUsb_ResetInterruptPipe().

◆ Hid_GetDescriptor()

NTSTATUS Hid_GetDescriptor ( IN PDEVICE_OBJECT  DeviceObject,
IN USHORT  UrbFunction,
IN USHORT  UrbLength,
IN OUT PVOID *  UrbBuffer,
IN OUT PULONG  UrbBufferLength,
IN UCHAR  DescriptorType,
IN UCHAR  Index,
IN USHORT  LanguageIndex 
)

Definition at line 1054 of file hidusb.c.

1063{
1064 PURB Urb;
1067
1068 //
1069 // allocate urb
1070 //
1072 if (!Urb)
1073 {
1074 //
1075 // no memory
1076 //
1078 }
1079
1080 //
1081 // is there an urb buffer
1082 //
1083 if (!*UrbBuffer)
1084 {
1085 //
1086 // allocate buffer
1087 //
1088 *UrbBuffer = ExAllocatePoolWithTag(NonPagedPool, *UrbBufferLength, HIDUSB_TAG);
1089 if (!*UrbBuffer)
1090 {
1091 //
1092 // no memory
1093 //
1096 }
1097
1098 //
1099 // zero buffer
1100 //
1101 RtlZeroMemory(*UrbBuffer, *UrbBufferLength);
1102 Allocated = TRUE;
1103 }
1104
1105 //
1106 // zero urb
1107 //
1108 RtlZeroMemory(Urb, UrbLength);
1109
1110 //
1111 // build descriptor request
1112 //
1113 UsbBuildGetDescriptorRequest(Urb, UrbLength, DescriptorType, Index, LanguageIndex, *UrbBuffer, NULL, *UrbBufferLength, NULL);
1114
1115 //
1116 // set urb function
1117 //
1118 Urb->UrbHeader.Function = UrbFunction;
1119
1120 //
1121 // dispatch urb
1122 //
1124
1125 //
1126 // did the request fail
1127 //
1128 if (!NT_SUCCESS(Status))
1129 {
1130 if (Allocated)
1131 {
1132 //
1133 // free allocated buffer
1134 //
1135 ExFreePoolWithTag(*UrbBuffer, HIDUSB_TAG);
1136 *UrbBuffer = NULL;
1137 }
1138
1139 //
1140 // free urb
1141 //
1143 *UrbBufferLength = 0;
1144 return Status;
1145 }
1146
1147 //
1148 // did urb request fail
1149 //
1150 if (!NT_SUCCESS(Urb->UrbHeader.Status))
1151 {
1152 if (Allocated)
1153 {
1154 //
1155 // free allocated buffer
1156 //
1157 ExFreePoolWithTag(*UrbBuffer, HIDUSB_TAG);
1158 *UrbBuffer = NULL;
1159 }
1160
1161 //
1162 // free urb
1163 //
1165 *UrbBufferLength = 0;
1166 return STATUS_UNSUCCESSFUL;
1167 }
1168
1169 //
1170 // store result length
1171 //
1172 *UrbBufferLength = Urb->UrbControlDescriptorRequest.TransferBufferLength;
1173
1174 //
1175 // free urb
1176 //
1178
1179 //
1180 // completed successfully
1181 //
1182 return STATUS_SUCCESS;
1183}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
IN PFCB IN VBO OUT PLBO OUT PULONG OUT PBOOLEAN Allocated
Definition: fatprocs.h:311
NTSTATUS Hid_DispatchUrb(IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
Definition: hidusb.c:962
#define HIDUSB_URB_TAG
Definition: hidusb.h:91
#define HIDUSB_TAG
Definition: hidusb.h:90
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: usb.h:557
unsigned char UCHAR
Definition: typedefs.h:53
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UsbBuildGetDescriptorRequest(urb, length, descriptorType, descriptorIndex, languageId, transferBuffer, transferBufferMDL, transferBufferLength, link)
Definition: usbdlib.h:23
_In_ ULONG _In_ PVOID _In_ LONG DescriptorType
Definition: usbdlib.h:187
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by Hid_PnpStart(), and HidUsb_GetReportDescriptor().