Solved

Enumerate files and folders in NTFS

Posted on 2004-04-06
11
1,157 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 327
Simple Delphi Question 9 96
Drag & Drop... Data from one grid to another 2 42
Installshield for Embarcadero EX 10.1 Berlin 4 60
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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