Skip to content

Commit

Permalink
Export context constructed from Raw MFT file. (#92)
Browse files Browse the repository at this point in the history
It is possible to create an ntfs context from an MFT raw file.
  • Loading branch information
scudette authored Jun 24, 2024
1 parent afc44f8 commit 9c6c647
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
21 changes: 21 additions & 0 deletions parser/easy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ type FileInfo struct {
SlackOffset int64 `json:"SlackOffset,omitempty"`
}

// Build an NTFS Context from the raw MFT file. NOTE: This approach
// has some shortcomings which callers should be aware of:

// 1. There is no image other than the provided MFT so any MFT
// attributes with external clusters will return empty data.

// 2. The cluster size and MFT record size are not known (These are
// specified in the boot sector) so callers will have to guess those.
func GetNTFSContextFromRawMFT(reader io.ReaderAt,
cluster_size int64,
record_size int64) *NTFSContext {

ntfs := newNTFSContext(&NullReader{}, "NullReader")

ntfs.MFTReader = reader
ntfs.ClusterSize = cluster_size
ntfs.RecordSize = record_size

return ntfs
}

func GetNTFSContext(image io.ReaderAt, offset int64) (*NTFSContext, error) {
ntfs := newNTFSContext(image, "GetNTFSContext")

Expand Down
6 changes: 2 additions & 4 deletions parser/mft.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,10 @@ func ParseMFTFileWithOptions(
go func() {
defer close(output)

ntfs := newNTFSContext(&NullReader{}, "NullReader")
ntfs := GetNTFSContextFromRawMFT(
reader, cluster_size, record_size)
defer ntfs.Close()

ntfs.MFTReader = reader
ntfs.ClusterSize = cluster_size
ntfs.RecordSize = record_size
ntfs.SetOptions(options)

for id := start_entry; id < size/record_size+1; id++ {
Expand Down

0 comments on commit 9c6c647

Please sign in to comment.