Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1996,1997 Microsoft Corporation
  3. Module Name:
  4. hidmini.c
  5. Abstract: Human Input Device (HID) minidriver that creates an example
  6. device.
  7. --*/
  8. #include <WDM.H>
  9. #include <USBDI.H>
  10. #include <HIDPORT.H>
  11. #include <HIDMINI.H>
  12. NTSTATUS
  13. DriverEntry(
  14. IN PDRIVER_OBJECT DriverObject,
  15. IN PUNICODE_STRING registryPath
  16. )
  17. /*++
  18. Routine Description:
  19. Installable driver initialization entry point.
  20. This entry point is called directly by the I/O system.
  21. Arguments:
  22. DriverObject - pointer to the driver object
  23. registryPath - pointer to a unicode string representing the path,
  24. to driver-specific key in the registry.
  25. Return Value:
  26. STATUS_SUCCESS if successful,
  27. STATUS_UNSUCCESSFUL otherwise
  28. --*/
  29. {
  30. NTSTATUS ntStatus = STATUS_SUCCESS;
  31. HID_MINIDRIVER_REGISTRATION HidMinidriverRegistration;
  32. DBGPrint(("'HIDMINI.SYS: DriverEntry Enter\n"));
  33. DBGPrint(("'HIDMINI.SYS: DriverObject (%lx)\n", DriverObject));
  34. //
  35. // Create dispatch points
  36. //
  37. // All of the other dispatch routines are handled by HIDCLASS, except for
  38. // IRP_MJ_POWER, which isn't implemented yet.
  39. //
  40. DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = HidMiniIoctl;
  41. DriverObject->MajorFunction[IRP_MJ_PNP] = HidMiniPnP;
  42. DriverObject->DriverExtension->AddDevice = HidMiniAddDevice;
  43. DriverObject->DriverUnload = HidMiniUnload;
  44. //
  45. // Register Sample layer with HIDCLASS.SYS module
  46. //
  47. HidMinidriverRegistration.Revision = HID_REVISION;
  48. HidMinidriverRegistration.DriverObject = DriverObject;
  49. HidMinidriverRegistration.RegistryPath = registryPath;
  50. HidMinidriverRegistration.DeviceExtensionSize = sizeof(DEVICE_EXTENSION);
  51. // HIDMINI does not need to be polled.
  52. HidMinidriverRegistration.DevicesArePolled = FALSE;
  53. DBGPrint(("'HIDMINI.SYS: DeviceExtensionSize = %x\n", HidMinidriverRegistration.DeviceExtensionSize));
  54. DBGPrint(("'HIDMINI.SYS: Registering with HIDCLASS.SYS\n"));
  55. //
  56. // After registering with HIDCLASS, it takes over control of the device, and sends
  57. // things our way if they need device specific processing.
  58. //
  59. ntStatus = HidRegisterMinidriver(&HidMinidriverRegistration);
  60. DBGPrint(("'HIDMINI.SYS: DriverEntry Exit = %x\n", ntStatus));
  61. return ntStatus;
  62. }
  63. NTSTATUS
  64. HidMiniAddDevice(
  65. IN PDRIVER_OBJECT DriverObject,
  66. IN PDEVICE_OBJECT DeviceObject
  67. )
  68. /*++
  69. Routine Description:
  70. Process AddDevice. Provides the opportunity to initialize the DeviceObject or the
  71. DriverObject.
  72. Arguments:
  73. DriverObject - pointer to the driver object.
  74. DeviceObject - pointer to a device object.
  75. Return Value:
  76. NT status code.
  77. --*/
  78. {
  79. NTSTATUS ntStatus = STATUS_SUCCESS;
  80. PDEVICE_EXTENSION deviceExtension;
  81. DBGPrint(("'HIDMINI.SYS: HidMiniAddDevice Entry\n"));
  82. deviceExtension = GET_MINIDRIVER_DEVICE_EXTENSION( DeviceObject );
  83. KeInitializeEvent( &deviceExtension->AllRequestsCompleteEvent,
  84. NotificationEvent,
  85. FALSE );
  86. DBGPrint(("'HIDMINI.SYS: HidMiniAddDevice Exit = %x\n", ntStatus));
  87. return ntStatus;
  88. }
  89. VOID
  90. HidMiniUnload(
  91. IN PDRIVER_OBJECT DriverObject
  92. )
  93. /*++
  94. Routine Description:
  95. Free all the allocated resources, etc. in anticipation of this driver being unloaded.
  96. Arguments:
  97. DriverObject - pointer to the driver object.
  98. Return Value:
  99. VOID.
  100. --*/
  101. {
  102. DBGPrint(("'HIDMINI.SYS: HidMiniUnload Enter\n"));
  103. DBGPrint(("'HIDMINI.SYS: Unloading DriverObject = %x\n", DriverObject));
  104. DBGPrint(("'HIDMINI.SYS: Unloading Exit = VOID\n"));
  105. }