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.

344 lines
8.7 KiB

  1. #include "winkeyd.h"
  2. #include <wmistr.h>
  3. NTSTATUS
  4. KeyboardClassSystemControl (
  5. IN PDEVICE_OBJECT DeviceObject,
  6. IN PIRP Irp
  7. )
  8. /*++
  9. Routine Description
  10. We have just received a System Control IRP.
  11. Assume that this is a WMI IRP and
  12. call into the WMI system library and let it handle this IRP for us.
  13. --*/
  14. {
  15. PDEVICE_EXTENSION deviceExtension;
  16. NTSTATUS status;
  17. SYSCTL_IRP_DISPOSITION disposition;
  18. deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
  19. status = WmiSystemControl(&deviceExtension->WmiLibInfo,
  20. DeviceObject,
  21. Irp,
  22. &disposition);
  23. switch(disposition) {
  24. case IrpProcessed:
  25. //
  26. // This irp has been processed and may be completed or pending.
  27. //
  28. break;
  29. case IrpNotCompleted:
  30. //
  31. // This irp has not been completed, but has been fully processed.
  32. // we will complete it now
  33. //
  34. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  35. break;
  36. case IrpForward:
  37. case IrpNotWmi:
  38. //
  39. // This irp is either not a WMI irp or is a WMI irp targetted
  40. // at a device lower in the stack.
  41. //
  42. status = WinKey_DispatchPassThrough(DeviceObject, Irp);
  43. break;
  44. default:
  45. //
  46. // We really should never get here, but if we do just forward....
  47. //
  48. ASSERT(FALSE);
  49. status = WinKey_DispatchPassThrough(DeviceObject, Irp);
  50. break;
  51. }
  52. return status;
  53. }
  54. NTSTATUS
  55. WinKey_SetWmiDataItem(
  56. IN PDEVICE_OBJECT DeviceObject,
  57. IN PIRP Irp,
  58. IN ULONG GuidIndex,
  59. IN ULONG InstanceIndex,
  60. IN ULONG DataItemId,
  61. IN ULONG BufferSize,
  62. IN PUCHAR Buffer
  63. )
  64. /*++
  65. Routine Description:
  66. This routine is a callback into the driver to set for the contents of
  67. a data block. When the driver has finished filling the data block it
  68. must call ClassWmiCompleteRequest to complete the irp. The driver can
  69. return STATUS_PENDING if the irp cannot be completed immediately.
  70. Arguments:
  71. DeviceObject is the device whose data block is being queried
  72. Irp is the Irp that makes this request
  73. GuidIndex is the index into the list of guids provided when the
  74. device registered
  75. InstanceIndex is the index that denotes which instance of the data block
  76. is being queried.
  77. DataItemId has the id of the data item being set
  78. BufferSize has the size of the data item passed
  79. Buffer has the new values for the data item
  80. Return Value:
  81. status
  82. --*/
  83. {
  84. PDEVICE_EXTENSION data;
  85. NTSTATUS status;
  86. ULONG size = 0;
  87. PAGED_CODE ();
  88. data = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
  89. switch(GuidIndex) {
  90. case 0:
  91. status = STATUS_WMI_READ_ONLY;
  92. break;
  93. default:
  94. status = STATUS_WMI_GUID_NOT_FOUND;
  95. }
  96. status = WmiCompleteRequest (DeviceObject,
  97. Irp,
  98. status,
  99. size,
  100. IO_NO_INCREMENT);
  101. return status;
  102. }
  103. NTSTATUS
  104. WinKey_SetWmiDataBlock(
  105. IN PDEVICE_OBJECT DeviceObject,
  106. IN PIRP Irp,
  107. IN ULONG GuidIndex,
  108. IN ULONG InstanceIndex,
  109. IN ULONG BufferSize,
  110. IN PUCHAR Buffer
  111. )
  112. /*++
  113. Routine Description:
  114. This routine is a callback into the driver to set the contents of
  115. a data block. When the driver has finished filling the data block it
  116. must call ClassWmiCompleteRequest to complete the irp. The driver can
  117. return STATUS_PENDING if the irp cannot be completed immediately.
  118. Arguments:
  119. DeviceObject is the device whose data block is being queried
  120. Irp is the Irp that makes this request
  121. GuidIndex is the index into the list of guids provided when the
  122. device registered
  123. InstanceIndex is the index that denotes which instance of the data block
  124. is being queried.
  125. BufferSize has the size of the data block passed
  126. Buffer has the new values for the data block
  127. Return Value:
  128. status
  129. --*/
  130. {
  131. PDEVICE_EXTENSION data;
  132. NTSTATUS status;
  133. ULONG size = 0;
  134. PAGED_CODE ();
  135. data = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
  136. switch(GuidIndex) {
  137. case 0:
  138. status = STATUS_WMI_READ_ONLY;
  139. break;
  140. default:
  141. status = STATUS_WMI_GUID_NOT_FOUND;
  142. }
  143. status = WmiCompleteRequest (DeviceObject,
  144. Irp,
  145. status,
  146. size,
  147. IO_NO_INCREMENT);
  148. return status;
  149. }
  150. NTSTATUS
  151. WinKey_QueryWmiDataBlock(
  152. IN PDEVICE_OBJECT DeviceObject,
  153. IN PIRP Irp,
  154. IN ULONG GuidIndex,
  155. IN ULONG InstanceIndex,
  156. IN ULONG InstanceCount,
  157. IN OUT PULONG InstanceLengthArray,
  158. IN ULONG OutBufferSize,
  159. OUT PUCHAR Buffer
  160. )
  161. /*++
  162. Routine Description:
  163. This routine is a callback into the driver to query for the contents of
  164. a data block. When the driver has finished filling the data block it
  165. must call ClassWmiCompleteRequest to complete the irp. The driver can
  166. return STATUS_PENDING if the irp cannot be completed immediately.
  167. Arguments:
  168. DeviceObject is the device whose data block is being queried
  169. Irp is the Irp that makes this request
  170. GuidIndex is the index into the list of guids provided when the
  171. device registered
  172. InstanceIndex is the index that denotes which instance of the data block
  173. is being queried.
  174. InstanceCount is the number of instnaces expected to be returned for
  175. the data block.
  176. InstanceLengthArray is a pointer to an array of ULONG that returns the
  177. lengths of each instance of the data block. If this is NULL then
  178. there was not enough space in the output buffer to fufill the request
  179. so the irp should be completed with the buffer needed.
  180. BufferAvail on has the maximum size available to write the data
  181. block.
  182. Buffer on return is filled with the returned data block
  183. Return Value:
  184. status
  185. --*/
  186. {
  187. PDEVICE_EXTENSION data;
  188. NTSTATUS status;
  189. ULONG size = 0;
  190. PAGED_CODE ();
  191. data = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
  192. switch (GuidIndex) {
  193. case 0:
  194. default:
  195. status = STATUS_WMI_GUID_NOT_FOUND;
  196. }
  197. status = WmiCompleteRequest (DeviceObject,
  198. Irp,
  199. status,
  200. size,
  201. IO_NO_INCREMENT);
  202. return status;
  203. }
  204. NTSTATUS
  205. WinKey_QueryWmiRegInfo(
  206. IN PDEVICE_OBJECT DeviceObject,
  207. OUT ULONG *RegFlags,
  208. OUT PUNICODE_STRING InstanceName,
  209. OUT PUNICODE_STRING *RegistryPath,
  210. OUT PUNICODE_STRING MofResourceName,
  211. OUT PDEVICE_OBJECT *Pdo
  212. )
  213. /*++
  214. Routine Description:
  215. This routine is a callback into the driver to retrieve information about
  216. the guids being registered.
  217. Implementations of this routine may be in paged memory
  218. Arguments:
  219. DeviceObject is the device whose registration information is needed
  220. *RegFlags returns with a set of flags that describe all of the guids being
  221. registered for this device. If the device wants enable and disable
  222. collection callbacks before receiving queries for the registered
  223. guids then it should return the WMIREG_FLAG_EXPENSIVE flag. Also the
  224. returned flags may specify WMIREG_FLAG_INSTANCE_PDO in which case
  225. the instance name is determined from the PDO associated with the
  226. device object. Note that the PDO must have an associated devnode. If
  227. WMIREG_FLAG_INSTANCE_PDO is not set then Name must return a unique
  228. name for the device. These flags are ORed into the flags specified
  229. by the GUIDREGINFO for each guid.
  230. InstanceName returns with the instance name for the guids if
  231. WMIREG_FLAG_INSTANCE_PDO is not set in the returned *RegFlags. The
  232. caller will call ExFreePool with the buffer returned.
  233. *RegistryPath returns with the registry path of the driver. This is
  234. required
  235. *MofResourceName returns with the name of the MOF resource attached to
  236. the binary file. If the driver does not have a mof resource attached
  237. then this can be returned as NULL.
  238. *Pdo returns with the device object for the PDO associated with this
  239. device if the WMIREG_FLAG_INSTANCE_PDO flag is retured in
  240. *RegFlags.
  241. Return Value:
  242. status
  243. --*/
  244. {
  245. PDEVICE_EXTENSION deviceExtension;
  246. PAGED_CODE ();
  247. deviceExtension = DeviceObject->DeviceExtension;
  248. *RegFlags = WMIREG_FLAG_INSTANCE_PDO;
  249. *RegistryPath = &Globals.RegistryPath;
  250. *Pdo = deviceExtension->PDO;
  251. return STATUS_SUCCESS;
  252. }