diff --git a/reactos/drivers/bus/serenum/detect.c b/reactos/drivers/bus/serenum/detect.c index 655f48b51be..252e106bf47 100644 --- a/reactos/drivers/bus/serenum/detect.c +++ b/reactos/drivers/bus/serenum/detect.c @@ -60,44 +60,6 @@ DeviceIoControl( return Status; } -static NTSTATUS -SendIrp( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG MajorFunction) -{ - KEVENT Event; - PIRP Irp; - IO_STATUS_BLOCK IoStatus; - NTSTATUS Status; - - KeInitializeEvent(&Event, NotificationEvent, FALSE); - - Irp = IoBuildSynchronousFsdRequest( - MajorFunction, - DeviceObject, - NULL, - 0, - NULL, - &Event, - &IoStatus); - if (Irp == NULL) - { - DPRINT("IoBuildSynchronousFsdRequest() failed\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - Status = IoCallDriver(DeviceObject, Irp); - - if (Status == STATUS_PENDING) - { - DPRINT("Operation pending\n"); - KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); - Status = IoStatus.Status; - } - - return Status; -} - static NTSTATUS ReadBytes( IN PDEVICE_OBJECT LowerDevice, @@ -256,6 +218,7 @@ SerenumDetectPnpDevice( IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle = NULL; UCHAR Buffer[256]; ULONG BaudRate; ULONG_PTR TotalBytesReceived = 0; @@ -270,7 +233,14 @@ SerenumDetectPnpDevice( NTSTATUS Status; /* Open port */ - Status = SendIrp(LowerDevice, IRP_MJ_CREATE); + Status = ObOpenObjectByPointer( + LowerDevice, + OBJ_KERNEL_HANDLE, + NULL, + 0, + NULL, + KernelMode, + &Handle); if (!NT_SUCCESS(Status)) goto ByeBye; /* 1. COM port initialization, check for device enumerate */ @@ -459,8 +429,8 @@ DisconnectIdle: ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return Status; } @@ -469,6 +439,7 @@ SerenumDetectLegacyDevice( IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle = NULL; ULONG Fcr, Mcr; ULONG BaudRate; ULONG Command; @@ -490,7 +461,14 @@ SerenumDetectLegacyDevice( RtlZeroMemory(Buffer, sizeof(Buffer)); /* Open port */ - Status = SendIrp(LowerDevice, IRP_MJ_CREATE); + Status = ObOpenObjectByPointer( + LowerDevice, + OBJ_EXCLUSIVE | OBJ_KERNEL_HANDLE, + NULL, + 0, + NULL, + KernelMode, + &Handle); if (!NT_SUCCESS(Status)) return Status; /* Reset UART */ @@ -610,7 +588,7 @@ SerenumDetectLegacyDevice( ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return Status; } diff --git a/reactos/drivers/input/sermouse/detect.c b/reactos/drivers/input/sermouse/detect.c index 59ade5a3c63..f8cc24c5d15 100644 --- a/reactos/drivers/input/sermouse/detect.c +++ b/reactos/drivers/input/sermouse/detect.c @@ -63,44 +63,6 @@ DeviceIoControl( return Status; } -static NTSTATUS -SendIrp( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG MajorFunction) -{ - KEVENT Event; - PIRP Irp; - IO_STATUS_BLOCK IoStatus; - NTSTATUS Status; - - KeInitializeEvent(&Event, NotificationEvent, FALSE); - - Irp = IoBuildSynchronousFsdRequest( - MajorFunction, - DeviceObject, - NULL, - 0, - NULL, - &Event, - &IoStatus); - if (Irp == NULL) - { - DPRINT("IoBuildSynchronousFsdRequest() failed\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - Status = IoCallDriver(DeviceObject, Irp); - - if (Status == STATUS_PENDING) - { - DPRINT("Operation pending\n"); - KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); - Status = IoStatus.Status; - } - - return Status; -} - static NTSTATUS ReadBytes( IN PDEVICE_OBJECT LowerDevice, @@ -155,6 +117,7 @@ SERMOUSE_MOUSE_TYPE SermouseDetectLegacyDevice( IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle; ULONG Fcr, Mcr; ULONG BaudRate; ULONG Command; @@ -170,7 +133,14 @@ SermouseDetectLegacyDevice( RtlZeroMemory(Buffer, sizeof(Buffer)); /* Open port */ - Status = SendIrp(LowerDevice, IRP_MJ_CREATE); + Status = ObOpenObjectByPointer( + LowerDevice, + OBJ_EXCLUSIVE | OBJ_KERNEL_HANDLE, + NULL, + 0, + NULL, + KernelMode, + &Handle); if (!NT_SUCCESS(Status)) return mtNone; /* Reset UART */ @@ -268,7 +238,7 @@ SermouseDetectLegacyDevice( ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return MouseType; }