One good argument for hooking: More context. A filter sees a file being
opened or read through the paging I/O path; a hook can actually tell
that a file was opened with execute access and is now used to create a
section object (again with execution allowed) and is being mapped into
PAGE_EXECUTE memory.
One good argument against hooking: If I were MS, I would break every
hook in every FE or at least SP, just so people cannot come back later
and whine about backwards compatibility. Raymond Chen has some good
(well, not so good) war stories –
http://blogs.msdn.com/oldnewthing/category/2282.aspx is the “history”
category of his blog.
One bad argument against hooking: Some of the original designers of NT
don’t like hooks (and call-backs, and every other way to modify the OS’s
behaviour). I have heard claims about how hooking drivers might make MS
look bad if they are slow or buggy. Well, duh. As if filter drivers were
always as pure as the driven snow.
I’d rather see an official hooking API and/or rich set of call-backs –
and in the dump file header, and every tenth second in the kernel
debugger, there should be fat bold lettering “HOOKS ARE IN USE. IT IS
*THEIR* FAULT” or something to that effect.
Oh well. Unless NT learns to provide a decent interface to its
functionality (from both sides), I am afraid hooks are here to stay. and
as you imply, once a driver is in the system, it can just go and disable
whatever the OS did to make the system service table read-only, up to
patching any run-time validators out of existence. (I can think of
hardware that would be waterproof, but nothing within reach of current
hardware.)
Cheers,
Felix.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Randy Cook
Sent: Tuesday, 26 October 2004 14:17
To: Windows File Systems Devs Interest List
Subject: Re: Understanding Microsoft’s Stance on Hooking (was re:
[ntfsd] Hooksys example… )
Very interesting question. No real answers yet
besides “that’s the way MS does it” (which is a
perfectly valid reason). BTW, if there really is a
security issue with hooking, probably no one who knows
will discuss it here.
Here are some random thoughts:
Security
If I manage to get a kernel driver loaded on a box, I
can own the box. It doesn’t matter what interfaces I
use.
Speed
Seems to me that hooking will always be faster (less
overhead).
Level of Difficulty
Much simpler initially to hook. For example, a driver
that printed out the return code for open calls would
take about 10 lines when hooking vs. a lot more with a
filter. Once the complexity of the driver reaches a
certain point, this isn’t very important. Don’t know
how a mini-filter would do here.
Interop
What are the main issues with interop between drivers?
Here are some I’ve seen:
- Recursion
- Stack usage
- Context
Seems to me that all of these do better in a hooking
model.
Completion and Context
Simpler to call the routine below you and deal with
the return in the same function rather than
registering a completion routine, high IRQLs, worker
threads, etc. Of course, syncing back to the dispatch
routine is pretty simple and similar to the hooking
model…
Stability
With a proper hooking API this can be stable.
Functionality Coverage
The good thing with hooking is that you have access to
all functionality…no need to have MS provide an
interface. The bad thing with hooking is that you
have access to all functionalilty without MS providing
you an interface 
Unloading
This can be done more easily with hooking. What’s one
of the main reasons filter drivers can’t unload: They
have registered a completion routine in an IRP that is
below them. With a hook, you can get out anytime,
unless you need to undo changes you have made to
requests that have been sent down… This would of
course assume a proper unhook API or methodology.
It would be interesting to have someone familiar with
the filter manager detail how it addresses some of
these issues.
I’m sure there are some things that I’m not thinking
about. The grass is always greener…right?
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@mvps.org
To unsubscribe send a blank email to xxxxx@lists.osr.com