hugomind said:
The Eventlog is not an option in this case, any sysadmin could disable
it, but why does an fs filter driver not work ? How does filemon from
sysinternals solve this problem ?
thnx,
Hugo
Oh I see, you don't trust your Admins, installing a FS Filter driver won't
help you because Admins can uninstall them easily, or they can run as
(command "runas") some other user and do whatever they like on their behalf.
That said, Filemon (a tool now replaced by Process Monitor) is a complex
diagnostics tool (something you should not write using managed code) that
uses a FS Filter driver (something you can't write using managed code) to
capture IRP and FASTIO requests and pass the parsed contents back to a user
portion of the program that keeps track of the running processes and their
corresponding file handles. The file info is obtained by peeking in the
running processes handle table in order to find the file object
corresponding to the file handle. Here you have your first issue, where to
find the handle table in a running process? there are no documented API's
for this, the author of the tool knows the internal API's and how to use
them and when. The second issue is related to impersonation, the tool can
only catch the UserId of the process issuing the IO request, not the ID of
the thread in case of an impersonated thread. So in case of an impersonated
client, you are getting the process UserId, not the ID of the issuing
client.
And a third issue is that you'll need to process *sequences* of IRP's in
order to know exactly what's happening to a File. For instance when deleting
a File, an IRP_MJ_SETINFORMATION is sent down the IO stack followed by an
IRP_MJ_CLEANUP and an IRP_MJ_CLOSE, these events do not necessarily follow
each other directly, the sequence can get intermixed by other events AND you
need to keep track of the return status of each event in the sequence. This
means processing overhead, especially on a busy system.
Supposing you can solve all above issues, you still need to trust your
Admins not to kill this process, so why not simply trust them and use the
File Systems auditing facility which was specially made for such task?
Willy.