Solved

Enumerate files and folders in NTFS

Posted on 2004-04-06
11
1,153 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

11 Experts available now in Live!

Get 1:1 Help Now