Hi Don,
Thanks a lot for the answers! One more question.
If MS were to provide an API for hooking, wouldn’t
things be different?
Not as messy at any rate… Right?
Or are filtering just that and more?
If so, more in what way?
Regards,
Manoj
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf
Of Don Burn
Sent: Tuesday, April 13, 2004 6:06 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Filter drivers vs hooking
“Manoj Paul Joseph” wrote in message
news:xxxxx@ntfsd…
I have ‘known’ that writing filter drivers is the
recomended method to hooking filesystem requests.
But I don’t fully understand the reasons.
Manoj,
First off this is system call table hooking,
there are other types of
hooking with various impacts. My list against system
call table hooking is
a follows:
- Many of the calls are undocumented
Bottom line is if you are doing anything more
than the simplest hook,
you will be wandering into areas of undocumented and
changeable calls.
- Call numbers change
While this isn’t bad for ZwCreateFile or others
that are exposed in
the kernel, there are plenty of calls that are not
exposed getting the right
index for the hook is messy.
- No locking on applying the hook
This is a serious problem. If driver A and
driver B both are hooking,
there is nothing stopping a situation of:
System call 1 - Call A’s hook, then Call
B’s hook, then call the
system
System call 2 - Call B’s hook, then Call
A’s hook. then call the
system
Depending what A and B are doing this is a
disaster. And this assumes
that the drivers are smart on their hooking and use
interlocked exchange.
Otherwise you can have situations where A & B stomp on
the others hook.
- Don’t even think about unloading a hook driver
While filter drivers are rarely unloaded,
unloading a hook driver is
a disaster. If anyone hooks above you then that
driver will still try to
call your code with the disasterous results.
Bottomline is that there is absolutely no need to do
something this stupid
when Microsoft gives you a blessed way of handling
things that avoids the
above problems.
–
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/