38 { _QueryAllData,
FALSE },
41 { _QuerySingleInstance,
TRUE },
44 { _ChangeSingleInstance,
TRUE },
47 { _ChangeSingleItem,
TRUE },
50 { _EnableDisableEventsAndCollection,
FALSE },
53 { _EnableDisableEventsAndCollection,
FALSE },
56 { _EnableDisableEventsAndCollection,
FALSE },
59 { _EnableDisableEventsAndCollection,
FALSE },
65 { _ExecuteMethod,
TRUE },
89 m_NumProviders(0), m_RegisteredState(WmiUnregistered),
90 m_WorkItem(
NULL), m_WorkItemEvent(
NULL), m_WorkItemQueued(
FALSE),
151 "could not register WMI with OS, %!STATUS!",
status);
190 event.EnterCRAndWaitAndLeave();
210 "failure deregistering WMI with OS, %!STATUS!",
status);
381 "IoWMIRegistrationControl DevObj %p, for UpdateGuids failed, %!STATUS!",
432 BOOLEAN providerAllocated, providerAdded, update;
434 providerAllocated =
FALSE;
435 providerAdded =
FALSE;
455 providerAllocated =
TRUE;
462 providerAdded =
TRUE;
474 "WMI Guid already registered by client driver");
530 else if (providerAdded) {
546 if (providerAllocated) {
665 "WDFDEVICE 0x%p !devobj 0x%p IRP_MJ_SYSTEM_CONTROL, %!sysctrl! IRP 0x%p",
717 instanceIndex, pTag);
774 if (handled ==
FALSE) {
776 if (completeNow || pAttached ==
NULL) {
847 ULONG instanceCount, dataBlockOffset, lengthArraySize,
i, sizeRemaining,
848 lastAdjustment, bufferUsed, tempOffset;
886 instanceCount =
Provider->m_NumInstances;
899 if (instanceCount == 0) {
903 "Failing QueryAllData since no instances found for "
904 "WDFWMIPROVIDER %p, %!STATUS!",
912 "WDFWMIPROVIDER %p QueryAllData, num instances %d",
913 Provider->GetHandle(), instanceCount);
922 pNodeData->
WnodeHeader.Flags &= ~WNODE_FLAG_FIXED_INSTANCE_SIZE;
929 status = RtlULongMult(instanceCount,
945 if (dataBlockOffset < tempOffset) {
954 "Failing QueryAllData since integer overflow occured using"
955 " provider instance count %d for WDFWMIPROVIDER %p, %!STATUS!",
963 if (dataBlockOffset <= stack->
Parameters.WMI.BufferSize) {
965 sizeRemaining =
stack->Parameters.WMI.BufferSize - dataBlockOffset;
985 if (instanceCount > 0 &&
Provider->GetMinInstanceBufferSize() != 0) {
991 Provider->GetMinInstanceBufferSize(),
1013 status = RtlULongMult(minSizeAdjusted, instanceCount - 1, &
size);
1030 if (sizeRemaining <
size) {
1041 for (
i = 0;
i < instanceCount;
i++) {
1075 if (adjustedSize < tmpSize) {
1083 "WDFWMIINSTNACE %p queried, returned a buffer size of %d,"
1084 "but it could not be rounded up, %!STATUS!",
1094 lastAdjustment = adjustedSize - tmpSize;
1107 pData += adjustedSize;
1116 if (adjustedSize <= sizeRemaining) {
1117 sizeRemaining -= adjustedSize;
1122 addStatus = RtlULongAdd(dataBlockOffset,
1130 addStatus = RtlULongAdd(dataBlockOffset,
1140 "WDFWMIPROVIDER %p, arithmetic overflow in computing "
1141 "block offset, %!STATUS!",
Provider->GetHandle(),
1154 addStatus = RtlULongAdd(bufferUsed, adjustedSize, &bufferUsed);
1160 "WDFWMIPROVIDER %p, arithmetic overflow in computing "
1161 "buffer consumed(%d+%d), %!STATUS!",
1167 else if (pOffsets !=
NULL) {
1205 bufferUsed -=lastAdjustment;
1211 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!, requesting "
1212 "buffer size of 0x%x",
Provider->GetHandle(),
status, bufferUsed);
1227 bufferUsed = dataBlockOffset - pNodeData->
DataBlockOffset - lastAdjustment;
1232 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!",
1240 "WDFWMIPROVIDER %p QueryAllData returning %!STATUS!, buffer used 0x%x",
1272 else if (bufferSize < Provider->GetMinInstanceBufferSize()) {
1410 Irp->IoStatus.Information = 0;
1419 switch (
stack->MinorFunction) {
1461 if (
Provider->IsFunctionControlSupported()) {
1509 ULONG size, inBufferSize, outBufferSize;
1547 (inBufferSize == 0 && outBufferSize == 0) ?
1636 registryPathOffset = mofResourceOffset +
sizeof(
USHORT);
1637 if (pMofString !=
NULL) {
1638 registryPathOffset += pMofString->
Length;
1645 status = RtlULongAdd(registryPathOffset, pRegPath->
Length, &bufferNeeded);
1650 status = RtlULongAdd(bufferNeeded,
sizeof(
USHORT), &bufferNeeded);
1672 for (
ple =
This->m_ProvidersListHead.Flink,
i = 0;
1715 if (pMofString !=
NULL) {
1716 *pLength = pMofString->
Length;
1728 *pLength = pRegPath->
Length;
1772 pNodeAllData->
WnodeHeader.BufferSize = bufferNeeded;
1811 pNodeSingle->
WnodeHeader.BufferSize = bufferNeeded;
1853 pNodeMethod->
WnodeHeader.BufferSize = bufferNeeded;
1936 "Converting %!STATUS! to %!STATUS!",
1948 Irp->IoStatus.Information = 0;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
__inline FxDriver * GetDriver(VOID)
MdDeviceObject __inline GetPhysicalDevice(VOID)
WDFDEVICE __inline GetHandle(VOID)
MdDeviceObject __inline GetAttachedDevice(VOID)
MdDeviceObject __inline GetDeviceObject(VOID)
CfxDevice * m_ParentDevice
UNICODE_STRING m_MofResourceName
static FxWdmDeviceExtension * _GetFxWdmExtension(__in MdDeviceObject DeviceObject)
PUNICODE_STRING GetRegistryPathUnicodeString(VOID)
_Must_inspect_result_ NTSTATUS AssignParentObject(__in FxObject *ParentObject)
virtual VOID DeleteObject(VOID)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
__in __drv_restoresIRQL KIRQL OldIrql
virtual BOOLEAN IsQueryInstanceSupported(VOID)
WDFWMIINSTANCE GetHandle(VOID)
BOOLEAN DeferUpdateLocked(__in KIRQL OldIrql)
static MX_WORKITEM_ROUTINE _UpdateGuids
_Must_inspect_result_ FxWmiProvider * FindProviderReferenced(__in LPGUID Guid, __in PVOID Tag)
virtual _Must_inspect_result_ NTSTATUS Dispatch(__in PIRP Irp)
VOID RemoveProvider(__in FxWmiProvider *Provider)
static VOID CheckAssumptions(VOID)
static _Must_inspect_result_ NTSTATUS _ExecuteMethod(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in FxWmiInstance *Instance)
VOID CompleteWmiExecuteMethodRequest(__in PIRP Irp, __in NTSTATUS Status, __in ULONG BufferUsed)
_Must_inspect_result_ NTSTATUS AddProvider(__in FxWmiProvider *Provider, __out_opt PBOOLEAN Update=NULL)
LIST_ENTRY m_ProvidersListHead
VOID IncrementUpdateCount()
WmiRegisteredState m_RegisteredState
VOID RemoveProviderLocked(__in FxWmiProvider *Provider)
static _Must_inspect_result_ NTSTATUS _RegInfo(__in FxWmiIrpHandler *This, __in PIRP Irp, __in_opt FxWmiProvider *Provider, __in_opt FxWmiInstance *Instance)
_Must_inspect_result_ NTSTATUS AddPowerPolicyProviderAndInstance(__in PWDF_WMI_PROVIDER_CONFIG ProviderConfig, __in FxWmiInstanceInternalCallbacks *Callbacks, __inout FxWmiInstanceInternal **Instance)
static _Must_inspect_result_ NTSTATUS _ChangeSingleInstance(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in FxWmiInstance *Instance)
_Must_inspect_result_ FxWmiProvider * FindProviderLocked(__in LPGUID Guid)
static _Must_inspect_result_ NTSTATUS _QueryAllData(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in_opt FxWmiInstance *Instance)
static _Must_inspect_result_ NTSTATUS _ChangeSingleItem(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in FxWmiInstance *Instance)
static const FxWmiMinorEntry m_WmiDispatchTable[]
FxWmiIrpHandler(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in CfxDevice *Device, __in WDFTYPE Type=FX_TYPE_WMI_IRP_HANDLER)
_Must_inspect_result_ NTSTATUS PostCreateDeviceInitialize(VOID)
static _Must_inspect_result_ NTSTATUS _EnableDisableEventsAndCollection(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in FxWmiInstance *Instance)
_Must_inspect_result_ NTSTATUS Register(VOID)
VOID CompleteWmiQueryAllDataRequest(__in PIRP Irp, __in NTSTATUS Status, __in ULONG BufferUsed)
VOID DecrementUpdateCountAndWait()
_Must_inspect_result_ NTSTATUS AddProviderLocked(__in FxWmiProvider *Provider, __in KIRQL Irql, __out_opt PBOOLEAN Update=NULL)
VOID ResetStateForPdoRestart(VOID)
static _Must_inspect_result_ NTSTATUS _QuerySingleInstance(__in FxWmiIrpHandler *This, __in PIRP Irp, __in FxWmiProvider *Provider, __in FxWmiInstance *Instance)
_Must_inspect_result_ NTSTATUS CompleteWmiRequest(__in PIRP Irp, __in NTSTATUS Status, __in ULONG BufferUsed)
VOID CompleteWmiQuerySingleInstanceRequest(__in PIRP Irp, __in NTSTATUS Status, __in ULONG BufferUsed)
VOID DecrementUpdateCount()
_Must_inspect_result_ FxWmiInstance * GetInstanceReferencedLocked(__in ULONG Index, __in PVOID Tag)
_Must_inspect_result_ NTSTATUS AddInstanceLocked(__in FxWmiInstance *Instance, __in BOOLEAN NoErrorIfPresent, __out PBOOLEAN Update, __in AddInstanceAction Action=AddInstanceToTail)
ULONG GetRegistrationFlagsLocked(VOID)
static PDB_INFORMATION information
#define NT_SUCCESS(StatCode)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define RtlCompareMemory(s1, s2, l)
#define KeSetEvent(pEvt, foo, foo2)
#define KeQuerySystemTime(t)
#define InitializeListHead(ListHead)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
return pDevice GetDeviceObject()
FX_TRACK_DRIVER(fxDriverGlobals)
_Must_inspect_result_ BOOLEAN __inline FxIsEqualGuid(__in CONST GUID *Lhs, __in CONST GUID *Rhs)
FxWmiProvider * pProvider
FxWmiInstanceExternal * pInstance
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define InterlockedCompareExchangePointer
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
unsigned __int3264 UINT_PTR
#define _Must_inspect_result_
#define MEMORY_ALLOCATION_ALIGNMENT
#define UNREFERENCED_PARAMETER(P)
#define IoSkipCurrentIrpStackLocation(Irp)
#define IoCompleteRequest
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
#define STATUS_WMI_GUID_DISCONNECTED
#define STATUS_OBJECT_NAME_EXISTS
#define STATUS_WMI_SET_FAILURE
#define STATUS_WMI_INSTANCE_NOT_FOUND
#define STATUS_WMI_GUID_NOT_FOUND
#define STATUS_WMI_READ_ONLY
#define STATUS_INTEGER_OVERFLOW
#define STATUS_BUFFER_TOO_SMALL
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize(__in BOOLEAN InitialState=FALSE)
WUDF_IO_REMOVE_LOCK IoRemoveLock
__in PFN_WMI_HANDLER_MINOR_DISPATCH Handler
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@3980::@4018 WMI
struct _LIST_ENTRY * Flink
OFFSETINSTANCEDATAANDLENGTH OffsetInstanceDataAndLength[0]
struct _WNODE_HEADER WnodeHeader
struct _WNODE_HEADER WnodeHeader
struct _WNODE_HEADER WnodeHeader
struct _WNODE_HEADER WnodeHeader
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_INVALID_DEVICE_STATE
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_ WDFDEVICE Device
#define WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, _type)
FORCEINLINE size_t WDF_ALIGN_SIZE_UP(_In_ size_t Length, _In_ size_t AlignTo)
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_In_ UCHAR _In_ UCHAR MinorFunction
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
#define WDF_NO_OBJECT_ATTRIBUTES
_In_ ULONG _Out_ PULONG BufferUsed
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
WDF_EXTERN_C_START enum _WDF_WMI_PROVIDER_CONTROL WDF_WMI_PROVIDER_CONTROL
struct tagWNODE_METHOD_ITEM * PWNODE_METHOD_ITEM
#define WNODE_FLAG_TOO_SMALL
#define WNODE_FLAG_STATIC_INSTANCE_NAMES
struct tagWNODE_ALL_DATA * PWNODE_ALL_DATA
struct tagWNODE_SINGLE_ITEM * PWNODE_SINGLE_ITEM
struct tagWNODE_SINGLE_INSTANCE * PWNODE_SINGLE_INSTANCE
struct tagWNODE_TOO_SMALL * PWNODE_TOO_SMALL
struct tagWNODE_TOO_SMALL WNODE_TOO_SMALL
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
#define IRP_MN_EXECUTE_METHOD
#define IRP_MN_DISABLE_COLLECTION
#define IRP_MN_CHANGE_SINGLE_ITEM
#define WMIREG_ACTION_REGISTER
#define IRP_MN_QUERY_ALL_DATA
#define WMIREG_ACTION_DEREGISTER
#define IRP_MN_DISABLE_EVENTS
#define WMIREG_ACTION_UPDATE_GUIDS
#define IRP_MN_ENABLE_EVENTS
#define IRP_MN_ENABLE_COLLECTION
#define IRP_MN_REGINFO_EX
#define IRP_MN_CHANGE_SINGLE_INSTANCE
#define IRP_MN_QUERY_SINGLE_INSTANCE
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
#define ObReferenceObject