ReactOS 0.4.15-dev-7958-gcd0bb1a
compbatt.h File Reference
#include <wdm.h>
#include <batclass.h>
Include dependency graph for compbatt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _COMPBATT_BATTERY_DATA
 
struct  _COMPBATT_DEVICE_EXTENSION
 

Macros

#define COMPBATT_BATTERY_INFORMATION_PRESENT   0x04
 
#define COMPBATT_TAG_ASSIGNED   0x80
 

Typedefs

typedef struct _COMPBATT_BATTERY_DATA COMPBATT_BATTERY_DATA
 
typedef struct _COMPBATT_BATTERY_DATAPCOMPBATT_BATTERY_DATA
 
typedef struct _COMPBATT_DEVICE_EXTENSION COMPBATT_DEVICE_EXTENSION
 
typedef struct _COMPBATT_DEVICE_EXTENSIONPCOMPBATT_DEVICE_EXTENSION
 

Functions

NTSTATUS NTAPI CompBattAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PdoDeviceObject)
 
NTSTATUS NTAPI CompBattPowerDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI CompBattPnpDispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI CompBattQueryInformation (IN PCOMPBATT_DEVICE_EXTENSION FdoExtension, IN ULONG Tag, IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, IN OPTIONAL LONG AtRate, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG ReturnedLength)
 
NTSTATUS NTAPI CompBattQueryStatus (IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag, IN PBATTERY_STATUS BatteryStatus)
 
NTSTATUS NTAPI CompBattSetStatusNotify (IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG BatteryTag, IN PBATTERY_NOTIFY BatteryNotify)
 
NTSTATUS NTAPI CompBattDisableStatusNotify (IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI CompBattQueryTag (IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, OUT PULONG Tag)
 
NTSTATUS NTAPI CompBattMonitorIrpComplete (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PKEVENT Event)
 
NTSTATUS NTAPI CompBattMonitorIrpCompleteWorker (IN PCOMPBATT_BATTERY_DATA BatteryData)
 
NTSTATUS NTAPI CompBattGetDeviceObjectPointer (IN PUNICODE_STRING DeviceName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject)
 
NTSTATUS NTAPI BatteryIoctl (IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl)
 

Variables

ULONG CompBattDebug
 

Macro Definition Documentation

◆ COMPBATT_BATTERY_INFORMATION_PRESENT

#define COMPBATT_BATTERY_INFORMATION_PRESENT   0x04

Definition at line 15 of file compbatt.h.

◆ COMPBATT_TAG_ASSIGNED

#define COMPBATT_TAG_ASSIGNED   0x80

Definition at line 16 of file compbatt.h.

Typedef Documentation

◆ COMPBATT_BATTERY_DATA

◆ COMPBATT_DEVICE_EXTENSION

◆ PCOMPBATT_BATTERY_DATA

◆ PCOMPBATT_DEVICE_EXTENSION

Function Documentation

◆ BatteryIoctl()

NTSTATUS NTAPI BatteryIoctl ( IN ULONG  IoControlCode,
IN PDEVICE_OBJECT  DeviceObject,
IN PVOID  InputBuffer,
IN ULONG  InputBufferLength,
IN PVOID  OutputBuffer,
IN ULONG  OutputBufferLength,
IN BOOLEAN  InternalDeviceIoControl 
)

Definition at line 17 of file compmisc.c.

24{
28 PIRP Irp;
29 PAGED_CODE();
30 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING BatteryIoctl\n");
31
32 /* Initialize the event and IRP */
41 &Event,
43 if (Irp)
44 {
45 /* Call the class driver miniport */
48 {
49 /* Wait for result */
52 }
53
54 /* Print failure */
55 if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8))
56 DbgPrint("BatteryIoctl: Irp failed - %x\n", Status);
57
58 /* Done */
59 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n");
60 }
61 else
62 {
63 /* Out of memory */
64 if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n");
66 }
67
68 /* Return status */
69 return Status;
70}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
ULONG CompBattDebug
Definition: compbatt.c:17
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
Definition: wdfio.h:325
_In_ WDFREQUEST _In_ size_t OutputBufferLength
Definition: wdfio.h:320
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
Definition: wdfio.h:322
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID _In_ ULONG _In_ BOOLEAN InternalDeviceIoControl
Definition: iofuncs.h:720
@ Executive
Definition: ketypes.h:415

Referenced by CompBattGetBatteryGranularity(), and CompBattGetBatteryInformation().

◆ CompBattAddDevice()

NTSTATUS NTAPI CompBattAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  PdoDeviceObject 
)

Definition at line 320 of file comppnp.c.

322{
325 PCOMPBATT_DEVICE_EXTENSION DeviceExtension;
328 BATTERY_MINIPORT_INFO MiniportInfo;
329 if (CompBattDebug & 2) DbgPrint("CompBatt: Got an AddDevice - %x\n", PdoDeviceObject);
330
331 /* Create the device */
332 RtlInitUnicodeString(&DeviceName, L"\\Device\\CompositeBattery");
335 &DeviceName,
338 FALSE,
339 &DeviceObject);
340 if (!NT_SUCCESS(Status)) return Status;
341
342 /* Setup symbolic link for Win32 access */
343 RtlInitUnicodeString(&SymbolicLinkName, L"\\DosDevices\\CompositeBattery");
345
346 /* Initialize the device extension */
347 DeviceExtension = DeviceObject->DeviceExtension;
348 RtlZeroMemory(DeviceExtension, sizeof(COMPBATT_DEVICE_EXTENSION));
349
350 /* Attach to device stack and set DO pointers */
353 DeviceExtension->DeviceObject = DeviceObject;
354 if (!DeviceExtension->AttachedDevice)
355 {
356 /* Fail */
357 if (CompBattDebug & 8)
358 DbgPrint("CompBattAddDevice: Could not attach to LowerDevice.\n");
360 return STATUS_UNSUCCESSFUL;
361 }
362
363 /* Set device object flags */
365 DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
366
367 /* Setup the device extension */
368 ExInitializeFastMutex(&DeviceExtension->Lock);
369 InitializeListHead(&DeviceExtension->BatteryList);
370 DeviceExtension->Flags = 0;
371 DeviceExtension->NextTag = 1;
372
373 /* Setup the miniport data */
374 RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo));
377 MiniportInfo.Context = DeviceExtension;
378 MiniportInfo.DeviceName = &DeviceName;
381 MiniportInfo.SetInformation = NULL;
385 MiniportInfo.Pdo = NULL;
386
387 /* Register with the class driver */
388 Status = BatteryClassInitializeDevice(&MiniportInfo,
389 &DeviceExtension->ClassData);
390 if (!NT_SUCCESS(Status))
391 {
392 /* Undo everything */
393 IoDetachDevice(DeviceExtension->AttachedDevice);
395 }
396
397 /* Return status */
398 return Status;
399}
#define BATTERY_CLASS_MAJOR_VERSION
Definition: batclass.h:163
PBCLASS_QUERY_INFORMATION_CALLBACK BCLASS_QUERY_INFORMATION
Definition: batclass.h:241
PBCLASS_SET_STATUS_NOTIFY_CALLBACK BCLASS_SET_STATUS_NOTIFY
Definition: batclass.h:243
PBCLASS_DISABLE_STATUS_NOTIFY_CALLBACK BCLASS_DISABLE_STATUS_NOTIFY
Definition: batclass.h:245
#define BATTERY_CLASS_MINOR_VERSION
Definition: batclass.h:164
PBCLASS_QUERY_STATUS_CALLBACK BCLASS_QUERY_STATUS
Definition: batclass.h:242
PBCLASS_QUERY_TAG_CALLBACK BCLASS_QUERY_TAG
Definition: batclass.h:240
BCLASSAPI NTSTATUS NTAPI BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, PVOID *ClassData)
Definition: battc.c:137
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
NTSTATUS NTAPI CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag, IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, IN OPTIONAL LONG AtRate, IN PVOID Buffer, IN ULONG BufferLength, OUT PULONG ReturnedLength)
Definition: compbatt.c:482
NTSTATUS NTAPI CompBattDisableStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: compbatt.c:184
NTSTATUS NTAPI CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, OUT PULONG Tag)
Definition: compbatt.c:149
NTSTATUS NTAPI CompBattSetStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG BatteryTag, IN PBATTERY_NOTIFY BatteryNotify)
Definition: compbatt.c:211
NTSTATUS NTAPI CompBattQueryStatus(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag, IN PBATTERY_STATUS BatteryStatus)
Definition: compbatt.c:221
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT _In_ PUSB_PORT_PATH _Out_ PUSB_CD_ERROR_INFORMATION _In_ USHORT _In_ PDEVICE_OBJECT PdoDeviceObject
Definition: hubbusif.h:95
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_BATTERY
Definition: winioctl.h:147
BCLASS_QUERY_INFORMATION QueryInformation
Definition: batclass.h:252
PDEVICE_OBJECT Pdo
Definition: batclass.h:257
BCLASS_SET_STATUS_NOTIFY SetStatusNotify
Definition: batclass.h:255
BCLASS_SET_INFORMATION SetInformation
Definition: batclass.h:253
PUNICODE_STRING DeviceName
Definition: batclass.h:258
BCLASS_DISABLE_STATUS_NOTIFY DisableStatusNotify
Definition: batclass.h:256
BCLASS_QUERY_STATUS QueryStatus
Definition: batclass.h:254
BCLASS_QUERY_TAG QueryTag
Definition: batclass.h:251
PDEVICE_OBJECT DeviceObject
Definition: compbatt.h:55
PDEVICE_OBJECT AttachedDevice
Definition: compbatt.h:54
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define DO_POWER_PAGABLE

Referenced by DriverEntry().

◆ CompBattDisableStatusNotify()

NTSTATUS NTAPI CompBattDisableStatusNotify ( IN PCOMPBATT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 184 of file compbatt.c.

185{
186 PCOMPBATT_BATTERY_DATA BatteryData;
187 PLIST_ENTRY ListHead, NextEntry;
188 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n");
189
190 /* Loop the battery list */
191 ExAcquireFastMutex(&DeviceExtension->Lock);
192 ListHead = &DeviceExtension->BatteryList;
193 NextEntry = ListHead->Flink;
194 while (NextEntry != ListHead)
195 {
196 /* Get the battery information and clear capacity data */
197 BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink);
198 BatteryData->WaitStatus.LowCapacity = 0;
199 BatteryData->WaitStatus.HighCapacity = 0x7FFFFFFF;
200 NextEntry = NextEntry->Flink;
201 }
202
203 /* Done */
204 ExReleaseFastMutex(&DeviceExtension->Lock);
205 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING DisableStatusNotify\n");
206 return STATUS_SUCCESS;
207}
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define STATUS_SUCCESS
Definition: shellext.h:65
BATTERY_WAIT_STATUS WaitStatus
Definition: compbatt.h:26
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by CompBattAddDevice().

◆ CompBattGetDeviceObjectPointer()

NTSTATUS NTAPI CompBattGetDeviceObjectPointer ( IN PUNICODE_STRING  DeviceName,
IN ACCESS_MASK  DesiredAccess,
OUT PFILE_OBJECT FileObject,
OUT PDEVICE_OBJECT DeviceObject 
)

Definition at line 74 of file compmisc.c.

78{
82 PFILE_OBJECT LocalFileObject;
84 PAGED_CODE();
85
86 /* Open a file object handle to the device */
90 NULL,
91 NULL);
92 Status = ZwCreateFile(&DeviceHandle,
96 NULL,
97 0,
100 0,
101 NULL,
102 0);
103 if (NT_SUCCESS(Status))
104 {
105 /* Reference the file object */
107 0,
110 (PVOID)&LocalFileObject,
111 NULL);
112 if (NT_SUCCESS(Status))
113 {
114 /* Return the FO and the associated DO */
115 *FileObject = LocalFileObject;
116 *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject);
117 }
118
119 /* Close the handle */
121 }
122
123 /* Return status */
124 return Status;
125}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_OPEN
Definition: from_kernel.h:54
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject)
Definition: device.c:1539
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998

Referenced by CompBattAddNewBattery().

◆ CompBattMonitorIrpComplete()

NTSTATUS NTAPI CompBattMonitorIrpComplete ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PKEVENT  Event 
)

Definition at line 70 of file compbatt.c.

73{
76}
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by CompBattAddNewBattery().

◆ CompBattMonitorIrpCompleteWorker()

NTSTATUS NTAPI CompBattMonitorIrpCompleteWorker ( IN PCOMPBATT_BATTERY_DATA  BatteryData)

Definition at line 80 of file compbatt.c.

81{
84}

Referenced by CompBattAddNewBattery().

◆ CompBattPnpDispatch()

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

Definition at line 403 of file comppnp.c.

405{
408 PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
409 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpDispatch\n");
410
411 /* Set default error */
413
414 /* Check what kind of PnP function this is */
415 switch (IoStackLocation->MinorFunction)
416 {
418
419 /* Device is starting, register for new batteries and pick up current ones */
421 0,
422 (PVOID)&GUID_DEVICE_BATTERY,
423 DeviceObject->DriverObject,
425 DeviceExtension,
426 &DeviceExtension->NotificationEntry);
427 if (NT_SUCCESS(Status))
428 {
429 /* Now go get the batteries */
430 if (CompBattDebug & 2)
431 DbgPrint("CompBatt: Successfully registered for PnP notification\n");
432 Status = CompBattGetBatteries(DeviceExtension);
433 }
434 else
435 {
436 /* We failed */
437 if (CompBattDebug & 8)
438 DbgPrint("CompBatt: Couldn't register for PnP notification - %x\n",
439 Status);
440 }
441 break;
443
444 /* Explicitly say ok */
446 break;
447
449
450 /* Explicitly say ok */
452 break;
453
455
456 /* Explicitly say ok */
458 break;
459
461
462 /* Add this in */
463 Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
465 break;
466
467 default:
468
469 /* Not supported */
471 break;
472 }
473
474 /* Set IRP status if we have one */
475 if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status;
476
477 /* Did someone pick it up? */
479 {
480 /* Still unsupported, try ACPI */
482 Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp);
483 }
484 else
485 {
486 /* Complete the request */
487 Status = Irp->IoStatus.Status;
489 }
490
491 /* Release the remove lock and return status */
492 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpDispatch\n");
493 return Status;
494}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
NTSTATUS NTAPI CompBattPnpEventHandler(IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: comppnp.c:287
NTSTATUS NTAPI CompBattGetBatteries(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: comppnp.c:246
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:345
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define PNP_DEVICE_NOT_DISABLEABLE
Definition: iotypes.h:1006
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IRP_MN_START_DEVICE
@ EventCategoryDeviceInterfaceChange
Definition: iotypes.h:1226
#define IRP_MN_CANCEL_REMOVE_DEVICE
DRIVER_NOTIFICATION_CALLBACK_ROUTINE * PDRIVER_NOTIFICATION_CALLBACK_ROUTINE
Definition: iotypes.h:1247

Referenced by DriverEntry().

◆ CompBattPowerDispatch()

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

Definition at line 19 of file comppnp.c.

21{
22 PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
23 if (CompBattDebug & 1) DbgPrint("CompBatt: PowerDispatch received power IRP.\n");
24
25 /* Start the next IRP */
27
28 /* Call the next driver in the stack */
30 return PoCallDriver(DeviceExtension->AttachedDevice, Irp);
31}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758

Referenced by DriverEntry().

◆ CompBattQueryInformation()

NTSTATUS NTAPI CompBattQueryInformation ( IN PCOMPBATT_DEVICE_EXTENSION  FdoExtension,
IN ULONG  Tag,
IN BATTERY_QUERY_INFORMATION_LEVEL  InfoLevel,
IN OPTIONAL LONG  AtRate,
IN PVOID  Buffer,
IN ULONG  BufferLength,
OUT PULONG  ReturnedLength 
)

Definition at line 482 of file compbatt.c.

489{
490 BATTERY_INFORMATION BatteryInfo;
491 BATTERY_REPORTING_SCALE BatteryGranularity[4];
492 PWCHAR BatteryName = L"Composite Battery";
493 //BATTERY_MANUFACTURE_DATE Date;
494 ULONG Dummy, Time;
495 PVOID QueryData = NULL;
496 ULONG QueryLength = 0;
498 PAGED_CODE();
499 if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING QueryInformation\n");
500
501 /* Check for valid/correct tag */
502 if ((Tag != DeviceExtension->Tag) ||
503 (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED)))
504 {
505 /* Not right, so fail */
507 }
508
509 /* Check what caller wants */
510 switch (InfoLevel)
511 {
513
514 /* Query combined battery information */
515 RtlZeroMemory(&BatteryInfo, sizeof(BatteryInfo));
516 Status = CompBattGetBatteryInformation(&BatteryInfo, DeviceExtension);
517 if (NT_SUCCESS(Status))
518 {
519 /* Return the data if successful */
520 QueryData = &BatteryInfo;
521 QueryLength = sizeof(BatteryInfo);
522 }
523 break;
524
526
527 /* Query combined granularity information */
528 RtlZeroMemory(&BatteryGranularity, sizeof(BatteryGranularity));
529 Status = CompBattGetBatteryGranularity(BatteryGranularity, DeviceExtension);
530 if (NT_SUCCESS(Status))
531 {
532 /* Return the data if successful */
533 QueryLength = sizeof(BatteryGranularity);
534 QueryData = &BatteryGranularity;
535 }
536 break;
537
539
540 /* Query combined time estimate information */
541 RtlZeroMemory(&Time, sizeof(Time));
542 Status = CompBattGetEstimatedTime(&Time, DeviceExtension);
543 if (NT_SUCCESS(Status))
544 {
545 /* Return the data if successful */
546 QueryLength = sizeof(Time);
547 QueryData = &Time;
548 }
549 break;
550
553
554 /* Return the static buffer */
555 QueryData = BatteryName;
556 QueryLength = sizeof(L"Composite Battery");
557 break;
558
560
561 /* Static data */
562 //Date.Day = 26;
563 //Date.Month = 06;
564 //Date.Year = 1997;
565 break;
566
568 case BatteryUniqueID:
569
570 /* Return zero */
571 Dummy = 0;
572 QueryData = &Dummy;
573 QueryLength = sizeof(Dummy);
574 break;
575
576 default:
577 /* Everything else is unknown */
579 break;
580 }
581
582 /* Return the required length and check if the caller supplied enough */
583 *ReturnedLength = QueryLength;
584 if (BufferLength < QueryLength) Status = STATUS_BUFFER_TOO_SMALL;
585
586 /* Copy the data if there's enough space and it exists */
587 if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength);
588
589 /* Return function result */
590 if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING QueryInformation\n");
591 return Status;
592}
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
@ BatteryInformation
Definition: batclass.h:97
@ BatteryManufactureName
Definition: batclass.h:103
@ BatteryGranularityInformation
Definition: batclass.h:98
@ BatteryUniqueID
Definition: batclass.h:104
@ BatteryEstimatedTime
Definition: batclass.h:100
@ BatteryDeviceName
Definition: batclass.h:101
@ BatteryTemperature
Definition: batclass.h:99
@ BatteryManufactureDate
Definition: batclass.h:102
Definition: bufpool.h:45
NTSTATUS NTAPI CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInfo, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: compbatt.c:231
NTSTATUS NTAPI CompBattGetBatteryGranularity(OUT PBATTERY_REPORTING_SCALE ReportingScale, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: compbatt.c:387
NTSTATUS NTAPI CompBattGetEstimatedTime(OUT PULONG Time, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: compbatt.c:473
#define COMPBATT_TAG_ASSIGNED
Definition: compbatt.h:16
static PLARGE_INTEGER Time
Definition: time.c:105
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by CompBattAddDevice().

◆ CompBattQueryStatus()

NTSTATUS NTAPI CompBattQueryStatus ( IN PCOMPBATT_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  Tag,
IN PBATTERY_STATUS  BatteryStatus 
)

Definition at line 221 of file compbatt.c.

224{
227}

Referenced by CompBattAddDevice().

◆ CompBattQueryTag()

NTSTATUS NTAPI CompBattQueryTag ( IN PCOMPBATT_DEVICE_EXTENSION  DeviceExtension,
OUT PULONG  Tag 
)

Definition at line 149 of file compbatt.c.

151{
153 PAGED_CODE();
154 if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING QueryTag\n");
155
156 /* Was a tag assigned? */
157 if (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED))
158 {
159 /* Assign one */
160 CompBattRecalculateTag(DeviceExtension);
161 }
162
163 /* Do we have a tag now? */
164 if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && (DeviceExtension->Tag))
165 {
166 /* Return the tag */
167 *Tag = DeviceExtension->Tag;
169 }
170 else
171 {
172 /* No tag */
173 *Tag = 0;
175 }
176
177 /* Return status */
178 if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING QueryTag\n");
179 return Status;
180}
VOID NTAPI CompBattRecalculateTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
Definition: compbatt.c:88

Referenced by CompBattAddDevice().

◆ CompBattSetStatusNotify()

NTSTATUS NTAPI CompBattSetStatusNotify ( IN PCOMPBATT_DEVICE_EXTENSION  DeviceExtension,
IN ULONG  BatteryTag,
IN PBATTERY_NOTIFY  BatteryNotify 
)

Definition at line 211 of file compbatt.c.

214{
217}

Referenced by CompBattAddDevice().

Variable Documentation

◆ CompBattDebug