A Different View....

Hi All,

I wish to show a single view of all the files which are in C: or in E:
drive, i.e.
I have C:\EXE containing files 1.txt and 2.txt and I have E:\EXE
containing files 3.txt.
Now in explorer where I have hidden E drive I wish to show C:\EXE as
containing 1.txt, 2.txt and 3.txt

I am doing it by catching the IRP_MJ_DIRECTORY_CONTROL and modifying the
userbuffer to include other entries. But it is throwing errors.
Is there any other method then the one I am adopting.

Thanks and Regards,
Lalit

Your method is correct, but, you are doing something wrong - depending on the
error:

  • Calling the wrong device object to get E:\Exe folder entries. Probably not
    this…
  • Returning the wrong error code?
  • Not setting Irp->IoStatus.Information field?
  • Not setting the last entry’s NextEntryOffset field?
  • Using the SAME buffer to enumerate the E:\Exe directory!

IMO, this should go as:

  • Enumerate C:\Exe until the FS returns STATUS_NO_MORE_FILES (or
    STATUS_NO_SUCH_FILE). If it returns STATUS_SUCCESS, just pass it back.
  • When you get an error status (the above two only, others can mean I/O
    errors), then resend the IRP to the E: device object, and have it enumerate the
    directory entries. In essence, I think you only need to specify a different device
    object AND set the SL_RESTART_SCAN bit, otherwise, the FS will return an error!
    You need not do anything else, in this scenario (as far as I can tell, but I
    never TESTed it)

This requires handling IRP by returning STATUS_MORE_PROCESSING_REQUIRED from
your completion, and calling IoCompleteRequest afterwards.

Regards, Dejan.

“Lalit S. Rana” wrote:

Hi All,

I wish to show a single view of all the files which are in C: or in E:
drive, i.e.
I have C:\EXE containing files 1.txt and 2.txt and I have E:\EXE
containing files 3.txt.
Now in explorer where I have hidden E drive I wish to show C:\EXE as
containing 1.txt, 2.txt and 3.txt

I am doing it by catching the IRP_MJ_DIRECTORY_CONTROL and modifying the
userbuffer to include other entries. But it is throwing errors.
Is there any other method then the one I am adopting.

Thanks and Regards,
Lalit


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Hi Dejan,
Thanks, I got a whole lot of clues from your suggestions.
Earlier I was attaching the entries in the same user buffer but now I
think I will go by your method i.e. to restart the scan once the scan is
completed.
Thanks and Regards,
Lalit

Dejan,
If there are two folders C:\Exe\one\ and E:\EXE\one
then would your algorithm tackle that issue.
What would happen in that case,
moreover the listing won’t be sorted.
Please tell
Thanks
Lalit

What do you mean?
If the user lists C:\Exe\One then you want to list files in
E:\Exe\One as well? Yeah, this will work - just make sure you know what
type of pattern handling you do when you decide whether to list another
directory.

“Lalit S. Rana” wrote:

Dejan,
If there are two folders C:\Exe\one\ and E:\EXE\one
then would your algorithm tackle that issue.
What would happen in that case,
moreover the listing won’t be sorted.
Please tell
Thanks
Lalit


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa File Monitor - File monitoring library for Win32 developers.

I think Lalit wants to ask what’s gonna happen if you return 2 entries with
the same name. I never worked on this kind of FSFD but I think you must
handle this situation in your algorithm. And as to listing order, FastFat
won’t sort directory contents too. NTFS would (but it always stores
directories alphabetically ordered).

And my own observation: if you start directory enum on FAT volume and other
thread at this time modifies contents of enumerated directory (i.e. creates
and deletes files), the changes are reflected immediately. NTFS seems to
create directory snapshot when you start enumeration. Are my observations
right?

-htfv

----- Original Message -----
From: “Dejan Maksimovic”
To: “File Systems Developers”
Sent: Friday, June 06, 2003 10:37 PM
Subject: [ntfsd] Re: A Different View…

>
> What do you mean?
> If the user lists C:\Exe\One then you want to list files in
> E:\Exe\One as well? Yeah, this will work - just make sure you know what
> type of pattern handling you do when you decide whether to list another
> directory.
>
> “Lalit S. Rana” wrote:
>
> > Dejan,
> > If there are two folders C:\Exe\one\ and E:\EXE\one
> > then would your algorithm tackle that issue.
> > What would happen in that case,
> > moreover the listing won’t be sorted.
> > Please tell
> > Thanks
> > Lalit
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> –
> Kind regards, Dejan M. MVP for DDK
> http://www.alfasp.com E-mail: xxxxx@alfasp.com
> Alfa Transparent File Encryptor - Transparent file encryption services.
> Alfa File Protector - File protection and hiding library for Win32
> developers.
> Alfa File Monitor - File monitoring library for Win32 developers.
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@vba.com.by
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Two entries with the same name will be seen by any user-mode application.
Directory buffers are unsorted (though there might be an order caused by the
fs internal file management), sorting is done by explorer. I recommend
reading both buffers and constructing a new buffer containing your view of
the directory.

----- Original Message -----
From: “Alexey Logachyov”
To: “File Systems Developers”
Sent: Friday, June 06, 2003 10:34 PM
Subject: [ntfsd] Re: A Different View…

> I think Lalit wants to ask what’s gonna happen if you return 2 entries
with
> the same name. I never worked on this kind of FSFD but I think you must
> handle this situation in your algorithm. And as to listing order, FastFat
> won’t sort directory contents too. NTFS would (but it always stores
> directories alphabetically ordered).
>
> And my own observation: if you start directory enum on FAT volume and
other
> thread at this time modifies contents of enumerated directory (i.e.
creates
> and deletes files), the changes are reflected immediately. NTFS seems to
> create directory snapshot when you start enumeration. Are my observations
> right?
>
> -htfv
>
>
> ----- Original Message -----
> From: “Dejan Maksimovic”
> To: “File Systems Developers”
> Sent: Friday, June 06, 2003 10:37 PM
> Subject: [ntfsd] Re: A Different View…
>
>
> >
> > What do you mean?
> > If the user lists C:\Exe\One then you want to list files in
> > E:\Exe\One as well? Yeah, this will work - just make sure you know what
> > type of pattern handling you do when you decide whether to list another
> > directory.
> >
> > “Lalit S. Rana” wrote:
> >
> > > Dejan,
> > > If there are two folders C:\Exe\one\ and E:\EXE\one
> > > then would your algorithm tackle that issue.
> > > What would happen in that case,
> > > moreover the listing won’t be sorted.
> > > Please tell
> > > Thanks
> > > Lalit
> > >
> > > —
> > > You are currently subscribed to ntfsd as: xxxxx@alfasp.com
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> > –
> > Kind regards, Dejan M. MVP for DDK
> > http://www.alfasp.com E-mail: xxxxx@alfasp.com
> > Alfa Transparent File Encryptor - Transparent file encryption services.
> > Alfa File Protector - File protection and hiding library for Win32
> > developers.
> > Alfa File Monitor - File monitoring library for Win32 developers.
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@vba.com.by
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@linkwave.org
> To unsubscribe send a blank email to xxxxx@lists.osr.com

> I think Lalit wants to ask what’s gonna happen if you return 2 entries with

the same name. I never worked on this kind of FSFD but I think you must
handle this situation in your algorithm.

Ahh! This would be VERY hard to handle…

And my own observation: if you start directory enum on FAT volume and other
thread at this time modifies contents of enumerated directory (i.e. creates
and deletes files), the changes are reflected immediately. NTFS seems to
create directory snapshot when you start enumeration. Are my observations
right?

If you mean FindFirst/NextFile APIs, it seems that THESE make the
snapshot - or maybe it’s just because of the big buffer.
I don’t think NTFS makes a snapshot, because it is easy to have
millions of files in one directory, so that would take too much memory, if one
just needs to find the first file. Would be very unoptimized. It might have a
snapshot, for just a few blocks (say 64 KB buffer), but one can’t tell this for
sure.


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32 developers.
Alfa File Monitor - File monitoring library for Win32 developers.