Prev: legacyMode Problems
Next: OID_802_11_BSSID_LIST_SCAN
From: Robert on 25 May 2005 23:17 Hi, Currently iam doing a keyboard filter driver based on kbfiltr example from ddk. My objectives are to 1. Insert multiple keystrokes from a single key press. For example, when user press <a> i must send it as <SHIFT><F1> in the same context of <a>. 2. Drop and remap multiple keystrokes. For example,when user press <ALT><F2> I must send it as <b> In my previous post,Mr.Doron suggested me the following for my 1 objective. >>>>>>>>>>>>>>>>>>>>>>>Doron's post>>>>>>>>>>>>>>>>>>>> >> if this is with in the context of <a> being reported to your own callback, >> just declare a KEYBOARD_INPUT_DATA array on the stack, initialize it, then >> call the upper service callback with the new keystrokes, then finally report >> <a> using the caller's buffer. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I tried to execute what Doron told,and in the usermode application trace, iam getting <SHIFT><F1><F1><F1><F1><F1><F1>...... where <F1> goes infinite. Can anyone plz tell me where iam doing wrong ? below is my code. Please give me some suggestions or reference for my 2 objective too. Thanks for the patience shown to read this on. >>>>>>>>>>>>MY CODE >>>>>>>>>>>>>>>>>>>>>>>>>>>>> VOID KbFilter_ServiceCallback( IN PDEVICE_OBJECT DeviceObject, IN PKEYBOARD_INPUT_DATA InputDataStart, IN PKEYBOARD_INPUT_DATA InputDataEnd, IN OUT PULONG InputDataConsumed ) { PDEVICE_EXTENSION devExt; ULONG i=0,j=0; KEYBOARD_INPUT_DATA data[1]; devExt = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); for(j=0;j<i;j++) { if(InputDataStart[j].MakeCode != 0) { switch(InputDataStart[j].MakeCode) { case 0x1E: // If scancode for <a> data[0].UnitId = 0; data[0].MakeCode = 0x2A; // Left Shift data[0].Reserved = 0; data[0].ExtraInformation = 0; if(InputDataStart->Flags == KEY_MAKE) data[0].Flags = KEY_MAKE; else if(InputDataStart->Flags == KEY_BREAK) data[0].Flags = KEY_BREAK; (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( devExt->UpperConnectData.ClassDeviceObject, data, data+1, InputDataConsumed); InputDataStart[j].MakeCode = 0x3B; // F1 break; default: break; } } } (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( devExt->UpperConnectData.ClassDeviceObject, InputDataStart, InputDataEnd, InputDataConsumed); } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
From: Ray Trent on 26 May 2005 11:57 All of your problems (that I can see at first glance) probably devolve from this line: > i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); Ummm, you do realize that this will give you the length of the occupied buffer in bytes rather than in array entries, right? Get rid of the (PCHAR)'s. Robert wrote: > Hi, > > Currently iam doing a keyboard filter driver > based on kbfiltr example from ddk. > > My objectives are to > 1. Insert multiple keystrokes from a single key press. > For example, when user press <a> i must send it as <SHIFT><F1> > in the same context of <a>. > > 2. Drop and remap multiple keystrokes. > For example,when user press <ALT><F2> I must send it as <b> > > > In my previous post,Mr.Doron suggested me the following for my 1 objective. > > >>>>>>>>>>>>>>>>>>>>>>>>Doron's post>>>>>>>>>>>>>>>>>>>> >>> >>>if this is with in the context of <a> being reported to your own callback, >>>just declare a KEYBOARD_INPUT_DATA array on the stack, initialize it, then >>>call the upper service callback with the new keystrokes, then finally report >>><a> using the caller's buffer. >>> > > I tried to execute what Doron told,and in the usermode application trace, > iam getting <SHIFT><F1><F1><F1><F1><F1><F1>...... where <F1> goes infinite. > Can anyone plz tell me where iam doing wrong ? below is my code. > Please give me some suggestions or reference for my 2 objective too. > > Thanks for the patience shown to read this on. > > >>>>>>>>>>>>>MY CODE >>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > > VOID > KbFilter_ServiceCallback( > IN PDEVICE_OBJECT DeviceObject, > IN PKEYBOARD_INPUT_DATA InputDataStart, > IN PKEYBOARD_INPUT_DATA InputDataEnd, > IN OUT PULONG InputDataConsumed > ) > > { > PDEVICE_EXTENSION devExt; > ULONG i=0,j=0; > KEYBOARD_INPUT_DATA data[1]; > > devExt = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; > > i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); > > for(j=0;j<i;j++) > { > if(InputDataStart[j].MakeCode != 0) > { > switch(InputDataStart[j].MakeCode) > { > case 0x1E: // If scancode for <a> > data[0].UnitId = 0; > data[0].MakeCode = 0x2A; // Left Shift > data[0].Reserved = 0; > data[0].ExtraInformation = 0; > > if(InputDataStart->Flags == KEY_MAKE) > data[0].Flags = KEY_MAKE; > else if(InputDataStart->Flags == KEY_BREAK) > data[0].Flags = KEY_BREAK; > > (*(PSERVICE_CALLBACK_ROUTINE) > devExt->UpperConnectData.ClassService)( > devExt->UpperConnectData.ClassDeviceObject, > data, > data+1, > InputDataConsumed); > > InputDataStart[j].MakeCode = 0x3B; // F1 > break; > default: > break; > } > } > } > > > (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( > devExt->UpperConnectData.ClassDeviceObject, > InputDataStart, > InputDataEnd, > InputDataConsumed); > > } > -- .../ray\..
From: Robert on 26 May 2005 21:18 Thanks for the suggestion Ray. But i still face the same problem even after getting rid of those (PCHAR)'s. -Robert "Ray Trent" wrote: > All of your problems (that I can see at first glance) probably devolve > from this line: > > > i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); > > Ummm, you do realize that this will give you the length of the occupied > buffer in bytes rather than in array entries, right? Get rid of the > (PCHAR)'s. > > Robert wrote: > > Hi, > > > > Currently iam doing a keyboard filter driver > > based on kbfiltr example from ddk. > > > > My objectives are to > > 1. Insert multiple keystrokes from a single key press. > > For example, when user press <a> i must send it as <SHIFT><F1> > > in the same context of <a>. > > > > 2. Drop and remap multiple keystrokes. > > For example,when user press <ALT><F2> I must send it as <b> > > > > > > In my previous post,Mr.Doron suggested me the following for my 1 objective. > > > > > >>>>>>>>>>>>>>>>>>>>>>>>Doron's post>>>>>>>>>>>>>>>>>>>> > >>> > >>>if this is with in the context of <a> being reported to your own callback, > >>>just declare a KEYBOARD_INPUT_DATA array on the stack, initialize it, then > >>>call the upper service callback with the new keystrokes, then finally report > >>><a> using the caller's buffer. > >>> > > > > I tried to execute what Doron told,and in the usermode application trace, > > iam getting <SHIFT><F1><F1><F1><F1><F1><F1>...... where <F1> goes infinite. > > Can anyone plz tell me where iam doing wrong ? below is my code. > > Please give me some suggestions or reference for my 2 objective too. > > > > Thanks for the patience shown to read this on. > > > > > >>>>>>>>>>>>>MY CODE >>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > > > > > VOID > > KbFilter_ServiceCallback( > > IN PDEVICE_OBJECT DeviceObject, > > IN PKEYBOARD_INPUT_DATA InputDataStart, > > IN PKEYBOARD_INPUT_DATA InputDataEnd, > > IN OUT PULONG InputDataConsumed > > ) > > > > { > > PDEVICE_EXTENSION devExt; > > ULONG i=0,j=0; > > KEYBOARD_INPUT_DATA data[1]; > > > > devExt = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; > > > > i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); > > > > for(j=0;j<i;j++) > > { > > if(InputDataStart[j].MakeCode != 0) > > { > > switch(InputDataStart[j].MakeCode) > > { > > case 0x1E: // If scancode for <a> > > data[0].UnitId = 0; > > data[0].MakeCode = 0x2A; // Left Shift > > data[0].Reserved = 0; > > data[0].ExtraInformation = 0; > > > > if(InputDataStart->Flags == KEY_MAKE) > > data[0].Flags = KEY_MAKE; > > else if(InputDataStart->Flags == KEY_BREAK) > > data[0].Flags = KEY_BREAK; > > > > (*(PSERVICE_CALLBACK_ROUTINE) > > devExt->UpperConnectData.ClassService)( > > devExt->UpperConnectData.ClassDeviceObject, > > data, > > data+1, > > InputDataConsumed); > > > > InputDataStart[j].MakeCode = 0x3B; // F1 > > break; > > default: > > break; > > } > > } > > } > > > > > > (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( > > devExt->UpperConnectData.ClassDeviceObject, > > InputDataStart, > > InputDataEnd, > > InputDataConsumed); > > > > } > > > > -- > .../ray\.. >
From: Ray Trent on 27 May 2005 14:09 I hope this isn't a "duh" moment, but I suggest that you step through this routine in the debugger and see what it's doing directly rather than trying to analyze it further by staring at the code. I'm not sure this has anything to do with your problem, but you probably also shouldn't reuse the InputDataConsumed variable without resetting its value. I'd have to look at the MOUCLASS source to see whether it actually cares what the value is on input, but it might... Now that I look at this some more, BTW, it's logically bizarre. You're first sending out a bunch of left shifts (one for each 0x1E in the buffer), and then spewing out the real keystrokes. I'm assuming that your intent was to insert an extra 0x2A before *each* 0x1E, right? That's noticeably harder to do. Robert wrote: > Thanks for the suggestion Ray. > But i still face the same problem even after getting rid of those (PCHAR)'s. > -Robert > > "Ray Trent" wrote: > > >>All of your problems (that I can see at first glance) probably devolve >>from this line: >> >> > i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); >> >>Ummm, you do realize that this will give you the length of the occupied >>buffer in bytes rather than in array entries, right? Get rid of the >>(PCHAR)'s. >> >>Robert wrote: >> >>>Hi, >>> >>>Currently iam doing a keyboard filter driver >>>based on kbfiltr example from ddk. >>> >>>My objectives are to >>>1. Insert multiple keystrokes from a single key press. >>> For example, when user press <a> i must send it as <SHIFT><F1> >>> in the same context of <a>. >>> >>>2. Drop and remap multiple keystrokes. >>> For example,when user press <ALT><F2> I must send it as <b> >>> >>> >>>In my previous post,Mr.Doron suggested me the following for my 1 objective. >>> >>> >>> >>>>>>>>>>>>>>>>>>>>>>>>>>Doron's post>>>>>>>>>>>>>>>>>>>> >>>>> >>>>>if this is with in the context of <a> being reported to your own callback, >>>>>just declare a KEYBOARD_INPUT_DATA array on the stack, initialize it, then >>>>>call the upper service callback with the new keystrokes, then finally report >>>>><a> using the caller's buffer. >>>>> >>> >>>I tried to execute what Doron told,and in the usermode application trace, >>>iam getting <SHIFT><F1><F1><F1><F1><F1><F1>...... where <F1> goes infinite. >>>Can anyone plz tell me where iam doing wrong ? below is my code. >>>Please give me some suggestions or reference for my 2 objective too. >>> >>>Thanks for the patience shown to read this on. >>> >>> >>> >>>>>>>>>>>>>>>MY CODE >>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>> >>> >>>VOID >>>KbFilter_ServiceCallback( >>> IN PDEVICE_OBJECT DeviceObject, >>> IN PKEYBOARD_INPUT_DATA InputDataStart, >>> IN PKEYBOARD_INPUT_DATA InputDataEnd, >>> IN OUT PULONG InputDataConsumed >>> ) >>> >>>{ >>> PDEVICE_EXTENSION devExt; >>> ULONG i=0,j=0; >>> KEYBOARD_INPUT_DATA data[1]; >>> >>> devExt = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension; >>> >>> i = (ULONG)((PCHAR) InputDataEnd - (PCHAR) InputDataStart); >>> >>> for(j=0;j<i;j++) >>> { >>> if(InputDataStart[j].MakeCode != 0) >>> { >>> switch(InputDataStart[j].MakeCode) >>> { >>> case 0x1E: // If scancode for <a> >>> data[0].UnitId = 0; >>> data[0].MakeCode = 0x2A; // Left Shift >>> data[0].Reserved = 0; >>> data[0].ExtraInformation = 0; >>> >>> if(InputDataStart->Flags == KEY_MAKE) >>> data[0].Flags = KEY_MAKE; >>> else if(InputDataStart->Flags == KEY_BREAK) >>> data[0].Flags = KEY_BREAK; >>> >>> (*(PSERVICE_CALLBACK_ROUTINE) >>> devExt->UpperConnectData.ClassService)( >>> devExt->UpperConnectData.ClassDeviceObject, >>> data, >>> data+1, >>> InputDataConsumed); >>> >>> InputDataStart[j].MakeCode = 0x3B; // F1 >>> break; >>> default: >>> break; >>> } >>> } >>> } >>> >>> >>> (*(PSERVICE_CALLBACK_ROUTINE) devExt->UpperConnectData.ClassService)( >>> devExt->UpperConnectData.ClassDeviceObject, >>> InputDataStart, >>> InputDataEnd, >>> InputDataConsumed); >>> >>>} >>> >> >>-- >>.../ray\.. >> -- .../ray\..
|
Pages: 1 Prev: legacyMode Problems Next: OID_802_11_BSSID_LIST_SCAN |