PDEVICE_EXTENSION DevExt;
PFDO_DEVICE_EXTENSION FdoDevExt;
PDEVICE_OBJECT Fdo;
- static BOOLEAN AlreadyAdded = FALSE;
DPRINT("I8042AddDevice\n");
- /* HACK! */
- if (AlreadyAdded)
+ if (Pdo != NULL)
+ {
+ /* Device detected by pnpmgr. Ignore it, as we already have
+ * detected the keyboard and mouse at first call */
return STATUS_UNSUCCESSFUL;
- AlreadyAdded = TRUE;
+ }
Status = IoCreateDevice(DriverObject,
sizeof(DEVICE_EXTENSION),
if (!NT_SUCCESS(Status))
return Status;
- IoAttachDeviceToDeviceStack(Fdo, Pdo);
-
DevExt = Fdo->DeviceExtension;
RtlZeroMemory(DevExt, sizeof(DEVICE_EXTENSION));
{
PDEVICE_OBJECT Fdo;
NTSTATUS Status;
+ BOOLEAN IsPnpDriver = FALSE;
if (DriverObject->DriverExtension->AddDevice)
{
DPRINT("Calling driver AddDevice entrypoint at %08lx\n",
DriverObject->DriverExtension->AddDevice);
+ IsPnpDriver = !IopDeviceNodeHasFlag(DeviceNode, DNF_LEGACY_DRIVER);
Status = DriverObject->DriverExtension->AddDevice(
- DriverObject, DeviceNode->PhysicalDeviceObject);
+ DriverObject, IsPnpDriver ? DeviceNode->PhysicalDeviceObject : NULL);
if (!NT_SUCCESS(Status))
{
return Status;
}
- Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject);
-
- if (Fdo == DeviceNode->PhysicalDeviceObject)
+ if (IsPnpDriver)
{
- /* FIXME: What do we do? Unload the driver or just disable the device? */
- DbgPrint("An FDO was not attached\n");
- IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
- return STATUS_UNSUCCESSFUL;
- }
+ Fdo = IoGetAttachedDeviceReference(DeviceNode->PhysicalDeviceObject);
- IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
-
- if (Fdo->DeviceType == FILE_DEVICE_ACPI)
- {
- static BOOLEAN SystemPowerDeviceNodeCreated = FALSE;
+ if (Fdo == DeviceNode->PhysicalDeviceObject)
+ {
+ /* FIXME: What do we do? Unload the driver or just disable the device? */
+ DbgPrint("An FDO was not attached\n");
+ IopDeviceNodeSetFlag(DeviceNode, DNF_DISABLED);
+ return STATUS_UNSUCCESSFUL;
+ }
- /* There can be only one system power device */
- if (!SystemPowerDeviceNodeCreated)
+ if (Fdo->DeviceType == FILE_DEVICE_ACPI)
{
- PopSystemPowerDeviceNode = DeviceNode;
- SystemPowerDeviceNodeCreated = TRUE;
+ static BOOLEAN SystemPowerDeviceNodeCreated = FALSE;
+
+ /* There can be only one system power device */
+ if (!SystemPowerDeviceNodeCreated)
+ {
+ PopSystemPowerDeviceNode = DeviceNode;
+ SystemPowerDeviceNodeCreated = TRUE;
+ }
}
+
+ ObDereferenceObject(Fdo);
}
- ObDereferenceObject(Fdo);
+ IopDeviceNodeSetFlag(DeviceNode, DNF_ADDED);
}
return STATUS_SUCCESS;
if (!NT_SUCCESS(Status))
{
- DPRINT1("Cannot insert Device Object into Handle Table\n");
+ DPRINT1("Cannot insert Device Object into Handle Table (status 0x%08lx)\n", Status);
*DeviceObject = NULL;
return Status;
}