mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[USB-BRINGUP-TRUNK]
- Open a file handle to the port driver like Windows does - USB mice are working now svn path=/branches/usb-bringup-trunk/; revision=55041
This commit is contained in:
parent
48c2e17262
commit
8fdcfb28ce
4 changed files with 136 additions and 0 deletions
|
@ -824,6 +824,72 @@ HandleReadIrp(
|
|||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
ClassPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
NTSTATUS Status;
|
||||
|
||||
switch (IrpSp->MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE:
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&DeviceExtension->InterfaceName,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = ZwOpenFile(&DeviceExtension->FileHandle,
|
||||
FILE_READ_DATA,
|
||||
&ObjectAttributes,
|
||||
&Iosb,
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
}
|
||||
else
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
case IRP_MN_STOP_DEVICE:
|
||||
if (DeviceExtension->FileHandle)
|
||||
{
|
||||
ZwClose(DeviceExtension->FileHandle);
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = Irp->IoStatus.Status;
|
||||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->LowerDevice, Irp);
|
||||
}
|
||||
else
|
||||
{
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
ClassStartIo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -1021,6 +1087,7 @@ DriverEntry(
|
|||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
|
||||
DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
||||
DriverObject->DriverStartIo = ClassStartIo;
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef struct _PORT_DEVICE_EXTENSION
|
|||
PORT_DEVICE_STATE PnpState;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
PDEVICE_OBJECT ClassDO;
|
||||
HANDLE FileHandle;
|
||||
UNICODE_STRING InterfaceName;
|
||||
} PORT_DEVICE_EXTENSION, *PPORT_DEVICE_EXTENSION;
|
||||
|
||||
|
|
|
@ -800,6 +800,72 @@ HandleReadIrp(
|
|||
return Status;
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
ClassPnp(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
PPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
NTSTATUS Status;
|
||||
|
||||
switch (IrpSp->MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE:
|
||||
Status = ForwardIrpAndWait(DeviceObject, Irp);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&DeviceExtension->InterfaceName,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = ZwOpenFile(&DeviceExtension->FileHandle,
|
||||
FILE_READ_DATA,
|
||||
&ObjectAttributes,
|
||||
&Iosb,
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
}
|
||||
else
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
case IRP_MN_STOP_DEVICE:
|
||||
if (DeviceExtension->FileHandle)
|
||||
{
|
||||
ZwClose(DeviceExtension->FileHandle);
|
||||
DeviceExtension->FileHandle = NULL;
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
Status = Irp->IoStatus.Status;
|
||||
break;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
IoSkipCurrentIrpStackLocation(Irp);
|
||||
return IoCallDriver(DeviceExtension->LowerDevice, Irp);
|
||||
}
|
||||
else
|
||||
{
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
ClassStartIo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -993,6 +1059,7 @@ DriverEntry(
|
|||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = ClassClose;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = ClassCleanup;
|
||||
DriverObject->MajorFunction[IRP_MJ_READ] = ClassRead;
|
||||
DriverObject->MajorFunction[IRP_MJ_PNP] = ClassPnp;
|
||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ClassDeviceControl;
|
||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = ForwardIrpAndForget;
|
||||
DriverObject->DriverStartIo = ClassStartIo;
|
||||
|
|
|
@ -48,6 +48,7 @@ typedef struct _PORT_DEVICE_EXTENSION
|
|||
PORT_DEVICE_STATE PnpState;
|
||||
PDEVICE_OBJECT LowerDevice;
|
||||
PDEVICE_OBJECT ClassDO;
|
||||
HANDLE FileHandle;
|
||||
UNICODE_STRING InterfaceName;
|
||||
} PORT_DEVICE_EXTENSION, *PPORT_DEVICE_EXTENSION;
|
||||
|
||||
|
|
Loading…
Reference in a new issue