Leaked source code of windows server 2003
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.

180 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. ioctl.c
  5. Abstract: Human Input Device (HID) minidriver for Infrared (IR) devices
  6. The HID IR Minidriver (HidIr) provides an abstraction layer for the
  7. HID Class to talk to HID IR devices.
  8. Author:
  9. jsenior
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #include "pch.h"
  15. NTSTATUS
  16. HidIrIoctl(
  17. IN PDEVICE_OBJECT DeviceObject,
  18. IN PIRP Irp
  19. )
  20. /*++
  21. Routine Description:
  22. Process the Control IRPs sent to this device.
  23. Arguments:
  24. DeviceObject - pointer to a device object.
  25. Irp - pointer to an I/O Request Packet.
  26. Return Value:
  27. NT status code
  28. --*/
  29. {
  30. NTSTATUS ntStatus = STATUS_SUCCESS;
  31. PIO_STACK_LOCATION irpStack;
  32. BOOLEAN needsCompletion = TRUE;
  33. HidIrKdPrint((3, "HidIrIoctl Enter"));
  34. //
  35. // Get a pointer to the current location in the Irp
  36. //
  37. irpStack = IoGetCurrentIrpStackLocation(Irp);
  38. //
  39. // Get a pointer to the device extension
  40. //
  41. switch(irpStack->Parameters.DeviceIoControl.IoControlCode)
  42. {
  43. case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
  44. //
  45. // Return the HID descriptor
  46. //
  47. HidIrKdPrint((3, "IOCTL_HID_GET_DEVICE_DESCRIPTOR"));
  48. ntStatus = HidIrGetHidDescriptor (DeviceObject, Irp, HID_HID_DESCRIPTOR_TYPE);
  49. break;
  50. case IOCTL_HID_GET_REPORT_DESCRIPTOR:
  51. //
  52. // Return the Report descriptor
  53. //
  54. HidIrKdPrint((3, "IOCTL_HID_GET_REPORT_DESCRIPTOR"));
  55. ntStatus = HidIrGetHidDescriptor (DeviceObject, Irp, HID_REPORT_DESCRIPTOR_TYPE);
  56. break;
  57. case IOCTL_GET_PHYSICAL_DESCRIPTOR:
  58. //
  59. // Return the Report descriptor
  60. //
  61. HidIrKdPrint((3, "IOCTL_HID_GET_REPORT_DESCRIPTOR"));
  62. ntStatus = HidIrGetHidDescriptor (DeviceObject, Irp, HID_PHYSICAL_DESCRIPTOR_TYPE);
  63. break;
  64. case IOCTL_HID_READ_REPORT:
  65. //
  66. // Perform a read
  67. //
  68. HidIrKdPrint((3, "IOCTL_HID_READ_REPORT"));
  69. ntStatus = HidIrReadReport (DeviceObject, Irp, &needsCompletion);
  70. break;
  71. case IOCTL_HID_WRITE_REPORT:
  72. //
  73. // Perform a write
  74. //
  75. HidIrKdPrint((3, "IOCTL_HID_WRITE_REPORT not supported for IR"));
  76. ntStatus = STATUS_UNSUCCESSFUL;
  77. break;
  78. case IOCTL_HID_ACTIVATE_DEVICE:
  79. case IOCTL_HID_DEACTIVATE_DEVICE:
  80. /*
  81. * We don't do anything for these IOCTLs but some minidrivers might.
  82. */
  83. ntStatus = STATUS_SUCCESS;
  84. break;
  85. case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
  86. HidIrKdPrint((3, "IOCTL_GET_DEVICE_ATTRIBUTES"));
  87. ntStatus = HidIrGetDeviceAttributes(DeviceObject, Irp);
  88. break;
  89. case IOCTL_HID_GET_FEATURE:
  90. case IOCTL_HID_GET_INPUT_REPORT:
  91. case IOCTL_HID_SET_FEATURE:
  92. case IOCTL_HID_SET_OUTPUT_REPORT:
  93. case IOCTL_HID_GET_MS_GENRE_DESCRIPTOR:
  94. /*
  95. * This IOCTL uses buffering method METHOD_NEITHER,
  96. * so the buffer is Irp->UserBuffer.
  97. * If the IRP is coming to us from user space,
  98. * we must validate the buffer.
  99. */
  100. case IOCTL_HID_GET_STRING:
  101. case IOCTL_HID_GET_INDEXED_STRING:
  102. // Strings.
  103. case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST:
  104. // ntStatus = HidIrSendIdleNotificationRequest(DeviceObject, Irp, &needsCompletion);
  105. // break;
  106. default:
  107. HidIrKdPrint((3, "Unknown or unsupported IOCTL (%x)", irpStack->Parameters.DeviceIoControl.IoControlCode));
  108. /*
  109. * Note: do not return STATUS_NOT_SUPPORTED;
  110. * Just keep the default status (this allows filter drivers to work).
  111. */
  112. ntStatus = Irp->IoStatus.Status;
  113. break;
  114. }
  115. //
  116. // Complete Irp
  117. //
  118. if (needsCompletion) {
  119. ASSERT(ntStatus != STATUS_PENDING);
  120. //
  121. // Set real return status in Irp
  122. //
  123. Irp->IoStatus.Status = ntStatus;
  124. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  125. }
  126. HidIrKdPrint((3, "HidIrIoctl Exit = %x", ntStatus));
  127. return ntStatus;
  128. }