a problem about hide file

Hi:
i met a problem when i hide file.
i use the method presented on list and every one knows.use
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY and do the hide file job
in completion routine.but the filename in FILE_BOTH_DIR_INFORMATION is a
relative file name(e.g.: fullpathname is d:\osr\osr.txt, when query the
d:\osr directory, the filename is osr.txt).
so the problem occurs,if i set the hiden file name to osr.txt, i can hide
the d:\osr\osr.txt. but d:\osr.txt, or all files in any other place if its
name is osr.txt will be hiden too.
so i use the full path name to solve this problem. i get the full path
name of the queried directory (for example: d:\osr), and when i get a
file name from FILE_BOTH_DIR_INFORMATION type buffer returned by
IRP_MN_QUERY_DIRECTORY, i get the file’s full path name by “the full path
name of the queried directory” + “file name”. and check whether it need to
be hiden. and i am successful!
but i find, in explorer, when i enter the d:\osr, i can’t see osr.txt
file,but if i click right mouse button and select “refresh”, the hiden
osr.txt file appear.why this problem occurs? can anyone help me? think
you!

Put a breakpoint in your handler and see why you are
not hiding the entry the second time around. When you
do a refresh, explorer does another enumeration.

BTW, you need to handle the other query formats
besides FILE_BOTH_DIR_INFORMATION. Some apps, like MS
Office installer, use them directly.

Randy

— deltali wrote:
> Hi:
> i met a problem when i hide file.
> i use the method presented on list and every one
> knows.use
> IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY and
> do the hide file job
> in completion routine.but the filename in
> FILE_BOTH_DIR_INFORMATION is a
> relative file name(e.g.: fullpathname is
> d:\osr\osr.txt, when query the
> d:\osr directory, the filename is osr.txt).
> so the problem occurs,if i set the hiden file name
> to osr.txt, i can hide
> the d:\osr\osr.txt. but d:\osr.txt, or all files in
> any other place if its
> name is osr.txt will be hiden too.
> so i use the full path name to solve this problem. i
> get the full path
> name of the queried directory (for example:
> d:\osr), and when i get a
> file name from FILE_BOTH_DIR_INFORMATION type buffer
> returned by
> IRP_MN_QUERY_DIRECTORY, i get the file’s full path
> name by “the full path
> name of the queried directory” + “file name”. and
> check whether it need to
> be hiden. and i am successful!
> but i find, in explorer, when i enter the d:\osr, i
> can’t see osr.txt
> file,but if i click right mouse button and select
> “refresh”, the hiden
> osr.txt file appear.why this problem occurs? can
> anyone help me? think
> you!
>
> —
> You are currently subscribed to ntfsd as:
> xxxxx@yahoo.com
> To unsubscribe send a blank email to
xxxxx@lists.osr.com

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

Hash cache, probably… make sure you don’t have ANY stale information
(unless you use the method presented in NTInsider article you probably will!),
as that would cause incorrect file names to be generated.

deltali wrote:

Hi:
i met a problem when i hide file.
i use the method presented on list and every one knows.use
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY and do the hide file job
in completion routine.but the filename in FILE_BOTH_DIR_INFORMATION is a
relative file name(e.g.: fullpathname is d:\osr\osr.txt, when query the
d:\osr directory, the filename is osr.txt).
so the problem occurs,if i set the hiden file name to osr.txt, i can hide
the d:\osr\osr.txt. but d:\osr.txt, or all files in any other place if its
name is osr.txt will be hiden too.
so i use the full path name to solve this problem. i get the full path
name of the queried directory (for example: d:\osr), and when i get a
file name from FILE_BOTH_DIR_INFORMATION type buffer returned by
IRP_MN_QUERY_DIRECTORY, i get the file’s full path name by “the full path
name of the queried directory” + “file name”. and check whether it need to
be hiden. and i am successful!
but i find, in explorer, when i enter the d:\osr, i can’t see osr.txt
file,but if i click right mouse button and select “refresh”, the hiden
osr.txt file appear.why this problem occurs? can anyone help me? think
you!


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.

File can be hidden exactly in this way, I think your problem is in the
comparing of the file what need to be hidden. file list in
FILE_BOTH_DIR_INFORMATION returned by IRP_MN_QUERY_DIRECTORY may be
different even for the same directory without file add/removed, you must
do with the following condition as well:

  1. The file you want to hide is the 1st entry in
    FILE_BOTH_DIR_INFORMATION;
  2. The file you want to hide is one of the middle entry in
    FILE_BOTH_DIR_INFORMATION;
  3. The file you want to hide is the last entry in
    FILE_BOTH_DIR_INFORMATION.
    Change FILE_BOTH_DIR_INFORMATION structure properly, you’ll work out.
    UNC path compare may mislead you either, note "??" prefix.

Hi:
i met a problem when i hide file.
i use the method presented on list and every one knows.use
IRP_MJ_DIRECTORY_CONTROL/IRP_MN_QUERY_DIRECTORY and do the hide file job
in completion routine.but the filename in FILE_BOTH_DIR_INFORMATION is a
relative file name(e.g.: fullpathname is d:\osr\osr.txt, when query the
d:\osr directory, the filename is osr.txt).
so the problem occurs,if i set the hiden file name to osr.txt, i can hide
the d:\osr\osr.txt. but d:\osr.txt, or all files in any other place if its
name is osr.txt will be hiden too.
so i use the full path name to solve this problem. i get the full path
name of the queried directory (for example: d:\osr), and when i get a
file name from FILE_BOTH_DIR_INFORMATION type buffer returned by
IRP_MN_QUERY_DIRECTORY, i get the file’s full path name by “the full path
name of the queried directory” + “file name”. and check whether it need to
be hiden. and i am successful!
but i find, in explorer, when i enter the d:\osr, i can’t see osr.txt
file,but if i click right mouse button and select “refresh”, the hiden
osr.txt file appear.why this problem occurs? can anyone help me? think
you!

thanks for all your reply.
today i know more about this problem. because windows 2000 add some string
to the files in current directory which we cann’t see.
now i can hide file with different extension successful. but if i hide
file osr.txt, the file osr.txt** also hide too. I don’t know how to solve
this problem, because i don’t know the str after osr.txt is added by
windows 2000 or added by the user? can somebody know how to solve this
problem?
appreciate!!!

It sounds like you might be treating the UNICODE filename strings as
zero terminated rather than using the string length field. You will
also see this if your code uses the UNICODE string length as the
number of characters rather than the number of bytes in the string.

On Thu, 30 Oct 2003 04:49:21 -0500, “deltali”
wrote:
>thanks for all your reply.
>today i know more about this problem. because windows 2000 add some string
>to the files in current directory which we cann’t see.
>now i can hide file with different extension successful. but if i hide
>file osr.txt, the file osr.txt** also hide too. I don’t know how to solve
>this problem, because i don’t know the str after osr.txt is added by
>windows 2000 or added by the user? can somebody know how to solve this
>problem?
>appreciate!!!
>