mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[KBDHID][MOUHID]
- Properly stub DispatchPower - Implement DispatchSystemControl svn path=/trunk/; revision=58992
This commit is contained in:
parent
309a347ed1
commit
22de130758
2 changed files with 226 additions and 190 deletions
|
@ -50,7 +50,7 @@ KbdHid_InsertScanCodes(
|
||||||
/* get device extension */
|
/* get device extension */
|
||||||
DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context;
|
DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context;
|
||||||
|
|
||||||
for (Index = 0; Index < Length; Index++)
|
for(Index = 0; Index < Length; Index++)
|
||||||
{
|
{
|
||||||
DPRINT("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index, NewScanCodes[Index] & 0xFF);
|
DPRINT("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index, NewScanCodes[Index] & 0xFF);
|
||||||
|
|
||||||
|
@ -368,59 +368,59 @@ KbdHid_InternalDeviceControl(
|
||||||
switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
|
switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
|
||||||
{
|
{
|
||||||
case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
|
case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
|
||||||
/* verify output buffer length */
|
/* verify output buffer length */
|
||||||
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUSE_ATTRIBUTES))
|
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUSE_ATTRIBUTES))
|
||||||
{
|
{
|
||||||
/* invalid request */
|
/* invalid request */
|
||||||
DPRINT1("[MOUHID] IOCTL_MOUSE_QUERY_ATTRIBUTES Buffer too small\n");
|
DPRINT1("[MOUHID] IOCTL_MOUSE_QUERY_ATTRIBUTES Buffer too small\n");
|
||||||
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
|
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
Attributes = (PKEYBOARD_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer;
|
Attributes = (PKEYBOARD_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer;
|
||||||
|
|
||||||
/* copy attributes */
|
/* copy attributes */
|
||||||
RtlCopyMemory(Attributes,
|
RtlCopyMemory(Attributes,
|
||||||
&DeviceExtension->Attributes,
|
&DeviceExtension->Attributes,
|
||||||
sizeof(KEYBOARD_ATTRIBUTES));
|
sizeof(KEYBOARD_ATTRIBUTES));
|
||||||
|
|
||||||
/* complete request */
|
/* complete request */
|
||||||
Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
|
Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
case IOCTL_INTERNAL_KEYBOARD_CONNECT:
|
case IOCTL_INTERNAL_KEYBOARD_CONNECT:
|
||||||
/* verify input buffer length */
|
/* verify input buffer length */
|
||||||
if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
|
if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(CONNECT_DATA))
|
||||||
{
|
{
|
||||||
/* invalid request */
|
/* invalid request */
|
||||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* is it already connected */
|
|
||||||
if (DeviceExtension->ClassService)
|
|
||||||
{
|
|
||||||
/* already connected */
|
|
||||||
Irp->IoStatus.Status = STATUS_SHARING_VIOLATION;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return STATUS_SHARING_VIOLATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get connect data */
|
|
||||||
Data = (PCONNECT_DATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
|
|
||||||
|
|
||||||
/* store connect details */
|
|
||||||
DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject;
|
|
||||||
DeviceExtension->ClassService = Data->ClassService;
|
|
||||||
|
|
||||||
/* completed successfully */
|
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* is it already connected */
|
||||||
|
if (DeviceExtension->ClassService)
|
||||||
|
{
|
||||||
|
/* already connected */
|
||||||
|
Irp->IoStatus.Status = STATUS_SHARING_VIOLATION;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
return STATUS_SHARING_VIOLATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get connect data */
|
||||||
|
Data = (PCONNECT_DATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
|
||||||
|
|
||||||
|
/* store connect details */
|
||||||
|
DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject;
|
||||||
|
DeviceExtension->ClassService = Data->ClassService;
|
||||||
|
|
||||||
|
/* completed successfully */
|
||||||
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
case IOCTL_INTERNAL_KEYBOARD_DISCONNECT:
|
case IOCTL_INTERNAL_KEYBOARD_DISCONNECT:
|
||||||
|
@ -444,11 +444,11 @@ KbdHid_InternalDeviceControl(
|
||||||
case IOCTL_KEYBOARD_QUERY_INDICATORS:
|
case IOCTL_KEYBOARD_QUERY_INDICATORS:
|
||||||
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS))
|
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(KEYBOARD_INDICATOR_PARAMETERS))
|
||||||
{
|
{
|
||||||
/* invalid parameter */
|
/* invalid parameter */
|
||||||
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy indicators */
|
/* copy indicators */
|
||||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||||
|
@ -477,8 +477,8 @@ KbdHid_InternalDeviceControl(
|
||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS);
|
Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS);
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
case IOCTL_KEYBOARD_SET_INDICATORS:
|
case IOCTL_KEYBOARD_SET_INDICATORS:
|
||||||
|
@ -523,10 +523,10 @@ KbdHid_InternalDeviceControl(
|
||||||
|
|
||||||
case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
|
case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not implemented\n");
|
DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not implemented\n");
|
||||||
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unknown control code */
|
/* unknown control code */
|
||||||
|
@ -561,8 +561,25 @@ KbdHid_Power(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
PKBDHID_DEVICE_EXTENSION DeviceExtension;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
PoStartNextPowerIrp(Irp);
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
KbdHid_SystemControl(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp)
|
||||||
|
{
|
||||||
|
PKBDHID_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -800,84 +817,84 @@ KbdHid_Pnp(
|
||||||
|
|
||||||
switch (IoStack->MinorFunction)
|
switch (IoStack->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_STOP_DEVICE:
|
case IRP_MN_STOP_DEVICE:
|
||||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||||
case IRP_MN_QUERY_STOP_DEVICE:
|
case IRP_MN_QUERY_STOP_DEVICE:
|
||||||
case IRP_MN_CANCEL_STOP_DEVICE:
|
case IRP_MN_CANCEL_STOP_DEVICE:
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
/* indicate success */
|
/* indicate success */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
/* skip irp stack location */
|
/* skip irp stack location */
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* dispatch to lower device */
|
||||||
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
|
||||||
case IRP_MN_REMOVE_DEVICE:
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
/* FIXME synchronization */
|
/* FIXME synchronization */
|
||||||
|
|
||||||
/* cancel irp */
|
/* cancel irp */
|
||||||
IoCancelIrp(DeviceExtension->Irp);
|
IoCancelIrp(DeviceExtension->Irp);
|
||||||
|
|
||||||
/* indicate success */
|
/* indicate success */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
/* skip irp stack location */
|
/* skip irp stack location */
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* dispatch to lower device */
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
|
||||||
IoFreeIrp(DeviceExtension->Irp);
|
IoFreeIrp(DeviceExtension->Irp);
|
||||||
IoDetachDevice(DeviceExtension->NextDeviceObject);
|
IoDetachDevice(DeviceExtension->NextDeviceObject);
|
||||||
IoDeleteDevice(DeviceObject);
|
IoDeleteDevice(DeviceObject);
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
/* init event */
|
/* init event */
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
/* copy stack location */
|
/* copy stack location */
|
||||||
IoCopyCurrentIrpStackLocationToNext (Irp);
|
IoCopyCurrentIrpStackLocationToNext (Irp);
|
||||||
|
|
||||||
/* set completion routine */
|
/* set completion routine */
|
||||||
IoSetCompletionRoutine(Irp, KbdHid_StartDeviceCompletion, &Event, TRUE, TRUE, TRUE);
|
IoSetCompletionRoutine(Irp, KbdHid_StartDeviceCompletion, &Event, TRUE, TRUE, TRUE);
|
||||||
Irp->IoStatus.Status = 0;
|
Irp->IoStatus.Status = 0;
|
||||||
|
|
||||||
/* pass request */
|
/* pass request */
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* failed */
|
/* failed */
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lets start the device */
|
|
||||||
Status = KbdHid_StartDevice(DeviceObject);
|
|
||||||
DPRINT("KbdHid_StartDevice %x\n", Status);
|
|
||||||
|
|
||||||
/* complete request */
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
/* done */
|
|
||||||
return Status;
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
/* lets start the device */
|
||||||
/* skip irp stack location */
|
Status = KbdHid_StartDevice(DeviceObject);
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
DPRINT("KbdHid_StartDevice %x\n", Status);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* complete request */
|
||||||
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Irp->IoStatus.Status = Status;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
/* done */
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* skip irp stack location */
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
/* dispatch to lower device */
|
||||||
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,6 +997,7 @@ DriverEntry(
|
||||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = KbdHid_InternalDeviceControl;
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = KbdHid_InternalDeviceControl;
|
||||||
DriverObject->MajorFunction[IRP_MJ_POWER] = KbdHid_Power;
|
DriverObject->MajorFunction[IRP_MJ_POWER] = KbdHid_Power;
|
||||||
DriverObject->MajorFunction[IRP_MJ_PNP] = KbdHid_Pnp;
|
DriverObject->MajorFunction[IRP_MJ_PNP] = KbdHid_Pnp;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = KbdHid_SystemControl;
|
||||||
DriverObject->DriverUnload = KbdHid_Unload;
|
DriverObject->DriverUnload = KbdHid_Unload;
|
||||||
DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice;
|
DriverObject->DriverExtension->AddDevice = KbdHid_AddDevice;
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ MouHid_GetButtonFlags(
|
||||||
|
|
||||||
/* move to next index*/
|
/* move to next index*/
|
||||||
Index++;
|
Index++;
|
||||||
} while (Index < DeviceExtension->UsageListLength);
|
}while(Index < DeviceExtension->UsageListLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeviceExtension->UsageListLength)
|
if (DeviceExtension->UsageListLength)
|
||||||
|
@ -200,7 +200,7 @@ MouHid_GetButtonFlags(
|
||||||
|
|
||||||
/* move to next index*/
|
/* move to next index*/
|
||||||
Index++;
|
Index++;
|
||||||
} while (Index < DeviceExtension->UsageListLength);
|
}while(Index < DeviceExtension->UsageListLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now switch the previous list with current list */
|
/* now switch the previous list with current list */
|
||||||
|
@ -636,8 +636,25 @@ MouHid_Power(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED
|
PMOUHID_DEVICE_EXTENSION DeviceExtension;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
PoStartNextPowerIrp(Irp);
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return PoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
MouHid_SystemControl(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp)
|
||||||
|
{
|
||||||
|
PMOUHID_DEVICE_EXTENSION DeviceExtension;
|
||||||
|
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -843,7 +860,7 @@ MouHid_StartDevice(
|
||||||
&ValueCaps,
|
&ValueCaps,
|
||||||
&ValueCapsLength,
|
&ValueCapsLength,
|
||||||
PreparsedData);
|
PreparsedData);
|
||||||
if (Status == HIDP_STATUS_SUCCESS)
|
if (Status == HIDP_STATUS_SUCCESS )
|
||||||
{
|
{
|
||||||
/* mouse has wheel support */
|
/* mouse has wheel support */
|
||||||
DeviceExtension->MouseIdentifier = WHEELMOUSE_HID_HARDWARE;
|
DeviceExtension->MouseIdentifier = WHEELMOUSE_HID_HARDWARE;
|
||||||
|
@ -931,97 +948,97 @@ MouHid_Pnp(
|
||||||
|
|
||||||
switch (IoStack->MinorFunction)
|
switch (IoStack->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_STOP_DEVICE:
|
case IRP_MN_STOP_DEVICE:
|
||||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||||
case IRP_MN_QUERY_STOP_DEVICE:
|
case IRP_MN_QUERY_STOP_DEVICE:
|
||||||
case IRP_MN_CANCEL_STOP_DEVICE:
|
case IRP_MN_CANCEL_STOP_DEVICE:
|
||||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||||
/* indicate success */
|
/* indicate success */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
/* skip irp stack location */
|
/* skip irp stack location */
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* dispatch to lower device */
|
||||||
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
|
||||||
case IRP_MN_REMOVE_DEVICE:
|
case IRP_MN_REMOVE_DEVICE:
|
||||||
/* FIXME synchronization */
|
/* FIXME synchronization */
|
||||||
|
|
||||||
/* request stop */
|
/* request stop */
|
||||||
DeviceExtension->StopReadReport = TRUE;
|
DeviceExtension->StopReadReport = TRUE;
|
||||||
|
|
||||||
/* cancel irp */
|
/* cancel irp */
|
||||||
IoCancelIrp(DeviceExtension->Irp);
|
IoCancelIrp(DeviceExtension->Irp);
|
||||||
|
|
||||||
/* indicate success */
|
/* indicate success */
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
/* skip irp stack location */
|
/* skip irp stack location */
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* dispatch to lower device */
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
|
|
||||||
/* wait for completion of stop event */
|
/* wait for completion of stop event */
|
||||||
KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent, Executive, KernelMode, FALSE, NULL);
|
||||||
|
|
||||||
/* free irp */
|
/* free irp */
|
||||||
IoFreeIrp(DeviceExtension->Irp);
|
IoFreeIrp(DeviceExtension->Irp);
|
||||||
|
|
||||||
/* detach device */
|
/* detach device */
|
||||||
IoDetachDevice(DeviceExtension->NextDeviceObject);
|
IoDetachDevice(DeviceExtension->NextDeviceObject);
|
||||||
|
|
||||||
/* delete device */
|
/* delete device */
|
||||||
IoDeleteDevice(DeviceObject);
|
IoDeleteDevice(DeviceObject);
|
||||||
|
|
||||||
/* done */
|
/* done */
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
/* init event */
|
/* init event */
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
/* copy stack location */
|
/* copy stack location */
|
||||||
IoCopyCurrentIrpStackLocationToNext (Irp);
|
IoCopyCurrentIrpStackLocationToNext (Irp);
|
||||||
|
|
||||||
/* set completion routine */
|
/* set completion routine */
|
||||||
IoSetCompletionRoutine(Irp, MouHid_StartDeviceCompletion, &Event, TRUE, TRUE, TRUE);
|
IoSetCompletionRoutine(Irp, MouHid_StartDeviceCompletion, &Event, TRUE, TRUE, TRUE);
|
||||||
Irp->IoStatus.Status = 0;
|
Irp->IoStatus.Status = 0;
|
||||||
|
|
||||||
/* pass request */
|
/* pass request */
|
||||||
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* failed */
|
/* failed */
|
||||||
Irp->IoStatus.Status = Status;
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* lets start the device */
|
|
||||||
Status = MouHid_StartDevice(DeviceObject);
|
|
||||||
DPRINT("MouHid_StartDevice %x\n", Status);
|
|
||||||
|
|
||||||
/* complete request */
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
/* done */
|
|
||||||
return Status;
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
/* lets start the device */
|
||||||
/* skip irp stack location */
|
Status = MouHid_StartDevice(DeviceObject);
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
DPRINT("MouHid_StartDevice %x\n", Status);
|
||||||
|
|
||||||
/* dispatch to lower device */
|
/* complete request */
|
||||||
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
Irp->IoStatus.Status = Status;
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
|
/* done */
|
||||||
|
return Status;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* skip irp stack location */
|
||||||
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
/* dispatch to lower device */
|
||||||
|
return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,6 +1133,7 @@ DriverEntry(
|
||||||
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = MouHid_InternalDeviceControl;
|
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = MouHid_InternalDeviceControl;
|
||||||
DriverObject->MajorFunction[IRP_MJ_POWER] = MouHid_Power;
|
DriverObject->MajorFunction[IRP_MJ_POWER] = MouHid_Power;
|
||||||
DriverObject->MajorFunction[IRP_MJ_PNP] = MouHid_Pnp;
|
DriverObject->MajorFunction[IRP_MJ_PNP] = MouHid_Pnp;
|
||||||
|
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = MouHid_SystemControl;
|
||||||
DriverObject->DriverUnload = MouHid_Unload;
|
DriverObject->DriverUnload = MouHid_Unload;
|
||||||
DriverObject->DriverExtension->AddDevice = MouHid_AddDevice;
|
DriverObject->DriverExtension->AddDevice = MouHid_AddDevice;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue