ReactOS 0.4.17-dev-1421-g4623072
precomp.h File Reference
#include <wdm.h>
#include <hidpddi.h>
#include <stdio.h>
#include <hidport.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HIDCLASS_DRIVER_EXTENSION
 
struct  HIDCLASS_COMMON_DEVICE_EXTENSION
 
struct  HIDCLASS_FDO_EXTENSION
 
struct  HIDCLASS_PDO_DEVICE_EXTENSION
 
struct  __HIDCLASS_FILEOP_CONTEXT__
 
struct  HIDCLASS_IRP_CONTEXT
 

Macros

#define _HIDPI_NO_FUNCTION_MACROS_
 
#define HIDCLASS_TAG   'CdiH'
 

Typedefs

typedef struct HIDCLASS_DRIVER_EXTENSION * PHIDCLASS_DRIVER_EXTENSION
 
typedef struct HIDCLASS_COMMON_DEVICE_EXTENSION * PHIDCLASS_COMMON_DEVICE_EXTENSION
 
typedef struct HIDCLASS_FDO_EXTENSION * PHIDCLASS_FDO_EXTENSION
 
typedef struct HIDCLASS_PDO_DEVICE_EXTENSION * PHIDCLASS_PDO_DEVICE_EXTENSION
 
typedef struct __HIDCLASS_FILEOP_CONTEXT__ HIDCLASS_FILEOP_CONTEXT
 
typedef struct __HIDCLASS_FILEOP_CONTEXT__ * PHIDCLASS_FILEOP_CONTEXT
 
typedef struct HIDCLASS_IRP_CONTEXT * PHIDCLASS_IRP_CONTEXT
 

Functions

NTSTATUS HidClassFDO_PnP (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS HidClassFDO_DispatchRequest (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS HidClassFDO_DispatchRequestSynchronous (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS HidClassPDO_CreatePDO (IN PDEVICE_OBJECT DeviceObject, OUT PDEVICE_RELATIONS *OutDeviceRelations)
 
NTSTATUS HidClassPDO_PnP (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
PHIDP_COLLECTION_DESC HidClassPDO_GetCollectionDescription (PHIDP_DEVICE_DESC DeviceDescription, ULONG CollectionNumber)
 
PHIDP_REPORT_IDS HidClassPDO_GetReportDescription (PHIDP_DEVICE_DESC DeviceDescription, ULONG CollectionNumber)
 
PHIDP_REPORT_IDS HidClassPDO_GetReportDescriptionByReportID (PHIDP_DEVICE_DESC DeviceDescription, UCHAR ReportID)
 

Macro Definition Documentation

◆ _HIDPI_NO_FUNCTION_MACROS_

#define _HIDPI_NO_FUNCTION_MACROS_

Definition at line 4 of file precomp.h.

◆ HIDCLASS_TAG

#define HIDCLASS_TAG   'CdiH'

Definition at line 10 of file precomp.h.

Typedef Documentation

◆ HIDCLASS_FILEOP_CONTEXT

◆ PHIDCLASS_COMMON_DEVICE_EXTENSION

◆ PHIDCLASS_DRIVER_EXTENSION

◆ PHIDCLASS_FDO_EXTENSION

◆ PHIDCLASS_FILEOP_CONTEXT

◆ PHIDCLASS_IRP_CONTEXT

◆ PHIDCLASS_PDO_DEVICE_EXTENSION

Function Documentation

◆ HidClassFDO_DispatchRequest()

NTSTATUS HidClassFDO_DispatchRequest ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 217 of file fdo.c.

220{
221 PHIDCLASS_COMMON_DEVICE_EXTENSION CommonDeviceExtension;
223 PIO_STACK_LOCATION IoStack;
224
225 //
226 // get device extension
227 //
228 CommonDeviceExtension = DeviceObject->DeviceExtension;
229
230 ASSERT(Irp->CurrentLocation > 0);
231
232 //
233 // create stack location
234 //
236
237 //
238 // get next stack location
239 //
241
242 //
243 // store device object
244 //
245 IoStack->DeviceObject = DeviceObject;
246
247 //
248 // sanity check
249 //
250 ASSERT(CommonDeviceExtension->DriverExtension->MajorFunction[IoStack->MajorFunction] != NULL);
251
252 //
253 // call driver
254 //
255 Status = CommonDeviceExtension->DriverExtension->MajorFunction[IoStack->MajorFunction](DeviceObject, Irp);
256
257 //
258 // done
259 //
260 return Status;
261}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:24
_In_ PIRP Irp
Definition: kse.h:79
#define ASSERT(a)
Definition: mode.c:44
PHIDCLASS_DRIVER_EXTENSION DriverExtension
Definition: precomp.h:39
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: precomp.h:17
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:3238
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:3005

Referenced by HidClass_Power(), HidClassFDO_DeviceRelations(), and HidClassFDO_PnP().

◆ HidClassFDO_DispatchRequestSynchronous()

NTSTATUS HidClassFDO_DispatchRequestSynchronous ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 147 of file fdo.c.

150{
152 PHIDCLASS_COMMON_DEVICE_EXTENSION CommonDeviceExtension;
154 PIO_STACK_LOCATION IoStack;
155
156 //
157 // init event
158 //
160
161 //
162 // get device extension
163 //
164 CommonDeviceExtension = DeviceObject->DeviceExtension;
165
166 //
167 // set completion routine
168 //
170
171 ASSERT(Irp->CurrentLocation > 0);
172 //
173 // create stack location
174 //
176
177 //
178 // get next stack location
179 //
181
182 //
183 // store device object
184 //
185 IoStack->DeviceObject = DeviceObject;
186
187 //
188 // sanity check
189 //
190 ASSERT(CommonDeviceExtension->DriverExtension->MajorFunction[IoStack->MajorFunction] != NULL);
191
192 //
193 // call minidriver (hidusb)
194 //
195 Status = CommonDeviceExtension->DriverExtension->MajorFunction[IoStack->MajorFunction](DeviceObject, Irp);
196
197 //
198 // wait for the request to finish
199 //
200 if (Status == STATUS_PENDING)
201 {
203
204 //
205 // update status
206 //
207 Status = Irp->IoStatus.Status;
208 }
209
210 //
211 // done
212 //
213 return Status;
214}
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
#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
NTSTATUS NTAPI HidClassFDO_DispatchRequestSynchronousCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: fdo.c:129
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
#define KernelMode
Definition: asm.h:38
@ NotificationEvent
#define STATUS_PENDING
Definition: telnetd.h:14
@ Executive
Definition: ketypes.h:467

Referenced by HidClassFDO_GetDescriptors(), HidClassFDO_RemoveDevice(), HidClassFDO_StartDevice(), HidClassPDO_HandleQueryDeviceId(), and HidClassPDO_HandleQueryHardwareId().

◆ HidClassFDO_PnP()

NTSTATUS HidClassFDO_PnP ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 659 of file fdo.c.

662{
663 PIO_STACK_LOCATION IoStack;
664 PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
666
667 //
668 // get device extension
669 //
670 FDODeviceExtension = DeviceObject->DeviceExtension;
671 ASSERT(FDODeviceExtension->Common.IsFDO);
672
673 //
674 // get current irp stack location
675 //
677 switch (IoStack->MinorFunction)
678 {
680 {
682 }
684 {
686 }
688 {
690 }
695 {
696 //
697 // set status to success and fall through
698 //
699 Irp->IoStatus.Status = STATUS_SUCCESS;
700 }
701 default:
702 {
703 //
704 // dispatch to mini driver
705 //
708 return Status;
709 }
710 }
711}
NTSTATUS HidClassFDO_RemoveDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:481
NTSTATUS HidClassFDO_DispatchRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:217
NTSTATUS HidClassFDO_StartDevice(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:393
NTSTATUS HidClassFDO_DeviceRelations(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: fdo.c:576
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
#define STATUS_SUCCESS
Definition: shellext.h:65
HIDCLASS_COMMON_DEVICE_EXTENSION Common
Definition: precomp.h:58
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_START_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

Referenced by HidClass_PnP().

◆ HidClassPDO_CreatePDO()

NTSTATUS HidClassPDO_CreatePDO ( IN PDEVICE_OBJECT  DeviceObject,
OUT PDEVICE_RELATIONS *  OutDeviceRelations 
)

Definition at line 699 of file pdo.c.

702{
703 PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
705 PDEVICE_OBJECT PDODeviceObject;
706 PHIDCLASS_PDO_DEVICE_EXTENSION PDODeviceExtension;
707 PHIDP_COLLECTION_DESC CollectionDescription;
708 ULONG Index;
709 PDEVICE_RELATIONS DeviceRelations;
711
712 //
713 // get device extension
714 //
715 FDODeviceExtension = DeviceObject->DeviceExtension;
716 ASSERT(FDODeviceExtension->Common.IsFDO);
717
718 //
719 // first allocate device relations
720 //
723 if (!DeviceRelations)
724 {
725 //
726 // no memory
727 //
729 }
730
731 //
732 // zero device relations
733 //
734 RtlZeroMemory(DeviceRelations, Length);
735
736 //
737 // let's create a PDO for top level collection
738 //
739 Index = 0;
740 while (Index < FDODeviceExtension->Common.DeviceDescription.CollectionDescLength)
741 {
742 //
743 // let's create the device object
744 //
747 NULL,
750 FALSE,
751 &PDODeviceObject);
752 if (!NT_SUCCESS(Status))
753 {
754 //
755 // failed to create device
756 //
757 DPRINT1("[HIDCLASS] Failed to create PDO %x\n", Status);
758 break;
759 }
760
761 //
762 // patch stack size
763 //
764 PDODeviceObject->StackSize = DeviceObject->StackSize + 1;
765
766 //
767 // get device extension
768 //
769 PDODeviceExtension = PDODeviceObject->DeviceExtension;
770
771 //
772 // init device extension
773 //
774 CollectionDescription = &FDODeviceExtension->Common.DeviceDescription.CollectionDesc[Index];
777 PDODeviceExtension->Common.HidDeviceExtension.PhysicalDeviceObject = PDODeviceObject;
778 PDODeviceExtension->Common.IsFDO = FALSE;
779 PDODeviceExtension->FDODeviceExtension = FDODeviceExtension;
780 PDODeviceExtension->FDODeviceObject = DeviceObject;
781 PDODeviceExtension->Common.DriverExtension = FDODeviceExtension->Common.DriverExtension;
782 PDODeviceExtension->CollectionNumber = CollectionDescription->CollectionNumber;
783 PDODeviceExtension->InstanceID = Index;
784
785 //
786 // copy device data
787 //
788 RtlCopyMemory(&PDODeviceExtension->Common.Attributes, &FDODeviceExtension->Common.Attributes, sizeof(HID_DEVICE_ATTRIBUTES));
789 RtlCopyMemory(&PDODeviceExtension->Common.DeviceDescription, &FDODeviceExtension->Common.DeviceDescription, sizeof(HIDP_DEVICE_DESC));
790 RtlCopyMemory(&PDODeviceExtension->Capabilities, &FDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
791
792 //
793 // is it a keyboard or mouse (we'll need it for multiple things)
794 //
795 PDODeviceExtension->IsKeyboardOrMouse = CollectionDescription->UsagePage == HID_USAGE_PAGE_GENERIC &&
796 (CollectionDescription->Usage == HID_USAGE_GENERIC_POINTER ||
797 CollectionDescription->Usage == HID_USAGE_GENERIC_MOUSE ||
798 CollectionDescription->Usage == HID_USAGE_GENERIC_KEYBOARD ||
799 CollectionDescription->Usage == HID_USAGE_GENERIC_KEYPAD);
800
801 //
802 // set device flags
803 //
804 PDODeviceObject->Flags |= DO_MAP_IO_BUFFER;
805
806 //
807 // device is initialized
808 //
809 PDODeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
810
811 //
812 // store device object in device relations
813 //
814 DeviceRelations->Objects[Index] = PDODeviceObject;
815 DeviceRelations->Count++;
816
817 //
818 // move to next
819 //
820 Index++;
821
822 }
823
824
825 //
826 // check if creating succeeded
827 //
828 if (!NT_SUCCESS(Status))
829 {
830 //
831 // failed
832 //
833 for (Index = 0; Index < DeviceRelations->Count; Index++)
834 {
835 //
836 // delete device
837 //
838 IoDeleteDevice(DeviceRelations->Objects[Index]);
839 }
840
841 //
842 // free device relations
843 //
844 ExFreePoolWithTag(DeviceRelations, HIDCLASS_TAG);
845 return Status;
846 }
847
848 //
849 // store device relations
850 //
851 *OutDeviceRelations = DeviceRelations;
852
853 //
854 // done
855 //
856 return STATUS_SUCCESS;
857}
#define DPRINT1
Definition: precomp.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define HIDCLASS_TAG
Definition: precomp.h:10
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _DEVICE_OBJECT * PDEVICE_OBJECT
#define DO_MAP_IO_BUFFER
Definition: env_spec_w32.h:397
#define PagedPool
Definition: env_spec_w32.h:308
#define HID_USAGE_GENERIC_MOUSE
Definition: hidusage.h:33
#define HID_USAGE_GENERIC_POINTER
Definition: hidusage.h:32
#define HID_USAGE_GENERIC_KEYPAD
Definition: hidusage.h:37
#define HID_USAGE_PAGE_GENERIC
Definition: hidusage.h:176
#define HID_USAGE_GENERIC_KEYBOARD
Definition: hidusage.h:36
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:142
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1038
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1261
#define FILE_DEVICE_UNKNOWN
Definition: winioctl.h:79
HIDP_DEVICE_DESC DeviceDescription
Definition: precomp.h:44
HID_DEVICE_ATTRIBUTES Attributes
Definition: precomp.h:49
HID_DEVICE_EXTENSION HidDeviceExtension
Definition: precomp.h:29
PDRIVER_OBJECT DriverObject
Definition: precomp.h:14
DEVICE_CAPABILITIES Capabilities
Definition: precomp.h:63
HIDCLASS_COMMON_DEVICE_EXTENSION Common
Definition: precomp.h:92
PDEVICE_OBJECT FDODeviceObject
Definition: precomp.h:122
PHIDCLASS_FDO_EXTENSION FDODeviceExtension
Definition: precomp.h:127
DEVICE_CAPABILITIES Capabilities
Definition: precomp.h:97
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2165
UCHAR CollectionNumber
Definition: hidpddi.h:11
PHIDP_COLLECTION_DESC CollectionDesc
Definition: hidpddi.h:38
ULONG CollectionDescLength
Definition: hidpddi.h:39
PDEVICE_OBJECT PhysicalDeviceObject
Definition: hidport.h:17
PVOID MiniDeviceExtension
Definition: hidport.h:19
PDEVICE_OBJECT NextDeviceObject
Definition: hidport.h:18
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFCOLLECTION _In_ ULONG Index
DEVICE_CAPABILITIES
Definition: iotypes.h:965

Referenced by HidClassFDO_DeviceRelations().

◆ HidClassPDO_GetCollectionDescription()

PHIDP_COLLECTION_DESC HidClassPDO_GetCollectionDescription ( PHIDP_DEVICE_DESC  DeviceDescription,
ULONG  CollectionNumber 
)

Definition at line 19 of file pdo.c.

22{
24
25 for(Index = 0; Index < DeviceDescription->CollectionDescLength; Index++)
26 {
27 if (DeviceDescription->CollectionDesc[Index].CollectionNumber == CollectionNumber)
28 {
29 //
30 // found collection
31 //
32 return &DeviceDescription->CollectionDesc[Index];
33 }
34 }
35
36 //
37 // failed to find collection
38 //
39 DPRINT1("[HIDCLASS] GetCollectionDescription CollectionNumber %x not found\n", CollectionNumber);
41 return NULL;
42}
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432

Referenced by HidClass_BuildIrp(), HidClass_DeviceControl(), HidClass_ReadCompleteIrp(), and HidClassPDO_HandleQueryHardwareId().

◆ HidClassPDO_GetReportDescription()

PHIDP_REPORT_IDS HidClassPDO_GetReportDescription ( PHIDP_DEVICE_DESC  DeviceDescription,
ULONG  CollectionNumber 
)

Definition at line 45 of file pdo.c.

48{
50
51 for (Index = 0; Index < DeviceDescription->ReportIDsLength; Index++)
52 {
53 if (DeviceDescription->ReportIDs[Index].CollectionNumber == CollectionNumber)
54 {
55 //
56 // found collection
57 //
58 return &DeviceDescription->ReportIDs[Index];
59 }
60 }
61
62 //
63 // failed to find collection
64 //
65 DPRINT1("[HIDCLASS] GetReportDescription CollectionNumber %x not found\n", CollectionNumber);
67 return NULL;
68}

Referenced by HidClass_BuildIrp(), and HidClass_ReadCompleteIrp().

◆ HidClassPDO_GetReportDescriptionByReportID()

PHIDP_REPORT_IDS HidClassPDO_GetReportDescriptionByReportID ( PHIDP_DEVICE_DESC  DeviceDescription,
UCHAR  ReportID 
)

Definition at line 71 of file pdo.c.

74{
76
77 for (Index = 0; Index < DeviceDescription->ReportIDsLength; Index++)
78 {
79 if (DeviceDescription->ReportIDs[Index].ReportID == ReportID)
80 {
81 //
82 // found report id
83 //
84 return &DeviceDescription->ReportIDs[Index];
85 }
86 }
87
88 //
89 // failed to find report id
90 //
91 DPRINT1("[HIDCLASS] GetReportDescriptionByReportID ReportID %x not found\n", ReportID);
93 return NULL;
94}
_Must_inspect_result_ _In_ UCHAR ReportID
Definition: hidpi.h:482

Referenced by HidClass_DeviceControl().

◆ HidClassPDO_PnP()

NTSTATUS HidClassPDO_PnP ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 382 of file pdo.c.

385{
386 PHIDCLASS_PDO_DEVICE_EXTENSION PDODeviceExtension;
387 PIO_STACK_LOCATION IoStack;
390 PDEVICE_RELATIONS DeviceRelation;
391 ULONG Index, bFound;
392
393 //
394 // get device extension
395 //
396 PDODeviceExtension = DeviceObject->DeviceExtension;
397 ASSERT(PDODeviceExtension->Common.IsFDO == FALSE);
398
399 //
400 // get current irp stack location
401 //
403
404 //
405 // handle request
406 //
407 switch (IoStack->MinorFunction)
408 {
409 case IRP_MN_QUERY_ID:
410 {
411 if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID)
412 {
413 //
414 // handle query device id
415 //
417 break;
418 }
419 else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
420 {
421 //
422 // handle instance id
423 //
425 break;
426 }
427 else if (IoStack->Parameters.QueryId.IdType == BusQueryInstanceID)
428 {
429 //
430 // handle instance id
431 //
433 break;
434 }
435 else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
436 {
437 //
438 // handle instance id
439 //
441 break;
442 }
443
444 DPRINT1("[HIDCLASS]: IRP_MN_QUERY_ID IdType %x unimplemented\n", IoStack->Parameters.QueryId.IdType);
446 Irp->IoStatus.Information = 0;
447 break;
448 }
450 {
451 if (IoStack->Parameters.DeviceCapabilities.Capabilities == NULL)
452 {
453 //
454 // invalid request
455 //
457 break;
458 }
459
460 //
461 // copy capabilities
462 //
463 RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
464 &PDODeviceExtension->Capabilities,
465 sizeof(DEVICE_CAPABILITIES));
466
467 //
468 // override some capabilities
469 //
470 IoStack->Parameters.DeviceCapabilities.Capabilities->Removable = FALSE;
471 IoStack->Parameters.DeviceCapabilities.Capabilities->SilentInstall = TRUE;
472 IoStack->Parameters.DeviceCapabilities.Capabilities->SurpriseRemovalOK = TRUE;
473 IoStack->Parameters.DeviceCapabilities.Capabilities->RawDeviceOK = !PDODeviceExtension->IsKeyboardOrMouse;
474
476 break;
477 }
479 {
480 //
481 //
482 //
484
485 //
486 // fill in result
487 //
488 RtlCopyMemory(&BusInformation->BusTypeGuid, &GUID_BUS_TYPE_HID, sizeof(GUID));
489 BusInformation->LegacyBusType = PNPBus;
490 BusInformation->BusNumber = 0; //FIXME
491
492 //
493 // store result
494 //
495 Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
497 break;
498 }
500 {
501 //
502 // FIXME set flags when driver fails / disabled
503 //
505 break;
506 }
508 {
509 //
510 // only target relations are supported
511 //
513 {
514 //
515 // not supported
516 //
517 Status = Irp->IoStatus.Status;
518 break;
519 }
520
521 //
522 // allocate device relations
523 //
525 if (!DeviceRelation)
526 {
527 //
528 // no memory
529 //
531 break;
532 }
533
534 //
535 // init device relation
536 //
537 DeviceRelation->Count = 1;
538 DeviceRelation->Objects[0] = DeviceObject;
539 ObReferenceObject(DeviceRelation->Objects[0]);
540
541 //
542 // store result
543 //
544 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
546 break;
547 }
549 {
550 //
551 // FIXME: support polled devices
552 //
553 ASSERT(PDODeviceExtension->Common.DriverExtension->DevicesArePolled == FALSE);
554
555 if (!PDODeviceExtension->IsKeyboardOrMouse)
556 {
557 //
558 // now register the device interface
559 //
561 &GUID_DEVINTERFACE_HID,
562 NULL,
563 &PDODeviceExtension->DeviceInterface);
564 DPRINT("[HIDCLASS] IoRegisterDeviceInterfaceState Status %x\n", Status);
565 if (NT_SUCCESS(Status))
566 {
567 //
568 // enable device interface
569 //
570 Status = IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, TRUE);
571 DPRINT("[HIDCLASS] IoSetDeviceInterFaceState %x\n", Status);
572 }
573 }
574
575 //
576 // done
577 //
579 break;
580 }
582 {
583 /* Disable the device interface */
584 if (PDODeviceExtension->DeviceInterface.Length != 0)
585 IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, FALSE);
586
587 //
588 // remove us from the fdo's pdo list
589 //
590 bFound = FALSE;
591 for (Index = 0; Index < PDODeviceExtension->FDODeviceExtension->DeviceRelations->Count; Index++)
592 {
593 if (PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] == DeviceObject)
594 {
595 //
596 // remove us
597 //
598 bFound = TRUE;
599 PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] = NULL;
600 break;
601 }
602 }
603
604 /* Complete the IRP */
605 Irp->IoStatus.Status = STATUS_SUCCESS;
607
608 if (bFound)
609 {
610 /* Delete our device object*/
612 }
613
614 return STATUS_SUCCESS;
615 }
617 {
618 //
619 // return error default
620 //
621 Status = Irp->IoStatus.Status;
622
623 //
624 // check for known interfaces
625 //
626 if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
627 &GUID_HID_INTERFACE_NOTIFY))
628 {
629 PHID_INTERFACE_NOTIFY_PNP HidInterfaceNotify = (PHID_INTERFACE_NOTIFY_PNP)IoStack->Parameters.QueryInterface.Interface;
630 if (IoStack->Parameters.QueryInterface.Size == sizeof(*HidInterfaceNotify) &&
631 IoStack->Parameters.QueryInterface.Version == 1)
632 {
633 DPRINT1("[HIDCLASS] PDO IRP_MN_QUERY_INTERFACE/GUID_HID_INTERFACE_NOTIFY not implemented\n");
634 ASSERT(FALSE);
635 }
636 }
637 else if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
638 &GUID_HID_INTERFACE_HIDPARSE))
639 {
640 PHID_INTERFACE_HIDPARSE HidInterfaceHidparse = (PHID_INTERFACE_HIDPARSE)IoStack->Parameters.QueryInterface.Interface;
641 if (IoStack->Parameters.QueryInterface.Size == sizeof(*HidInterfaceHidparse) &&
642 IoStack->Parameters.QueryInterface.Version == 1)
643 {
644 HidInterfaceHidparse->HidpGetCaps = HidP_GetCaps;
646 }
647 }
648 break;
649 }
654 {
655 //
656 // no/op
657 //
658#if 0
660#else
661 DPRINT1("Denying removal of HID device due to IRP cancellation bugs\n");
663#endif
664 break;
665 }
666 default:
667 {
668 //
669 // do nothing
670 //
671 Status = Irp->IoStatus.Status;
672 break;
673 }
674 }
675
676 //
677 // complete request
678 //
679 if (Status != STATUS_PENDING)
680 {
681 //
682 // store result
683 //
684 Irp->IoStatus.Status = Status;
685
686 //
687 // complete request
688 //
690 }
691
692 //
693 // done processing
694 //
695 return Status;
696}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define ULONG_PTR
Definition: config.h:101
#define NonPagedPool
Definition: env_spec_w32.h:307
NTSTATUS HidClassPDO_HandleQueryCompatibleId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:353
NTSTATUS HidClassPDO_HandleQueryInstanceId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:315
NTSTATUS HidClassPDO_HandleQueryHardwareId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:183
NTSTATUS HidClassPDO_HandleQueryDeviceId(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: pdo.c:141
struct _HID_INTERFACE_HIDPARSE * PHID_INTERFACE_HIDPARSE
struct _HID_INTERFACE_NOTIFY_PNP * PHID_INTERFACE_NOTIFY_PNP
HIDAPI NTSTATUS NTAPI HidP_GetCaps(IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities)
Definition: hidp.c:26
if(dx< 0)
Definition: linetemp.h:194
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:1451
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1807
#define IoCompleteRequest
Definition: irp.c:1272
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:713
@ PNPBus
Definition: restypes.h:137
#define DPRINT
Definition: sndvol32.h:73
PDEVICE_RELATIONS DeviceRelations
Definition: precomp.h:83
UNICODE_STRING DeviceInterface
Definition: precomp.h:117
PHIDP_GETCAPS HidpGetCaps
Definition: hidclass.h:131
union _IO_STACK_LOCATION::@1823 Parameters
struct _IO_STACK_LOCATION::@5134::@5160 QueryInterface
struct _IO_STACK_LOCATION::@5134::@5165 QueryId
struct _IO_STACK_LOCATION::@5134::@5159 QueryDeviceRelations
struct _IO_STACK_LOCATION::@5134::@5161 DeviceCapabilities
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3921
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235
@ TargetDeviceRelation
Definition: iotypes.h:2158
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_QUERY_ID
#define IRP_MN_QUERY_CAPABILITIES
@ BusQueryCompatibleIDs
Definition: iotypes.h:2953
@ BusQueryInstanceID
Definition: iotypes.h:2954
@ BusQueryDeviceID
Definition: iotypes.h:2951
@ BusQueryHardwareIDs
Definition: iotypes.h:2952
#define IRP_MN_QUERY_BUS_INFORMATION
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by HidClass_PnP().