From: BladeMaster on
I have been modified the DDK sample moufiltr driver to be accessed by user app.
user mode app can access to the control objcet with the symbolic link.
It also works well with WriteFile() - IRP_MJ_WRITE.
But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
PC is rebooted immediately.

I'd like to create a mouse packet in the driver from the user mode app call.
What is wrong? What should I do?

Thank you.

--
Blade
From: soviet_bloke on
Hi mate

> But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> PC is rebooted immediately.


Have you noticed the following comment in
MouFilter_ServiceCallback()???

// UpperConnectData must be called at DISPATCH

Taking into consideration that MouFilter_ServiceCallback() does not do
anything IRQL-related before calling UpperConnectData, it is easy to
understand that it has to be called at DISPATCH_LEVEL. There are some
certain things that cannot be done at low IRQL (for example, releasing
a spinlock from DPC level) without screwing up the system. Therefore,
once this comment has been added, it implies that UpperConnectData,
apparently, does some operations that cannot be done at low IRQL. One
does not even know the context in which it is supposed to get call to
arrive to the above conclusion - looking at the souce alone is more
than enough.

However, IRP_MJ_WRITE that results from WriteFile() call gets processed
at PASSIVE_LEVEL. Have you got any more questions why you crash when
trying to call MouFilter_ServiceCallback() from IRP_MJ_WRITE
handler????

Anton Bassov


BladeMaster wrote:
> I have been modified the DDK sample moufiltr driver to be accessed by user app.
> user mode app can access to the control objcet with the symbolic link.
> It also works well with WriteFile() - IRP_MJ_WRITE.
> But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> PC is rebooted immediately.
>
> I'd like to create a mouse packet in the driver from the user mode app call.
> What is wrong? What should I do?
>
> Thank you.
>
> --
> Blade

From: BladeMaster on
Thank you for your kind answer.

So I use KeRaiseIrqlToDpcLevel() before calling MouFilter_ServiceCallback()
in moufiltr_DIspathWrite().
of course I also use KeLowerIrql() after call.
But it still crash.

Actually MouFilter_ServiceCallback() is expected to be called by the port
driver.
But I'd like to call it from DispathWrite() of filter driver.

Please give me any advice.
thank you.


KeRaiseIrqlToDpcLevel()

--
Blade

"soviet_bloke(a)hotmail.com" wrote:

> Hi mate
>
> > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > PC is rebooted immediately.
>
>
> Have you noticed the following comment in
> MouFilter_ServiceCallback()???
>
> // UpperConnectData must be called at DISPATCH
>
> Taking into consideration that MouFilter_ServiceCallback() does not do
> anything IRQL-related before calling UpperConnectData, it is easy to
> understand that it has to be called at DISPATCH_LEVEL. There are some
> certain things that cannot be done at low IRQL (for example, releasing
> a spinlock from DPC level) without screwing up the system. Therefore,
> once this comment has been added, it implies that UpperConnectData,
> apparently, does some operations that cannot be done at low IRQL. One
> does not even know the context in which it is supposed to get call to
> arrive to the above conclusion - looking at the souce alone is more
> than enough.
>
> However, IRP_MJ_WRITE that results from WriteFile() call gets processed
> at PASSIVE_LEVEL. Have you got any more questions why you crash when
> trying to call MouFilter_ServiceCallback() from IRP_MJ_WRITE
> handler????
>
> Anton Bassov
>
>
> BladeMaster wrote:
> > I have been modified the DDK sample moufiltr driver to be accessed by user app.
> > user mode app can access to the control objcet with the symbolic link.
> > It also works well with WriteFile() - IRP_MJ_WRITE.
> > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > PC is rebooted immediately.
> >
> > I'd like to create a mouse packet in the driver from the user mode app call.
> > What is wrong? What should I do?
> >
> > Thank you.
> >
> > --
> > Blade
>
>
From: soviet_bloke on
> 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 in your situation, but you
can do the above simply by calling SendInput() in the user mode, so
that you don't even need a driver here

Anton Bassov


BladeMaster wrote:
> Thank you for your kind answer.
>
> So I use KeRaiseIrqlToDpcLevel() before calling MouFilter_ServiceCallback()
> in moufiltr_DIspathWrite().
> of course I also use KeLowerIrql() after call.
> But it still crash.
>
> Actually MouFilter_ServiceCallback() is expected to be called by the port
> driver.
> But I'd like to call it from DispathWrite() of filter driver.
>
> Please give me any advice.
> thank you.
>
>
> KeRaiseIrqlToDpcLevel()
>
> --
> Blade
>
> "soviet_bloke(a)hotmail.com" wrote:
>
> > Hi mate
> >
> > > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > > PC is rebooted immediately.
> >
> >
> > Have you noticed the following comment in
> > MouFilter_ServiceCallback()???
> >
> > // UpperConnectData must be called at DISPATCH
> >
> > Taking into consideration that MouFilter_ServiceCallback() does not do
> > anything IRQL-related before calling UpperConnectData, it is easy to
> > understand that it has to be called at DISPATCH_LEVEL. There are some
> > certain things that cannot be done at low IRQL (for example, releasing
> > a spinlock from DPC level) without screwing up the system. Therefore,
> > once this comment has been added, it implies that UpperConnectData,
> > apparently, does some operations that cannot be done at low IRQL. One
> > does not even know the context in which it is supposed to get call to
> > arrive to the above conclusion - looking at the souce alone is more
> > than enough.
> >
> > However, IRP_MJ_WRITE that results from WriteFile() call gets processed
> > at PASSIVE_LEVEL. Have you got any more questions why you crash when
> > trying to call MouFilter_ServiceCallback() from IRP_MJ_WRITE
> > handler????
> >
> > Anton Bassov
> >
> >
> > BladeMaster wrote:
> > > I have been modified the DDK sample moufiltr driver to be accessed by user app.
> > > user mode app can access to the control objcet with the symbolic link.
> > > It also works well with WriteFile() - IRP_MJ_WRITE.
> > > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > > PC is rebooted immediately.
> > >
> > > I'd like to create a mouse packet in the driver from the user mode app call.
> > > What is wrong? What should I do?
> > >
> > > Thank you.
> > >
> > > --
> > > Blade
> >
> >

From: BladeMaster on

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 in your situation, but you
> can do the above simply by calling SendInput() in the user mode, so
> that you don't even need a driver here
>
> Anton Bassov
>
>
> BladeMaster wrote:
> > Thank you for your kind answer.
> >
> > So I use KeRaiseIrqlToDpcLevel() before calling MouFilter_ServiceCallback()
> > in moufiltr_DIspathWrite().
> > of course I also use KeLowerIrql() after call.
> > But it still crash.
> >
> > Actually MouFilter_ServiceCallback() is expected to be called by the port
> > driver.
> > But I'd like to call it from DispathWrite() of filter driver.
> >
> > Please give me any advice.
> > thank you.
> >
> >
> > KeRaiseIrqlToDpcLevel()
> >
> > --
> > Blade
> >
> > "soviet_bloke(a)hotmail.com" wrote:
> >
> > > Hi mate
> > >
> > > > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > > > PC is rebooted immediately.
> > >
> > >
> > > Have you noticed the following comment in
> > > MouFilter_ServiceCallback()???
> > >
> > > // UpperConnectData must be called at DISPATCH
> > >
> > > Taking into consideration that MouFilter_ServiceCallback() does not do
> > > anything IRQL-related before calling UpperConnectData, it is easy to
> > > understand that it has to be called at DISPATCH_LEVEL. There are some
> > > certain things that cannot be done at low IRQL (for example, releasing
> > > a spinlock from DPC level) without screwing up the system. Therefore,
> > > once this comment has been added, it implies that UpperConnectData,
> > > apparently, does some operations that cannot be done at low IRQL. One
> > > does not even know the context in which it is supposed to get call to
> > > arrive to the above conclusion - looking at the souce alone is more
> > > than enough.
> > >
> > > However, IRP_MJ_WRITE that results from WriteFile() call gets processed
> > > at PASSIVE_LEVEL. Have you got any more questions why you crash when
> > > trying to call MouFilter_ServiceCallback() from IRP_MJ_WRITE
> > > handler????
> > >
> > > Anton Bassov
> > >
> > >
> > > BladeMaster wrote:
> > > > I have been modified the DDK sample moufiltr driver to be accessed by user app.
> > > > user mode app can access to the control objcet with the symbolic link.
> > > > It also works well with WriteFile() - IRP_MJ_WRITE.
> > > > But when it call MouFilter_ServiceCallback() in IRP_MJ_WRITE hanlder,
> > > > PC is rebooted immediately.
> > > >
> > > > I'd like to create a mouse packet in the driver from the user mode app call.
> > > > What is wrong? What should I do?
> > > >
> > > > Thank you.
> > > >
> > > > --
> > > > Blade
> > >
> > >
>
>