Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7727735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:32:06+00:00 2026-06-01T05:32:06+00:00

I need to parse a RAM dump for MFT records (from the NTFS filesystem).

  • 0

I need to parse a RAM dump for MFT records (from the NTFS filesystem).

I’ve done some programming in the past with regard to reading headers of multiple files (using FileSearcher class, etc.), but I’m not entirely sure how to start reading from the start of a large file, read through it, and when a certain value is found I need to read in 1024 bytes from the point that the magic value is found (FILE0, in the case of MFT entries) and ‘do stuff’ with the values in between that and the end of the 1024 byte range. It then needs to carry on searching for the next FILE0 record.

So far I have the following – my intention is that it reads through the source file (which is a TFileStream) looking for ‘FILE0’. When it finds it, at this stage I just want it to report that it has found a record and output the position, but in due course I need it to then read a series of bytes from the point at which FILE0 was found:

type
    MFTRecordsStore = packed record
    FILE0MagicMarker: array[0..4] of byte;
    // Lots more follow....
end;

var
    MFTHeaderArray : MFTRecordsStore;
    FILE0Present : string;
    i : integer;

begin
    SourceFile.Position := 0;
    while (SourceFile.Position < SourceFile.Size) do
        begin
            SourceFile.ReadBuffer(MFTHeaderArray, SizeOf(MFTHeaderArray));
            for i := 0 to 4 do
                FILE0Present := FILE0Present + IntToHex(MFTHeaderArray.FILE0MagicMarker[i], 2);
                if FILE0Present = 'FILE0' then
                    begin
                        Memo1.Lines.Add('FILE0 Entry found at '+ IntToStr(SourceFile.Position));
                    end;
        end;
  end;

This code compiles and runs (it starts to parse the file), but after several minutes of heavy CPU usage the program crashes and reports that it cannot read the stream. I have a feeling this has something to do with getting to the end of the file and there not been a full ‘chunk’ left to read so it crashes?

What is the solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:32:07+00:00Added an answer on June 1, 2026 at 5:32 am

    I’m posting an example of how I would write and read file of records using streams and seek for a certain ANSI text in it. You may check also the commented version of this post.

    Here is the record definition used in this example:

    type
      TFileRecord = packed record
        Marker: array [0..4] of Byte;
        Width: Integer;
        Height: Integer;
        Useful: Boolean;
      end;
    

    Here is how to create such file of records (what you already have 🙂

    procedure TForm1.Button1Click(Sender: TObject);
    var
      FileStream: TFileStream;
      FileRecord: TFileRecord;
    const
      RecordSize = SizeOf(TFileRecord);
    
      procedure FillFileRecord(const AMarker: string; const AWidth: Integer;
        const AHeight: Integer; const AUseful: Boolean);
      begin
        FillChar(FileRecord, RecordSize, 0);
        Move(AMarker[1], FileRecord.Marker, Length(FileRecord.Marker));
        FileRecord.Width := AWidth;
        FileRecord.Height := AHeight;
        FileRecord.Useful := AUseful;
      end;
    
    begin
      FileStream := TFileStream.Create('File.dat', fmCreate);
      try
        FillFileRecord('FILE1', 111, 112, False);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE2', 211, 212, False);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE3', 311, 312, False);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE4', 411, 412, False);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE0', 666, 777, True);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE5', 511, 512, False);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE0', 11111, 22222, True);
        FileStream.Write(FileRecord, RecordSize);
        FillFileRecord('FILE6', 611, 612, False);
        FileStream.Write(FileRecord, RecordSize);
      finally
        FileStream.Free;
      end;
    end;
    

    And here is how to read such file:

    procedure TForm1.Button2Click(Sender: TObject);
    var
      FileStream: TFileStream;
      FileRecord: TFileRecord;
    const
      HeaderSeq = 'FILE0';
      HeaderLen = Length(HeaderSeq);
      RecordSize = SizeOf(TFileRecord);
    begin
      FileStream := TFileStream.Create('File.dat', fmOpenRead);
      try
        while FileStream.Read(FileRecord, RecordSize) = RecordSize do
        begin
          if CompareMem(@HeaderSeq[1], @FileRecord.Marker[0], HeaderLen) then
          begin
            Memo1.Lines.Add('FILE0 entry found at '+
              IntToStr(FileStream.Position - RecordSize));
            Memo1.Lines.Add('FileRecord.Width = ' +
              IntToStr(FileRecord.Width));
            Memo1.Lines.Add('FileRecord.Height = ' +
              IntToStr(FileRecord.Height));
            Memo1.Lines.Add('FileRecord.Useful = ' +
              BoolToStr(FileRecord.Useful, True));
          end;
        end;
      finally
        FileStream.Free;
      end;
    end;   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse a XML file from the website.I have went through some
I need parse through a file and do some processing into it. The file
I write my first module on nodejs. I need parse my site from google
I need to parse some files in the background mode. How can I do
I need to parse some scanned documents to textual data. Is it possible to
I need to parse the server response from my http post & puts. I
I need to parse a xml file using jQuery from an external domain. How
Hi I need parse and deserialize pseudo JSON string. Input data: {aBubbleData[ 'jaja2581' ]={
Need to parse a file for lines of data that start with this pattern
I need to parse a file but the data is in a strange format

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.