I wrote a keybaord upper filter driver for WinXP(like systeminternal.com 's
Ctrl2cap),it had work correctly,such as notice my APP.
I only want to get the multimedia key's code and change the multimedia
key's behavior,but I found if I use USB keyboard ,I can't get any
information when I press the multimedia keys and power management keys.But
if I use PS/2 keyboard,I can get every key's make code and break code,Why?
In IRP_MJ_READ I use:
IoSetCompletionRoutine( Irp, ReadComplete, DeviceObject, TRUE, TRUE,
TRUE );
NTSTATUS ReadComplete( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp,IN PVOID
Context )
{
PIO_STACK_LOCATION IrpSp;
PKEYBOARD_INPUT_DATA KeyData;
int numKeys, i;
PAGED_CODE();
// Request completed - look at the result.
IrpSp = IoGetCurrentIrpStackLocation( Irp );
if( NT_SUCCESS( Irp->IoStatus.Status ) )
{
KeyData = Irp->AssociatedIrp.SystemBuffer;
numKeys = Irp->IoStatus.Information / sizeof(KEYBOARD_INPUT_DATA);
for( i = 0; i < numKeys; i++ )
{
if((KeyData[i].Flags == 2 || KeyData[i].Flags==4) &&
KeyData[i].MakeCode==0x6D) //Press Media Sel Key
{
KeyCode=KeyData[i].MakeCode;//store the make code for params to notice
my APP
KeSetEvent(pEvent, EVENT_INCREMENT, FALSE);//notice my APP
}
}
}
// Mark the Irp pending if required
if( Irp->PendingReturned )
{
IoMarkIrpPending( Irp );
}
return Irp->IoStatus.Status;
}
Please help me.