Discussion:
INF file for mouse filter driver
(too old to reply)
Moritz Franckenstein
2010-11-13 08:53:31 UTC
Permalink
Hi there,

I have a working mouse filter driver for 32 bit windows.

Now I ported it to x64 and got it to work, but only for PS2 mice. Can
anyone give a hint how to change the INF file so it works with USB mice,
too? The 32 bit version did.

I can send the current state by email or you tell me which part I should
post here. Or maybe you can point me to any resource or tool which could
help me?

Thanks in advance,
--
Moritz Franckenstein
mailto:maf-***@gmx.net
icq: 22030984 y!: maf_soft
4***@email.com
2010-11-14 12:21:30 UTC
Permalink
If the inf file adds a UpperFilters or LowerFilters entry for the
mouse class it will filter both ps2 and usb mice.
Moritz Franckenstein
2010-11-16 10:38:11 UTC
Permalink
Post by 4***@email.com
If the inf file adds a UpperFilters or LowerFilters entry for the
mouse class it will filter both ps2 and usb mice.
The INF File, copied from some MS example, seems to only support PS2
mice. I see there sections like this:

; Install the port driver and mouclass from msmouse.inf
Include=msmouse.inf
Needs=PS2_Inst.Services

; run the directives need by the port driver
Include=msmouse.inf
Needs=PS2_Inst.HW

For the 32 bits version of the driver I also had different INF file
versions for PS2 and USB, but I don't understand enough to port them to
64 bits.

Could I send you the files by email and you take a look? It would help
me much...
Or if I should post parts of the files here, please tell which ones...
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
4***@email.com
2010-11-16 12:46:02 UTC
Permalink
This post might be inappropriate. Click to display it.
Moritz Franckenstein
2010-11-16 14:57:06 UTC
Permalink
Post by 4***@email.com
Post by Moritz Franckenstein
The INF File, copied from some MS example,
seems to only support PS2 mice.
Right. That is a reason why it is a bad example. This might be the
most terrible example in the DDK for its many shortcomings and bugs.
Ouch. Nice to hear. Do you have some examples of what is buggy in the
source code? I took most things over and it works. What could happen
when using this driver? Bad things?
Post by 4***@email.com
what you seem to need is a mouse class filter driver which filters
all types of mice, not a ps/2 port filter which is limited to ps/2
mice. For a class filter your inf file could look like the below.
Is that really all? My existing INF files are much more complicated...

I will try it out, thank you very much.
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
Moritz Franckenstein
2010-11-16 20:12:57 UTC
Permalink
Post by 4***@email.com
For a class filter your inf file could look like the below.
Unfortunately, it is not a class filter - it is a device filter:

I tried your example out (on a x86 machine) by right-clicking the inf
file and it was installed without any question or any success message.
After installation I found it in the upper class filter of the mouse
driver, but it didn't work.
How to uninstall? Rollback driver isn't available and after uninstalling
the mouse driver itself and reinstalling it, my driver is also back there :)

I then installed my old version of the inf file again. It worked
correctly and I found it then as upper device filter. So this seems to
be a different type.
This old version cannot be installed by right click - I have to choose
the mouse in the devicemanager and install it from there. After
installation, the mouse name in the devicemanager changes to the new
name out of the inf file, and for uninstallation I can simply use the
rollback feature.

It is important that the driver is only active for a selected mouse, so
by right-clicking it cannot work anyway.

I hope you will help me again and tell what to change for this type of
driver.

Thank you very much for your help!
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
4***@email.com
2010-11-17 00:48:08 UTC
Permalink
What could happen when using this driver? Bad things?
Yes. For example it blows away the users existing mouse driver and
replaces it with a de-featured driver dating back 20 years. This will
in turn de-feature many of the newer types of mice. There is a very
long list of issues with this sample, don't use it.
After installation I found it in the upper class filter of the mouse driver, but it didn't work
Are you using IOCTL_INTERNAL_MOUSE_CONNECT and/or
IOCTL_INTERNAL_I8042_HOOK_MOUSE?

If yes, then this architecture won't work for USB at all (another
reason not to use this sample). Change your architecture to strictly
filter IRPs and delete everything related to such ioctls. You want an
upper class filter. Use the inf suggested and filter the IRP traffic.
It will work consistently with ps2 and USB.
It is important that the driver is only active for a selected mouse,
so by right-clicking it cannot work anyway.
It can work in several ways. A class filter can choose which devices
it wishes to filter and which it does not. It is also be possible to
install it for a specific device rather than as a class. It can also
be installed and/or uninstalled using setup api, dpinst, etc.
Moritz Franckenstein
2010-11-18 10:31:59 UTC
Permalink
Post by 4***@email.com
What could happen when using this driver? Bad things?
Yes. For example it blows away the users existing mouse driver and
replaces it with a de-featured driver dating back 20 years. This will
in turn de-feature many of the newer types of mice. There is a very
long list of issues with this sample, don't use it.
Until now (x86 version) I never had any problems with it, on many
machines. But of course I am willing to change it to something better.
Post by 4***@email.com
Are you using IOCTL_INTERNAL_MOUSE_CONNECT and/or
IOCTL_INTERNAL_I8042_HOOK_MOUSE?
Yes, both, but some comment in the example says I can remove the latter
because I only want to filter MOUSE_INPUT_DATA. I didn't remove it.
Post by 4***@email.com
If yes, then this architecture won't work for USB at all (another
reason not to use this sample).
But in x86 it works well, since years! I have two INF files, one for PS2
and one for USB and they both use the same SYS file.
Post by 4***@email.com
Change your architecture to strictly
filter IRPs and delete everything related to such ioctls. You want an
upper class filter. Use the inf suggested and filter the IRP traffic.
It will work consistently with ps2 and USB.
The problem is that I only got it to work because of the MS example
where I only had to change few things - mainly this callback:

MouFilter_ServiceCallback(
IN PDEVICE_OBJECT DeviceObject,
IN PMOUSE_INPUT_DATA InputDataStart,
IN PMOUSE_INPUT_DATA InputDataEnd,
IN OUT PULONG InputDataConsumed
)

Is there anywhere some similar example to filter IRPs the same way?
Post by 4***@email.com
It can work in several ways. A class filter can choose which devices
it wishes to filter and which it does not. It is also be possible to
install it for a specific device rather than as a class. It can also
be installed and/or uninstalled using setup api, dpinst, etc.
Is it possible to let the user install it for only one device just by
right-clicking this one in the devicemanager? Or how can he choose which
one he wants? I hoped not to need some complicated installer.

Thanks for your help,
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
Moritz Franckenstein
2010-11-18 10:40:15 UTC
Permalink
Post by 4***@email.com
Are you using IOCTL_INTERNAL_MOUSE_CONNECT
There is a comment in the MS example saying:

IOCTL_INTERNAL_MOUSE_CONNECT:
Store the old context and function pointer and replace it with our own.
This makes life much simpler than intercepting IRPs sent by the RIT and
modifying them on the way back up.

:)

Since it worked for USB mice for x86, are you sure that it won't work
for x64, just with some appropriate INF file?
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
Moritz Franckenstein
2010-11-18 16:54:51 UTC
Permalink
Post by Moritz Franckenstein
I tried your example out (on a x86 machine) by right-clicking the inf
file and it was installed without any question or any success message.
After installation I found it in the upper class filter of the mouse
driver, but it didn't work.
How to uninstall? Rollback driver isn't available and after uninstalling
the mouse driver itself and reinstalling it, my driver is also back there :)
I still have no idea how to uninstall it. So the broken filter is still
there in my system. Can anyone help?
--
Moritz Franckenstein
mailto:maf-***@gmx.net
http://www.maf-soft.de/
icq: 22030984 y!: maf_soft
Loading...