mirror of
https://github.com/reactos/reactos.git
synced 2024-07-29 07:39:10 +00:00
[BATTC] Check if MiniportInfo->Pdo is NULL before passing it to IoRegisterDeviceInterface
[CMBATT] Fix broken CmBattGetAcpiInterfaces [COMPBATT] Fix "typo" in CompBattAddDevice that caused memory corruption svn path=/trunk/; revision=61628
This commit is contained in:
parent
fa95b5794c
commit
1ea1ab9f88
|
@ -151,6 +151,8 @@ BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo,
|
||||||
|
|
||||||
ExInitializeFastMutex(&BattClass->Mutex);
|
ExInitializeFastMutex(&BattClass->Mutex);
|
||||||
|
|
||||||
|
if (MiniportInfo->Pdo != NULL)
|
||||||
|
{
|
||||||
Status = IoRegisterDeviceInterface(MiniportInfo->Pdo,
|
Status = IoRegisterDeviceInterface(MiniportInfo->Pdo,
|
||||||
&GUID_DEVICE_BATTERY,
|
&GUID_DEVICE_BATTERY,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -158,12 +160,18 @@ BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo,
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("Initialized battery interface: %wZ\n", &BattClass->InterfaceName);
|
DPRINT("Initialized battery interface: %wZ\n", &BattClass->InterfaceName);
|
||||||
IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE);
|
Status = IoSetDeviceInterfaceState(&BattClass->InterfaceName, TRUE);
|
||||||
|
if (Status == STATUS_OBJECT_NAME_EXISTS)
|
||||||
|
{
|
||||||
|
DPRINT1("Got STATUS_OBJECT_NAME_EXISTS for SetDeviceInterfaceState\n");
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status);
|
DPRINT1("IoRegisterDeviceInterface failed (0x%x)\n", Status);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*ClassData = BattClass;
|
*ClassData = BattClass;
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ CmBattGetAcpiInterfaces(IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
/* Build the query */
|
/* Build the query */
|
||||||
IoStackLocation = IoGetNextIrpStackLocation(Irp);
|
IoStackLocation = IoGetNextIrpStackLocation(Irp);
|
||||||
|
IoStackLocation->MajorFunction = IRP_MJ_PNP;
|
||||||
IoStackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE;
|
IoStackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE;
|
||||||
IoStackLocation->Parameters.QueryInterface.InterfaceType = &GUID_ACPI_INTERFACE_STANDARD;
|
IoStackLocation->Parameters.QueryInterface.InterfaceType = &GUID_ACPI_INTERFACE_STANDARD;
|
||||||
IoStackLocation->Parameters.QueryInterface.Size = sizeof(ACPI_INTERFACE_STANDARD);
|
IoStackLocation->Parameters.QueryInterface.Size = sizeof(ACPI_INTERFACE_STANDARD);
|
||||||
|
@ -102,7 +103,6 @@ CmBattGetAcpiInterfaces(IN PDEVICE_OBJECT DeviceObject,
|
||||||
KeInitializeEvent(&Event, SynchronizationEvent, 0);
|
KeInitializeEvent(&Event, SynchronizationEvent, 0);
|
||||||
|
|
||||||
/* Set the completion routine */
|
/* Set the completion routine */
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
|
||||||
IoSetCompletionRoutine(Irp,
|
IoSetCompletionRoutine(Irp,
|
||||||
(PVOID)CmBattIoCompletion,
|
(PVOID)CmBattIoCompletion,
|
||||||
&Event,
|
&Event,
|
||||||
|
@ -276,7 +276,7 @@ CmBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject,
|
||||||
Status = STATUS_NOT_SUPPORTED;
|
Status = STATUS_NOT_SUPPORTED;
|
||||||
|
|
||||||
/* Try to acquire the lock before doing anything */
|
/* Try to acquire the lock before doing anything */
|
||||||
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0);
|
Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, Irp);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Complete the request */
|
/* Complete the request */
|
||||||
|
@ -604,7 +604,7 @@ CmBattCreateFdo(IN PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
/* Setup the rest of the extension */
|
/* Setup the rest of the extension */
|
||||||
ExInitializeFastMutex(&FdoExtension->FastMutex);
|
ExInitializeFastMutex(&FdoExtension->FastMutex);
|
||||||
IoInitializeRemoveLock(&FdoExtension->RemoveLock, 0, 0, 0);
|
IoInitializeRemoveLock(&FdoExtension->RemoveLock, 'RbmC', 0, 0);
|
||||||
FdoExtension->HandleCount = 0;
|
FdoExtension->HandleCount = 0;
|
||||||
FdoExtension->WaitWakeEnable = FALSE;
|
FdoExtension->WaitWakeEnable = FALSE;
|
||||||
FdoExtension->DeviceId = UniqueId;
|
FdoExtension->DeviceId = UniqueId;
|
||||||
|
@ -630,7 +630,7 @@ CmBattCreateFdo(IN PDRIVER_OBJECT DriverObject,
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Set value */
|
/* Set value */
|
||||||
FdoExtension->WaitWakeEnable = *(PULONG)PartialInfo->Data;
|
FdoExtension->WaitWakeEnable = ((*(PULONG)PartialInfo->Data) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the handle */
|
/* Close the handle */
|
||||||
|
|
|
@ -343,7 +343,7 @@ CompBattAddDevice(IN PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
/* Initialize the device extension */
|
/* Initialize the device extension */
|
||||||
DeviceExtension = DeviceObject->DeviceExtension;
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
RtlZeroMemory(DeviceExtension, 0x1B0u);
|
RtlZeroMemory(DeviceExtension, sizeof(COMPBATT_DEVICE_EXTENSION));
|
||||||
|
|
||||||
/* Attach to device stack and set DO pointers */
|
/* Attach to device stack and set DO pointers */
|
||||||
DeviceExtension->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
DeviceExtension->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||||
|
|
|
@ -353,6 +353,63 @@ PciIdeXPdoQueryDeviceRelations(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GUID_PCIIDE_INTERRUPT_INTERFACE
|
||||||
|
//GUID_PCIIDE_REQUEST_PROPER_RESOURCES
|
||||||
|
|
||||||
|
DEFINE_GUID(GUID_PCIIDE_SYNC_ACCESS_INTERFACE, 0x681190EB, 0xE4EA, 0x11D0, 0xAB, 0x82, 0x00, 0xA0, 0xC9, 0x06, 0x96, 0x2F);
|
||||||
|
DEFINE_GUID(GUID_PCIIDE_XFER_MODE_INTERFACE, 0x681190EC, 0xE4EA, 0x11D0, 0xAB, 0x82, 0x00, 0xA0, 0xC9, 0x06, 0x96, 0x2F);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
PciIdeXPdoPnpQueryInterface(
|
||||||
|
PIRP Irp)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
PACPI_INTERFACE_STANDARD AcpiInterface;
|
||||||
|
|
||||||
|
if (IrpStack->Parameters.QueryInterface.Version != 1)
|
||||||
|
{
|
||||||
|
DPRINT1("Invalid version number: %d\n",
|
||||||
|
IrpStack->Parameters.QueryInterface.Version);
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsEqualGUID(IrpStack->Parameters.QueryInterface.InterfaceType,
|
||||||
|
&GUID_PCIIDE_XFER_MODE_INTERFACE))
|
||||||
|
{
|
||||||
|
DPRINT1("GUID_PCIIDE_XFER_MODE_INTERFACE\n");
|
||||||
|
|
||||||
|
if (IrpStack->Parameters.QueryInterface.Size < sizeof(ACPI_INTERFACE_STANDARD))
|
||||||
|
{
|
||||||
|
DPRINT1("Buffer too small! (%d)\n", IrpStack->Parameters.QueryInterface.Size);
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AcpiInterface = (PACPI_INTERFACE_STANDARD)IrpStack->Parameters.QueryInterface.Interface;
|
||||||
|
|
||||||
|
AcpiInterface->InterfaceReference = AcpiInterfaceReference;
|
||||||
|
AcpiInterface->InterfaceDereference = AcpiInterfaceDereference;
|
||||||
|
AcpiInterface->GpeConnectVector = AcpiInterfaceConnectVector;
|
||||||
|
AcpiInterface->GpeDisconnectVector = AcpiInterfaceDisconnectVector;
|
||||||
|
AcpiInterface->GpeEnableEvent = AcpiInterfaceEnableEvent;
|
||||||
|
AcpiInterface->GpeDisableEvent = AcpiInterfaceDisableEvent;
|
||||||
|
AcpiInterface->GpeClearStatus = AcpiInterfaceClearStatus;
|
||||||
|
AcpiInterface->RegisterForDeviceNotifications = AcpiInterfaceNotificationsRegister;
|
||||||
|
AcpiInterface->UnregisterForDeviceNotifications = AcpiInterfaceNotificationsUnregister;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("Invalid GUID\n");
|
||||||
|
return STATUS_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
PciIdeXPdoPnpDispatch(
|
PciIdeXPdoPnpDispatch(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
@ -518,6 +575,11 @@ PciIdeXPdoPnpDispatch(
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case IRP_MN_QUERY_INTERFACE:
|
||||||
|
{
|
||||||
|
Status = PciIdeXPdoPnpQueryInterface(Irp);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue