Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulating Mouse Input

0 views
Skip to first unread message

fishnchips

unread,
Feb 13, 2008, 10:00:00 PM2/13/08
to
Hi

I've developed a KM (mouse and keyboard sharing) type of program, alike
Synergy, etc.

I have a problem: some people play games are picking up events prior to the
global mouse hook, I'm sure this is DirectInput. This is causing troubles in
various ways, so the solution I see is to use a driver of some type.

What I need to do:
1) Block input totally on the non active PC.
2) Generate clicks and movement on the active PC.

I'm looking at using a filter driver (the moufiltr example) and controlling
it using DeviceIoControl, which I have succeeded to connect to drivers with.
I don't want to use a driver if you can just control the existing mouclass
driver tho.

I have DriverspyNT that shows IRP_MJ_INTERNAL_DEVICE_CONTROL is the ultimate
gloal. I have the DDK and also dbgview.

ty for any help/pointers

Ray Trent

unread,
Feb 14, 2008, 1:21:30 PM2/14/08
to
Yes, if you want mouse input that will work regardless of the situation,
you'll need to write a driver for it. SendInput used to be pretty good,
but in Vista elevated apps don't receive those either, in addition to
the DirectX issue (though what the justification is for simulating input
on a device the application specifically identified as the one it wanted
to receive input from is beyond me).

Whether you need a mouse port driver/HID minidriver or a device filter
will depend on whether you're willing to rely on installing on an
existing pointing device or want to make sure to work even in server
rack with no mouse attached.

Please note that any mechanism you provide to allow user mode apps to
inject mouse packets via a driver opens a security hole in UAC and
Vista's anti-Shatter protections. Not saying you shouldn't do it, just
be aware of the tradeoff.


--
Ray

fishnchips

unread,
Feb 14, 2008, 10:34:00 PM2/14/08
to
"Ray Trent" wrote:

> Yes, if you want mouse input that will work regardless of the situation,
> you'll need to write a driver for it. SendInput used to be pretty good,
> but in Vista elevated apps don't receive those either, in addition to
> the DirectX issue (though what the justification is for simulating input
> on a device the application specifically identified as the one it wanted
> to receive input from is beyond me).

Basically, my app is for multiboxing, where you take an MMORPG, and play 2
or more characters. If your using more than 1 computer you don't wanna
change mouse / keyboard. For me, it's just something to learn but it's free
and on sourceforge.

> Whether you need a mouse port driver/HID minidriver or a device filter
> will depend on whether you're willing to rely on installing on an
> existing pointing device or want to make sure to work even in server
> rack with no mouse attached.

Currently I'm looking at the KMDF kbfltr example in the DDK and the
possibilty of adapting it to a mouse class upper filter. This isn't based on
wanting to stay away from an additional device, I'm looking for the easist
option for a newbie, so I rely on examples more or less:)

fishnchips

unread,
Feb 16, 2008, 9:15:01 AM2/16/08
to
I've done pretty well for a first driver. I used the PS2 example moufiltr
but it works as a class filter fine. I took the PS2 parts out. I added a
control device which I'm able to connect with and send IO_CTL codes. I'm
able to choke the mouse input, but I cannot figure out how to add packets via
my control device. I'm sure I can do it via the service call back, but I
need to do it from the IO_CTL codes. So I figured to copy the
MouFilter_ServiceCallback function just like when there is real data, but add
fake packets, but I get a BSOD when using this code. The MOUSE_INPUT_DATA is
arriving correctly.

PMOUSE_INPUT_DATA mid = (PMOUSE_INPUT_DATA)Irp->AssociatedIrp.SystemBuffer;

ULONG count = 1;

KIRQL irq = KeGetCurrentIrql();

KeRaiseIrqlToDpcLevel();

(*(PSERVICE_CALLBACK_ROUTINE) ConnectData->ClassService)(
ConnectData->ClassDeviceObject,
mid,
mid + 1,
&count
);

KeLowerIrql(irq);

ConnectData is the same info stored to the device extension that is used in
the normal service call back.
Anyway I probably got it all wrong, if anyone knows how, pls pls help :)

Maxim S. Shatskih

unread,
Feb 16, 2008, 5:02:53 PM2/16/08
to
What is the BSOD details? what does !analyze -v prints?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"fishnchips" <fishn...@discussions.microsoft.com> wrote in message
news:4A9390E8-E5E4-4256...@microsoft.com...

fishnchips

unread,
Feb 17, 2008, 7:59:00 AM2/17/08
to
Thx for helping, but I figured it out after reading the DDK help and
understanding the IOCTL_INTERNAL_MOUSE_CONNECT better. I was using the
modified connect data rather than the original pointers to the class device.
So it's working now pretty much, all I need to figure out now is how to have
a callback to my application so I can have a pseudo mouse hook and block the
stream to DirectInput at the same time.

When it is done, the code will be available at
http://www.sourceforge.net/projects/octo

0 new messages