How should I implement IOCTL_REDIR_QUERY_PATH to support UNC?

I’m making a network redirector and would like to support UNC.
To support UNC I should implement IOCTL_REDIR_QUERY_PATH. I have read the document but can’t understand what LengthAccepted means. Suppose my unc name is \a\b and receive the control code with the path string \a\b\c.txt. Then what should I fill the LengthAccepted variable?

(I called FsRtlRegisterUncProvider successfully and have implemented network provider dll)

MUP will end up cashing the portion you specify as accepted and thus any
other path which contains that prefix will be immediately resolved and
not be processed via this IOCtl request. In your example, if you were to
specify a length of 4, 2 UNICODE characters, hence the \a, MUP will
cache this internally for a period of time, 15 minutes if I remember
correctly. For this period of time, any path which comes in that begins
with \a will be sent directly to your redirector without any further
name resolution via the IOCtl.

Pete

On 3/16/2012 3:35 AM, xxxxx@gmail.com wrote:

I’m making a network redirector and would like to support UNC.
To support UNC I should implement IOCTL_REDIR_QUERY_PATH. I have read the document but can’t understand what LengthAccepted means. Suppose my unc name is \a\b and receive the control code with the path string \a\b\c.txt. Then what should I fill the LengthAccepted variable?

(I called FsRtlRegisterUncProvider successfully and have implemented network provider dll)


NTFSD is sponsored by OSR

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

Okay, I understood. I’ll retry it.
Thank you Peter.

I implemented returning LengthAccepted variable always 4 bytes if the path string begins with ‘\a’.
Then I receive IRP_MJ_CREATE with the path like begining with ‘\a\b\c.txt’ (IOCTL_REDIR_QUERY_PATH control code is not issued anymore -maybe during cache time you said)
At here, I have no idea what should I do next. Is it okay if I just trim ‘\a\b’ and pass the remain path to CREATE dispatch routine continually? Or should I learn something like STATUS_REPARSE to receive a Irp with correct path?

This is as expected. You need to parse the name accordingly and process
the request. The entire name is passed into the IRP_MJ_CREATE dispatch
handler so one can differentiate paths to different servers, etc.

Depending on your implementation of how the paths are handled, you could
parse off the beginning server\share portion and pass the remainder to
your handler routine.

Pete

On 3/18/2012 9:10 PM, xxxxx@gmail.com wrote:

I implemented returning LengthAccepted variable always 4 bytes if the path string begins with ‘\a’.
Then I receive IRP_MJ_CREATE with the path like begining with ‘\a\b\c.txt’ (IOCTL_REDIR_QUERY_PATH control code is not issued anymore -maybe during cache time you said)
At here, I have no idea what should I do next. Is it okay if I just trim ‘\a\b’ and pass the remain path to CREATE dispatch routine continually? Or should I learn something like STATUS_REPARSE to receive a Irp with correct path?


NTFSD is sponsored by OSR

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

>This is as expected.
Okay, clear. That’s what I wanted to know. Actually I expected I will get the path ‘\c.txt’

But there is a weird thing.
How should I distinguish UNC path and normal(with dosdevice like Z:) path?
Maybe you already know what I mean, however, for the clearness. Let’s suppose again, is A, and is B.

1. CreateFile(L"\A\B\c.txt", …); // Please do not care the escaping at here.
2. CreateFile(L"Z:\A\B\c.txt", …);

I guess the two irps have a same path. Then how should I do?
In my IRP_MJ_CREATE dispatch routine I can’t guess anything this is UNC or NOT.

Run filespy accessing a drive mapped UNC path and you will see the
difference. The names passed in for UNC access and drive letter mapped
UNC paths are different.

Pete

On 3/20/2012 12:19 AM, xxxxx@gmail.com wrote:

> This is as expected.
Okay, clear. That’s what I wanted to know. Actually I expected I will get the path ‘\c.txt’

But there is a weird thing.
How should I distinguish UNC path and normal(with dosdevice like Z:) path?
Maybe you already know what I mean, however, for the clearness. Let’s suppose again, is A, and is B.
>
>
> 1. CreateFile(L"\A\B\c.txt", …); // Please do not care the escaping at here.
> 2. CreateFile(L"Z:\A\B\c.txt", …);
>
> I guess the two irps have a same path. Then how should I do?
> In my IRP_MJ_CREATE dispatch routine I can’t guess anything this is UNC or NOT.
>
> —
> NTFSD is sponsored by OSR
>
> 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

Peter, really appreciate for your answer.
I have implemented as you said. And the requests by UNC are handled well now.

But it has a problem I haven’t solved yet.
I think this is the last problem.

I said UNC path requests are handled well. I can all operations ‘Open, Create, Rename, Delete, Listing etc’ with UNC path now.
But on Windows Explorer(XP and Vista and later), when I type ‘\my-server-name\my-share-name’ on its address bar, it doesn’t navigate to the path I requested(Error message occurs. 'can not find ‘\my-server-name\my-share-name’ blablabla)

To find what’s wrong, I opened the ‘\my-server-name\my-share-name’ path with FILE_BACKUP_SEMANTIC by filetest tool(I guessed you might know this tool). Yes it was opened well. And I sent query directory IRP for listing. It works well too. The files are listed well. I don’t have any idea what is wrong.

A weird thing is the IRPs which have the path like ‘\my-server-name\IPC$’, ‘\my-server-name\PIPE\xxx’. What’s that?
When I type my UNC path on Windows Explorer, these IRPs come. Lanmanager handle those as STATUS_SUCCESS. But my redirector handle thosse STATUS_PATH_NOT_FOUND or STATUS_NOT_IMPLEMENTED. I didn’t think this is a problem. But I’m not sure anymore.

Do you have any idea?