Reparse directory open with STATUS_REPARSE

I’m trying to redirect listing files from FolderA to FolderB. To achieve that, I’m replacing TargetFileObject in IRP_MJ_PreWrite callback and returning STATUS_REPARSE.

Here’s the code https://paste.ofcode.org/38yqtipSTGiigJepi3AwAgi

Basically, I’m expecting FindFirstFile/ZwQueryDirectoryFile on any folder named hellooWorld to be redirected to C:\Temp folder, but that is not the case. explorer and cmd are throwing errors when I try to access the folder. I assume returning STATUS_REPARSE is not enough and I’m missing something, but I don’t know what. Any help would be greatly appreciated.

Thanks

The simrep WDK sample probably has all the information you need to accomplish this. https://github.com/microsoft/Windows-driver-samples/tree/master/filesys/miniFilter/simrep

Hey Jeremy

Thanks for the reply, but it doesn’t. I’m actually following that example, simplified a lot to see how it works. I can see from DebugView that my driver returns STATUS_REPARSE, but this doesn’t translate to desired behavior mentioned above.

explorer and cmd are throwing errors when I try to access the folder.

What are the errors, when? What does procmon say?

If I were you I’d ignore explorer and concentrate on cmd for not. With that fixed you can start thinking about explorer.

Also, are you happy that you are handling related opens correctly?

You cannot replace the TargetFileObject and return STATUS_REPARSE.
You need to replace the FILENAME of the TargetFileObject (via
IoReplaceFileObjectName) and return STATUS_REPARSE.

Dejan.

I’m trying to redirect listing files from FolderA to FolderB. To achieve
that, I’m replacing TargetFileObject in IRP_MJ_PreWrite callback and
returning STATUS_REPARSE.

Here’s the code https://paste.ofcode.org/38yqtipSTGiigJepi3AwAgi

Basically, I’m expecting FindFirstFile/ZwQueryDirectoryFile on any folder
named hellooWorld to be redirected to C:\Temp folder, but that is not the
case. explorer and cmd are throwing errors when I try to access the folder.
I assume returning STATUS_REPARSE is not enough and I’m missing something,
but I don’t know what. Any help would be greatly appreciated.

Ah, I saw your code now…
sizeof(route) * sizeof(wchar_t)); << this is where your issue is.
You need to use:
sizeof(route) - sizeof(wchar_t));
Basic C there.

Dejan.

On 5/4/20, Dejan Maksimovic <dejan.maksimovic> wrote:
> You cannot replace the TargetFileObject and return STATUS_REPARSE.
> You need to replace the FILENAME of the TargetFileObject (via
> IoReplaceFileObjectName) and return STATUS_REPARSE.
>
> Dejan.
>
>> I’m trying to redirect listing files from FolderA to FolderB. To achieve
>> that, I’m replacing TargetFileObject in IRP_MJ_PreWrite callback and
>> returning STATUS_REPARSE.
>>
>> Here’s the code https://paste.ofcode.org/38yqtipSTGiigJepi3AwAgi
>>
>> Basically, I’m expecting FindFirstFile/ZwQueryDirectoryFile on any folder
>> named hellooWorld to be redirected to C:\Temp folder, but that is not the
>> case. explorer and cmd are throwing errors when I try to access the
>> folder.
>> I assume returning STATUS_REPARSE is not enough and I’m missing
>> something,
>> but I don’t know what. Any help would be greatly appreciated.</dejan.maksimovic>

1 Like

@Dejan_Maksimovic Damn it, thank you so much my friend :))) I would’ve lost hours trying to figure this out.