ReactOS 0.4.16-dev-122-g325d74c
cmbwmi.c File Reference
#include "cmbatt.h"
#include <debug.h>
Include dependency graph for cmbwmi.c:

Go to the source code of this file.

Functions

PCHAR NTAPI WMIMinorFunctionString (IN UCHAR MinorFunction)
 
NTSTATUS NTAPI CmBattQueryWmiRegInfo (PDEVICE_OBJECT DeviceObject, PULONG RegFlags, PUNICODE_STRING InstanceName, PUNICODE_STRING *RegistryPath, PUNICODE_STRING MofResourceName, PDEVICE_OBJECT *Pdo)
 
NTSTATUS NTAPI CmBattQueryWmiDataBlock (PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG InstanceCount, PULONG InstanceLengthArray, ULONG BufferAvail, PUCHAR Buffer)
 
NTSTATUS NTAPI CmBattSetWmiDataBlock (PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG BufferSize, PUCHAR Buffer)
 
NTSTATUS NTAPI CmBattSetWmiDataItem (PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG DataItemId, ULONG BufferSize, PUCHAR Buffer)
 
NTSTATUS NTAPI CmBattWmiDeRegistration (IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI CmBattWmiRegistration (IN PCMBATT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI CmBattSystemControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 

Variables

WMIGUIDREGINFO CmBattWmiGuidList [1]
 

Function Documentation

◆ CmBattQueryWmiDataBlock()

NTSTATUS NTAPI CmBattQueryWmiDataBlock ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
ULONG  GuidIndex,
ULONG  InstanceIndex,
ULONG  InstanceCount,
PULONG  InstanceLengthArray,
ULONG  BufferAvail,
PUCHAR  Buffer 
)

Definition at line 70 of file cmbwmi.c.

78{
81}
#define UNIMPLEMENTED
Definition: debug.h:118
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by CmBattWmiRegistration().

◆ CmBattQueryWmiRegInfo()

NTSTATUS NTAPI CmBattQueryWmiRegInfo ( PDEVICE_OBJECT  DeviceObject,
PULONG  RegFlags,
PUNICODE_STRING  InstanceName,
PUNICODE_STRING RegistryPath,
PUNICODE_STRING  MofResourceName,
PDEVICE_OBJECT Pdo 
)

Definition at line 57 of file cmbwmi.c.

63{
66}

Referenced by CmBattWmiRegistration().

◆ CmBattSetWmiDataBlock()

NTSTATUS NTAPI CmBattSetWmiDataBlock ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
ULONG  GuidIndex,
ULONG  InstanceIndex,
ULONG  BufferSize,
PUCHAR  Buffer 
)

Definition at line 85 of file cmbwmi.c.

91{
94}

Referenced by CmBattWmiRegistration().

◆ CmBattSetWmiDataItem()

NTSTATUS NTAPI CmBattSetWmiDataItem ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
ULONG  GuidIndex,
ULONG  InstanceIndex,
ULONG  DataItemId,
ULONG  BufferSize,
PUCHAR  Buffer 
)

Definition at line 98 of file cmbwmi.c.

105{
108}

Referenced by CmBattWmiRegistration().

◆ CmBattSystemControl()

NTSTATUS NTAPI CmBattSystemControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 147 of file cmbwmi.c.

149{
151 PCMBATT_DEVICE_EXTENSION DeviceExtension;
154 PAGED_CODE();
155 if (CmBattDebug & 2)
156 DbgPrint("CmBatt: SystemControl: %s\n",
158
159 /* Acquire the remove lock */
160 DeviceExtension = DeviceObject->DeviceExtension;
161 Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0);
162 if (!NT_SUCCESS(Status))
163 {
164 /* It's too late, fail */
165 Irp->IoStatus.Status = STATUS_DEVICE_REMOVED;
168 }
169
170 /* What kind of device is this? */
171 WmiLibContext = &DeviceExtension->WmiLibInfo;
172 if (DeviceExtension->FdoType == CmBattBattery)
173 {
174 /* For batteries, let the class driver handle it */
175 Status = BatteryClassSystemControl(DeviceExtension->ClassData,
178 Irp,
179 &Disposition);
180 }
181 else
182 {
183 /* Otherwise, call the wmi library directly */
186 Irp,
187 &Disposition);
188 }
189
190 /* Check what happened */
191 switch (Disposition)
192 {
193 case IrpNotCompleted:
194
195 /* Complete it here */
196 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Not Completed.\n");
198 break;
199
200 case IrpForward:
201
202 /* Forward it to ACPI */
203 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Forward.\n");
205 Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
206 break;
207
208 case IrpProcessed:
209
210 /* Nothing to do */
211 if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Processed.\n");
212 break;
213
214 default:
215 ASSERT(FALSE);
216 }
217
218 /* Release the lock and return */
219 IoReleaseRemoveLock(&DeviceExtension->RemoveLock, 0);
220 return Status;
221}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
_In_ PVOID WmiLibContext
Definition: batclass.h:377
BCLASSAPI NTSTATUS NTAPI BatteryClassSystemControl(PVOID ClassData, PVOID WmiLibContext, PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Disposition)
Definition: battc.c:49
ULONG CmBattDebug
Definition: cmbatt.c:17
@ CmBattBattery
Definition: cmbatt.h:48
PCHAR NTAPI WMIMinorFunctionString(IN UCHAR MinorFunction)
Definition: cmbwmi.c:26
_In_ PIRP Irp
Definition: csq.h:116
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define ASSERT(a)
Definition: mode.c:44
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:56
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_DEVICE_REMOVED
Definition: ntstatus.h:809
CMBATT_EXTENSION_TYPE FdoType
Definition: cmbatt.h:104
WMILIB_CONTEXT WmiLibInfo
Definition: cmbatt.h:113
PDEVICE_OBJECT AttachedDevice
Definition: cmbatt.h:108
IO_REMOVE_LOCK RemoveLock
Definition: cmbatt.h:115
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699
NTSTATUS NTAPI WmiSystemControl(IN PWMILIB_CONTEXT WmiLibInfo, IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, OUT PSYSCTL_IRP_DISPOSITION IrpDisposition)
Definition: wmilib.c:48
@ IrpForward
Definition: wmilib.h:16
@ IrpNotCompleted
Definition: wmilib.h:14
@ IrpProcessed
Definition: wmilib.h:13
enum _SYSCTL_IRP_DISPOSITION SYSCTL_IRP_DISPOSITION
#define IoAcquireRemoveLock(RemoveLock, Tag)
#define IoReleaseRemoveLock(_RemoveLock, _Tag)
Definition: iofuncs.h:2764
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ CmBattWmiDeRegistration()

NTSTATUS NTAPI CmBattWmiDeRegistration ( IN PCMBATT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 112 of file cmbwmi.c.

113{
114 PAGED_CODE();
115
116 /* De-register */
117 return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
119}
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define WMIREG_ACTION_DEREGISTER

◆ CmBattWmiRegistration()

NTSTATUS NTAPI CmBattWmiRegistration ( IN PCMBATT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 123 of file cmbwmi.c.

124{
125 PAGED_CODE();
126
127 /* GUID information */
128 DeviceExtension->WmiLibInfo.GuidCount = sizeof(CmBattWmiGuidList) /
129 sizeof(WMIGUIDREGINFO);
130 DeviceExtension->WmiLibInfo.GuidList = CmBattWmiGuidList;
131
132 /* Callbacks */
133 DeviceExtension->WmiLibInfo.QueryWmiRegInfo = CmBattQueryWmiRegInfo;
134 DeviceExtension->WmiLibInfo.QueryWmiDataBlock = CmBattQueryWmiDataBlock;
135 DeviceExtension->WmiLibInfo.SetWmiDataBlock = CmBattSetWmiDataBlock;
136 DeviceExtension->WmiLibInfo.SetWmiDataItem = CmBattSetWmiDataItem;
137 DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL;
138 DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL;
139
140 /* Register */
141 return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject,
143}
WMIGUIDREGINFO CmBattWmiGuidList[1]
Definition: cmbwmi.c:17
NTSTATUS NTAPI CmBattQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG InstanceCount, PULONG InstanceLengthArray, ULONG BufferAvail, PUCHAR Buffer)
Definition: cmbwmi.c:70
NTSTATUS NTAPI CmBattSetWmiDataItem(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG DataItemId, ULONG BufferSize, PUCHAR Buffer)
Definition: cmbwmi.c:98
NTSTATUS NTAPI CmBattSetWmiDataBlock(PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, ULONG InstanceIndex, ULONG BufferSize, PUCHAR Buffer)
Definition: cmbwmi.c:85
NTSTATUS NTAPI CmBattQueryWmiRegInfo(PDEVICE_OBJECT DeviceObject, PULONG RegFlags, PUNICODE_STRING InstanceName, PUNICODE_STRING *RegistryPath, PUNICODE_STRING MofResourceName, PDEVICE_OBJECT *Pdo)
Definition: cmbwmi.c:57
#define NULL
Definition: types.h:112
#define WMIREG_ACTION_REGISTER

◆ WMIMinorFunctionString()

PCHAR NTAPI WMIMinorFunctionString ( IN UCHAR  MinorFunction)

Definition at line 26 of file cmbwmi.c.

27{
28 switch (MinorFunction)
29 {
31 return "IRP_MN_CHANGE_SINGLE_INSTANCE";
33 return "IRP_MN_CHANGE_SINGLE_ITEM";
35 return "IRP_MN_DISABLE_COLLECTION";
37 return "IRP_MN_DISABLE_EVENTS";
39 return "IRP_MN_ENABLE_COLLECTION";
41 return "IRP_MN_ENABLE_EVENTS";
43 return "IRP_MN_EXECUTE_METHOD";
45 return "IRP_MN_QUERY_ALL_DATA";
47 return "IRP_MN_QUERY_SINGLE_INSTANCE";
48 case IRP_MN_REGINFO:
49 return "IRP_MN_REGINFO";
50 default:
51 return "IRP_MN_?????";
52 }
53}
#define IRP_MN_EXECUTE_METHOD
#define IRP_MN_DISABLE_COLLECTION
#define IRP_MN_CHANGE_SINGLE_ITEM
#define IRP_MN_QUERY_ALL_DATA
#define IRP_MN_DISABLE_EVENTS
#define IRP_MN_ENABLE_EVENTS
#define IRP_MN_ENABLE_COLLECTION
#define IRP_MN_REGINFO
#define IRP_MN_CHANGE_SINGLE_INSTANCE
#define IRP_MN_QUERY_SINGLE_INSTANCE

Referenced by CmBattSystemControl().

Variable Documentation

◆ CmBattWmiGuidList

WMIGUIDREGINFO CmBattWmiGuidList[1]
Initial value:
=
{
{&GUID_POWER_DEVICE_WAKE_ENABLE, 1, 0}
}

Definition at line 17 of file cmbwmi.c.

Referenced by CmBattWmiRegistration().