DriverExtension = IoGetDriverObjectExtension(DriverObject, DriverObject);
- Status = IoCreateDevice(DriverObject,
+ Status = IoCreateDevice(
+ DriverObject,
sizeof(GREEN_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_TERMSRV,
RtlZeroMemory(DeviceExtension, sizeof(GREEN_DEVICE_EXTENSION));
DeviceExtension->Common.Type = GreenFDO;
DriverExtension->GreenMainDO->Flags |= DO_POWER_PAGABLE;
- IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
+ DriverExtension->LowerDevice = IoAttachDeviceToDeviceStack(DriverExtension->GreenMainDO, GreenPdo);
/* Initialize serial port */
InitializeObjectAttributes(&ObjectAttributes, &DriverExtension->AttachedDeviceName, OBJ_KERNEL_HANDLE, NULL, NULL);
{
if (DeviceExtension && DeviceExtension->Serial)
ObDereferenceObject(DeviceExtension->Serial);
- if (DriverExtension && DriverExtension->GreenMainDO)
+ if (DriverExtension)
{
- IoDeleteDevice(DriverExtension->GreenMainDO);
- DriverExtension->GreenMainDO = NULL;
+ if (DriverExtension->LowerDevice)
+ {
+ IoDetachDevice(DriverExtension->LowerDevice);
+ DriverExtension->LowerDevice = NULL;
+ }
+ if (DriverExtension->GreenMainDO)
+ {
+ IoDeleteDevice(DriverExtension->GreenMainDO);
+ DriverExtension->GreenMainDO = NULL;
+ }
}
}
return Status;
DeviceExtension = (PGREEN_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* Create PDOs for keyboard and screen */
- Status = IoCreateDevice(
- DeviceObject->DriverObject,
- sizeof(COMMON_DEVICE_EXTENSION),
- NULL,
- FILE_DEVICE_KEYBOARD,
- FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
- FALSE,
- &DeviceExtension->KeyboardPdo);
- if (!NT_SUCCESS(Status))
+ if (DeviceExtension->KeyboardPdo == NULL)
{
- DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
- goto cleanup;
+ Status = IoCreateDevice(
+ DeviceObject->DriverObject,
+ sizeof(COMMON_DEVICE_EXTENSION),
+ NULL,
+ FILE_DEVICE_KEYBOARD,
+ FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
+ FALSE,
+ &DeviceExtension->KeyboardPdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
+ goto cleanup;
+ }
+ ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
+ DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
+ DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
}
- ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->KeyboardPdo->DeviceExtension)->Type = KeyboardPDO;
- DeviceExtension->KeyboardPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
- DeviceExtension->KeyboardPdo->Flags &= ~DO_DEVICE_INITIALIZING;
- Status = IoCreateDevice(
- DeviceObject->DriverObject,
- sizeof(COMMON_DEVICE_EXTENSION),
- NULL,
- FILE_DEVICE_SCREEN,
- FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
- FALSE,
- &DeviceExtension->ScreenPdo);
- if (!NT_SUCCESS(Status))
+ if (DeviceExtension->ScreenPdo == NULL)
{
- DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
- goto cleanup;
+ Status = IoCreateDevice(
+ DeviceObject->DriverObject,
+ sizeof(COMMON_DEVICE_EXTENSION),
+ NULL,
+ FILE_DEVICE_SCREEN,
+ FILE_AUTOGENERATED_DEVICE_NAME | FILE_DEVICE_SECURE_OPEN,
+ FALSE,
+ &DeviceExtension->ScreenPdo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT("IoCreateDevice() failed with status 0x%lx\n", Status);
+ goto cleanup;
+ }
+ ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
+ DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
+ DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
}
- ((PCOMMON_DEVICE_EXTENSION)DeviceExtension->ScreenPdo->DeviceExtension)->Type = ScreenPDO;
- DeviceExtension->ScreenPdo->Flags |= DO_POWER_PAGABLE | DO_BUS_ENUMERATED_DEVICE;
- DeviceExtension->ScreenPdo->Flags &= ~DO_DEVICE_INITIALIZING;
/* Allocate return structure */
DeviceRelations = (PDEVICE_RELATIONS)ExAllocatePool(