ReactOS  r76032
batclass.h
Go to the documentation of this file.
1 /*
2  * batclass.h
3  *
4  * Battery class driver interface
5  *
6  * This file is part of the w32api package.
7  *
8  * Contributors:
9  * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAIMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  */
22 
23 #pragma once
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /* Battery device GUIDs */
30 
31 DEFINE_GUID(GUID_DEVICE_BATTERY,
32  0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a);
33 
34 #if (NTDDI_VERSION >= NTDDI_WINXP)
35 DEFINE_GUID(BATTERY_STATUS_WMI_GUID,
36  0xfc4670d1, 0xebbf, 0x416e, 0x87, 0xce, 0x37, 0x4a, 0x4e, 0xbc, 0x11, 0x1a);
37 DEFINE_GUID(BATTERY_RUNTIME_WMI_GUID,
38  0x535a3767, 0x1ac2, 0x49bc, 0xa0, 0x77, 0x3f, 0x7a, 0x02, 0xe4, 0x0a, 0xec);
39 DEFINE_GUID(BATTERY_TEMPERATURE_WMI_GUID,
40  0x1a52a14d, 0xadce, 0x4a44, 0x9a, 0x3e, 0xc8, 0xd8, 0xf1, 0x5f, 0xf2, 0xc2);
41 DEFINE_GUID(BATTERY_FULL_CHARGED_CAPACITY_WMI_GUID,
42  0x40b40565, 0x96f7, 0x4435, 0x86, 0x94, 0x97, 0xe0, 0xe4, 0x39, 0x59, 0x05);
43 DEFINE_GUID(BATTERY_CYCLE_COUNT_WMI_GUID,
44  0xef98db24, 0x0014, 0x4c25, 0xa5, 0x0b, 0xc7, 0x24, 0xae, 0x5c, 0xd3, 0x71);
45 DEFINE_GUID(BATTERY_STATIC_DATA_WMI_GUID,
46  0x05e1e463, 0xe4e2, 0x4ea9, 0x80, 0xcb, 0x9b, 0xd4, 0xb3, 0xca, 0x06, 0x55);
47 DEFINE_GUID(BATTERY_STATUS_CHANGE_WMI_GUID,
48  0xcddfa0c3, 0x7c5b, 0x4e43, 0xa0, 0x34, 0x05, 0x9f, 0xa5, 0xb8, 0x43, 0x64);
49 DEFINE_GUID(BATTERY_TAG_CHANGE_WMI_GUID,
50  0x5e1f6e19, 0x8786, 0x4d23, 0x94, 0xfc, 0x9e, 0x74, 0x6b, 0xd5, 0xd8, 0x88);
51 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
52 
53 #ifndef _BATCLASS_
54 #define _BATCLASS_
55 
56 /* BATTERY_INFORMATION.Capabilities constants */
57 #define BATTERY_SET_CHARGE_SUPPORTED 0x00000001
58 #define BATTERY_SET_DISCHARGE_SUPPORTED 0x00000002
59 #define BATTERY_SET_RESUME_SUPPORTED 0x00000004
60 #define BATTERY_IS_SHORT_TERM 0x20000000
61 #define BATTERY_CAPACITY_RELATIVE 0x40000000
62 #define BATTERY_SYSTEM_BATTERY 0x80000000
63 
64 /* BATTERY_INFORMATION.Capacity constants */
65 #define BATTERY_UNKNOWN_CAPACITY 0xFFFFFFFF
66 
67 /* BatteryEstimatedTime constant */
68 #define BATTERY_UNKNOWN_TIME 0x80000000
69 
70 #define MAX_BATTERY_STRING_SIZE 128
71 
72 /* BATTERY_STATUS.PowerState flags */
73 #define BATTERY_POWER_ON_LINE 0x00000001
74 #define BATTERY_DISCHARGING 0x00000002
75 #define BATTERY_CHARGING 0x00000004
76 #define BATTERY_CRITICAL 0x00000008
77 
78 /* BATTERY_STATUS.Voltage constant */
79 #define BATTERY_UNKNOWN_VOLTAGE 0xFFFFFFFF
80 
81 /* BATTERY_STATUS.Rate constant */
82 #define BATTERY_UNKNOWN_RATE 0x80000000
83 
84 #define IOCTL_BATTERY_QUERY_TAG \
85  CTL_CODE(FILE_DEVICE_BATTERY, 0x10, METHOD_BUFFERED, FILE_READ_ACCESS)
86 #define IOCTL_BATTERY_QUERY_INFORMATION \
87  CTL_CODE(FILE_DEVICE_BATTERY, 0x11, METHOD_BUFFERED, FILE_READ_ACCESS)
88 #define IOCTL_BATTERY_SET_INFORMATION \
89  CTL_CODE(FILE_DEVICE_BATTERY, 0x12, METHOD_BUFFERED, FILE_WRITE_ACCESS)
90 #define IOCTL_BATTERY_QUERY_STATUS \
91  CTL_CODE(FILE_DEVICE_BATTERY, 0x13, METHOD_BUFFERED, FILE_READ_ACCESS)
92 
93 /* NTSTATUS possibly returned by BCLASS_QUERY_STATUS */
94 #define BATTERY_TAG_INVALID 0
95 
107 
113 
114 typedef struct _BATTERY_INFORMATION {
126 
132 
138 
139 typedef struct _BATTERY_SET_INFORMATION {
144 
145 typedef struct _BATTERY_WAIT_STATUS {
152 
153 typedef struct _BATTERY_STATUS {
159 
160 #ifndef _WINDOWS_H
161 
162 /* BATTERY_MINIPORT_INFO.XxxVersion */
163 #define BATTERY_CLASS_MAJOR_VERSION 0x0001
164 #define BATTERY_CLASS_MINOR_VERSION 0x0000
165 
166 _Function_class_(BCLASS_QUERY_TAG_CALLBACK)
170 typedef NTSTATUS
171 (NTAPI BCLASS_QUERY_TAG_CALLBACK)(
174 typedef BCLASS_QUERY_TAG_CALLBACK *PBCLASS_QUERY_TAG_CALLBACK;
175 
176 _Function_class_(BCLASS_QUERY_INFORMATION_CALLBACK)
180 typedef NTSTATUS
181 (NTAPI BCLASS_QUERY_INFORMATION_CALLBACK)(
182  _In_ PVOID Context,
183  _In_ ULONG BatteryTag,
185  _In_ LONG AtRate,
187  _In_ ULONG BufferLength,
189 typedef BCLASS_QUERY_INFORMATION_CALLBACK *PBCLASS_QUERY_INFORMATION_CALLBACK;
190 
191 _Function_class_(BCLASS_QUERY_STATUS_CALLBACK)
195 typedef NTSTATUS
196 (NTAPI BCLASS_QUERY_STATUS_CALLBACK)(
197  _In_ PVOID Context,
198  _In_ ULONG BatteryTag,
199  _Out_ PBATTERY_STATUS BatteryStatus);
200 typedef BCLASS_QUERY_STATUS_CALLBACK *PBCLASS_QUERY_STATUS_CALLBACK;
201 
207 
208 _Function_class_(BCLASS_SET_STATUS_NOTIFY_CALLBACK)
212 typedef NTSTATUS
213 (NTAPI BCLASS_SET_STATUS_NOTIFY_CALLBACK)(
216  _In_ PBATTERY_NOTIFY BatteryNotify);
217 typedef BCLASS_SET_STATUS_NOTIFY_CALLBACK *PBCLASS_SET_STATUS_NOTIFY_CALLBACK;
218 
219 _Function_class_(BCLASS_SET_INFORMATION_CALLBACK)
223 typedef NTSTATUS
224 (NTAPI BCLASS_SET_INFORMATION_CALLBACK)(
225  _In_ PVOID Context,
226  _In_ ULONG BatteryTag,
229 typedef BCLASS_SET_INFORMATION_CALLBACK *PBCLASS_SET_INFORMATION_CALLBACK;
230 
231 _Function_class_(BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK)
235 typedef NTSTATUS
236 (NTAPI BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK)(
237  _In_ PVOID Context);
238 typedef BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK *PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK;
239 
243 typedef PBCLASS_SET_STATUS_NOTIFY_CALLBACK BCLASS_SET_STATUS_NOTIFY;
244 typedef PBCLASS_SET_INFORMATION_CALLBACK BCLASS_SET_INFORMATION;
245 typedef PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK BCLASS_DISABLE_STATUS_NOTIFY;
246 
251  BCLASS_QUERY_TAG QueryTag;
252  BCLASS_QUERY_INFORMATION QueryInformation;
253  BCLASS_SET_INFORMATION SetInformation;
254  BCLASS_QUERY_STATUS QueryStatus;
255  BCLASS_SET_STATUS_NOTIFY SetStatusNotify;
256  BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify;
260 
261 #if (NTDDI_VERSION >= NTDDI_WINXP)
262 
263 typedef struct _BATTERY_WMI_STATUS {
274 
275 typedef struct _BATTERY_WMI_RUNTIME {
279 
280 typedef struct _BATTERY_WMI_TEMPERATURE {
284 
289 
290 typedef struct _BATTERY_WMI_CYCLE_COUNT {
294 
295 typedef struct _BATTERY_WMI_STATIC_DATA {
308 
316 
317 typedef struct _BATTERY_TAG_CHANGE {
320 
321 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
322 
323 #if defined(_BATTERYCLASS_)
324 #define BCLASSAPI
325 #else
326 #define BCLASSAPI DECLSPEC_IMPORT
327 #endif
328 
331 BCLASSAPI
332 NTSTATUS
333 NTAPI
335  _In_ PBATTERY_MINIPORT_INFO MiniportInfo,
337 
340 BCLASSAPI
341 NTSTATUS
342 NTAPI
344  _In_ PVOID ClassData,
346 
348 BCLASSAPI
349 NTSTATUS
350 NTAPI
352  _In_ PVOID ClassData);
353 
354 #if (NTDDI_VERSION >= NTDDI_WINXP)
355 
358 BCLASSAPI
359 NTSTATUS
360 NTAPI
362  _In_ PVOID ClassData,
364  _Inout_ PIRP Irp,
366  _Out_writes_(1) PULONG InstanceLengthArray,
368  _Out_writes_bytes_opt_(OutBufferSize) PUCHAR Buffer);
369 
372 BCLASSAPI
373 NTSTATUS
374 NTAPI
376  _In_ PVOID ClassData,
377  _In_ PVOID WmiLibContext, /* PWMILIB_CONTEXT */
378  _In_ PDEVICE_OBJECT DeviceObject,
379  _Inout_ PIRP Irp,
380  _Out_ PVOID Disposition); /* PSYSCTL_IRP_DISPOSITION */
381 
382 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
383 
385 BCLASSAPI
386 NTSTATUS
387 NTAPI
389  _In_ PVOID ClassData);
390 
391 #endif /* _WINDOWS_H */
392 
393 #endif /* _BATCLASS_ */
394 
395 #ifdef __cplusplus
396 }
397 #endif
DWORD *typedef PVOID
Definition: winlogon.h:52
struct _BATTERY_TAG_CHANGE * PBATTERY_TAG_CHANGE
struct _BATTERY_WAIT_STATUS * PBATTERY_WAIT_STATUS
struct _BATTERY_WMI_RUNTIME * PBATTERY_WMI_RUNTIME
#define _IRQL_requires_same_
Definition: no_sal2.h:652
BCLASSAPI NTSTATUS NTAPI BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, PVOID *ClassData)
Definition: battc.c:133
enum _BATTERY_SET_INFORMATION_LEVEL BATTERY_SET_INFORMATION_LEVEL
_In_ ULONG _Out_ PBATTERY_STATUS BatteryStatus
Definition: batclass.h:198
struct _BATTERY_WMI_CYCLE_COUNT BATTERY_WMI_CYCLE_COUNT
BCLASS_QUERY_STATUS_CALLBACK * PBCLASS_QUERY_STATUS_CALLBACK
Definition: batclass.h:200
struct _BATTERY_INFORMATION BATTERY_INFORMATION
_In_ PVOID WmiLibContext
Definition: batclass.h:377
_Inout_ PDEVICE_OBJECT _Inout_ PIRP _In_ ULONG _Out_writes_(1) PULONG InstanceLengthArray
struct _BATTERY_WMI_CYCLE_COUNT * PBATTERY_WMI_CYCLE_COUNT
struct _BATTERY_MANUFACTURE_DATE * PBATTERY_MANUFACTURE_DATE
_In_ PIRP Irp
Definition: csq.h:116
ULONG PowerState
Definition: batclass.h:154
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char * PUCHAR
Definition: retypes.h:3
enum _BATTERY_QUERY_INFORMATION_LEVEL BATTERY_QUERY_INFORMATION_LEVEL
struct _BATTERY_WMI_STATUS_CHANGE BATTERY_WMI_STATUS_CHANGE
struct _BATTERY_QUERY_INFORMATION * PBATTERY_QUERY_INFORMATION
PBCLASS_QUERY_STATUS_CALLBACK BCLASS_QUERY_STATUS
Definition: batclass.h:242
PBCLASS_SET_STATUS_NOTIFY_CALLBACK BCLASS_SET_STATUS_NOTIFY
Definition: batclass.h:243
struct _BATTERY_WMI_TEMPERATURE * PBATTERY_WMI_TEMPERATURE
_In_ ULONG _In_ PBATTERY_NOTIFY BatteryNotify
Definition: batclass.h:215
struct _BATTERY_NOTIFY BATTERY_NOTIFY
BCLASS_DISABLE_STATUS_NOTIFY_CALLBACK * PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK
Definition: batclass.h:238
BCLASSAPI NTSTATUS NTAPI BatteryClassIoctl(PVOID ClassData, PIRP Irp)
Definition: battc.c:184
#define _Check_return_
Definition: no_sal2.h:13
_Out_ PULONG BatteryTag
Definition: batclass.h:173
BCLASS_SET_INFORMATION_CALLBACK * PBCLASS_SET_INFORMATION_CALLBACK
Definition: batclass.h:229
struct _BATTERY_MINIPORT_INFO BATTERY_MINIPORT_INFO
_IRQL_requires_max_(PASSIVE_LEVEL) _Check_return_ BCLASSAPI NTSTATUS NTAPI BatteryClassInitializeDevice(_In_ PBATTERY_MINIPORT_INFO MiniportInfo
Definition: Messaging.c:37
BCLASSAPI NTSTATUS NTAPI BatteryClassUnload(PVOID ClassData)
Definition: battc.c:27
BOOLEAN Discharging
Definition: batclass.h:271
#define _In_opt_
Definition: no_sal2.h:213
IN OUT PIRP IN ULONG IN ULONG IN ULONG IN ULONG IN ULONG OutBufferSize
Definition: wmilib.h:56
struct _BATTERY_WMI_STATUS * PBATTERY_WMI_STATUS
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify
Definition: batclass.h:256
struct _BATTERY_MANUFACTURE_DATE BATTERY_MANUFACTURE_DATE
BATTERY_SET_INFORMATION_LEVEL InformationLevel
Definition: batclass.h:141
long LONG
Definition: pedump.c:60
_Inout_ PDEVICE_OBJECT _Inout_ PIRP _In_ ULONG _In_ ULONG _Out_writes_bytes_opt_(OutBufferSize) PUCHAR Buffer)
struct _BATTERY_WMI_FULL_CHARGED_CAPACITY * PBATTERY_WMI_FULL_CHARGED_CAPACITY
struct _BATTERY_SET_INFORMATION BATTERY_SET_INFORMATION
#define BCLASSAPI
Definition: batclass.h:326
BATTERY_REPORTING_SCALE Granularity[4]
Definition: batclass.h:298
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _Out_writes_bytes_to_(BufferLength,*ReturnedLength) PVOID Buffer
struct _BATTERY_NOTIFY * PBATTERY_NOTIFY
PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK BCLASS_DISABLE_STATUS_NOTIFY
Definition: batclass.h:245
BCLASSAPI NTSTATUS NTAPI BatteryClassStatusNotify(PVOID ClassData)
Definition: battc.c:78
#define _Out_
Definition: no_sal2.h:323
BOOLEAN PowerOnline
Definition: batclass.h:269
Definition: bufpool.h:45
BATTERY_QUERY_INFORMATION_LEVEL InformationLevel
Definition: batclass.h:110
ULONG HighCapacity
Definition: batclass.h:205
_BATTERY_SET_INFORMATION_LEVEL
Definition: batclass.h:133
unsigned char BOOLEAN
ULONG PowerState
Definition: batclass.h:203
_Function_class_(BCLASS_QUERY_TAG_CALLBACK) _IRQL_requires_same_ _IRQL_requires_max_(PASSIVE_LEVEL) _Check_return_ typedef NTSTATUS(NTAPI BCLASS_QUERY_TAG_CALLBACK)(_In_ PVOID Context
struct _BATTERY_INFORMATION * PBATTERY_INFORMATION
_In_ PVOID _In_ PDEVICE_OBJECT _Inout_ PIRP _Out_ PVOID Disposition
Definition: batclass.h:377
PDEVICE_OBJECT Pdo
Definition: batclass.h:257
BCLASS_QUERY_INFORMATION_CALLBACK * PBCLASS_QUERY_INFORMATION_CALLBACK
Definition: batclass.h:189
ULONG RemainingCapacity
Definition: batclass.h:265
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG AtRate
Definition: batclass.h:183
struct _BATTERY_STATUS * PBATTERY_STATUS
BCLASS_SET_STATUS_NOTIFY_CALLBACK * PBCLASS_SET_STATUS_NOTIFY_CALLBACK
Definition: batclass.h:217
#define _Inout_
Definition: no_sal2.h:244
struct _BATTERY_WAIT_STATUS BATTERY_WAIT_STATUS
struct _BATTERY_WMI_STATIC_DATA BATTERY_WMI_STATIC_DATA
BCLASSAPI NTSTATUS NTAPI BatteryClassSystemControl(PVOID ClassData, PVOID WmiLibContext, PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Disposition)
Definition: battc.c:48
unsigned char UCHAR
Definition: xmlstorage.h:181
PUNICODE_STRING DeviceName
Definition: batclass.h:258
struct _BATTERY_MINIPORT_INFO * PBATTERY_MINIPORT_INFO
struct _BATTERY_WMI_STATUS_CHANGE * PBATTERY_WMI_STATUS_CHANGE
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:187
BCLASS_QUERY_INFORMATION QueryInformation
Definition: batclass.h:252
DEFINE_GUID(GUID_DEVICE_BATTERY, 0x72631e54L, 0x78A4, 0x11d0, 0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_BATTERY_QUERY_INFORMATION_LEVEL
Definition: batclass.h:96
_Inout_ PDEVICE_OBJECT DeviceObject
Definition: batclass.h:363
ULONG PVOID Reserved
Definition: ntimage.h:533
ULONG Capacity
Definition: batclass.h:155
IN OUT PIRP IN ULONG GuidIndex
Definition: wmilib.h:37
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG BufferLength
Definition: batclass.h:187
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define _In_
Definition: no_sal2.h:204
ULONG FullChargedCapacity
Definition: batclass.h:120
BCLASSAPI NTSTATUS NTAPI BatteryClassQueryWmiDataBlock(PVOID ClassData, PDEVICE_OBJECT DeviceObject, PIRP Irp, ULONG GuidIndex, PULONG InstanceLengthArray, ULONG OutBufferSize, PUCHAR Buffer)
Definition: battc.c:62
PBCLASS_SET_INFORMATION_CALLBACK BCLASS_SET_INFORMATION
Definition: batclass.h:244
ULONG LowCapacity
Definition: batclass.h:204
LONG NTSTATUS
Definition: DriverTester.h:11
struct _BATTERY_TAG_CHANGE BATTERY_TAG_CHANGE
unsigned short USHORT
Definition: pedump.c:61
struct _BATTERY_WMI_RUNTIME BATTERY_WMI_RUNTIME
BCLASS_SET_INFORMATION SetInformation
Definition: batclass.h:253
unsigned int * PULONG
Definition: retypes.h:1
BCLASS_QUERY_TAG_CALLBACK * PBCLASS_QUERY_TAG_CALLBACK
Definition: batclass.h:174
UCHAR Chemistry[4]
Definition: batclass.h:118
struct _BATTERY_QUERY_INFORMATION BATTERY_QUERY_INFORMATION
struct _BATTERY_SET_INFORMATION * PBATTERY_SET_INFORMATION
PBCLASS_QUERY_TAG_CALLBACK BCLASS_QUERY_TAG
Definition: batclass.h:240
PVOID PIRP
Definition: usb.h:38
unsigned int ULONG
Definition: retypes.h:1
BCLASS_SET_STATUS_NOTIFY SetStatusNotify
Definition: batclass.h:255
BCLASS_QUERY_TAG QueryTag
Definition: batclass.h:251
BCLASS_QUERY_STATUS QueryStatus
Definition: batclass.h:254
PBCLASS_QUERY_INFORMATION_CALLBACK BCLASS_QUERY_INFORMATION
Definition: batclass.h:241
WCHAR ManufactureDate[25]
Definition: batclass.h:297
struct _BATTERY_STATUS BATTERY_STATUS
struct _BATTERY_WMI_STATIC_DATA * PBATTERY_WMI_STATIC_DATA
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL Level
Definition: batclass.h:183
_Out_ PVOID * ClassData
Definition: batclass.h:336
struct _BATTERY_WMI_TEMPERATURE BATTERY_WMI_TEMPERATURE
struct _BATTERY_WMI_STATUS BATTERY_WMI_STATUS
struct _BATTERY_WMI_FULL_CHARGED_CAPACITY BATTERY_WMI_FULL_CHARGED_CAPACITY