[COMPBATT] Use the documented debug switches

Use the debug switches that are documented and have a name rather than some cryptic values with no meaning or some shit.
This commit is contained in:
George Bișoc 2024-12-14 22:27:07 +01:00
parent c6bdbefdc4
commit 95f062bf0d
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
3 changed files with 49 additions and 49 deletions

View file

@ -25,7 +25,7 @@ CompBattOpenClose(
_In_ PIRP Irp)
{
PAGED_CODE();
if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING OpenClose\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING OpenClose\n");
/* Complete the IRP with success */
Irp->IoStatus.Status = STATUS_SUCCESS;
@ -33,7 +33,7 @@ CompBattOpenClose(
IoCompleteRequest(Irp, IO_NO_INCREMENT);
/* Return success */
if (CompBattDebug & 0x100) DbgPrint("CompBatt: Exiting OpenClose\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: Exiting OpenClose\n");
return STATUS_SUCCESS;
}
@ -46,7 +46,7 @@ CompBattSystemControl(
PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status;
PAGED_CODE();
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING System Control\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING System Control\n");
/* Are we attached yet? */
if (DeviceExtension->AttachedDevice)
@ -95,7 +95,7 @@ CompBattRecalculateTag(
PCOMPBATT_BATTERY_DATA BatteryData;
ULONG Tag;
PLIST_ENTRY ListHead, NextEntry;
if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING CompBattRecalculateTag\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING CompBattRecalculateTag\n");
/* Loop the battery list */
ExAcquireFastMutex(&DeviceExtension->Lock);
@ -122,7 +122,7 @@ CompBattRecalculateTag(
/* We're done */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING CompBattRecalculateTag\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING CompBattRecalculateTag\n");
}
NTSTATUS
@ -133,7 +133,7 @@ CompBattIoctl(
{
PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
NTSTATUS Status;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING Ioctl\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING Ioctl\n");
/* Let the class driver handle it */
Status = BatteryClassIoctl(DeviceExtension->ClassData, Irp);
@ -146,7 +146,7 @@ CompBattIoctl(
}
/* Return status */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING Ioctl\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING Ioctl\n");
return Status;
}
@ -158,7 +158,7 @@ CompBattQueryTag(
{
NTSTATUS Status;
PAGED_CODE();
if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING QueryTag\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING QueryTag\n");
/* Was a tag assigned? */
if (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED))
@ -182,7 +182,7 @@ CompBattQueryTag(
}
/* Return status */
if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING QueryTag\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING QueryTag\n");
return Status;
}
@ -193,7 +193,7 @@ CompBattDisableStatusNotify(
{
PCOMPBATT_BATTERY_DATA BatteryData;
PLIST_ENTRY ListHead, NextEntry;
if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n");
/* Loop the battery list */
ExAcquireFastMutex(&DeviceExtension->Lock);
@ -210,7 +210,7 @@ CompBattDisableStatusNotify(
/* Done */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING DisableStatusNotify\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING DisableStatusNotify\n");
return STATUS_SUCCESS;
}
@ -246,7 +246,7 @@ CompBattGetBatteryInformation(
BATTERY_QUERY_INFORMATION InputBuffer;
PCOMPBATT_BATTERY_DATA BatteryData;
PLIST_ENTRY ListHead, NextEntry;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryInformation\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING GetBatteryInformation\n");
/* Set defaults */
BatteryInfo->DefaultAlert1 = 0;
@ -298,7 +298,7 @@ CompBattGetBatteryInformation(
/* Next time we can use the static copy */
BatteryData->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT;
if (CompBattDebug & 2)
if (CompBattDebug & COMPBATT_DEBUG_INFO)
DbgPrint("CompBattGetBatteryInformation: Read individual BATTERY_INFORMATION\n"
"-------- Capabilities = %x\n-------- Technology = %x\n"
"-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n"
@ -364,7 +364,7 @@ CompBattGetBatteryInformation(
}
/* Print out final combined data */
if (CompBattDebug & 2)
if (CompBattDebug & COMPBATT_DEBUG_INFO)
DbgPrint("CompBattGetBatteryInformation: Returning BATTERY_INFORMATION\n"
"-------- Capabilities = %x\n-------- Technology = %x\n"
"-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n"
@ -389,7 +389,7 @@ CompBattGetBatteryInformation(
}
/* We are done */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryInformation\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING GetBatteryInformation\n");
return Status;
}
@ -405,7 +405,7 @@ CompBattGetBatteryGranularity(
BATTERY_REPORTING_SCALE BatteryScale[4];
PLIST_ENTRY ListHead, NextEntry;
ULONG i;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryGranularity\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING GetBatteryGranularity\n");
/* Set defaults */
ReportingScale[0].Granularity = -1;
@ -476,7 +476,7 @@ CompBattGetBatteryGranularity(
/* All done */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryGranularity\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING GetBatteryGranularity\n");
return STATUS_SUCCESS;
}
@ -510,7 +510,7 @@ CompBattQueryInformation(
ULONG QueryLength = 0;
NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE();
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING QueryInformation\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING QueryInformation\n");
/* Check for valid/correct tag */
if ((Tag != DeviceExtension->Tag) ||
@ -601,7 +601,7 @@ CompBattQueryInformation(
if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength);
/* Return function result */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING QueryInformation\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING QueryInformation\n");
return Status;
}

View file

@ -28,7 +28,7 @@ BatteryIoctl(
NTSTATUS Status;
PIRP Irp;
PAGED_CODE();
if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING BatteryIoctl\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING BatteryIoctl\n");
/* Initialize the event and IRP */
KeInitializeEvent(&Event, SynchronizationEvent, 0);
@ -53,16 +53,16 @@ BatteryIoctl(
}
/* Print failure */
if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8))
if (!(NT_SUCCESS(Status)) && (CompBattDebug & COMPBATT_DEBUG_ERR))
DbgPrint("BatteryIoctl: Irp failed - %x\n", Status);
/* Done */
if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING BatteryIoctl\n");
}
else
{
/* Out of memory */
if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n");
if (CompBattDebug & COMPBATT_DEBUG_ERR) DbgPrint("BatteryIoctl: couldn't create Irp\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
}

View file

@ -21,7 +21,7 @@ CompBattPowerDispatch(
_In_ PIRP Irp)
{
PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
if (CompBattDebug & 1) DbgPrint("CompBatt: PowerDispatch received power IRP.\n");
if (CompBattDebug & COMPBATT_DEBUG_WARN) DbgPrint("CompBatt: PowerDispatch received power IRP.\n");
/* Start the next IRP */
PoStartNextPowerIrp(Irp);
@ -39,7 +39,7 @@ RemoveBatteryFromList(
{
PLIST_ENTRY ListHead, NextEntry;
PCOMPBATT_BATTERY_DATA BatteryData;
if (CompBattDebug & 1)
if (CompBattDebug & COMPBATT_DEBUG_TRACE)
DbgPrint("CompBatt: ENTERING RemoveBatteryFromList\n");
/* Loop the battery list */
@ -70,7 +70,7 @@ RemoveBatteryFromList(
/* Done */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING RemoveBatteryFromList\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING RemoveBatteryFromList\n");
return NULL;
}
@ -83,7 +83,7 @@ IsBatteryAlreadyOnList(
PLIST_ENTRY ListHead, NextEntry;
PCOMPBATT_BATTERY_DATA BatteryData;
BOOLEAN Found = FALSE;
if (CompBattDebug & 1)
if (CompBattDebug & COMPBATT_DEBUG_TRACE)
DbgPrint("CompBatt: ENTERING IsBatteryAlreadyOnList\n");
/* Loop the battery list */
@ -107,7 +107,7 @@ IsBatteryAlreadyOnList(
/* Release the lock and return search status */
ExReleaseFastMutex(&DeviceExtension->Lock);
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING IsBatteryAlreadyOnList\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING IsBatteryAlreadyOnList\n");
return Found;
}
@ -123,7 +123,7 @@ CompBattAddNewBattery(
PIO_STACK_LOCATION IoStackLocation;
PFILE_OBJECT FileObject;
PAGED_CODE();
if (CompBattDebug & 1)
if (CompBattDebug & COMPBATT_DEBUG_WARN)
DbgPrint("CompBatt: ENTERING AddNewBattery \"%w\" \n", BatteryName->Buffer);
/* Is this a new battery? */
@ -189,13 +189,13 @@ CompBattAddNewBattery(
else
{
/* Fail, no memory */
if (CompBattDebug & 8)
if (CompBattDebug & COMPBATT_DEBUG_ERR)
DbgPrint("CompBatt: Couldn't allocate new battery Irp\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
ObDereferenceObject(BatteryData->DeviceObject);
}
}
else if (CompBattDebug & 8)
else if (CompBattDebug & COMPBATT_DEBUG_ERR)
{
/* Fail */
DbgPrint("CompBattAddNewBattery: Failed to get device Object. status = %lx\n",
@ -211,14 +211,14 @@ CompBattAddNewBattery(
else
{
/* Fail, no memory */
if (CompBattDebug & 8)
if (CompBattDebug & COMPBATT_DEBUG_ERR)
DbgPrint("CompBatt: Couldn't allocate new battery node\n");
Status = STATUS_INSUFFICIENT_RESOURCES;
}
}
/* We're done */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING AddNewBattery\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING AddNewBattery\n");
return Status;
}
@ -229,7 +229,7 @@ CompBattRemoveBattery(
_In_ PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
PCOMPBATT_BATTERY_DATA BatteryData;
if (CompBattDebug & 1) DbgPrint("CompBatt: RemoveBattery\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: RemoveBattery\n");
/* Remove the entry */
BatteryData = RemoveBatteryFromList(BatteryName, DeviceExtension);
@ -257,7 +257,7 @@ CompBattGetBatteries(
NTSTATUS Status;
PWCHAR LinkList;
UNICODE_STRING LinkString;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteries\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING GetBatteries\n");
/* Get all battery links */
Status = IoGetDeviceInterfaces(&GUID_DEVICE_BATTERY, NULL, 0, &LinkList);
@ -279,14 +279,14 @@ CompBattGetBatteries(
/* Parsing complete, clean up buffer */
ExFreePool(LinkList);
}
else if (CompBattDebug & 8)
else if (CompBattDebug & COMPBATT_DEBUG_ERR)
{
/* Fail */
DbgPrint("CompBatt: Couldn't get list of batteries\n");
}
/* Done */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteries\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING GetBatteries\n");
return Status;
}
@ -296,31 +296,31 @@ CompBattPnpEventHandler(
_In_ PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification,
_In_ PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
{
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpEventHandler\n");
if (CompBattDebug & 2) DbgPrint("CompBatt: Received device interface change notification\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING PnpEventHandler\n");
if (CompBattDebug & COMPBATT_DEBUG_WARN) DbgPrint("CompBatt: Received device interface change notification\n");
/* Check what happened */
if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL))
{
/* Add the new battery */
if (CompBattDebug & 2)
if (CompBattDebug & COMPBATT_DEBUG_WARN)
DbgPrint("CompBatt: Received notification of battery arrival\n");
CompBattAddNewBattery(Notification->SymbolicLinkName, DeviceExtension);
}
else if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL))
{
/* Don't do anything */
if (CompBattDebug & 2)
if (CompBattDebug & COMPBATT_DEBUG_WARN)
DbgPrint("CompBatt: Received notification of battery removal\n");
}
else
{
/* Shouldn't happen */
if (CompBattDebug & 2) DbgPrint("CompBatt: Received unhandled PnP event\n");
if (CompBattDebug & COMPBATT_DEBUG_WARN) DbgPrint("CompBatt: Received unhandled PnP event\n");
}
/* Done, return success */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpEventHandler\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING PnpEventHandler\n");
return STATUS_SUCCESS;
}
@ -336,7 +336,7 @@ CompBattAddDevice(
PDEVICE_OBJECT DeviceObject;
UNICODE_STRING SymbolicLinkName;
BATTERY_MINIPORT_INFO MiniportInfo;
if (CompBattDebug & 2) DbgPrint("CompBatt: Got an AddDevice - %x\n", PdoDeviceObject);
if (CompBattDebug & COMPBATT_DEBUG_WARN) DbgPrint("CompBatt: Got an AddDevice - %x\n", PdoDeviceObject);
/* Create the device */
RtlInitUnicodeString(&DeviceName, L"\\Device\\CompositeBattery");
@ -364,7 +364,7 @@ CompBattAddDevice(
if (!DeviceExtension->AttachedDevice)
{
/* Fail */
if (CompBattDebug & 8)
if (CompBattDebug & COMPBATT_DEBUG_ERR)
DbgPrint("CompBattAddDevice: Could not attach to LowerDevice.\n");
IoDeleteDevice(DeviceObject);
return STATUS_UNSUCCESSFUL;
@ -417,7 +417,7 @@ CompBattPnpDispatch(
PIO_STACK_LOCATION IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
NTSTATUS Status;
PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpDispatch\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: ENTERING PnpDispatch\n");
/* Set default error */
Status = STATUS_NOT_SUPPORTED;
@ -438,14 +438,14 @@ CompBattPnpDispatch(
if (NT_SUCCESS(Status))
{
/* Now go get the batteries */
if (CompBattDebug & 2)
if (CompBattDebug & COMPBATT_DEBUG_WARN)
DbgPrint("CompBatt: Successfully registered for PnP notification\n");
Status = CompBattGetBatteries(DeviceExtension);
}
else
{
/* We failed */
if (CompBattDebug & 8)
if (CompBattDebug & COMPBATT_DEBUG_ERR)
DbgPrint("CompBatt: Couldn't register for PnP notification - %x\n",
Status);
}
@ -499,7 +499,7 @@ CompBattPnpDispatch(
}
/* Release the remove lock and return status */
if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpDispatch\n");
if (CompBattDebug & COMPBATT_DEBUG_TRACE) DbgPrint("CompBatt: EXITING PnpDispatch\n");
return Status;
}