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.

266 lines
8.7 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. picontrol.h
  5. Abstract:
  6. This header contains private prototypes for communication between
  7. kernel-mode and user-mode. This file should be included only by ppcontrol.c.
  8. Author:
  9. Adrian J. Oney (AdriaO) 07/19/2000
  10. Revision History:
  11. --*/
  12. typedef NTSTATUS (*PLUGPLAY_CONTROL_HANDLER)(
  13. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  14. IN OUT PVOID PnPControlData,
  15. IN ULONG PnPControlDataLength,
  16. IN KPROCESSOR_MODE CallerMode
  17. );
  18. typedef struct {
  19. PLUGPLAY_CONTROL_CLASS ControlCode;
  20. ULONG ControlDataSize;
  21. PLUGPLAY_CONTROL_HANDLER ControlFunction;
  22. } PLUGPLAY_CONTROL_HANDLER_DATA, *PPLUGPLAY_CONTROL_HANDLER_DATA;
  23. VOID
  24. PiControlGetUserFlagsFromDeviceNode(
  25. IN PDEVICE_NODE DeviceNode,
  26. OUT ULONG *StatusFlags
  27. );
  28. NTSTATUS
  29. PiControlStartDevice(
  30. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  31. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  32. IN ULONG PnPControlDataLength,
  33. IN KPROCESSOR_MODE CallerMode
  34. );
  35. NTSTATUS
  36. PiControlResetDevice(
  37. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  38. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  39. IN ULONG PnPControlDataLength,
  40. IN KPROCESSOR_MODE CallerMode
  41. );
  42. NTSTATUS
  43. PiControlInitializeDevice(
  44. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  45. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  46. IN ULONG PnPControlDataLength,
  47. IN KPROCESSOR_MODE CallerMode
  48. );
  49. NTSTATUS
  50. PiControlDeregisterDevice(
  51. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  52. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  53. IN ULONG PnPControlDataLength,
  54. IN KPROCESSOR_MODE CallerMode
  55. );
  56. NTSTATUS
  57. PiControlRegisterNewDevice(
  58. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  59. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  60. IN ULONG PnPControlDataLength,
  61. IN KPROCESSOR_MODE CallerMode
  62. );
  63. NTSTATUS
  64. PiControlEnumerateDevice(
  65. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  66. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  67. IN ULONG PnPControlDataLength,
  68. IN KPROCESSOR_MODE CallerMode
  69. );
  70. NTSTATUS
  71. PiControlQueryAndRemoveDevice(
  72. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  73. IN OUT PPLUGPLAY_CONTROL_QUERY_AND_REMOVE_DATA QueryAndRemoveData,
  74. IN ULONG PnPControlDataLength,
  75. IN KPROCESSOR_MODE CallerMode
  76. );
  77. NTSTATUS
  78. PiControlUserResponse(
  79. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  80. IN OUT PPLUGPLAY_CONTROL_USER_RESPONSE_DATA UserResponseData,
  81. IN ULONG PnPControlDataLength,
  82. IN KPROCESSOR_MODE CallerMode
  83. );
  84. NTSTATUS
  85. PiControlGenerateLegacyDevice(
  86. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  87. IN OUT PPLUGPLAY_CONTROL_LEGACY_DEVGEN_DATA LegacyDevGenData,
  88. IN ULONG PnPControlDataLength,
  89. IN KPROCESSOR_MODE CallerMode
  90. );
  91. NTSTATUS
  92. PiControlGetInterfaceDeviceList(
  93. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  94. IN OUT PPLUGPLAY_CONTROL_INTERFACE_LIST_DATA InterfaceData,
  95. IN ULONG PnPControlDataLength,
  96. IN KPROCESSOR_MODE CallerMode
  97. );
  98. NTSTATUS
  99. PiControlGetPropertyData(
  100. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  101. IN OUT PPLUGPLAY_CONTROL_PROPERTY_DATA PropertyData,
  102. IN ULONG PnPControlDataLength,
  103. IN KPROCESSOR_MODE CallerMode
  104. );
  105. NTSTATUS
  106. PiControlDeviceClassAssociation(
  107. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  108. IN OUT PPLUGPLAY_CONTROL_CLASS_ASSOCIATION_DATA AssociationData,
  109. IN ULONG PnPControlDataLength,
  110. IN KPROCESSOR_MODE CallerMode
  111. );
  112. NTSTATUS
  113. PiControlGetRelatedDevice(
  114. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  115. IN OUT PPLUGPLAY_CONTROL_RELATED_DEVICE_DATA RelatedData,
  116. IN ULONG PnPControlDataLength,
  117. IN KPROCESSOR_MODE CallerMode
  118. );
  119. NTSTATUS
  120. PiControlGetInterfaceDeviceAlias(
  121. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  122. IN OUT PPLUGPLAY_CONTROL_INTERFACE_ALIAS_DATA InterfaceAliasData,
  123. IN ULONG PnPControlDataLength,
  124. IN KPROCESSOR_MODE CallerMode
  125. );
  126. NTSTATUS
  127. PiControlGetSetDeviceStatus(
  128. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  129. IN OUT PPLUGPLAY_CONTROL_STATUS_DATA StatusData,
  130. IN ULONG PnPControlDataLength,
  131. IN KPROCESSOR_MODE CallerMode
  132. );
  133. NTSTATUS
  134. PiControlGetDeviceDepth(
  135. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  136. IN OUT PPLUGPLAY_CONTROL_DEPTH_DATA DepthData,
  137. IN ULONG PnPControlDataLength,
  138. IN KPROCESSOR_MODE CallerMode
  139. );
  140. NTSTATUS
  141. PiControlQueryDeviceRelations(
  142. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  143. IN OUT PPLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA RelationsData,
  144. IN ULONG PnPControlDataLength,
  145. IN KPROCESSOR_MODE CallerMode
  146. );
  147. NTSTATUS
  148. PiControlQueryTargetDeviceRelation(
  149. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  150. IN OUT PPLUGPLAY_CONTROL_TARGET_RELATION_DATA TargetData,
  151. IN ULONG PnPControlDataLength,
  152. IN KPROCESSOR_MODE CallerMode
  153. );
  154. NTSTATUS
  155. PiControlQueryConflictList(
  156. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  157. IN OUT PPLUGPLAY_CONTROL_CONFLICT_DATA ConflictData,
  158. IN ULONG PnPControlDataLength,
  159. IN KPROCESSOR_MODE CallerMode
  160. );
  161. NTSTATUS
  162. PiControlRetrieveDockData(
  163. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  164. IN OUT PPLUGPLAY_CONTROL_RETRIEVE_DOCK_DATA DockData,
  165. IN ULONG DockDataLength,
  166. IN KPROCESSOR_MODE CallerMode
  167. );
  168. NTSTATUS
  169. PiControlGetDevicePowerData(
  170. IN PDEVICE_NODE DeviceNode,
  171. IN KPROCESSOR_MODE CallerMode,
  172. IN ULONG OutputBufferLength,
  173. IN PVOID PowerDataBuffer OPTIONAL,
  174. OUT ULONG *BytesWritten
  175. );
  176. NTSTATUS
  177. PiControlHaltDevice(
  178. IN PLUGPLAY_CONTROL_CLASS PnPControlClass,
  179. IN OUT PPLUGPLAY_CONTROL_DEVICE_CONTROL_DATA DeviceControlData,
  180. IN ULONG PnPControlDataLength,
  181. IN KPROCESSOR_MODE CallerMode
  182. );
  183. NTSTATUS
  184. FORCEINLINE
  185. PiControlAllocateBufferForUserModeCaller(
  186. PVOID *Dest,
  187. ULONG Size,
  188. KPROCESSOR_MODE CallerMode,
  189. PVOID Src
  190. )
  191. {
  192. if (Size == 0) {
  193. *Dest = NULL;
  194. return STATUS_SUCCESS;
  195. }
  196. if (CallerMode == KernelMode) {
  197. *Dest = Src;
  198. return STATUS_SUCCESS;
  199. }
  200. *Dest = ExAllocatePoolWithQuota(
  201. PagedPool | POOL_QUOTA_FAIL_INSTEAD_OF_RAISE,
  202. Size
  203. );
  204. if (*Dest == NULL) {
  205. return STATUS_INSUFFICIENT_RESOURCES;
  206. }
  207. RtlZeroMemory(*Dest, Size);
  208. return STATUS_SUCCESS;
  209. }
  210. VOID
  211. FORCEINLINE
  212. PiControlFreeUserModeCallersBuffer(
  213. KPROCESSOR_MODE CallerMode,
  214. PVOID Buffer
  215. )
  216. {
  217. if (CallerMode != KernelMode) {
  218. if (Buffer != NULL) {
  219. ExFreePool(Buffer);
  220. }
  221. }
  222. }