mirror of
https://github.com/reactos/reactos.git
synced 2025-06-13 14:08:30 +00:00
Do not expect a call to AddDevice with a NULL Pdo. Those are not guaranteed
svn path=/trunk/; revision=24323
This commit is contained in:
parent
3f47783c54
commit
b606a6771c
2 changed files with 39 additions and 27 deletions
|
@ -13,11 +13,6 @@
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
#include "kbdclass.h"
|
#include "kbdclass.h"
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
SearchForLegacyDrivers(
|
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PCLASS_DRIVER_EXTENSION DriverExtension);
|
|
||||||
|
|
||||||
static VOID NTAPI
|
static VOID NTAPI
|
||||||
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
|
@ -675,9 +670,8 @@ ClassAddDevice(
|
||||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
|
||||||
if (Pdo == NULL)
|
if (Pdo == NULL)
|
||||||
/* We're getting a NULL Pdo at the first call as we're a legacy driver.
|
/* We may get a NULL Pdo at the first call as we're a legacy driver. Ignore it */
|
||||||
* Use it to search for legacy port drivers. */
|
return STATUS_SUCCESS;
|
||||||
return SearchForLegacyDrivers(DriverObject, DriverExtension);
|
|
||||||
|
|
||||||
/* Create new device object */
|
/* Create new device object */
|
||||||
Status = IoCreateDevice(
|
Status = IoCreateDevice(
|
||||||
|
@ -808,12 +802,14 @@ ClassStartIo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static VOID NTAPI
|
||||||
SearchForLegacyDrivers(
|
SearchForLegacyDrivers(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PCLASS_DRIVER_EXTENSION DriverExtension)
|
IN PVOID Context, /* PCLASS_DRIVER_EXTENSION */
|
||||||
|
IN ULONG Count)
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceMapKeyU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP");
|
UNICODE_STRING DeviceMapKeyU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP");
|
||||||
|
PCLASS_DRIVER_EXTENSION DriverExtension;
|
||||||
UNICODE_STRING PortBaseName = {0, };
|
UNICODE_STRING PortBaseName = {0, };
|
||||||
PKEY_VALUE_BASIC_INFORMATION KeyValueInformation = NULL;
|
PKEY_VALUE_BASIC_INFORMATION KeyValueInformation = NULL;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
@ -823,6 +819,13 @@ SearchForLegacyDrivers(
|
||||||
ULONG Size, ResultLength;
|
ULONG Size, ResultLength;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("SearchForLegacyDrivers(%p %p %lu)\n",
|
||||||
|
DriverObject, Context, Count);
|
||||||
|
|
||||||
|
if (Count != 1)
|
||||||
|
return;
|
||||||
|
DriverExtension = (PCLASS_DRIVER_EXTENSION)Context;
|
||||||
|
|
||||||
/* Create port base name, by replacing Class by Port at the end of the class base name */
|
/* Create port base name, by replacing Class by Port at the end of the class base name */
|
||||||
Status = RtlDuplicateUnicodeString(
|
Status = RtlDuplicateUnicodeString(
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
|
@ -902,8 +905,6 @@ SearchForLegacyDrivers(
|
||||||
DPRINT("ClassAddDevice() failed with status 0x%08lx\n", Status);
|
DPRINT("ClassAddDevice() failed with status 0x%08lx\n", Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (KeyValueInformation != NULL)
|
if (KeyValueInformation != NULL)
|
||||||
|
@ -912,7 +913,6 @@ cleanup:
|
||||||
ZwClose(hDeviceMapKey);
|
ZwClose(hDeviceMapKey);
|
||||||
if (hPortKey != (HANDLE)-1)
|
if (hPortKey != (HANDLE)-1)
|
||||||
ZwClose(hPortKey);
|
ZwClose(hPortKey);
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -982,5 +982,11 @@ DriverEntry(
|
||||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
||||||
DriverObject->DriverStartIo = ClassStartIo;
|
DriverObject->DriverStartIo = ClassStartIo;
|
||||||
|
|
||||||
|
/* We will detect the legacy devices later */
|
||||||
|
IoRegisterDriverReinitialization(
|
||||||
|
DriverObject,
|
||||||
|
SearchForLegacyDrivers,
|
||||||
|
DriverExtension);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,6 @@
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
#include "mouclass.h"
|
#include "mouclass.h"
|
||||||
|
|
||||||
static NTSTATUS
|
|
||||||
SearchForLegacyDrivers(
|
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PCLASS_DRIVER_EXTENSION DriverExtension);
|
|
||||||
|
|
||||||
static VOID NTAPI
|
static VOID NTAPI
|
||||||
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
DriverUnload(IN PDRIVER_OBJECT DriverObject)
|
||||||
{
|
{
|
||||||
|
@ -651,9 +646,8 @@ ClassAddDevice(
|
||||||
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
|
||||||
|
|
||||||
if (Pdo == NULL)
|
if (Pdo == NULL)
|
||||||
/* We're getting a NULL Pdo at the first call as we're a legacy driver.
|
/* We may get a NULL Pdo at the first call as we're a legacy driver. Ignore it */
|
||||||
* Use it to search for legacy port drivers. */
|
return STATUS_SUCCESS;
|
||||||
return SearchForLegacyDrivers(DriverObject, DriverExtension);
|
|
||||||
|
|
||||||
/* Create new device object */
|
/* Create new device object */
|
||||||
Status = IoCreateDevice(
|
Status = IoCreateDevice(
|
||||||
|
@ -712,7 +706,7 @@ ClassAddDevice(
|
||||||
|
|
||||||
/* Register interface ; ignore the error (if any) as having
|
/* Register interface ; ignore the error (if any) as having
|
||||||
* a registred interface is not so important... */
|
* a registred interface is not so important... */
|
||||||
IoRegisterDeviceInterface(
|
Status = IoRegisterDeviceInterface(
|
||||||
Pdo,
|
Pdo,
|
||||||
&GUID_DEVINTERFACE_MOUSE,
|
&GUID_DEVINTERFACE_MOUSE,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -784,12 +778,14 @@ ClassStartIo(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static VOID NTAPI
|
||||||
SearchForLegacyDrivers(
|
SearchForLegacyDrivers(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PCLASS_DRIVER_EXTENSION DriverExtension)
|
IN PVOID Context, /* PCLASS_DRIVER_EXTENSION */
|
||||||
|
IN ULONG Count)
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceMapKeyU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP");
|
UNICODE_STRING DeviceMapKeyU = RTL_CONSTANT_STRING(L"\\REGISTRY\\MACHINE\\HARDWARE\\DEVICEMAP");
|
||||||
|
PCLASS_DRIVER_EXTENSION DriverExtension;
|
||||||
UNICODE_STRING PortBaseName = {0, };
|
UNICODE_STRING PortBaseName = {0, };
|
||||||
PKEY_VALUE_BASIC_INFORMATION KeyValueInformation = NULL;
|
PKEY_VALUE_BASIC_INFORMATION KeyValueInformation = NULL;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
@ -799,6 +795,13 @@ SearchForLegacyDrivers(
|
||||||
ULONG Size, ResultLength;
|
ULONG Size, ResultLength;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("SearchForLegacyDrivers(%p %p %lu)\n",
|
||||||
|
DriverObject, Context, Count);
|
||||||
|
|
||||||
|
if (Count != 1)
|
||||||
|
return;
|
||||||
|
DriverExtension = (PCLASS_DRIVER_EXTENSION)Context;
|
||||||
|
|
||||||
/* Create port base name, by replacing Class by Port at the end of the class base name */
|
/* Create port base name, by replacing Class by Port at the end of the class base name */
|
||||||
Status = RtlDuplicateUnicodeString(
|
Status = RtlDuplicateUnicodeString(
|
||||||
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE,
|
||||||
|
@ -878,8 +881,6 @@ SearchForLegacyDrivers(
|
||||||
DPRINT("ClassAddDevice() failed with status 0x%08lx\n", Status);
|
DPRINT("ClassAddDevice() failed with status 0x%08lx\n", Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Status == STATUS_NO_MORE_ENTRIES)
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (KeyValueInformation != NULL)
|
if (KeyValueInformation != NULL)
|
||||||
|
@ -888,7 +889,6 @@ cleanup:
|
||||||
ZwClose(hDeviceMapKey);
|
ZwClose(hDeviceMapKey);
|
||||||
if (hPortKey != (HANDLE)-1)
|
if (hPortKey != (HANDLE)-1)
|
||||||
ZwClose(hPortKey);
|
ZwClose(hPortKey);
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -958,5 +958,11 @@ DriverEntry(
|
||||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
||||||
DriverObject->DriverStartIo = ClassStartIo;
|
DriverObject->DriverStartIo = ClassStartIo;
|
||||||
|
|
||||||
|
/* We will detect the legacy devices later */
|
||||||
|
IoRegisterDriverReinitialization(
|
||||||
|
DriverObject,
|
||||||
|
SearchForLegacyDrivers,
|
||||||
|
DriverExtension);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue