Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Reparse directory open with STATUS_REPARSE

dato0011dato0011 Member Posts: 11

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

Comments

  • Jeremy_HurrenJeremy_Hurren Member - All Emails Posts: 17

    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

  • dato0011dato0011 Member Posts: 11

    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.

  • rod_widdowsonrod_widdowson Member - All Emails Posts: 1,121

    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?

  • Dejan_MaksimovicDejan_Maksimovic Member - All Emails Posts: 303
    via Email
    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_MaksimovicDejan_Maksimovic Member - All Emails Posts: 303
    via Email
    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 <[email protected]> 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.
  • dato0011dato0011 Member Posts: 11

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

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA