?? dispatch.cpp
字號:
break;
default:
status = STATUS_INVALID_DEVICE_REQUEST;
}
// Complete IRP
return CompleteIrp(Irp,status,BytesTxd);
}
/////////////////////////////////////////////////////////////////////////////
// InternalControl:
//
// Description:
// Handle IRP_MJ_INTERNAL_DEVICE_CONTROL requests
// Return Value:
// This function returns STATUS_XXX
NTSTATUS InternalControl(IN PDEVICE_OBJECT fdo,IN PIRP Irp)
{
PDEVICE_EXTENSION dx = (PDEVICE_EXTENSION)fdo->DeviceExtension;
PIO_STACK_LOCATION irpStack;
irpStack = IoGetCurrentIrpStackLocation(Irp);
ULONG CtlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;
DbgPrint("internal = %x\n",CtlCode);
switch(CtlCode)
{
// Jason Yu
// Connect a mouse class device driver to the port driver.
//
case IOCTL_INTERNAL_MOUSE_CONNECT:
{
PCONNECT_DATA connectData;
//
// Only allow one connection.
//
//if (devExt->UpperConnectData.ClassService != NULL) {
// status = STATUS_SHARING_VIOLATION;
// break;
// }
// else
// if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
// sizeof(CONNECT_DATA)) {
//
// invalid buffer
//
// status = STATUS_INVALID_PARAMETER;
// break;
//}
//
// Copy the connection parameters to the device extension.
//
connectData = ((PCONNECT_DATA)
(irpStack->Parameters.DeviceIoControl.Type3InputBuffer));
dx->UpperConnectData = *connectData;
//
// Hook into the report chain. Everytime a mouse packet is reported to
// the system, MouFilter_ServiceCallback will be called
//
// connectData->ClassDeviceObject = devExt->Self;
// Donot need Jason Yu connectData->ClassService = MouFilter_ServiceCallback;
//KeyboardClassDO = connectData->ClassDeviceObject;
// SeviceCallback = (KeyboardClassServiceCallback)connectData->ClassService;
SeviceCallbackMouse = (MouseClassServiceCallback)connectData->ClassService;
KeyboardClassDO = connectData->ClassDeviceObject; //UpperData
return CompleteIrp(Irp,STATUS_SUCCESS,0);
}
break;
//
// Disconnect a mouse class device driver from the port driver.
//
case IOCTL_INTERNAL_MOUSE_DISCONNECT:
//
// Clear the connection parameters in the device extension.
//
// devExt->UpperConnectData.ClassDeviceObject = NULL;
// devExt->UpperConnectData.ClassService = NULL;
// status = STATUS_NOT_IMPLEMENTED;
break;
//
// Attach this driver to the initialization and byte processing of the
// i8042 (ie PS/2) mouse. This is only necessary if you want to do PS/2
// specific functions, otherwise hooking the CONNECT_DATA is sufficient
//
// case IOCTL_INTERNAL_I8042_HOOK_MOUSE:
//
// if (irpStack->Parameters.DeviceIoControl.InputBufferLength <
// sizeof(INTERNAL_I8042_HOOK_MOUSE)) {
//
// invalid buffer
//
// status = STATUS_INVALID_PARAMETER;
// break;
//}
//
// Copy the connection parameters to the device extension.
//
// hookMouse = (PINTERNAL_I8042_HOOK_MOUSE)
// (irpStack->Parameters.DeviceIoControl.Type3InputBuffer);
//
// Set isr routine and context and record any values from above this driver
//
// devExt->UpperContext = hookMouse->Context;
// hookMouse->Context = (PVOID) DeviceObject;
// if (hookMouse->IsrRoutine) {
// devExt->UpperIsrHook = hookMouse->IsrRoutine;
//}
//hookMouse->IsrRoutine = (PI8042_MOUSE_ISR) MouFilter_IsrHook;
//
// Store all of the other functions we might need in the future
//
// devExt->IsrWritePort = hookMouse->IsrWritePort;
// devExt->CallContext = hookMouse->CallContext;
// devExt->QueueMousePacket = hookMouse->QueueMousePacket;
// break;
//
// These internal ioctls are not supported by the new PnP model.
//
#if 0 // obsolete
case IOCTL_INTERNAL_MOUSE_ENABLE:
case IOCTL_INTERNAL_MOUSE_DISABLE:
status = STATUS_NOT_SUPPORTED;
break;
#endif // obsolete
//
// Might want to capture this in the future. For now, then pass it down
// the stack. These queries must be successful for the RIT to communicate
// with the mouse.
//
case IOCTL_MOUSE_QUERY_ATTRIBUTES:
{
PMOUSE_ATTRIBUTES pka = (PMOUSE_ATTRIBUTES) Irp->AssociatedIrp.SystemBuffer ;
pka->MouseIdentifier = 2;
pka->NumberOfButtons= 2;
pka->SampleRate = 900;
pka->InputDataQueueLength = 256;
return CompleteIrp(Irp,STATUS_SUCCESS,sizeof(MOUSE_ATTRIBUTES));
}
break;
//////////////////////////////////////// Jason End
case IOCTL_INTERNAL_KEYBOARD_CONNECT:
if (irpStack->Parameters.DeviceIoControl.InputBufferLength >= sizeof(CONNECT_DATA))
{
PCONNECT_DATA connectData = ((PCONNECT_DATA)(irpStack->Parameters.DeviceIoControl.Type3InputBuffer));
KeyboardClassDO = connectData->ClassDeviceObject;
SeviceCallback = (KeyboardClassServiceCallback)connectData->ClassService;
DbgPrint("KeyClass = %x,Service Callback = %x\n",KeyboardClassDO,SeviceCallback);
return CompleteIrp(Irp,STATUS_SUCCESS,0);
}
break;
case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
if(irpStack->Parameters.DeviceIoControl.InputBufferLength>=sizeof(KEYBOARD_UNIT_ID_PARAMETER))
{
PKEYBOARD_UNIT_ID_PARAMETER puip = (PKEYBOARD_UNIT_ID_PARAMETER) Irp->AssociatedIrp.SystemBuffer ;
UnitId = puip-> UnitId;
DbgPrint("id = %x\n",UnitId);
}
else
{
DbgPrint("id = 0\n");
}
if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <sizeof(KEYBOARD_ATTRIBUTES))
{
return CompleteIrp(Irp,STATUS_BUFFER_TOO_SMALL,0);
}
else
{
PKEYBOARD_ATTRIBUTES pka = (PKEYBOARD_ATTRIBUTES) Irp->AssociatedIrp.SystemBuffer ;
pka->KeyboardIdentifier.Type = 2;
pka->KeyboardIdentifier.Subtype = 0;
pka->KeyboardMode = 2;
pka->NumberOfFunctionKeys = 0;
pka->NumberOfIndicators = 0;
pka->NumberOfKeysTotal = 101;
pka->InputDataQueueLength = 256;
pka->KeyRepeatMinimum.UnitId = UnitId;
pka->KeyRepeatMinimum.Rate = 15;
pka->KeyRepeatMinimum.Delay = 100;
pka->KeyRepeatMaximum.UnitId = UnitId;
pka->KeyRepeatMaximum.Rate = 150;
pka->KeyRepeatMaximum.Delay = 10;
return CompleteIrp(Irp,STATUS_SUCCESS,sizeof(KEYBOARD_ATTRIBUTES));
}
case IOCTL_KEYBOARD_SET_TYPEMATIC:
DbgPrint("IOCTL_KEYBOARD_SET_TYPEMATIC\n");
break;
case IOCTL_KEYBOARD_SET_INDICATORS:
DbgPrint("IOCTL_KEYBOARD_SET_INDICATORS\n");
break;
case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
DbgPrint("IOCTL_KEYBOARD_QUERY_TYPEMATIC\n");
break;
case IOCTL_KEYBOARD_QUERY_INDICATORS:
DbgPrint("IOCTL_KEYBOARD_QUERY_INDICATORS\n");
break;
case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
DbgPrint("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION\n");
break;
case IOCTL_KEYBOARD_INSERT_DATA:
DbgPrint("IOCTL_KEYBOARD_INSERT_DATA\n");
break;
}
IoSkipCurrentIrpStackLocation(Irp);
return IoCallDriver( dx->NextStackDevice, Irp);
}
/////////////////////////////////////////////////////////////////////////////
// SystemControl:
//
// Description:
// Handle IRP_MJ_SYSTEM_CONTROL requests
//
// Arguments:
// Pointer to our FDO
// Pointer to the IRP
// Various minor parameters
// IrpStack->Parameters.WMI.xxx has WMI parameters
//
// Return Value:
// This function returns STATUS_XXX
NTSTATUS SystemControl( IN PDEVICE_OBJECT fdo,IN PIRP Irp)
{
if(FunctionDevice == fdo)
{
return CompleteIrp(Irp,STATUS_UNSUCCESSFUL,0);
}
// Just pass to lower driver
IoSkipCurrentIrpStackLocation(Irp);
PDEVICE_EXTENSION dx = (PDEVICE_EXTENSION)fdo->DeviceExtension;
return IoCallDriver( dx->NextStackDevice, Irp);
}
/////////////////////////////////////////////////////////////////////////////
// CompleteIrp: Sets IoStatus and completes the IRP
NTSTATUS CompleteIrp( PIRP Irp, NTSTATUS status, ULONG info)
{
Irp->IoStatus.Status = status;
Irp->IoStatus.Information = info;
IoCompleteRequest(Irp,IO_NO_INCREMENT);
return status;
}
/////////////////////////////////////////////////////////////////////////////
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -