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.

237 lines
5.2 KiB

  1. /*++
  2. Copyright (c) 1998-2001 Microsoft Corporation
  3. Module Name:
  4. devctrl.cxx
  5. Abstract:
  6. This module contains the dispatcher for device control IRPs.
  7. Author:
  8. Keith Moore (keithmo) 10-Jun-1998
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #ifdef ALLOC_PRAGMA
  13. #endif // ALLOC_PRAGMA
  14. #if 0
  15. NOT PAGEABLE -- UlDeviceControl
  16. #endif
  17. //
  18. // Lookup table to verify incoming IOCTL codes.
  19. //
  20. typedef
  21. NTSTATUS
  22. (NTAPI * PFN_IOCTL_HANDLER)(
  23. IN PIRP Irp,
  24. IN PIO_STACK_LOCATION IrpSp
  25. );
  26. typedef struct _UL_IOCTL_TABLE
  27. {
  28. ULONG IoControlCode;
  29. #if DBG
  30. PCSTR IoControlName;
  31. # define UL_IOCTL(code) IOCTL_HTTP_##code, #code
  32. #else // !DBG
  33. # define UL_IOCTL(code) IOCTL_HTTP_##code
  34. #endif // !DBG
  35. PFN_IOCTL_HANDLER Handler;
  36. } UL_IOCTL_TABLE, *PUL_IOCTL_TABLE;
  37. UL_IOCTL_TABLE UlIoctlTable[] =
  38. {
  39. { UL_IOCTL(QUERY_CONTROL_CHANNEL),
  40. &UlQueryControlChannelIoctl
  41. },
  42. { UL_IOCTL(SET_CONTROL_CHANNEL),
  43. &UlSetControlChannelIoctl
  44. },
  45. { UL_IOCTL(CREATE_CONFIG_GROUP),
  46. &UlCreateConfigGroupIoctl
  47. },
  48. { UL_IOCTL(DELETE_CONFIG_GROUP),
  49. &UlDeleteConfigGroupIoctl
  50. },
  51. { UL_IOCTL(QUERY_CONFIG_GROUP),
  52. &UlQueryConfigGroupIoctl
  53. },
  54. { UL_IOCTL(SET_CONFIG_GROUP),
  55. &UlSetConfigGroupIoctl
  56. },
  57. { UL_IOCTL(ADD_URL_TO_CONFIG_GROUP),
  58. &UlAddUrlToConfigGroupIoctl
  59. },
  60. { UL_IOCTL(REMOVE_URL_FROM_CONFIG_GROUP),
  61. &UlRemoveUrlFromConfigGroupIoctl
  62. },
  63. { UL_IOCTL(QUERY_APP_POOL_INFORMATION),
  64. &UlQueryAppPoolInformationIoctl
  65. },
  66. { UL_IOCTL(SET_APP_POOL_INFORMATION),
  67. &UlSetAppPoolInformationIoctl
  68. },
  69. { UL_IOCTL(RECEIVE_HTTP_REQUEST),
  70. &UlReceiveHttpRequestIoctl
  71. },
  72. { UL_IOCTL(RECEIVE_ENTITY_BODY),
  73. &UlReceiveEntityBodyIoctl
  74. },
  75. { UL_IOCTL(SEND_HTTP_RESPONSE),
  76. &UlSendHttpResponseIoctl
  77. },
  78. { UL_IOCTL(SEND_ENTITY_BODY),
  79. &UlSendEntityBodyIoctl
  80. },
  81. { UL_IOCTL(FLUSH_RESPONSE_CACHE),
  82. &UlFlushResponseCacheIoctl
  83. },
  84. { UL_IOCTL(WAIT_FOR_DEMAND_START),
  85. &UlWaitForDemandStartIoctl
  86. },
  87. { UL_IOCTL(WAIT_FOR_DISCONNECT),
  88. &UlWaitForDisconnectIoctl
  89. },
  90. { UL_IOCTL(REMOVE_ALL_URLS_FROM_CONFIG_GROUP),
  91. &UlRemoveAllUrlsFromConfigGroupIoctl
  92. },
  93. { UL_IOCTL(ADD_TRANSIENT_URL),
  94. &UlAddTransientUrlIoctl
  95. },
  96. { UL_IOCTL(REMOVE_TRANSIENT_URL),
  97. &UlRemoveTransientUrlIoctl
  98. },
  99. { UL_IOCTL(FILTER_ACCEPT),
  100. &UlFilterAcceptIoctl
  101. },
  102. { UL_IOCTL(FILTER_CLOSE),
  103. &UlFilterCloseIoctl
  104. },
  105. { UL_IOCTL(FILTER_RAW_READ),
  106. &UlFilterRawReadIoctl
  107. },
  108. { UL_IOCTL(FILTER_RAW_WRITE),
  109. &UlFilterRawWriteIoctl
  110. },
  111. { UL_IOCTL(FILTER_APP_READ),
  112. &UlFilterAppReadIoctl
  113. },
  114. { UL_IOCTL(FILTER_APP_WRITE),
  115. &UlFilterAppWriteIoctl
  116. },
  117. { UL_IOCTL(FILTER_RECEIVE_CLIENT_CERT),
  118. &UlReceiveClientCertIoctl
  119. },
  120. { UL_IOCTL(GET_COUNTERS),
  121. &UlGetCountersIoctl
  122. },
  123. };
  124. C_ASSERT( HTTP_NUM_IOCTLS == DIMENSION(UlIoctlTable) );
  125. //
  126. // Public functions.
  127. //
  128. /***************************************************************************++
  129. Routine Description:
  130. This is the dispatch routine for IOCTL IRPs.
  131. Arguments:
  132. pDeviceObject - Pointer to device object for target device.
  133. pIrp - Pointer to IO request packet.
  134. Return Value:
  135. NTSTATUS -- Indicates whether the request was successfully queued.
  136. --***************************************************************************/
  137. NTSTATUS
  138. UlDeviceControl(
  139. IN PDEVICE_OBJECT pDeviceObject,
  140. IN PIRP pIrp
  141. )
  142. {
  143. ULONG code;
  144. ULONG request;
  145. NTSTATUS status;
  146. PIO_STACK_LOCATION pIrpSp;
  147. UL_ENTER_DRIVER( "UlDeviceControl", pIrp );
  148. //
  149. // Snag the current IRP stack pointer.
  150. //
  151. pIrpSp = IoGetCurrentIrpStackLocation( pIrp );
  152. //
  153. // Extract the IOCTL control code and process the request.
  154. //
  155. code = pIrpSp->Parameters.DeviceIoControl.IoControlCode;
  156. request = _HTTP_REQUEST(code);
  157. if (request < HTTP_NUM_IOCTLS &&
  158. UlIoctlTable[request].IoControlCode == code)
  159. {
  160. #if DBG
  161. KIRQL oldIrql = KeGetCurrentIrql();
  162. #endif // DBG
  163. UlTrace(IOCTL,
  164. ("UlDeviceControl: %-30s code=0x%08lx, "
  165. "pIrp=%p, pIrpSp=%p.\n",
  166. UlIoctlTable[request].IoControlName, code,
  167. pIrp, pIrpSp
  168. ));
  169. status = (UlIoctlTable[request].Handler)( pIrp, pIrpSp );
  170. ASSERT( KeGetCurrentIrql() == oldIrql );
  171. }
  172. else
  173. {
  174. //
  175. // If we made it this far, then the ioctl is invalid.
  176. //
  177. KdPrint(( "UlDeviceControl: invalid IOCTL %08lX\n", code ));
  178. status = STATUS_INVALID_DEVICE_REQUEST;
  179. pIrp->IoStatus.Status = status;
  180. UlCompleteRequest( pIrp, g_UlPriorityBoost );
  181. }
  182. UL_LEAVE_DRIVER( "UlDeviceControl" );
  183. return status;
  184. } // UlDeviceControl
  185. //
  186. // Private functions.
  187. //