Folder redirection in minifiler driver

I have one question regarding the folder redirection implementation from
minifiler driver.

What I want to achieve is that when an application opens a folder c:\x\y
and access files and subfolders from there, my minifilter driver wants to
redirect the folder to c:\a\b and access the files and subfolders from the
redirected folder.

My driver is developed based on WINDK sample simrep which is to redirect a
file access to anther file. But when I redirect a folder to another, it
does not work. Can anyone tell me if I can achieve my goal using the
minifiler driver? If I cannot use the minifilter driver, what is an
alternative approach to do that?

If I can redirect a folder access to another using the miniflter driver,
what should I do besides to change the “TargetFileObject” (simrep uses this
method to redirect a file access)?

You can register a pre-op callback for IRP_MJ_CREATE, swap TargetFileObject->FileName with your own UNICODE_STRING and pass it on.
Then register a post-op callback for IRP_MJ_CREATE and swap back the original UNICODE_STRING. This means you’ll have to save the original in pre-op, and pass it to post-op via the CompletionContext.

Not 100% sure about this though, since I’m pretty new to driver development.

Why do you need to restore the original folder name in post-op of
IRP_MJ_CREATE? I actually did change the new folder name in pre-op of
IRP_MJ_CREATE but it did not work. My code can redirect to another file
without any problem. Redirecting to another folder seem to be the same as
redirecting to another file. But it does not work this way.

On Friday, August 16, 2013, wrote:

You can register a pre-op callback for IRP_MJ_CREATE, swap
TargetFileObject->FileName with your own UNICODE_STRING and pass it on.
Then register a post-op callback for IRP_MJ_CREATE and swap back the
original UNICODE_STRING. This means you’ll have to save the original in
pre-op, and pass it to post-op via the CompletionContext.

Not 100% sure about this though, since I’m pretty new to driver
development.


NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Swapping back allows the allocater of the original UNICODE_STRING to free it. If you don’t swap it back then you’ll leak memory. Furthermore it may mess up any filter drivers above yours if they are using the FileName in post-op.

Don’t know why it doesn’t work for folders though, will have to wait for one of the veterans to reply.

Ok, I see your points. The new driver in Vista or latter has an API to call to replace the Filename.
Thus, the memory of UNICODE string is maintained already.

從我的 iPad 傳送

xxxxx@hotmail.com 於 Aug 17, 2013 12:56 AM 寫道:

Swapping back allows the allocater of the original UNICODE_STRING to free it. If you don’t swap it back then you’ll leak memory. Furthermore it may mess up any filter drivers above yours if they are using the FileName in post-op.

Don’t know why it doesn’t work for folders though, will have to wait for one of the veterans to reply.


NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Normally, when you want replace a Unicode string, you need to check the buffer size. If it is too small, you need to free the buffer and allocate the a new one.Otherwise, you simply replace the string using the existing buffer. The unicode buffer finally will be free by the filter manager.
I don’t think you need to replace the original name at post-op of IRP_MJ_CREATE.

xxxxx@hotmail.com 於 Aug 17, 2013 12:56 AM 寫道:

Swapping back allows the allocater of the original UNICODE_STRING to free it. If you don’t swap it back then you’ll leak memory. Furthermore it may mess up any filter drivers above yours if they are using the FileName in post-op.

Don’t know why it doesn’t work for folders though, will have to wait for one of the veterans to reply.


NTFSD is sponsored by OSR

OSR is hiring!! Info at http://www.osr.com/careers

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Are you handling all the accesses to the redirected folder? For example
you have the normal access when the caller wants to open c:\x\y but then
it also will perform opens on c:\x\y\foo.txt. Are you handling all these
cases? What about relative opens on the folder?

My point being, how are you determining when to perform the update of
the TFO? For several of the cases, a swap of these won’t work like in
the case where the caller tries to open c:\x\y\foo.txt.

Pete

On 8/16/2013 3:44 PM, Charles Tsai wrote:

I have one question regarding the folder redirection implementation from
minifiler driver.

What I want to achieve is that when an application opens a folder c:\x\y
and access files and subfolders from there, my minifilter driver wants
to redirect the folder to c:\a\b and access the files and subfolders
from the redirected folder.

My driver is developed based on WINDK sample simrep which is to redirect
a file access to anther file. But when I redirect a folder to another,
it does not work. Can anyone tell me if I can achieve my goal using the
minifiler driver? If I cannot use the minifilter driver, what is an
alternative approach to do that?

If I can redirect a folder access to another using the miniflter driver,
what should I do besides to change the “TargetFileObject” (simrep uses
this method to redirect a file access)?
— NTFSD is sponsored by OSR OSR is hiring!! Info at
http://www.osr.com/careers For our schedule of debugging and file system
seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295

I think that FlgMgr has the Namespace Provider support, this is what you should implement.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com
“Charles Tsai” wrote in message news:xxxxx@ntfsd…
I have one question regarding the folder redirection implementation from minifiler driver.

What I want to achieve is that when an application opens a folder c:\x\y and access files and subfolders from there, my minifilter driver wants to redirect the folder to c:\a\b and access the files and subfolders from the redirected folder.

My driver is developed based on WINDK sample simrep which is to redirect a file access to anther file. But when I redirect a folder to another, it does not work. Can anyone tell me if I can achieve my goal using the minifiler driver? If I cannot use the minifilter driver, what is an alternative approach to do that?

If I can redirect a folder access to another using the miniflter driver, what should I do besides to change the “TargetFileObject” (simrep uses this method to redirect a file access)?

I expect that the file system is able to read files and sub folders from a redirected folder. In other words, minifilter driver need not to redirect each file and sub folder after the parent folder is redirected.

從我的 iPad 傳送

Peter Scott 於 Aug 18, 2013 6:21 AM 寫道:

>
> Are you handling all the accesses to the redirected folder? For example you have the normal access when the caller wants to open c:\x\y but then it also will perform opens on c:\x\y\foo.txt. Are you handling all these cases? What about relative opens on the folder?
>
> My point being, how are you determining when to perform the update of the TFO? For several of the cases, a swap of these won’t work like in the case where the caller tries to open c:\x\y\foo.txt.
>
> Pete
>
> On 8/16/2013 3:44 PM, Charles Tsai wrote:
>> I have one question regarding the folder redirection implementation from
>> minifiler driver.
>>
>> What I want to achieve is that when an application opens a folder c:\x\y
>> and access files and subfolders from there, my minifilter driver wants
>> to redirect the folder to c:\a\b and access the files and subfolders
>> from the redirected folder.
>>
>> My driver is developed based on WINDK sample simrep which is to redirect
>> a file access to anther file. But when I redirect a folder to another,
>> it does not work. Can anyone tell me if I can achieve my goal using the
>> minifiler driver? If I cannot use the minifilter driver, what is an
>> alternative approach to do that?
>>
>> If I can redirect a folder access to another using the miniflter driver,
>> what should I do besides to change the “TargetFileObject” (simrep uses
>> this method to redirect a file access)?
>> — NTFSD is sponsored by OSR OSR is hiring!! Info at
>> http://www.osr.com/careers For our schedule of debugging and file system
>> seminars visit: http://www.osr.com/seminars To unsubscribe, visit the
>> List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
> –
> Kernel Drivers
> Windows File System and Device Driver Consulting
> www.KernelDrivers.com
> 866.263.9295
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system seminars visit: http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Is there a sample on the WinDk?

從我的 iPad 傳送

“Maxim S. Shatskih” 於 Aug 18, 2013 12:32 PM 寫道:

> I think that FlgMgr has the Namespace Provider support, this is what you should implement.
>
> –
> Maxim S. Shatskih
> Microsoft MVP on File System And Storage
> xxxxx@storagecraft.com
> http://www.storagecraft.com
> “Charles Tsai” wrote in message news:xxxxx@ntfsd…
> I have one question regarding the folder redirection implementation from minifiler driver.
>
> What I want to achieve is that when an application opens a folder c:\x\y and access files and subfolders from there, my minifilter driver wants to redirect the folder to c:\a\b and access the files and subfolders from the redirected folder.
>
> My driver is developed based on WINDK sample simrep which is to redirect a file access to anther file. But when I redirect a folder to another, it does not work. Can anyone tell me if I can achieve my goal using the minifiler driver? If I cannot use the minifilter driver, what is an alternative approach to do that?
>
> If I can redirect a folder access to another using the miniflter driver, what should I do besides to change the “TargetFileObject” (simrep uses this method to redirect a file access)?
>
> —
> NTFSD is sponsored by OSR
>
> OSR is hiring!! Info at http://www.osr.com/careers
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes there is a sample. It is called ?NameChanger?.

Tony
OSR