// wmilib.h
WMI_EXECUTE_METHOD_CALLBACK WmiExecuteMethodCallback;
NTSTATUS WmiExecuteMethodCallback(
[in] PDEVICE_OBJECT DeviceObject,
[in] PIRP Irp,
[in] ULONG GuidIndex,
[in] ULONG InstanceIndex,
[in] ULONG MethodId,
[in] ULONG InBufferSize,
[in] ULONG OutBufferSize,
[in, out] PUCHAR Buffer
)
{...}
View the official Windows Driver Kit DDI referenceNo description available.
The DpWmiExecuteMethod routine executes a method associated with a data block. This routine is optional.
DeviceObject [in]Pointer to the driver's WDM DEVICE_OBJECT structure.
Irp [in]Pointer to the IRP.
GuidIndex [in]Specifies the data block by supplying a zero-based index into the list of GUIDs that the driver provided in the WMILIB_CONTEXT structure it passed to WmiSystemControl.
InstanceIndex [in]If the block specified by GuidIndex has multiple instances, InstanceIndex specifies a zero-based index value that identifies the instance.
MethodId [in]Specifies the ID of the method to execute. The driver defines the method ID as an item in a data block.
InBufferSize [in]Indicates the size in bytes of the input data. If there is no input data, InBufferSize is zero.
OutBufferSize [in]Indicates the number of bytes available in the buffer for output data.
Buffer [in, out]Pointer to a buffer that holds input data, if any, and receives output data, if any, for the method. If the buffer is too small to receive all of the output data, the driver returns STATUS_BUFFER_TOO_SMALL and calls WmiCompleteRequest with the size required.
DpWmiExecuteMethod returns STATUS_SUCCESS or an appropriate error code such as the following:
WMI calls a driver's DpWmiExecuteMethod routine after the driver calls WmiSystemControl in response to an IRP_MN_EXECUTE_METHOD request.
If a driver implements a DpWmiExecuteMethod routine, the driver must place the routine's address in the ExecuteWmiMethod member of the WMILIB_CONTEXT structure that it passes to WmiSystemControl. If a driver does not implement a DpWmiExecuteMethod routine, it must set ExecuteWmiMethod to NULL. In the latter case, WMI returns STATUS_INVALID_DEVICE_REQUEST to the caller in response to any IRP_MN_EXECUTE_METHOD request.
The driver is responsible for validating all input arguments. Specifically, the driver must do the following:
Do not assume the thread context is that of the initiating user-mode application—a higher-level driver might have changed it.
If the specified method performs an operation that causes data loss, such as fetching and resetting the contents of a set of counters, the driver should validate the output buffer size before performing the operation. That way, the driver can return STATUS_BUFFER_TOO_SMALL and allow the caller to resubmit the request with a larger buffer, without prematurely resetting the counters.
After executing the method and writing any output data to the buffer, the driver calls WmiCompleteRequest to complete the request.
This routine can be pageable.
For more information about implementing this routine, see Calling WmiSystemControl to Handle WMI IRPs.