Hi,
I have an issue I’ve been banging my head against and thought I’d post up for thoughts/comments.
I’m currently writing a file redirect mini filter, which watches IRP_MJ_CREATE operations for certain processes, and re-directs IRP_MJ_CREATE operations made by those processes under a specified directory, to a target directory.
Unfortunately for me, my current version is an abject failure.
For example, lets say I have a VisualStudio project, which I would like to redirect all compile output for, just as a test, thus:
C:\Temp\Source\TestApp\
stdafx.h
stdafx.cpp
MyTest.sln
MyTest.vcproj
D:\Temp\Target\TestApp\
stdafx.h
stdafx.cpp
…
MyTest.sln
MyTest.vcproj
Now, to get things going, I specify the process i’d like to track, PID=3378, and give the source and target directories
Src=C:\Temp\Source, Tgt=D:\Temp\Target
to my API
The mini filter will now track all file iop made by the process PID, and optionally any iop made by child processes that PID generates. All IRP_MJ_CREATE io events with relevant directories are re-directed via FltSetCallbackDataDirty and FLT_PREOP_COMPLETE.
All good so far? OK, as far as I’m aware, one is not allowed to re-direct anything other than IRP_MJ_CREATE. So currently that’s all that I re-direct.
With the directory structure as above, and PID=VisualStudio, a compile produces quite a large number of IOP events, many CREATE ops which are re-directed, for example:
1
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result Success
File C:\Temp\Source\TestApp\Debug
2
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result Success
File C:\Temp\Target\TestApp\Debug
3
Process devenv.com
Major Code IRP_MJ_DIRECTORY_CONTROL
Minor Code IRP_MN_QUERY_DIRECTORY
Result NO_SUCH_FILE
File C:\Temp\Target\TestApp\Debug
quite a large number of…
k
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result Success
File C:\Temp\Source\TestApp\Debug\vc80.pdb
k+1
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result OBJECT_NAME_NOT_FOUND
File C:\Temp\Target\TestApp\Debug\vc80.pdb
and a whole bunch of other exciting records which I wont bore you with here.
The interesting part is the records concening vc80.pdb
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result OBJECT_NAME_NOT_FOUND
File C:\Temp\Source\TestApp\Debug\vc80.pdb
which occur a number of times down the list of events.
Along with a bunch of
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result OBJECT_PATH_NOT_FOUND
File C:\Temp\Source\TestApp\Debug\vc80.idb
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result OBJECT_PATH_NOT_FOUND
File C:\Temp\source\testapp\debug\stdafx.obj
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result OBJECT_PATH_NOT_FOUND
File C:\Temp\source\testapp\debug\TestAppView.obj
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result OBJECT_PATH_NOT_FOUND
File C:\Temp\source\testapp\debug\TestAppDoc.obj
The result is a compile failure.
Microsoft (R) Visual Studio Version 8.0.50727.762.
Copyright (C) Microsoft Corp 1984-2005. All rights reserved.
------ Build started: Project: TestApp, Configuration: Debug Win32 ------
TestApp : error PRJ0007 : Could not create output directory ‘c:\temp\source\testapp\debug’.
Compiling…
cl : Command line warning D9028 : minimal rebuild failure, reverting to normal build
stdafx.cpp
c:\temp\source\testapp\stdafx.cpp : fatal error C1033: cannot open program database ‘c:\temp\source\testapp\debug\vc80.pdb’
TestApp - 2 error(s), 1 warning(s)
The resulting directory structure looks like this…
C:\Temp\Source\TestApp\
stdafx.h
stdafx.cpp
MyTest.sln
MyTest.vcproj
D:\Temp\Target\TestApp\
Debug
BuildLog.htm
TestApp.exe.embed.manifest
stdafx.h
stdafx.cpp
MyTest.sln
MyTest.vcproj
OK, so a bit of head scratching later I noticed that if I created a \Debug directory in the source, the build works, but unfortunately the source \Debug folder contains the following three files:
C:\Temp\Source\TestApp\Debug
TestApp.pdb
vc80.idb
vc80.pdb
(the destination contains the following files:)
D:\Temp\Target\TestApp\Debug
BuildLog.htm
MainFrm.obj
mt.dep
stdafx.obj
TestApp.exe
TestApp.exe.embed.manifest
TestApp.exe.embed.manifest.res
TestApp.exe.intermediate.manifest
TestApp.ilk
TestApp.obj
TestApp.pch
TestApp.res
TestAppDoc.obj
TestAppView.obj
The events that create the idb
Process devenv.com
Major Code IRP_MJ_NETWORK_QUERY_OPEN
Minor Code
Result Success
File C:\Temp\Source\TestApp\Debug\vc80.idb
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result Success
File C:\Temp\Source\TestApp\Debug\vc80.idb
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result OBJECT_NAME_NOT_FOUND
File D:\Temp\Source\TestApp\Debug\vc80.idb
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result Success
File C:\Temp\Source\TestApp\Debug\vc80.idb
Process devenv.com
Major Code IRP_MJ_CREATE
Minor Code
Result OBJECT_NAME_NOT_FOUND
File D:\Temp\Source\TestApp\Debug\vc80.idb
However all events captured for vc80.pdb fail with OBJECT_PATH_NOT_FOUND, yet it’s still created in Source. Very odd.
So, these pdb, idb files are not being re-directed / re-located correctly, obviously as I’m not intercepting IRP_MJ_NETWORK_QUERY_OPEN (perhaps?) and re-directing it.
Could this be the reason, or is it something more subtle (I suspect so).
Am I missing a re-direction event along the way? Or is this actually indicative of ‘something that’s not possible’?
Some relevant points - My filter is running on WinXP at altitude 40100 as a test in order to try to redirect the filename before any other filters get at it. The result codes shown above are written during PostOp
Apologies for the longish post. I’m wondering whether anyone has come across this type of issue before?
Many thanks
Mike