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.

1590 lines
53 KiB

  1. //
  2. // Test.c - Code generated by wmimofck tool
  3. //
  4. // Finish code by doing all TODO: sections
  5. //
  6. #include <wdm.h>
  7. #include <wmistr.h>
  8. #include <wmiguid.h>
  9. #include <wmilib.h>
  10. #include "filter.h"
  11. //
  12. // Include data header for classes
  13. #include "hbadata.h"
  14. #define NUMBEROFPORTS 8
  15. //
  16. // TODO: Place the contents in this device extension into the driver's
  17. // actual device extension. It is only defined here to supply
  18. // a device extension so that this file can be compiled on its own
  19. //
  20. #ifdef MAKE_THIS_COMPILE
  21. typedef struct DEVICE_EXTENSION
  22. {
  23. WMILIB_CONTEXT WmiLib;
  24. PDEVICE_OBJECT physicalDevObj;
  25. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  26. #endif
  27. NTSTATUS
  28. TestFunctionControl(
  29. IN PDEVICE_OBJECT DeviceObject,
  30. IN PIRP Irp,
  31. IN ULONG GuidIndex,
  32. IN WMIENABLEDISABLECONTROL Function,
  33. IN BOOLEAN Enable
  34. );
  35. NTSTATUS
  36. TestExecuteWmiMethod(
  37. IN PDEVICE_OBJECT DeviceObject,
  38. IN PIRP Irp,
  39. IN ULONG GuidIndex,
  40. IN ULONG InstanceIndex,
  41. IN ULONG MethodId,
  42. IN ULONG InBufferSize,
  43. IN ULONG OutBufferSize,
  44. IN PUCHAR Buffer
  45. );
  46. NTSTATUS
  47. TestSetWmiDataBlock(
  48. IN PDEVICE_OBJECT DeviceObject,
  49. IN PIRP Irp,
  50. IN ULONG GuidIndex,
  51. IN ULONG InstanceIndex,
  52. IN ULONG BufferSize,
  53. IN PUCHAR Buffer
  54. );
  55. NTSTATUS
  56. TestQueryWmiDataBlock(
  57. IN PDEVICE_OBJECT DeviceObject,
  58. IN PIRP Irp,
  59. IN ULONG GuidIndex,
  60. IN ULONG InstanceIndex,
  61. IN ULONG InstanceCount,
  62. IN OUT PULONG InstanceLengthArray,
  63. IN ULONG BufferAvail,
  64. OUT PUCHAR Buffer
  65. );
  66. NTSTATUS
  67. TestQueryWmiRegInfo(
  68. IN PDEVICE_OBJECT DeviceObject,
  69. OUT ULONG *RegFlags,
  70. OUT PUNICODE_STRING InstanceName,
  71. OUT PUNICODE_STRING *RegistryPath,
  72. OUT PUNICODE_STRING MofResourceName,
  73. OUT PDEVICE_OBJECT *Pdo
  74. );
  75. #ifdef ALLOC_PRAGMA
  76. #pragma alloc_text(PAGE,TestQueryWmiRegInfo)
  77. #pragma alloc_text(PAGE,TestQueryWmiDataBlock)
  78. #pragma alloc_text(PAGE,TestSetWmiDataBlock)
  79. #pragma alloc_text(PAGE,TestExecuteWmiMethod)
  80. #pragma alloc_text(PAGE,TestFunctionControl)
  81. #pragma alloc_text(PAGE,TestInitializeWmilibContext)
  82. #endif
  83. //
  84. // TODO: Decide if your MOF is going to be part of your driver as a resource
  85. // attached to it. If this is done then all MOF in the resource will be
  86. // added to the schema. If this is the case be sure that
  87. // USE_BINARY_MOF_RESOURCE is defined. MOF can also be reported at
  88. // runtime via a query to the driver. This can be useful if you want
  89. // the MOF reported to the schema to be dynamic. If MOF is reported via
  90. // a query then USE_BINARY_MOF_QUERY should be defined.
  91. #define USE_BINARY_MOF_RESOURCE
  92. #ifdef USE_BINARY_MOF_QUERY
  93. //
  94. // MOF data can be reported by a device driver via a resource attached to
  95. // the device drivers image file or in response to a query on the binary
  96. // mof data guid. Here we define global variables containing the binary mof
  97. // data to return in response to a binary mof guid query. Note that this
  98. // data is defined to be in a PAGED data segment since it does not need to
  99. // be in nonpaged memory. Note that instead of a single large mof file
  100. // we could have broken it into multiple individual files. Each file would
  101. // have its own binary mof data buffer and get reported via a different
  102. // instance of the binary mof guid. By mixing and matching the different
  103. // sets of binary mof data buffers a "dynamic" composite mof would be created.
  104. #ifdef ALLOC_DATA_PRAGMA
  105. #pragma data_seg("PAGED")
  106. #endif
  107. UCHAR TestBinaryMofData[] =
  108. {
  109. #include "test.x"
  110. };
  111. #ifdef ALLOC_DATA_PRAGMA
  112. #pragma data_seg()
  113. #endif
  114. #endif
  115. //
  116. // Define symbolic names for the guid indexes
  117. #define MSFC_FibrePortHBAStatisticsGuidIndex 0
  118. #define MSFC_FibrePortHBAAttributesGuidIndex 1
  119. #define MSFC_FibrePortHBAMethodsGuidIndex 2
  120. #define MSFC_FCAdapterHBAAttributesGuidIndex 3
  121. #define MSFC_HBAFC3MgmtInfoGuidIndex 4
  122. #define MSFC_HBAPortMethodsGuidIndex 5
  123. #define MSFC_HBAFc3MgmtMethodsGuidIndex 6
  124. #define MSFC_HBAFCPInfoGuidIndex 7
  125. #ifdef USE_BINARY_MOF_QUERY
  126. #define BinaryMofGuidIndex 8
  127. #endif
  128. //
  129. // List of guids supported
  130. GUID MSFC_FibrePortHBAStatisticsGUID = MSFC_FibrePortHBAStatisticsGuid;
  131. GUID MSFC_FibrePortHBAAttributesGUID = MSFC_FibrePortHBAAttributesGuid;
  132. GUID MSFC_FibrePortHBAMethodsGUID = MSFC_FibrePortHBAMethodsGuid;
  133. GUID MSFC_FCAdapterHBAAttributesGUID = MSFC_FCAdapterHBAAttributesGuid;
  134. GUID MSFC_HBAFC3MgmtInfoGUID = MSFC_HBAFC3MgmtInfoGuid;
  135. GUID MSFC_HBAPortMethodsGUID = MSFC_HBAPortMethodsGuid;
  136. GUID MSFC_HBAFc3MgmtMethodsGUID = MSFC_HBAFc3MgmtMethodsGuid;
  137. GUID MSFC_HBAFCPInfoGUID = MSFC_HBAFCPInfoGuid;
  138. #ifdef USE_BINARY_MOF_QUERY
  139. GUID TestBinaryMofGUID = BINARY_MOF_GUID;
  140. #endif
  141. //
  142. // TODO: Make sure the instance count and flags are set properly for each
  143. // guid
  144. WMIGUIDREGINFO TestGuidList[] =
  145. {
  146. {
  147. &MSFC_FibrePortHBAStatisticsGUID, // Guid
  148. NUMBEROFPORTS, // # of instances in each device
  149. 0 // Flags
  150. },
  151. {
  152. &MSFC_FibrePortHBAAttributesGUID, // Guid
  153. NUMBEROFPORTS, // # of instances in each device
  154. 0 // Flags
  155. },
  156. {
  157. &MSFC_FibrePortHBAMethodsGUID, // Guid
  158. NUMBEROFPORTS, // # of instances in each device
  159. 0 // Flags
  160. },
  161. {
  162. &MSFC_FCAdapterHBAAttributesGUID, // Guid
  163. 1, // # of instances in each device
  164. 0 // Flags
  165. },
  166. {
  167. &MSFC_HBAFC3MgmtInfoGUID, // Guid
  168. 1, // # of instances in each device
  169. 0 // Flags
  170. },
  171. {
  172. &MSFC_HBAPortMethodsGUID, // Guid
  173. 1, // # of instances in each device
  174. 0 // Flags
  175. },
  176. {
  177. &MSFC_HBAFc3MgmtMethodsGUID, // Guid
  178. 1, // # of instances in each device
  179. 0 // Flags
  180. },
  181. {
  182. &MSFC_HBAFCPInfoGUID, // Guid
  183. 1, // # of instances in each device
  184. 0 // Flags
  185. },
  186. #ifdef USE_BINARY_MOF_QUERY
  187. {
  188. &TestBinaryMofGUID,
  189. 1,
  190. 0
  191. }
  192. #endif
  193. };
  194. #define TestGuidCount (sizeof(TestGuidList) / sizeof(WMIGUIDREGINFO))
  195. //
  196. // We need to hang onto the registry path passed to our driver entry so that
  197. // we can return it in the QueryWmiRegInfo callback. Be sure to store a copy
  198. // of it into TestRegistryPath in the DriverEntry routine
  199. //
  200. extern UNICODE_STRING FilterRegistryPath;
  201. NTSTATUS TestSystemControl(
  202. PDEVICE_OBJECT DeviceObject,
  203. PIRP Irp
  204. )
  205. /*++
  206. Routine Description:
  207. Dispatch routine for System Control IRPs (MajorFunction == IRP_MJ_SYSTEM_CONTROL)
  208. Arguments:
  209. DeviceObject
  210. Irp
  211. Return Value:
  212. NT status code
  213. --*/
  214. {
  215. PWMILIB_CONTEXT wmilibContext;
  216. NTSTATUS status;
  217. SYSCTL_IRP_DISPOSITION disposition;
  218. PDEVICE_EXTENSION devExt = DeviceObject->DeviceExtension;
  219. //
  220. // TODO: Point at the WMILIB context within the device extension
  221. wmilibContext = &devExt->WmiLib;
  222. //
  223. // Call Wmilib helper function to crack the irp. If this is a wmi irp
  224. // that is targetted for this device then WmiSystemControl will callback
  225. // at the appropriate callback routine.
  226. //
  227. status = WmiSystemControl(wmilibContext,
  228. DeviceObject,
  229. Irp,
  230. &disposition);
  231. switch(disposition)
  232. {
  233. case IrpProcessed:
  234. {
  235. //
  236. // This irp has been processed and may be completed or pending.
  237. break;
  238. }
  239. case IrpNotCompleted:
  240. {
  241. //
  242. // This irp has not been completed, but has been fully processed.
  243. // we will complete it now.
  244. IoCompleteRequest(Irp, IO_NO_INCREMENT);
  245. break;
  246. }
  247. case IrpForward:
  248. case IrpNotWmi:
  249. default:
  250. {
  251. //
  252. // This irp is either not a WMI irp or is a WMI irp targetted
  253. // at a device lower in the stack.
  254. // TODO: Forward IRP down the device stack to the next device
  255. // Or if this is a PDO then just complete the irp without
  256. // touching it.
  257. break;
  258. }
  259. }
  260. return(status);
  261. }
  262. NTSTATUS
  263. TestQueryWmiRegInfo(
  264. IN PDEVICE_OBJECT DeviceObject,
  265. OUT ULONG *RegFlags,
  266. OUT PUNICODE_STRING InstanceName,
  267. OUT PUNICODE_STRING *RegistryPath,
  268. OUT PUNICODE_STRING MofResourceName,
  269. OUT PDEVICE_OBJECT *Pdo
  270. )
  271. /*++
  272. Routine Description:
  273. This routine is a callback into the driver to retrieve the list of
  274. guids or data blocks that the driver wants to register with WMI. This
  275. routine may not pend or block. Driver should NOT call
  276. WmiCompleteRequest.
  277. gArguments:
  278. DeviceObject is the device whose registration info is being queried
  279. *RegFlags returns with a set of flags that describe the guids being
  280. registered for this device. If the device wants enable and disable
  281. collection callbacks before receiving queries for the registered
  282. guids then it should return the WMIREG_FLAG_EXPENSIVE flag. Also the
  283. returned flags may specify WMIREG_FLAG_INSTANCE_PDO in which case
  284. the instance name is determined from the PDO associated with the
  285. device object. Note that the PDO must have an associated devnode. If
  286. WMIREG_FLAG_INSTANCE_PDO is not set then Name must return a unique
  287. name for the device.
  288. InstanceName returns with the instance name for the guids if
  289. WMIREG_FLAG_INSTANCE_PDO is not set in the returned *RegFlags. The
  290. caller will call ExFreePool with the buffer returned.
  291. *RegistryPath returns with the registry path of the driver. The caller
  292. does NOT free this buffer.
  293. *MofResourceName returns with the name of the MOF resource attached to
  294. the binary file. If the driver does not have a mof resource attached
  295. then this can be returned as NULL. The caller does NOT free this
  296. buffer.
  297. *Pdo returns with the device object for the PDO associated with this
  298. device if the WMIREG_FLAG_INSTANCE_PDO flag is retured in
  299. *RegFlags.
  300. Return Value:
  301. status
  302. --*/
  303. {
  304. struct DEVICE_EXTENSION * devExt = DeviceObject->DeviceExtension;
  305. //
  306. // Return the registry path for this driver. This is required so WMI
  307. // can find your driver image and can attribute any eventlog messages to
  308. // your driver.
  309. *RegistryPath = &FilterRegistryPath;
  310. #ifndef USE_BINARY_MOF_RESOURCE
  311. //
  312. // Return the name specified in the .rc file of the resource which
  313. // contains the bianry mof data. By default WMI will look for this
  314. // resource in the driver image (.sys) file, however if the value
  315. // MofImagePath is specified in the driver's registry key
  316. // then WMI will look for the resource in the file specified there.
  317. RtlInitUnicodeString(MofResourceName, L"MofResourceName");
  318. #endif
  319. *RegFlags = WMIREG_FLAG_INSTANCE_PDO;
  320. *Pdo = devExt->physicalDevObj;
  321. return(STATUS_SUCCESS);
  322. }
  323. #define CopyString(field, string, length) \
  324. { \
  325. PWCHAR p = field; \
  326. *p++ = length*sizeof(WCHAR); \
  327. wcsncpy(p, string, length); \
  328. }
  329. NTSTATUS
  330. TestQueryWmiDataBlock(
  331. IN PDEVICE_OBJECT DeviceObject,
  332. IN PIRP Irp,
  333. IN ULONG GuidIndex,
  334. IN ULONG InstanceIndex,
  335. IN ULONG InstanceCount,
  336. IN OUT PULONG InstanceLengthArray,
  337. IN ULONG BufferAvail,
  338. OUT PUCHAR Buffer
  339. )
  340. /*++
  341. Routine Description:
  342. This routine is a callback into the driver to query for the contents of
  343. all instances of a data block. If the driver can satisfy the query within
  344. the callback it should call WmiCompleteRequest to complete the irp before
  345. returning to the caller. Or the driver can return STATUS_PENDING if the
  346. irp cannot be completed immediately and must then call WmiCompleteRequest
  347. once the query is satisfied.
  348. Arguments:
  349. DeviceObject is the device whose data block is being queried
  350. Irp is the Irp that makes this request
  351. GuidIndex is the index into the list of guids provided when the
  352. device registered
  353. InstanceCount is the number of instnaces expected to be returned for
  354. the data block.
  355. InstanceLengthArray is a pointer to an array of ULONG that returns the
  356. lengths of each instance of the data block. If this is NULL then
  357. there was not enough space in the output buffer to fufill the request
  358. so the irp should be completed with the buffer needed.
  359. BufferAvail on entry has the maximum size available to write the data
  360. blocks.
  361. Buffer on return is filled with the returned data blocks. Note that each
  362. instance of the data block must be aligned on a 8 byte boundry.
  363. Return Value:
  364. status
  365. --*/
  366. {
  367. NTSTATUS status = STATUS_UNSUCCESSFUL;
  368. struct DEVICE_EXTENSION * devExt = DeviceObject->DeviceExtension;
  369. ULONG SizeNeeded;
  370. ULONG i, LastIndex, InstanceSize;
  371. switch(GuidIndex)
  372. {
  373. case MSFC_FibrePortHBAStatisticsGuidIndex:
  374. {
  375. PMSFC_FibrePortHBAStatistics PortStats;
  376. //
  377. // First thing to do is verify if there is enough room in
  378. // the output buffer to return all data requested
  379. //
  380. InstanceSize = (sizeof(MSFC_FibrePortHBAStatistics)+7)&~7;
  381. SizeNeeded = InstanceCount * InstanceSize;
  382. if (BufferAvail >= SizeNeeded)
  383. {
  384. //
  385. // Yes, loop over all instances for the data block and
  386. // fill in the values for them
  387. //
  388. LastIndex = InstanceIndex + InstanceCount;
  389. for (i = InstanceIndex; i < LastIndex; i++)
  390. {
  391. PortStats = (PMSFC_FibrePortHBAStatistics)Buffer;
  392. //
  393. // TODO: Initialize values in PortStats for the port
  394. //
  395. memset(Buffer, (CHAR)i, InstanceSize);
  396. //
  397. // Establish a unique value for the port
  398. //
  399. PortStats->UniquePortId = ((ULONGLONG)DeviceObject) + i;
  400. Buffer += InstanceSize;
  401. *InstanceLengthArray++ = sizeof(MSFC_FibrePortHBAStatistics);
  402. }
  403. status = STATUS_SUCCESS;
  404. } else {
  405. status = STATUS_BUFFER_TOO_SMALL;
  406. }
  407. break;
  408. }
  409. case MSFC_FibrePortHBAAttributesGuidIndex:
  410. {
  411. PMSFC_FibrePortHBAAttributes PortAttributes;
  412. //
  413. // First thing to do is verify if there is enough room in
  414. // the output buffer to return all data requested
  415. //
  416. InstanceSize = (sizeof(MSFC_FibrePortHBAAttributes)+7)&~7;
  417. SizeNeeded = InstanceCount * InstanceSize;
  418. if (BufferAvail >= SizeNeeded)
  419. {
  420. //
  421. // Yes, loop over all instances for the data block and
  422. // fill in the values for them
  423. //
  424. LastIndex = InstanceIndex + InstanceCount;
  425. for (i = InstanceIndex; i < LastIndex; i++)
  426. {
  427. PortAttributes = (PMSFC_FibrePortHBAAttributes)Buffer;
  428. //
  429. // TODO: initialize port attribute values properly
  430. //
  431. memset(Buffer, (CHAR)i, InstanceSize);
  432. #define PORTNAME L"FibrePortName"
  433. CopyString(PortAttributes->Attributes.PortSymbolicName,
  434. PORTNAME,
  435. 256);
  436. #define OSDEVICENAME L"OsDeviceName"
  437. CopyString(PortAttributes->Attributes.OSDeviceName,
  438. OSDEVICENAME,
  439. 256);
  440. //
  441. // Establish a unique value for the port
  442. //
  443. PortAttributes->UniquePortId = ((ULONGLONG)DeviceObject) + i;
  444. Buffer += InstanceSize;
  445. *InstanceLengthArray++ = sizeof(MSFC_FibrePortHBAAttributes);
  446. }
  447. status = STATUS_SUCCESS;
  448. } else {
  449. status = STATUS_BUFFER_TOO_SMALL;
  450. }
  451. break;
  452. }
  453. case MSFC_FCAdapterHBAAttributesGuidIndex:
  454. {
  455. PMSFC_FCAdapterHBAAttributes AdapterAttributes;
  456. //
  457. // First thing to do is verify if there is enough room in
  458. // the output buffer to return all data requested
  459. //
  460. SizeNeeded = (sizeof(MSFC_FCAdapterHBAAttributes));
  461. if (BufferAvail >= SizeNeeded)
  462. {
  463. //
  464. // We know there is always only 1 instance for this
  465. // guid
  466. //
  467. AdapterAttributes = (PMSFC_FCAdapterHBAAttributes)Buffer;
  468. //
  469. // TODO: initialize adapter attribute values properly
  470. //
  471. memset(Buffer, (CHAR)7, SizeNeeded);
  472. AdapterAttributes->NumberOfPorts = 8;
  473. #define MANUFACTURER L"FibreAdapter Manufacturer"
  474. CopyString(AdapterAttributes->Manufacturer,
  475. MANUFACTURER,
  476. 64);
  477. #define SERIALNUMBER L"FibreAdapter SerialNumber"
  478. CopyString(AdapterAttributes->SerialNumber,
  479. SERIALNUMBER,
  480. 64);
  481. #define MODEL L"FibreAdapter Model"
  482. CopyString(AdapterAttributes->Model,
  483. MODEL,
  484. 256);
  485. #define MODELDESCRIPTION L"FibreAdapter ModelDescription"
  486. CopyString(AdapterAttributes->ModelDescription,
  487. MODELDESCRIPTION,
  488. 256);
  489. #define NODESYMBOLICNAME L"FibreAdapter NodeSymbolicName"
  490. CopyString(AdapterAttributes->NodeSymbolicName,
  491. NODESYMBOLICNAME,
  492. 256);
  493. #define HARDWAREVERSION L"FibreAdapter HardwareVersion"
  494. CopyString(AdapterAttributes->HardwareVersion,
  495. HARDWAREVERSION,
  496. 256);
  497. #define DRIVERVERSION L"FibreAdapter DriverVersion"
  498. CopyString(AdapterAttributes->DriverVersion,
  499. DRIVERVERSION,
  500. 256);
  501. #define OPTIONROMVERSION L"FibreAdapter OptionROMVersion"
  502. CopyString(AdapterAttributes->OptionROMVersion,
  503. OPTIONROMVERSION,
  504. 256);
  505. #define FIRMWAREVERSION L"FibreAdapter FirmwareVersion"
  506. CopyString(AdapterAttributes->FirmwareVersion,
  507. FIRMWAREVERSION,
  508. 256);
  509. #define DRIVERNAME L"FibreAdapter DriverName"
  510. CopyString(AdapterAttributes->DriverName,
  511. DRIVERNAME,
  512. 256);
  513. //
  514. // Establish a unique value for the Adapter
  515. //
  516. AdapterAttributes->UniqueAdapterId = ((ULONGLONG)DeviceObject);
  517. *InstanceLengthArray = sizeof(MSFC_FCAdapterHBAAttributes);
  518. status = STATUS_SUCCESS;
  519. } else {
  520. status = STATUS_BUFFER_TOO_SMALL;
  521. }
  522. break;
  523. }
  524. case MSFC_HBAFC3MgmtInfoGuidIndex:
  525. {
  526. PMSFC_HBAFC3MgmtInfo Fc3MgmtInfo;
  527. //
  528. // First thing to do is verify if there is enough room in
  529. // the output buffer to return all data requested
  530. //
  531. SizeNeeded = sizeof(MSFC_HBAFC3MgmtInfo);
  532. if (BufferAvail >= SizeNeeded)
  533. {
  534. //
  535. // We know there is always only 1 instance for this
  536. // guid
  537. //
  538. Fc3MgmtInfo = (PMSFC_HBAFC3MgmtInfo)Buffer;
  539. //
  540. // TODO: initialize adapter fc3 values properly
  541. //
  542. memset(Buffer, (CHAR)4, SizeNeeded);
  543. *InstanceLengthArray = sizeof(MSFC_HBAFC3MgmtInfo);
  544. status = STATUS_SUCCESS;
  545. } else {
  546. status = STATUS_BUFFER_TOO_SMALL;
  547. }
  548. break;
  549. }
  550. case MSFC_HBAFCPInfoGuidIndex:
  551. case MSFC_HBAFc3MgmtMethodsGuidIndex:
  552. case MSFC_FibrePortHBAMethodsGuidIndex:
  553. case MSFC_HBAPortMethodsGuidIndex:
  554. {
  555. //
  556. // Methods don't return data per se, but must respond to
  557. // queries with an empty data block. We know that all of
  558. // these method guids only have one instance
  559. //
  560. SizeNeeded = sizeof(ULONG);
  561. if (BufferAvail >= SizeNeeded)
  562. {
  563. status = STATUS_SUCCESS;
  564. } else {
  565. status = STATUS_BUFFER_TOO_SMALL;
  566. }
  567. break;
  568. }
  569. #ifdef USE_BINARY_MOF_QUERY
  570. case BinaryMofGuidIndex:
  571. {
  572. //
  573. // TODO: If the driver supports reporting MOF dynamically,
  574. // change this code to handle multiple instances of the
  575. // binary mof guid and return only those instances that
  576. // should be reported to the schema
  577. //
  578. SizeNeeded = sizeof(TestBinaryMofData);
  579. if (BufferAvail < SizeNeeded)
  580. {
  581. status = STATUS_BUFFER_TOO_SMALL;
  582. } else {
  583. RtlCopyMemory(Buffer, TestBinaryMofData, SizeNeeded);
  584. *InstanceLengthArray = SizeNeeded;
  585. status = STATUS_SUCCESS;
  586. }
  587. break;
  588. }
  589. #endif
  590. default:
  591. {
  592. status = STATUS_WMI_GUID_NOT_FOUND;
  593. break;
  594. }
  595. }
  596. //
  597. // Complete the irp. If there was not enough room in the output buffer
  598. // then status is STATUS_BUFFER_TOO_SMALL and sizeNeeded has the size
  599. // needed to return all of the data. If there was enough room then
  600. // status is STATUS_SUCCESS and sizeNeeded is the actual number of bytes
  601. // being returned.
  602. status = WmiCompleteRequest(
  603. DeviceObject,
  604. Irp,
  605. status,
  606. SizeNeeded,
  607. IO_NO_INCREMENT);
  608. return(status);
  609. }
  610. NTSTATUS
  611. TestExecuteWmiMethod(
  612. IN PDEVICE_OBJECT DeviceObject,
  613. IN PIRP Irp,
  614. IN ULONG GuidIndex,
  615. IN ULONG InstanceIndex,
  616. IN ULONG MethodId,
  617. IN ULONG InBufferSize,
  618. IN ULONG OutBufferSize,
  619. IN PUCHAR Buffer
  620. )
  621. /*++
  622. Routine Description:
  623. This routine is a callback into the driver to execute a method. If
  624. the driver can complete the method within the callback it should
  625. call WmiCompleteRequest to complete the irp before returning to the
  626. caller. Or the driver can return STATUS_PENDING if the irp cannot be
  627. completed immediately and must then call WmiCompleteRequest once the
  628. data is changed.
  629. Arguments:
  630. DeviceObject is the device whose method is being executed
  631. Irp is the Irp that makes this request
  632. GuidIndex is the index into the list of guids provided when the
  633. device registered
  634. MethodId has the id of the method being called
  635. InBufferSize has the size of the data block passed in as the input to
  636. the method.
  637. OutBufferSize on entry has the maximum size available to write the
  638. returned data block.
  639. Buffer is filled with the input buffer on entry and returns with
  640. the output data block
  641. Return Value:
  642. status
  643. --*/
  644. {
  645. ULONG sizeNeeded = 0;
  646. NTSTATUS status;
  647. ULONG i;
  648. switch(GuidIndex)
  649. {
  650. case MSFC_FibrePortHBAMethodsGuidIndex:
  651. {
  652. switch(MethodId)
  653. {
  654. //
  655. // void ResetStatistics();
  656. //
  657. case ResetStatistics:
  658. {
  659. //
  660. // No input or output buffers expected so no
  661. // validation needed. InstanceIndex has the Port
  662. // Index
  663. //
  664. //
  665. // TODO: Do what is needed to reset port
  666. // statistics. The index to the port is the
  667. // InstanceIndex parameter
  668. //
  669. sizeNeeded = 0;
  670. status = STATUS_SUCCESS;
  671. break;
  672. }
  673. default:
  674. {
  675. status = STATUS_WMI_ITEMID_NOT_FOUND;
  676. break;
  677. }
  678. }
  679. break;
  680. }
  681. case MSFC_HBAPortMethodsGuidIndex:
  682. {
  683. switch(MethodId)
  684. {
  685. //
  686. // void GetDiscoveredPortAttributes(
  687. // [in
  688. // ] uint32 PortIndex,
  689. //
  690. // [in] uint32 DiscoveredPortIndex,
  691. //
  692. // [out,
  693. // HBAType("HBA_PORTATTRIBUTES")
  694. // ] MSFC_HBAPortAttributesResults PortAttributes);
  695. //
  696. case GetDiscoveredPortAttributes:
  697. {
  698. //
  699. // Validate that the input buffer is the correct
  700. // size and the output buffer is large enough
  701. //
  702. if (InBufferSize >= sizeof(GetDiscoveredPortAttributes_IN))
  703. {
  704. sizeNeeded = sizeof(GetDiscoveredPortAttributes_OUT);
  705. if (OutBufferSize >= sizeNeeded)
  706. {
  707. PGetDiscoveredPortAttributes_IN In;
  708. PGetDiscoveredPortAttributes_OUT Out;
  709. In = (PGetDiscoveredPortAttributes_IN)Buffer;
  710. Out = (PGetDiscoveredPortAttributes_OUT)Buffer;
  711. //
  712. // TODO: Examine In->PortIndex and
  713. // In->DiscoveredPortIndex and
  714. // validate that they are correct.
  715. //
  716. //
  717. // TODO: Fill Out->PortAttributes with
  718. // correct values.
  719. //
  720. memset(&Out->PortAttributes,
  721. 3,
  722. sizeof(MSFC_HBAPortAttributesResults));
  723. CopyString(Out->PortAttributes.PortSymbolicName,
  724. PORTNAME,
  725. 256);
  726. CopyString(Out->PortAttributes.OSDeviceName,
  727. OSDEVICENAME,
  728. 256);
  729. status = STATUS_SUCCESS;
  730. } else {
  731. status = STATUS_BUFFER_TOO_SMALL;
  732. }
  733. } else {
  734. status = STATUS_INVALID_PARAMETER;
  735. }
  736. break;
  737. }
  738. case GetPortAttributesByWWN:
  739. {
  740. //
  741. // Validate that the input buffer is the correct
  742. // size and the output buffer is large enough
  743. //
  744. if (InBufferSize >= sizeof(GetPortAttributesByWWN_IN))
  745. {
  746. sizeNeeded = sizeof(GetPortAttributesByWWN_OUT);
  747. if (OutBufferSize >= sizeNeeded)
  748. {
  749. PGetPortAttributesByWWN_IN In;
  750. PGetPortAttributesByWWN_OUT Out;
  751. In = (PGetPortAttributesByWWN_IN)Buffer;
  752. Out = (PGetPortAttributesByWWN_OUT)Buffer;
  753. //
  754. // TODO: Examine In->wwn to // In->DiscoveredPortIndex and
  755. // validate that it is correct.
  756. //
  757. //
  758. // TODO: Fill Out->PortAttributes with
  759. // correct values.
  760. //
  761. memset(&Out->PortAttributes,
  762. 3,
  763. sizeof(MSFC_HBAPortAttributesResults));
  764. CopyString(Out->PortAttributes.PortSymbolicName,
  765. PORTNAME,
  766. 256);
  767. CopyString(Out->PortAttributes.OSDeviceName,
  768. OSDEVICENAME,
  769. 256);
  770. status = STATUS_SUCCESS;
  771. } else {
  772. status = STATUS_BUFFER_TOO_SMALL;
  773. }
  774. } else {
  775. status = STATUS_INVALID_PARAMETER;
  776. }
  777. break;
  778. }
  779. default:
  780. {
  781. status = STATUS_WMI_ITEMID_NOT_FOUND;
  782. break;
  783. }
  784. }
  785. break;
  786. }
  787. case MSFC_HBAFc3MgmtMethodsGuidIndex:
  788. {
  789. switch(MethodId)
  790. {
  791. case SendCTPassThru:
  792. {
  793. PSendCTPassThru_IN In;
  794. PSendCTPassThru_OUT Out;
  795. ULONG RequestCount, ResponseCount;
  796. ULONG InSizeNeeded;
  797. //
  798. // Validate that the input buffer is the correct
  799. // size and the output buffer is large enough
  800. //
  801. if (InBufferSize >= sizeof(ULONG))
  802. {
  803. In = (PSendCTPassThru_IN)Buffer;
  804. RequestCount = In->RequestBufferCount;
  805. InSizeNeeded = sizeof(SendCTPassThru_IN) - 1 + RequestCount;
  806. if (InBufferSize >= InSizeNeeded)
  807. {
  808. #define RESPONSE_BUFFER_SIZE 0x1000
  809. ResponseCount = RESPONSE_BUFFER_SIZE;
  810. sizeNeeded = sizeof(SendCTPassThru_OUT) - 1 + ResponseCount;
  811. if (OutBufferSize >= sizeNeeded)
  812. {
  813. Out = (PSendCTPassThru_OUT)Buffer;
  814. //
  815. // TODO: Do the CT Pass thru
  816. //
  817. //
  818. // TODO: Fill the output buffer with
  819. // results
  820. //
  821. Out->ResponseBufferCount = ResponseCount;
  822. memset(Out->ResponseBuffer,
  823. 7,
  824. ResponseCount);
  825. status = STATUS_SUCCESS;
  826. } else {
  827. status = STATUS_BUFFER_TOO_SMALL;
  828. }
  829. } else {
  830. status = STATUS_INVALID_PARAMETER;
  831. }
  832. } else {
  833. status = STATUS_INVALID_PARAMETER;
  834. }
  835. break;
  836. }
  837. case SendRNID:
  838. {
  839. PSendRNID_IN In;
  840. PSendRNID_OUT Out;
  841. ULONG ResponseCount;
  842. ULONG InSizeNeeded;
  843. //
  844. // Validate that the input buffer is the correct
  845. // size and the output buffer is large enough
  846. //
  847. if (InBufferSize >= sizeof(SendRNID_IN))
  848. {
  849. ResponseCount = RESPONSE_BUFFER_SIZE;
  850. sizeNeeded = sizeof(SendRNID_OUT) - 1 + ResponseCount;
  851. if (OutBufferSize >= sizeNeeded)
  852. {
  853. In = (PSendRNID_IN)Buffer;
  854. Out = (PSendRNID_OUT)Buffer;
  855. //
  856. // TODO: Do the SendRNID
  857. //
  858. //
  859. // TODO: Fill the output buffer with
  860. // results
  861. //
  862. Out->ResponseBufferCount = ResponseCount;
  863. memset(Out->ResponseBuffer,
  864. 7,
  865. ResponseCount);
  866. status = STATUS_SUCCESS;
  867. } else {
  868. status = STATUS_BUFFER_TOO_SMALL;
  869. }
  870. } else {
  871. status = STATUS_INVALID_PARAMETER;
  872. }
  873. break;
  874. }
  875. default:
  876. {
  877. status = STATUS_WMI_ITEMID_NOT_FOUND;
  878. break;
  879. }
  880. }
  881. break;
  882. }
  883. case MSFC_HBAFCPInfoGuidIndex:
  884. {
  885. switch(MethodId)
  886. {
  887. case GetFcpTargetMapping:
  888. {
  889. PGetFcpTargetMapping_OUT Out;
  890. //
  891. // TODO: Change this code to return the correct
  892. // number of mappings and the correct
  893. // mappings
  894. //
  895. #define FCPTargetMappingCount 0x20
  896. sizeNeeded = sizeof(GetFcpTargetMapping_OUT) -
  897. sizeof(HBAFCPScsiEntry) +
  898. FCPTargetMappingCount * sizeof(HBAFCPScsiEntry);
  899. if (OutBufferSize > sizeNeeded)
  900. {
  901. Out = (PGetFcpTargetMapping_OUT)Buffer;
  902. Out->EntryCount = FCPTargetMappingCount;
  903. for (i = 0; i < FCPTargetMappingCount; i++)
  904. {
  905. memset(&Out->Entry[i],
  906. 3,
  907. sizeof(HBAFCPScsiEntry));
  908. CopyString(Out->Entry[i].ScsiId.OSDeviceName,
  909. OSDEVICENAME,
  910. 256);
  911. }
  912. }
  913. break;
  914. }
  915. case GetFcpPersistentBinding:
  916. {
  917. PGetFcpPersistentBinding_OUT Out;
  918. //
  919. // TODO: Change this code to return the correct
  920. // number of mappings and the correct
  921. // mappings
  922. //
  923. #define FCPPersistentBindingCount 0x20
  924. sizeNeeded = sizeof(GetFcpPersistentBinding_OUT) -
  925. sizeof(HBAFCPBindingEntry) +
  926. FCPPersistentBindingCount * sizeof(HBAFCPBindingEntry);
  927. if (OutBufferSize > sizeNeeded)
  928. {
  929. Out = (PGetFcpPersistentBinding_OUT)Buffer;
  930. Out->EntryCount = FCPPersistentBindingCount;
  931. for (i = 0; i < FCPPersistentBindingCount; i++)
  932. {
  933. memset(&Out->Entry[i],
  934. 3,
  935. sizeof(HBAFCPBindingEntry));
  936. CopyString(Out->Entry[i].ScsiId.OSDeviceName,
  937. OSDEVICENAME,
  938. 256);
  939. }
  940. }
  941. break;
  942. }
  943. default:
  944. {
  945. status = STATUS_WMI_ITEMID_NOT_FOUND;
  946. break;
  947. }
  948. }
  949. break;
  950. }
  951. default:
  952. {
  953. status = STATUS_WMI_GUID_NOT_FOUND;
  954. }
  955. }
  956. status = WmiCompleteRequest(
  957. DeviceObject,
  958. Irp,
  959. status,
  960. sizeNeeded,
  961. IO_NO_INCREMENT);
  962. return(status);
  963. }
  964. NTSTATUS
  965. TestSetWmiDataBlock(
  966. IN PDEVICE_OBJECT DeviceObject,
  967. IN PIRP Irp,
  968. IN ULONG GuidIndex,
  969. IN ULONG InstanceIndex,
  970. IN ULONG BufferSize,
  971. IN PUCHAR Buffer
  972. )
  973. /*++
  974. Routine Description:
  975. This routine is a callback into the driver to change the contents of
  976. a data block. If the driver can change the data block within
  977. the callback it should call WmiCompleteRequest to complete the irp before
  978. returning to the caller. Or the driver can return STATUS_PENDING if the
  979. irp cannot be completed immediately and must then call WmiCompleteRequest
  980. once the data is changed.
  981. Arguments:
  982. DeviceObject is the device whose data block is being queried
  983. Irp is the Irp that makes this request
  984. GuidIndex is the index into the list of guids provided when the
  985. device registered
  986. BufferSize has the size of the data block passed
  987. Buffer has the new values for the data block
  988. Return Value:
  989. status
  990. --*/
  991. {
  992. ULONG sizeNeeded = 0;
  993. NTSTATUS status;
  994. switch(GuidIndex)
  995. {
  996. case MSFC_HBAFC3MgmtInfoGuidIndex:
  997. {
  998. PMSFC_HBAFC3MgmtInfo FC3MgmtInfo;
  999. if (BufferSize >= sizeof(MSFC_HBAFC3MgmtInfo))
  1000. {
  1001. FC3MgmtInfo = (PMSFC_HBAFC3MgmtInfo)Buffer;
  1002. //
  1003. // TODO: Extract informtion from FC3MgmtInfo and
  1004. // process it appropriately
  1005. //
  1006. status = STATUS_SUCCESS;
  1007. }
  1008. break;
  1009. }
  1010. case MSFC_HBAFCPInfoGuidIndex:
  1011. case MSFC_HBAFc3MgmtMethodsGuidIndex:
  1012. case MSFC_FibrePortHBAMethodsGuidIndex:
  1013. case MSFC_HBAPortMethodsGuidIndex:
  1014. case MSFC_FibrePortHBAAttributesGuidIndex:
  1015. case MSFC_FCAdapterHBAAttributesGuidIndex:
  1016. case MSFC_FibrePortHBAStatisticsGuidIndex:
  1017. {
  1018. //
  1019. // These are read only
  1020. //
  1021. status = STATUS_WMI_READ_ONLY;
  1022. break;
  1023. }
  1024. default:
  1025. {
  1026. status = STATUS_WMI_GUID_NOT_FOUND;
  1027. break;
  1028. }
  1029. }
  1030. status = WmiCompleteRequest(
  1031. DeviceObject,
  1032. Irp,
  1033. status,
  1034. 0,
  1035. IO_NO_INCREMENT);
  1036. return(status);
  1037. }
  1038. NTSTATUS
  1039. TestFunctionControl(
  1040. IN PDEVICE_OBJECT DeviceObject,
  1041. IN PIRP Irp,
  1042. IN ULONG GuidIndex,
  1043. IN WMIENABLEDISABLECONTROL Function,
  1044. IN BOOLEAN Enable
  1045. )
  1046. /*++
  1047. Routine Description:
  1048. This routine is a callback into the driver to enabled or disable event
  1049. generation or data block collection. A device should only expect a
  1050. single enable when the first event or data consumer enables events or
  1051. data collection and a single disable when the last event or data
  1052. consumer disables events or data collection. Data blocks will only
  1053. receive collection enable/disable if they were registered as requiring
  1054. it. If the driver can complete enabling/disabling within the callback it
  1055. should call WmiCompleteRequest to complete the irp before returning to
  1056. the caller. Or the driver can return STATUS_PENDING if the irp cannot be
  1057. completed immediately and must then call WmiCompleteRequest once the
  1058. data is changed.
  1059. Arguments:
  1060. DeviceObject is the device object
  1061. GuidIndex is the index into the list of guids provided when the
  1062. device registered
  1063. Function specifies which functionality is being enabled or disabled
  1064. Enable is TRUE then the function is being enabled else disabled
  1065. Return Value:
  1066. status
  1067. --*/
  1068. {
  1069. NTSTATUS status;
  1070. switch(GuidIndex)
  1071. {
  1072. case MSFC_FibrePortHBAStatisticsGuidIndex:
  1073. {
  1074. //
  1075. // TODO: Delete this entire case if data block does not have the
  1076. // WMIREG_FLAG_EXPENSIVE flag set
  1077. //
  1078. if (Enable)
  1079. {
  1080. //
  1081. // TODO: Datablock collection is being enabled. If this
  1082. // data block has been marked as expensive in the
  1083. // guid list then this code will be called when the
  1084. // first data consumer opens this data block. If
  1085. // anything needs to be done to allow data to be
  1086. // collected for this data block then it should be
  1087. // done here
  1088. //
  1089. } else {
  1090. //
  1091. // TODO: Datablock collection is being disabled. If this
  1092. // data block has been marked as expensive in the
  1093. // guid list then this code will be called when the
  1094. // last data consumer closes this data block. If
  1095. // anything needs to be done to cleanup after data has
  1096. // been collected for this data block then it should be
  1097. // done here
  1098. //
  1099. }
  1100. break;
  1101. }
  1102. case MSFC_FibrePortHBAAttributesGuidIndex:
  1103. {
  1104. //
  1105. // TODO: Delete this entire case if data block does not have the
  1106. // WMIREG_FLAG_EXPENSIVE flag set
  1107. //
  1108. if (Enable)
  1109. {
  1110. //
  1111. // TODO: Datablock collection is being enabled. If this
  1112. // data block has been marked as expensive in the
  1113. // guid list then this code will be called when the
  1114. // first data consumer opens this data block. If
  1115. // anything needs to be done to allow data to be
  1116. // collected for this data block then it should be
  1117. // done here
  1118. //
  1119. } else {
  1120. //
  1121. // TODO: Datablock collection is being disabled. If this
  1122. // data block has been marked as expensive in the
  1123. // guid list then this code will be called when the
  1124. // last data consumer closes this data block. If
  1125. // anything needs to be done to cleanup after data has
  1126. // been collected for this data block then it should be
  1127. // done here
  1128. //
  1129. }
  1130. break;
  1131. }
  1132. case MSFC_FibrePortHBAMethodsGuidIndex:
  1133. {
  1134. //
  1135. // TODO: Delete this entire case if data block does not have the
  1136. // WMIREG_FLAG_EXPENSIVE flag set
  1137. //
  1138. if (Enable)
  1139. {
  1140. //
  1141. // TODO: Datablock collection is being enabled. If this
  1142. // data block has been marked as expensive in the
  1143. // guid list then this code will be called when the
  1144. // first data consumer opens this data block. If
  1145. // anything needs to be done to allow data to be
  1146. // collected for this data block then it should be
  1147. // done here
  1148. //
  1149. } else {
  1150. //
  1151. // TODO: Datablock collection is being disabled. If this
  1152. // data block has been marked as expensive in the
  1153. // guid list then this code will be called when the
  1154. // last data consumer closes this data block. If
  1155. // anything needs to be done to cleanup after data has
  1156. // been collected for this data block then it should be
  1157. // done here
  1158. //
  1159. }
  1160. break;
  1161. }
  1162. case MSFC_FCAdapterHBAAttributesGuidIndex:
  1163. {
  1164. //
  1165. // TODO: Delete this entire case if data block does not have the
  1166. // WMIREG_FLAG_EXPENSIVE flag set
  1167. //
  1168. if (Enable)
  1169. {
  1170. //
  1171. // TODO: Datablock collection is being enabled. If this
  1172. // data block has been marked as expensive in the
  1173. // guid list then this code will be called when the
  1174. // first data consumer opens this data block. If
  1175. // anything needs to be done to allow data to be
  1176. // collected for this data block then it should be
  1177. // done here
  1178. //
  1179. } else {
  1180. //
  1181. // TODO: Datablock collection is being disabled. If this
  1182. // data block has been marked as expensive in the
  1183. // guid list then this code will be called when the
  1184. // last data consumer closes this data block. If
  1185. // anything needs to be done to cleanup after data has
  1186. // been collected for this data block then it should be
  1187. // done here
  1188. //
  1189. }
  1190. break;
  1191. }
  1192. case MSFC_HBAFC3MgmtInfoGuidIndex:
  1193. {
  1194. //
  1195. // TODO: Delete this entire case if data block does not have the
  1196. // WMIREG_FLAG_EXPENSIVE flag set
  1197. //
  1198. if (Enable)
  1199. {
  1200. //
  1201. // TODO: Datablock collection is being enabled. If this
  1202. // data block has been marked as expensive in the
  1203. // guid list then this code will be called when the
  1204. // first data consumer opens this data block. If
  1205. // anything needs to be done to allow data to be
  1206. // collected for this data block then it should be
  1207. // done here
  1208. //
  1209. } else {
  1210. //
  1211. // TODO: Datablock collection is being disabled. If this
  1212. // data block has been marked as expensive in the
  1213. // guid list then this code will be called when the
  1214. // last data consumer closes this data block. If
  1215. // anything needs to be done to cleanup after data has
  1216. // been collected for this data block then it should be
  1217. // done here
  1218. //
  1219. }
  1220. break;
  1221. }
  1222. case MSFC_HBAPortMethodsGuidIndex:
  1223. {
  1224. //
  1225. // TODO: Delete this entire case if data block does not have the
  1226. // WMIREG_FLAG_EXPENSIVE flag set
  1227. //
  1228. if (Enable)
  1229. {
  1230. //
  1231. // TODO: Datablock collection is being enabled. If this
  1232. // data block has been marked as expensive in the
  1233. // guid list then this code will be called when the
  1234. // first data consumer opens this data block. If
  1235. // anything needs to be done to allow data to be
  1236. // collected for this data block then it should be
  1237. // done here
  1238. //
  1239. } else {
  1240. //
  1241. // TODO: Datablock collection is being disabled. If this
  1242. // data block has been marked as expensive in the
  1243. // guid list then this code will be called when the
  1244. // last data consumer closes this data block. If
  1245. // anything needs to be done to cleanup after data has
  1246. // been collected for this data block then it should be
  1247. // done here
  1248. //
  1249. }
  1250. break;
  1251. }
  1252. case MSFC_HBAFc3MgmtMethodsGuidIndex:
  1253. {
  1254. //
  1255. // TODO: Delete this entire case if data block does not have the
  1256. // WMIREG_FLAG_EXPENSIVE flag set
  1257. //
  1258. if (Enable)
  1259. {
  1260. //
  1261. // TODO: Datablock collection is being enabled. If this
  1262. // data block has been marked as expensive in the
  1263. // guid list then this code will be called when the
  1264. // first data consumer opens this data block. If
  1265. // anything needs to be done to allow data to be
  1266. // collected for this data block then it should be
  1267. // done here
  1268. //
  1269. } else {
  1270. //
  1271. // TODO: Datablock collection is being disabled. If this
  1272. // data block has been marked as expensive in the
  1273. // guid list then this code will be called when the
  1274. // last data consumer closes this data block. If
  1275. // anything needs to be done to cleanup after data has
  1276. // been collected for this data block then it should be
  1277. // done here
  1278. //
  1279. }
  1280. break;
  1281. }
  1282. case MSFC_HBAFCPInfoGuidIndex:
  1283. {
  1284. //
  1285. // TODO: Delete this entire case if data block does not have the
  1286. // WMIREG_FLAG_EXPENSIVE flag set
  1287. //
  1288. if (Enable)
  1289. {
  1290. //
  1291. // TODO: Datablock collection is being enabled. If this
  1292. // data block has been marked as expensive in the
  1293. // guid list then this code will be called when the
  1294. // first data consumer opens this data block. If
  1295. // anything needs to be done to allow data to be
  1296. // collected for this data block then it should be
  1297. // done here
  1298. //
  1299. } else {
  1300. //
  1301. // TODO: Datablock collection is being disabled. If this
  1302. // data block has been marked as expensive in the
  1303. // guid list then this code will be called when the
  1304. // last data consumer closes this data block. If
  1305. // anything needs to be done to cleanup after data has
  1306. // been collected for this data block then it should be
  1307. // done here
  1308. //
  1309. }
  1310. break;
  1311. }
  1312. default:
  1313. {
  1314. status = STATUS_WMI_GUID_NOT_FOUND;
  1315. break;
  1316. }
  1317. }
  1318. status = WmiCompleteRequest(
  1319. DeviceObject,
  1320. Irp,
  1321. STATUS_SUCCESS,
  1322. 0,
  1323. IO_NO_INCREMENT);
  1324. return(status);
  1325. }
  1326. NTSTATUS
  1327. TestInitializeWmilibContext(
  1328. IN PWMILIB_CONTEXT WmilibContext
  1329. )
  1330. /*++
  1331. Routine Description:
  1332. This routine will initialize the wmilib context structure with the
  1333. guid list and the pointers to the wmilib callback functions. This routine
  1334. should be called before calling IoWmiRegistrationControl to register
  1335. your device object.
  1336. Arguments:
  1337. WmilibContext is pointer to the wmilib context.
  1338. Return Value:
  1339. status
  1340. --*/
  1341. {
  1342. RtlZeroMemory(WmilibContext, sizeof(WMILIB_CONTEXT));
  1343. WmilibContext->GuidCount = TestGuidCount;
  1344. WmilibContext->GuidList = TestGuidList;
  1345. WmilibContext->QueryWmiRegInfo = TestQueryWmiRegInfo;
  1346. WmilibContext->QueryWmiDataBlock = TestQueryWmiDataBlock;
  1347. WmilibContext->ExecuteWmiMethod = TestExecuteWmiMethod;
  1348. WmilibContext->WmiFunctionControl = TestFunctionControl;
  1349. WmilibContext->SetWmiDataBlock = TestSetWmiDataBlock;
  1350. return(STATUS_SUCCESS);
  1351. }