Author: hpoussin Date: Sat Jul 1 01:47:42 2006 New Revision: 22729
URL: http://svn.reactos.org/svn/reactos?rev=22729&view=rev Log: Use ObOpenObjectByPointer instead of creating ourselves the IRP_MJ_CREATE/CLEANUP/CLOSE IRPs
Modified: trunk/reactos/drivers/bus/serenum/detect.c trunk/reactos/drivers/input/sermouse/detect.c
Modified: trunk/reactos/drivers/bus/serenum/detect.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/serenum/detect.... ============================================================================== --- trunk/reactos/drivers/bus/serenum/detect.c (original) +++ trunk/reactos/drivers/bus/serenum/detect.c Sat Jul 1 01:47:42 2006 @@ -55,44 +55,6 @@ if (OutputBufferSize) { *OutputBufferSize = IoStatus.Information; - } - - 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; @@ -256,6 +218,7 @@ IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle = NULL; UCHAR Buffer[256]; ULONG BaudRate; ULONG_PTR TotalBytesReceived = 0; @@ -270,7 +233,14 @@ 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 @@
ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return Status; }
@@ -469,6 +439,7 @@ IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle = NULL; ULONG Fcr, Mcr; ULONG BaudRate; ULONG Command; @@ -490,7 +461,14 @@ 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 @@
ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return Status; }
Modified: trunk/reactos/drivers/input/sermouse/detect.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/input/sermouse/dete... ============================================================================== --- trunk/reactos/drivers/input/sermouse/detect.c (original) +++ trunk/reactos/drivers/input/sermouse/detect.c Sat Jul 1 01:47:42 2006 @@ -58,44 +58,6 @@ if (OutputBufferSize) { *OutputBufferSize = IoStatus.Information; - } - - 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; @@ -155,6 +117,7 @@ SermouseDetectLegacyDevice( IN PDEVICE_OBJECT LowerDevice) { + HANDLE Handle; ULONG Fcr, Mcr; ULONG BaudRate; ULONG Command; @@ -170,7 +133,14 @@ 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 @@
ByeBye: /* Close port */ - SendIrp(LowerDevice, IRP_MJ_CLOSE); - SendIrp(LowerDevice, IRP_MJ_CLEANUP); + if (Handle) + ZwClose(Handle); return MouseType; }