Callback Optional Set a single data item in a single instance of a data block
ExecuteWmiMethod Callback Optional Execute a method associated with a data block
WmiFunctionControl Callback Optional Enable and disable event notification andexpensive data block collection
Handling System Control IRPs

Your driver must then handle System Control IRPs in your SystemControl routine. Table 12.2 shows the various minor codes associated with this IRP.

Table 12.2 System control minor request codes

IRP_MN_REGINFO Query a driver's registration information
IRP_MN_QUERY_ALL_DATA Get all instances in a given data block
IRP_MN_QUERY_SINGLE_INSTANCE Get a single instance in a given data block
IRP_MN_CHANGE_SINGLE_INSTANCE Change all data items in a given data block
IRP_MN_CHANGE_SINGLE_ITEM Change a single data item in a given data block
IRP_MN_ENABLE_EVENTS Enable event notification
IRP_MN_DISABLE_EVENTS Disable event notification
IRP_MN_ENABLE_COLLECTION Start collection of data that is expensive to collect
IRP_MN_DISABLE_COLLECTION Stop collection of data that is expensive to collect
IRP_MN_EXECUTE_METHOD Execute a method in a data block

If you have dynamic instance names, you must process the IRP and call WmiCompleteRequest, or pass it onto the next driver if you do not recognize the GUID.

For static instances, as used by Wdm3, you simply have to call WmiSystemControl, passing a pointer to your WMILIBCONTEXT structure. WmiSystemControl processes the IRPs as much as possible. If the request is destined for your driver, it invokes the appropriate callback to let you process the IRP. On return, WmiSystemControl sets its IrpDisposition parameter to tell you how to continue processing the IRP, as shown in Table 12.3. For example, if the IRP was not destined for your driver, IrpDisposition is set to IrpForward and the IRP is sent down the stack.

Table 12.3 WmiSystemControl IrpDisposition handling

IrpProcessed Either call WmiCompleteRequest here or in your call-back routine.
IrpNotComplete IRP processed but an error detected, so just call IoCompleteRequest.
IrpNotWMI or IrpForward Forward to next driver: call IoSkipCurrentIrpStackLocation and IoCallDriver

Listing 12.4 shows how the Wdm3SystemControl routine processes System Control IRPs. The main processing is carried out by the system function WmiSystemControl. Wdm3SystemControl acts on the IrpDisposition parameter in the recommended way.

Listing 12.4 Wdm3SystemControl routine

NTSTATUS Wdm3SystemControl (IN PDEVICE_OBJECT fdo, IN PIRP Irp) {

 DebugPrintMsg('Wdm3SystemControl');

 PWDM3_DEVICE_EXTENSION dx = (PWDM3_DEVICE_EXTENSION)fdo->DeviceExtension;

 SYSCTL_IRP_DISPOSITION disposition;

 NTSTATUS status =  WmiSystemControl(&dx->WmiLibInfo, fdo, Irp, &disposition);

 switch(disposition) {

 case IrpProcessed:

  // This irp has been processed and may be completed or pending.

  break;

 case IrpNotCompleted:

  // This irp has not been completed, but has been fully processed.

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату
×