Solved

Enumerate files and folders in NTFS

Posted on 2004-04-06
11
1,154 Views
Last Modified: 2010-04-16
How to enumerate files and folders in Windows XP (NTFS) on a very low level (no FindFirst or NTQueryFile). Perhaps the Win32API DeviceIoControl function with a FSCTL_ const?
Thanks for your hints & help!
Kann
0
Comment
Question by:Kann
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10767170
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 10769228
Is this OK? ;)

procedure FindFilesAndDirs(Directory : string; var DestList : TStringList);
var
  sr : TSearchRec;
  dirs : array of string;
  n : integer;
  s : string;
begin
Directory := StringReplace(Directory,'/','\',[rfReplaceAll]);
if Directory[length(Directory)] = '\' then SetLength(Directory, length(Directory) - 1);
SetLength(dirs, 1);
dirs[0] := Directory;
while Length(dirs) > 0 do begin
  if FindFirst(format('%s\*.*',[dirs[0]]),faAnyFile,sr) = 0 then while FindNext(sr) = 0 do begin
    s := format('%s\%s',[dirs[0], sr.Name]);
    if FileExists(s) then begin
      DestList.Add(s);
    end else if sr.Name <> '..' then begin
      SetLength(dirs,length(dirs)+1);
      dirs[high(dirs)] := s;
    end;
  end;
  for n := low(dirs) to high(dirs) - 1 do dirs[n] := dirs[n+1];
  SetLength(dirs,length(dirs) - 1);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  list : TStringList;
begin
list := TStringList.Create;
FindFilesAndDirs('C:\SomeDir',list);
ListBox1.Items := list;
list.Free;
end;
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10769264
I believe he stated "no FindFirst"

<smile>

Shane
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 10769452
ou.. Didn't see that 'no' ;) sorry..
0
 

Author Comment

by:Kann
ID: 10772396
shaneholmes, this source (VWIN32) can only be used with Win9x. I need information about NTFS (Windows XP). Any hints?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Kann
ID: 10772687
I found a solution, but there is no source code or documentation available :-(
"NtFsControlFile : FSCTL_READ_MFT_RECORD makes it possible to very efficiently determine what files are on a NTFS volume and where their clusters are located, but its use requires detailed knowledge of undocumented NTFS on-disk data structures, "

I think, this question is to difficult to find a solution...
0
 

Author Comment

by:Kann
ID: 10772730
If you have an answer you get also 500 points here (together 1000 points)
http://experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20946139.html
0
 
LVL 1

Expert Comment

by:fawndull
ID: 10779192
if u want low level, use assembly.  Here is the link.  It uses interrupts to get the files.  Is this what you want?


http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH13/CH13-6.html#HEADING6-176
0
 

Author Comment

by:Kann
ID: 10782213
Hi fawndull, low level applied to NTFS programming technics, not to the programming language ;-) (The link descripted an articel about MSDOS, Sep. 1996.)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11075745
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now