From: soviet_bloke on
> I am a novice. Frankly speaking, I couldn't set up a kernel debugger.. --;
> (My target PC has no COM port, so I couldn't connect NULL-modem cable)


Get yourself VMWare, so that you would not need a second PC and
NULL-modem cable.
You may find the link below quite helpfull:

http://www.catch22.net/tuts/vmware.asp

> (But I cannot understand what's the problem if my mouse event were treated
> as an actual hardware event)

Processing actual hardware events may involve interaction with physical
hardware, which knows its own state perfectly well. Therefore, there
may be some "misunderstanding" between hardware and the OS.

Anton Bassov

BladeMaster wrote:
> Thank you.
> I am a novice. Frankly speaking, I couldn't set up a kernel debugger.. --;
> (My target PC has no COM port, so I couldn't connect NULL-modem cable)
>
> I already looked at mouclass and i8042 samples many times
> but I couldn't find solution, so I posted questions.
> Anyway your replies are very helpful.
> (But I cannot understand what's the problem if my mouse event were treated
> as an actual hardware event)
> And I'll have to study harder and try to do it by myself ^^
> Thank you again.
>
>
>
>
> --
> Blade
>
>
> "soviet_bloke(a)hotmail.com" wrote:
>
> > Doron,
> >
> > > how about posting a callstack and the output of !analyze -v?
> >
> > Apparently, this is going to be the OP's next step - up to this point
> > we were speaking about
> > the problems that can be immediately identified simply by looking at
> > the source......
> >
> > Anton Bassov
> >
> >
> > Doron Holan [MS] wrote:
> > > how about posting a callstack and the output of !analyze -v? debugging in
> > > the dark is a bit hard sometimes...
> > >
> > > d
> > >
> > > --
> > > Please do not send e-mail directly to this alias. this alias is for
> > > newsgroup purposes only.
> > > This posting is provided "AS IS" with no warranties, and confers no rights.
> > >
> > >
> > > <soviet_bloke(a)hotmail.com> wrote in message
> > > news:1163303936.783077.49490(a)k70g2000cwa.googlegroups.com...
> > > >A brief look at mouclass sample shows the following block in
> > > > MouseClassServiceCallback()
> > > >
> > > > if ((InputDataEnd == InputDataStart + 1) &&
> > > > (InputDataStart->Flags & MOUSE_ATTRIBUTES_CHANGED)) {
> > > > //
> > > > // This is a notification packet that is not indicative of the
> > > > user
> > > > // being present. It is instead just a blank packet for the
> > > > Raw
> > > > // Input User Thread.
> > > > //
> > > > // We will pass it on, but we will not treat this as human
> > > > input.
> > > > //
> > > >
> > > > ;
> > > > } else {
> > > > //
> > > > // Notify system that human input has occured
> > > > //
> > > >
> > > > PoSetSystemState (ES_USER_PRESENT);
> > > > }
> > > >
> > > >
> > > > ntddmou. h defines MOUSE_ATTRIBUTES_CHANGED as 0x04. You have specified
> > > >
> > > > MOUSE_MOVE_RELATIVE flag, which is defined as 0 in ntddmou.h.
> > > > Therefore,
> > > > InputDataStart->Flags & MOUSE_ATTRIBUTES_CHANGED will always be FALSE,
> > > > which means that your "mouse event" will always be treated as an actual
> > > > hardware event. Apparently, this is why you are crashing this time (a
> > > > brief look at MouseClassServiceCallback() shows that my previous
> > > > statement about spinlocks and IRQL is absolutely correct as well - it
> > > > acquires a spinlock at DPC level)
> > > >
> > > > In general, you should not ask questions in the NG - instead, you
> > > > should look at MouseClassServiceCallback() implementation in mouclass
> > > > sample, so that you will discover everything yourself (AFAIK, kbdclass,
> > > > mouclass and i8042prt are the provide the source to the *REAL* drivers,
> > > > provided by the system)
> > > >
> > > > Anton Bassov
> > > >
> > > >
> > > >
> > > > BladeMaster wrote:
> > > >> Using SendInput() has some problem with anti-virus program.
> > > >> So I have to do it by driver.
> > > >>
> > > >> mouse port driver(i8042) simply send starting and end pointers of queue
> > > >> filled with MOUSE_INPUT_DATA to moufiltr_ServiceCallback routine .
> > > >> so I create a buffer in filter driver and copy the queue data from port
> > > >> driver's one.
> > > >> When I copy and inject data only in moufiltr_serviceCallback,
> > > >> I works well.
> > > >> But When I call the moufiltr_serviceCallBack from DispatchWrite
> > > >> routine(and
> > > >> only injection), It crashes.
> > > >> The following code is the part of my DispatchWrite() of moufiltr.
> > > >> Any help much appreciated
> > > >> thank you.
> > > >>
> > > >> ------------------------------------
> > > >>
> > > >> InputData.Flags =MOUSE_MOVE_RELATIVE;
> > > >> InputData.Buttons = 0;
> > > >> // InputData.Buttons.ButtonData =0;
> > > >> // InputData.Buttons.RawButtons =
> > > >> InputData.LastX = *((ULONG*)buffer);
> > > >> InputData.LastY = *((ULONG*)buffer+1);
> > > >>
> > > >> InputDataStart = &InputData;
> > > >> InputDataEnd = InputDataStart+1;
> > > >>
> > > >> oldirq = KeRaiseIrqlToDpcLevel();
> > > >>
> > > >> MouFilter_ServiceCallback(
> > > >> DeviceObject,
> > > >> InputDataStart,
> > > >> InputDataEnd,
> > > >> &InputDataConsumed
> > > >> );
> > > >> KeLowerIrql(oldirq);
> > > >> -------------------------------
> > > >>
> > > >>
> > > >> --
> > > >> Blade
> > > >>
> > > >> "soviet_bloke(a)hotmail.com" wrote:
> > > >>
> > > >> > > Actually MouFilter_ServiceCallback() is expected to be called by the
> > > >> > > port
> > > >> > > driver.
> > > >> >
> > > >> > Indeed, it is supposed to get called by the port driver's DPC routine -
> > > >> > this is why it is supposed to get called at DISPATCH_LEVEL. Therefore,
> > > >> > its paramters are normally specified by the port driver, rather than
> > > >> > your code . Are you sure your code passes
> > > >> > correct parameters to it???
> > > >> >
> > > >> > BTW, if I got it right, you just want to inject data into mouclass
> > > >> > input queue upon your application's request, right? In other words, you
> > > >> > are trying to simulate mouse activity.
> > > >> > I don't know if it is appropriate solution
From: Ray Trent on
In spite of what everyone else is saying, assuming all your parameters
are correct the below should work, so one of your parameters is probably
wrong.

Did you pass your device object, or the one that mouclass sent you in
the mouse connect IOCTL (you need to pass the latter)?

Are you sure your "buffer" is valid? Are you sure that InputDataStart
and InputDataEnd are MOUSE_INPUT_DATA*'s (it's usually better to just
call the function with &foo, (&foo)+1 to avoid having to worry about
that)? Also, you should be sure to RtlZeroMemory the MOUSE_INPUT_DATA
struct before filling it in...

BladeMaster wrote:
>
> Using SendInput() has some problem with anti-virus program.
> So I have to do it by driver.
>
> mouse port driver(i8042) simply send starting and end pointers of queue
> filled with MOUSE_INPUT_DATA to moufiltr_ServiceCallback routine .
> so I create a buffer in filter driver and copy the queue data from port
> driver's one.
> When I copy and inject data only in moufiltr_serviceCallback,
> I works well.
> But When I call the moufiltr_serviceCallBack from DispatchWrite routine(and
> only injection), It crashes.
> The following code is the part of my DispatchWrite() of moufiltr.
> Any help much appreciated
> thank you.
>
> ------------------------------------
>
> InputData.Flags =MOUSE_MOVE_RELATIVE;
> InputData.Buttons = 0;
> // InputData.Buttons.ButtonData =0;
> // InputData.Buttons.RawButtons =
> InputData.LastX = *((ULONG*)buffer);
> InputData.LastY = *((ULONG*)buffer+1);
>
> InputDataStart = &InputData;
> InputDataEnd = InputDataStart+1;
>
> oldirq = KeRaiseIrqlToDpcLevel();
>
> MouFilter_ServiceCallback(
> DeviceObject,
> InputDataStart,
> InputDataEnd,
> &InputDataConsumed
> );
> KeLowerIrql(oldirq);
> -------------------------------
>
>


--
Ray
From: soviet_bloke on
Ray,

> In spite of what everyone else is saying, assuming all your parameters
> are correct the below should work, so one of your parameters is probably
> wrong.

Well, actually, "everyone else" is saying that some of the parameters
are incorrect in context of this call. Therefore, the whole discussion
is all about which particular parameter is wrong.....

Up to this point, we have already identified IRQL and flags as
trouble-makers, but probably, something else is still left.You have
properly highlighed few more "candidates" that have to be checked -
after all, who told you that there is only one bug there???? However,
as Doron has already pointed out, it may be not so easy to identify a
problem without actually hooking up a debugger

Anton Bassov


Ray Trent wrote:
> In spite of what everyone else is saying, assuming all your parameters
> are correct the below should work, so one of your parameters is probably
> wrong.
>
> Did you pass your device object, or the one that mouclass sent you in
> the mouse connect IOCTL (you need to pass the latter)?
>
> Are you sure your "buffer" is valid? Are you sure that InputDataStart
> and InputDataEnd are MOUSE_INPUT_DATA*'s (it's usually better to just
> call the function with &foo, (&foo)+1 to avoid having to worry about
> that)? Also, you should be sure to RtlZeroMemory the MOUSE_INPUT_DATA
> struct before filling it in...
>
> BladeMaster wrote:
> >
> > Using SendInput() has some problem with anti-virus program.
> > So I have to do it by driver.
> >
> > mouse port driver(i8042) simply send starting and end pointers of queue
> > filled with MOUSE_INPUT_DATA to moufiltr_ServiceCallback routine .
> > so I create a buffer in filter driver and copy the queue data from port
> > driver's one.
> > When I copy and inject data only in moufiltr_serviceCallback,
> > I works well.
> > But When I call the moufiltr_serviceCallBack from DispatchWrite routine(and
> > only injection), It crashes.
> > The following code is the part of my DispatchWrite() of moufiltr.
> > Any help much appreciated
> > thank you.
> >
> > ------------------------------------
> >
> > InputData.Flags =MOUSE_MOVE_RELATIVE;
> > InputData.Buttons = 0;
> > // InputData.Buttons.ButtonData =0;
> > // InputData.Buttons.RawButtons =
> > InputData.LastX = *((ULONG*)buffer);
> > InputData.LastY = *((ULONG*)buffer+1);
> >
> > InputDataStart = &InputData;
> > InputDataEnd = InputDataStart+1;
> >
> > oldirq = KeRaiseIrqlToDpcLevel();
> >
> > MouFilter_ServiceCallback(
> > DeviceObject,
> > InputDataStart,
> > InputDataEnd,
> > &InputDataConsumed
> > );
> > KeLowerIrql(oldirq);
> > -------------------------------
> >
> >
>
>
> --
> Ray